@kymoscope/sdk 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{importers-rg_Kg8Bl.js → importers-BVYsv8Vy.js} +1 -1
- package/dist/keys-Iv24Wam2.js +11 -0
- package/dist/kymoscope-embed.js +69 -69
- package/dist/kymoscope-sdk.js +3 -3
- package/dist/types/components/TreemapChart.d.ts +16 -0
- package/dist/types/lib/live/timeBuckets.d.ts +10 -4
- package/package.json +1 -1
- package/dist/keys-AcReVG65.js +0 -11
package/dist/kymoscope-sdk.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! @kymoscope/sdk (c) 2026 Kymoscope. Proprietary software: use requires a license. See LICENSE.md. */
|
|
2
|
-
import{$ as e,$t as t,A as n,At as r,B as i,Bt as a,C as o,Ct as s,D as c,Dt as l,E as u,Et as d,F as f,G as p,Gt as m,H as h,Ht as g,I as _,J as v,Jt as y,K as b,Kt as x,L as S,M as C,N as w,O as T,Ot as E,P as D,Q as O,Qt as k,R as A,S as j,St as M,T as N,Tt as P,U as F,Ut as I,V as L,Vt as R,W as z,Wt as B,X as V,Xt as ee,Y as te,Yt as H,Z as ne,Zt as re,_ as ie,_t as U,a as ae,at as oe,b as se,bt as ce,c as le,ct as ue,d as de,dt as fe,en as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,jt as we,k as Te,kt as Ee,l as De,lt as Oe,m as ke,mt as Ae,n as je,nn as Me,nt as Ne,o as Pe,ot as Fe,p as Ie,pt as Le,q as Re,qt as ze,r as Be,rt as Ve,st as He,tn as Ue,tt as We,u as Ge,ut as Ke,v as qe,w as Je,x as Ye,y as Xe,yt as Ze,z as Qe,zt as $e}from"./keys-AcReVG65.js";import{i as et,n as tt,r as nt,t as rt}from"./threshold-C9it0Y7P.js";import{createContext as it,forwardRef as at,memo as ot,startTransition as st,useCallback as ct,useContext as lt,useEffect as W,useImperativeHandle as ut,useLayoutEffect as G,useMemo as dt,useRef as K,useState as ft,useSyncExternalStore as pt}from"react";import{createPortal as mt}from"react-dom";import{createRoot as ht}from"react-dom/client";import{Fragment as gt,jsx as q,jsxs as _t}from"react/jsx-runtime";var vt=Object.create,yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,St=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,wt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tt=(e,t)=>{let n={};for(var r in e)yt(n,r,{get:e[r],enumerable:!0});return t||yt(n,Symbol.toStringTag,{value:`Module`}),n},Et=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ct.call(e,s)&&s!==n&&yt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bt(t,s))||r.enumerable});return e},Dt=(e,t,n)=>(n=e==null?{}:vt(St(e)),Et(t||!e||!e.__esModule?yt(n,`default`,{value:e,enumerable:!0}):n,e)),Ot=[`text`,`brush`,`arrow`,`box`],kt={text:14,brush:3,arrow:2,box:2},At=/^#[0-9a-fA-F]{6}$/,jt={text:[1,1],arrow:[2,2],box:[2,2],brush:[2,1/0]},Mt=e=>typeof e==`number`&&Number.isFinite(e);function Nt(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(!Ot.includes(n)||typeof t.id!=`string`||!t.id||!Array.isArray(t.points))return null;let r=t.points.filter(e=>Array.isArray(e)&&Mt(e[0])&&Mt(e[1])).map(([e,t])=>[e,t]),[i,a]=jt[n];return r.length<i||r.length>a?null:{id:t.id,kind:n,points:r,...t.anchor===`x`?{anchor:`x`}:{},color:typeof t.color==`string`&&At.test(t.color)?t.color:`#f5a524`,width:Mt(t.width)&&t.width>0?Math.min(96,t.width):kt[n],...typeof t.text==`string`&&t.text!==``?{text:t.text}:{}}}function Pt(e){return Array.isArray(e)?e.map(Nt).filter(e=>e!==null):null}var Ft={info:`#8a93a6`,warning:`#f5a524`,critical:`#e5484d`},It={info:`var(--text-muted, #8a93a6)`,warning:`var(--accent, #f5a524)`,critical:`var(--danger, #e5484d)`};function Lt(e,t){return{id:`mark:${e.id}`,kind:`box`,anchor:`x`,points:[[e.t0,0],[e.t1??t,1]],color:Ft[e.severity],width:1,...e.ruleName?{text:e.ruleName}:{}}}var Rt=96,zt=96,Bt=2,Vt={multiband:6,xyscatter:6,xyzmesh:6,histogram:6,polar:6,spectrum:6,boxplot:6,spectrogram:6,heatmap:6,violin:6,confusion:6,roc:6,losscurve:6,controlchart:6,parallelcoords:6,embedding:6,flamegraph:6,barchart:6,radar:6,areachart:6,cdfchart:6,bubblechart:6,treemap:6,sankey:6,calibration:6,qqplot:6,gantt:6,gauge:6,camera:6},Ht={multiband:24,xyscatter:24,xyzmesh:24,histogram:24,polar:24,spectrum:24,boxplot:24,spectrogram:24,heatmap:24,violin:24,confusion:24,roc:24,losscurve:24,controlchart:24,parallelcoords:24,embedding:24,flamegraph:24,barchart:24,radar:24,areachart:24,cdfchart:24,bubblechart:24,treemap:24,sankey:24,calibration:24,qqplot:24,gantt:24,gauge:24,camera:24},Ut=Vt,Wt=Ht;function Gt(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function Kt(e,t,n,r=96){let i=Vt[e],a=Ht[e],o=Math.max(i,Math.min(t.w,n-Math.max(0,t.x))),s=Math.max(a,Math.min(t.h,r-Math.max(0,t.y)));return{x:Math.max(0,Math.min(t.x,n-o)),y:Math.max(0,Math.min(t.y,r-s)),w:o,h:s}}function qt(e,t,n,r,i,a,o=96,s=96){let c=Math.round(r/Math.max(1e-6,a.width/o)),l=Math.round(i/Math.max(1e-6,a.height/s));return n===`move`?Kt(e,{...t,x:t.x+c,y:t.y+l},o,s):{...t,w:Math.max(Vt[e],Math.min(t.w+c,o-t.x)),h:Math.max(Ht[e],Math.min(t.h+l,s-t.y))}}function Jt(e,t,n){for(let r of t)if(r.id!==n&&Gt(e,r.rect))return!0;return!1}function Yt(e,t,n=96){let r=Vt[e],i=Ht[e],a=Math.min(48,n),o=e===`multiband`||e===`xyzmesh`?64:48;for(let i=0;i<384;i+=8)for(let s=0;s<=n-r;s+=8){let r=Kt(e,{x:s,y:i,w:a,h:o},n);if(!Jt(r,t,``))return r}return Kt(e,{x:0,y:0,w:r,h:i},n)}function Xt(e,t){return{id:crypto.randomUUID(),kind:e,rect:Yt(e,t)}}function Zt(e){if(e<=0)return[];if(e===1)return[{x:0,y:0,w:1,h:1}];if(e===2)return[{x:0,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1}];if(e===3)return[{x:0,y:0,w:.5,h:.5},{x:.5,y:0,w:.5,h:.5},{x:0,y:.5,w:1,h:.5}];if(e===4)return[{x:0,y:0,w:.5,h:.5},{x:.5,y:0,w:.5,h:.5},{x:0,y:.5,w:.5,h:.5},{x:.5,y:.5,w:.5,h:.5}];let t=Zt(e-4).map(e=>({x:e.x*.5,y:e.y,w:e.w*.5,h:e.h})),n=Zt(4).map(e=>({x:.5+e.x*.5,y:e.y,w:e.w*.5,h:e.h}));return[...t,...n]}function Qt(e,t=96,n=96){let r=Zt(e.length);return e.map((e,i)=>{let a=r[i];if(!a)return e;let o=Math.round(a.x*t),s=Math.round(a.y*n),c=Math.max(1,Math.round(a.w*t)),l=Math.max(1,Math.round(a.h*n));return{...e,rect:{x:o,y:s,w:c,h:l}}})}function $t(){return{scaleMin:``,scaleMax:``,majorStep:``,minorStep:``,alarm:null}}var en={style:`dashed`,width:1,color:null},tn={style:`solid`,width:1,color:null},nn={enabled:!1,reference:`previous`,datasetId:null,datasetColor:`#94a3b8`,previousColor:`#64748b`},rn=/^#[0-9a-f]{6}$/i;function an(e){if(!e||typeof e!=`object`)return;let t=e;return{enabled:t.enabled===!0,reference:t.reference===`dataset`||t.reference===`none`?t.reference:`previous`,datasetId:typeof t.datasetId==`string`&&t.datasetId?t.datasetId:null,datasetColor:typeof t.datasetColor==`string`&&rn.test(t.datasetColor)?t.datasetColor:nn.datasetColor,previousColor:typeof t.previousColor==`string`&&rn.test(t.previousColor)?t.previousColor:nn.previousColor}}var on=[`#f5a524`,`#38bdf8`,`#22c55e`,`#f472b6`,`#a78bfa`,`#fb7185`];function sn(e,t){return{id:crypto.randomUUID(),column:e,color:on[t%on.length],value:`last`,style:`arc`,min:``,max:``}}function cn(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(typeof n.column!=`string`)return null;let r=Zn(n.alarm);return{id:typeof n.id==`string`&&n.id?n.id:`g${t}`,column:n.column,color:typeof n.color==`string`?n.color:on[t%on.length],value:n.value===`mean`||n.value===`min`||n.value===`max`?n.value:`last`,style:n.style===`linear`?`linear`:`arc`,...n.fill===`zero`?{fill:`zero`}:{},min:typeof n.min==`string`?n.min:``,max:typeof n.max==`string`?n.max:``,...r?{alarm:r}:{},...n.colorMode===`gradient`||n.colorMode===`zones`?{colorMode:n.colorMode}:{},...Array.isArray(n.stops)?{stops:n.stops.flatMap(e=>{let t=e;return t&&typeof t.at==`number`&&Number.isFinite(t.at)&&typeof t.color==`string`?[{at:t.at,color:t.color}]:[]})}:{}}}function ln(e,t){let n=parseFloat(e),r=parseFloat(t);return Number.isFinite(n)&&Number.isFinite(r)&&n<r?[n,r]:void 0}var un=1.8,dn=4,fn=1;function pn(){return{kind:`multiband`,series:[],addColumn:``,layout:`overlay`,xAxisLine:{...en},yAxisLine:{...en},gridLine:{...tn},lineWidth:1}}function mn(e){return{kind:`xyscatter`,xyXCol:``,xyYCol:``,xyColorCol:null,xyColor:e,xyPointRadius:un,xyXAxisLine:{...en},xyYAxisLine:{...en},xyGridLine:{...tn},xyFit:null,xyXScale:$t(),xyYScale:$t()}}function hn(e=4){return{kind:`xyzmesh`,xyzXCol:``,xyzYCol:``,xyzZCol:``,xyzViewMode:`3d`,xyzXScale:$t(),xyzYScale:$t(),xyzZScale:$t(),xyzPointRadius:e,showMesh:!1,meshStyle:`filled`,meshOpacity:.85}}function gn(){return{kind:`histogram`,histColumn:``,histBins:0,histColor:`#38bdf8`,histNormal:!1,histLogY:!1}}function _n(){return{kind:`polar`,polarAngleCol:``,polarRadiusCol:``,polarColor:`#a78bfa`,polarMode:`waveform`,polarRadiusMin:``,polarRadiusMax:``}}function vn(){return{kind:`spectrum`,specSignalCol:``,specTimeCol:``,specSampleRate:`1000`,specXMode:`hz`,specYMode:`amplitude`,specWindow:`hann`,specColor:`#34d399`,specLogX:!1}}function yn(){return{kind:`boxplot`,boxValueCol:``,boxGroupCol:``,boxColor:`#fb923c`,boxWhiskers:`1.5iqr`}}function bn(){return{kind:`spectrogram`,sgSignalCol:``,sgTimeCol:``,sgSampleRate:`1000`,sgWindowSize:512,sgOverlap:.5,sgWinFunc:`hann`,sgYMode:`db`,sgLogFreq:!1}}function xn(){return{kind:`heatmap`,hmMode:`binned`,hmColumns:[],hmXCol:``,hmYCol:``,hmValueCol:``,hmXBins:6,hmYBins:6,hmXMin:``,hmXMax:``,hmYMin:``,hmYMax:``,hmShowValues:!0,hmColorScheme:`diverging`}}function Sn(){return{kind:`violin`,vlValueCol:``,vlGroupCol:``,vlColor:`#818cf8`,vlShowBox:!0,vlBandwidth:``,vlOrientation:`vertical`}}function Cn(){return{kind:`confusion`,cfActualCol:``,cfPredictedCol:``,cfNormalize:!1}}function wn(){return{kind:`roc`,rocScoreCol:``,rocLabelCol:``,rocMode:`roc`,rocColor:`#f472b6`}}function Tn(){return{kind:`losscurve`,lcXCol:``,lcLeftCols:[],lcRightCols:[]}}function En(){return{kind:`controlchart`,ccValueCol:``,ccSubgroupCol:``,ccSigmaLevel:3,ccColor:`#22d3ee`}}function Dn(){return{kind:`parallelcoords`,pcColumns:[],pcColorByCol:``,pcColor:`#64748b`}}function On(){return{kind:`embedding`,emXCol:``,emYCol:``,emColorCol:``,emColorMode:`categorical`,emLabelCol:``,emPointSize:3,emColor:`#a78bfa`}}function kn(){return{kind:`flamegraph`,fgNameCol:``,fgParentCol:``,fgValueCol:``,fgDirection:`topdown`}}function An(){return{kind:`barchart`,bcCategoryCol:``,bcValueCols:[],bcMode:`grouped`,bcHorizontal:!1}}function jn(){return{kind:`radar`,rdAxesCols:[],rdGroupCol:``,rdColor:`#38bdf8`,rdFill:!0}}function Mn(){return{kind:`areachart`,acXCol:``,acYCols:[],acStacked:!1}}function Nn(){return{kind:`cdfchart`,cdValueCols:[],cdComplement:!1,cdLogX:!1}}function Pn(){return{kind:`bubblechart`,bbXCol:``,bbYCol:``,bbSizeCol:``,bbColorCol:``,bbColorMode:`categorical`,bbColor:`#64748b`,bbMaxRadius:24}}function Fn(){return{kind:`treemap`,tmNameCol:``,tmParentCol:``,tmValueCol:``}}function In(){return{kind:`sankey`,skSourceCol:``,skTargetCol:``,skValueCol:``}}function Ln(){return{kind:`gauge`,ggGauges:[]}}function Rn(){return{kind:`calibration`,cbScoreCol:``,cbLabelCol:``,cbBins:10,cbColor:`#38bdf8`}}function zn(){return{kind:`qqplot`,qqValueCol:``,qqMode:`normal`,qqRefCol:``,qqColor:`#a78bfa`}}function Bn(){return{kind:`gantt`,gtLabelCol:``,gtStartCol:``,gtEndCol:``,gtGroupCol:``}}function Vn(e,t){let n=(e.parentId?t.find(t=>t.id===e.parentId)?.name:void 0)??e.parentName;return n?`${n} · ${e.name}`:e.name}var Hn=()=>({kind:`camera`,cameraStreamId:``,cameras:[],syncStreamId:``,offsetMs:0,fit:`contain`}),Un=9;function Wn(e){return e.cameraStreamId?e.cameras?.[0]===e.cameraStreamId?e.cameras.slice(0,9):[e.cameraStreamId]:[]}function Gn(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.column==`string`&&typeof t.color==`string`&&typeof t.bandFromPct==`number`&&typeof t.bandToPct==`number`&&typeof t.scaleMin==`number`&&typeof t.scaleMax==`number`&&typeof t.yMajorStep==`number`&&typeof t.yMinorStep==`number`}function Kn(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.style===`none`||t.style===`solid`||t.style===`dashed`||t.style===`dotted`)&&typeof t.width==`number`&&(t.color===null||typeof t.color==`string`)}function qn(e,t){return Kn(e)?e:{...t}}function Jn(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`multiband`&&Array.isArray(t.series)&&t.series.every(Gn)&&typeof t.addColumn==`string`}function Yn(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`xyscatter`&&typeof t.xyXCol==`string`&&typeof t.xyYCol==`string`&&typeof t.xyColor==`string`&&typeof t.xyPointRadius==`number`}function Xn(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.xyzViewMode,r=n===`3d`||n===`xy`||n===`xz`||n===`yz`;return t.kind===`xyzmesh`&&typeof t.xyzXCol==`string`&&typeof t.xyzYCol==`string`&&typeof t.xyzZCol==`string`&&r&&typeof t.xyzPointRadius==`number`}function Zn(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.value!=`number`||!Number.isFinite(t.value)||t.style!==`solid`&&t.style!==`dashed`&&t.style!==`dotted`||typeof t.width!=`number`||typeof t.color!=`string`?null:{value:t.value,style:t.style,width:t.width,color:t.color,...typeof t.ruleId==`string`&&Qn.test(t.ruleId)?{ruleId:t.ruleId}:{}}}var Qn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $n(e,t){if(!t.size)return e;let n=!1,r=e=>{let r=e?.ruleId?t.get(e.ruleId):void 0;return!e||!r?e:(n=!0,{...e,value:r.value,linked:r.active?`active`:`idle`})},i=e,a=null,o=(e,t)=>{a??={...i},a[e]=t};if(e.kind===`multiband`){let t=e.series.map(e=>{let t=r(e.alarm);return t===e.alarm?e:{...e,alarm:t}});n&&o(`series`,t)}else if(e.kind===`gauge`){let t=e.ggGauges.map(e=>{let t=r(e.alarm);return t===e.alarm?e:{...e,alarm:t}});n&&o(`ggGauges`,t)}else if(e.kind===`xyscatter`||e.kind===`xyzmesh`){let t=e.kind===`xyscatter`?[`xyXScale`,`xyYScale`]:[`xyzXScale`,`xyzYScale`,`xyzZScale`];for(let e of t){let t=i[e],n=r(t?.alarm);t&&n!==t.alarm&&o(e,{...t,alarm:n})}}else if(e.kind in er){let t=er[e.kind],n=r(i[t]);n!==i[t]&&o(t,n)}return a||e}var er={histogram:`histAlarm`,spectrum:`specAlarm`,areachart:`acAlarm`,losscurve:`lcAlarm`,cdfchart:`cdAlarm`,bubblechart:`bbAlarm`,boxplot:`boxAlarm`,violin:`vlAlarm`,barchart:`bcAlarm`,gantt:`gtAlarm`};function tr(e){if(!e||!(e.kind in er))return null;let t=e[er[e.kind]];return t?{alarm:t,axis:e.kind===`histogram`||e.kind===`cdfchart`||e.kind===`gantt`||e.kind===`barchart`&&e.bcHorizontal||e.kind===`violin`&&e.vlOrientation===`horizontal`?`x`:`y`}:null}function nr(e){let t=$t();if(!e||typeof e!=`object`)return t;let n=e,r=Zn(n.alarm);return{scaleMin:typeof n.scaleMin==`string`?n.scaleMin:t.scaleMin,scaleMax:typeof n.scaleMax==`string`?n.scaleMax:t.scaleMax,majorStep:typeof n.majorStep==`string`?n.majorStep:t.majorStep,minorStep:typeof n.minorStep==`string`?n.minorStep:t.minorStep,alarm:r}}function rr(e,t,n){if(!e||typeof e!=`object`)return{};let r={};for(let[t,n]of Object.entries(e)){if(!t||typeof t!=`string`)continue;if(Jn(n)){let e=n;r[t]={kind:`multiband`,series:Array.isArray(e.series)?e.series.map(e=>e&&e.alarm&&typeof e.alarm==`object`?{...e,alarm:Zn(e.alarm)}:e):e.series,addColumn:e.addColumn,layout:e.layout===`parallel`?`parallel`:`overlay`,xAxisLine:qn(e.xAxisLine,en),yAxisLine:qn(e.yAxisLine,en),gridLine:qn(e.gridLine,tn),lineWidth:typeof e.lineWidth==`number`&&Number.isFinite(e.lineWidth)?Math.min(6,Math.max(.5,e.lineWidth)):1,...an(e.beacon)?{beacon:an(e.beacon)}:{},...e.envelope===!0?{envelope:!0}:{}}}else if(Yn(n)){let e=n,i=e.xyFit,a=i&&typeof i==`object`&&(i.degree===1||i.degree===2||i.degree===3)&&typeof i.color==`string`&&(i.lineStyle===`solid`||i.lineStyle===`dashed`||i.lineStyle===`dotted`)&&typeof i.width==`number`?{degree:i.degree,color:i.color,lineStyle:i.lineStyle,width:i.width}:null;r[t]={...n,xyColorCol:typeof e.xyColorCol==`string`?e.xyColorCol:null,xyPointRadius:Math.min(16,Math.max(.5,n.xyPointRadius)),xyDrawMode:e.xyDrawMode===`lines`||e.xyDrawMode===`both`?e.xyDrawMode:void 0,xyLineWidth:typeof e.xyLineWidth==`number`&&Number.isFinite(e.xyLineWidth)?Math.min(8,Math.max(.5,e.xyLineWidth)):void 0,xyXAxisLine:qn(e.xyXAxisLine,en),xyYAxisLine:qn(e.xyYAxisLine,en),xyGridLine:qn(e.xyGridLine,tn),xyFit:a,xyXScale:nr(e.xyXScale),xyYScale:nr(e.xyYScale)}}else if(Xn(n)){let e=e=>typeof e==`string`?e:``,i=n.xyzXScale?null:{scaleMin:e(n.xyzXMin),scaleMax:e(n.xyzXMax),majorStep:``,minorStep:``,alarm:null},a=n.xyzYScale?null:{scaleMin:e(n.xyzYMin),scaleMax:e(n.xyzYMax),majorStep:``,minorStep:``,alarm:null},o=n.xyzZScale?null:{scaleMin:e(n.xyzZMin),scaleMax:e(n.xyzZMax),majorStep:``,minorStep:``,alarm:null};r[t]={kind:`xyzmesh`,xyzXCol:n.xyzXCol,xyzYCol:n.xyzYCol,xyzZCol:n.xyzZCol,xyzViewMode:n.xyzViewMode,xyzXScale:i??nr(n.xyzXScale),xyzYScale:a??nr(n.xyzYScale),xyzZScale:o??nr(n.xyzZScale),xyzPointRadius:Math.min(16,Math.max(.5,n.xyzPointRadius)),showMesh:n.showMesh===!0,meshStyle:n.meshStyle===`wireframe`||n.meshStyle===`both`?n.meshStyle:`filled`,meshOpacity:typeof n.meshOpacity==`number`&&n.meshOpacity>=0&&n.meshOpacity<=1?n.meshOpacity:.85,...n.xyzMode===`matrix`?{xyzMode:`matrix`}:{},...Array.isArray(n.xyzColumns)?{xyzColumns:n.xyzColumns.filter(e=>typeof e==`string`)}:{}}}else if(n&&typeof n==`object`&&n.kind===`histogram`){let e=n;r[t]={kind:`histogram`,histColumn:typeof e.histColumn==`string`?e.histColumn:``,histBins:typeof e.histBins==`number`?e.histBins:0,histColor:typeof e.histColor==`string`?e.histColor:`#38bdf8`,histNormal:e.histNormal===!0,histLogY:e.histLogY===!0}}else if(n&&typeof n==`object`&&n.kind===`polar`){let e=n;r[t]={kind:`polar`,polarAngleCol:typeof e.polarAngleCol==`string`?e.polarAngleCol:``,polarRadiusCol:typeof e.polarRadiusCol==`string`?e.polarRadiusCol:``,polarColor:typeof e.polarColor==`string`?e.polarColor:`#a78bfa`,polarMode:e.polarMode===`rose`?`rose`:`waveform`,polarRadiusMin:typeof e.polarRadiusMin==`string`?e.polarRadiusMin:``,polarRadiusMax:typeof e.polarRadiusMax==`string`?e.polarRadiusMax:``}}else if(n&&typeof n==`object`&&n.kind===`spectrum`){let e=n;r[t]={kind:`spectrum`,specSignalCol:typeof e.specSignalCol==`string`?e.specSignalCol:``,specTimeCol:typeof e.specTimeCol==`string`?e.specTimeCol:``,specSampleRate:typeof e.specSampleRate==`string`?e.specSampleRate:`1000`,specXMode:e.specXMode===`order`?`order`:`hz`,specYMode:e.specYMode===`db`?`db`:`amplitude`,specWindow:e.specWindow===`rectangular`?`rectangular`:`hann`,specColor:typeof e.specColor==`string`?e.specColor:`#34d399`,specLogX:e.specLogX===!0}}else if(n&&typeof n==`object`&&n.kind===`boxplot`){let e=n;r[t]={kind:`boxplot`,boxValueCol:typeof e.boxValueCol==`string`?e.boxValueCol:``,boxGroupCol:typeof e.boxGroupCol==`string`?e.boxGroupCol:``,boxColor:typeof e.boxColor==`string`?e.boxColor:`#fb923c`,boxWhiskers:e.boxWhiskers===`minmax`?`minmax`:`1.5iqr`}}else if(n&&typeof n==`object`&&n.kind===`spectrogram`){let e=n;r[t]={kind:`spectrogram`,sgSignalCol:typeof e.sgSignalCol==`string`?e.sgSignalCol:``,sgTimeCol:typeof e.sgTimeCol==`string`?e.sgTimeCol:``,sgSampleRate:typeof e.sgSampleRate==`string`?e.sgSampleRate:`1000`,sgWindowSize:typeof e.sgWindowSize==`number`?e.sgWindowSize:512,sgOverlap:typeof e.sgOverlap==`number`?e.sgOverlap:.5,sgWinFunc:e.sgWinFunc===`rectangular`?`rectangular`:`hann`,sgYMode:e.sgYMode===`amplitude`?`amplitude`:`db`,sgLogFreq:e.sgLogFreq===!0,...e.sgView===`waterfall`?{sgView:`waterfall`}:{}}}else if(n&&typeof n==`object`&&n.kind===`heatmap`){let e=n,i=Array.isArray(e.hmColumns)?e.hmColumns.filter(e=>typeof e==`string`):[],a=e=>Math.max(1,Math.min(50,typeof e==`number`&&Number.isFinite(e)?Math.floor(e):6)),o=e=>typeof e==`string`?e:``;r[t]={kind:`heatmap`,hmMode:e.hmMode===`raw`||e.hmMode===`binned`||e.hmMode===`count`||e.hmMode===`correlation`||e.hmMode===`matrix`?e.hmMode:`binned`,hmColumns:i,hmXCol:o(e.hmXCol),hmYCol:o(e.hmYCol),hmValueCol:o(e.hmValueCol),hmXBins:a(e.hmXBins),hmYBins:a(e.hmYBins),hmXMin:o(e.hmXMin),hmXMax:o(e.hmXMax),hmYMin:o(e.hmYMin),hmYMax:o(e.hmYMax),hmShowValues:e.hmShowValues!==!1,hmColorScheme:e.hmColorScheme===`plasma`||e.hmColorScheme===`viridis`?e.hmColorScheme:`diverging`,...e.hmSpacing===`values`?{hmSpacing:`values`}:{},...typeof e.hmContours==`number`&&e.hmContours>=1?{hmContours:Math.min(20,Math.round(e.hmContours))}:{},...e.hmRange&&typeof e.hmRange==`object`?{hmRange:{scaleMin:typeof e.hmRange.scaleMin==`string`?e.hmRange.scaleMin:``,scaleMax:typeof e.hmRange.scaleMax==`string`?e.hmRange.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`violin`){let e=n;r[t]={kind:`violin`,vlValueCol:typeof e.vlValueCol==`string`?e.vlValueCol:``,vlGroupCol:typeof e.vlGroupCol==`string`?e.vlGroupCol:``,vlColor:typeof e.vlColor==`string`?e.vlColor:`#818cf8`,vlShowBox:e.vlShowBox!==!1,vlBandwidth:typeof e.vlBandwidth==`string`?e.vlBandwidth:``,vlOrientation:e.vlOrientation===`horizontal`?`horizontal`:`vertical`}}else if(n&&typeof n==`object`&&n.kind===`confusion`){let e=n;r[t]={kind:`confusion`,cfActualCol:typeof e.cfActualCol==`string`?e.cfActualCol:``,cfPredictedCol:typeof e.cfPredictedCol==`string`?e.cfPredictedCol:``,cfNormalize:e.cfNormalize===!0}}else if(n&&typeof n==`object`&&n.kind===`roc`){let e=n;r[t]={kind:`roc`,rocScoreCol:typeof e.rocScoreCol==`string`?e.rocScoreCol:``,rocLabelCol:typeof e.rocLabelCol==`string`?e.rocLabelCol:``,rocMode:e.rocMode===`pr`?`pr`:`roc`,rocColor:typeof e.rocColor==`string`?e.rocColor:`#f472b6`}}else if(n&&typeof n==`object`&&n.kind===`losscurve`){let e=n,i=e=>Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.column==`string`&&typeof e.color==`string`):[];r[t]={kind:`losscurve`,lcXCol:typeof e.lcXCol==`string`?e.lcXCol:``,lcLeftCols:i(e.lcLeftCols),lcRightCols:i(e.lcRightCols)}}else if(n&&typeof n==`object`&&n.kind===`controlchart`){let e=n;r[t]={kind:`controlchart`,ccValueCol:typeof e.ccValueCol==`string`?e.ccValueCol:``,ccSubgroupCol:typeof e.ccSubgroupCol==`string`?e.ccSubgroupCol:``,ccSigmaLevel:typeof e.ccSigmaLevel==`number`?e.ccSigmaLevel:3,ccColor:typeof e.ccColor==`string`?e.ccColor:`#22d3ee`}}else if(n&&typeof n==`object`&&n.kind===`parallelcoords`){let e=n;r[t]={kind:`parallelcoords`,pcColumns:Array.isArray(e.pcColumns)?e.pcColumns.filter(e=>typeof e==`string`):[],pcColorByCol:typeof e.pcColorByCol==`string`?e.pcColorByCol:``,pcColor:typeof e.pcColor==`string`?e.pcColor:`#64748b`}}else if(n&&typeof n==`object`&&n.kind===`embedding`){let e=n;r[t]={kind:`embedding`,emXCol:typeof e.emXCol==`string`?e.emXCol:``,emYCol:typeof e.emYCol==`string`?e.emYCol:``,emColorCol:typeof e.emColorCol==`string`?e.emColorCol:``,emColorMode:e.emColorMode===`numeric`?`numeric`:`categorical`,emLabelCol:typeof e.emLabelCol==`string`?e.emLabelCol:``,emPointSize:typeof e.emPointSize==`number`?e.emPointSize:3,emColor:typeof e.emColor==`string`?e.emColor:`#a78bfa`}}else if(n&&typeof n==`object`&&n.kind===`flamegraph`){let e=n;r[t]={kind:`flamegraph`,fgNameCol:typeof e.fgNameCol==`string`?e.fgNameCol:``,fgParentCol:typeof e.fgParentCol==`string`?e.fgParentCol:``,fgValueCol:typeof e.fgValueCol==`string`?e.fgValueCol:``,fgDirection:e.fgDirection===`bottomup`?`bottomup`:`topdown`}}else if(n&&typeof n==`object`&&n.kind===`barchart`){let e=n,i=Array.isArray(e.bcValueCols)?e.bcValueCols.filter(e=>typeof e==`string`):[],a=e.bcValueScale;r[t]={kind:`barchart`,bcCategoryCol:typeof e.bcCategoryCol==`string`?e.bcCategoryCol:``,bcValueCols:i,bcMode:e.bcMode===`stacked`?`stacked`:`grouped`,bcHorizontal:e.bcHorizontal===!0,...a&&typeof a==`object`?{bcValueScale:{scaleMin:typeof a.scaleMin==`string`?a.scaleMin:``,scaleMax:typeof a.scaleMax==`string`?a.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`radar`){let e=n;r[t]={kind:`radar`,rdAxesCols:Array.isArray(e.rdAxesCols)?e.rdAxesCols.filter(e=>typeof e==`string`):[],rdGroupCol:typeof e.rdGroupCol==`string`?e.rdGroupCol:``,rdColor:typeof e.rdColor==`string`?e.rdColor:`#38bdf8`,rdFill:e.rdFill!==!1}}else if(n&&typeof n==`object`&&n.kind===`areachart`){let e=n,i=Array.isArray(e.acYCols)?e.acYCols.filter(e=>typeof e==`string`):[],a=e.acYScale;r[t]={kind:`areachart`,acXCol:typeof e.acXCol==`string`?e.acXCol:``,acYCols:i,acStacked:e.acStacked===!0,...a&&typeof a==`object`?{acYScale:{scaleMin:typeof a.scaleMin==`string`?a.scaleMin:``,scaleMax:typeof a.scaleMax==`string`?a.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`cdfchart`){let e=n;r[t]={kind:`cdfchart`,cdValueCols:Array.isArray(e.cdValueCols)?e.cdValueCols.filter(e=>typeof e==`string`):[],cdComplement:e.cdComplement===!0,cdLogX:e.cdLogX===!0}}else if(n&&typeof n==`object`&&n.kind===`bubblechart`){let e=n;r[t]={kind:`bubblechart`,bbXCol:typeof e.bbXCol==`string`?e.bbXCol:``,bbYCol:typeof e.bbYCol==`string`?e.bbYCol:``,bbSizeCol:typeof e.bbSizeCol==`string`?e.bbSizeCol:``,bbColorCol:typeof e.bbColorCol==`string`?e.bbColorCol:``,bbColorMode:e.bbColorMode===`numeric`?`numeric`:`categorical`,bbColor:typeof e.bbColor==`string`?e.bbColor:`#64748b`,bbMaxRadius:typeof e.bbMaxRadius==`number`?e.bbMaxRadius:24}}else if(n&&typeof n==`object`&&n.kind===`treemap`){let e=n;r[t]={kind:`treemap`,tmNameCol:typeof e.tmNameCol==`string`?e.tmNameCol:``,tmParentCol:typeof e.tmParentCol==`string`?e.tmParentCol:``,tmValueCol:typeof e.tmValueCol==`string`?e.tmValueCol:``}}else if(n&&typeof n==`object`&&n.kind===`sankey`){let e=n;r[t]={kind:`sankey`,skSourceCol:typeof e.skSourceCol==`string`?e.skSourceCol:``,skTargetCol:typeof e.skTargetCol==`string`?e.skTargetCol:``,skValueCol:typeof e.skValueCol==`string`?e.skValueCol:``}}else if(n&&typeof n==`object`&&n.kind===`gauge`){let e=n;r[t]={kind:`gauge`,ggGauges:Array.isArray(e.ggGauges)?e.ggGauges.flatMap((e,t)=>{let n=cn(e,t);return n?[n]:[]}):[]}}else if(n&&typeof n==`object`&&n.kind===`calibration`){let e=n;r[t]={kind:`calibration`,cbScoreCol:typeof e.cbScoreCol==`string`?e.cbScoreCol:``,cbLabelCol:typeof e.cbLabelCol==`string`?e.cbLabelCol:``,cbBins:typeof e.cbBins==`number`?e.cbBins:10,cbColor:typeof e.cbColor==`string`?e.cbColor:`#38bdf8`}}else if(n&&typeof n==`object`&&n.kind===`qqplot`){let e=n;r[t]={kind:`qqplot`,qqValueCol:typeof e.qqValueCol==`string`?e.qqValueCol:``,qqMode:e.qqMode===`column`?`column`:`normal`,qqRefCol:typeof e.qqRefCol==`string`?e.qqRefCol:``,qqColor:typeof e.qqColor==`string`?e.qqColor:`#a78bfa`}}else if(n&&typeof n==`object`&&n.kind===`gantt`){let e=n;r[t]={kind:`gantt`,gtLabelCol:typeof e.gtLabelCol==`string`?e.gtLabelCol:``,gtStartCol:typeof e.gtStartCol==`string`?e.gtStartCol:``,gtEndCol:typeof e.gtEndCol==`string`?e.gtEndCol:``,gtGroupCol:typeof e.gtGroupCol==`string`?e.gtGroupCol:``}}else if(n&&typeof n==`object`&&n.kind===`camera`){let e=n,i=typeof e.offsetMs==`number`&&Number.isFinite(e.offsetMs)?Math.round(e.offsetMs):0,a=Array.isArray(e.cameras)?[...new Set(e.cameras.filter(e=>typeof e==`string`&&e!==``))]:[],o=typeof e.cameraStreamId==`string`&&e.cameraStreamId?e.cameraStreamId:a[0]??``;r[t]={kind:`camera`,cameraStreamId:o,cameras:Wn({cameraStreamId:o,cameras:a.length?a:[o]}),syncStreamId:typeof e.syncStreamId==`string`?e.syncStreamId:``,offsetMs:Math.max(-1e4,Math.min(1e4,i)),fit:e.fit===`cover`?`cover`:`contain`}}let e=r[t]?Pt(n?.annotations):null;e?.length&&(r[t]={...r[t],annotations:e});let i=r[t]?er[r[t].kind]:void 0,a=i?Zn(n[i]):null;i&&a&&(r[t]={...r[t],[i]:a})}return r}function ir(e,t,n,r){let i={...t},a=!1;for(let t of e)if(t.kind===`multiband`){let e=i[t.id];(!e||e.kind!==`multiband`)&&(i[t.id]=pn(),a=!0)}else if(t.kind===`xyscatter`){let e=i[t.id];(!e||e.kind!==`xyscatter`)&&(i[t.id]=mn(n),a=!0)}else if(t.kind===`xyzmesh`){let e=i[t.id];(!e||e.kind!==`xyzmesh`)&&(i[t.id]=hn(r),a=!0)}else if(t.kind===`histogram`){let e=i[t.id];(!e||e.kind!==`histogram`)&&(i[t.id]=gn(),a=!0)}else if(t.kind===`polar`){let e=i[t.id];(!e||e.kind!==`polar`)&&(i[t.id]=_n(),a=!0)}else if(t.kind===`spectrum`){let e=i[t.id];(!e||e.kind!==`spectrum`)&&(i[t.id]=vn(),a=!0)}else if(t.kind===`boxplot`){let e=i[t.id];(!e||e.kind!==`boxplot`)&&(i[t.id]=yn(),a=!0)}else t.kind===`spectrogram`?(!i[t.id]||i[t.id].kind!==`spectrogram`)&&(i[t.id]=bn(),a=!0):t.kind===`heatmap`?(!i[t.id]||i[t.id].kind!==`heatmap`)&&(i[t.id]=xn(),a=!0):t.kind===`violin`?(!i[t.id]||i[t.id].kind!==`violin`)&&(i[t.id]=Sn(),a=!0):t.kind===`confusion`?(!i[t.id]||i[t.id].kind!==`confusion`)&&(i[t.id]=Cn(),a=!0):t.kind===`roc`?(!i[t.id]||i[t.id].kind!==`roc`)&&(i[t.id]=wn(),a=!0):t.kind===`losscurve`?(!i[t.id]||i[t.id].kind!==`losscurve`)&&(i[t.id]=Tn(),a=!0):t.kind===`controlchart`?(!i[t.id]||i[t.id].kind!==`controlchart`)&&(i[t.id]=En(),a=!0):t.kind===`parallelcoords`?(!i[t.id]||i[t.id].kind!==`parallelcoords`)&&(i[t.id]=Dn(),a=!0):t.kind===`embedding`?(!i[t.id]||i[t.id].kind!==`embedding`)&&(i[t.id]=On(),a=!0):t.kind===`flamegraph`?(!i[t.id]||i[t.id].kind!==`flamegraph`)&&(i[t.id]=kn(),a=!0):t.kind===`barchart`?(!i[t.id]||i[t.id].kind!==`barchart`)&&(i[t.id]=An(),a=!0):t.kind===`radar`?(!i[t.id]||i[t.id].kind!==`radar`)&&(i[t.id]=jn(),a=!0):t.kind===`areachart`?(!i[t.id]||i[t.id].kind!==`areachart`)&&(i[t.id]=Mn(),a=!0):t.kind===`cdfchart`?(!i[t.id]||i[t.id].kind!==`cdfchart`)&&(i[t.id]=Nn(),a=!0):t.kind===`bubblechart`?(!i[t.id]||i[t.id].kind!==`bubblechart`)&&(i[t.id]=Pn(),a=!0):t.kind===`treemap`?(!i[t.id]||i[t.id].kind!==`treemap`)&&(i[t.id]=Fn(),a=!0):t.kind===`sankey`?(!i[t.id]||i[t.id].kind!==`sankey`)&&(i[t.id]=In(),a=!0):t.kind===`gauge`?(!i[t.id]||i[t.id].kind!==`gauge`)&&(i[t.id]=Ln(),a=!0):t.kind===`calibration`?(!i[t.id]||i[t.id].kind!==`calibration`)&&(i[t.id]=Rn(),a=!0):t.kind===`qqplot`?(!i[t.id]||i[t.id].kind!==`qqplot`)&&(i[t.id]=zn(),a=!0):t.kind===`gantt`?(!i[t.id]||i[t.id].kind!==`gantt`)&&(i[t.id]=Bn(),a=!0):t.kind===`camera`&&(!i[t.id]||i[t.id].kind!==`camera`)&&(i[t.id]=Hn(),a=!0);for(let t of Object.keys(i))e.some(e=>e.id===t)||(delete i[t],a=!0);return a?i:t}function ar(e){return e===null||typeof e==`number`&&e>0?{liveWindowSeconds:e}:{}}function or(e){return Number.isNaN(e)?0:Math.min(100,Math.max(0,e))}function sr(){return crypto.randomUUID()}function cr(e={}){let t=Date.now();return{id:crypto.randomUUID(),name:``,units:``,formula:``,enabled:!0,createdAt:t,updatedAt:t,source:`personal`,sharedWithOrgId:null,projectId:null,ownerUserId:``,ownerDisplayName:null,ownerLastName:null,...e}}function lr(){return lr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lr.apply(null,arguments)}var ur={relTol:1e-12,absTol:1e-15,matrix:`Matrix`,number:`number`,numberFallback:`number`,precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function dr(e,t){if(pr(e,t)||mr(e,t))return e[t];throw _r(e,t)?Error(`Cannot access method "${t}" as a property`):e==null?TypeError(`Cannot access property "${t}": object is ${e}`):Error(`No access to property "`+t+`"`)}function fr(e,t,n){if(pr(e,t)||mr(e,t))return e[t]=n,n;throw Error(`No access to property "${t}"`)}function pr(e,t){return vr(e)?!(t in Object.prototype):!1}function mr(e,t){return Array.isArray(e)?typeof t==`number`||typeof t==`string`&&hr(t)||t===`length`:!1}function hr(e){return/^\d+$/.test(e)}function gr(e,t){if(!_r(e,t))throw Error(`No access to method "`+t+`"`);return e[t]}function _r(e,t){return e==null||typeof e[t]!=`function`||Ti(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)?!1:yr.has(t)?!0:!(t in Object.prototype||t in Function.prototype)}function vr(e){return typeof e==`object`&&e&&e.constructor===Object}var yr=new Set([`toString`,`valueOf`,`toLocaleString`]),br=class{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(e=>this.has(e)).values()}get(e){return dr(this.wrappedObject,e)}set(e,t){return fr(this.wrappedObject,e,t),this}has(e){return pr(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Sr(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){pr(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},xr=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return Sr(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function Sr(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function Cr(){return new Map}function wr(e){if(!e)return Cr();if(qr(e))return e;if(Kr(e))return new br(e);throw Error(`createMap can create maps from objects or Maps`)}function Tr(e){if(e instanceof br)return e.wrappedObject;var t={};for(var n of e.keys())fr(t,n,e.get(n));return t}function Er(e){return typeof e==`number`}function Dr(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function Or(e){return typeof e==`bigint`}function kr(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function Ar(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function jr(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Mr(e){return typeof e==`string`}var Nr=Array.isArray;function Pr(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function Fr(e){return Array.isArray(e)||Pr(e)}function Ir(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Lr(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Rr(e){return e&&e.constructor.prototype.isRange===!0||!1}function zr(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Br(e){return typeof e==`boolean`}function Vr(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Hr(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Ur(e){return typeof e==`function`}function Wr(e){return e instanceof Date}function Gr(e){return e instanceof RegExp}function Kr(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!kr(e)&&!Ar(e))}function qr(e){return e?e instanceof Map||e instanceof br||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function Jr(e){return qr(e)&&qr(e.a)&&qr(e.b)}function Yr(e){return qr(e)&&Kr(e.wrappedObject)}function Xr(e){return e===null}function Zr(e){return e===void 0}function Qr(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function $r(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function ei(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ti(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function ni(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function ri(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function ii(e){return ri(e)||ui(e)&&e.args.length===1&&ri(e.args[0])&&`-+~`.includes(e.op)}function ai(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function oi(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function si(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function ci(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function li(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function ui(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function di(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function fi(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function pi(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function mi(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function hi(e){return e&&e.constructor.prototype.isChain===!0||!1}function gi(e){var t=typeof e;return t===`object`?e===null?`null`:Dr(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function _i(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return _i(e)});if(e instanceof Date)return new Date(e.valueOf());if(Dr(e))return e;if(Kr(e))return vi(e,_i);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function vi(e,t){var n={};for(var r in e)Ti(e,r)&&(n[r]=t(e[r]));return n}function yi(e,t){for(var n in t)Ti(t,n)&&(e[n]=t[n]);return e}function bi(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(Ti(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?bi(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function xi(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r<i;r++)if(!xi(e[r],t[r]))return!1;return!0}else if(typeof e==`function`)return e===t;else if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!(n in t)||!xi(e[n],t[n]))return!1;for(n in t)if(!(n in e))return!1;return!0}else return e===t}function Si(e){var t={};return Ci(e,t),t}function Ci(e,t){for(var n in e)if(Ti(e,n)){var r=e[n];typeof r==`object`&&r?Ci(r,t):t[n]=r}}function wi(e,t,n){var r=!0,i;Object.defineProperty(e,t,{get:function(){return r&&=(i=n(),!1),i},set:function(e){i=e,r=!1},configurable:!0,enumerable:!0})}function Ti(e,t){return e&&Object.hasOwnProperty.call(e,t)}function Ei(e){return e&&typeof e.factory==`function`}function Di(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r],a=e[i];a!==void 0&&(n[i]=a)}return n}var Oi=[`Matrix`,`Array`],ki=[`number`,`BigNumber`,`bigint`,`Fraction`];function Ai(e,t){function n(r){if(r){if(r.epsilon!==void 0){console.warn(`Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.`);var i=_i(r);return i.relTol=r.epsilon,i.absTol=r.epsilon*.001,delete i.epsilon,n(i)}r.legacySubset===!0&&console.warn(`Warning: The configuration option "legacySubset" is for compatibility only and might be deprecated in the future.`);var a=_i(e);ji(r,`matrix`,Oi),ji(r,`number`,ki),bi(e,r);var o=_i(e);return t(`config`,o,a,_i(r)),o}else return _i(e)}return n.MATRIX_OPTIONS=Oi,n.NUMBER_OPTIONS=ki,Object.keys(ur).forEach(t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function ji(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}var Mi=wt(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t<e.length;++t){if(!e[t]||typeof e[t].name!=`string`||typeof e[t].test!=`function`)throw TypeError(`Object with properties {name: string, test: function} expected`);let i=e[t].name;if(c.has(i))throw TypeError(`Duplicate type name "`+i+`"`);r.push(i),c.set(i,{name:i,test:e[t].test,isAny:e[t].isAny,index:n+t,conversionsTo:[]})}let i=l.slice(n);l=l.slice(0,n).concat(r).concat(i);for(let e=n+r.length;e<l.length;++e)c.get(l[e]).index=e}function m(){c=new Map,l=[],u=0,p([s],!1)}m(),p(o);function h(){let e;for(e of l)c.get(e).conversionsTo=[];u=0}function g(e){let t=l.filter(t=>{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=T(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e<s;++e){let t=a[e],n=[],r;for(r of c){let i=k(r.params,e);if(!(!i||t.restParam&&!i.restParam)){if(!i.hasAny){let e=w(i);if(t.types.some(t=>!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t<r.length;t++)if(f(r[t].from).test(e))return r[t].convert(e);throw Error(`Cannot convert `+e+` to `+t)}function x(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,i+=e.name+`|`,{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function C(e){let t=R(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function T(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e<r.length;++e){let n=S(r[e].trim());if(n.restParam&&e!==r.length-1)throw SyntaxError(`Unexpected rest parameter "`+r[e]+`": only allowed for the last parameter`);if(n.types.length===0)return null;t.push(n)}return t}function E(e){let t=oe(e);return t?t.restParam:!1}function D(t){if(!t||t.types.length===0)return e;if(t.types.length===1)return f(t.types[0].name).test;if(t.types.length===2){let e=f(t.types[0].name).test,n=f(t.types[1].name).test;return function(t){return e(t)||n(t)}}else{let e=t.types.map(function(e){return f(e.name).test});return function(t){for(let n=0;n<e.length;n++)if(e[n](t))return!0;return!1}}}function O(e){let t,n,r;if(E(e)){t=ae(e).map(D);let n=t.length,r=D(oe(e)),i=function(e){for(let t=n;t<e.length;t++)if(!r(e[t]))return!1;return!0};return function(e){for(let n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return i(e)&&e.length>=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=D(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=D(e[0]),r=D(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(D),function(e){for(let n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return e.length===t.length}}function k(e,t){return t<e.length?e[t]:E(e)?oe(e):null}function A(e,t){let n=k(e,t);return n?w(n):new Set}function j(e){return e.conversion===null||e.conversion===void 0}function M(e,t){let n=new Set;return e.forEach(e=>{let r=A(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function N(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s<t.length;s++){let e=[];if(o.forEach(n=>{let r=D(k(n.params,s));(s<n.params.length||E(n.params))&&r(t[s])&&e.push(n)}),e.length===0){if(i=M(o,s),i.length>0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return E(e.params)?1/0:e.params.length});if(t.length<Math.min.apply(null,c))return i=M(o,s),r=TypeError(`Too few arguments in function `+a+` (expected: `+i.join(` or `)+`, index: `+t.length+`)`),r.data={category:`tooFewArgs`,fn:a,index:t.length,expected:i},r;let l=Math.max.apply(null,c);if(t.length>l)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e<t.length;++e)u.push(g(t[e]).join(`|`));return r=TypeError(`Arguments of type "`+u.join(`, `)+`" do not match any of the defined signatures of function `+a+`.`),r.data={category:`mismatch`,actual:u},r}function P(e){let t=l.length+1;for(let n=0;n<e.types.length;n++)t=Math.min(t,e.types[n].typeIndex);return t}function F(e){let t=u+1;for(let n=0;n<e.types.length;n++)j(e.types[n])||(t=Math.min(t,e.types[n].conversionIndex));return t}function I(e,t){if(e.hasAny){if(!t.hasAny)return .1}else if(t.hasAny)return-.1;if(e.restParam){if(!t.restParam)return .01}else if(t.restParam)return-.01;let n=P(e)-P(t);if(n<0)return-.001;if(n>0)return .001;let r=F(e),i=F(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function L(e,t){let n=e.params,r=t.params,i=oe(n),a=oe(r),o=E(n),s=E(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;e<n.length;++e){let t=I(n[e],r[e]);m.push(t),h+=t}if(h!==0)return(h<0?-10:10)+h;let g,_=9,v=_/(m.length+1);for(g of m){if(g!==0)return(g<0?-_:_)+g;_-=v}return 0}function R(e){if(e.length===0)return[];let t=e.map(f);if(e.length===1)return t[0].conversionsTo;let n=new Set(e),r=new Set;for(let e=0;e<t.length;++e)for(let i of t[e].conversionsTo)n.has(i.from)||r.add(i.from);let i=[];for(let e of r){let n=u+1,r=null;for(let i=0;i<t.length;++i)for(let a of t[i].conversionsTo)a.from===e&&a.index<n&&(n=a.index,r=a);i.push(r)}return i}function z(e,t){let n=t,r=``;if(e.some(e=>e.hasConversion)){let i=E(e),a=e.map(B);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t<n;t++)e[t]=a[t](arguments[t]);return i&&(e[n]=arguments[n].map(a[n])),t.apply(this,e)}}let i=n;if(E(e)){let t=e.length-1;i=function(){return n.apply(this,se(arguments,0,t).concat([se(arguments,t)]))}}return r&&Object.defineProperty(i,`name`,{value:r}),i}function B(e){let t,n,r,i,a=[],o=[],s=``;e.types.forEach(function(e){e.conversion&&(s+=e.conversion.from+`~>`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;t<o.length;t++)if(a[t](e))return o[t](e);return e}}return Object.defineProperty(c,`name`,{value:s}),c}function V(e){function t(e,n,r){if(n<e.length){let i=e[n],a=[];if(i.restParam){let e=i.types.filter(j);e.length<i.types.length&&a.push({types:e,name:`...`+e.map(e=>e.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return le(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function ee(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=A(e,r),i=A(t,r),a=!1,o;for(o of i)if(n.has(o)){a=!0;break}if(!a)return!1}let r=e.length,i=t.length,a=E(e),o=E(t);return a?o?r===i:i>=r:o?r>=i:r===i}function te(e){return e.map(e=>me(e)?fe(e.referToSelf.callback):pe(e)?de(e.referTo.references,e.referTo.callback):e)}function H(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function ne(e,t,n){let r=te(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o<r.length;++o){if(i[o])continue;let s=r[o];if(me(s))r[o]=s.referToSelf.callback(n),r[o].referToSelf=s.referToSelf,i[o]=!0,e=!1;else if(pe(s)){let n=H(s.referTo.references,r,t);n?(r[o]=s.referTo.callback.apply(this,n),r[o].referTo=s.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw SyntaxError(`Circular reference detected in resolving typed.referTo`)}return r}function re(e){let t=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach(n=>{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function ie(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&re(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=T(c);if(!e)continue;i.forEach(function(t){if(ee(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(C),l;for(l of V(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(L);let l=ne(a,o,ve),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!E(f[0].params),h=f[1]&&f[1].params.length<=2&&!E(f[1].params),g=f[2]&&f[2].params.length<=2&&!E(f[2].params),_=f[3]&&f[3].params.length<=2&&!E(f[3].params),v=f[4]&&f[4].params.length<=2&&!E(f[4].params),y=f[5]&&f[5].params.length<=2&&!E(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;e<f.length;++e)f[e].test=O(f[e].params);let S=m?D(f[0].params[0]):t,w=h?D(f[1].params[0]):t,k=g?D(f[2].params[0]):t,A=_?D(f[3].params[0]):t,j=v?D(f[4].params[0]):t,M=y?D(f[5].params[0]):t,N=m?D(f[0].params[1]):t,P=h?D(f[1].params[1]):t,F=g?D(f[2].params[1]):t,I=_?D(f[3].params[1]):t,R=v?D(f[4].params[1]):t,B=y?D(f[5].params[1]):t;for(let e=0;e<f.length;++e)f[e].implementation=z(f[e].params,f[e].fn);let te=m?f[0].implementation:n,H=h?f[1].implementation:n,ie=g?f[2].implementation:n,U=_?f[3].implementation:n,ae=v?f[4].implementation:n,oe=y?f[5].implementation:n,se=m?f[0].params.length:-1,ce=h?f[1].params.length:-1,le=g?f[2].params.length:-1,ue=_?f[3].params.length:-1,de=v?f[4].params.length:-1,fe=y?f[5].params.length:-1,pe=b?6:0,me=f.length,he=f.map(e=>e.test),ge=f.map(e=>e.implementation),_e=function(){for(let e=pe;e<me;e++)if(he[e](arguments))return ge[e].apply(this,arguments);return d.onMismatch(e,arguments,f)};function ve(e,t){return arguments.length===se&&S(e)&&N(t)?te.apply(this,arguments):arguments.length===ce&&w(e)&&P(t)?H.apply(this,arguments):arguments.length===le&&k(e)&&F(t)?ie.apply(this,arguments):arguments.length===ue&&A(e)&&I(t)?U.apply(this,arguments):arguments.length===de&&j(e)&&R(t)?ae.apply(this,arguments):arguments.length===fe&&M(e)&&B(t)?oe.apply(this,arguments):_e.apply(this,arguments)}try{Object.defineProperty(ve,`name`,{value:e})}catch{}return ve.signatures=o,ve._typedFunctionData={signatures:f,signatureMap:p},ve}function U(e,t,n){throw N(e,t,n)}function ae(e){return se(e,0,e.length-1)}function oe(e){return e[e.length-1]}function se(e,t,n){return Array.prototype.slice.call(e,t,n)}function ce(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n]}function le(e,t){return Array.prototype.concat.apply([],e.map(t))}function ue(){let e=ae(arguments).map(e=>x(T(e))),t=oe(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return de(e,t)}function de(e,t){return{referTo:{references:e,callback:t}}}function fe(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function pe(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function me(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function he(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function ge(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=he(t,e[n].name));return t}function _e(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let ve=d;d=function(e){let t=typeof e==`string`,n=+!!t,r=t?e:``,i={};for(let e=n;e<arguments.length;++e){let n=arguments[e],o={},s;if(typeof n==`function`?(s=n.name,typeof n.signature==`string`?o[n.signature]=n:_(n)&&(o=n.signatures)):a(n)&&(o=n,t||(s=ge(n))),Object.keys(o).length===0){let t=TypeError(`Argument to 'typed' at index `+e+` is not a (typed) function, nor an object with signatures as keys and functions as values.`);throw t.data={index:e,argument:n},t}t||(r=he(r,s)),_e(i,o)}return ie(r||``,i)},d.create=i,d.createCount=ve.createCount,d.onMismatch=U,d.throwMismatchError=U,d.createError=N,d.clear=m,d.clearConversions=h,d.addTypes=p,d._findType=f,d.referTo=ue,d.referToSelf=fe,d.convert=b,d.findSignature=v,d.find=y,d.isTypedFunction=_,d.warnAgainstDeprecatedThis=!0,d.addType=function(e,t){let n=`any`;t!==!1&&c.has(`Object`)&&(n=`Object`),d.addTypes([e],n)};function ye(e){if(!e||typeof e.from!=`string`||typeof e.to!=`string`||typeof e.convert!=`function`)throw TypeError(`Object with properties {from: string, to: string, convert: function} expected`);if(e.to===e.from)throw SyntaxError(`Illegal to define conversion from "`+e.from+`" to itself.`)}return d.addConversion=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ye(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){ye(e);let t=f(e.to),n=ce(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;e<n.length;++e)if(n[e].test(t))return n[e];return null},d}return i()}))}));function J(e,t,n,r){function i(r){var i=Di(r,t.map(Ii));return Pi(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function Ni(e){return typeof e==`function`&&typeof e.fn==`string`&&Array.isArray(e.dependencies)}function Pi(e,t,n){if(!t.filter(e=>!Fi(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function Fi(e){return e&&e[0]===`?`}function Ii(e){return e&&e[0]===`?`?e.slice(1):e}function Li(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function Ri(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var zi=Math.sign||function(e){return e>0?1:e<0?-1:0},Bi=Math.log2||function(e){return Math.log(e)/Math.LN2},Vi=Math.log10||function(e){return Math.log(e)/Math.LN10},Hi=Math.log1p||function(e){return Math.log(e+1)},Ui=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},Wi=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Gi(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!Li(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!Li(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function Ki(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=qi(t);switch(n){case`fixed`:return Xi(e,r);case`exponential`:return Zi(e,r);case`engineering`:return Yi(e,r);case`bin`:return Gi(e,2,i);case`oct`:return Gi(e,8,i);case`hex`:return Gi(e,16,i);case`auto`:return Qi(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function qi(e){var t=`auto`,n,r;if(e!==void 0)if(Er(e))n=e;else if(Dr(e))n=e.toNumber();else if(Kr(e))e.precision!==void 0&&(n=ua(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=ua(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function Ji(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function Yi(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=$i(Ji(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(Er(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s<o;s++)i.push(0);for(var c=Math.abs(r-a),l=1;c>0;)l++,c--;var u=i.slice(l).join(``),d=Er(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function Xi(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Ji(e),r=typeof t==`number`?$i(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length<o&&(i=i.concat(ea(o-i.length))),a<0&&(i=ea(-a+1).concat(i),a=1),a<i.length&&i.splice(a,0,a===0?`0.`:`.`),r.sign+i.join(``)}function Zi(e,t){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var n=Ji(e),r=t?$i(n,t):n,i=r.coefficients,a=r.exponent;i.length<t&&(i=i.concat(ea(t-i.length)));var o=i.shift();return r.sign+o+(i.length>0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function Qi(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=da(n?.lowerExp,-3),i=da(n?.upperExp,5),a=Ji(e),o=t?$i(a,t):a;if(o.exponent<r||o.exponent>=i)return Zi(e,t);var s=o.coefficients,c=o.exponent;s.length<t&&(s=s.concat(ea(t-s.length))),s=s.concat(ea(c-s.length+1+(s.length<t?t-s.length:0))),s=ea(-c).concat(s);var l=c>0?c:0;return l<s.length-1&&s.splice(l+1,0,`.`),o.sign+s.join(``)}function $i(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function ea(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}function ta(e){return e.toExponential().replace(/e.*$/,``).replace(/^0\.?0*|\./,``).length}function na(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return isNaN(e)||isNaN(t)?!1:!Number.isFinite(e)||!Number.isFinite(t)?e===t:e===t?!0:Math.abs(e-t)<=Math.max(n*Math.max(Math.abs(e),Math.abs(t)),r)}var ra=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},ia=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},aa=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},oa=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},sa=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},ca=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function la(e,t){return(e>0?!0:e<0?!1:1/e==1/0)^(t>0?!0:t<0?!1:1/t==1/0)?-e:e}function ua(e,t){if(Er(e))return e;if(Dr(e))return e.toNumber();t()}function da(e,t){return Er(e)?e:Dr(e)?e.toNumber():t}var fa=Dt(Mi(),1),pa=function(){return pa=fa.default.create,fa.default},ma=J(`typed`,[`?BigNumber`,`?Complex`,`?DenseMatrix`,`?Fraction`],function(e){var{BigNumber:t,Complex:n,DenseMatrix:r,Fraction:i}=e,a=pa();return a.clear(),a.addTypes([{name:`number`,test:Er},{name:`Complex`,test:kr},{name:`BigNumber`,test:Dr},{name:`bigint`,test:Or},{name:`Fraction`,test:Ar},{name:`Unit`,test:jr},{name:`identifier`,test:e=>Mr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:Mr},{name:`Chain`,test:hi},{name:`Array`,test:Nr},{name:`Matrix`,test:Pr},{name:`DenseMatrix`,test:Ir},{name:`SparseMatrix`,test:Lr},{name:`Range`,test:Rr},{name:`Index`,test:zr},{name:`boolean`,test:Br},{name:`ResultSet`,test:Vr},{name:`Help`,test:Hr},{name:`function`,test:Ur},{name:`Date`,test:Wr},{name:`RegExp`,test:Gr},{name:`null`,test:Xr},{name:`undefined`,test:Zr},{name:`AccessorNode`,test:Qr},{name:`ArrayNode`,test:$r},{name:`AssignmentNode`,test:ei},{name:`BlockNode`,test:ti},{name:`ConditionalNode`,test:ni},{name:`ConstantNode`,test:ri},{name:`FunctionNode`,test:oi},{name:`FunctionAssignmentNode`,test:ai},{name:`IndexNode`,test:si},{name:`Node`,test:ci},{name:`ObjectNode`,test:li},{name:`OperatorNode`,test:ui},{name:`ParenthesisNode`,test:di},{name:`RangeNode`,test:fi},{name:`RelationalNode`,test:pi},{name:`SymbolNode`,test:mi},{name:`Map`,test:qr},{name:`Object`,test:Kr}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||ha(e),ta(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||ga(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||ga(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw TypeError(`Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: `+e+`)`);return Number(e)}},{from:`bigint`,to:`BigNumber`,convert:function(e){return t||ha(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||va(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw TypeError(`Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.`)}},{from:`Fraction`,to:`Complex`,convert:function(e){return n||ga(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||va(e);var t=new i(e);if(t.valueOf()!==e)throw TypeError(`Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: `+e+`). Use function fraction(x) to convert to Fraction.`);return t}},{from:`string`,to:`number`,convert:function(e){var t=Number(e);if(isNaN(t))throw Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||ha(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||va(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||ga(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||ha(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||va(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||_a(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Fr(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Fr(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function ha(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function ga(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function _a(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function va(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var ya=J(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0}),ba=9e15,xa=1e9,Sa=`0123456789abcdef`,Ca=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,wa=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Ta={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ba,maxE:ba,crypto:!1},Ea,Da,Oa=!0,ka=`[DecimalError] `,Aa=ka+`Invalid argument: `,ja=ka+`Precision limit exceeded`,Ma=ka+`crypto unavailable`,Na=`[object Decimal]`,Pa=Math.floor,Fa=Math.pow,Ia=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,La=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ra=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,za=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ba=1e7,Va=7,Ha=9007199254740991,Ua=Ca.length-1,Wa=wa.length-1,Y={toStringTag:Na};Y.absoluteValue=Y.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Za(e)},Y.ceil=function(){return Za(new this.constructor(this),this.e+1,2)},Y.clampedTo=Y.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Aa+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},Y.comparedTo=Y.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},Y.cosine=Y.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Va,r.rounding=1,n=Ya(r,go(r,n)),r.precision=e,r.rounding=t,Za(Da==2||Da==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},Y.cubeRoot=Y.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(Oa=!1,a=u.s*Fa(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Ga(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=Fa(n,1/3),e=Pa((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=Xa(l.plus(u).times(s),l.plus(c),o+2,1),Ga(s.d).slice(0,o)===(n=Ga(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(Za(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(Za(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return Oa=!0,Za(r,e,d.rounding,t)},Y.decimalPlaces=Y.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Pa(this.e/Va))*Va,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},Y.dividedBy=Y.div=function(e){return Xa(this,new this.constructor(e))},Y.dividedToIntegerBy=Y.divToInt=function(e){var t=this,n=t.constructor;return Za(Xa(t,new n(e),0,1,1),n.precision,n.rounding)},Y.equals=Y.eq=function(e){return this.cmp(e)===0},Y.floor=function(){return Za(new this.constructor(this),this.e+1,3)},Y.greaterThan=Y.gt=function(e){return this.cmp(e)>0},Y.greaterThanOrEqualTo=Y.gte=function(e){var t=this.cmp(e);return t==1||t===0},Y.hyperbolicCosine=Y.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/ho(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=mo(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return Za(a,o.precision=n,o.rounding=r,!0)},Y.hyperbolicSine=Y.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=mo(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/ho(5,e)),i=mo(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,Za(i,t,n,!0)},Y.hyperbolicTangent=Y.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,Xa(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},Y.inverseCosine=Y.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?to(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?to(t,r,i):new t(0):new t(NaN)},Y.inverseHyperbolicCosine=Y.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,Oa=!1,n=n.times(n).minus(1).sqrt().plus(n),Oa=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},Y.inverseHyperbolicSine=Y.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,Oa=!1,n=n.times(n).plus(1).sqrt().plus(n),Oa=!0,r.precision=e,r.rounding=t,n.ln())},Y.inverseHyperbolicTangent=Y.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?Za(new a(i),e,t,!0):(a.precision=n=r-i.e,i=Xa(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},Y.inverseSine=Y.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=to(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},Y.inverseTangent=Y.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Wa)return o=to(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Wa)return o=to(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/Va+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(Oa=!1,t=Math.ceil(s/Va),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),Oa=!0,Za(o,u.precision=d,u.rounding=f,!0)},Y.isFinite=function(){return!!this.d},Y.isInteger=Y.isInt=function(){return!!this.d&&Pa(this.e/Va)>this.d.length-2},Y.isNaN=function(){return!this.s},Y.isNegative=Y.isNeg=function(){return this.s<0},Y.isPositive=Y.isPos=function(){return this.s>0},Y.isZero=function(){return!!this.d&&this.d[0]===0},Y.lessThan=Y.lt=function(e){return this.cmp(e)<0},Y.lessThanOrEqualTo=Y.lte=function(e){return this.cmp(e)<1},Y.logarithm=Y.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(Oa=!1,s=d+p,o=co(l,s),r=t?eo(u,s+10):co(e,s),c=Xa(o,r,s,1),qa(c.d,i=d,f))do if(s+=10,o=co(l,s),r=t?eo(u,s+10):co(e,s),c=Xa(o,r,s,1),!a){+Ga(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=Za(c,d+1,0));break}while(qa(c.d,i+=10,f));return Oa=!0,Za(c,d,f)},Y.minus=Y.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return Oa?Za(e,s,c):e}if(n=Pa(e.e/Va),u=Pa(p.e/Va),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/Va),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=Ba-1;--l[i],l[r]+=Ba}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=$a(l,n),Oa?Za(e,s,c):e):new m(c===3?-0:0)},Y.modulo=Y.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?Za(new r(n),r.precision,r.rounding):(Oa=!1,r.modulo==9?(t=Xa(n,e.abs(),0,3,1),t.s*=e.s):t=Xa(n,e,0,r.modulo,1),t=t.times(e),Oa=!0,n.minus(t))},Y.naturalExponential=Y.exp=function(){return so(this)},Y.naturalLogarithm=Y.ln=function(){return co(this)},Y.negated=Y.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Za(e)},Y.plus=Y.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),Oa?Za(e,s,c):e;if(a=Pa(d.e/Va),r=Pa(e.e/Va),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/Va),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/Ba|0,l[i]%=Ba;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=$a(l,r),Oa?Za(e,s,c):e},Y.precision=Y.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Aa+e);return n.d?(t=no(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Y.round=function(){var e=this,t=e.constructor;return Za(new t(e),e.e+1,t.rounding)},Y.sine=Y.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Va,r.rounding=1,n=po(r,go(r,n)),r.precision=e,r.rounding=t,Za(Da>2?n.neg():n,e,t,!0)):new r(NaN)},Y.squareRoot=Y.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(Oa=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Ga(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=Pa((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(Xa(o,a,n+2,1)).times(.5),Ga(a.d).slice(0,n)===(t=Ga(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(Za(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(Za(r,c+1,1),e=!r.times(r).eq(o));break}return Oa=!0,Za(r,c,u.rounding,e)},Y.tangent=Y.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=Xa(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,Za(Da==2||Da==4?n.neg():n,e,t,!0)):new r(NaN)},Y.times=Y.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=Pa(u.e/Va)+Pa(e.e/Va),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%Ba|0,t=s/Ba|0;a[i]=(a[i]+t)%Ba|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=$a(a,n),Oa?Za(e,d.precision,d.rounding):e},Y.toBinary=function(e,t){return _o(this,2,e,t)},Y.toDecimalPlaces=Y.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Ka(e,0,xa),t===void 0?t=r.rounding:Ka(t,0,8),Za(n,e+n.e+1,t))},Y.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Qa(r,!0):(Ka(e,0,xa),t===void 0?t=i.rounding:Ka(t,0,8),r=Za(new i(r),e+1,t),n=Qa(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},Y.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=Qa(i):(Ka(e,0,xa),t===void 0?t=a.rounding:Ka(t,0,8),r=Za(new a(i),e+i.e+1,t),n=Qa(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},Y.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=no(m)-p.e-1,o=a%Va,t.d[0]=Fa(10,o<0?Va+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Aa+s);e=s.gt(t)?a>0?t:l:s}for(Oa=!1,s=new h(Ga(m)),u=h.precision,h.precision=a=m.length*Va*2;d=Xa(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=Xa(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=Xa(l,r,a,1).minus(p).abs().cmp(Xa(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,Oa=!0,f},Y.toHexadecimal=Y.toHex=function(e,t){return _o(this,16,e,t)},Y.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Ka(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(Oa=!1,n=Xa(n,e,0,t,1).times(e),Oa=!0,Za(n)):(e.s=n.s,n=e),n},Y.toNumber=function(){return+this},Y.toOctal=function(e,t){return _o(this,8,e,t)},Y.toPower=Y.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(Fa(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return Za(s,r,a);if(t=Pa(e.e/Va),t>=e.d.length-1&&(n=l<0?-l:l)<=Ha)return i=io(c,s,n,r),e.s<0?new c(1).div(i):Za(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=Fa(+s,l),t=n==0||!isFinite(n)?Pa(l*(Math.log(`0.`+Ga(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(Oa=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=so(e.times(co(s,r+n)),r),i.d&&(i=Za(i,r+5,1),qa(i.d,r,a)&&(t=r+10,i=Za(so(e.times(co(s,t+n)),t),t+5,1),+Ga(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=Za(i,r+1,0)))),i.s=o,Oa=!0,c.rounding=a,Za(i,r,a))},Y.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Qa(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ka(e,1,xa),t===void 0?t=i.rounding:Ka(t,0,8),r=Za(new i(r),e,t),n=Qa(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},Y.toSignificantDigits=Y.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Ka(e,1,xa),t===void 0?t=r.rounding:Ka(t,0,8)),Za(new r(n),e,t)},Y.toString=function(){var e=this,t=e.constructor,n=Qa(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},Y.truncated=Y.trunc=function(){return Za(new this.constructor(this),this.e+1,1)},Y.valueOf=Y.toJSON=function(){var e=this,t=e.constructor,n=Qa(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Ga(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=Va-r.length,n&&(a+=ro(n)),a+=r;o=e[t],r=o+``,n=Va-r.length,n&&(a+=ro(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function Ka(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Aa+e)}function qa(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=Va,i=0):(i=Math.ceil((t+1)/Va),t%=Va),a=Fa(10,Va-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Fa(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Fa(10,t-3)-1,o}function Ja(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=Sa.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Ya(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/ho(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=mo(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var Xa=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k=r.constructor,A=r.s==i.s?1:-1,j=r.d,M=i.d;if(!j||!j[0]||!M||!M[0])return new k(!r.s||!i.s||(j?M&&j[0]==M[0]:!M)?NaN:j&&j[0]==0||!M?A*0:A/0);for(c?(p=1,u=r.e-i.e):(c=Ba,p=Va,u=Pa(r.e/p)-Pa(i.e/p)),D=M.length,T=j.length,_=new k(A),v=_.d=[],d=0;M[d]==(j[d]||0);d++);if(M[d]>(j[d]||0)&&u--,a==null?(S=a=k.precision,o=k.rounding):S=s?a+(r.e-i.e)+1:a,S<0)v.push(1),m=!0;else{if(S=S/p+2|0,d=0,D==1){for(f=0,M=M[0],S++;(d<T||f)&&S--;d++)C=f*c+(j[d]||0),v[d]=C/M|0,f=C%M|0;m=f||d<T}else{for(f=c/(M[0]+1)|0,f>1&&(M=e(M,f,c),j=e(j,f,c),D=M.length,T=j.length),w=D,y=j.slice(0,D),b=y.length;b<D;)y[b++]=0;O=M.slice(),O.unshift(0),E=M[0],M[1]>=c/2&&++E;do f=0,l=t(M,y,D,b),l<0?(x=y[0],D!=b&&(x=x*c+(y[1]||0)),f=x/E|0,f>1?(f>=c&&(f=c-1),h=e(M,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,D<g?O:M,g,c))):(f==0&&(l=f=1),h=M.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(M,y,D,b),l<1&&(f++,n(y,D<b?O:M,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=j[w]||0:(y=[j[w]],b=1);while((w++<T||y[0]!==void 0)&&S--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Ea=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,Za(_,s?a+_.e+1:a,o,m)}return _}})();function Za(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=Va,o=t,u=d[f=0],c=u/Fa(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/Va),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=Va,o=a-Va+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=Va,o=a-Va+i,c=o<0?0:u/Fa(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%Fa(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/Fa(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=Fa(10,(Va-t%Va)%Va),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=Fa(10,Va-a),d[f]=o>0?(u/Fa(10,i-o)%Fa(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==Ba&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=Ba)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return Oa&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function Qa(e,t,n){if(!e.isFinite())return lo(e);var r,i=e.e,a=Ga(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+ro(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+ro(-i-1)+a,n&&(r=n-o)>0&&(a+=ro(r))):i>=o?(a+=ro(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+ro(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=ro(r))),a}function $a(e,t){var n=e[0];for(t*=Va;n>=10;n/=10)t++;return t}function eo(e,t,n){if(t>Ua)throw Oa=!0,n&&(e.precision=n),Error(ja);return Za(new e(Ca),t,1,!0)}function to(e,t,n){if(t>Wa)throw Error(ja);return Za(new e(wa),t,n,!0)}function no(e){var t=e.length-1,n=t*Va+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ro(e){for(var t=``;e--;)t+=`0`;return t}function io(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/Va+4);for(Oa=!1;;){if(n%2&&(a=a.times(t),vo(a.d,o)&&(i=!0)),n=Pa(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),vo(t.d,o)}return Oa=!0,a}function ao(e){return e.d[e.d.length-1]&1}function oo(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function so(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Oa=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(Fa(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=Za(a.times(e),c,1),n=n.times(++u),s=o.plus(Xa(a,n,c,1)),Ga(s.d).slice(0,c)===Ga(o.d).slice(0,c)){for(i=d;i--;)o=Za(o.times(o),c,1);if(t==null)if(l<3&&qa(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return Za(o,f.precision=m,p,Oa=!0);else return f.precision=m,o}o=s}}function co(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(Oa=!1,u=y):u=t,_.precision=u+=m,n=Ga(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Ga(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=eo(_,u+2,y).times(a+``),h=co(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?Za(h,y,v,Oa=!0):h;for(d=h,c=o=h=Xa(h.minus(1),h.plus(1),u,1),f=Za(h.times(h),u,1),i=3;;){if(o=Za(o.times(f),u,1),l=c.plus(Xa(o,new _(i),u,1)),Ga(l.d).slice(0,u)===Ga(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(eo(_,u+2,y).times(a+``))),c=Xa(c,new _(p),u,1),t==null)if(qa(c.d,u-m,v,s))_.precision=u+=m,l=o=h=Xa(d.minus(1),d.plus(1),u,1),f=Za(h.times(h),u,1),i=s=1;else return Za(c,_.precision=y,v,Oa=!0);else return _.precision=y,c;c=l,i+=2}}function lo(e){return String(e.s*e.s/0)}function uo(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%Va,n<0&&(r+=Va),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=Va;r<i;)e.d.push(+t.slice(r,r+=Va));t=t.slice(r),r=Va-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),Oa&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function fo(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),za.test(t))return uo(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(La.test(t))n=16,t=t.toLowerCase();else if(Ia.test(t))n=2;else if(Ra.test(t))n=8;else throw Error(Aa+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=io(r,new r(n),a,a*2)),l=Ja(t,n,Ba),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=$a(l,u),e.d=l,Oa=!1,o&&(e=Xa(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?Fa(2,c):os.pow(2,c))),Oa=!0,e)}function po(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:mo(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/ho(5,n)),t=mo(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function mo(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/Va);for(Oa=!1,c=n.times(n),s=new e(r);;){if(o=Xa(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=Xa(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return Oa=!0,o.d.length=d+1,o}function ho(e,t){for(var n=e;--t;)n*=e;return n}function go(e,t){var n,r=t.s<0,i=to(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Da=r?4:1,t;if(n=t.divToInt(i),n.isZero())Da=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Da=ao(n)?r?2:3:r?4:1,t;Da=ao(n)?r?1:4:r?3:2}return t.minus(i).abs()}function _o(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(Ka(n,1,xa),r===void 0?r=p.rounding:Ka(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=lo(e);else{for(u=Qa(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=Ja(Qa(f),10,i),f.e=f.d.length),d=Ja(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=Xa(e,f,n,r,0,i),d=e.d,a=e.e,l=Ea),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=Sa.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=Ja(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=Sa.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function vo(e,t){if(e.length>t)return e.length=t,!0}function yo(e){return new this(e).abs()}function bo(e){return new this(e).acos()}function xo(e){return new this(e).acosh()}function So(e,t){return new this(e).plus(t)}function Co(e){return new this(e).asin()}function wo(e){return new this(e).asinh()}function To(e){return new this(e).atan()}function Eo(e){return new this(e).atanh()}function Do(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=to(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?to(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=to(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(Xa(e,t,a,1)),t=to(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(Xa(e,t,a,1)),n}function Oo(e){return new this(e).cbrt()}function ko(e){return Za(e=new this(e),e.e+1,2)}function Ao(e,t,n){return new this(e).clamp(t,n)}function jo(e){if(!e||typeof e!=`object`)throw Error(ka+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,xa,`rounding`,0,8,`toExpNeg`,-ba,0,`toExpPos`,0,ba,`maxE`,0,ba,`minE`,-ba,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Ta[n]),(r=e[n])!==void 0)if(Pa(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Aa+n+`: `+r);if(n=`crypto`,i&&(this[n]=Ta[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Ma);else this[n]=!1;else throw Error(Aa+n+`: `+r);return this}function Mo(e){return new this(e).cos()}function No(e){return new this(e).cosh()}function Po(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,zo(e)){a.s=e.s,Oa?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;Oa?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return uo(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),za.test(e)?uo(a,e):fo(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,uo(a,e.toString());throw Error(Aa+e)}if(i.prototype=Y,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=jo,i.clone=Po,i.isDecimal=zo,i.abs=yo,i.acos=bo,i.acosh=xo,i.add=So,i.asin=Co,i.asinh=wo,i.atan=To,i.atanh=Eo,i.atan2=Do,i.cbrt=Oo,i.ceil=ko,i.clamp=Ao,i.cos=Mo,i.cosh=No,i.div=Fo,i.exp=Io,i.floor=Lo,i.hypot=Ro,i.ln=Bo,i.log=Vo,i.log10=Uo,i.log2=Ho,i.max=Wo,i.min=Go,i.mod=Ko,i.mul=qo,i.pow=Jo,i.random=Yo,i.round=Xo,i.sign=Zo,i.sin=Qo,i.sinh=$o,i.sqrt=es,i.sub=ts,i.sum=ns,i.tan=rs,i.tanh=is,i.trunc=as,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function Fo(e,t){return new this(e).div(t)}function Io(e){return new this(e).exp()}function Lo(e){return Za(e=new this(e),e.e+1,3)}function Ro(){var e,t,n=new this(0);for(Oa=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return Oa=!0,new this(1/0);n=t}return Oa=!0,n.sqrt()}function zo(e){return e instanceof os||e&&e.toStringTag===Na||!1}function Bo(e){return new this(e).ln()}function Vo(e,t){return new this(e).log(t)}function Ho(e){return new this(e).log(2)}function Uo(e){return new this(e).log(10)}function Wo(){return oo(this,arguments,-1)}function Go(){return oo(this,arguments,1)}function Ko(e,t){return new this(e).mod(t)}function qo(e,t){return new this(e).mul(t)}function Jo(e,t){return new this(e).pow(t)}function Yo(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:Ka(e,1,xa),r=Math.ceil(e/Va),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(Ma);for(r=s[--a],e%=Va,r&&e&&(i=Fa(10,Va-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=Va)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<Va&&(n-=Va-r)}return o.e=n,o.d=s,o}function Xo(e){return Za(e=new this(e),e.e+1,this.rounding)}function Zo(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Qo(e){return new this(e).sin()}function $o(e){return new this(e).sinh()}function es(e){return new this(e).sqrt()}function ts(e,t){return new this(e).sub(t)}function ns(){var e=0,t=arguments,n=new this(t[e]);for(Oa=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return Oa=!0,Za(n,this.precision,this.rounding)}function rs(e){return new this(e).tan()}function is(e){return new this(e).tanh()}function as(e){return Za(e=new this(e),e.e+1,1)}Y[Symbol.for(`nodejs.util.inspect.custom`)]=Y.toString,Y[Symbol.toStringTag]=`Decimal`;var os=Y.constructor=Po(Ta);Ca=new os(Ca),wa=new os(wa);var ss=J(`BigNumber`,[`?on`,`config`],e=>{var{on:t,config:n}=e,r=os.clone({precision:n.precision,modulo:os.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type=`BigNumber`,r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:`BigNumber`,value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t(`config`,function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),cs=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},ls=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},us=e=>{let t=Math.sin(.5*e);return-2*t*t},ds=function(e,t){return e=Math.abs(e),t=Math.abs(t),e<t&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))},fs=function(){throw SyntaxError(`Invalid Param`)};function ps(e,t){let n=Math.abs(e),r=Math.abs(t);return e===0?Math.log(r):t===0?Math.log(n):n<3e3&&r<3e3?Math.log(e*e+t*t)*.5:(e*=.5,t*=.5,.5*Math.log(e*e+t*t)+Math.LN2)}var ms={re:0,im:0},hs=function(e,t){let n=ms;if(e==null)n.re=n.im=0;else if(t!==void 0)n.re=e,n.im=t;else switch(typeof e){case`object`:if(`im`in e&&`re`in e)n.re=e.re,n.im=e.im;else if(`abs`in e&&`arg`in e){if(!isFinite(e.abs)&&isFinite(e.arg))return X.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if(`r`in e&&`phi`in e){if(!isFinite(e.r)&&isFinite(e.phi))return X.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else e.length===2?(n.re=e[0],n.im=e[1]):fs();break;case`string`:n.im=n.re=0;let t=e.replace(/_/g,``).match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,i=0;t===null&&fs();for(let e=0;e<t.length;e++){let a=t[e];a===` `||a===` `||a===`
|
|
2
|
+
import{$ as e,$t as t,A as n,At as r,B as i,Bt as a,C as o,Ct as s,D as c,Dt as l,E as u,Et as d,F as f,G as p,Gt as m,H as h,Ht as g,I as _,J as v,Jt as y,K as b,Kt as x,L as S,M as C,N as w,O as T,Ot as E,P as D,Q as O,Qt as k,R as A,S as j,St as M,T as N,Tt as P,U as F,Ut as I,V as L,Vt as R,W as z,Wt as B,X as V,Xt as ee,Y as te,Yt as H,Z as ne,Zt as re,_ as ie,_t as U,a as ae,at as oe,b as se,bt as ce,c as le,ct as ue,d as de,dt as fe,en as pe,et as me,f as he,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as xe,it as Se,j as Ce,jt as we,k as Te,kt as Ee,l as De,lt as Oe,m as ke,mt as Ae,n as je,nn as Me,nt as Ne,o as Pe,ot as Fe,p as Ie,pt as Le,q as Re,qt as ze,r as Be,rt as Ve,st as He,tn as Ue,tt as We,u as Ge,ut as Ke,v as qe,w as Je,x as Ye,y as Xe,yt as Ze,z as Qe,zt as $e}from"./keys-Iv24Wam2.js";import{i as et,n as tt,r as nt,t as rt}from"./threshold-C9it0Y7P.js";import{createContext as it,forwardRef as at,memo as ot,startTransition as st,useCallback as ct,useContext as lt,useEffect as W,useImperativeHandle as ut,useLayoutEffect as G,useMemo as dt,useRef as K,useState as ft,useSyncExternalStore as pt}from"react";import{createPortal as mt}from"react-dom";import{createRoot as ht}from"react-dom/client";import{Fragment as gt,jsx as q,jsxs as _t}from"react/jsx-runtime";var vt=Object.create,yt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,xt=Object.getOwnPropertyNames,St=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,wt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tt=(e,t)=>{let n={};for(var r in e)yt(n,r,{get:e[r],enumerable:!0});return t||yt(n,Symbol.toStringTag,{value:`Module`}),n},Et=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=xt(t),a=0,o=i.length,s;a<o;a++)s=i[a],!Ct.call(e,s)&&s!==n&&yt(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=bt(t,s))||r.enumerable});return e},Dt=(e,t,n)=>(n=e==null?{}:vt(St(e)),Et(t||!e||!e.__esModule?yt(n,`default`,{value:e,enumerable:!0}):n,e)),Ot=[`text`,`brush`,`arrow`,`box`],kt={text:14,brush:3,arrow:2,box:2},At=/^#[0-9a-fA-F]{6}$/,jt={text:[1,1],arrow:[2,2],box:[2,2],brush:[2,1/0]},Mt=e=>typeof e==`number`&&Number.isFinite(e);function Nt(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(!Ot.includes(n)||typeof t.id!=`string`||!t.id||!Array.isArray(t.points))return null;let r=t.points.filter(e=>Array.isArray(e)&&Mt(e[0])&&Mt(e[1])).map(([e,t])=>[e,t]),[i,a]=jt[n];return r.length<i||r.length>a?null:{id:t.id,kind:n,points:r,...t.anchor===`x`?{anchor:`x`}:{},color:typeof t.color==`string`&&At.test(t.color)?t.color:`#f5a524`,width:Mt(t.width)&&t.width>0?Math.min(96,t.width):kt[n],...typeof t.text==`string`&&t.text!==``?{text:t.text}:{}}}function Pt(e){return Array.isArray(e)?e.map(Nt).filter(e=>e!==null):null}var Ft={info:`#8a93a6`,warning:`#f5a524`,critical:`#e5484d`},It={info:`var(--text-muted, #8a93a6)`,warning:`var(--accent, #f5a524)`,critical:`var(--danger, #e5484d)`};function Lt(e,t){return{id:`mark:${e.id}`,kind:`box`,anchor:`x`,points:[[e.t0,0],[e.t1??t,1]],color:Ft[e.severity],width:1,...e.ruleName?{text:e.ruleName}:{}}}var Rt=96,zt=96,Bt=2,Vt={multiband:6,xyscatter:6,xyzmesh:6,histogram:6,polar:6,spectrum:6,boxplot:6,spectrogram:6,heatmap:6,violin:6,confusion:6,roc:6,losscurve:6,controlchart:6,parallelcoords:6,embedding:6,flamegraph:6,barchart:6,radar:6,areachart:6,cdfchart:6,bubblechart:6,treemap:6,sankey:6,calibration:6,qqplot:6,gantt:6,gauge:6,camera:6},Ht={multiband:24,xyscatter:24,xyzmesh:24,histogram:24,polar:24,spectrum:24,boxplot:24,spectrogram:24,heatmap:24,violin:24,confusion:24,roc:24,losscurve:24,controlchart:24,parallelcoords:24,embedding:24,flamegraph:24,barchart:24,radar:24,areachart:24,cdfchart:24,bubblechart:24,treemap:24,sankey:24,calibration:24,qqplot:24,gantt:24,gauge:24,camera:24},Ut=Vt,Wt=Ht;function Gt(e,t){return e.x<t.x+t.w&&t.x<e.x+e.w&&e.y<t.y+t.h&&t.y<e.y+e.h}function Kt(e,t,n,r=96){let i=Vt[e],a=Ht[e],o=Math.max(i,Math.min(t.w,n-Math.max(0,t.x))),s=Math.max(a,Math.min(t.h,r-Math.max(0,t.y)));return{x:Math.max(0,Math.min(t.x,n-o)),y:Math.max(0,Math.min(t.y,r-s)),w:o,h:s}}function qt(e,t,n,r,i,a,o=96,s=96){let c=Math.round(r/Math.max(1e-6,a.width/o)),l=Math.round(i/Math.max(1e-6,a.height/s));return n===`move`?Kt(e,{...t,x:t.x+c,y:t.y+l},o,s):{...t,w:Math.max(Vt[e],Math.min(t.w+c,o-t.x)),h:Math.max(Ht[e],Math.min(t.h+l,s-t.y))}}function Jt(e,t,n){for(let r of t)if(r.id!==n&&Gt(e,r.rect))return!0;return!1}function Yt(e,t,n=96){let r=Vt[e],i=Ht[e],a=Math.min(48,n),o=e===`multiband`||e===`xyzmesh`?64:48;for(let i=0;i<384;i+=8)for(let s=0;s<=n-r;s+=8){let r=Kt(e,{x:s,y:i,w:a,h:o},n);if(!Jt(r,t,``))return r}return Kt(e,{x:0,y:0,w:r,h:i},n)}function Xt(e,t){return{id:crypto.randomUUID(),kind:e,rect:Yt(e,t)}}function Zt(e){if(e<=0)return[];if(e===1)return[{x:0,y:0,w:1,h:1}];if(e===2)return[{x:0,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1}];if(e===3)return[{x:0,y:0,w:.5,h:.5},{x:.5,y:0,w:.5,h:.5},{x:0,y:.5,w:1,h:.5}];if(e===4)return[{x:0,y:0,w:.5,h:.5},{x:.5,y:0,w:.5,h:.5},{x:0,y:.5,w:.5,h:.5},{x:.5,y:.5,w:.5,h:.5}];let t=Zt(e-4).map(e=>({x:e.x*.5,y:e.y,w:e.w*.5,h:e.h})),n=Zt(4).map(e=>({x:.5+e.x*.5,y:e.y,w:e.w*.5,h:e.h}));return[...t,...n]}function Qt(e,t=96,n=96){let r=Zt(e.length);return e.map((e,i)=>{let a=r[i];if(!a)return e;let o=Math.round(a.x*t),s=Math.round(a.y*n),c=Math.max(1,Math.round(a.w*t)),l=Math.max(1,Math.round(a.h*n));return{...e,rect:{x:o,y:s,w:c,h:l}}})}function $t(){return{scaleMin:``,scaleMax:``,majorStep:``,minorStep:``,alarm:null}}var en={style:`dashed`,width:1,color:null},tn={style:`solid`,width:1,color:null},nn={enabled:!1,reference:`previous`,datasetId:null,datasetColor:`#94a3b8`,previousColor:`#64748b`},rn=/^#[0-9a-f]{6}$/i;function an(e){if(!e||typeof e!=`object`)return;let t=e;return{enabled:t.enabled===!0,reference:t.reference===`dataset`||t.reference===`none`?t.reference:`previous`,datasetId:typeof t.datasetId==`string`&&t.datasetId?t.datasetId:null,datasetColor:typeof t.datasetColor==`string`&&rn.test(t.datasetColor)?t.datasetColor:nn.datasetColor,previousColor:typeof t.previousColor==`string`&&rn.test(t.previousColor)?t.previousColor:nn.previousColor}}var on=[`#f5a524`,`#38bdf8`,`#22c55e`,`#f472b6`,`#a78bfa`,`#fb7185`];function sn(e,t){return{id:crypto.randomUUID(),column:e,color:on[t%on.length],value:`last`,style:`arc`,min:``,max:``}}function cn(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(typeof n.column!=`string`)return null;let r=Zn(n.alarm);return{id:typeof n.id==`string`&&n.id?n.id:`g${t}`,column:n.column,color:typeof n.color==`string`?n.color:on[t%on.length],value:n.value===`mean`||n.value===`min`||n.value===`max`?n.value:`last`,style:n.style===`linear`?`linear`:`arc`,...n.fill===`zero`?{fill:`zero`}:{},min:typeof n.min==`string`?n.min:``,max:typeof n.max==`string`?n.max:``,...r?{alarm:r}:{},...n.colorMode===`gradient`||n.colorMode===`zones`?{colorMode:n.colorMode}:{},...Array.isArray(n.stops)?{stops:n.stops.flatMap(e=>{let t=e;return t&&typeof t.at==`number`&&Number.isFinite(t.at)&&typeof t.color==`string`?[{at:t.at,color:t.color}]:[]})}:{}}}function ln(e,t){let n=parseFloat(e),r=parseFloat(t);return Number.isFinite(n)&&Number.isFinite(r)&&n<r?[n,r]:void 0}var un=1.8,dn=4,fn=1;function pn(){return{kind:`multiband`,series:[],addColumn:``,layout:`overlay`,xAxisLine:{...en},yAxisLine:{...en},gridLine:{...tn},lineWidth:1}}function mn(e){return{kind:`xyscatter`,xyXCol:``,xyYCol:``,xyColorCol:null,xyColor:e,xyPointRadius:un,xyXAxisLine:{...en},xyYAxisLine:{...en},xyGridLine:{...tn},xyFit:null,xyXScale:$t(),xyYScale:$t()}}function hn(e=4){return{kind:`xyzmesh`,xyzXCol:``,xyzYCol:``,xyzZCol:``,xyzViewMode:`3d`,xyzXScale:$t(),xyzYScale:$t(),xyzZScale:$t(),xyzPointRadius:e,showMesh:!1,meshStyle:`filled`,meshOpacity:.85}}function gn(){return{kind:`histogram`,histColumn:``,histBins:0,histColor:`#38bdf8`,histNormal:!1,histLogY:!1}}function _n(){return{kind:`polar`,polarAngleCol:``,polarRadiusCol:``,polarColor:`#a78bfa`,polarMode:`waveform`,polarRadiusMin:``,polarRadiusMax:``}}function vn(){return{kind:`spectrum`,specSignalCol:``,specTimeCol:``,specSampleRate:`1000`,specXMode:`hz`,specYMode:`amplitude`,specWindow:`hann`,specColor:`#34d399`,specLogX:!1}}function yn(){return{kind:`boxplot`,boxValueCol:``,boxGroupCol:``,boxColor:`#fb923c`,boxWhiskers:`1.5iqr`}}function bn(){return{kind:`spectrogram`,sgSignalCol:``,sgTimeCol:``,sgSampleRate:`1000`,sgWindowSize:512,sgOverlap:.5,sgWinFunc:`hann`,sgYMode:`db`,sgLogFreq:!1}}function xn(){return{kind:`heatmap`,hmMode:`binned`,hmColumns:[],hmXCol:``,hmYCol:``,hmValueCol:``,hmXBins:6,hmYBins:6,hmXMin:``,hmXMax:``,hmYMin:``,hmYMax:``,hmShowValues:!0,hmColorScheme:`diverging`}}function Sn(){return{kind:`violin`,vlValueCol:``,vlGroupCol:``,vlColor:`#818cf8`,vlShowBox:!0,vlBandwidth:``,vlOrientation:`vertical`}}function Cn(){return{kind:`confusion`,cfActualCol:``,cfPredictedCol:``,cfNormalize:!1}}function wn(){return{kind:`roc`,rocScoreCol:``,rocLabelCol:``,rocMode:`roc`,rocColor:`#f472b6`}}function Tn(){return{kind:`losscurve`,lcXCol:``,lcLeftCols:[],lcRightCols:[]}}function En(){return{kind:`controlchart`,ccValueCol:``,ccSubgroupCol:``,ccSigmaLevel:3,ccColor:`#22d3ee`}}function Dn(){return{kind:`parallelcoords`,pcColumns:[],pcColorByCol:``,pcColor:`#64748b`}}function On(){return{kind:`embedding`,emXCol:``,emYCol:``,emColorCol:``,emColorMode:`categorical`,emLabelCol:``,emPointSize:3,emColor:`#a78bfa`}}function kn(){return{kind:`flamegraph`,fgNameCol:``,fgParentCol:``,fgValueCol:``,fgDirection:`topdown`}}function An(){return{kind:`barchart`,bcCategoryCol:``,bcValueCols:[],bcMode:`grouped`,bcHorizontal:!1}}function jn(){return{kind:`radar`,rdAxesCols:[],rdGroupCol:``,rdColor:`#38bdf8`,rdFill:!0}}function Mn(){return{kind:`areachart`,acXCol:``,acYCols:[],acStacked:!1}}function Nn(){return{kind:`cdfchart`,cdValueCols:[],cdComplement:!1,cdLogX:!1}}function Pn(){return{kind:`bubblechart`,bbXCol:``,bbYCol:``,bbSizeCol:``,bbColorCol:``,bbColorMode:`categorical`,bbColor:`#64748b`,bbMaxRadius:24}}function Fn(){return{kind:`treemap`,tmNameCol:``,tmParentCol:``,tmValueCol:``}}function In(){return{kind:`sankey`,skSourceCol:``,skTargetCol:``,skValueCol:``}}function Ln(){return{kind:`gauge`,ggGauges:[]}}function Rn(){return{kind:`calibration`,cbScoreCol:``,cbLabelCol:``,cbBins:10,cbColor:`#38bdf8`}}function zn(){return{kind:`qqplot`,qqValueCol:``,qqMode:`normal`,qqRefCol:``,qqColor:`#a78bfa`}}function Bn(){return{kind:`gantt`,gtLabelCol:``,gtStartCol:``,gtEndCol:``,gtGroupCol:``}}function Vn(e,t){let n=(e.parentId?t.find(t=>t.id===e.parentId)?.name:void 0)??e.parentName;return n?`${n} · ${e.name}`:e.name}var Hn=()=>({kind:`camera`,cameraStreamId:``,cameras:[],syncStreamId:``,offsetMs:0,fit:`contain`}),Un=9;function Wn(e){return e.cameraStreamId?e.cameras?.[0]===e.cameraStreamId?e.cameras.slice(0,9):[e.cameraStreamId]:[]}function Gn(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&typeof t.column==`string`&&typeof t.color==`string`&&typeof t.bandFromPct==`number`&&typeof t.bandToPct==`number`&&typeof t.scaleMin==`number`&&typeof t.scaleMax==`number`&&typeof t.yMajorStep==`number`&&typeof t.yMinorStep==`number`}function Kn(e){if(!e||typeof e!=`object`)return!1;let t=e;return(t.style===`none`||t.style===`solid`||t.style===`dashed`||t.style===`dotted`)&&typeof t.width==`number`&&(t.color===null||typeof t.color==`string`)}function qn(e,t){return Kn(e)?e:{...t}}function Jn(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`multiband`&&Array.isArray(t.series)&&t.series.every(Gn)&&typeof t.addColumn==`string`}function Yn(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`xyscatter`&&typeof t.xyXCol==`string`&&typeof t.xyYCol==`string`&&typeof t.xyColor==`string`&&typeof t.xyPointRadius==`number`}function Xn(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t.xyzViewMode,r=n===`3d`||n===`xy`||n===`xz`||n===`yz`;return t.kind===`xyzmesh`&&typeof t.xyzXCol==`string`&&typeof t.xyzYCol==`string`&&typeof t.xyzZCol==`string`&&r&&typeof t.xyzPointRadius==`number`}function Zn(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.value!=`number`||!Number.isFinite(t.value)||t.style!==`solid`&&t.style!==`dashed`&&t.style!==`dotted`||typeof t.width!=`number`||typeof t.color!=`string`?null:{value:t.value,style:t.style,width:t.width,color:t.color,...typeof t.ruleId==`string`&&Qn.test(t.ruleId)?{ruleId:t.ruleId}:{}}}var Qn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $n(e,t){if(!t.size)return e;let n=!1,r=e=>{let r=e?.ruleId?t.get(e.ruleId):void 0;return!e||!r?e:(n=!0,{...e,value:r.value,linked:r.active?`active`:`idle`})},i=e,a=null,o=(e,t)=>{a??={...i},a[e]=t};if(e.kind===`multiband`){let t=e.series.map(e=>{let t=r(e.alarm);return t===e.alarm?e:{...e,alarm:t}});n&&o(`series`,t)}else if(e.kind===`gauge`){let t=e.ggGauges.map(e=>{let t=r(e.alarm);return t===e.alarm?e:{...e,alarm:t}});n&&o(`ggGauges`,t)}else if(e.kind===`xyscatter`||e.kind===`xyzmesh`){let t=e.kind===`xyscatter`?[`xyXScale`,`xyYScale`]:[`xyzXScale`,`xyzYScale`,`xyzZScale`];for(let e of t){let t=i[e],n=r(t?.alarm);t&&n!==t.alarm&&o(e,{...t,alarm:n})}}else if(e.kind in er){let t=er[e.kind],n=r(i[t]);n!==i[t]&&o(t,n)}return a||e}var er={histogram:`histAlarm`,spectrum:`specAlarm`,areachart:`acAlarm`,losscurve:`lcAlarm`,cdfchart:`cdAlarm`,bubblechart:`bbAlarm`,boxplot:`boxAlarm`,violin:`vlAlarm`,barchart:`bcAlarm`,gantt:`gtAlarm`};function tr(e){if(!e||!(e.kind in er))return null;let t=e[er[e.kind]];return t?{alarm:t,axis:e.kind===`histogram`||e.kind===`cdfchart`||e.kind===`gantt`||e.kind===`barchart`&&e.bcHorizontal||e.kind===`violin`&&e.vlOrientation===`horizontal`?`x`:`y`}:null}function nr(e){let t=$t();if(!e||typeof e!=`object`)return t;let n=e,r=Zn(n.alarm);return{scaleMin:typeof n.scaleMin==`string`?n.scaleMin:t.scaleMin,scaleMax:typeof n.scaleMax==`string`?n.scaleMax:t.scaleMax,majorStep:typeof n.majorStep==`string`?n.majorStep:t.majorStep,minorStep:typeof n.minorStep==`string`?n.minorStep:t.minorStep,alarm:r}}function rr(e,t,n){if(!e||typeof e!=`object`)return{};let r={};for(let[t,n]of Object.entries(e)){if(!t||typeof t!=`string`)continue;if(Jn(n)){let e=n;r[t]={kind:`multiband`,series:Array.isArray(e.series)?e.series.map(e=>e&&e.alarm&&typeof e.alarm==`object`?{...e,alarm:Zn(e.alarm)}:e):e.series,addColumn:e.addColumn,layout:e.layout===`parallel`?`parallel`:`overlay`,xAxisLine:qn(e.xAxisLine,en),yAxisLine:qn(e.yAxisLine,en),gridLine:qn(e.gridLine,tn),lineWidth:typeof e.lineWidth==`number`&&Number.isFinite(e.lineWidth)?Math.min(6,Math.max(.5,e.lineWidth)):1,...an(e.beacon)?{beacon:an(e.beacon)}:{},...e.envelope===!0?{envelope:!0}:{}}}else if(Yn(n)){let e=n,i=e.xyFit,a=i&&typeof i==`object`&&(i.degree===1||i.degree===2||i.degree===3)&&typeof i.color==`string`&&(i.lineStyle===`solid`||i.lineStyle===`dashed`||i.lineStyle===`dotted`)&&typeof i.width==`number`?{degree:i.degree,color:i.color,lineStyle:i.lineStyle,width:i.width}:null;r[t]={...n,xyColorCol:typeof e.xyColorCol==`string`?e.xyColorCol:null,xyPointRadius:Math.min(16,Math.max(.5,n.xyPointRadius)),xyDrawMode:e.xyDrawMode===`lines`||e.xyDrawMode===`both`?e.xyDrawMode:void 0,xyLineWidth:typeof e.xyLineWidth==`number`&&Number.isFinite(e.xyLineWidth)?Math.min(8,Math.max(.5,e.xyLineWidth)):void 0,xyXAxisLine:qn(e.xyXAxisLine,en),xyYAxisLine:qn(e.xyYAxisLine,en),xyGridLine:qn(e.xyGridLine,tn),xyFit:a,xyXScale:nr(e.xyXScale),xyYScale:nr(e.xyYScale)}}else if(Xn(n)){let e=e=>typeof e==`string`?e:``,i=n.xyzXScale?null:{scaleMin:e(n.xyzXMin),scaleMax:e(n.xyzXMax),majorStep:``,minorStep:``,alarm:null},a=n.xyzYScale?null:{scaleMin:e(n.xyzYMin),scaleMax:e(n.xyzYMax),majorStep:``,minorStep:``,alarm:null},o=n.xyzZScale?null:{scaleMin:e(n.xyzZMin),scaleMax:e(n.xyzZMax),majorStep:``,minorStep:``,alarm:null};r[t]={kind:`xyzmesh`,xyzXCol:n.xyzXCol,xyzYCol:n.xyzYCol,xyzZCol:n.xyzZCol,xyzViewMode:n.xyzViewMode,xyzXScale:i??nr(n.xyzXScale),xyzYScale:a??nr(n.xyzYScale),xyzZScale:o??nr(n.xyzZScale),xyzPointRadius:Math.min(16,Math.max(.5,n.xyzPointRadius)),showMesh:n.showMesh===!0,meshStyle:n.meshStyle===`wireframe`||n.meshStyle===`both`?n.meshStyle:`filled`,meshOpacity:typeof n.meshOpacity==`number`&&n.meshOpacity>=0&&n.meshOpacity<=1?n.meshOpacity:.85,...n.xyzMode===`matrix`?{xyzMode:`matrix`}:{},...Array.isArray(n.xyzColumns)?{xyzColumns:n.xyzColumns.filter(e=>typeof e==`string`)}:{}}}else if(n&&typeof n==`object`&&n.kind===`histogram`){let e=n;r[t]={kind:`histogram`,histColumn:typeof e.histColumn==`string`?e.histColumn:``,histBins:typeof e.histBins==`number`?e.histBins:0,histColor:typeof e.histColor==`string`?e.histColor:`#38bdf8`,histNormal:e.histNormal===!0,histLogY:e.histLogY===!0}}else if(n&&typeof n==`object`&&n.kind===`polar`){let e=n;r[t]={kind:`polar`,polarAngleCol:typeof e.polarAngleCol==`string`?e.polarAngleCol:``,polarRadiusCol:typeof e.polarRadiusCol==`string`?e.polarRadiusCol:``,polarColor:typeof e.polarColor==`string`?e.polarColor:`#a78bfa`,polarMode:e.polarMode===`rose`?`rose`:`waveform`,polarRadiusMin:typeof e.polarRadiusMin==`string`?e.polarRadiusMin:``,polarRadiusMax:typeof e.polarRadiusMax==`string`?e.polarRadiusMax:``}}else if(n&&typeof n==`object`&&n.kind===`spectrum`){let e=n;r[t]={kind:`spectrum`,specSignalCol:typeof e.specSignalCol==`string`?e.specSignalCol:``,specTimeCol:typeof e.specTimeCol==`string`?e.specTimeCol:``,specSampleRate:typeof e.specSampleRate==`string`?e.specSampleRate:`1000`,specXMode:e.specXMode===`order`?`order`:`hz`,specYMode:e.specYMode===`db`?`db`:`amplitude`,specWindow:e.specWindow===`rectangular`?`rectangular`:`hann`,specColor:typeof e.specColor==`string`?e.specColor:`#34d399`,specLogX:e.specLogX===!0}}else if(n&&typeof n==`object`&&n.kind===`boxplot`){let e=n;r[t]={kind:`boxplot`,boxValueCol:typeof e.boxValueCol==`string`?e.boxValueCol:``,boxGroupCol:typeof e.boxGroupCol==`string`?e.boxGroupCol:``,boxColor:typeof e.boxColor==`string`?e.boxColor:`#fb923c`,boxWhiskers:e.boxWhiskers===`minmax`?`minmax`:`1.5iqr`}}else if(n&&typeof n==`object`&&n.kind===`spectrogram`){let e=n;r[t]={kind:`spectrogram`,sgSignalCol:typeof e.sgSignalCol==`string`?e.sgSignalCol:``,sgTimeCol:typeof e.sgTimeCol==`string`?e.sgTimeCol:``,sgSampleRate:typeof e.sgSampleRate==`string`?e.sgSampleRate:`1000`,sgWindowSize:typeof e.sgWindowSize==`number`?e.sgWindowSize:512,sgOverlap:typeof e.sgOverlap==`number`?e.sgOverlap:.5,sgWinFunc:e.sgWinFunc===`rectangular`?`rectangular`:`hann`,sgYMode:e.sgYMode===`amplitude`?`amplitude`:`db`,sgLogFreq:e.sgLogFreq===!0,...e.sgView===`waterfall`?{sgView:`waterfall`}:{}}}else if(n&&typeof n==`object`&&n.kind===`heatmap`){let e=n,i=Array.isArray(e.hmColumns)?e.hmColumns.filter(e=>typeof e==`string`):[],a=e=>Math.max(1,Math.min(50,typeof e==`number`&&Number.isFinite(e)?Math.floor(e):6)),o=e=>typeof e==`string`?e:``;r[t]={kind:`heatmap`,hmMode:e.hmMode===`raw`||e.hmMode===`binned`||e.hmMode===`count`||e.hmMode===`correlation`||e.hmMode===`matrix`?e.hmMode:`binned`,hmColumns:i,hmXCol:o(e.hmXCol),hmYCol:o(e.hmYCol),hmValueCol:o(e.hmValueCol),hmXBins:a(e.hmXBins),hmYBins:a(e.hmYBins),hmXMin:o(e.hmXMin),hmXMax:o(e.hmXMax),hmYMin:o(e.hmYMin),hmYMax:o(e.hmYMax),hmShowValues:e.hmShowValues!==!1,hmColorScheme:e.hmColorScheme===`plasma`||e.hmColorScheme===`viridis`?e.hmColorScheme:`diverging`,...e.hmSpacing===`values`?{hmSpacing:`values`}:{},...typeof e.hmContours==`number`&&e.hmContours>=1?{hmContours:Math.min(20,Math.round(e.hmContours))}:{},...e.hmRange&&typeof e.hmRange==`object`?{hmRange:{scaleMin:typeof e.hmRange.scaleMin==`string`?e.hmRange.scaleMin:``,scaleMax:typeof e.hmRange.scaleMax==`string`?e.hmRange.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`violin`){let e=n;r[t]={kind:`violin`,vlValueCol:typeof e.vlValueCol==`string`?e.vlValueCol:``,vlGroupCol:typeof e.vlGroupCol==`string`?e.vlGroupCol:``,vlColor:typeof e.vlColor==`string`?e.vlColor:`#818cf8`,vlShowBox:e.vlShowBox!==!1,vlBandwidth:typeof e.vlBandwidth==`string`?e.vlBandwidth:``,vlOrientation:e.vlOrientation===`horizontal`?`horizontal`:`vertical`}}else if(n&&typeof n==`object`&&n.kind===`confusion`){let e=n;r[t]={kind:`confusion`,cfActualCol:typeof e.cfActualCol==`string`?e.cfActualCol:``,cfPredictedCol:typeof e.cfPredictedCol==`string`?e.cfPredictedCol:``,cfNormalize:e.cfNormalize===!0}}else if(n&&typeof n==`object`&&n.kind===`roc`){let e=n;r[t]={kind:`roc`,rocScoreCol:typeof e.rocScoreCol==`string`?e.rocScoreCol:``,rocLabelCol:typeof e.rocLabelCol==`string`?e.rocLabelCol:``,rocMode:e.rocMode===`pr`?`pr`:`roc`,rocColor:typeof e.rocColor==`string`?e.rocColor:`#f472b6`}}else if(n&&typeof n==`object`&&n.kind===`losscurve`){let e=n,i=e=>Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.column==`string`&&typeof e.color==`string`):[];r[t]={kind:`losscurve`,lcXCol:typeof e.lcXCol==`string`?e.lcXCol:``,lcLeftCols:i(e.lcLeftCols),lcRightCols:i(e.lcRightCols)}}else if(n&&typeof n==`object`&&n.kind===`controlchart`){let e=n;r[t]={kind:`controlchart`,ccValueCol:typeof e.ccValueCol==`string`?e.ccValueCol:``,ccSubgroupCol:typeof e.ccSubgroupCol==`string`?e.ccSubgroupCol:``,ccSigmaLevel:typeof e.ccSigmaLevel==`number`?e.ccSigmaLevel:3,ccColor:typeof e.ccColor==`string`?e.ccColor:`#22d3ee`}}else if(n&&typeof n==`object`&&n.kind===`parallelcoords`){let e=n;r[t]={kind:`parallelcoords`,pcColumns:Array.isArray(e.pcColumns)?e.pcColumns.filter(e=>typeof e==`string`):[],pcColorByCol:typeof e.pcColorByCol==`string`?e.pcColorByCol:``,pcColor:typeof e.pcColor==`string`?e.pcColor:`#64748b`}}else if(n&&typeof n==`object`&&n.kind===`embedding`){let e=n;r[t]={kind:`embedding`,emXCol:typeof e.emXCol==`string`?e.emXCol:``,emYCol:typeof e.emYCol==`string`?e.emYCol:``,emColorCol:typeof e.emColorCol==`string`?e.emColorCol:``,emColorMode:e.emColorMode===`numeric`?`numeric`:`categorical`,emLabelCol:typeof e.emLabelCol==`string`?e.emLabelCol:``,emPointSize:typeof e.emPointSize==`number`?e.emPointSize:3,emColor:typeof e.emColor==`string`?e.emColor:`#a78bfa`}}else if(n&&typeof n==`object`&&n.kind===`flamegraph`){let e=n;r[t]={kind:`flamegraph`,fgNameCol:typeof e.fgNameCol==`string`?e.fgNameCol:``,fgParentCol:typeof e.fgParentCol==`string`?e.fgParentCol:``,fgValueCol:typeof e.fgValueCol==`string`?e.fgValueCol:``,fgDirection:e.fgDirection===`bottomup`?`bottomup`:`topdown`}}else if(n&&typeof n==`object`&&n.kind===`barchart`){let e=n,i=Array.isArray(e.bcValueCols)?e.bcValueCols.filter(e=>typeof e==`string`):[],a=e.bcValueScale;r[t]={kind:`barchart`,bcCategoryCol:typeof e.bcCategoryCol==`string`?e.bcCategoryCol:``,bcValueCols:i,bcMode:e.bcMode===`stacked`?`stacked`:`grouped`,bcHorizontal:e.bcHorizontal===!0,...a&&typeof a==`object`?{bcValueScale:{scaleMin:typeof a.scaleMin==`string`?a.scaleMin:``,scaleMax:typeof a.scaleMax==`string`?a.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`radar`){let e=n;r[t]={kind:`radar`,rdAxesCols:Array.isArray(e.rdAxesCols)?e.rdAxesCols.filter(e=>typeof e==`string`):[],rdGroupCol:typeof e.rdGroupCol==`string`?e.rdGroupCol:``,rdColor:typeof e.rdColor==`string`?e.rdColor:`#38bdf8`,rdFill:e.rdFill!==!1}}else if(n&&typeof n==`object`&&n.kind===`areachart`){let e=n,i=Array.isArray(e.acYCols)?e.acYCols.filter(e=>typeof e==`string`):[],a=e.acYScale;r[t]={kind:`areachart`,acXCol:typeof e.acXCol==`string`?e.acXCol:``,acYCols:i,acStacked:e.acStacked===!0,...a&&typeof a==`object`?{acYScale:{scaleMin:typeof a.scaleMin==`string`?a.scaleMin:``,scaleMax:typeof a.scaleMax==`string`?a.scaleMax:``}}:{}}}else if(n&&typeof n==`object`&&n.kind===`cdfchart`){let e=n;r[t]={kind:`cdfchart`,cdValueCols:Array.isArray(e.cdValueCols)?e.cdValueCols.filter(e=>typeof e==`string`):[],cdComplement:e.cdComplement===!0,cdLogX:e.cdLogX===!0}}else if(n&&typeof n==`object`&&n.kind===`bubblechart`){let e=n;r[t]={kind:`bubblechart`,bbXCol:typeof e.bbXCol==`string`?e.bbXCol:``,bbYCol:typeof e.bbYCol==`string`?e.bbYCol:``,bbSizeCol:typeof e.bbSizeCol==`string`?e.bbSizeCol:``,bbColorCol:typeof e.bbColorCol==`string`?e.bbColorCol:``,bbColorMode:e.bbColorMode===`numeric`?`numeric`:`categorical`,bbColor:typeof e.bbColor==`string`?e.bbColor:`#64748b`,bbMaxRadius:typeof e.bbMaxRadius==`number`?e.bbMaxRadius:24}}else if(n&&typeof n==`object`&&n.kind===`treemap`){let e=n;r[t]={kind:`treemap`,tmNameCol:typeof e.tmNameCol==`string`?e.tmNameCol:``,tmParentCol:typeof e.tmParentCol==`string`?e.tmParentCol:``,tmValueCol:typeof e.tmValueCol==`string`?e.tmValueCol:``}}else if(n&&typeof n==`object`&&n.kind===`sankey`){let e=n;r[t]={kind:`sankey`,skSourceCol:typeof e.skSourceCol==`string`?e.skSourceCol:``,skTargetCol:typeof e.skTargetCol==`string`?e.skTargetCol:``,skValueCol:typeof e.skValueCol==`string`?e.skValueCol:``}}else if(n&&typeof n==`object`&&n.kind===`gauge`){let e=n;r[t]={kind:`gauge`,ggGauges:Array.isArray(e.ggGauges)?e.ggGauges.flatMap((e,t)=>{let n=cn(e,t);return n?[n]:[]}):[]}}else if(n&&typeof n==`object`&&n.kind===`calibration`){let e=n;r[t]={kind:`calibration`,cbScoreCol:typeof e.cbScoreCol==`string`?e.cbScoreCol:``,cbLabelCol:typeof e.cbLabelCol==`string`?e.cbLabelCol:``,cbBins:typeof e.cbBins==`number`?e.cbBins:10,cbColor:typeof e.cbColor==`string`?e.cbColor:`#38bdf8`}}else if(n&&typeof n==`object`&&n.kind===`qqplot`){let e=n;r[t]={kind:`qqplot`,qqValueCol:typeof e.qqValueCol==`string`?e.qqValueCol:``,qqMode:e.qqMode===`column`?`column`:`normal`,qqRefCol:typeof e.qqRefCol==`string`?e.qqRefCol:``,qqColor:typeof e.qqColor==`string`?e.qqColor:`#a78bfa`}}else if(n&&typeof n==`object`&&n.kind===`gantt`){let e=n;r[t]={kind:`gantt`,gtLabelCol:typeof e.gtLabelCol==`string`?e.gtLabelCol:``,gtStartCol:typeof e.gtStartCol==`string`?e.gtStartCol:``,gtEndCol:typeof e.gtEndCol==`string`?e.gtEndCol:``,gtGroupCol:typeof e.gtGroupCol==`string`?e.gtGroupCol:``}}else if(n&&typeof n==`object`&&n.kind===`camera`){let e=n,i=typeof e.offsetMs==`number`&&Number.isFinite(e.offsetMs)?Math.round(e.offsetMs):0,a=Array.isArray(e.cameras)?[...new Set(e.cameras.filter(e=>typeof e==`string`&&e!==``))]:[],o=typeof e.cameraStreamId==`string`&&e.cameraStreamId?e.cameraStreamId:a[0]??``;r[t]={kind:`camera`,cameraStreamId:o,cameras:Wn({cameraStreamId:o,cameras:a.length?a:[o]}),syncStreamId:typeof e.syncStreamId==`string`?e.syncStreamId:``,offsetMs:Math.max(-1e4,Math.min(1e4,i)),fit:e.fit===`cover`?`cover`:`contain`}}let e=r[t]?Pt(n?.annotations):null;e?.length&&(r[t]={...r[t],annotations:e});let i=r[t]?er[r[t].kind]:void 0,a=i?Zn(n[i]):null;i&&a&&(r[t]={...r[t],[i]:a})}return r}function ir(e,t,n,r){let i={...t},a=!1;for(let t of e)if(t.kind===`multiband`){let e=i[t.id];(!e||e.kind!==`multiband`)&&(i[t.id]=pn(),a=!0)}else if(t.kind===`xyscatter`){let e=i[t.id];(!e||e.kind!==`xyscatter`)&&(i[t.id]=mn(n),a=!0)}else if(t.kind===`xyzmesh`){let e=i[t.id];(!e||e.kind!==`xyzmesh`)&&(i[t.id]=hn(r),a=!0)}else if(t.kind===`histogram`){let e=i[t.id];(!e||e.kind!==`histogram`)&&(i[t.id]=gn(),a=!0)}else if(t.kind===`polar`){let e=i[t.id];(!e||e.kind!==`polar`)&&(i[t.id]=_n(),a=!0)}else if(t.kind===`spectrum`){let e=i[t.id];(!e||e.kind!==`spectrum`)&&(i[t.id]=vn(),a=!0)}else if(t.kind===`boxplot`){let e=i[t.id];(!e||e.kind!==`boxplot`)&&(i[t.id]=yn(),a=!0)}else t.kind===`spectrogram`?(!i[t.id]||i[t.id].kind!==`spectrogram`)&&(i[t.id]=bn(),a=!0):t.kind===`heatmap`?(!i[t.id]||i[t.id].kind!==`heatmap`)&&(i[t.id]=xn(),a=!0):t.kind===`violin`?(!i[t.id]||i[t.id].kind!==`violin`)&&(i[t.id]=Sn(),a=!0):t.kind===`confusion`?(!i[t.id]||i[t.id].kind!==`confusion`)&&(i[t.id]=Cn(),a=!0):t.kind===`roc`?(!i[t.id]||i[t.id].kind!==`roc`)&&(i[t.id]=wn(),a=!0):t.kind===`losscurve`?(!i[t.id]||i[t.id].kind!==`losscurve`)&&(i[t.id]=Tn(),a=!0):t.kind===`controlchart`?(!i[t.id]||i[t.id].kind!==`controlchart`)&&(i[t.id]=En(),a=!0):t.kind===`parallelcoords`?(!i[t.id]||i[t.id].kind!==`parallelcoords`)&&(i[t.id]=Dn(),a=!0):t.kind===`embedding`?(!i[t.id]||i[t.id].kind!==`embedding`)&&(i[t.id]=On(),a=!0):t.kind===`flamegraph`?(!i[t.id]||i[t.id].kind!==`flamegraph`)&&(i[t.id]=kn(),a=!0):t.kind===`barchart`?(!i[t.id]||i[t.id].kind!==`barchart`)&&(i[t.id]=An(),a=!0):t.kind===`radar`?(!i[t.id]||i[t.id].kind!==`radar`)&&(i[t.id]=jn(),a=!0):t.kind===`areachart`?(!i[t.id]||i[t.id].kind!==`areachart`)&&(i[t.id]=Mn(),a=!0):t.kind===`cdfchart`?(!i[t.id]||i[t.id].kind!==`cdfchart`)&&(i[t.id]=Nn(),a=!0):t.kind===`bubblechart`?(!i[t.id]||i[t.id].kind!==`bubblechart`)&&(i[t.id]=Pn(),a=!0):t.kind===`treemap`?(!i[t.id]||i[t.id].kind!==`treemap`)&&(i[t.id]=Fn(),a=!0):t.kind===`sankey`?(!i[t.id]||i[t.id].kind!==`sankey`)&&(i[t.id]=In(),a=!0):t.kind===`gauge`?(!i[t.id]||i[t.id].kind!==`gauge`)&&(i[t.id]=Ln(),a=!0):t.kind===`calibration`?(!i[t.id]||i[t.id].kind!==`calibration`)&&(i[t.id]=Rn(),a=!0):t.kind===`qqplot`?(!i[t.id]||i[t.id].kind!==`qqplot`)&&(i[t.id]=zn(),a=!0):t.kind===`gantt`?(!i[t.id]||i[t.id].kind!==`gantt`)&&(i[t.id]=Bn(),a=!0):t.kind===`camera`&&(!i[t.id]||i[t.id].kind!==`camera`)&&(i[t.id]=Hn(),a=!0);for(let t of Object.keys(i))e.some(e=>e.id===t)||(delete i[t],a=!0);return a?i:t}function ar(e){return e===null||typeof e==`number`&&e>0?{liveWindowSeconds:e}:{}}function or(e){return Number.isNaN(e)?0:Math.min(100,Math.max(0,e))}function sr(){return crypto.randomUUID()}function cr(e={}){let t=Date.now();return{id:crypto.randomUUID(),name:``,units:``,formula:``,enabled:!0,createdAt:t,updatedAt:t,source:`personal`,sharedWithOrgId:null,projectId:null,ownerUserId:``,ownerDisplayName:null,ownerLastName:null,...e}}function lr(){return lr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lr.apply(null,arguments)}var ur={relTol:1e-12,absTol:1e-15,matrix:`Matrix`,number:`number`,numberFallback:`number`,precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function dr(e,t){if(pr(e,t)||mr(e,t))return e[t];throw _r(e,t)?Error(`Cannot access method "${t}" as a property`):e==null?TypeError(`Cannot access property "${t}": object is ${e}`):Error(`No access to property "`+t+`"`)}function fr(e,t,n){if(pr(e,t)||mr(e,t))return e[t]=n,n;throw Error(`No access to property "${t}"`)}function pr(e,t){return vr(e)?!(t in Object.prototype):!1}function mr(e,t){return Array.isArray(e)?typeof t==`number`||typeof t==`string`&&hr(t)||t===`length`:!1}function hr(e){return/^\d+$/.test(e)}function gr(e,t){if(!_r(e,t))throw Error(`No access to method "`+t+`"`);return e[t]}function _r(e,t){return e==null||typeof e[t]!=`function`||Ti(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)?!1:yr.has(t)?!0:!(t in Object.prototype||t in Function.prototype)}function vr(e){return typeof e==`object`&&e&&e.constructor===Object}var yr=new Set([`toString`,`valueOf`,`toLocaleString`]),br=class{constructor(e){this.wrappedObject=e,this[Symbol.iterator]=this.entries}keys(){return Object.keys(this.wrappedObject).filter(e=>this.has(e)).values()}get(e){return dr(this.wrappedObject,e)}set(e,t){return fr(this.wrappedObject,e,t),this}has(e){return pr(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Sr(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){pr(this.wrappedObject,e)&&delete this.wrappedObject[e]}clear(){for(var e of this.keys())this.delete(e)}get size(){return Object.keys(this.wrappedObject).length}},xr=class{constructor(e,t,n){this.a=e,this.b=t,this.bKeys=n,this[Symbol.iterator]=this.entries}get(e){return this.bKeys.has(e)?this.b.get(e):this.a.get(e)}set(e,t){return this.bKeys.has(e)?this.b.set(e,t):this.a.set(e,t),this}has(e){return this.b.has(e)||this.a.has(e)}keys(){return new Set([...this.a.keys(),...this.b.keys()])[Symbol.iterator]()}entries(){return Sr(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){return this.bKeys.has(e)?this.b.delete(e):this.a.delete(e)}clear(){this.a.clear(),this.b.clear()}get size(){return[...this.keys()].length}};function Sr(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function Cr(){return new Map}function wr(e){if(!e)return Cr();if(qr(e))return e;if(Kr(e))return new br(e);throw Error(`createMap can create maps from objects or Maps`)}function Tr(e){if(e instanceof br)return e.wrappedObject;var t={};for(var n of e.keys())fr(t,n,e.get(n));return t}function Er(e){return typeof e==`number`}function Dr(e){return!e||typeof e!=`object`||typeof e.constructor!=`function`?!1:e.isBigNumber===!0&&typeof e.constructor.prototype==`object`&&e.constructor.prototype.isBigNumber===!0||typeof e.constructor.isDecimal==`function`&&e.constructor.isDecimal(e)===!0}function Or(e){return typeof e==`bigint`}function kr(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isComplex===!0||!1}function Ar(e){return e&&typeof e==`object`&&Object.getPrototypeOf(e).isFraction===!0||!1}function jr(e){return e&&e.constructor.prototype.isUnit===!0||!1}function Mr(e){return typeof e==`string`}var Nr=Array.isArray;function Pr(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function Fr(e){return Array.isArray(e)||Pr(e)}function Ir(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Lr(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function Rr(e){return e&&e.constructor.prototype.isRange===!0||!1}function zr(e){return e&&e.constructor.prototype.isIndex===!0||!1}function Br(e){return typeof e==`boolean`}function Vr(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function Hr(e){return e&&e.constructor.prototype.isHelp===!0||!1}function Ur(e){return typeof e==`function`}function Wr(e){return e instanceof Date}function Gr(e){return e instanceof RegExp}function Kr(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!kr(e)&&!Ar(e))}function qr(e){return e?e instanceof Map||e instanceof br||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function Jr(e){return qr(e)&&qr(e.a)&&qr(e.b)}function Yr(e){return qr(e)&&Kr(e.wrappedObject)}function Xr(e){return e===null}function Zr(e){return e===void 0}function Qr(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function $r(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function ei(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function ti(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function ni(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function ri(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function ii(e){return ri(e)||ui(e)&&e.args.length===1&&ri(e.args[0])&&`-+~`.includes(e.op)}function ai(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function oi(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function si(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function ci(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function li(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function ui(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function di(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function fi(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function pi(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function mi(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function hi(e){return e&&e.constructor.prototype.isChain===!0||!1}function gi(e){var t=typeof e;return t===`object`?e===null?`null`:Dr(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function _i(e){var t=typeof e;if(t===`number`||t===`bigint`||t===`string`||t===`boolean`||e==null)return e;if(typeof e.clone==`function`)return e.clone();if(Array.isArray(e))return e.map(function(e){return _i(e)});if(e instanceof Date)return new Date(e.valueOf());if(Dr(e))return e;if(Kr(e))return vi(e,_i);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function vi(e,t){var n={};for(var r in e)Ti(e,r)&&(n[r]=t(e[r]));return n}function yi(e,t){for(var n in t)Ti(t,n)&&(e[n]=t[n]);return e}function bi(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(Ti(t,n)&&!(n in Object.prototype)&&!(n in Function.prototype))if(t[n]&&t[n].constructor===Object)e[n]===void 0&&(e[n]={}),e[n]&&e[n].constructor===Object?bi(e[n],t[n]):e[n]=t[n];else if(Array.isArray(t[n]))throw TypeError(`Arrays are not supported by deepExtend`);else e[n]=t[n];return e}function xi(e,t){var n,r,i;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(r=0,i=e.length;r<i;r++)if(!xi(e[r],t[r]))return!1;return!0}else if(typeof e==`function`)return e===t;else if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!(n in t)||!xi(e[n],t[n]))return!1;for(n in t)if(!(n in e))return!1;return!0}else return e===t}function Si(e){var t={};return Ci(e,t),t}function Ci(e,t){for(var n in e)if(Ti(e,n)){var r=e[n];typeof r==`object`&&r?Ci(r,t):t[n]=r}}function wi(e,t,n){var r=!0,i;Object.defineProperty(e,t,{get:function(){return r&&=(i=n(),!1),i},set:function(e){i=e,r=!1},configurable:!0,enumerable:!0})}function Ti(e,t){return e&&Object.hasOwnProperty.call(e,t)}function Ei(e){return e&&typeof e.factory==`function`}function Di(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r],a=e[i];a!==void 0&&(n[i]=a)}return n}var Oi=[`Matrix`,`Array`],ki=[`number`,`BigNumber`,`bigint`,`Fraction`];function Ai(e,t){function n(r){if(r){if(r.epsilon!==void 0){console.warn(`Warning: The configuration option "epsilon" is deprecated. Use "relTol" and "absTol" instead.`);var i=_i(r);return i.relTol=r.epsilon,i.absTol=r.epsilon*.001,delete i.epsilon,n(i)}r.legacySubset===!0&&console.warn(`Warning: The configuration option "legacySubset" is for compatibility only and might be deprecated in the future.`);var a=_i(e);ji(r,`matrix`,Oi),ji(r,`number`,ki),bi(e,r);var o=_i(e);return t(`config`,o,a,_i(r)),o}else return _i(e)}return n.MATRIX_OPTIONS=Oi,n.NUMBER_OPTIONS=ki,Object.keys(ur).forEach(t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function ji(e,t,n){e[t]!==void 0&&!n.includes(e[t])&&console.warn(`Warning: Unknown value "`+e[t]+`" for configuration option "`+t+`". Available options: `+n.map(e=>JSON.stringify(e)).join(`, `)+`.`)}var Mi=wt(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self,n.typed=r())})(e,(function(){function e(){return!0}function t(){return!1}function n(){}let r=`Argument is not a typed-function.`;function i(){function a(e){return typeof e==`object`&&!!e&&e.constructor===Object}let o=[{name:`number`,test:function(e){return typeof e==`number`}},{name:`string`,test:function(e){return typeof e==`string`}},{name:`boolean`,test:function(e){return typeof e==`boolean`}},{name:`Function`,test:function(e){return typeof e==`function`}},{name:`Array`,test:Array.isArray},{name:`Date`,test:function(e){return e instanceof Date}},{name:`RegExp`,test:function(e){return e instanceof RegExp}},{name:`Object`,test:a},{name:`null`,test:function(e){return e===null}},{name:`undefined`,test:function(e){return e===void 0}}],s={name:`any`,test:e,isAny:!0},c,l,u=0,d={createCount:0};function f(e){let t=c.get(e);if(t)return t;let n=`Unknown type "`+e+`"`,r=e.toLowerCase(),i;for(i of l)if(i.toLowerCase()===r){n+=`. Did you mean "`+i+`" ?`;break}throw TypeError(n)}function p(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`any`,n=t?f(t).index:l.length,r=[];for(let t=0;t<e.length;++t){if(!e[t]||typeof e[t].name!=`string`||typeof e[t].test!=`function`)throw TypeError(`Object with properties {name: string, test: function} expected`);let i=e[t].name;if(c.has(i))throw TypeError(`Duplicate type name "`+i+`"`);r.push(i),c.set(i,{name:i,test:e[t].test,isAny:e[t].isAny,index:n+t,conversionsTo:[]})}let i=l.slice(n);l=l.slice(0,n).concat(r).concat(i);for(let e=n+r.length;e<l.length;++e)c.get(l[e]).index=e}function m(){c=new Map,l=[],u=0,p([s],!1)}m(),p(o);function h(){let e;for(e of l)c.get(e).conversionsTo=[];u=0}function g(e){let t=l.filter(t=>{let n=c.get(t);return!n.isAny&&n.test(e)});return t.length?t:[`any`]}function _(e){return e&&typeof e==`function`&&`_typedFunctionData`in e}function v(e,t,n){if(!_(e))throw TypeError(r);let i=n&&n.exact,a=T(Array.isArray(t)?t.join(`,`):t),o=x(a);if(!i||o in e.signatures){let t=e._typedFunctionData.signatureMap.get(o);if(t)return t}let s=a.length,c;if(i){c=[];let t;for(t in e.signatures)c.push(e._typedFunctionData.signatureMap.get(t))}else c=e._typedFunctionData.signatures;for(let e=0;e<s;++e){let t=a[e],n=[],r;for(r of c){let i=k(r.params,e);if(!(!i||t.restParam&&!i.restParam)){if(!i.hasAny){let e=w(i);if(t.types.some(t=>!e.has(t.name)))continue}n.push(r)}}if(c=n,c.length===0)break}let l;for(l of c)if(l.params.length<=s)return l;throw TypeError(`Signature not found (signature: `+(e.name||`unnamed`)+`(`+x(a,`, `)+`))`)}function y(e,t,n){return v(e,t,n).implementation}function b(e,t){let n=f(t);if(n.test(e))return e;let r=n.conversionsTo;if(r.length===0)throw Error(`There are no conversions to `+t+` defined.`);for(let t=0;t<r.length;t++)if(f(r[t].from).test(e))return r[t].convert(e);throw Error(`Cannot convert `+e+` to `+t)}function x(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`,`;return e.map(e=>e.name).join(t)}function S(e){let t=e.indexOf(`...`)===0,n=(t?e.length>3?e.slice(3):`any`:e).split(`|`).map(e=>f(e.trim())),r=!1,i=t?`...`:``;return{types:n.map(function(e){return r=e.isAny||r,i+=e.name+`|`,{name:e.name,typeIndex:e.index,test:e.test,isAny:e.isAny,conversion:null,conversionIndex:-1}}),name:i.slice(0,-1),hasAny:r,hasConversion:!1,restParam:t}}function C(e){let t=R(e.types.map(e=>e.name)),n=e.hasAny,r=e.name,i=t.map(function(e){let t=f(e.from);return n=t.isAny||n,r+=`|`+e.from,{name:e.from,typeIndex:t.index,test:t.test,isAny:t.isAny,conversion:e,conversionIndex:e.index}});return{types:e.types.concat(i),name:r,hasAny:n,hasConversion:i.length>0,restParam:e.restParam}}function w(e){return e.typeSet||(e.typeSet=new Set,e.types.forEach(t=>e.typeSet.add(t.name))),e.typeSet}function T(e){let t=[];if(typeof e!=`string`)throw TypeError(`Signatures must be strings`);let n=e.trim();if(n===``)return t;let r=n.split(`,`);for(let e=0;e<r.length;++e){let n=S(r[e].trim());if(n.restParam&&e!==r.length-1)throw SyntaxError(`Unexpected rest parameter "`+r[e]+`": only allowed for the last parameter`);if(n.types.length===0)return null;t.push(n)}return t}function E(e){let t=oe(e);return t?t.restParam:!1}function D(t){if(!t||t.types.length===0)return e;if(t.types.length===1)return f(t.types[0].name).test;if(t.types.length===2){let e=f(t.types[0].name).test,n=f(t.types[1].name).test;return function(t){return e(t)||n(t)}}else{let e=t.types.map(function(e){return f(e.name).test});return function(t){for(let n=0;n<e.length;n++)if(e[n](t))return!0;return!1}}}function O(e){let t,n,r;if(E(e)){t=ae(e).map(D);let n=t.length,r=D(oe(e)),i=function(e){for(let t=n;t<e.length;t++)if(!r(e[t]))return!1;return!0};return function(e){for(let n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return i(e)&&e.length>=n+1}}else if(e.length===0)return function(e){return e.length===0};else if(e.length===1)return n=D(e[0]),function(e){return n(e[0])&&e.length===1};else if(e.length===2)return n=D(e[0]),r=D(e[1]),function(e){return n(e[0])&&r(e[1])&&e.length===2};else return t=e.map(D),function(e){for(let n=0;n<t.length;n++)if(!t[n](e[n]))return!1;return e.length===t.length}}function k(e,t){return t<e.length?e[t]:E(e)?oe(e):null}function A(e,t){let n=k(e,t);return n?w(n):new Set}function j(e){return e.conversion===null||e.conversion===void 0}function M(e,t){let n=new Set;return e.forEach(e=>{let r=A(e.params,t),i;for(i of r)n.add(i)}),n.has(`any`)?[`any`]:Array.from(n)}function N(e,t,n){let r,i,a=e||`unnamed`,o=n,s;for(s=0;s<t.length;s++){let e=[];if(o.forEach(n=>{let r=D(k(n.params,s));(s<n.params.length||E(n.params))&&r(t[s])&&e.push(n)}),e.length===0){if(i=M(o,s),i.length>0){let e=g(t[s]);return r=TypeError(`Unexpected type of argument in function `+a+` (expected: `+i.join(` or `)+`, actual: `+e.join(` | `)+`, index: `+s+`)`),r.data={category:`wrongType`,fn:a,index:s,actual:e,expected:i},r}}else o=e}let c=o.map(function(e){return E(e.params)?1/0:e.params.length});if(t.length<Math.min.apply(null,c))return i=M(o,s),r=TypeError(`Too few arguments in function `+a+` (expected: `+i.join(` or `)+`, index: `+t.length+`)`),r.data={category:`tooFewArgs`,fn:a,index:t.length,expected:i},r;let l=Math.max.apply(null,c);if(t.length>l)return r=TypeError(`Too many arguments in function `+a+` (expected: `+l+`, actual: `+t.length+`)`),r.data={category:`tooManyArgs`,fn:a,index:t.length,expectedLength:l},r;let u=[];for(let e=0;e<t.length;++e)u.push(g(t[e]).join(`|`));return r=TypeError(`Arguments of type "`+u.join(`, `)+`" do not match any of the defined signatures of function `+a+`.`),r.data={category:`mismatch`,actual:u},r}function P(e){let t=l.length+1;for(let n=0;n<e.types.length;n++)t=Math.min(t,e.types[n].typeIndex);return t}function F(e){let t=u+1;for(let n=0;n<e.types.length;n++)j(e.types[n])||(t=Math.min(t,e.types[n].conversionIndex));return t}function I(e,t){if(e.hasAny){if(!t.hasAny)return .1}else if(t.hasAny)return-.1;if(e.restParam){if(!t.restParam)return .01}else if(t.restParam)return-.01;let n=P(e)-P(t);if(n<0)return-.001;if(n>0)return .001;let r=F(e),i=F(t);if(e.hasConversion){if(!t.hasConversion)return(1+r)*1e-6}else if(t.hasConversion)return-(1+i)*1e-6;let a=r-i;return a<0?-1e-7:a>0?1e-7:0}function L(e,t){let n=e.params,r=t.params,i=oe(n),a=oe(r),o=E(n),s=E(r);if(o&&i.hasAny){if(!s||!a.hasAny)return 1e7}else if(s&&a.hasAny)return-1e7;let c=0,l=0,u;for(u of n)u.hasAny&&++c,u.hasConversion&&++l;let d=0,f=0;for(u of r)u.hasAny&&++d,u.hasConversion&&++f;if(c!==d)return(c-d)*1e6;if(o&&i.hasConversion){if(!s||!a.hasConversion)return 1e5}else if(s&&a.hasConversion)return-1e5;if(l!==f)return(l-f)*1e4;if(o){if(!s)return 1e3}else if(s)return-1e3;let p=(n.length-r.length)*(o?-100:100);if(p!==0)return p;let m=[],h=0;for(let e=0;e<n.length;++e){let t=I(n[e],r[e]);m.push(t),h+=t}if(h!==0)return(h<0?-10:10)+h;let g,_=9,v=_/(m.length+1);for(g of m){if(g!==0)return(g<0?-_:_)+g;_-=v}return 0}function R(e){if(e.length===0)return[];let t=e.map(f);if(e.length===1)return t[0].conversionsTo;let n=new Set(e),r=new Set;for(let e=0;e<t.length;++e)for(let i of t[e].conversionsTo)n.has(i.from)||r.add(i.from);let i=[];for(let e of r){let n=u+1,r=null;for(let i=0;i<t.length;++i)for(let a of t[i].conversionsTo)a.from===e&&a.index<n&&(n=a.index,r=a);i.push(r)}return i}function z(e,t){let n=t,r=``;if(e.some(e=>e.hasConversion)){let i=E(e),a=e.map(B);r=a.map(e=>e.name).join(`;`),n=function(){let e=[],n=i?arguments.length-1:arguments.length;for(let t=0;t<n;t++)e[t]=a[t](arguments[t]);return i&&(e[n]=arguments[n].map(a[n])),t.apply(this,e)}}let i=n;if(E(e)){let t=e.length-1;i=function(){return n.apply(this,se(arguments,0,t).concat([se(arguments,t)]))}}return r&&Object.defineProperty(i,`name`,{value:r}),i}function B(e){let t,n,r,i,a=[],o=[],s=``;e.types.forEach(function(e){e.conversion&&(s+=e.conversion.from+`~>`+e.conversion.to+`,`,a.push(f(e.conversion.from).test),o.push(e.conversion.convert))}),s=s?s.slice(0,-1):`pass`;let c=e=>e;switch(o.length){case 0:break;case 1:t=a[0],r=o[0],c=function(e){return t(e)?r(e):e};break;case 2:t=a[0],n=a[1],r=o[0],i=o[1],c=function(e){return t(e)?r(e):n(e)?i(e):e};break;default:c=function(e){for(let t=0;t<o.length;t++)if(a[t](e))return o[t](e);return e}}return Object.defineProperty(c,`name`,{value:s}),c}function V(e){function t(e,n,r){if(n<e.length){let i=e[n],a=[];if(i.restParam){let e=i.types.filter(j);e.length<i.types.length&&a.push({types:e,name:`...`+e.map(e=>e.name).join(`|`),hasAny:e.some(e=>e.isAny),hasConversion:!1,restParam:!0}),a.push(i)}else a=i.types.map(function(e){return{types:[e],name:e.name,hasAny:e.isAny,hasConversion:e.conversion,restParam:!1}});return le(a,function(i){return t(e,n+1,r.concat([i]))})}else return[r]}return t(e,0,[])}function ee(e,t){let n=Math.max(e.length,t.length);for(let r=0;r<n;r++){let n=A(e,r),i=A(t,r),a=!1,o;for(o of i)if(n.has(o)){a=!0;break}if(!a)return!1}let r=e.length,i=t.length,a=E(e),o=E(t);return a?o?r===i:i>=r:o?r>=i:r===i}function te(e){return e.map(e=>me(e)?fe(e.referToSelf.callback):pe(e)?de(e.referTo.references,e.referTo.callback):e)}function H(e,t,n){let r=[],i;for(i of e){let e=n[i];if(typeof e!=`number`)throw TypeError(`No definition for referenced signature "`+i+`"`);if(e=t[e],typeof e!=`function`)return!1;r.push(e)}return r}function ne(e,t,n){let r=te(e),i=Array(r.length).fill(!1),a=!0;for(;a;){a=!1;let e=!0;for(let o=0;o<r.length;++o){if(i[o])continue;let s=r[o];if(me(s))r[o]=s.referToSelf.callback(n),r[o].referToSelf=s.referToSelf,i[o]=!0,e=!1;else if(pe(s)){let n=H(s.referTo.references,r,t);n?(r[o]=s.referTo.callback.apply(this,n),r[o].referTo=s.referTo,i[o]=!0,e=!1):a=!0}}if(e&&a)throw SyntaxError(`Circular reference detected in resolving typed.referTo`)}return r}function re(e){let t=/\bthis(\(|\.signatures\b)/;Object.keys(e).forEach(n=>{let r=e[n];if(t.test(r.toString()))throw SyntaxError("Using `this` to self-reference a function is deprecated since typed-function@3. Use typed.referTo and typed.referToSelf instead.")})}function ie(e,r){if(d.createCount++,Object.keys(r).length===0)throw SyntaxError(`No signatures provided`);d.warnAgainstDeprecatedThis&&re(r);let i=[],a=[],o={},s=[],c;for(c in r){if(!Object.prototype.hasOwnProperty.call(r,c))continue;let e=T(c);if(!e)continue;i.forEach(function(t){if(ee(t,e))throw TypeError(`Conflicting signatures "`+x(t)+`" and "`+x(e)+`".`)}),i.push(e);let t=a.length;a.push(r[c]);let n=e.map(C),l;for(l of V(n)){let e=x(l);s.push({params:l,name:e,fn:t}),l.every(e=>!e.hasConversion)&&(o[e]=t)}}s.sort(L);let l=ne(a,o,ve),u;for(u in o)Object.prototype.hasOwnProperty.call(o,u)&&(o[u]=l[o[u]]);let f=[],p=new Map;for(u of s)p.has(u.name)||(u.fn=l[u.fn],f.push(u),p.set(u.name,u));let m=f[0]&&f[0].params.length<=2&&!E(f[0].params),h=f[1]&&f[1].params.length<=2&&!E(f[1].params),g=f[2]&&f[2].params.length<=2&&!E(f[2].params),_=f[3]&&f[3].params.length<=2&&!E(f[3].params),v=f[4]&&f[4].params.length<=2&&!E(f[4].params),y=f[5]&&f[5].params.length<=2&&!E(f[5].params),b=m&&h&&g&&_&&v&&y;for(let e=0;e<f.length;++e)f[e].test=O(f[e].params);let S=m?D(f[0].params[0]):t,w=h?D(f[1].params[0]):t,k=g?D(f[2].params[0]):t,A=_?D(f[3].params[0]):t,j=v?D(f[4].params[0]):t,M=y?D(f[5].params[0]):t,N=m?D(f[0].params[1]):t,P=h?D(f[1].params[1]):t,F=g?D(f[2].params[1]):t,I=_?D(f[3].params[1]):t,R=v?D(f[4].params[1]):t,B=y?D(f[5].params[1]):t;for(let e=0;e<f.length;++e)f[e].implementation=z(f[e].params,f[e].fn);let te=m?f[0].implementation:n,H=h?f[1].implementation:n,ie=g?f[2].implementation:n,U=_?f[3].implementation:n,ae=v?f[4].implementation:n,oe=y?f[5].implementation:n,se=m?f[0].params.length:-1,ce=h?f[1].params.length:-1,le=g?f[2].params.length:-1,ue=_?f[3].params.length:-1,de=v?f[4].params.length:-1,fe=y?f[5].params.length:-1,pe=b?6:0,me=f.length,he=f.map(e=>e.test),ge=f.map(e=>e.implementation),_e=function(){for(let e=pe;e<me;e++)if(he[e](arguments))return ge[e].apply(this,arguments);return d.onMismatch(e,arguments,f)};function ve(e,t){return arguments.length===se&&S(e)&&N(t)?te.apply(this,arguments):arguments.length===ce&&w(e)&&P(t)?H.apply(this,arguments):arguments.length===le&&k(e)&&F(t)?ie.apply(this,arguments):arguments.length===ue&&A(e)&&I(t)?U.apply(this,arguments):arguments.length===de&&j(e)&&R(t)?ae.apply(this,arguments):arguments.length===fe&&M(e)&&B(t)?oe.apply(this,arguments):_e.apply(this,arguments)}try{Object.defineProperty(ve,`name`,{value:e})}catch{}return ve.signatures=o,ve._typedFunctionData={signatures:f,signatureMap:p},ve}function U(e,t,n){throw N(e,t,n)}function ae(e){return se(e,0,e.length-1)}function oe(e){return e[e.length-1]}function se(e,t,n){return Array.prototype.slice.call(e,t,n)}function ce(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return e[n]}function le(e,t){return Array.prototype.concat.apply([],e.map(t))}function ue(){let e=ae(arguments).map(e=>x(T(e))),t=oe(arguments);if(typeof t!=`function`)throw TypeError(`Callback function expected as last argument`);return de(e,t)}function de(e,t){return{referTo:{references:e,callback:t}}}function fe(e){if(typeof e!=`function`)throw TypeError(`Callback function expected as first argument`);return{referToSelf:{callback:e}}}function pe(e){return e&&typeof e.referTo==`object`&&Array.isArray(e.referTo.references)&&typeof e.referTo.callback==`function`}function me(e){return e&&typeof e.referToSelf==`object`&&typeof e.referToSelf.callback==`function`}function he(e,t){if(!e)return t;if(t&&t!==e){let n=Error(`Function names do not match (expected: `+e+`, actual: `+t+`)`);throw n.data={actual:t,expected:e},n}return e}function ge(e){let t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(_(e[n])||typeof e[n].signature==`string`)&&(t=he(t,e[n].name));return t}function _e(e,t){let n;for(n in t)if(Object.prototype.hasOwnProperty.call(t,n)){if(n in e&&t[n]!==e[n]){let r=Error(`Signature "`+n+`" is defined twice`);throw r.data={signature:n,sourceFunction:t[n],destFunction:e[n]},r}e[n]=t[n]}}let ve=d;d=function(e){let t=typeof e==`string`,n=+!!t,r=t?e:``,i={};for(let e=n;e<arguments.length;++e){let n=arguments[e],o={},s;if(typeof n==`function`?(s=n.name,typeof n.signature==`string`?o[n.signature]=n:_(n)&&(o=n.signatures)):a(n)&&(o=n,t||(s=ge(n))),Object.keys(o).length===0){let t=TypeError(`Argument to 'typed' at index `+e+` is not a (typed) function, nor an object with signatures as keys and functions as values.`);throw t.data={index:e,argument:n},t}t||(r=he(r,s)),_e(i,o)}return ie(r||``,i)},d.create=i,d.createCount=ve.createCount,d.onMismatch=U,d.throwMismatchError=U,d.createError=N,d.clear=m,d.clearConversions=h,d.addTypes=p,d._findType=f,d.referTo=ue,d.referToSelf=fe,d.convert=b,d.findSignature=v,d.find=y,d.isTypedFunction=_,d.warnAgainstDeprecatedThis=!0,d.addType=function(e,t){let n=`any`;t!==!1&&c.has(`Object`)&&(n=`Object`),d.addTypes([e],n)};function ye(e){if(!e||typeof e.from!=`string`||typeof e.to!=`string`||typeof e.convert!=`function`)throw TypeError(`Object with properties {from: string, to: string, convert: function} expected`);if(e.to===e.from)throw SyntaxError(`Illegal to define conversion from "`+e.from+`" to itself.`)}return d.addConversion=function(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{override:!1};ye(e);let n=f(e.to),r=n.conversionsTo.find(t=>t.from===e.from);if(r)if(t&&t.override)d.removeConversion({from:r.from,to:e.to,convert:r.convert});else throw Error(`There is already a conversion from "`+e.from+`" to "`+n.name+`"`);n.conversionsTo.push({from:e.from,to:n.name,convert:e.convert,index:u++})},d.addConversions=function(e,t){e.forEach(e=>d.addConversion(e,t))},d.removeConversion=function(e){ye(e);let t=f(e.to),n=ce(t.conversionsTo,t=>t.from===e.from);if(!n)throw Error(`Attempt to remove nonexistent conversion from `+e.from+` to `+e.to);if(n.convert!==e.convert)throw Error(`Conversion to remove does not match existing conversion`);let r=t.conversionsTo.indexOf(n);t.conversionsTo.splice(r,1)},d.resolve=function(e,t){if(!_(e))throw TypeError(r);let n=e._typedFunctionData.signatures;for(let e=0;e<n.length;++e)if(n[e].test(t))return n[e];return null},d}return i()}))}));function J(e,t,n,r){function i(r){var i=Di(r,t.map(Ii));return Pi(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function Ni(e){return typeof e==`function`&&typeof e.fn==`string`&&Array.isArray(e.dependencies)}function Pi(e,t,n){if(!t.filter(e=>!Fi(e)).every(e=>n[e]!==void 0)){var r=t.filter(e=>n[e]===void 0);throw Error(`Cannot create function "${e}", some dependencies are missing: ${r.map(e=>`"${e}"`).join(`, `)}.`)}}function Fi(e){return e&&e[0]===`?`}function Ii(e){return e&&e[0]===`?`?e.slice(1):e}function Li(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function Ri(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var zi=Math.sign||function(e){return e>0?1:e<0?-1:0},Bi=Math.log2||function(e){return Math.log(e)/Math.LN2},Vi=Math.log10||function(e){return Math.log(e)/Math.LN10},Hi=Math.log1p||function(e){return Math.log(e+1)},Ui=Math.cbrt||function(e){if(e===0)return e;var t=e<0,n;return t&&(e=-e),Number.isFinite(e)?(n=Math.exp(Math.log(e)/3),n=(e/(n*n)+2*n)/3):n=e,t?-n:n},Wi=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function Gi(e,t,n){var r={2:`0b`,8:`0o`,16:`0x`}[t],i=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!Li(n))throw Error(`size must be an integer`);if(e>2**(n-1)-1||e<-(2**(n-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!Li(e))throw Error(`Value must be an integer`);e<0&&(e+=2**n),i=`i${n}`}var a=``;return e<0&&(e=-e,a=`-`),`${a}${r}${e.toString(t)}${i}`}function Ki(e,t){if(typeof t==`function`)return t(e);if(e===1/0)return`Infinity`;if(e===-1/0)return`-Infinity`;if(isNaN(e))return`NaN`;var{notation:n,precision:r,wordSize:i}=qi(t);switch(n){case`fixed`:return Xi(e,r);case`exponential`:return Zi(e,r);case`engineering`:return Yi(e,r);case`bin`:return Gi(e,2,i);case`oct`:return Gi(e,8,i);case`hex`:return Gi(e,16,i);case`auto`:return Qi(e,r,t).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function qi(e){var t=`auto`,n,r;if(e!==void 0)if(Er(e))n=e;else if(Dr(e))n=e.toNumber();else if(Kr(e))e.precision!==void 0&&(n=ua(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=ua(e.wordSize,()=>{throw Error(`Option "wordSize" must be a number or BigNumber`)})),e.notation&&(t=e.notation);else throw Error(`Unsupported type of options, number, BigNumber, or object expected`);return{notation:t,precision:n,wordSize:r}}function Ji(e){var t=String(e).toLowerCase().match(/^(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw SyntaxError(`Invalid number `+e);var n=t[1],r=t[2],i=parseFloat(t[4]||`0`),a=r.indexOf(`.`);i+=a===-1?r.length-1:a-1;var o=r.replace(`.`,``).replace(/^0*/,function(e){return i-=e.length,``}).replace(/0*$/,``).split(``).map(function(e){return parseInt(e)});return o.length===0&&(o.push(0),i++),{sign:n,coefficients:o,exponent:i}}function Yi(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=$i(Ji(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(Er(t))for(;t>i.length||r-a+1>i.length;)i.push(0);else for(var o=Math.abs(r-a)-(i.length-1),s=0;s<o;s++)i.push(0);for(var c=Math.abs(r-a),l=1;c>0;)l++,c--;var u=i.slice(l).join(``),d=Er(t)&&u.length||u.match(/[1-9]/)?`.`+u:``,f=i.slice(0,l).join(``)+d+`e`+(r>=0?`+`:``)+a.toString();return n.sign+f}function Xi(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Ji(e),r=typeof t==`number`?$i(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length<o&&(i=i.concat(ea(o-i.length))),a<0&&(i=ea(-a+1).concat(i),a=1),a<i.length&&i.splice(a,0,a===0?`0.`:`.`),r.sign+i.join(``)}function Zi(e,t){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var n=Ji(e),r=t?$i(n,t):n,i=r.coefficients,a=r.exponent;i.length<t&&(i=i.concat(ea(t-i.length)));var o=i.shift();return r.sign+o+(i.length>0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function Qi(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=da(n?.lowerExp,-3),i=da(n?.upperExp,5),a=Ji(e),o=t?$i(a,t):a;if(o.exponent<r||o.exponent>=i)return Zi(e,t);var s=o.coefficients,c=o.exponent;s.length<t&&(s=s.concat(ea(t-s.length))),s=s.concat(ea(c-s.length+1+(s.length<t?t-s.length:0))),s=ea(-c).concat(s);var l=c>0?c:0;return l<s.length-1&&s.splice(l+1,0,`.`),o.sign+s.join(``)}function $i(e,t){for(var n={sign:e.sign,coefficients:e.coefficients,exponent:e.exponent},r=n.coefficients;t<=0;)r.unshift(0),n.exponent++,t++;if(r.length>t&&r.splice(t,r.length-t)[0]>=5){var i=t-1;for(r[i]++;r[i]===10;)r.pop(),i===0&&(r.unshift(0),n.exponent++,i++),i--,r[i]++}return n}function ea(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}function ta(e){return e.toExponential().replace(/e.*$/,``).replace(/^0\.?0*|\./,``).length}function na(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-8,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return isNaN(e)||isNaN(t)?!1:!Number.isFinite(e)||!Number.isFinite(t)?e===t:e===t?!0:Math.abs(e-t)<=Math.max(n*Math.max(Math.abs(e),Math.abs(t)),r)}var ra=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},ia=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},aa=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},oa=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},sa=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},ca=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function la(e,t){return(e>0?!0:e<0?!1:1/e==1/0)^(t>0?!0:t<0?!1:1/t==1/0)?-e:e}function ua(e,t){if(Er(e))return e;if(Dr(e))return e.toNumber();t()}function da(e,t){return Er(e)?e:Dr(e)?e.toNumber():t}var fa=Dt(Mi(),1),pa=function(){return pa=fa.default.create,fa.default},ma=J(`typed`,[`?BigNumber`,`?Complex`,`?DenseMatrix`,`?Fraction`],function(e){var{BigNumber:t,Complex:n,DenseMatrix:r,Fraction:i}=e,a=pa();return a.clear(),a.addTypes([{name:`number`,test:Er},{name:`Complex`,test:kr},{name:`BigNumber`,test:Dr},{name:`bigint`,test:Or},{name:`Fraction`,test:Ar},{name:`Unit`,test:jr},{name:`identifier`,test:e=>Mr&&/^(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])(?:[0-9A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDD70-\uDD7A\uDD7C-\uDD8A\uDD8C-\uDD92\uDD94\uDD95\uDD97-\uDDA1\uDDA3-\uDDB1\uDDB3-\uDDB9\uDDBB\uDDBC\uDDC0-\uDDF3\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67\uDF80-\uDF85\uDF87-\uDFB0\uDFB2-\uDFBA]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD40-\uDD59\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDD4A-\uDD65\uDD6F-\uDD85\uDE80-\uDEA9\uDEB0\uDEB1\uDEC2-\uDEC7\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDF70-\uDF81\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC71\uDC72\uDC75\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE3F\uDE40\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61\uDF80-\uDF89\uDF8B\uDF8E\uDF90-\uDFB5\uDFB7\uDFD1\uDFD3]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A\uDF40-\uDF46]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEB0-\uDEF8\uDFC0-\uDFE0]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDB0-\uDDDB\uDEE0-\uDEF2\uDF02\uDF04-\uDF10\uDF12-\uDF33\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC80-\uDD43]|\uD80B[\uDF90-\uDFF0]|[\uD80C\uD80E\uD80F\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2F\uDC41-\uDC46\uDC60-\uDFFF]|\uD810[\uDC00-\uDFFA]|\uD811[\uDC00-\uDE46]|\uD818[\uDD00-\uDD1D]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE70-\uDEBE\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDD40-\uDD6C\uDE40-\uDE7F\uDEA0-\uDEB8\uDEBB-\uDED3\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3\uDFF2\uDFF3]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD32\uDD50-\uDD52\uDD55\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD837[\uDF00-\uDF1E\uDF25-\uDF2A]|\uD838[\uDC30-\uDC6D\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDE90-\uDEAD\uDEC0-\uDEEB]|\uD839[\uDCD0-\uDCEB\uDDD0-\uDDED\uDDF0\uDEC0-\uDEDE\uDEE0-\uDEE2\uDEE4\uDEE5\uDEE7-\uDEED\uDEF0-\uDEF4\uDEFE\uDEFF\uDFE0-\uDFE6\uDFE8-\uDFEB\uDFED\uDFEE\uDFF0-\uDFFE]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79])*$/.test(e)},{name:`string`,test:Mr},{name:`Chain`,test:hi},{name:`Array`,test:Nr},{name:`Matrix`,test:Pr},{name:`DenseMatrix`,test:Ir},{name:`SparseMatrix`,test:Lr},{name:`Range`,test:Rr},{name:`Index`,test:zr},{name:`boolean`,test:Br},{name:`ResultSet`,test:Vr},{name:`Help`,test:Hr},{name:`function`,test:Ur},{name:`Date`,test:Wr},{name:`RegExp`,test:Gr},{name:`null`,test:Xr},{name:`undefined`,test:Zr},{name:`AccessorNode`,test:Qr},{name:`ArrayNode`,test:$r},{name:`AssignmentNode`,test:ei},{name:`BlockNode`,test:ti},{name:`ConditionalNode`,test:ni},{name:`ConstantNode`,test:ri},{name:`FunctionNode`,test:oi},{name:`FunctionAssignmentNode`,test:ai},{name:`IndexNode`,test:si},{name:`Node`,test:ci},{name:`ObjectNode`,test:li},{name:`OperatorNode`,test:ui},{name:`ParenthesisNode`,test:di},{name:`RangeNode`,test:fi},{name:`RelationalNode`,test:pi},{name:`SymbolNode`,test:mi},{name:`Map`,test:qr},{name:`Object`,test:Kr}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||ha(e),ta(e)>15)throw TypeError(`Cannot implicitly convert a number with >15 significant digits to BigNumber (value: `+e+`). Use function bignumber(x) to convert to BigNumber.`);return new t(e)}},{from:`number`,to:`Complex`,convert:function(e){return n||ga(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||ga(e),new n(e.toNumber(),0)}},{from:`bigint`,to:`number`,convert:function(e){if(e>2**53-1)throw TypeError(`Cannot implicitly convert bigint to number: value exceeds the max safe integer value (value: `+e+`)`);return Number(e)}},{from:`bigint`,to:`BigNumber`,convert:function(e){return t||ha(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||va(e),new i(e)}},{from:`Fraction`,to:`BigNumber`,convert:function(e){throw TypeError(`Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.`)}},{from:`Fraction`,to:`Complex`,convert:function(e){return n||ga(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||va(e);var t=new i(e);if(t.valueOf()!==e)throw TypeError(`Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: `+e+`). Use function fraction(x) to convert to Fraction.`);return t}},{from:`string`,to:`number`,convert:function(e){var t=Number(e);if(isNaN(t))throw Error(`Cannot convert "`+e+`" to a number`);return t}},{from:`string`,to:`BigNumber`,convert:function(e){t||ha(e);try{return new t(e)}catch{throw Error(`Cannot convert "`+e+`" to BigNumber`)}}},{from:`string`,to:`bigint`,convert:function(e){try{return BigInt(e)}catch{throw Error(`Cannot convert "`+e+`" to BigInt`)}}},{from:`string`,to:`Fraction`,convert:function(e){i||va(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||ga(e);try{return new n(e)}catch{throw Error(`Cannot convert "`+e+`" to Complex`)}}},{from:`boolean`,to:`number`,convert:function(e){return+e}},{from:`boolean`,to:`BigNumber`,convert:function(e){return t||ha(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||va(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||_a(),new r(e)}},{from:`Matrix`,to:`Array`,convert:function(e){return e.valueOf()}}]),a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Fr(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a.onMismatch=(e,t,n)=>{var r=a.createError(e,t,n);if([`wrongType`,`mismatch`].includes(r.data.category)&&t.length===1&&Fr(t[0])&&n.some(e=>!e.params.includes(`,`))){var i=TypeError(`Function '${e}' doesn't apply to matrices. To call it elementwise on a matrix 'M', try 'map(M, ${e})'.`);throw i.data=r.data,i}throw r},a});function ha(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function ga(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function _a(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function va(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var ya=J(`ResultSet`,[],()=>{function e(t){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);this.entries=t||[]}return e.prototype.type=`ResultSet`,e.prototype.isResultSet=!0,e.prototype.valueOf=function(){return this.entries},e.prototype.toString=function(){return`[`+this.entries.map(String).join(`, `)+`]`},e.prototype.toJSON=function(){return{mathjs:`ResultSet`,entries:this.entries}},e.fromJSON=function(t){return new e(t.entries)},e},{isClass:!0}),ba=9e15,xa=1e9,Sa=`0123456789abcdef`,Ca=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,wa=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,Ta={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-ba,maxE:ba,crypto:!1},Ea,Da,Oa=!0,ka=`[DecimalError] `,Aa=ka+`Invalid argument: `,ja=ka+`Precision limit exceeded`,Ma=ka+`crypto unavailable`,Na=`[object Decimal]`,Pa=Math.floor,Fa=Math.pow,Ia=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,La=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ra=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,za=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Ba=1e7,Va=7,Ha=9007199254740991,Ua=Ca.length-1,Wa=wa.length-1,Y={toStringTag:Na};Y.absoluteValue=Y.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Za(e)},Y.ceil=function(){return Za(new this.constructor(this),this.e+1,2)},Y.clampedTo=Y.clamp=function(e,t){var n,r=this,i=r.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(Aa+t);return n=r.cmp(e),n<0?e:r.cmp(t)>0?t:new i(r)},Y.comparedTo=Y.cmp=function(e){var t,n,r,i,a=this,o=a.d,s=(e=new a.constructor(e)).d,c=a.s,l=e.s;if(!o||!s)return!c||!l?NaN:c===l?o===s?0:!o^c<0?1:-1:c;if(!o[0]||!s[0])return o[0]?c:s[0]?-l:0;if(c!==l)return c;if(a.e!==e.e)return a.e>e.e^c<0?1:-1;for(r=o.length,i=s.length,t=0,n=r<i?r:i;t<n;++t)if(o[t]!==s[t])return o[t]>s[t]^c<0?1:-1;return r===i?0:r>i^c<0?1:-1},Y.cosine=Y.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Va,r.rounding=1,n=Ya(r,go(r,n)),r.precision=e,r.rounding=t,Za(Da==2||Da==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},Y.cubeRoot=Y.cbrt=function(){var e,t,n,r,i,a,o,s,c,l,u=this,d=u.constructor;if(!u.isFinite()||u.isZero())return new d(u);for(Oa=!1,a=u.s*Fa(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=Ga(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=Fa(n,1/3),e=Pa((e+1)/3)-(e%3==(e<0?-1:2)),a==1/0?n=`5e`+e:(n=a.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+e),r=new d(n),r.s=u.s):r=new d(a.toString()),o=(e=d.precision)+3;;)if(s=r,c=s.times(s).times(s),l=c.plus(u),r=Xa(l.plus(u).times(s),l.plus(c),o+2,1),Ga(s.d).slice(0,o)===(n=Ga(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(Za(s,e+1,0),s.times(s).times(s).eq(u))){r=s;break}o+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(Za(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return Oa=!0,Za(r,e,d.rounding,t)},Y.decimalPlaces=Y.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-Pa(this.e/Va))*Va,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},Y.dividedBy=Y.div=function(e){return Xa(this,new this.constructor(e))},Y.dividedToIntegerBy=Y.divToInt=function(e){var t=this,n=t.constructor;return Za(Xa(t,new n(e),0,1,1),n.precision,n.rounding)},Y.equals=Y.eq=function(e){return this.cmp(e)===0},Y.floor=function(){return Za(new this.constructor(this),this.e+1,3)},Y.greaterThan=Y.gt=function(e){return this.cmp(e)>0},Y.greaterThanOrEqualTo=Y.gte=function(e){var t=this.cmp(e);return t==1||t===0},Y.hyperbolicCosine=Y.cosh=function(){var e,t,n,r,i,a=this,o=a.constructor,s=new o(1);if(!a.isFinite())return new o(a.s?1/0:NaN);if(a.isZero())return s;n=o.precision,r=o.rounding,o.precision=n+Math.max(a.e,a.sd())+4,o.rounding=1,i=a.d.length,i<32?(e=Math.ceil(i/3),t=(1/ho(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=mo(o,1,a.times(t),new o(1),!0);for(var c,l=e,u=new o(8);l--;)c=a.times(a),a=s.minus(c.times(u.minus(c.times(u))));return Za(a,o.precision=n,o.rounding=r,!0)},Y.hyperbolicSine=Y.sinh=function(){var e,t,n,r,i=this,a=i.constructor;if(!i.isFinite()||i.isZero())return new a(i);if(t=a.precision,n=a.rounding,a.precision=t+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<3)i=mo(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/ho(5,e)),i=mo(a,2,i,i,!0);for(var o,s=new a(5),c=new a(16),l=new a(20);e--;)o=i.times(i),i=i.times(s.plus(o.times(c.times(o).plus(l))))}return a.precision=t,a.rounding=n,Za(i,t,n,!0)},Y.hyperbolicTangent=Y.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,Xa(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},Y.inverseCosine=Y.acos=function(){var e=this,t=e.constructor,n=e.abs().cmp(1),r=t.precision,i=t.rounding;return n===-1?e.isZero()?to(t,r+4,i).times(.5):(t.precision=r+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=r,t.rounding=i,e.times(2)):n===0?e.isNeg()?to(t,r,i):new t(0):new t(NaN)},Y.inverseHyperbolicCosine=Y.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,Oa=!1,n=n.times(n).minus(1).sqrt().plus(n),Oa=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},Y.inverseHyperbolicSine=Y.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,Oa=!1,n=n.times(n).plus(1).sqrt().plus(n),Oa=!0,r.precision=e,r.rounding=t,n.ln())},Y.inverseHyperbolicTangent=Y.atanh=function(){var e,t,n,r,i=this,a=i.constructor;return i.isFinite()?i.e>=0?new a(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=a.precision,t=a.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?Za(new a(i),e,t,!0):(a.precision=n=r-i.e,i=Xa(i.plus(1),new a(1).minus(i),n+e,1),a.precision=e+4,a.rounding=1,i=i.ln(),a.precision=e,a.rounding=t,i.times(.5))):new a(NaN)},Y.inverseSine=Y.asin=function(){var e,t,n,r,i=this,a=i.constructor;return i.isZero()?new a(i):(t=i.abs().cmp(1),n=a.precision,r=a.rounding,t===-1?(a.precision=n+6,a.rounding=1,i=i.div(new a(1).minus(i.times(i)).sqrt().plus(1)).atan(),a.precision=n,a.rounding=r,i.times(2)):t===0?(e=to(a,n+4,r).times(.5),e.s=i.s,e):new a(NaN))},Y.inverseTangent=Y.atan=function(){var e,t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding;if(!l.isFinite()){if(!l.s)return new u(NaN);if(d+4<=Wa)return o=to(u,d+4,f).times(.5),o.s=l.s,o}else if(l.isZero())return new u(l);else if(l.abs().eq(1)&&d+4<=Wa)return o=to(u,d+4,f).times(.25),o.s=l.s,o;for(u.precision=s=d+10,u.rounding=1,n=Math.min(28,s/Va+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(Oa=!1,t=Math.ceil(s/Va),r=1,c=l.times(l),o=new u(l),i=l;e!==-1;)if(i=i.times(c),a=o.minus(i.div(r+=2)),i=i.times(c),o=a.plus(i.div(r+=2)),o.d[t]!==void 0)for(e=t;o.d[e]===a.d[e]&&e--;);return n&&(o=o.times(2<<n-1)),Oa=!0,Za(o,u.precision=d,u.rounding=f,!0)},Y.isFinite=function(){return!!this.d},Y.isInteger=Y.isInt=function(){return!!this.d&&Pa(this.e/Va)>this.d.length-2},Y.isNaN=function(){return!this.s},Y.isNegative=Y.isNeg=function(){return this.s<0},Y.isPositive=Y.isPos=function(){return this.s>0},Y.isZero=function(){return!!this.d&&this.d[0]===0},Y.lessThan=Y.lt=function(e){return this.cmp(e)<0},Y.lessThanOrEqualTo=Y.lte=function(e){return this.cmp(e)<1},Y.logarithm=Y.log=function(e){var t,n,r,i,a,o,s,c,l=this,u=l.constructor,d=u.precision,f=u.rounding,p=5;if(e==null)e=new u(10),t=!0;else{if(e=new u(e),n=e.d,e.s<0||!n||!n[0]||e.eq(1))return new u(NaN);t=e.eq(10)}if(n=l.d,l.s<0||!n||!n[0]||l.eq(1))return new u(n&&!n[0]?-1/0:l.s==1?n?0:1/0:NaN);if(t)if(n.length>1)a=!0;else{for(i=n[0];i%10==0;)i/=10;a=i!==1}if(Oa=!1,s=d+p,o=co(l,s),r=t?eo(u,s+10):co(e,s),c=Xa(o,r,s,1),qa(c.d,i=d,f))do if(s+=10,o=co(l,s),r=t?eo(u,s+10):co(e,s),c=Xa(o,r,s,1),!a){+Ga(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=Za(c,d+1,0));break}while(qa(c.d,i+=10,f));return Oa=!0,Za(c,d,f)},Y.minus=Y.sub=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.constructor;if(e=new m(e),!p.d||!e.d)return!p.s||!e.s?e=new m(NaN):p.d?e.s=-e.s:e=new m(e.d||p.s!==e.s?p:NaN),e;if(p.s!=e.s)return e.s=-e.s,p.plus(e);if(l=p.d,f=e.d,s=m.precision,c=m.rounding,!l[0]||!f[0]){if(f[0])e.s=-e.s;else if(l[0])e=new m(p);else return new m(c===3?-0:0);return Oa?Za(e,s,c):e}if(n=Pa(e.e/Va),u=Pa(p.e/Va),l=l.slice(),a=u-n,a){for(d=a<0,d?(t=l,a=-a,o=f.length):(t=f,n=u,o=l.length),r=Math.max(Math.ceil(s/Va),o)+2,a>r&&(a=r,t.length=1),t.reverse(),r=a;r--;)t.push(0);t.reverse()}else{for(r=l.length,o=f.length,d=r<o,d&&(o=r),r=0;r<o;r++)if(l[r]!=f[r]){d=l[r]<f[r];break}a=0}for(d&&(t=l,l=f,f=t,e.s=-e.s),o=l.length,r=f.length-o;r>0;--r)l[o++]=0;for(r=f.length;r>a;){if(l[--r]<f[r]){for(i=r;i&&l[--i]===0;)l[i]=Ba-1;--l[i],l[r]+=Ba}l[r]-=f[r]}for(;l[--o]===0;)l.pop();for(;l[0]===0;l.shift())--n;return l[0]?(e.d=l,e.e=$a(l,n),Oa?Za(e,s,c):e):new m(c===3?-0:0)},Y.modulo=Y.mod=function(e){var t,n=this,r=n.constructor;return e=new r(e),!n.d||!e.s||e.d&&!e.d[0]?new r(NaN):!e.d||n.d&&!n.d[0]?Za(new r(n),r.precision,r.rounding):(Oa=!1,r.modulo==9?(t=Xa(n,e.abs(),0,3,1),t.s*=e.s):t=Xa(n,e,0,r.modulo,1),t=t.times(e),Oa=!0,n.minus(t))},Y.naturalExponential=Y.exp=function(){return so(this)},Y.naturalLogarithm=Y.ln=function(){return co(this)},Y.negated=Y.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Za(e)},Y.plus=Y.add=function(e){var t,n,r,i,a,o,s,c,l,u,d=this,f=d.constructor;if(e=new f(e),!d.d||!e.d)return!d.s||!e.s?e=new f(NaN):d.d||(e=new f(e.d||d.s===e.s?d:NaN)),e;if(d.s!=e.s)return e.s=-e.s,d.minus(e);if(l=d.d,u=e.d,s=f.precision,c=f.rounding,!l[0]||!u[0])return u[0]||(e=new f(d)),Oa?Za(e,s,c):e;if(a=Pa(d.e/Va),r=Pa(e.e/Va),l=l.slice(),i=a-r,i){for(i<0?(n=l,i=-i,o=u.length):(n=u,r=a,o=l.length),a=Math.ceil(s/Va),o=a>o?a+1:o+1,i>o&&(i=o,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for(o=l.length,i=u.length,o-i<0&&(i=o,n=u,u=l,l=n),t=0;i;)t=(l[--i]=l[i]+u[i]+t)/Ba|0,l[i]%=Ba;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=$a(l,r),Oa?Za(e,s,c):e},Y.precision=Y.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(Aa+e);return n.d?(t=no(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Y.round=function(){var e=this,t=e.constructor;return Za(new t(e),e.e+1,t.rounding)},Y.sine=Y.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+Va,r.rounding=1,n=po(r,go(r,n)),r.precision=e,r.rounding=t,Za(Da>2?n.neg():n,e,t,!0)):new r(NaN)},Y.squareRoot=Y.sqrt=function(){var e,t,n,r,i,a,o=this,s=o.d,c=o.e,l=o.s,u=o.constructor;if(l!==1||!s||!s[0])return new u(!l||l<0&&(!s||s[0])?NaN:s?o:1/0);for(Oa=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=Ga(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=Pa((c+1)/2)-(c<0||c%2),l==1/0?t=`5e`+c:(t=l.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+c),r=new u(t)):r=new u(l.toString()),n=(c=u.precision)+3;;)if(a=r,r=a.plus(Xa(o,a,n+2,1)).times(.5),Ga(a.d).slice(0,n)===(t=Ga(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(Za(a,c+1,0),a.times(a).eq(o))){r=a;break}n+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)==`5`)&&(Za(r,c+1,1),e=!r.times(r).eq(o));break}return Oa=!0,Za(r,c,u.rounding,e)},Y.tangent=Y.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=Xa(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,Za(Da==2||Da==4?n.neg():n,e,t,!0)):new r(NaN)},Y.times=Y.mul=function(e){var t,n,r,i,a,o,s,c,l,u=this,d=u.constructor,f=u.d,p=(e=new d(e)).d;if(e.s*=u.s,!f||!f[0]||!p||!p[0])return new d(!e.s||f&&!f[0]&&!p||p&&!p[0]&&!f?NaN:!f||!p?e.s/0:e.s*0);for(n=Pa(u.e/Va)+Pa(e.e/Va),c=f.length,l=p.length,c<l&&(a=f,f=p,p=a,o=c,c=l,l=o),a=[],o=c+l,r=o;r--;)a.push(0);for(r=l;--r>=0;){for(t=0,i=c+r;i>r;)s=a[i]+p[r]*f[i-r-1]+t,a[i--]=s%Ba|0,t=s/Ba|0;a[i]=(a[i]+t)%Ba|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=$a(a,n),Oa?Za(e,d.precision,d.rounding):e},Y.toBinary=function(e,t){return _o(this,2,e,t)},Y.toDecimalPlaces=Y.toDP=function(e,t){var n=this,r=n.constructor;return n=new r(n),e===void 0?n:(Ka(e,0,xa),t===void 0?t=r.rounding:Ka(t,0,8),Za(n,e+n.e+1,t))},Y.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Qa(r,!0):(Ka(e,0,xa),t===void 0?t=i.rounding:Ka(t,0,8),r=Za(new i(r),e+1,t),n=Qa(r,!0,e+1)),r.isNeg()&&!r.isZero()?`-`+n:n},Y.toFixed=function(e,t){var n,r,i=this,a=i.constructor;return e===void 0?n=Qa(i):(Ka(e,0,xa),t===void 0?t=a.rounding:Ka(t,0,8),r=Za(new a(i),e+i.e+1,t),n=Qa(r,!1,e+r.e+1)),i.isNeg()&&!i.isZero()?`-`+n:n},Y.toFraction=function(e){var t,n,r,i,a,o,s,c,l,u,d,f,p=this,m=p.d,h=p.constructor;if(!m)return new h(p);if(l=n=new h(1),r=c=new h(0),t=new h(r),a=t.e=no(m)-p.e-1,o=a%Va,t.d[0]=Fa(10,o<0?Va+o:o),e==null)e=a>0?t:l;else{if(s=new h(e),!s.isInt()||s.lt(l))throw Error(Aa+s);e=s.gt(t)?a>0?t:l:s}for(Oa=!1,s=new h(Ga(m)),u=h.precision,h.precision=a=m.length*Va*2;d=Xa(s,t,0,1,1),i=n.plus(d.times(r)),i.cmp(e)!=1;)n=r,r=i,i=l,l=c.plus(d.times(i)),c=i,i=t,t=s.minus(d.times(i)),s=i;return i=Xa(e.minus(n),r,0,1,1),c=c.plus(i.times(l)),n=n.plus(i.times(r)),c.s=l.s=p.s,f=Xa(l,r,a,1).minus(p).abs().cmp(Xa(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,Oa=!0,f},Y.toHexadecimal=Y.toHex=function(e,t){return _o(this,16,e,t)},Y.toNearest=function(e,t){var n=this,r=n.constructor;if(n=new r(n),e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{if(e=new r(e),t===void 0?t=r.rounding:Ka(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(Oa=!1,n=Xa(n,e,0,t,1).times(e),Oa=!0,Za(n)):(e.s=n.s,n=e),n},Y.toNumber=function(){return+this},Y.toOctal=function(e,t){return _o(this,8,e,t)},Y.toPower=Y.pow=function(e){var t,n,r,i,a,o,s=this,c=s.constructor,l=+(e=new c(e));if(!s.d||!e.d||!s.d[0]||!e.d[0])return new c(Fa(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return Za(s,r,a);if(t=Pa(e.e/Va),t>=e.d.length-1&&(n=l<0?-l:l)<=Ha)return i=io(c,s,n,r),e.s<0?new c(1).div(i):Za(i,r,a);if(o=s.s,o<0){if(t<e.d.length-1)return new c(NaN);if(e.d[t]&1||(o=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=o,s}return n=Fa(+s,l),t=n==0||!isFinite(n)?Pa(l*(Math.log(`0.`+Ga(s.d))/Math.LN10+s.e+1)):new c(n+``).e,t>c.maxE+1||t<c.minE-1?new c(t>0?o/0:0):(Oa=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=so(e.times(co(s,r+n)),r),i.d&&(i=Za(i,r+5,1),qa(i.d,r,a)&&(t=r+10,i=Za(so(e.times(co(s,t+n)),t),t+5,1),+Ga(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=Za(i,r+1,0)))),i.s=o,Oa=!0,c.rounding=a,Za(i,r,a))},Y.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Qa(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(Ka(e,1,xa),t===void 0?t=i.rounding:Ka(t,0,8),r=Za(new i(r),e,t),n=Qa(r,e<=r.e||r.e<=i.toExpNeg,e)),r.isNeg()&&!r.isZero()?`-`+n:n},Y.toSignificantDigits=Y.toSD=function(e,t){var n=this,r=n.constructor;return e===void 0?(e=r.precision,t=r.rounding):(Ka(e,1,xa),t===void 0?t=r.rounding:Ka(t,0,8)),Za(new r(n),e,t)},Y.toString=function(){var e=this,t=e.constructor,n=Qa(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},Y.truncated=Y.trunc=function(){return Za(new this.constructor(this),this.e+1,1)},Y.valueOf=Y.toJSON=function(){var e=this,t=e.constructor,n=Qa(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function Ga(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=Va-r.length,n&&(a+=ro(n)),a+=r;o=e[t],r=o+``,n=Va-r.length,n&&(a+=ro(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function Ka(e,t,n){if(e!==~~e||e<t||e>n)throw Error(Aa+e)}function qa(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=Va,i=0):(i=Math.ceil((t+1)/Va),t%=Va),a=Fa(10,Va-t),s=e[i]%a|0,r==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),o=n<4&&s==99999||n>3&&s==49999||s==5e4||s==0):o=(n<4&&s+1==a||n>3&&s+1==a/2)&&(e[i+1]/a/100|0)==Fa(10,t-2)-1||(s==a/2||s==0)&&(e[i+1]/a/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),o=(r||n<4)&&s==9999||!r&&n>3&&s==4999):o=((r||n<4)&&s+1==a||!r&&n>3&&s+1==a/2)&&(e[i+1]/a/1e3|0)==Fa(10,t-3)-1,o}function Ja(e,t,n){for(var r,i=[0],a,o=0,s=e.length;o<s;){for(a=i.length;a--;)i[a]*=t;for(i[0]+=Sa.indexOf(e.charAt(o++)),r=0;r<i.length;r++)i[r]>n-1&&(i[r+1]===void 0&&(i[r+1]=0),i[r+1]+=i[r]/n|0,i[r]%=n)}return i.reverse()}function Ya(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/ho(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=mo(e,1,t.times(i),new e(1));for(var a=n;a--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}var Xa=(function(){function e(e,t,n){var r,i=0,a=e.length;for(e=e.slice();a--;)r=e[a]*t+i,e[a]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=+(e[n]<t[n]),e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,a,o,s,c){var l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k=r.constructor,A=r.s==i.s?1:-1,j=r.d,M=i.d;if(!j||!j[0]||!M||!M[0])return new k(!r.s||!i.s||(j?M&&j[0]==M[0]:!M)?NaN:j&&j[0]==0||!M?A*0:A/0);for(c?(p=1,u=r.e-i.e):(c=Ba,p=Va,u=Pa(r.e/p)-Pa(i.e/p)),D=M.length,T=j.length,_=new k(A),v=_.d=[],d=0;M[d]==(j[d]||0);d++);if(M[d]>(j[d]||0)&&u--,a==null?(S=a=k.precision,o=k.rounding):S=s?a+(r.e-i.e)+1:a,S<0)v.push(1),m=!0;else{if(S=S/p+2|0,d=0,D==1){for(f=0,M=M[0],S++;(d<T||f)&&S--;d++)C=f*c+(j[d]||0),v[d]=C/M|0,f=C%M|0;m=f||d<T}else{for(f=c/(M[0]+1)|0,f>1&&(M=e(M,f,c),j=e(j,f,c),D=M.length,T=j.length),w=D,y=j.slice(0,D),b=y.length;b<D;)y[b++]=0;O=M.slice(),O.unshift(0),E=M[0],M[1]>=c/2&&++E;do f=0,l=t(M,y,D,b),l<0?(x=y[0],D!=b&&(x=x*c+(y[1]||0)),f=x/E|0,f>1?(f>=c&&(f=c-1),h=e(M,f,c),g=h.length,b=y.length,l=t(h,y,g,b),l==1&&(f--,n(h,D<g?O:M,g,c))):(f==0&&(l=f=1),h=M.slice()),g=h.length,g<b&&h.unshift(0),n(y,h,b,c),l==-1&&(b=y.length,l=t(M,y,D,b),l<1&&(f++,n(y,D<b?O:M,b,c))),b=y.length):l===0&&(f++,y=[0]),v[d++]=f,l&&y[0]?y[b++]=j[w]||0:(y=[j[w]],b=1);while((w++<T||y[0]!==void 0)&&S--);m=y[0]!==void 0}v[0]||v.shift()}if(p==1)_.e=u,Ea=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,Za(_,s?a+_.e+1:a,o,m)}return _}})();function Za(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor;out:if(t!=null){if(d=e.d,!d)return e;for(i=1,s=d[0];s>=10;s/=10)i++;if(a=t-i,a<0)a+=Va,o=t,u=d[f=0],c=u/Fa(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/Va),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=Va,o=a-Va+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=Va,o=a-Va+i,c=o<0?0:u/Fa(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%Fa(10,i-o-1)),l=n<4?(c||r)&&(n==0||n==(e.s<0?3:2)):c>5||c==5&&(n==4||r||n==6&&(a>0?o>0?u/Fa(10,i-o):0:d[f-1])%10&1||n==(e.s<0?8:7)),t<1||!d[0])return d.length=0,l?(t-=e.e+1,d[0]=Fa(10,(Va-t%Va)%Va),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=Fa(10,Va-a),d[f]=o>0?(u/Fa(10,i-o)%Fa(10,o)|0)*s:0),l)for(;;)if(f==0){for(a=1,o=d[0];o>=10;o/=10)a++;for(o=d[0]+=s,s=1;o>=10;o/=10)s++;a!=s&&(e.e++,d[0]==Ba&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=Ba)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return Oa&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function Qa(e,t,n){if(!e.isFinite())return lo(e);var r,i=e.e,a=Ga(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+ro(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+ro(-i-1)+a,n&&(r=n-o)>0&&(a+=ro(r))):i>=o?(a+=ro(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+ro(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=ro(r))),a}function $a(e,t){var n=e[0];for(t*=Va;n>=10;n/=10)t++;return t}function eo(e,t,n){if(t>Ua)throw Oa=!0,n&&(e.precision=n),Error(ja);return Za(new e(Ca),t,1,!0)}function to(e,t,n){if(t>Wa)throw Error(ja);return Za(new e(wa),t,n,!0)}function no(e){var t=e.length-1,n=t*Va+1;if(t=e[t],t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function ro(e){for(var t=``;e--;)t+=`0`;return t}function io(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/Va+4);for(Oa=!1;;){if(n%2&&(a=a.times(t),vo(a.d,o)&&(i=!0)),n=Pa(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),vo(t.d,o)}return Oa=!0,a}function ao(e){return e.d[e.d.length-1]&1}function oo(e,t,n){for(var r,i,a=new e(t[0]),o=0;++o<t.length;){if(i=new e(t[o]),!i.s){a=i;break}r=a.cmp(i),(r===n||r===0&&a.s===n)&&(a=i)}return a}function so(e,t){var n,r,i,a,o,s,c,l=0,u=0,d=0,f=e.constructor,p=f.rounding,m=f.precision;if(!e.d||!e.d[0]||e.e>17)return new f(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(t==null?(Oa=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(Fa(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=Za(a.times(e),c,1),n=n.times(++u),s=o.plus(Xa(a,n,c,1)),Ga(s.d).slice(0,c)===Ga(o.d).slice(0,c)){for(i=d;i--;)o=Za(o.times(o),c,1);if(t==null)if(l<3&&qa(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return Za(o,f.precision=m,p,Oa=!0);else return f.precision=m,o}o=s}}function co(e,t){var n,r,i,a,o,s,c,l,u,d,f,p=1,m=10,h=e,g=h.d,_=h.constructor,v=_.rounding,y=_.precision;if(h.s<0||!g||!g[0]||!h.e&&g[0]==1&&g.length==1)return new _(g&&!g[0]?-1/0:h.s==1?g?0:h:NaN);if(t==null?(Oa=!1,u=y):u=t,_.precision=u+=m,n=Ga(g),r=n.charAt(0),Math.abs(a=h.e)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)h=h.times(e),n=Ga(h.d),r=n.charAt(0),p++;a=h.e,r>1?(h=new _(`0.`+n),a++):h=new _(r+`.`+n.slice(1))}else return l=eo(_,u+2,y).times(a+``),h=co(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?Za(h,y,v,Oa=!0):h;for(d=h,c=o=h=Xa(h.minus(1),h.plus(1),u,1),f=Za(h.times(h),u,1),i=3;;){if(o=Za(o.times(f),u,1),l=c.plus(Xa(o,new _(i),u,1)),Ga(l.d).slice(0,u)===Ga(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(eo(_,u+2,y).times(a+``))),c=Xa(c,new _(p),u,1),t==null)if(qa(c.d,u-m,v,s))_.precision=u+=m,l=o=h=Xa(d.minus(1),d.plus(1),u,1),f=Za(h.times(h),u,1),i=s=1;else return Za(c,_.precision=y,v,Oa=!0);else return _.precision=y,c;c=l,i+=2}}function lo(e){return String(e.s*e.s/0)}function uo(e,t){var n,r,i;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(r,i),t){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%Va,n<0&&(r+=Va),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=Va;r<i;)e.d.push(+t.slice(r,r+=Va));t=t.slice(r),r=Va-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),Oa&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function fo(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),za.test(t))return uo(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(La.test(t))n=16,t=t.toLowerCase();else if(Ia.test(t))n=2;else if(Ra.test(t))n=8;else throw Error(Aa+t);for(a=t.search(/p/i),a>0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),a=t.indexOf(`.`),o=a>=0,r=e.constructor,o&&(t=t.replace(`.`,``),s=t.length,a=s-a,i=io(r,new r(n),a,a*2)),l=Ja(t,n,Ba),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=$a(l,u),e.d=l,Oa=!1,o&&(e=Xa(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?Fa(2,c):os.pow(2,c))),Oa=!0,e)}function po(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:mo(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/ho(5,n)),t=mo(e,2,t,t);for(var i,a=new e(5),o=new e(16),s=new e(20);n--;)i=t.times(t),t=t.times(a.plus(i.times(o.times(i).minus(s))));return t}function mo(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/Va);for(Oa=!1,c=n.times(n),s=new e(r);;){if(o=Xa(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=Xa(o.times(c),new e(t++*t++),u,1),o=s.plus(r),o.d[d]!==void 0){for(a=d;o.d[a]===s.d[a]&&a--;);if(a==-1)break}a=s,s=r,r=o,o=a,l++}return Oa=!0,o.d.length=d+1,o}function ho(e,t){for(var n=e;--t;)n*=e;return n}function go(e,t){var n,r=t.s<0,i=to(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return Da=r?4:1,t;if(n=t.divToInt(i),n.isZero())Da=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return Da=ao(n)?r?2:3:r?4:1,t;Da=ao(n)?r?1:4:r?3:2}return t.minus(i).abs()}function _o(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(Ka(n,1,xa),r===void 0?r=p.rounding:Ka(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=lo(e);else{for(u=Qa(e),o=u.indexOf(`.`),m?(i=2,t==16?n=n*4-3:t==8&&(n=n*3-2)):i=t,o>=0&&(u=u.replace(`.`,``),f=new p(1),f.e=u.length-o,f.d=Ja(Qa(f),10,i),f.e=f.d.length),d=Ja(u,10,i),a=c=d.length;d[--c]==0;)d.pop();if(!d[0])u=m?`0p+0`:`0`;else{if(o<0?a--:(e=new p(e),e.d=d,e.e=a,e=Xa(e,f,n,r,0,i),d=e.d,a=e.e,l=Ea),o=d[n],s=i/2,l||=d[n+1]!==void 0,l=r<4?(o!==void 0||l)&&(r===0||r===(e.s<0?3:2)):o>s||o===s&&(r===4||l||r===6&&d[n-1]&1||r===(e.s<0?8:7)),d.length=n,l)for(;++d[--n]>i-1;)d[n]=0,n||(++a,d.unshift(1));for(c=d.length;!d[c-1];--c);for(o=0,u=``;o<c;o++)u+=Sa.charAt(d[o]);if(m){if(c>1)if(t==16||t==8){for(o=t==16?4:3,--c;c%o;c++)u+=`0`;for(d=Ja(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=Sa.charAt(d[o])}else u=u.charAt(0)+`.`+u.slice(1);u=u+(a<0?`p`:`p+`)+a}else if(a<0){for(;++a;)u=`0`+u;u=`0.`+u}else if(++a>c)for(a-=c;a--;)u+=`0`;else a<c&&(u=u.slice(0,a)+`.`+u.slice(a))}u=(t==16?`0x`:t==2?`0b`:t==8?`0o`:``)+u}return e.s<0?`-`+u:u}function vo(e,t){if(e.length>t)return e.length=t,!0}function yo(e){return new this(e).abs()}function bo(e){return new this(e).acos()}function xo(e){return new this(e).acosh()}function So(e,t){return new this(e).plus(t)}function Co(e){return new this(e).asin()}function wo(e){return new this(e).asinh()}function To(e){return new this(e).atan()}function Eo(e){return new this(e).atanh()}function Do(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,a=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=to(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?to(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=to(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(Xa(e,t,a,1)),t=to(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(Xa(e,t,a,1)),n}function Oo(e){return new this(e).cbrt()}function ko(e){return Za(e=new this(e),e.e+1,2)}function Ao(e,t,n){return new this(e).clamp(t,n)}function jo(e){if(!e||typeof e!=`object`)throw Error(ka+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,xa,`rounding`,0,8,`toExpNeg`,-ba,0,`toExpPos`,0,ba,`maxE`,0,ba,`minE`,-ba,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=Ta[n]),(r=e[n])!==void 0)if(Pa(r)===r&&r>=a[t+1]&&r<=a[t+2])this[n]=r;else throw Error(Aa+n+`: `+r);if(n=`crypto`,i&&(this[n]=Ta[n]),(r=e[n])!==void 0)if(r===!0||r===!1||r===0||r===1)if(r)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[n]=!0;else throw Error(Ma);else this[n]=!1;else throw Error(Aa+n+`: `+r);return this}function Mo(e){return new this(e).cos()}function No(e){return new this(e).cosh()}function Po(e){var t,n,r;function i(e){var t,n,r,a=this;if(!(a instanceof i))return new i(e);if(a.constructor=i,zo(e)){a.s=e.s,Oa?!e.d||e.e>i.maxE?(a.e=NaN,a.d=null):e.e<i.minE?(a.e=0,a.d=[0]):(a.e=e.e,a.d=e.d.slice()):(a.e=e.e,a.d=e.d?e.d.slice():e.d);return}if(r=typeof e,r===`number`){if(e===0){a.s=1/e<0?-1:1,a.e=0,a.d=[0];return}if(e<0?(e=-e,a.s=-1):a.s=1,e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;Oa?t>i.maxE?(a.e=NaN,a.d=null):t<i.minE?(a.e=0,a.d=[0]):(a.e=t,a.d=[e]):(a.e=t,a.d=[e]);return}if(e*0!=0){e||(a.s=NaN),a.e=NaN,a.d=null;return}return uo(a,e.toString())}if(r===`string`)return(n=e.charCodeAt(0))===45?(e=e.slice(1),a.s=-1):(n===43&&(e=e.slice(1)),a.s=1),za.test(e)?uo(a,e):fo(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,uo(a,e.toString());throw Error(Aa+e)}if(i.prototype=Y,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=jo,i.clone=Po,i.isDecimal=zo,i.abs=yo,i.acos=bo,i.acosh=xo,i.add=So,i.asin=Co,i.asinh=wo,i.atan=To,i.atanh=Eo,i.atan2=Do,i.cbrt=Oo,i.ceil=ko,i.clamp=Ao,i.cos=Mo,i.cosh=No,i.div=Fo,i.exp=Io,i.floor=Lo,i.hypot=Ro,i.ln=Bo,i.log=Vo,i.log10=Uo,i.log2=Ho,i.max=Wo,i.min=Go,i.mod=Ko,i.mul=qo,i.pow=Jo,i.random=Yo,i.round=Xo,i.sign=Zo,i.sin=Qo,i.sinh=$o,i.sqrt=es,i.sub=ts,i.sum=ns,i.tan=rs,i.tanh=is,i.trunc=as,e===void 0&&(e={}),e&&e.defaults!==!0)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`maxE`,`minE`,`modulo`,`crypto`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function Fo(e,t){return new this(e).div(t)}function Io(e){return new this(e).exp()}function Lo(e){return Za(e=new this(e),e.e+1,3)}function Ro(){var e,t,n=new this(0);for(Oa=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)n.d&&(n=n.plus(t.times(t)));else{if(t.s)return Oa=!0,new this(1/0);n=t}return Oa=!0,n.sqrt()}function zo(e){return e instanceof os||e&&e.toStringTag===Na||!1}function Bo(e){return new this(e).ln()}function Vo(e,t){return new this(e).log(t)}function Ho(e){return new this(e).log(2)}function Uo(e){return new this(e).log(10)}function Wo(){return oo(this,arguments,-1)}function Go(){return oo(this,arguments,1)}function Ko(e,t){return new this(e).mod(t)}function qo(e,t){return new this(e).mul(t)}function Jo(e,t){return new this(e).pow(t)}function Yo(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:Ka(e,1,xa),r=Math.ceil(e/Va),!this.crypto)for(;a<r;)s[a++]=Math.random()*1e7|0;else if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(r));a<r;)i=t[a],i>=429e7?t[a]=crypto.getRandomValues(new Uint32Array(1))[0]:s[a++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(r*=4);a<r;)i=t[a]+(t[a+1]<<8)+(t[a+2]<<16)+((t[a+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,a):(s.push(i%1e7),a+=4);a=r/4}else throw Error(Ma);for(r=s[--a],e%=Va,r&&e&&(i=Fa(10,Va-e),s[a]=(r/i|0)*i);s[a]===0;a--)s.pop();if(a<0)n=0,s=[0];else{for(n=-1;s[0]===0;n-=Va)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<Va&&(n-=Va-r)}return o.e=n,o.d=s,o}function Xo(e){return Za(e=new this(e),e.e+1,this.rounding)}function Zo(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Qo(e){return new this(e).sin()}function $o(e){return new this(e).sinh()}function es(e){return new this(e).sqrt()}function ts(e,t){return new this(e).sub(t)}function ns(){var e=0,t=arguments,n=new this(t[e]);for(Oa=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return Oa=!0,Za(n,this.precision,this.rounding)}function rs(e){return new this(e).tan()}function is(e){return new this(e).tanh()}function as(e){return Za(e=new this(e),e.e+1,1)}Y[Symbol.for(`nodejs.util.inspect.custom`)]=Y.toString,Y[Symbol.toStringTag]=`Decimal`;var os=Y.constructor=Po(Ta);Ca=new os(Ca),wa=new os(wa);var ss=J(`BigNumber`,[`?on`,`config`],e=>{var{on:t,config:n}=e,r=os.clone({precision:n.precision,modulo:os.EUCLID});return r.prototype=Object.create(r.prototype),r.prototype.type=`BigNumber`,r.prototype.isBigNumber=!0,r.prototype.toJSON=function(){return{mathjs:`BigNumber`,value:this.toString()}},r.fromJSON=function(e){return new r(e.value)},t&&t(`config`,function(e,t){e.precision!==t.precision&&r.config({precision:e.precision})}),r},{isClass:!0}),cs=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},ls=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},us=e=>{let t=Math.sin(.5*e);return-2*t*t},ds=function(e,t){return e=Math.abs(e),t=Math.abs(t),e<t&&([e,t]=[t,e]),e<1e8?Math.sqrt(e*e+t*t):(t/=e,e*Math.sqrt(1+t*t))},fs=function(){throw SyntaxError(`Invalid Param`)};function ps(e,t){let n=Math.abs(e),r=Math.abs(t);return e===0?Math.log(r):t===0?Math.log(n):n<3e3&&r<3e3?Math.log(e*e+t*t)*.5:(e*=.5,t*=.5,.5*Math.log(e*e+t*t)+Math.LN2)}var ms={re:0,im:0},hs=function(e,t){let n=ms;if(e==null)n.re=n.im=0;else if(t!==void 0)n.re=e,n.im=t;else switch(typeof e){case`object`:if(`im`in e&&`re`in e)n.re=e.re,n.im=e.im;else if(`abs`in e&&`arg`in e){if(!isFinite(e.abs)&&isFinite(e.arg))return X.INFINITY;n.re=e.abs*Math.cos(e.arg),n.im=e.abs*Math.sin(e.arg)}else if(`r`in e&&`phi`in e){if(!isFinite(e.r)&&isFinite(e.phi))return X.INFINITY;n.re=e.r*Math.cos(e.phi),n.im=e.r*Math.sin(e.phi)}else e.length===2?(n.re=e[0],n.im=e[1]):fs();break;case`string`:n.im=n.re=0;let t=e.replace(/_/g,``).match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,i=0;t===null&&fs();for(let e=0;e<t.length;e++){let a=t[e];a===` `||a===` `||a===`
|
|
3
3
|
`||(a===`+`?r++:a===`-`?i++:a===`i`||a===`I`?(r+i===0&&fs(),t[e+1]!==` `&&!isNaN(t[e+1])?(n.im+=parseFloat((i%2?`-`:``)+t[e+1]),e++):n.im+=parseFloat((i%2?`-`:``)+`1`),r=i=0):((r+i===0||isNaN(a))&&fs(),t[e+1]===`i`||t[e+1]===`I`?(n.im+=parseFloat((i%2?`-`:``)+a),e++):n.re+=parseFloat((i%2?`-`:``)+a),r=i=0))}r+i>0&&fs();break;case`number`:n.im=0,n.re=e;break;default:fs()}return isNaN(n.re)||isNaN(n.im),n};function X(e,t){if(!(this instanceof X))return new X(e,t);let n=hs(e,t);this.re=n.re,this.im=n.im}X.prototype={re:0,im:0,sign:function(){let e=ds(this.re,this.im);return new X(this.re/e,this.im/e)},add:function(e,t){let n=hs(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?X.NAN:X.INFINITY:new X(this.re+n.re,this.im+n.im)},sub:function(e,t){let n=hs(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im));return r||i?r&&i?X.NAN:X.INFINITY:new X(this.re-n.re,this.im-n.im)},mul:function(e,t){let n=hs(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;return r&&o||i&&a?X.NAN:r||i?X.INFINITY:n.im===0&&this.im===0?new X(this.re*n.re,0):new X(this.re*n.re-this.im*n.im,this.re*n.im+this.im*n.re)},div:function(e,t){let n=hs(e,t),r=this.isInfinite(),i=!(isFinite(n.re)&&isFinite(n.im)),a=this.re===0&&this.im===0,o=n.re===0&&n.im===0;if(a&&o||r&&i)return X.NAN;if(o||r)return X.INFINITY;if(a||i)return X.ZERO;if(n.im===0)return new X(this.re/n.re,this.im/n.re);if(Math.abs(n.re)<Math.abs(n.im)){let e=n.re/n.im,t=n.re*e+n.im;return new X((this.re*e+this.im)/t,(this.im*e-this.re)/t)}else{let e=n.im/n.re,t=n.im*e+n.re;return new X((this.re+this.im*e)/t,(this.im-this.re*e)/t)}},pow:function(e,t){let n=hs(e,t),r=this.re===0&&this.im===0;if(n.re===0&&n.im===0)return X.ONE;if(n.im===0){if(this.im===0&&this.re>0)return new X(this.re**+n.re,0);if(this.re===0)switch((n.re%4+4)%4){case 0:return new X(this.im**+n.re,0);case 1:return new X(0,this.im**+n.re);case 2:return new X(-(this.im**+n.re),0);case 3:return new X(0,-(this.im**+n.re))}}if(r&&n.re>0)return X.ZERO;let i=Math.atan2(this.im,this.re),a=ps(this.re,this.im),o=Math.exp(n.re*a-n.im*i),s=n.im*a+n.re*i;return new X(o*Math.cos(s),o*Math.sin(s))},sqrt:function(){let e=this.re,t=this.im;if(t===0)return e>=0?new X(Math.sqrt(e),0):new X(0,Math.sqrt(-e));let n=ds(e,t),r=Math.sqrt(.5*(n+Math.abs(e))),i=Math.abs(t)/(2*r);return e>=0?new X(r,t<0?-i:i):new X(i,t<0?-r:r)},exp:function(){let e=Math.exp(this.re);return this.im===0?new X(e,0):new X(e*Math.cos(this.im),e*Math.sin(this.im))},expm1:function(){let e=this.re,t=this.im;return new X(Math.expm1(e)*Math.cos(t)+us(t),Math.exp(e)*Math.sin(t))},log:function(){let e=this.re,t=this.im;return t===0&&e>0?new X(Math.log(e),0):new X(ps(e,t),Math.atan2(t,e))},abs:function(){return ds(this.re,this.im)},arg:function(){return Math.atan2(this.im,this.re)},sin:function(){let e=this.re,t=this.im;return new X(Math.sin(e)*cs(t),Math.cos(e)*ls(t))},cos:function(){let e=this.re,t=this.im;return new X(Math.cos(e)*cs(t),-Math.sin(e)*ls(t))},tan:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)+cs(t);return new X(Math.sin(e)/n,ls(t)/n)},cot:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)-cs(t);return new X(-Math.sin(e)/n,ls(t)/n)},sec:function(){let e=this.re,t=this.im,n=.5*cs(2*t)+.5*Math.cos(2*e);return new X(Math.cos(e)*cs(t)/n,Math.sin(e)*ls(t)/n)},csc:function(){let e=this.re,t=this.im,n=.5*cs(2*t)-.5*Math.cos(2*e);return new X(Math.sin(e)*cs(t)/n,-Math.cos(e)*ls(t)/n)},asin:function(){let e=this.re,t=this.im,n=new X(t*t-e*e+1,-2*e*t).sqrt(),r=new X(n.re-t,n.im+e).log();return new X(r.im,-r.re)},acos:function(){let e=this.re,t=this.im,n=new X(t*t-e*e+1,-2*e*t).sqrt(),r=new X(n.re-t,n.im+e).log();return new X(Math.PI/2-r.im,r.re)},atan:function(){let e=this.re,t=this.im;if(e===0){if(t===1)return new X(0,1/0);if(t===-1)return new X(0,-1/0)}let n=e*e+(1-t)*(1-t),r=new X((1-t*t-e*e)/n,-2*e/n).log();return new X(-.5*r.im,.5*r.re)},acot:function(){let e=this.re,t=this.im;if(t===0)return new X(Math.atan2(1,e),0);let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).atan():new X(e/n,-t/n).atan()},asec:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new X(0,1/0);let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).acos():new X(e/n,-t/n).acos()},acsc:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new X(Math.PI/2,1/0);let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).asin():new X(e/n,-t/n).asin()},sinh:function(){let e=this.re,t=this.im;return new X(ls(e)*Math.cos(t),cs(e)*Math.sin(t))},cosh:function(){let e=this.re,t=this.im;return new X(cs(e)*Math.cos(t),ls(e)*Math.sin(t))},tanh:function(){let e=2*this.re,t=2*this.im,n=cs(e)+Math.cos(t);return new X(ls(e)/n,Math.sin(t)/n)},coth:function(){let e=2*this.re,t=2*this.im,n=cs(e)-Math.cos(t);return new X(ls(e)/n,-Math.sin(t)/n)},csch:function(){let e=this.re,t=this.im,n=Math.cos(2*t)-cs(2*e);return new X(-2*ls(e)*Math.cos(t)/n,2*cs(e)*Math.sin(t)/n)},sech:function(){let e=this.re,t=this.im,n=Math.cos(2*t)+cs(2*e);return new X(2*cs(e)*Math.cos(t)/n,-2*ls(e)*Math.sin(t)/n)},asinh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new X(0,0);let t=Math.abs(e),n=Math.log(t+Math.sqrt(t*t+1));return new X(e<0?-n:n,0)}let n=new X(e*e-t*t+1,2*e*t).sqrt();return new X(e+n.re,t+n.im).log()},acosh:function(){let e=this.re,t=this.im;if(t===0){if(e>1)return new X(Math.log(e+Math.sqrt(e-1)*Math.sqrt(e+1)),0);if(e<-1){let t=Math.sqrt(e*e-1);return new X(Math.log(-e+t),Math.PI)}return new X(0,Math.acos(e))}let n=new X(e-1,t).sqrt(),r=new X(e+1,t).sqrt();return new X(e+n.re*r.re-n.im*r.im,t+n.re*r.im+n.im*r.re).log()},atanh:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new X(0,0);if(e===1)return new X(1/0,0);if(e===-1)return new X(-1/0,0);if(-1<e&&e<1)return new X(.5*Math.log((1+e)/(1-e)),0);if(e>1){let t=(e+1)/(e-1);return new X(.5*Math.log(t),-Math.PI/2)}let t=(1+e)/(1-e);return new X(.5*Math.log(-t),Math.PI/2)}let n=1-e,r=1+e,i=n*n+t*t;if(i===0)return new X(e===-1?0:e/0,t===0?0:t/0);let a=(r*n-t*t)/i,o=(t*n+r*t)/i;return new X(ps(a,o)/2,Math.atan2(o,a)/2)},acoth:function(){let e=this.re,t=this.im;if(e===0&&t===0)return new X(0,Math.PI/2);let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).atanh():new X(e/n,-t/n).atanh()},acsch:function(){let e=this.re,t=this.im;if(t===0){if(e===0)return new X(1/0,0);let t=1/e;return new X(Math.log(t+Math.sqrt(t*t+1)),0)}let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).asinh():new X(e/n,-t/n).asinh()},asech:function(){let e=this.re,t=this.im;if(this.isZero())return X.INFINITY;let n=e*e+t*t;return n===0?new X(e===0?0:e/0,t===0?0:-t/0).acosh():new X(e/n,-t/n).acosh()},inverse:function(){if(this.isZero())return X.INFINITY;if(this.isInfinite())return X.ZERO;let e=this.re,t=this.im,n=e*e+t*t;return new X(e/n,-t/n)},conjugate:function(){return new X(this.re,-this.im)},neg:function(){return new X(-this.re,-this.im)},ceil:function(e){return e=10**(e||0),new X(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)},floor:function(e){return e=10**(e||0),new X(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)},round:function(e){return e=10**(e||0),new X(Math.round(this.re*e)/e,Math.round(this.im*e)/e)},equals:function(e,t){let n=hs(e,t);return Math.abs(n.re-this.re)<=X.EPSILON&&Math.abs(n.im-this.im)<=X.EPSILON},clone:function(){return new X(this.re,this.im)},toString:function(){let e=this.re,t=this.im,n=``;return this.isNaN()?`NaN`:this.isInfinite()?`Infinity`:(Math.abs(e)<X.EPSILON&&(e=0),Math.abs(t)<X.EPSILON&&(t=0),t===0?n+e:(e===0?t<0&&(t=-t,n+=`-`):(n+=e,n+=` `,t<0?(t=-t,n+=`-`):n+=`+`,n+=` `),t!==1&&(n+=t),n+`i`))},toVector:function(){return[this.re,this.im]},valueOf:function(){return this.im===0?this.re:null},isNaN:function(){return isNaN(this.re)||isNaN(this.im)},isZero:function(){return this.im===0&&this.re===0},isFinite:function(){return isFinite(this.re)&&isFinite(this.im)},isInfinite:function(){return!this.isFinite()}},X.ZERO=new X(0,0),X.ONE=new X(1,0),X.I=new X(0,1),X.PI=new X(Math.PI,0),X.E=new X(Math.E,0),X.INFINITY=new X(1/0,1/0),X.NAN=new X(NaN,NaN),X.EPSILON=1e-15;var gs=J(`Complex`,[],()=>(Object.defineProperty(X,`name`,{value:`Complex`}),X.prototype.constructor=X,X.prototype.type=`Complex`,X.prototype.isComplex=!0,X.prototype.toJSON=function(){return{mathjs:`Complex`,re:this.re,im:this.im}},X.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},X.prototype.format=function(e){var t=``,n=this.im,r=this.re,i=Ki(this.re,e),a=Ki(this.im,e),o=Er(e)?e:e?e.precision:null;if(o!==null){var s=10**-o;Math.abs(r/n)<s&&(r=0),Math.abs(n/r)<s&&(n=0)}return t=n===0?i:r===0?n===1?`i`:n===-1?`-i`:a+`i`:n<0?n===-1?i+` - i`:i+` - `+a.substring(1)+`i`:n===1?i+` + i`:i+` + `+a+`i`,t},X.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if(typeof t==`object`)return X(t);throw TypeError(`Input has to be an object with r and phi keys.`);case 2:var n=arguments[0],r=arguments[1];if(Er(n)){if(jr(r)&&r.hasBase(`ANGLE`)&&(r=r.toNumber(`rad`)),Er(r))return new X({r:n,phi:r});throw TypeError(`Phi is not a number nor an angle unit.`)}else throw TypeError(`Radius r is not a number.`);default:throw SyntaxError(`Wrong number of arguments in function fromPolar`)}},X.prototype.valueOf=X.prototype.toString,X.fromJSON=function(e){return new X(e)},X.compare=function(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0},X),{isClass:!0});typeof BigInt>`u`&&(BigInt=function(e){if(isNaN(e))throw Error(``);return e});var _s=BigInt(0),vs=BigInt(1),ys=BigInt(2),bs=BigInt(3),xs=BigInt(5),Ss=BigInt(10);BigInt(2**53-1);var Cs=2e3,ws={s:vs,n:_s,d:vs};function Ts(e,t){try{e=BigInt(e)}catch{throw Ls()}return e*t}function Es(e){return typeof e==`bigint`?e:Math.floor(e)}function Ds(e,t){if(t===_s)throw Is();let n=Object.create(Fs.prototype);n.s=e<_s?-vs:vs,e=e<_s?-e:e;let r=Ps(e,t);return n.n=e/r,n.d=t/r,n}var Os=[ys*ys,ys,ys*ys,ys,ys*ys,ys*bs,ys,ys*bs];function ks(e){let t=Object.create(null);if(e<=vs)return t[e]=vs,t;let n=e=>{t[e]=(t[e]||_s)+vs};for(;e%ys===_s;)n(ys),e/=ys;for(;e%bs===_s;)n(bs),e/=bs;for(;e%xs===_s;)n(xs),e/=xs;for(let t=0,r=ys+xs;r*r<=e;){for(;e%r===_s;)n(r),e/=r;r+=Os[t],t=t+1&7}return e>vs&&n(e),t}var As=function(e,t){let n=_s,r=vs,i=vs;if(e!=null)if(t!==void 0){if(typeof e==`bigint`)n=e;else if(isNaN(e))throw Ls();else if(e%1!=0)throw Rs();else n=BigInt(e);if(typeof t==`bigint`)r=t;else if(isNaN(t))throw Ls();else if(t%1!=0)throw Rs();else r=BigInt(t);i=n*r}else if(typeof e==`object`){if(`d`in e&&`n`in e)n=BigInt(e.n),r=BigInt(e.d),`s`in e&&(n*=BigInt(e.s));else if(0 in e)n=BigInt(e[0]),1 in e&&(r=BigInt(e[1]));else if(typeof e==`bigint`)n=e;else throw Ls();i=n*r}else if(typeof e==`number`){if(isNaN(e))throw Ls();if(e<0&&(i=-vs,e=-e),e%1==0)n=BigInt(e);else{let t=1,i=0,a=1,o=1,s=1,c=1e7;for(e>=1&&(t=10**Math.floor(1+Math.log10(e)),e/=t);a<=c&&s<=c;){let t=(i+o)/(a+s);if(e===t){a+s<=c?(n=i+o,r=a+s):s>a?(n=o,r=s):(n=i,r=a);break}else e>t?(i+=o,a+=s):(o+=i,s+=a),a>c?(n=o,r=s):(n=i,r=a)}n=BigInt(n)*BigInt(t),r=BigInt(r)}}else if(typeof e==`string`){let t=0,a=_s,o=_s,s=_s,c=vs,l=vs,u=e.replace(/_/g,``).match(/\d+|./g);if(u===null)throw Ls();if(u[t]===`-`?(i=-vs,t++):u[t]===`+`&&t++,u.length===t+1?o=Ts(u[t++],i):u[t+1]===`.`||u[t]===`.`?(u[t]!==`.`&&(a=Ts(u[t++],i)),t++,(t+1===u.length||u[t+1]===`(`&&u[t+3]===`)`||u[t+1]===`'`&&u[t+3]===`'`)&&(o=Ts(u[t],i),c=Ss**BigInt(u[t].length),t++),(u[t]===`(`&&u[t+2]===`)`||u[t]===`'`&&u[t+2]===`'`)&&(s=Ts(u[t+1],i),l=Ss**BigInt(u[t+1].length)-vs,t+=3)):u[t+1]===`/`||u[t+1]===`:`?(o=Ts(u[t],i),c=Ts(u[t+2],vs),t+=3):u[t+3]===`/`&&u[t+1]===` `&&(a=Ts(u[t],i),o=Ts(u[t+2],i),c=Ts(u[t+4],vs),t+=5),u.length<=t)r=c*l,i=n=s+r*a+l*o;else throw Ls()}else if(typeof e==`bigint`)n=e,i=e,r=vs;else throw Ls();if(r===_s)throw Is();ws.s=i<_s?-vs:vs,ws.n=n<_s?-n:n,ws.d=r<_s?-r:r};function js(e,t,n){let r=vs;for(;t>_s;e=e*e%n,t>>=vs)t&vs&&(r=r*e%n);return r}function Ms(e,t){for(;t%ys===_s;t/=ys);for(;t%xs===_s;t/=xs);if(t===vs)return _s;let n=Ss%t,r=1;for(;n!==vs;r++)if(n=n*Ss%t,r>Cs)return _s;return BigInt(r)}function Ns(e,t,n){let r=vs,i=js(Ss,n,t);for(let e=0;e<300;e++){if(r===i)return BigInt(e);r=r*Ss%t,i=i*Ss%t}return 0}function Ps(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}}function Fs(e,t){if(As(e,t),this instanceof Fs)e=Ps(ws.d,ws.n),this.s=ws.s,this.n=ws.n/e,this.d=ws.d/e;else return Ds(ws.s*ws.n,ws.d)}var Is=function(){return Error(`Division by Zero`)},Ls=function(){return Error(`Invalid argument`)},Rs=function(){return Error(`Parameters must be integer`)};Fs.prototype={s:vs,n:_s,d:vs,abs:function(){return Ds(this.n,this.d)},neg:function(){return Ds(-this.s*this.n,this.d)},add:function(e,t){return As(e,t),Ds(this.s*this.n*ws.d+ws.s*this.d*ws.n,this.d*ws.d)},sub:function(e,t){return As(e,t),Ds(this.s*this.n*ws.d-ws.s*this.d*ws.n,this.d*ws.d)},mul:function(e,t){return As(e,t),Ds(this.s*ws.s*this.n*ws.n,this.d*ws.d)},div:function(e,t){return As(e,t),Ds(this.s*ws.s*this.n*ws.d,this.d*ws.n)},clone:function(){return Ds(this.s*this.n,this.d)},mod:function(e,t){if(e===void 0)return Ds(this.s*this.n%this.d,vs);if(As(e,t),_s===ws.n*this.d)throw Is();return Ds(this.s*(ws.d*this.n)%(ws.n*this.d),ws.d*this.d)},gcd:function(e,t){return As(e,t),Ds(Ps(ws.n,this.n)*Ps(ws.d,this.d),ws.d*this.d)},lcm:function(e,t){return As(e,t),ws.n===_s&&this.n===_s?Ds(_s,vs):Ds(ws.n*this.n,Ps(ws.n,this.n)*Ps(ws.d,this.d))},inverse:function(){return Ds(this.s*this.d,this.n)},pow:function(e,t){if(As(e,t),ws.d===vs)return ws.s<_s?Ds((this.s*this.d)**ws.n,this.n**ws.n):Ds((this.s*this.n)**ws.n,this.d**ws.n);if(this.s<_s)return null;let n=ks(this.n),r=ks(this.d),i=vs,a=vs;for(let e in n)if(e!==`1`){if(e===`0`){i=_s;break}if(n[e]*=ws.n,n[e]%ws.d===_s)n[e]/=ws.d;else return null;i*=BigInt(e)**n[e]}for(let e in r)if(e!==`1`){if(r[e]*=ws.n,r[e]%ws.d===_s)r[e]/=ws.d;else return null;a*=BigInt(e)**r[e]}return ws.s<_s?Ds(a,i):Ds(i,a)},log:function(e,t){if(As(e,t),this.s<=_s||ws.s<=_s)return null;let n=Object.create(null),r=ks(ws.n),i=ks(ws.d),a=ks(this.n),o=ks(this.d);for(let e in i)r[e]=(r[e]||_s)-i[e];for(let e in o)a[e]=(a[e]||_s)-o[e];for(let e in r)e!==`1`&&(n[e]=!0);for(let e in a)e!==`1`&&(n[e]=!0);let s=null,c=null;for(let e in n){let t=r[e]||_s,n=a[e]||_s;if(t===_s){if(n!==_s)return null;continue}let i=n,o=t,l=Ps(i,o);if(i/=l,o/=l,s===null&&c===null)s=i,c=o;else if(i*c!==s*o)return null}return s!==null&&c!==null?Ds(s,c):null},equals:function(e,t){return As(e,t),this.s*this.n*ws.d===ws.s*ws.n*this.d},lt:function(e,t){return As(e,t),this.s*this.n*ws.d<ws.s*ws.n*this.d},lte:function(e,t){return As(e,t),this.s*this.n*ws.d<=ws.s*ws.n*this.d},gt:function(e,t){return As(e,t),this.s*this.n*ws.d>ws.s*ws.n*this.d},gte:function(e,t){return As(e,t),this.s*this.n*ws.d>=ws.s*ws.n*this.d},compare:function(e,t){As(e,t);let n=this.s*this.n*ws.d-ws.s*ws.n*this.d;return(_s<n)-(n<_s)},ceil:function(e){return e=Ss**BigInt(e||0),Ds(Es(this.s*e*this.n/this.d)+(e*this.n%this.d>_s&&this.s>=_s?vs:_s),e)},floor:function(e){return e=Ss**BigInt(e||0),Ds(Es(this.s*e*this.n/this.d)-(e*this.n%this.d>_s&&this.s<_s?vs:_s),e)},round:function(e){return e=Ss**BigInt(e||0),Ds(Es(this.s*e*this.n/this.d)+this.s*((this.s>=_s?vs:_s)+ys*(e*this.n%this.d)>this.d?vs:_s),e)},roundTo:function(e,t){As(e,t);let n=this.n*ws.d,r=this.d*ws.n,i=n%r,a=Es(n/r);return i+i>=r&&a++,Ds(this.s*a*ws.n,ws.d)},divisible:function(e,t){return As(e,t),ws.n===_s?!1:this.n*ws.d%(ws.n*this.d)===_s},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let t=this.n,n=this.d,r=Ms(t,n),i=Ns(t,n,r),a=this.s<_s?`-`:``;if(a+=Es(t/n),t%=n,t*=Ss,t&&(a+=`.`),r){for(let e=i;e--;)a+=Es(t/n),t%=n,t*=Ss;a+=`(`;for(let e=r;e--;)a+=Es(t/n),t%=n,t*=Ss;a+=`)`}else for(let r=e;t&&r--;)a+=Es(t/n),t%=n,t*=Ss;return a},toFraction:function(e=!1){let t=this.n,n=this.d,r=this.s<_s?`-`:``;if(n===vs)r+=t;else{let i=Es(t/n);e&&i>_s&&(r+=i,r+=` `,t%=n),r+=t,r+=`/`,r+=n}return r},toLatex:function(e=!1){let t=this.n,n=this.d,r=this.s<_s?`-`:``;if(n===vs)r+=t;else{let i=Es(t/n);e&&i>_s&&(r+=i,t%=n),r+=`\\frac{`,r+=t,r+=`}{`,r+=n,r+=`}`}return r},toContinued:function(){let e=this.n,t=this.d,n=[];for(;t;){n.push(Es(e/t));let r=e%t;e=t,t=r}return n},simplify:function(e=.001){let t=BigInt(Math.ceil(1/e)),n=this.abs(),r=n.toContinued();for(let e=1;e<r.length;e++){let i=Ds(r[e-1],vs);for(let t=e-2;t>=0;t--)i=i.inverse().add(r[t]);let a=i.sub(n);if(a.n*t<a.d)return i.mul(this.s)}return this}};var zs=J(`Fraction`,[],()=>(Object.defineProperty(Fs,`name`,{value:`Fraction`}),Fs.prototype.constructor=Fs,Fs.prototype.type=`Fraction`,Fs.prototype.isFraction=!0,Fs.prototype.toJSON=function(){return{mathjs:`Fraction`,n:String(this.s*this.n),d:String(this.d)}},Fs.fromJSON=function(e){return new Fs(e)},Fs),{isClass:!0}),Bs=J(`Range`,[],()=>{function e(t,n,r){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`);var i=t!=null,a=n!=null,o=r!=null;if(i){if(Dr(t))t=t.toNumber();else if(typeof t!=`number`&&!Or(t))throw TypeError(`Parameter start must be a number or bigint`)}if(a){if(Dr(n))n=n.toNumber();else if(typeof n!=`number`&&!Or(n))throw TypeError(`Parameter end must be a number or bigint`)}if(o){if(Dr(r))r=r.toNumber();else if(typeof r!=`number`&&!Or(r))throw TypeError(`Parameter step must be a number or bigint`)}if(this.start=i?parseFloat(t):0,this.end=a?parseFloat(n):0,this.step=o?parseFloat(r):1,o&&na(this.step,0))throw Error(`Step must not be zero`)}return e.prototype.type=`Range`,e.prototype.isRange=!0,e.parse=function(t){if(typeof t!=`string`)return null;var n=t.split(`:`).map(function(e){return parseFloat(e)});if(n.some(function(e){return isNaN(e)}))return null;switch(n.length){case 2:return new e(n[0],n[1]);case 3:return new e(n[0],n[2],n[1]);default:return null}},e.prototype.clone=function(){return new e(this.start,this.end,this.step)},e.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end-t;return zi(n)===zi(r)?e=Math.ceil(r/n):r===0&&(e=0),isNaN(e)&&(e=0),[e]},e.prototype.min=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start:this.start+(e-1)*this.step},e.prototype.max=function(){var e=this.size()[0];if(e>0)return this.step>0?this.start+(e-1)*this.step:this.start},e.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,i=0;if(n>0)for(;t<r;)e(t,[i],this),t+=n,i++;else if(n<0)for(;t>r;)e(t,[i],this),t+=n,i++},e.prototype.map=function(e){var t=[];return this.forEach(function(n,r,i){t[r[0]]=e(n,r,i)}),t},e.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n[0]]=t}),e},e.prototype.valueOf=function(){return this.toArray()},e.prototype.format=function(e){var t=Ki(this.start,e);return this.step!==1&&(t+=`:`+Ki(this.step,e)),t+=`:`+Ki(this.end,e),t},e.prototype.toString=function(){return this.format()},e.prototype.toJSON=function(){return{mathjs:`Range`,start:this.start,end:this.end,step:this.step}},e.fromJSON=function(t){return new e(t.start,t.end,t.step)},e},{isClass:!0}),Vs=J(`Matrix`,[],()=>{function e(){if(!(this instanceof e))throw SyntaxError(`Constructor must be called with the new operator`)}return e.prototype.type=`Matrix`,e.prototype.isMatrix=!0,e.prototype.storage=function(){throw Error(`Cannot invoke storage on a Matrix interface`)},e.prototype.datatype=function(){throw Error(`Cannot invoke datatype on a Matrix interface`)},e.prototype.create=function(e,t){throw Error(`Cannot invoke create on a Matrix interface`)},e.prototype.subset=function(e,t,n){throw Error(`Cannot invoke subset on a Matrix interface`)},e.prototype.get=function(e){throw Error(`Cannot invoke get on a Matrix interface`)},e.prototype.set=function(e,t,n){throw Error(`Cannot invoke set on a Matrix interface`)},e.prototype.resize=function(e,t){throw Error(`Cannot invoke resize on a Matrix interface`)},e.prototype.reshape=function(e,t){throw Error(`Cannot invoke reshape on a Matrix interface`)},e.prototype.clone=function(){throw Error(`Cannot invoke clone on a Matrix interface`)},e.prototype.size=function(){throw Error(`Cannot invoke size on a Matrix interface`)},e.prototype.map=function(e,t){throw Error(`Cannot invoke map on a Matrix interface`)},e.prototype.forEach=function(e){throw Error(`Cannot invoke forEach on a Matrix interface`)},e.prototype[Symbol.iterator]=function(){throw Error(`Cannot iterate a Matrix interface`)},e.prototype.toArray=function(){throw Error(`Cannot invoke toArray on a Matrix interface`)},e.prototype.valueOf=function(){throw Error(`Cannot invoke valueOf on a Matrix interface`)},e.prototype.format=function(e){throw Error(`Cannot invoke format on a Matrix interface`)},e.prototype.toString=function(){throw Error(`Cannot invoke toString on a Matrix interface`)},e},{isClass:!0});function Hs(e,t,n){var r=e.constructor,i=new r(2),a=``;if(n){if(n<1)throw Error(`size must be in greater than 0`);if(!Li(n))throw Error(`size must be an integer`);if(e.greaterThan(i.pow(n-1).sub(1))||e.lessThan(i.pow(n-1).mul(-1)))throw Error(`Value must be in range [-2^${n-1}, 2^${n-1}-1]`);if(!e.isInteger())throw Error(`Value must be an integer`);e.lessThan(0)&&(e=e.add(i.pow(n))),a=`i${n}`}switch(t){case 2:return`${e.toBinary()}${a}`;case 8:return`${e.toOctal()}${a}`;case 16:return`${e.toHexadecimal()}${a}`;default:throw Error(`Base ${t} not supported `)}}function Us(e,t){if(typeof t==`function`)return t(e);if(!e.isFinite())return e.isNaN()?`NaN`:e.gt(0)?`Infinity`:`-Infinity`;var{notation:n,precision:r,wordSize:i}=qi(t);switch(n){case`fixed`:return Ks(e,r);case`exponential`:return Gs(e,r);case`engineering`:return Ws(e,r);case`bin`:return Hs(e,2,i);case`oct`:return Hs(e,8,i);case`hex`:return Hs(e,16,i);case`auto`:var a=qs(t?.lowerExp,-3),o=qs(t?.upperExp,5);if(e.isZero())return`0`;var s,c=e.toSignificantDigits(r),l=c.e;return s=l>=a&&l<o?c.toFixed():Gs(e,r),s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return e===`.`?t:e+t});default:throw Error(`Unknown notation "`+n+`". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.`)}}function Ws(e,t){var n=e.e,r=n%3==0?n:n<0?n-3-n%3:n-n%3,i=e.mul(10**-r).toPrecision(t);if(i.includes(`e`)){var a=e.constructor;i=new a(i).toFixed()}return i+`e`+(n>=0?`+`:``)+r.toString()}function Gs(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function Ks(e,t){return e.toFixed(t)}function qs(e,t){return Er(e)?e:Dr(e)?e.toNumber():t}function Js(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function Ys(e,t){var n=Xs(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function Xs(e,t){return typeof e==`number`?Ki(e,t):Dr(e)?Us(e,t):tc(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?ec(e,t):Mr(e)?Zs(e):typeof e==`function`?e.syntax?String(e.syntax):`function`:e&&typeof e==`object`?typeof e.format==`function`?e.format(t):e&&e.toString(t)!=={}.toString()?e.toString(t):`{`+Object.keys(e).map(n=>Zs(n)+`: `+Ys(e[n],t)).join(`, `)+`}`:String(e)}function Zs(e){for(var t=String(e),n=``,r=0;r<t.length;){var i=t.charAt(r);n+=i in Qs?Qs[i]:i,r++}return`"`+n+`"`}var Qs={'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`};function $s(e){var t=String(e);return t=t.replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`),t}function ec(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;i<r;i++)i!==0&&(n+=`, `),n+=ec(e[i],t);return n+=`]`,n}else return Ys(e,t)}function tc(e){return e&&typeof e==`object`&&typeof e.s==`bigint`&&typeof e.n==`bigint`&&typeof e.d==`bigint`||!1}function nc(e,t){if(!Mr(e))throw TypeError(`Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: `+gi(e)+`, index: 0)`);if(!Mr(t))throw TypeError(`Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: `+gi(t)+`, index: 1)`);return e===t?0:e>t?1:-1}function rc(e,t,n){if(!(this instanceof rc))throw SyntaxError(`Constructor must be called with the new operator`);this.actual=e,this.expected=t,this.relation=n,this.message=`Dimension mismatch (`+(Array.isArray(e)?`[`+e.join(`, `)+`]`:e)+` `+(this.relation||`!=`)+` `+(Array.isArray(t)?`[`+t.join(`, `)+`]`:t)+`)`,this.stack=Error().stack}rc.prototype=RangeError(),rc.prototype.constructor=RangeError,rc.prototype.name=`DimensionError`,rc.prototype.isDimensionError=!0;function ic(e,t,n){if(!(this instanceof ic))throw SyntaxError(`Constructor must be called with the new operator`);this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=n),this.min!==void 0&&this.index<this.min?this.message=`Index out of range (`+this.index+` < `+this.min+`)`:this.max!==void 0&&this.index>=this.max?this.message=`Index out of range (`+this.index+` > `+(this.max-1)+`)`:this.message=`Index out of range (`+this.index+`)`,this.stack=Error().stack}ic.prototype=RangeError(),ic.prototype.constructor=RangeError,ic.prototype.name=`IndexError`,ic.prototype.isIndexError=!0;function ac(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function oc(e,t,n){var r,i=e.length;if(i!==t[n])throw new rc(i,t[n]);if(n<t.length-1){var a=n+1;for(r=0;r<i;r++){var o=e[r];if(!Array.isArray(o))throw new rc(t.length-1,t.length,`<`);oc(e[r],t,a)}}else for(r=0;r<i;r++)if(Array.isArray(e[r]))throw new rc(t.length+1,t.length,`>`)}function sc(e,t){if(t.length===0){if(Array.isArray(e))throw new rc(e.length,0)}else oc(e,t,0)}function cc(e,t){var n=e.isMatrix?e._size:ac(e);t._sourceSize.forEach((e,t)=>{if(e!==null&&e!==n[t])throw new rc(e,n[t])})}function lc(e,t){if(e!==void 0){if(!Er(e)||!Li(e))throw TypeError(`Index must be an integer (value: `+e+`)`);if(e<0||typeof t==`number`&&e>=t)throw new ic(e,t)}}function uc(e){for(var t=0;t<e._dimensions.length;++t){var n=e._dimensions[t];if(n._data&&Nr(n._data)){if(n._size[0]===0)return!0}else if(n.isRange){if(n.start===n.end)return!0}else if(Mr(n)&&n.length===0)return!0}return!1}function dc(e,t,n){if(!Array.isArray(t))throw TypeError(`Array expected`);if(t.length===0)throw Error(`Resizing to scalar is not supported`);return t.forEach(function(e){if(!Er(e)||!Li(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+Ys(t)+`)`)}),(Er(e)||Dr(e))&&(e=[e]),fc(e,t,0,n===void 0?0:n),e}function fc(e,t,n,r){var i,a,o=e.length,s=t[n],c=Math.min(o,s);if(e.length=s,n<t.length-1){var l=n+1;for(i=0;i<c;i++)a=e[i],Array.isArray(a)||(a=[a],e[i]=a),fc(a,t,l,r);for(i=c;i<s;i++)a=[],e[i]=a,fc(a,t,l,r)}else{for(i=0;i<c;i++)for(;Array.isArray(e[i]);)e[i]=e[i][0];for(i=c;i<s;i++)e[i]=r}}function pc(e,t){var n=xc(e,!0),r=n.length;if(!Array.isArray(e)||!Array.isArray(t))throw TypeError(`Array expected`);if(t.length===0)throw new rc(0,r,`!=`);t=mc(t,r);var i=hc(t);if(r!==i)throw new rc(i,r,`!=`);try{return gc(n,t)}catch(e){throw e instanceof rc?new rc(i,r,`!=`):e}}function mc(e,t){var n=hc(e),r=e.slice(),i=-1,a=e.indexOf(i);if(e.indexOf(i,a+1)>=0)throw Error(`More than one wildcard in sizes`);var o=a>=0,s=t%n===0;if(o)if(s)r[a]=-t/n;else throw Error(`Could not replace wildcard, since `+t+` is no multiple of `+-n);return r}function hc(e){return e.reduce((e,t)=>e*t,1)}function gc(e,t){for(var n=e,r,i=t.length-1;i>0;i--){var a=t[i];r=[];for(var o=n.length/a,s=0;s<o;s++)r.push(n.slice(s*a,(s+1)*a));n=r}return n}function _c(e,t){for(var n=t||ac(e);Array.isArray(e)&&e.length===1;)e=e[0],n.shift();for(var r=n.length;n[r-1]===1;)r--;return r<n.length&&(e=vc(e,r,0),n.length=r),e}function vc(e,t,n){var r,i;if(n<t){var a=n+1;for(r=0,i=e.length;r<i;r++)e[r]=vc(e[r],t,a)}else for(;Array.isArray(e);)e=e[0];return e}function yc(e,t,n,r){var i=r||ac(e);if(n)for(var a=0;a<n;a++)e=[e],i.unshift(1);for(e=bc(e,t,0);i.length<t;)i.push(1);return e}function bc(e,t,n){var r,i;if(Array.isArray(e)){var a=n+1;for(r=0,i=e.length;r<i;r++)e[r]=bc(e[r],t,a)}else for(var o=n;o<t;o++)e=[e];return e}function xc(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!Array.isArray(e))return e;if(typeof t!=`boolean`)throw TypeError(`Boolean expected for second argument of flatten`);var n=[];return t?i(e):r(e),n;function r(e){for(var t=0;t<e.length;t++){var i=e[t];Array.isArray(i)?r(i):n.push(i)}}function i(e){if(Array.isArray(e[0]))for(var t=0;t<e.length;t++)i(e[t]);else for(var r=0;r<e.length;r++)n.push(e[r])}}function Sc(e,t){return Array.prototype.map.call(e,t)}function Cc(e,t){Array.prototype.forEach.call(e,t)}function wc(e,t){if(ac(e).length!==1)throw Error(`Only one dimensional matrices supported`);return Array.prototype.filter.call(e,t)}function Tc(e,t){if(ac(e).length!==1)throw Error(`Only one dimensional matrices supported`);return Array.prototype.filter.call(e,e=>t.test(e))}function Ec(e,t){return Array.prototype.join.call(e,t)}function Dc(e){if(!Array.isArray(e))throw TypeError(`Array input expected`);if(e.length===0)return e;var t=[],n=0;t[0]={value:e[0],identifier:0};for(var r=1;r<e.length;r++)e[r]===e[r-1]?n++:n=0,t.push({value:e[r],identifier:n});return t}function Oc(e){if(!Array.isArray(e))throw TypeError(`Array input expected`);if(e.length===0)return e;for(var t=[],n=0;n<e.length;n++)t.push(e[n].value);return t}function kc(e,t){for(var n,r=0,i=0;i<e.length;i++){var a=e[i],o=Array.isArray(a);if(i===0&&o&&(r=a.length),o&&a.length!==r)return;var s=o?kc(a,t):t(a);if(n===void 0)n=s;else if(n!==s)return`mixed`}return n}function Ac(e,t,n,r){if(r<n){if(e.length!==t.length)throw new rc(e.length,t.length);for(var i=[],a=0;a<e.length;a++)i[a]=Ac(e[a],t[a],n,r+1);return i}else return e.concat(t)}function jc(){var e=Array.prototype.slice.call(arguments,0,-1),t=Array.prototype.slice.call(arguments,-1);if(e.length===1)return e[0];if(e.length>1)return e.slice(1).reduce(function(e,n){return Ac(e,n,t,0)},e[0]);throw Error(`Wrong number of arguments in function concat`)}function Mc(){for(var e=[...arguments],t=e.map(e=>e.length),n=Math.max(...t),r=Array(n).fill(null),i=0;i<e.length;i++)for(var a=e[i],o=t[i],s=0;s<o;s++){var c=n-o+s;a[s]>r[c]&&(r[c]=a[s])}for(var l=0;l<e.length;l++)Nc(e[l],r);return r}function Nc(e,t){for(var n=t.length,r=e.length,i=0;i<r;i++){var a=n-r+i;if(e[i]<t[a]&&e[i]>1||e[i]>t[a])throw Error(`shape mismatch: mismatch is found in arg with shape (${e}) not possible to broadcast dimension ${r} with size ${e[i]} to size ${t[a]}`)}}function Pc(e,t){var n=ac(e);if(xi(n,t))return e;Nc(n,t);var r=Mc(n,t),i=r.length,a=[...Array(i-n.length).fill(1),...n],o=zc(e);n.length<i&&(o=pc(o,a),n=ac(o));for(var s=0;s<i;s++)n[s]<r[s]&&(o=Fc(o,r[s],s),n=ac(o));return o}function Fc(e,t,n){return jc(...Array(t).fill(e),n)}function Ic(e,t){if(!Array.isArray(e))throw Error(`Array expected`);if(!Array.isArray(t))throw Error(`Array expected for index`);var n=ac(e);if(t.length!==n.length)throw new rc(t.length,n.length);for(var r=0;r<t.length;r++)lc(t[r],n[r]);return t.reduce((e,t)=>e[t],e)}function Lc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return[];if(n)return a(e);var r=[];return i(e,0);function i(n,a){if(Array.isArray(n)){for(var o=n.length,s=Array(o),c=0;c<o;c++)r[a]=c,s[c]=i(n[c],a+1);return s}else return t(n,r.slice(0,a),e)}function a(e){if(Array.isArray(e)){for(var n=e.length,r=Array(n),i=0;i<n;i++)r[i]=a(e[i]);return r}else return t(e)}}function Rc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.length===0)return;if(n){a(e);return}var r=[];i(e,0);function i(n,a){if(Array.isArray(n))for(var o=n.length,s=0;s<o;s++)r[a]=s,i(n[s],a+1);else t(n,r.slice(0,a),e)}function a(e){if(Array.isArray(e))for(var n=e.length,r=0;r<n;r++)a(e[r]);else t(e)}}function zc(e){return lr([],e)}function Bc(e,t,n,r){if(fa.default.isTypedFunction(e)){var i;if(r)i=1;else{var a=t.isMatrix?t.size():ac(t);if(!a.length||a[a.length-1]===0)return{isUnary:r,fn:e};var o=a.map(()=>0);i=Uc(e,t.isMatrix?t.get(o):Ic(t,o),o,t)}var s;if(t.isMatrix&&t.dataType!==`mixed`&&t.dataType!==void 0){var c=Vc(e,i);s=c===void 0?e:c}else s=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){return Wc(s,[...arguments].slice(0,i),n,e.name)}}:{isUnary:!1,fn:function(){return Wc(s,[...arguments],n,e.name)}}}return r===void 0?{isUnary:Hc(e),fn:e}:{isUnary:r,fn:e}}function Vc(e,t){var n=[];if(Object.entries(e.signatures).forEach(e=>{var[r,i]=e;r.split(`,`).length===t&&n.push(i)}),n.length===1)return n[0]}function Hc(e){if(e.length!==1)return!1;var t=e.toString();if(/arguments/.test(t))return!1;var n=t.match(/\(.*?\)/);return!/\.\.\./.test(n)}function Uc(e,t,n,r){for(var i=[t,n,r],a=3;a>0;a--){var o=i.slice(0,a);if(fa.default.resolve(e,o)!==null)return a}}function Wc(e,t,n,r){try{return e(...t)}catch(e){Gc(e,t,n,r)}}function Gc(e,t,n,r){if(e instanceof TypeError&&e.data?.category===`wrongType`){var i=[];throw i.push(`value: ${gi(t[0])}`),t.length>=2&&i.push(`index: ${gi(t[1])}`),t.length>=3&&i.push(`array: ${gi(t[2])}`),TypeError(`Function ${n} cannot apply callback arguments ${r}(${i.join(`, `)}) at index ${JSON.stringify(t[1])}`)}else throw TypeError(`Function ${n} cannot apply callback arguments to function ${r}: ${e.message}`)}var Kc=J(`DenseMatrix`,[`Matrix`,`config`],e=>{var{Matrix:t,config:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!Mr(t))throw Error(`Invalid datatype: `+t);if(Pr(e))e.type===`DenseMatrix`?(this._data=_i(e._data),this._size=_i(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&Nr(e.data)&&Nr(e.size))this._data=e.data,this._size=e.size,sc(this._data,this._size),this._datatype=t||e.datatype;else if(Nr(e))this._data=u(e),this._size=ac(this._data),sc(this._data,this._size),this._datatype=t;else if(e)throw TypeError(`Unsupported type of data (`+gi(e)+`)`);else this._data=[],this._size=[0],this._datatype=t}r.prototype=new t,r.prototype.createDenseMatrix=function(e,t){return new r(e,t)},Object.defineProperty(r,`name`,{value:`DenseMatrix`}),r.prototype.constructor=r,r.prototype.type=`DenseMatrix`,r.prototype.isDenseMatrix=!0,r.prototype.getDataType=function(){return kc(this._data,gi)},r.prototype.storage=function(){return`dense`},r.prototype.datatype=function(){return this._datatype},r.prototype.create=function(e,t){return new r(e,t)},r.prototype.subset=function(e,t,n){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return o(this,e,t,n);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.get=function(e){return Ic(this._data,e)},r.prototype.set=function(e,t,n){if(!Nr(e))throw TypeError(`Array expected`);if(e.length<this._size.length)throw new rc(e.length,this._size.length,`<`);var r,i,a,o=e.map(function(e){return e+1});l(this,o,n);var s=this._data;for(r=0,i=e.length-1;r<i;r++)a=e[r],lc(a,s.length),s=s[a];return a=e[e.length-1],lc(a,s.length),s[a]=t,this};function i(e,t){if(!zr(t))throw TypeError(`Invalid index`);if(n.legacySubset?t.size().every(e=>e===1):t.isScalar())return e.get(t.min());var i=t.size();if(i.length!==e._size.length)throw new rc(i.length,e._size.length);for(var o=t.min(),s=t.max(),c=0,l=e._size.length;c<l;c++)lc(o[c],e._size[c]),lc(s[c],e._size[c]);var u=new r,d=a(e._data,t);return u._size=d.size,u._datatype=e._datatype,u._data=d.data,n.legacySubset?u.reshape(t.size()):u}function a(e,t){var n=t.size().length-1,r=Array(n);return{data:i(e),size:r.filter(e=>e!==null)};function i(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=t.dimension(a);function s(e,t){return Er(e)?t(e):e.map(t).valueOf()}return Er(o)?r[a]=null:r[a]=o.size()[0],a<n?s(o,t=>(lc(t,e.length),i(e[t],a+1))):s(o,t=>(lc(t,e.length),e[t]))}}function o(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Invalid index`);var i=t.size(),a=t.isScalar(),o;if(Pr(n)?(o=n.size(),n=n.valueOf()):o=ac(n),a){if(o.length!==0)throw TypeError(`Scalar expected`);e.set(t.min(),n,r)}else{if(!xi(o,i)){if(o.length===0)n=Pc([n],i);else try{n=Pc(n,i)}catch{}o=ac(n)}if(i.length<e._size.length)throw new rc(i.length,e._size.length,`<`);if(o.length<i.length){for(var c=0,u=0;i[c]===1&&o[c]===1;)c++;for(;i[c]===1;)u++,c++;n=yc(n,i.length,u,o)}if(!xi(i,o))throw new rc(i,o,`>`);l(e,t.max().map(function(e){return e+1}),r),s(e._data,t,n)}return e}function s(e,t,n){var r=t.size().length-1;i(e,n);function i(e,n){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=t.dimension(a),s=(t,r)=>{lc(t,e.length),i(e[t],n[r[0]],a+1)},c=(t,r)=>{lc(t,e.length),e[t]=n[r[0]]};a<r?Er(o)?s(o,[0]):o.forEach(s):Er(o)?c(o,[0]):o.forEach(c)}}r.prototype.resize=function(e,t,n){if(!Fr(e))throw TypeError(`Array or Matrix expected`);var r=e.valueOf().map(e=>Array.isArray(e)&&e.length===1?e[0]:e);return c(n?this.clone():this,r,t)};function c(e,t,n){if(t.length===0){for(var r=e._data;Nr(r);)r=r[0];return r}return e._size=t.slice(0),e._data=dc(e._data,e._size,n),e}r.prototype.reshape=function(e,t){var n=t?this.clone():this;return n._data=pc(n._data,e),n._size=mc(e,n._size.reduce((e,t)=>e*t)),n};function l(e,t,n){for(var r=e._size.slice(0),i=!1;r.length<t.length;)r.push(0),i=!0;for(var a=0,o=t.length;a<o;a++)t[a]>r[a]&&(r[a]=t[a],i=!0);i&&c(e,r,n)}r.prototype.clone=function(){return new r({data:_i(this._data),size:_i(this._size),datatype:this._datatype})},r.prototype.size=function(){return this._size.slice(0)},r.prototype.map=function(e){arguments.length>1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return n.clone();var i=Bc(e,n,`map`,t),a=i.fn,o=n.create(void 0,n._datatype);if(o._size=n._size,t||i.isUnary)return o._data=f(n._data),o;if(r===0){for(var s=n.valueOf(),c=Array(s.length),l=0;l<s.length;l++)c[l]=a(s[l],[l],n);return o._data=c,o}var u=[];return o._data=d(n._data),o;function d(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=Array(e.length);if(t<r)for(var o=0;o<e.length;o++)u[t]=o,i[o]=d(e[o],t+1);else for(var s=0;s<e.length;s++)u[t]=s,i[s]=a(e[s],u.slice(),n);return i}function f(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=Array(e.length);if(t<r)for(var i=0;i<e.length;i++)n[i]=f(e[i],t+1);else for(var o=0;o<e.length;o++)n[o]=a(e[o]);return n}},r.prototype.forEach=function(e){arguments.length>1&&arguments[1]!==void 0&&arguments[1];var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=this,r=n._size.length-1;if(r<0)return;var i=Bc(e,n,`map`,t),a=i.fn;if(t||i.isUnary){l(n._data);return}if(r===0){for(var o=0;o<n._data.length;o++)a(n._data[o],[o],n);return}var s=[];c(n._data);function c(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(t<r)for(var i=0;i<e.length;i++)s[t]=i,c(e[i],t+1);else for(var o=0;o<e.length;o++)s[t]=o,a(e[o],s.slice(),n)}function l(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(t<r)for(var n=0;n<e.length;n++)l(e[n],t+1);else for(var i=0;i<e.length;i++)a(e[i])}},r.prototype[Symbol.iterator]=function*(){var e=this._size.length-1;if(!(e<0)){if(e===0){for(var t=0;t<this._data.length;t++)yield{value:this._data[t],index:[t]};return}for(var n=Array(e+1).fill(0),r=this._size.reduce((e,t)=>e*t,1),i=0;i<r;i++){for(var a=this._data,o=0;o<e;o++)a=a[n[o]];yield{value:a[n[e]],index:n.slice()};for(var s=e;s>=0&&(n[s]++,!(n[s]<this._size[s]));s--)n[s]=0}}},r.prototype.rows=function(){var e=[];if(this.size().length!==2)throw TypeError(`Rows can only be returned for a 2D matrix.`);for(var t of this._data)e.push(new r([t],this._datatype));return e},r.prototype.columns=function(){var e=this,t=[],n=this.size();if(n.length!==2)throw TypeError(`Rows can only be returned for a 2D matrix.`);for(var i=this._data,a=function(n){var a=i.map(e=>[e[n]]);t.push(new r(a,e._datatype))},o=0;o<n[1];o++)a(o);return t},r.prototype.toArray=function(){return _i(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return Ys(this._data,e)},r.prototype.toString=function(){return Ys(this._data)},r.prototype.toJSON=function(){return{mathjs:`DenseMatrix`,data:this._data,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(e){if(e){if(Dr(e)&&(e=e.toNumber()),!Er(e)||!Li(e))throw TypeError(`The parameter k must be an integer number`)}else e=0;for(var t=e>0?e:0,n=e<0?-e:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),s=[],c=0;c<o;c++)s[c]=this._data[c+n][c+t];return new r({data:s,size:[o],datatype:this._datatype})},r.diagonal=function(e,t,n,i){if(!Nr(e))throw TypeError(`Array expected, size parameter`);if(e.length!==2)throw Error(`Only two dimensions matrix are supported`);if(e=e.map(function(e){if(Dr(e)&&(e=e.toNumber()),!Er(e)||!Li(e)||e<1)throw Error(`Size values must be positive integers`);return e}),n){if(Dr(n)&&(n=n.toNumber()),!Er(n)||!Li(n))throw TypeError(`The parameter k must be an integer number`)}else n=0;var a=n>0?n:0,o=n<0?-n:0,s=e[0],c=e[1],l=Math.min(s-o,c-a),u;if(Nr(t)){if(t.length!==l)throw Error(`Invalid value array length`);u=function(e){return t[e]}}else if(Pr(t)){var d=t.size();if(d.length!==1||d[0]!==l)throw Error(`Invalid matrix length`);u=function(e){return t.get([e])}}else u=function(){return t};i||=Dr(u(0))?u(0).mul(0):0;var f=[];if(e.length>0){f=dc(f,e,i);for(var p=0;p<l;p++)f[p+o][p+a]=u(p)}return new r({data:f,size:[s,c]})},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(e,t){if(!Er(e)||!Li(e)||!Er(t)||!Li(t))throw Error(`Row index must be positive integers`);if(this._size.length!==2)throw Error(`Only two dimensional matrix is supported`);return lc(e,this._size[0]),lc(t,this._size[0]),r._swapRows(e,t,this._data),this},r._swapRows=function(e,t,n){var r=n[e];n[e]=n[t],n[t]=r};function u(e){return Pr(e)?u(e.valueOf()):Nr(e)?e.map(u):e}return r},{isClass:!0}),qc=`clone`,Jc=J(qc,[`typed`],e=>{var{typed:t}=e;return t(qc,{any:_i})});function Yc(e){var t=e.length,n=e[0].length,r,i,a=[];for(i=0;i<n;i++){var o=[];for(r=0;r<t;r++)o.push(e[r][i]);a.push(o)}return a}function Xc(e){for(var t=0;t<e.length;t++)if(Fr(e[t]))return!0;return!1}function Zc(e,t){Pr(e)?e.forEach(e=>t(e),!1,!0):Rc(e,t,!0)}function Qc(e,t,n){if(!n)return Pr(e)?e.map(e=>t(e),!1,!0):Lc(e,t,!0);var r=e=>e===0?e:t(e);return Pr(e)?e.map(e=>r(e),!1,!0):Lc(e,r,!0)}function $c(e,t,n){var r=Array.isArray(e)?ac(e):e.size();if(t<0||t>=r.length)throw new ic(t,r.length);return Pr(e)?e.create(el(e.valueOf(),t,n),e.datatype()):el(e,t,n)}function el(e,t,n){var r,i,a,o;if(t<=0)if(Array.isArray(e[0])){for(o=Yc(e),i=[],r=0;r<o.length;r++)i[r]=el(o[r],t-1,n);return i}else{for(a=e[0],r=1;r<e.length;r++)a=n(a,e[r]);return a}else{for(i=[],r=0;r<e.length;r++)i[r]=el(e[r],t-1,n);return i}}function tl(e,t,n,r,i,a,o,s,c,l,u){var d=e._values,f=e._index,p=e._ptr,m,h,g,_;if(r)for(h=p[t],g=p[t+1],m=h;m<g;m++)_=f[m],n[_]===a?(r[_]=c?s(d[m],r[_]):s(r[_],d[m]),i[_]=a):(n[_]=a,o.push(_),l?(r[_]=c?s(d[m],u):s(u,d[m]),i[_]=a):r[_]=d[m]);else for(h=p[t],g=p[t+1],m=h;m<g;m++)_=f[m],n[_]===a?i[_]=a:(n[_]=a,o.push(_))}var nl=`isInteger`,rl=J(nl,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(nl,{number:e=>Number.isFinite(e)?n(e,Math.round(e)):!1,BigNumber:e=>e.isFinite()?n(e.round(),e):!1,bigint:e=>!0,Fraction:e=>e.d===1n,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),il=`number`,al=`number, number`;function ol(e){return Math.abs(e)}ol.signature=il;function sl(e,t){return e+t}sl.signature=al;function cl(e,t){return e-t}cl.signature=al;function ll(e,t){return e*t}ll.signature=al;function ul(e,t){return e/t}ul.signature=al;function dl(e){return-e}dl.signature=il;function fl(e){return e}fl.signature=il;function pl(e){return Ui(e)}pl.signature=il;function ml(e){return e*e*e}ml.signature=il;function hl(e){return Math.exp(e)}hl.signature=il;function gl(e){return Wi(e)}gl.signature=il;function _l(e,t){if(!Li(e)||!Li(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=e%t,e=t,t=n;return e<0?-e:e}_l.signature=al;function vl(e,t){if(!Li(e)||!Li(t))throw Error(`Parameters in function lcm must be integer numbers`);if(e===0||t===0)return 0;for(var n,r=e*t;t!==0;)n=t,t=e%n,e=n;return Math.abs(r/e)}vl.signature=al;function yl(e,t){return t?Math.log(e)/Math.log(t):Math.log(e)}function bl(e){return Vi(e)}bl.signature=il;function xl(e){return Bi(e)}xl.signature=il;function Sl(e){return Hi(e)}Sl.signature=il;function Cl(e,t){return t===0?e:e-t*Math.floor(e/t)}Cl.signature=al;function wl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,n=t<0;if(n&&(t=-t),t===0)throw Error(`Root must be non-zero`);if(e<0&&Math.abs(t)%2!=1)throw Error(`Root must be odd when a is negative.`);if(e===0)return n?1/0:0;if(!isFinite(e))return n?0:e;var r=Math.abs(e)**(1/t);return r=e<0?-r:r,n?1/r:r}function Tl(e){return zi(e)}Tl.signature=il;function El(e){return Math.sqrt(e)}El.signature=il;function Dl(e){return e*e}Dl.signature=il;function Ol(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!Li(e)||!Li(t))throw Error(`Parameters in function xgcd must be integer numbers`);for(;t;)r=Math.floor(e/t),i=e-r*t,n=a,a=o-r*a,o=n,n=s,s=c-r*s,c=n,e=t,t=i;return e<0?[-e,-o,-c]:[e,e?o:0,c]}Ol.signature=al;function kl(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}kl.signature=al;function Al(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!Li(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(Xi(e,t))}function jl(e){return Math.abs(e)}jl.signature=il;var Ml=`number`,Nl=`number, number`;function Pl(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function bitAnd`);return e&t}Pl.signature=Nl;function Fl(e){if(!Li(e))throw Error(`Integer expected in function bitNot`);return~e}Fl.signature=Ml;function Il(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function bitOr`);return e|t}Il.signature=Nl;function Ll(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function bitXor`);return e^t}Ll.signature=Nl;function Rl(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function leftShift`);return e<<t}Rl.signature=Nl;function zl(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function rightArithShift`);return e>>t}zl.signature=Nl;function Bl(e,t){if(!Li(e)||!Li(t))throw Error(`Integers expected in function rightLogShift`);return e>>>t}Bl.signature=Nl;function Vl(e,t){if(t<e)return 1;if(t===e)return t;var n=t+e>>1;return Vl(e,n)*Vl(n+1,t)}function Hl(e,t){if(!Li(e)||e<0||!Li(t)||t<0)throw TypeError(`Positive integer value expected in function combinations`);if(t>e)throw TypeError(`k must be less than or equal to n`);for(var n=e-t,r=1,i=t<n?n+1:t+1,a=2,o=t<n?t:n,s=i;s<=e;++s)for(r*=s;a<=o&&r%a===0;)r/=a,++a;return a<=o&&(r/=Vl(a,o)),r}Hl.signature=`number, number`;var Ul=Math.PI,Wl=2*Math.PI,Gl=Math.E,Kl=1.618033988749895,ql=`number`,Jl=`number, number`;function Yl(e){return!e}Yl.signature=ql;function Xl(e,t){return!!(e||t)}Xl.signature=Jl;function Zl(e,t){return!!e!=!!t}Zl.signature=Jl;function Ql(e,t){return!!(e&&t)}Ql.signature=Jl;function $l(e){var t;if(Li(e))return e<=0?Number.isFinite(e)?1/0:NaN:e>171?1/0:Vl(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*$l(1-e));if(e>=171.35)return 1/0;if(e>85){var n=e*e,r=n*e,i=r*e,a=i*e;return Math.sqrt(2*Math.PI/e)*(e/Math.E)**+e*(1+1/(12*e)+1/(288*n)-139/(51840*r)-571/(2488320*i)+163879/(209018880*a)+5246819/(75246796800*a*e))}--e,t=tu[0];for(var o=1;o<tu.length;++o)t+=tu[o]/(e+o);var s=e+eu+.5;return Math.sqrt(2*Math.PI)*s**+(e+.5)*Math.exp(-s)*t}$l.signature=`number`;var eu=4.7421875,tu=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],nu=.9189385332046728,ru=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function iu(e){if(e<0)return NaN;if(e===0)return 1/0;if(!Number.isFinite(e))return e;if(e<.5)return Math.log(Math.PI/Math.sin(Math.PI*e))-iu(1-e);--e;for(var t=e+5+.5,n=ru[0],r=6;r>=1;r--)n+=ru[r]/(e+r);return nu+(e+.5)*Math.log(t)-t+Math.log(n)}iu.signature=`number`;var au=`number`,ou=`number, number`;function su(e){return Math.acos(e)}su.signature=au;function cu(e){return ra(e)}cu.signature=au;function lu(e){return Math.atan(1/e)}lu.signature=au;function uu(e){return Number.isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}uu.signature=au;function du(e){return Math.asin(1/e)}du.signature=au;function fu(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}fu.signature=au;function pu(e){return Math.acos(1/e)}pu.signature=au;function mu(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}mu.signature=au;function hu(e){return Math.asin(e)}hu.signature=au;function gu(e){return ia(e)}gu.signature=au;function _u(e){return Math.atan(e)}_u.signature=au;function vu(e,t){return Math.atan2(e,t)}vu.signature=ou;function yu(e){return aa(e)}yu.signature=au;function bu(e){return Math.cos(e)}bu.signature=au;function xu(e){return oa(e)}xu.signature=au;function Su(e){return 1/Math.tan(e)}Su.signature=au;function Cu(e){var t=Math.exp(2*e);return(t+1)/(t-1)}Cu.signature=au;function wu(e){return 1/Math.sin(e)}wu.signature=au;function Tu(e){return e===0?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*zi(e)}Tu.signature=au;function Eu(e){return 1/Math.cos(e)}Eu.signature=au;function Du(e){return 2/(Math.exp(e)+Math.exp(-e))}Du.signature=au;function Ou(e){return Math.sin(e)}Ou.signature=au;function ku(e){return sa(e)}ku.signature=au;function Au(e){return Math.tan(e)}Au.signature=au;function ju(e){return ca(e)}ju.signature=au;var Mu=`number`;function Nu(e){return Li(e)}Nu.signature=Mu;function Pu(e){return e<0}Pu.signature=Mu;function Fu(e){return e>0}Fu.signature=Mu;function Iu(e){return e===0}Iu.signature=Mu;function Lu(e){return Number.isNaN(e)}Lu.signature=Mu;function Ru(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e-9,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;if(n<=0)throw Error(`Relative tolerance must be greater than 0`);if(r<0)throw Error(`Absolute tolerance must be at least 0`);return e.isNaN()||t.isNaN()?!1:!e.isFinite()||!t.isFinite()?e.eq(t):e.eq(t)?!0:e.minus(t).abs().lte(e.constructor.max(e.constructor.max(e.abs(),t.abs()).mul(n),r))}var zu=`isNegative`,Bu=J(zu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(zu,{number:e=>na(e,0,n.relTol,n.absTol)?!1:Pu(e),BigNumber:e=>Ru(e,new e.constructor(0),n.relTol,n.absTol)?!1:e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e<0n,Fraction:e=>e.s<0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Vu=`isNumeric`,Hu=J(Vu,[`typed`],e=>{var{typed:t}=e;return t(Vu,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Uu=`hasNumericValue`,Wu=J(Uu,[`typed`,`isNumeric`],e=>{var{typed:t,isNumeric:n}=e;return t(Uu,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),Gu=`isPositive`,Ku=J(Gu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Gu,{number:e=>na(e,0,n.relTol,n.absTol)?!1:Fu(e),BigNumber:e=>Ru(e,new e.constructor(0),n.relTol,n.absTol)?!1:!e.isNeg()&&!e.isZero()&&!e.isNaN(),bigint:e=>e>0n,Fraction:e=>e.s>0n&&e.n>0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),qu=`isZero`,Ju=J(qu,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(qu,{"number | BigNumber | Complex | Fraction":e=>n(e,0),bigint:e=>e===0n,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Yu=`isNaN`,Xu=J(Yu,[`typed`],e=>{var{typed:t}=e;return t(Yu,{number:Lu,BigNumber:function(e){return e.isNaN()},bigint:function(e){return!1},Fraction:function(e){return!1},Complex:function(e){return e.isNaN()},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Zu=`isBounded`,Qu=J(Zu,[`typed`],e=>{var{typed:t}=e;return t(Zu,{number:e=>Number.isFinite(e),"BigNumber | Complex":e=>e.isFinite(),"bigint | Fraction":()=>!0,"null | undefined":()=>!1,Unit:t.referToSelf(e=>t=>e(t.value)),"Array | Matrix":t.referToSelf(e=>t=>(Array.isArray(t)||(t=t.valueOf()),t.every(t=>e(t))))})}),$u=`isFinite`,ed=J($u,[`typed`,`isBounded`,`map`],e=>{var{typed:t,isBounded:n,map:r}=e;return t($u,{"Array | Matrix":e=>r(e,n),any:e=>n(e)})}),td=`typeOf`,nd=J(td,[`typed`],e=>{var{typed:t}=e;return t(td,{any:gi})});function rd(e,t,n,r){return na(e.re,t.re,n,r)&&na(e.im,t.im,n,r)}var id=J(`compareUnits`,[`typed`],e=>{var{typed:t}=e;return{"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(!n.equalBase(r))throw Error(`Cannot compare units with different base`);return t.find(e,[n.valueType(),r.valueType()])(n.value,r.value)})}}),ad=`equalScalar`,od=J(ad,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(ad,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return na(e,t,n.relTol,n.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||Ru(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e===t},"Fraction, Fraction":function(e,t){return e.equals(t)},"Complex, Complex":function(e,t){return rd(e,t,n.relTol,n.absTol)}},id({typed:t}))});J(ad,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(ad,{"number, number":function(e,t){return na(e,t,n.relTol,n.absTol)}})});var sd=J(`SparseMatrix`,[`typed`,`equalScalar`,`Matrix`],e=>{var{typed:t,equalScalar:n,Matrix:r}=e;function i(e,t){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!Mr(t))throw Error(`Invalid datatype: `+t);if(Pr(e))a(this,e,t);else if(e&&Nr(e.index)&&Nr(e.ptr)&&Nr(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(Nr(e))o(this,e,t);else if(e)throw TypeError(`Unsupported type of data (`+gi(e)+`)`);else this._values=[],this._index=[],this._ptr=[0],this._size=[0,0],this._datatype=t}function a(e,t,n){t.type===`SparseMatrix`?(e._values=t._values?_i(t._values):void 0,e._index=_i(t._index),e._ptr=_i(t._ptr),e._size=_i(t._size),e._datatype=n||t._datatype):o(e,t.valueOf(),n||t._datatype)}function o(e,r,i){e._values=[],e._index=[],e._ptr=[],e._datatype=i;var a=r.length,o=0,s=n,c=0;if(Mr(i)&&(s=t.find(n,[i,i])||n,c=t.convert(0,i)),a>0){var l=0;do{e._ptr.push(e._index.length);for(var u=0;u<a;u++){var d=r[u];if(Nr(d)){if(l===0&&o<d.length&&(o=d.length),l<d.length){var f=d[l];s(f,c)||(e._values.push(f),e._index.push(u))}}else l===0&&o<1&&(o=1),s(d,c)||(e._values.push(d),e._index.push(u))}l++}while(l<o)}for(;e._ptr.length<=o;)e._ptr.push(e._index.length);e._size=[a,o]}i.prototype=new r,i.prototype.createSparseMatrix=function(e,t){return new i(e,t)},Object.defineProperty(i,`name`,{value:`SparseMatrix`}),i.prototype.constructor=i,i.prototype.type=`SparseMatrix`,i.prototype.isSparseMatrix=!0,i.prototype.getDataType=function(){return kc(this._values,gi)},i.prototype.storage=function(){return`sparse`},i.prototype.datatype=function(){return this._datatype},i.prototype.create=function(e,t){return new i(e,t)},i.prototype.density=function(){var e=this._size[0],t=this._size[1];return e!==0&&t!==0?this._index.length/(e*t):0},i.prototype.subset=function(e,t,n){if(!this._values)throw Error(`Cannot invoke subset on a Pattern only matrix`);switch(arguments.length){case 1:return s(this,e);case 2:case 3:return c(this,e,t,n);default:throw SyntaxError(`Wrong number of arguments`)}};function s(e,t){if(!zr(t))throw TypeError(`Invalid index`);if(t.isScalar())return e.get(t.min());var n=t.size();if(n.length!==e._size.length)throw new rc(n.length,e._size.length);var r,a,o,s,c=t.min(),l=t.max();for(r=0,a=e._size.length;r<a;r++)lc(c[r],e._size[r]),lc(l[r],e._size[r]);var u=e._values,d=e._index,f=e._ptr,p=t.dimension(0),m=t.dimension(1),h=[],g=[];function _(e,t){g[e]=t[0],h[e]=!0}Number.isInteger(p)?_(p,[0]):p.forEach(_);var v=u?[]:void 0,y=[],b=[];function x(e){for(b.push(y.length),o=f[e],s=f[e+1];o<s;o++)r=d[o],h[r]===!0&&(y.push(g[r]),v&&v.push(u[o]))}return Number.isInteger(m)?x(m):m.forEach(x),b.push(y.length),new i({values:v,index:y,ptr:b,size:n,datatype:e._datatype})}function c(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Invalid index`);var i=t.size(),a=t.isScalar(),o;if(Pr(n)?(o=n.size(),n=n.toArray()):o=ac(n),a){if(o.length!==0)throw TypeError(`Scalar expected`);e.set(t.min(),n,r)}else{if(i.length!==1&&i.length!==2)throw new rc(i.length,e._size.length,`<`);if(o.length<i.length){for(var s=0,c=0;i[s]===1&&o[s]===1;)s++;for(;i[s]===1;)c++,s++;n=yc(n,i.length,c,o)}if(!xi(i,o))throw new rc(i,o,`>`);if(i.length===1)d(t.dimension(0),(t,i)=>{lc(t),e.set([t,0],n[i[0]],r)});else{var l=t.dimension(0),u=t.dimension(1);d(l,(t,i)=>{lc(t),d(u,(a,o)=>{lc(a),e.set([t,a],n[i[0]][o[0]],r)})})}}return e;function d(e,t){Er(e)?t(e,[0]):e.forEach(t)}}i.prototype.get=function(e){if(!Nr(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new rc(e.length,this._size.length);if(!this._values)throw Error(`Cannot invoke get on a Pattern only matrix`);var t=e[0],n=e[1];lc(t,this._size[0]),lc(n,this._size[1]);var r=l(t,this._ptr[n],this._ptr[n+1],this._index);return r<this._ptr[n+1]&&this._index[r]===t?this._values[r]:0},i.prototype.set=function(e,r,i){if(!Nr(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new rc(e.length,this._size.length);if(!this._values)throw Error(`Cannot invoke set on a Pattern only matrix`);var a=e[0],o=e[1],s=this._size[0],c=this._size[1],p=n,m=0;Mr(this._datatype)&&(p=t.find(n,[this._datatype,this._datatype])||n,m=t.convert(0,this._datatype)),(a>s-1||o>c-1)&&(f(this,Math.max(a+1,s),Math.max(o+1,c),i),s=this._size[0],c=this._size[1]),lc(a,s),lc(o,c);var h=l(a,this._ptr[o],this._ptr[o+1],this._index);return h<this._ptr[o+1]&&this._index[h]===a?p(r,m)?u(h,o,this._values,this._index,this._ptr):this._values[h]=r:p(r,m)||d(h,a,o,r,this._values,this._index,this._ptr),this};function l(e,t,n,r){if(n-t===0)return n;for(var i=t;i<n;i++)if(r[i]===e)return i;return t}function u(e,t,n,r,i){n.splice(e,1),r.splice(e,1);for(var a=t+1;a<i.length;a++)i[a]--}function d(e,t,n,r,i,a,o){i.splice(e,0,r),a.splice(e,0,t);for(var s=n+1;s<o.length;s++)o[s]++}i.prototype.resize=function(e,t,n){if(!Fr(e))throw TypeError(`Array or Matrix expected`);var r=e.valueOf().map(e=>Array.isArray(e)&&e.length===1?e[0]:e);if(r.length!==2)throw Error(`Only two dimensions matrix are supported`);return r.forEach(function(e){if(!Er(e)||!Li(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+Ys(r)+`)`)}),f(n?this.clone():this,r[0],r[1],t)};function f(e,r,i,a){var o=a||0,s=n,c=0;Mr(e._datatype)&&(s=t.find(n,[e._datatype,e._datatype])||n,c=t.convert(0,e._datatype),o=t.convert(o,e._datatype));var l=!s(o,c),u=e._size[0],d=e._size[1],f,p,m;if(i>d){for(p=d;p<i;p++)if(e._ptr[p]=e._values.length,l)for(f=0;f<u;f++)e._values.push(o),e._index.push(f);e._ptr[i]=e._values.length}else i<d&&(e._ptr.splice(i+1,d-i),e._values.splice(e._ptr[i],e._values.length),e._index.splice(e._ptr[i],e._index.length));if(d=i,r>u){if(l){var h=0;for(p=0;p<d;p++){e._ptr[p]=e._ptr[p]+h,m=e._ptr[p+1]+h;var g=0;for(f=u;f<r;f++,g++)e._values.splice(m+g,0,o),e._index.splice(m+g,0,f),h++}e._ptr[d]=e._values.length}}else if(r<u){var _=0;for(p=0;p<d;p++){e._ptr[p]=e._ptr[p]-_;var v=e._ptr[p],y=e._ptr[p+1]-_;for(m=v;m<y;m++)f=e._index[m],f>r-1&&(e._values.splice(m,1),e._index.splice(m,1),_++)}e._ptr[p]=e._values.length}return e._size[0]=r,e._size[1]=i,e}i.prototype.reshape=function(e,t){if(!Nr(e))throw TypeError(`Array expected`);if(e.length!==2)throw Error(`Sparse matrices can only be reshaped in two dimensions`);e.forEach(function(t){if(!Er(t)||!Li(t)||t<=-2||t===0)throw TypeError(`Invalid size, must contain positive integers or -1 (size: `+Ys(e)+`)`)});var n=this._size[0]*this._size[1];if(e=mc(e,n),n!==e[0]*e[1])throw Error(`Reshaping sparse matrix will result in the wrong number of elements`);var r=t?this.clone():this;if(this._size[0]===e[0]&&this._size[1]===e[1])return r;for(var i=[],a=0;a<r._ptr.length;a++)for(var o=0;o<r._ptr[a+1]-r._ptr[a];o++)i.push(a);for(var s=r._values.slice(),c=r._index.slice(),u=0;u<r._index.length;u++){var f=c[u],p=i[u],m=f*r._size[1]+p;i[u]=m%e[1],c[u]=Math.floor(m/e[1])}r._values.length=0,r._index.length=0,r._ptr.length=e[1]+1,r._size=e.slice();for(var h=0;h<r._ptr.length;h++)r._ptr[h]=0;for(var g=0;g<s.length;g++){var _=c[g],v=i[g],y=s[g];d(l(_,r._ptr[v],r._ptr[v+1],r._index),_,v,y,r._values,r._index,r._ptr)}return r},i.prototype.clone=function(){return new i({values:this._values?_i(this._values):void 0,index:_i(this._index),ptr:_i(this._ptr),size:_i(this._size),datatype:this._datatype})},i.prototype.size=function(){return this._size.slice(0)},i.prototype.map=function(e,t){if(!this._values)throw Error(`Cannot invoke map on a Pattern only matrix`);var n=this,r=this._size[0],i=this._size[1],a=Bc(e,n,`map`);return p(this,0,r-1,0,i-1,function(e,t,r){return a.fn(e,[t,r],n)},t)};function p(e,r,a,o,s,c,l){var u=[],d=[],f=[],p=n,m=0;Mr(e._datatype)&&(p=t.find(n,[e._datatype,e._datatype])||n,m=t.convert(0,e._datatype));for(var h=function(e,t,n){var r=c(e,t,n);p(r,m)||(u.push(r),d.push(t))},g=o;g<=s;g++){f.push(u.length);var _=e._ptr[g],v=e._ptr[g+1];if(l)for(var y=_;y<v;y++){var b=e._index[y];b>=r&&b<=a&&h(e._values[y],b-r,g-o)}else{for(var x={},S=_;S<v;S++){var C=e._index[S];x[C]=e._values[S]}for(var w=r;w<=a;w++)h(w in x?x[w]:0,w-r,g-o)}}return f.push(u.length),new i({values:u,index:d,ptr:f,size:[a-r+1,s-o+1]})}i.prototype.forEach=function(e,t){if(!this._values)throw Error(`Cannot invoke forEach on a Pattern only matrix`);for(var n=this,r=this._size[0],i=this._size[1],a=Bc(e,n,`forEach`),o=0;o<i;o++){var s=this._ptr[o],c=this._ptr[o+1];if(t)for(var l=s;l<c;l++){var u=this._index[l];a.fn(this._values[l],[u,o],n)}else{for(var d={},f=s;f<c;f++){var p=this._index[f];d[p]=this._values[f]}for(var m=0;m<r;m++){var h=m in d?d[m]:0;a.fn(h,[m,o],n)}}}},i.prototype[Symbol.iterator]=function*(){if(!this._values)throw Error(`Cannot iterate a Pattern only matrix`);for(var e=this._size[1],t=0;t<e;t++)for(var n=this._ptr[t],r=this._ptr[t+1],i=n;i<r;i++){var a=this._index[i];yield{value:this._values[i],index:[a,t]}}},i.prototype.toArray=function(){return m(this._values,this._index,this._ptr,this._size,!0)},i.prototype.valueOf=function(){return m(this._values,this._index,this._ptr,this._size,!1)};function m(e,t,n,r,i){var a=r[0],o=r[1],s=[],c,l;for(c=0;c<a;c++)for(s[c]=[],l=0;l<o;l++)s[c][l]=0;for(l=0;l<o;l++)for(var u=n[l],d=n[l+1],f=u;f<d;f++)c=t[f],s[c][l]=e?i?_i(e[f]):e[f]:1;return s}return i.prototype.format=function(e){for(var t=this._size[0],n=this._size[1],r=this.density(),i=`Sparse Matrix [`+Ys(t,e)+` x `+Ys(n,e)+`] density: `+Ys(r,e)+`
|
|
4
4
|
`,a=0;a<n;a++)for(var o=this._ptr[a],s=this._ptr[a+1],c=o;c<s;c++){var l=this._index[c];i+=`
|
|
5
5
|
(`+Ys(l,e)+`, `+Ys(a,e)+`) ==> `+(this._values?Ys(this._values[c],e):`X`)}return i},i.prototype.toString=function(){return Ys(this.toArray())},i.prototype.toJSON=function(){return{mathjs:`SparseMatrix`,values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},i.prototype.diagonal=function(e){if(e){if(Dr(e)&&(e=e.toNumber()),!Er(e)||!Li(e))throw TypeError(`The parameter k must be an integer number`)}else e=0;var t=e>0?e:0,n=e<0?-e:0,r=this._size[0],a=this._size[1],o=Math.min(r-n,a-t),s=[],c=[],l=[];l[0]=0;for(var u=t;u<a&&s.length<o;u++)for(var d=this._ptr[u],f=this._ptr[u+1],p=d;p<f;p++){var m=this._index[p];if(m===u-t+n){s.push(this._values[p]),c[s.length-1]=m-n;break}}return l.push(s.length),new i({values:s,index:c,ptr:l,size:[o,1]})},i.fromJSON=function(e){return new i(e)},i.diagonal=function(e,r,a,o,s){if(!Nr(e))throw TypeError(`Array expected, size parameter`);if(e.length!==2)throw Error(`Only two dimensions matrix are supported`);if(e=e.map(function(e){if(Dr(e)&&(e=e.toNumber()),!Er(e)||!Li(e)||e<1)throw Error(`Size values must be positive integers`);return e}),a){if(Dr(a)&&(a=a.toNumber()),!Er(a)||!Li(a))throw TypeError(`The parameter k must be an integer number`)}else a=0;var c=n,l=0;Mr(s)&&(c=t.find(n,[s,s])||n,l=t.convert(0,s));var u=a>0?a:0,d=a<0?-a:0,f=e[0],p=e[1],m=Math.min(f-d,p-u),h;if(Nr(r)){if(r.length!==m)throw Error(`Invalid value array length`);h=function(e){return r[e]}}else if(Pr(r)){var g=r.size();if(g.length!==1||g[0]!==m)throw Error(`Invalid matrix length`);h=function(e){return r.get([e])}}else h=function(){return r};for(var _=[],v=[],y=[],b=0;b<p;b++){y.push(_.length);var x=b-u;if(x>=0&&x<m){var S=h(x);c(S,l)||(v.push(x+d),_.push(S))}}return y.push(_.length),new i({values:_,index:v,ptr:y,size:[f,p]})},i.prototype.swapRows=function(e,t){if(!Er(e)||!Li(e)||!Er(t)||!Li(t))throw Error(`Row index must be positive integers`);if(this._size.length!==2)throw Error(`Only two dimensional matrix is supported`);return lc(e,this._size[0]),lc(t,this._size[0]),i._swapRows(e,t,this._size[1],this._values,this._index,this._ptr),this},i._forEachRow=function(e,t,n,r,i){for(var a=r[e],o=r[e+1],s=a;s<o;s++)i(n[s],t[s])},i._swapRows=function(e,t,n,r,i,a){for(var o=0;o<n;o++){var s=a[o],c=a[o+1],u=l(e,s,c,i),d=l(t,s,c,i);if(u<c&&d<c&&i[u]===e&&i[d]===t){if(r){var f=r[u];r[u]=r[d],r[d]=f}continue}if(u<c&&i[u]===e&&(d>=c||i[d]!==t)){var p=r?r[u]:void 0;i.splice(d,0,t),r&&r.splice(d,0,p),i.splice(d<=u?u+1:u,1),r&&r.splice(d<=u?u+1:u,1);continue}if(d<c&&i[d]===t&&(u>=c||i[u]!==e)){var m=r?r[d]:void 0;i.splice(u,0,e),r&&r.splice(u,0,m),i.splice(u<=d?d+1:d,1),r&&r.splice(u<=d?d+1:d,1)}}},i},{isClass:!0}),cd=`number`,ld=[`typed`];function ud(e){var t=e.match(/(0[box])([0-9a-fA-F]*)\.([0-9a-fA-F]*)/);return t?{input:e,radix:{"0b":2,"0o":8,"0x":16}[t[1]],integerPart:t[2],fractionalPart:t[3]}:null}function dd(e){for(var t=parseInt(e.integerPart,e.radix),n=0,r=0;r<e.fractionalPart.length;r++){var i=parseInt(e.fractionalPart[r],e.radix);n+=i/e.radix**+(r+1)}var a=t+n;if(isNaN(a))throw SyntaxError(`String "`+e.input+`" is not a valid number`);return a}var fd=J(cd,ld,e=>{var{typed:t}=e,n=t(`number`,{"":function(){return 0},number:function(e){return e},string:function(e){if(e===`NaN`)return NaN;var t=ud(e);if(t)return dd(t);var n=0,r=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);r&&(n=Number(r[2]),e=r[1]);var i=Number(e);if(isNaN(i))throw SyntaxError(`String "`+e+`" is not a valid number`);if(r){if(i>2**n-1)throw SyntaxError(`String "${e}" is out of range`);i>=2**(n-1)&&(i-=2**n)}return i},BigNumber:function(e){return e.toNumber()},bigint:function(e){return Number(e)},Fraction:function(e){return e.valueOf()},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),null:function(e){return 0},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),pd=J(`bigint`,[`typed`],e=>{var{typed:t}=e,n=t(`bigint`,{"":function(){return 0n},bigint:function(e){return e},number:function(e){return BigInt(e.toFixed())},BigNumber:function(e){return BigInt(e.round().toString())},Fraction:function(e){return BigInt(e.valueOf().toFixed())},"string | boolean":function(e){return BigInt(e)},null:function(e){return 0n},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))});return n.fromJSON=function(e){return BigInt(e.value)},n}),md=`string`,hd=J(md,[`typed`],e=>{var{typed:t}=e;return t(md,{"":function(){return``},number:Ki,null:function(e){return`null`},boolean:function(e){return e+``},string:function(e){return e},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e)),any:function(e){return String(e)}})}),gd=`boolean`,_d=J(gd,[`typed`],e=>{var{typed:t}=e;return t(gd,{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},null:function(e){return!1},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1;var n=Number(e);if(e!==``&&!isNaN(n))return!!n;throw Error(`Cannot convert "`+e+`" to a boolean`)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),vd=J(`bignumber`,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(`bignumber`,{"":function(){return new n(0)},number:function(e){return new n(e+``)},string:function(e){var t=e.match(/(0[box][0-9a-fA-F]*)i([0-9]*)/);if(t){var r=t[2],i=n(t[1]),a=new n(2).pow(Number(r));if(i.gt(a.sub(1)))throw SyntaxError(`String "${e}" is out of range`);var o=new n(2).pow(Number(r)-1);return i.gte(o)?i.sub(a):i}return new n(e)},BigNumber:function(e){return e},bigint:function(e){return new n(e.toString())},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Fraction:function(e){return new n(String(e.n)).div(String(e.d)).times(String(e.s))},null:function(e){return new n(0)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),yd=J(`complex`,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(`complex`,{"":function(){return n.ZERO},number:function(e){return new n(e,0)},"number, number":function(e,t){return new n(e,t)},"BigNumber, BigNumber":function(e,t){return new n(e.toNumber(),t.toNumber())},Fraction:function(e){return new n(e.valueOf(),0)},Complex:function(e){return e.clone()},string:function(e){return n(e)},null:function(e){return n(0)},Object:function(e){if(`re`in e&&`im`in e)return new n(e.re,e.im);if(`r`in e&&`phi`in e||`abs`in e&&`arg`in e)return new n(e);throw Error(`Expected object with properties (re and im) or (r and phi) or (abs and arg)`)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),bd=J(`fraction`,[`typed`,`Fraction`],e=>{var{typed:t,Fraction:n}=e;return t(`fraction`,{number:function(e){if(!Number.isFinite(e)||isNaN(e))throw Error(e+` cannot be represented as a fraction`);return new n(e)},string:function(e){return new n(e)},"number, number":function(e,t){return new n(e,t)},"bigint, bigint":function(e,t){return new n(e,t)},null:function(e){return new n(0)},BigNumber:function(e){return new n(e.toString())},bigint:function(e){return new n(e.toString())},Fraction:function(e){return e},Unit:t.referToSelf(e=>t=>{var n=t.clone();return n.value=e(t.value),n}),Object:function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),xd=`matrix`,Sd=J(xd,[`typed`,`Matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(xd,{"":function(){return a([])},string:function(e){return a([],e)},"string, string":function(e,t){return a([],e,t)},Array:function(e){return a(e)},Matrix:function(e){return a(e,e.storage())},"Array | Matrix, string":a,"Array | Matrix, string, string":a});function a(e,t,n){if(t===`dense`||t===`default`||t===void 0)return new r(e,n);if(t===`sparse`)return new i(e,n);throw TypeError(`Unknown matrix type `+JSON.stringify(t)+`.`)}}),Cd=`matrixFromFunction`,wd=J(Cd,[`typed`,`matrix`,`isZero`],e=>{var{typed:t,matrix:n,isZero:r}=e;return t(Cd,{"Array | Matrix, function, string, string":function(e,t,n,r){return i(e,t,n,r)},"Array | Matrix, function, string":function(e,t,n){return i(e,t,n)},"Matrix, function":function(e,t){return i(e,t,`dense`)},"Array, function":function(e,t){return i(e,t,`dense`).toArray()},"Array | Matrix, string, function":function(e,t,n){return i(e,n,t)},"Array | Matrix, string, string, function":function(e,t,n,r){return i(e,r,t,n)}});function i(e,t,i,a){var o=a===void 0?n(i):n(i,a);return o.resize(e),o.forEach(function(e,n){var i=t(n);r(i)||o.set(n,i)}),o}}),Td=`matrixFromRows`,Ed=J(Td,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(Td,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one row is needed to construct a matrix.`);var t=o(e[0]),n=[];for(var i of e){var a=o(i);if(a!==t)throw TypeError(`The vectors had different length: `+(t|0)+` ≠ `+(a|0));n.push(r(i))}return n}function o(e){var t=i(e);if(t.length===1)return t[0];if(t.length===2){if(t[0]===1)return t[1];if(t[1]===1)return t[0];throw TypeError(`At least one of the arguments is not a vector.`)}else throw TypeError(`Only one- or two-dimensional vectors are supported.`)}}),Dd=`matrixFromColumns`,Od=J(Dd,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(Dd,{"...Array":function(e){return a(e)},"...Matrix":function(e){return n(a(e.map(e=>e.toArray())))}});function a(e){if(e.length===0)throw TypeError(`At least one column is needed to construct a matrix.`);for(var t=o(e[0]),n=[],i=0;i<t;i++)n[i]=[];for(var a of e){var s=o(a);if(s!==t)throw TypeError(`The vectors had different length: `+(t|0)+` ≠ `+(s|0));for(var c=r(a),l=0;l<t;l++)n[l].push(c[l])}return n}function o(e){var t=i(e);if(t.length===1)return t[0];if(t.length===2){if(t[0]===1)return t[1];if(t[1]===1)return t[0];throw TypeError(`At least one of the arguments is not a vector.`)}else throw TypeError(`Only one- or two-dimensional vectors are supported.`)}}),kd=`splitUnit`,Ad=J(kd,[`typed`],e=>{var{typed:t}=e;return t(kd,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),jd=`unaryMinus`,Md=J(jd,[`typed`],e=>{var{typed:t}=e;return t(jd,{number:dl,"Complex | BigNumber | Fraction":e=>e.neg(),bigint:e=>-e,Unit:t.referToSelf(e=>n=>{var r=n.clone();return r.value=t.find(e,r.valueType())(n.value),r}),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0))})}),Nd=`unaryPlus`,Pd=J(Nd,[`typed`,`config`,`numeric`],e=>{var{typed:t,config:n,numeric:r}=e;return t(Nd,{number:fl,Complex:function(e){return e},BigNumber:function(e){return e},bigint:function(e){return e},Fraction:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),boolean:function(e){return r(+!!e,n.number)},string:function(e){return r(e,Ri(e,n))}})}),Fd=`abs`,Id=J(Fd,[`typed`],e=>{var{typed:t}=e;return t(Fd,{number:ol,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0))})}),Ld=`mapSlices`,Rd=J(Ld,[`typed`,`isInteger`],e=>{var{typed:t,isInteger:n}=e;return t(Ld,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw TypeError(`Integer number expected for dimension`);var i=Array.isArray(e)?ac(e):e.size();if(t<0||t>=i.length)throw new ic(t,i.length);return Pr(e)?e.create(zd(e.valueOf(),t,r),e.datatype()):zd(e,t,r)}})},{formerly:`apply`});function zd(e,t,n){var r,i,a;if(t<=0)if(Array.isArray(e[0])){for(a=Bd(e),i=[],r=0;r<a.length;r++)i[r]=zd(a[r],t-1,n);return i}else return n(e);else{for(i=[],r=0;r<e.length;r++)i[r]=zd(e[r],t-1,n);return i}}function Bd(e){var t=e.length,n=e[0].length,r,i,a=[];for(i=0;i<n;i++){var o=[];for(r=0;r<t;r++)o.push(e[r][i]);a.push(o)}return a}var Vd=`addScalar`,Hd=J(Vd,[`typed`],e=>{var{typed:t}=e;return t(Vd,{"number, number":sl,"Complex, Complex":function(e,t){return e.add(t)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"bigint, bigint":function(e,t){return e+t},"Fraction, Fraction":function(e,t){return e.add(t)},"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),Ud=`subtractScalar`,Wd=J(Ud,[`typed`],e=>{var{typed:t}=e;return t(Ud,{"number, number":cl,"Complex, Complex":function(e,t){return e.sub(t)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"bigint, bigint":function(e,t){return e-t},"Fraction, Fraction":function(e,t){return e.sub(t)},"Unit, Unit":t.referToSelf(e=>(n,r)=>{if(n.value===null||n.value===void 0)throw Error(`Parameter x contains a unit with undefined value`);if(r.value===null||r.value===void 0)throw Error(`Parameter y contains a unit with undefined value`);if(!n.equalBase(r))throw Error(`Units do not match`);var i=n.clone();return i.value=t.find(e,[i.valueType(),r.valueType()])(i.value,r.value),i.fixPrefix=!1,i})})}),Gd=`cbrt`,Kd=J(Gd,[`config`,`typed`,`isNegative`,`unaryMinus`,`matrix`,`Complex`,`BigNumber`,`Fraction`],e=>{var{config:t,typed:n,isNegative:r,unaryMinus:i,matrix:a,Complex:o,BigNumber:s,Fraction:c}=e;return n(Gd,{number:pl,Complex:l,"Complex, boolean":l,BigNumber:function(e){return e.cbrt()},Unit:u});function l(e,n){var r=e.arg()/3,i=e.abs(),s=new o(pl(i),0).mul(new o(0,r).exp());if(n){var c=[s,new o(pl(i),0).mul(new o(0,r+Math.PI*2/3).exp()),new o(pl(i),0).mul(new o(0,r-Math.PI*2/3).exp())];return t.matrix===`Array`?c:a(c)}else return s}function u(e){if(e.value&&kr(e.value)){var t=e.clone();return t.value=1,t=t.pow(1/3),t.value=l(e.value),t}else{var n=r(e.value);n&&(e.value=i(e.value));var a=Dr(e.value)?new s(1).div(3):Ar(e.value)?new c(1,3):1/3,o=e.pow(a);return n&&(o.value=i(o.value)),o}}}),qd=J(`matAlgo11xS0s`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=n,h=0,g=i;typeof u==`string`&&(p=u,m=t.find(n,[p,p]),h=t.convert(0,p),r=t.convert(r,p),g=t.find(i,[p,p]));for(var _=[],v=[],y=[],b=0;b<f;b++){y[b]=v.length;for(var x=c[b],S=c[b+1],C=x;C<S;C++){var w=s[C],T=a?g(r,o[C]):g(o[C],r);m(T,h)||(v.push(w),_.push(T))}}return y[f]=v.length,e.createSparseMatrix({values:_,index:v,ptr:y,size:[d,f],datatype:p})}}),Jd=J(`matAlgo12xSfs`,[`typed`,`DenseMatrix`],e=>{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;v<f;v++){for(var y=v+1,b=c[v],x=c[v+1],S=b;S<x;S++){var C=s[S];g[C]=o[S],_[C]=y}for(var w=0;w<d;w++)v===0&&(h[w]=[]),_[w]===y?h[w][v]=a?m(r,g[w]):m(g[w],r):h[w][v]=a?m(r,0):m(0,r)}return new n({data:h,size:[d,f],datatype:p})}}),Yd=J(`matAlgo14xDs`,[`typed`],e=>{var{typed:t}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype,l,u=i;typeof c==`string`&&(l=c,r=t.convert(r,l),u=t.find(i,[l,l]));var d=s.length>0?n(u,0,s,s[0],o,r,a):[];return e.createDenseMatrix({data:d,size:_i(s),datatype:l})};function n(e,t,r,i,a,o,s){var c=[];if(t===r.length-1)for(var l=0;l<i;l++)c[l]=s?e(o,a[l]):e(a[l],o);else for(var u=0;u<i;u++)c[u]=n(e,t+1,r,r[t+1],a[u],o,s);return c}}),Xd=`ceil`,Zd=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],Qd=new os(10),$d=J(Xd,[`typed`,`config`,`round`],e=>{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.ceil(e),i=r(e);return t===i?t:na(e,i,n.relTol,n.absTol)&&!na(e,t,n.relTol,n.absTol)?i:t}return t(Xd,{number:i,"number, number":function(e,t){if(!Li(t))throw RangeError(`number of decimals in function ceil must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in ceil number must be in range 0-15`);var n=10**t;return i(e*n)/n}})}),ef=J(Xd,Zd,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=qd({typed:t,equalScalar:a}),l=Jd({typed:t,DenseMatrix:s}),u=Yd({typed:t}),d=$d({typed:t,config:n,round:r});function f(e){var t=(e,t)=>Ru(e,t,n.relTol,n.absTol),i=e.ceil(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`ceil`,{number:d.signatures.number,"number,number":d.signatures[`number,number`],Complex:function(e){return e.ceil()},"Complex, number":function(e,t){return e.ceil(t)},"Complex, BigNumber":function(e,t){return e.ceil(t.toNumber())},BigNumber:f,"BigNumber, BigNumber":function(e,t){var n=Qd.pow(t);return f(e.mul(n)).div(n)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.ceil()},"Fraction, number":function(e,t){return e.ceil(t)},"Fraction, BigNumber":function(e,t){return e.ceil(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>Qc(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>Qc(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),tf=`cube`,nf=J(tf,[`typed`],e=>{var{typed:t}=e;return t(tf,{number:ml,Complex:function(e){return e.mul(e).mul(e)},BigNumber:function(e){return e.times(e).times(e)},bigint:function(e){return e*e*e},Fraction:function(e){return e.pow(3)},Unit:function(e){return e.pow(3)}})}),rf=`exp`,af=J(rf,[`typed`],e=>{var{typed:t}=e;return t(rf,{number:hl,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})}),of=`expm1`,sf=J(of,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(of,{number:gl,Complex:function(e){var t=Math.exp(e.re);return new n(t*Math.cos(e.im)-1,t*Math.sin(e.im))},BigNumber:function(e){return e.exp().minus(1)}})}),cf=`fix`,lf=[`typed`,`Complex`,`matrix`,`ceil`,`floor`,`equalScalar`,`zeros`,`DenseMatrix`],uf=J(cf,[`typed`,`ceil`,`floor`],e=>{var{typed:t,ceil:n,floor:r}=e;return t(cf,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})}),df=J(cf,lf,e=>{var{typed:t,Complex:n,matrix:r,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:c}=e,l=Jd({typed:t,DenseMatrix:c}),u=Yd({typed:t}),d=uf({typed:t,ceil:i,floor:a});return t(`fix`,{number:d.signatures.number,"number, number | BigNumber":d.signatures[`number,number`],Complex:function(e){return new n(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},"Complex, number":function(e,t){return new n(e.re>0?a(e.re,t):i(e.re,t),e.im>0?a(e.im,t):i(e.im,t))},"Complex, BigNumber":function(e,t){var r=t.toNumber();return new n(e.re>0?a(e.re,r):i(e.re,r),e.im>0?a(e.im,r):i(e.im,r))},BigNumber:function(e){return e.isNegative()?i(e):a(e)},"BigNumber, number | BigNumber":function(e,t){return e.isNegative()?i(e,t):a(e,t)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.s<0n?e.ceil():e.floor()},"Fraction, number | BigNumber":function(e,t){return e.s<0n?i(e,t):a(e,t)},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>Qc(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),"Array | Matrix, number | BigNumber":t.referToSelf(e=>(t,n)=>Qc(t,t=>e(t,n),!0)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>o(t,0)?s(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),ff=`floor`,pf=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],mf=new os(10),hf=J(ff,[`typed`,`config`,`round`],e=>{var{typed:t,config:n,round:r}=e;function i(e){var t=Math.floor(e),i=r(e);return t===i?t:na(e,i,n.relTol,n.absTol)&&!na(e,t,n.relTol,n.absTol)?i:t}return t(ff,{number:i,"number, number":function(e,t){if(!Li(t))throw RangeError(`number of decimals in function floor must be an integer`);if(t<0||t>15)throw RangeError(`number of decimals in floor number must be in range 0 - 15`);var n=10**t;return i(e*n)/n}})}),gf=J(ff,pf,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=qd({typed:t,equalScalar:a}),l=Jd({typed:t,DenseMatrix:s}),u=Yd({typed:t}),d=hf({typed:t,config:n,round:r});function f(e){var t=(e,t)=>Ru(e,t,n.relTol,n.absTol),i=e.floor(),a=r(e);return i.eq(a)?i:t(e,a)&&!t(e,i)?a:i}return t(`floor`,{number:d.signatures.number,"number,number":d.signatures[`number,number`],Complex:function(e){return e.floor()},"Complex, number":function(e,t){return e.floor(t)},"Complex, BigNumber":function(e,t){return e.floor(t.toNumber())},BigNumber:f,"BigNumber, BigNumber":function(e,t){var n=mf.pow(t);return f(e.mul(n)).div(n)},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.floor()},"Fraction, number":function(e,t){return e.floor(t)},"Fraction, BigNumber":function(e,t){return e.floor(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>Qc(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>Qc(t,t=>e(t,n),!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"number | Complex | Fraction | BigNumber, Array":t.referToSelf(e=>(t,n)=>u(i(n),t,e,!0).valueOf()),"number | Complex | Fraction | BigNumber, Matrix":t.referToSelf(e=>(t,n)=>a(t,0)?o(n.size(),n.storage()):n.storage()===`dense`?u(n,t,e,!0):l(n,t,e,!0))})}),_f=J(`matAlgo02xDS0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i,a){var o=e._data,s=e._size,c=e._datatype||e.getDataType(),l=r._values,u=r._index,d=r._ptr,f=r._size,p=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(s.length!==f.length)throw new rc(s.length,f.length);if(s[0]!==f[0]||s[1]!==f[1])throw RangeError(`Dimension mismatch. Matrix A (`+s+`) must match Matrix B (`+f+`)`);if(!l)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var m=s[0],h=s[1],g,_=n,v=0,y=i;typeof c==`string`&&c===p&&c!==`mixed`&&(g=c,_=t.find(n,[g,g]),v=t.convert(0,g),y=t.find(i,[g,g]));for(var b=[],x=[],S=[],C=0;C<h;C++){S[C]=x.length;for(var w=d[C],T=d[C+1],E=w;E<T;E++){var D=u[E],O=a?y(l[E],o[D][C]):y(o[D][C],l[E]);_(O,v)||(x.push(D),b.push(O))}}return S[h]=x.length,r.createSparseMatrix({values:b,index:x,ptr:S,size:[m,h],datatype:c===e._datatype&&p===r._datatype?g:void 0})}}),vf=J(`matAlgo03xDSf`,[`typed`],e=>{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new rc(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h,g=0,_=r;typeof s==`string`&&s===f&&s!==`mixed`&&(h=s,g=t.convert(0,h),_=t.find(r,[h,h]));for(var v=[],y=0;y<p;y++)v[y]=[];for(var b=[],x=[],S=0;S<m;S++){for(var C=S+1,w=u[S],T=u[S+1],E=w;E<T;E++){var D=l[E];b[D]=i?_(c[E],a[D][S]):_(a[D][S],c[E]),x[D]=C}for(var O=0;O<p;O++)x[O]===C?v[O][S]=b[O]:v[O][S]=i?_(g,a[O][S]):_(a[O][S],g)}return e.createDenseMatrix({data:v,size:[p,m],datatype:s===e._datatype&&f===n._datatype?h:void 0})}}),yf=J(`matAlgo05xSfSf`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new rc(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=x?[]:void 0,E=[],D=[],O,k,A,j;for(k=0;k<g;k++){C[k]=S.length;var M=k+1;for(A=s[k],j=s[k+1];A<j;A++)O=o[A],S.push(O),E[O]=M,w&&(w[O]=a[A]);for(A=f[k],j=f[k+1];A<j;A++)O=d[A],E[O]!==M&&S.push(O),D[O]=M,T&&(T[O]=u[A]);if(x)for(A=C[k];A<S.length;){O=S[A];var N=E[O],P=D[O];if(N===M||P===M){var F=N===M?w[O]:y,I=P===M?T[O]:y,L=b(F,I);v(L,y)?S.splice(A,1):(x.push(L),A++)}}}return C[g]=S.length,e.createSparseMatrix({values:x,index:S,ptr:C,size:[h,g],datatype:l===e._datatype&&m===r._datatype?_:void 0})}}),bf=J(`matAlgo13xDD`,[`typed`],e=>{var{typed:t}=e;return function(e,r,i){var a=e._data,o=e._size,s=e._datatype,c=r._data,l=r._size,u=r._datatype,d=[];if(o.length!==l.length)throw new rc(o.length,l.length);for(var f=0;f<o.length;f++){if(o[f]!==l[f])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+l+`)`);d[f]=o[f]}var p,m=i;typeof s==`string`&&s===u&&(p=s,m=t.find(i,[p,p]));var h=d.length>0?n(m,0,d,d[0],a,c):[];return e.createDenseMatrix({data:h,size:d,datatype:p})};function n(e,t,r,i,a,o){var s=[];if(t===r.length-1)for(var c=0;c<i;c++)s[c]=e(a[c],o[c]);else for(var l=0;l<i;l++)s[l]=n(e,t+1,r,r[t+1],a[l],o[l]);return s}});function xf(e,t){if(xi(e.size(),t.size()))return[e,t];var n=Mc(e.size(),t.size());return[e,t].map(e=>Sf(e,n))}function Sf(e,t){return xi(e.size(),t)?e:e.create(Pc(e.valueOf(),t),e.datatype())}var Cf=J(`matrixAlgorithmSuite`,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e,r=bf({typed:t}),i=Yd({typed:t});return function(e){var a=e.elop,o=e.SD||e.DS,s;a?(s={"DenseMatrix, DenseMatrix":(e,t)=>r(...xf(e,t),a),"Array, Array":(e,t)=>r(...xf(n(e),n(t)),a).valueOf(),"Array, DenseMatrix":(e,t)=>r(...xf(n(e),t),a),"DenseMatrix, Array":(e,t)=>r(...xf(e,n(t)),a)},e.SS&&(s[`SparseMatrix, SparseMatrix`]=(t,n)=>e.SS(...xf(t,n),a,!1)),e.DS&&(s[`DenseMatrix, SparseMatrix`]=(t,n)=>e.DS(...xf(t,n),a,!1),s[`Array, SparseMatrix`]=(t,r)=>e.DS(...xf(n(t),r),a,!1)),o&&(s[`SparseMatrix, DenseMatrix`]=(e,t)=>o(...xf(t,e),a,!0),s[`SparseMatrix, Array`]=(e,t)=>o(...xf(n(t),e),a,!0))):(s={"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>r(...xf(t,n),e)),"Array, Array":t.referToSelf(e=>(t,i)=>r(...xf(n(t),n(i)),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,i)=>r(...xf(n(t),i),e)),"DenseMatrix, Array":t.referToSelf(e=>(t,i)=>r(...xf(t,n(i)),e))},e.SS&&(s[`SparseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.SS(...xf(n,r),t,!1))),e.DS&&(s[`DenseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.DS(...xf(n,r),t,!1)),s[`Array, SparseMatrix`]=t.referToSelf(t=>(r,i)=>e.DS(...xf(n(r),i),t,!1))),o&&(s[`SparseMatrix, DenseMatrix`]=t.referToSelf(e=>(t,n)=>o(...xf(n,t),e,!0)),s[`SparseMatrix, Array`]=t.referToSelf(e=>(t,r)=>o(...xf(n(r),t),e,!0))));var c=e.scalar||`any`;(e.Ds||e.Ss)&&(a?(s[`DenseMatrix,`+c]=(e,t)=>i(e,t,a,!1),s[c+`, DenseMatrix`]=(e,t)=>i(t,e,a,!0),s[`Array,`+c]=(e,t)=>i(n(e),t,a,!1).valueOf(),s[c+`, Array`]=(e,t)=>i(n(t),e,a,!0).valueOf()):(s[`DenseMatrix,`+c]=t.referToSelf(e=>(t,n)=>i(t,n,e,!1)),s[c+`, DenseMatrix`]=t.referToSelf(e=>(t,n)=>i(n,t,e,!0)),s[`Array,`+c]=t.referToSelf(e=>(t,r)=>i(n(t),r,e,!1).valueOf()),s[c+`, Array`]=t.referToSelf(e=>(t,r)=>i(n(r),t,e,!0).valueOf())));var l=e.sS===void 0?e.Ss:e.sS;return a?(e.Ss&&(s[`SparseMatrix,`+c]=(t,n)=>e.Ss(t,n,a,!1)),l&&(s[c+`, SparseMatrix`]=(e,t)=>l(t,e,a,!0))):(e.Ss&&(s[`SparseMatrix,`+c]=t.referToSelf(t=>(n,r)=>e.Ss(n,r,t,!1))),l&&(s[c+`, SparseMatrix`]=t.referToSelf(e=>(t,n)=>l(n,t,e,!0)))),a&&a.signatures&&yi(s,a.signatures),s}}),wf=`mod`,Tf=J(wf,[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s,concat:c}=e,l=gf({typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),u=_f({typed:t,equalScalar:a}),d=vf({typed:t}),f=yf({typed:t,equalScalar:a}),p=qd({typed:t,equalScalar:a}),m=Jd({typed:t,DenseMatrix:s}),h=Cf({typed:t,matrix:i,concat:c});return t(wf,{"number, number":g,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.sub(t.mul(l(e.div(t))))},"bigint, bigint":function(e,t){if(t===0n)return e;if(e<0){var n=e%t;return n===0n?n:n+t}return e%t},"Fraction, Fraction":function(e,t){return t.equals(0)?e:e.sub(t.mul(l(e.div(t))))}},h({SS:f,DS:d,SD:u,Ss:p,sS:m}));function g(e,t){return t===0?e:e-t*l(e/t)}}),Ef=J(`matAlgo01xDSid`,[`typed`],e=>{var{typed:t}=e;return function(e,n,r,i){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._values,l=n._index,u=n._ptr,d=n._size,f=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(o.length!==d.length)throw new rc(o.length,d.length);if(o[0]!==d[0]||o[1]!==d[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+d+`)`);if(!c)throw Error(`Cannot perform operation on Dense Matrix and Pattern Sparse Matrix`);var p=o[0],m=o[1],h=typeof s==`string`&&s!==`mixed`&&s===f?s:void 0,g=h?t.find(r,[h,h]):r,_,v,y=[];for(_=0;_<p;_++)y[_]=[];var b=[],x=[];for(v=0;v<m;v++){for(var S=v+1,C=u[v],w=u[v+1],T=C;T<w;T++)_=l[T],b[_]=i?g(c[T],a[_][v]):g(a[_][v],c[T]),x[_]=S;for(_=0;_<p;_++)x[_]===S?y[_][v]=b[_]:y[_][v]=a[_][v]}return e.createDenseMatrix({data:y,size:[p,m],datatype:s===e._datatype&&f===n._datatype?h:void 0})}}),Df=J(`matAlgo04xSidSid`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new rc(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=a&&u?[]:void 0,T=a&&u?[]:void 0,E=[],D=[],O,k,A,j,M;for(k=0;k<g;k++){C[k]=S.length;var N=k+1;for(j=s[k],M=s[k+1],A=j;A<M;A++)O=o[A],S.push(O),E[O]=N,w&&(w[O]=a[A]);for(j=f[k],M=f[k+1],A=j;A<M;A++)if(O=d[A],E[O]===N){if(w){var P=b(w[O],u[A]);v(P,y)?E[O]=null:w[O]=P}}else S.push(O),D[O]=N,T&&(T[O]=u[A]);if(w&&T)for(A=C[k];A<S.length;)O=S[A],E[O]===N?(x[A]=w[O],A++):D[O]===N?(x[A]=T[O],A++):S.splice(A,1)}return C[g]=S.length,e.createSparseMatrix({values:x,index:S,ptr:C,size:[h,g],datatype:l===e._datatype&&m===r._datatype?_:void 0})}}),Of=J(`matAlgo10xSids`,[`typed`,`DenseMatrix`],e=>{var{typed:t,DenseMatrix:n}=e;return function(e,r,i,a){var o=e._values,s=e._index,c=e._ptr,l=e._size,u=e._datatype;if(!o)throw Error(`Cannot perform operation on Pattern Sparse Matrix and Scalar value`);var d=l[0],f=l[1],p,m=i;typeof u==`string`&&(p=u,r=t.convert(r,p),m=t.find(i,[p,p]));for(var h=[],g=[],_=[],v=0;v<f;v++){for(var y=v+1,b=c[v],x=c[v+1],S=b;S<x;S++){var C=s[S];g[C]=o[S],_[C]=y}for(var w=0;w<d;w++)v===0&&(h[w]=[]),_[w]===y?h[w][v]=a?m(r,g[w]):m(g[w],r):h[w][v]=r}return new n({data:h,size:[d,f],datatype:p})}});function kf(e,t,n,r){if(!(this instanceof kf))throw SyntaxError(`Constructor must be called with the new operator`);this.fn=e,this.count=t,this.min=n,this.max=r,this.message=`Wrong number of arguments in function `+e+` (`+t+` provided, `+n+(r==null?``:`-`+r)+` expected)`,this.stack=Error().stack}kf.prototype=Error(),kf.prototype.constructor=Error,kf.prototype.name=`ArgumentsError`,kf.prototype.isArgumentsError=!0;var Af=`gcd`,jf=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`BigNumber`,`DenseMatrix`,`concat`],Mf=`number | BigNumber | Fraction | Matrix | Array`,Nf=`${Mf}, ${Mf}, ...${Mf}`;function Pf(e){return!e.some(e=>Array.isArray(e))}var Ff=J(Af,jf,e=>{var{typed:t,matrix:n,config:r,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:c,concat:l}=e,u=Tf({typed:t,config:r,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:c,concat:l}),d=Ef({typed:t}),f=Df({typed:t,equalScalar:a}),p=Of({typed:t,DenseMatrix:c}),m=Cf({typed:t,matrix:n,concat:l});return t(Af,{"number, number":h,"BigNumber, BigNumber":g,"Fraction, Fraction":(e,t)=>e.gcd(t)},m({SS:f,DS:d,Ss:p}),{[Nf]:t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a<r.length;a++)i=e(i,r[a]);return i}),Array:t.referToSelf(e=>t=>{if(t.length===1&&Array.isArray(t[0])&&Pf(t[0]))return e(...t[0]);if(Pf(t))return e(...t);throw new kf(`gcd() supports only 1d matrices!`)}),Matrix:t.referToSelf(e=>t=>e(t.toArray()))});function h(e,t){if(!Li(e)||!Li(t))throw Error(`Parameters in function gcd must be integer numbers`);for(var n;t!==0;)n=u(e,t),e=t,t=n;return e<0?-e:e}function g(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function gcd must be integer numbers`);for(var n=new s(0);!t.isZero();){var r=u(e,t);e=t,t=r}return e.lt(n)?e.neg():e}}),If=J(`matAlgo06xS0S0`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=r._values,l=r._size,u=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(o.length!==l.length)throw new rc(o.length,l.length);if(o[0]!==l[0]||o[1]!==l[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+l+`)`);var d=o[0],f=o[1],p,m=n,h=0,g=i;typeof s==`string`&&s===u&&s!==`mixed`&&(p=s,m=t.find(n,[p,p]),h=t.convert(0,p),g=t.find(i,[p,p]));for(var _=a&&c?[]:void 0,v=[],y=[],b=_?[]:void 0,x=[],S=[],C=0;C<f;C++){y[C]=v.length;var w=C+1;if(tl(e,C,x,b,S,w,v,g),tl(r,C,x,b,S,w,v,g),b)for(var T=y[C];T<v.length;){var E=v[T];if(S[E]===w){var D=b[E];m(D,h)?v.splice(T,1):(_.push(D),T++)}else v.splice(T,1)}else for(var O=y[C];O<v.length;)S[v[O]]===w?O++:v.splice(O,1)}return y[f]=v.length,e.createSparseMatrix({values:_,index:v,ptr:y,size:[d,f],datatype:s===e._datatype&&u===r._datatype?p:void 0})}}),Lf=`lcm`,Rf=J(Lf,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=_f({typed:t,equalScalar:r}),o=If({typed:t,equalScalar:r}),s=qd({typed:t,equalScalar:r}),c=Cf({typed:t,matrix:n,concat:i}),l=`number | BigNumber | Fraction | Matrix | Array`,u={};return u[`${l}, ${l}, ...${l}`]=t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a<r.length;a++)i=e(i,r[a]);return i}),t(Lf,{"number, number":vl,"BigNumber, BigNumber":d,"Fraction, Fraction":(e,t)=>e.lcm(t)},c({SS:o,DS:a,Ss:s}),u);function d(e,t){if(!e.isInt()||!t.isInt())throw Error(`Parameters in function lcm must be integer numbers`);if(e.isZero())return e;if(t.isZero())return t;for(var n=e.times(t);!t.isZero();){var r=t;t=e.mod(r),e=r}return n.div(e).abs()}});function zf(e,t,n,r){return function(i){if(i>0||n.predictable){if(i<=0)return NaN;var a=i.toString(16),o=a.substring(0,15);return e*(a.length-o.length)+t(Number(`0x`+o))}return r(i.toNumber())}}var Bf=`log10`,Vf=[`typed`,`config`,`Complex`],Hf=bl(16),Uf=J(Bf,Vf,e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return e.log().div(Math.LN10)}function a(e){return i(new r(e,0))}return t(Bf,{number:function(e){return e>=0||n.predictable?bl(e):a(e)},bigint:zf(Hf,bl,n,a),Complex:i,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():a(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Wf=`log2`,Gf=J(Wf,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return a(new r(e,0))}return t(Wf,{number:function(e){return e>=0||n.predictable?xl(e):i(e)},bigint:zf(4,xl,n,i),Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))});function a(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new r(Math.log2?Math.log2(t):Math.log(t)/Math.LN2,Math.atan2(e.im,e.re)/Math.LN2)}}),Kf=J(`multiplyScalar`,[`typed`],e=>{var{typed:t}=e;return t(`multiplyScalar`,{"number, number":ll,"Complex, Complex":function(e,t){return e.mul(t)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"bigint, bigint":function(e,t){return e*t},"Fraction, Fraction":function(e,t){return e.mul(t)},"number | Fraction | BigNumber | Complex, Unit":(e,t)=>t.multiply(e),"Unit, number | Fraction | BigNumber | Complex | Unit":(e,t)=>e.multiply(t)})}),qf=`multiply`,Jf=J(qf,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`equalScalar`,`dot`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,equalScalar:a,dot:o}=e,s=qd({typed:t,equalScalar:a}),c=Yd({typed:t});function l(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vectors must have the same length`);break;case 2:if(e[0]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Vector length (`+e[0]+`) must match Matrix rows (`+t[0]+`)`);break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix B has `+t.length+` dimensions)`)}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Matrix columns (`+e[1]+`) must match Vector length (`+t[0]+`)`);break;case 2:if(e[1]!==t[0])throw RangeError(`Dimension mismatch in multiplication. Matrix A columns (`+e[1]+`) must match Matrix B rows (`+t[0]+`)`);break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix B has `+t.length+` dimensions)`)}break;default:throw Error(`Can only multiply a 1 or 2 dimensional matrix (Matrix A has `+e.length+` dimensions)`)}}function u(e,t,n){if(n===0)throw Error(`Cannot multiply two empty vectors`);return o(e,t)}function d(e,t){if(t.storage()!==`dense`)throw Error(`Support for SparseMatrix not implemented`);return f(e,t)}function f(e,n){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._data,l=n._size,u=n._datatype||n.getDataType(),d=o[0],f=l[1],p,m=r,h=i;s&&u&&s===u&&typeof s==`string`&&s!==`mixed`&&(p=s,m=t.find(r,[p,p]),h=t.find(i,[p,p]));for(var g=[],_=0;_<f;_++){for(var v=h(a[0],c[0][_]),y=1;y<d;y++)v=m(v,h(a[y],c[y][_]));g[_]=v}return e.createDenseMatrix({data:g,size:[f],datatype:s===e._datatype&&u===n._datatype?p:void 0})}var p=t(`_multiplyMatrixVector`,{"DenseMatrix, any":h,"SparseMatrix, any":v}),m=t(`_multiplyMatrixMatrix`,{"DenseMatrix, DenseMatrix":g,"DenseMatrix, SparseMatrix":_,"SparseMatrix, DenseMatrix":y,"SparseMatrix, SparseMatrix":b});function h(e,n){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._data,l=n._datatype||n.getDataType(),u=o[0],d=o[1],f,p=r,m=i;s&&l&&s===l&&typeof s==`string`&&s!==`mixed`&&(f=s,p=t.find(r,[f,f]),m=t.find(i,[f,f]));for(var h=[],g=0;g<u;g++){for(var _=a[g],v=m(_[0],c[0]),y=1;y<d;y++)v=p(v,m(_[y],c[y]));h[g]=v}return e.createDenseMatrix({data:h,size:[u],datatype:s===e._datatype&&l===n._datatype?f:void 0})}function g(e,n){var a=e._data,o=e._size,s=e._datatype||e.getDataType(),c=n._data,l=n._size,u=n._datatype||n.getDataType(),d=o[0],f=o[1],p=l[1],m,h=r,g=i;s&&u&&s===u&&typeof s==`string`&&s!==`mixed`&&s!==`mixed`&&(m=s,h=t.find(r,[m,m]),g=t.find(i,[m,m]));for(var _=[],v=0;v<d;v++){var y=a[v];_[v]=[];for(var b=0;b<p;b++){for(var x=g(y[0],c[0][b]),S=1;S<f;S++)x=h(x,g(y[S],c[S][b]));_[v][b]=x}}return e.createDenseMatrix({data:_,size:[d,p],datatype:s===e._datatype&&u===n._datatype?m:void 0})}function _(e,n){var o=e._data,s=e._size,c=e._datatype||e.getDataType(),l=n._values,u=n._index,d=n._ptr,f=n._size,p=n._datatype||n._data===void 0?n._datatype:n.getDataType();if(!l)throw Error(`Cannot multiply Dense Matrix times Pattern only Matrix`);var m=s[0],h=f[1],g,_=r,v=i,y=a,b=0;c&&p&&c===p&&typeof c==`string`&&c!==`mixed`&&(g=c,_=t.find(r,[g,g]),v=t.find(i,[g,g]),y=t.find(a,[g,g]),b=t.convert(0,g));for(var x=[],S=[],C=[],w=n.createSparseMatrix({values:x,index:S,ptr:C,size:[m,h],datatype:c===e._datatype&&p===n._datatype?g:void 0}),T=0;T<h;T++){C[T]=S.length;var E=d[T],D=d[T+1];if(D>E)for(var O=0,k=0;k<m;k++){for(var A=k+1,j=void 0,M=E;M<D;M++){var N=u[M];O===A?j=_(j,v(o[k][N],l[M])):(j=v(o[k][N],l[M]),O=A)}O===A&&!y(j,b)&&(S.push(k),x.push(j))}}return C[h]=S.length,w}function v(e,n){var o=e._values,s=e._index,c=e._ptr,l=e._datatype||e._data===void 0?e._datatype:e.getDataType();if(!o)throw Error(`Cannot multiply Pattern only Matrix times Dense Matrix`);var u=n._data,d=n._datatype||n.getDataType(),f=e._size[0],p=n._size[0],m=[],h=[],g=[],_,v=r,y=i,b=a,x=0;l&&d&&l===d&&typeof l==`string`&&l!==`mixed`&&(_=l,v=t.find(r,[_,_]),y=t.find(i,[_,_]),b=t.find(a,[_,_]),x=t.convert(0,_));var S=[],C=[];g[0]=0;for(var w=0;w<p;w++){var T=u[w];if(!b(T,x))for(var E=c[w],D=c[w+1],O=E;O<D;O++){var k=s[O];C[k]?S[k]=v(S[k],y(T,o[O])):(C[k]=!0,h.push(k),S[k]=y(T,o[O]))}}for(var A=h.length,j=0;j<A;j++)m[j]=S[h[j]];return g[1]=h.length,e.createSparseMatrix({values:m,index:h,ptr:g,size:[f,1],datatype:l===e._datatype&&d===n._datatype?_:void 0})}function y(e,n){var o=e._values,s=e._index,c=e._ptr,l=e._datatype||e._data===void 0?e._datatype:e.getDataType();if(!o)throw Error(`Cannot multiply Pattern only Matrix times Dense Matrix`);var u=n._data,d=n._datatype||n.getDataType(),f=e._size[0],p=n._size[0],m=n._size[1],h,g=r,_=i,v=a,y=0;l&&d&&l===d&&typeof l==`string`&&l!==`mixed`&&(h=l,g=t.find(r,[h,h]),_=t.find(i,[h,h]),v=t.find(a,[h,h]),y=t.convert(0,h));for(var b=[],x=[],S=[],C=e.createSparseMatrix({values:b,index:x,ptr:S,size:[f,m],datatype:l===e._datatype&&d===n._datatype?h:void 0}),w=[],T=[],E=0;E<m;E++){S[E]=x.length;for(var D=E+1,O=0;O<p;O++){var k=u[O][E];if(!v(k,y))for(var A=c[O],j=c[O+1],M=A;M<j;M++){var N=s[M];T[N]===D?w[N]=g(w[N],_(k,o[M])):(T[N]=D,x.push(N),w[N]=_(k,o[M]))}}for(var P=S[E],F=x.length,I=P;I<F;I++)b[I]=w[x[I]]}return S[m]=x.length,C}function b(e,n){var a=e._values,o=e._index,s=e._ptr,c=e._datatype||e._data===void 0?e._datatype:e.getDataType(),l=n._values,u=n._index,d=n._ptr,f=n._datatype||n._data===void 0?n._datatype:n.getDataType(),p=e._size[0],m=n._size[1],h=a&&l,g,_=r,v=i;c&&f&&c===f&&typeof c==`string`&&c!==`mixed`&&(g=c,_=t.find(r,[g,g]),v=t.find(i,[g,g]));for(var y=h?[]:void 0,b=[],x=[],S=e.createSparseMatrix({values:y,index:b,ptr:x,size:[p,m],datatype:c===e._datatype&&f===n._datatype?g:void 0}),C=h?[]:void 0,w=[],T,E,D,O,k,A,j,M,N=0;N<m;N++){x[N]=b.length;var P=N+1;for(k=d[N],A=d[N+1],O=k;O<A;O++)if(M=u[O],h)for(E=s[M],D=s[M+1],T=E;T<D;T++)j=o[T],w[j]===P?C[j]=_(C[j],v(l[O],a[T])):(w[j]=P,b.push(j),C[j]=v(l[O],a[T]));else for(E=s[M],D=s[M+1],T=E;T<D;T++)j=o[T],w[j]!==P&&(w[j]=P,b.push(j));if(h)for(var F=x[N],I=b.length,L=F;L<I;L++)y[L]=C[b[L]]}return x[m]=b.length,S}return t(qf,i,{"Array, Array":t.referTo(`Matrix, Matrix`,e=>(t,r)=>{l(ac(t),ac(r));var i=e(n(t),n(r));return Pr(i)?i.valueOf():i}),"Matrix, Matrix":function(e,t){var n=e.size(),r=t.size();return l(n,r),n.length===1?r.length===1?u(e,t,n[0]):d(e,t):r.length===1?p(e,t):m(e,t)},"Matrix, Array":t.referTo(`Matrix,Matrix`,e=>(t,r)=>e(t,n(r))),"Array, Matrix":t.referToSelf(e=>(t,r)=>e(n(t,r.storage()),r)),"SparseMatrix, any":function(e,t){return s(e,t,i,!1)},"DenseMatrix, any":function(e,t){return c(e,t,i,!1)},"any, SparseMatrix":function(e,t){return s(t,e,i,!0)},"any, DenseMatrix":function(e,t){return c(t,e,i,!0)},"Array, any":function(e,t){return c(n(e),t,i,!1).valueOf()},"any, Array":function(e,t){return c(n(t),e,i,!0).valueOf()},"any, any":i,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a<r.length;a++)i=e(i,r[a]);return i})})}),Yf=`nthRoot`,Xf=J(Yf,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,concat:a}=e,o=Ef({typed:t}),s=_f({typed:t,equalScalar:r}),c=If({typed:t,equalScalar:r}),l=qd({typed:t,equalScalar:r}),u=Cf({typed:t,matrix:n,concat:a});function d(){throw Error(`Complex number not supported in function nthRoot. Use nthRoots instead.`)}return t(Yf,{number:wl,"number, number":wl,BigNumber:e=>f(e,new i(2)),"BigNumber, BigNumber":f,Complex:d,"Complex, number":d,Array:t.referTo(`DenseMatrix,number`,e=>t=>e(n(t),2).valueOf()),DenseMatrix:t.referTo(`DenseMatrix,number`,e=>t=>e(t,2)),SparseMatrix:t.referTo(`SparseMatrix,number`,e=>t=>e(t,2)),"SparseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return c(t,n,e);throw Error(`Root must be non-zero`)}),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return o(t,n,e,!1);throw Error(`Root must be non-zero`)}),"Array, SparseMatrix":t.referTo(`DenseMatrix,SparseMatrix`,e=>(t,r)=>e(n(t),r)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>{if(n.density()===1)return l(n,t,e,!0);throw Error(`Root must be non-zero`)})},u({scalar:`number | BigNumber`,SD:s,Ss:l,sS:!1}));function f(e,t){var n=i.precision,r=i.clone({precision:n+2}),a=new i(0),o=new r(1),s=t.isNegative();if(s&&(t=t.neg()),t.isZero())throw Error(`Root must be non-zero`);if(e.isNegative()&&!t.abs().mod(2).equals(1))throw Error(`Root must be odd when a is negative.`);if(e.isZero())return s?new r(1/0):0;if(!e.isFinite())return s?a:e;var c=e.abs().pow(o.div(t));return c=e.isNeg()?c.neg():c,new i((s?o.div(c):c).toPrecision(n))}}),Zf=`sign`,Qf=J(Zf,[`typed`,`BigNumber`,`Fraction`,`complex`],e=>{var{typed:t,BigNumber:n,complex:r,Fraction:i}=e;return t(Zf,{number:Tl,Complex:function(e){return e.im===0?r(Tl(e.re)):e.sign()},BigNumber:function(e){return new n(e.cmp(0))},bigint:function(e){return e>0n?1n:e<0n?-1n:0n},Fraction:function(e){return e.n===0n?new i(0):new i(e.s)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),Unit:t.referToSelf(e=>n=>{if(!n._isDerived()&&n.units[0].unit.offset!==0)throw TypeError(`sign is ambiguous for units with offset`);return t.find(e,n.valueType())(n.value)})})}),$f=J(`sqrt`,[`config`,`typed`,`Complex`],e=>{var{config:t,typed:n,Complex:r}=e;return n(`sqrt`,{number:i,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():i(e.toNumber())},Unit:function(e){return e.pow(.5)}});function i(e){return isNaN(e)?NaN:e>=0||t.predictable?Math.sqrt(e):new r(e,0).sqrt()}}),ep=`square`,tp=J(ep,[`typed`],e=>{var{typed:t}=e;return t(ep,{number:Dl,Complex:function(e){return e.mul(e)},BigNumber:function(e){return e.times(e)},bigint:function(e){return e*e},Fraction:function(e){return e.mul(e)},Unit:function(e){return e.pow(2)}})}),np=`subtract`,rp=J(np,[`typed`,`matrix`,`equalScalar`,`subtractScalar`,`unaryMinus`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,subtractScalar:i,unaryMinus:a,DenseMatrix:o,concat:s}=e,c=Ef({typed:t}),l=vf({typed:t}),u=yf({typed:t,equalScalar:r}),d=Of({typed:t,DenseMatrix:o}),f=Jd({typed:t,DenseMatrix:o}),p=Cf({typed:t,matrix:n,concat:s});return t(np,{"any, any":i},p({elop:i,SS:u,DS:c,SD:l,Ss:f,sS:d}))}),ip=`xgcd`,ap=J(ip,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(ip,{"number, number":function(e,t){var i=Ol(e,t);return n.matrix===`Array`?i:r(i)},"BigNumber, BigNumber":a});function a(e,t){var a,o,s,c=new i(0),l=new i(1),u=c,d=l,f=l,p=c;if(!e.isInt()||!t.isInt())throw Error(`Parameters in function xgcd must be integer numbers`);for(;!t.isZero();)o=e.div(t).floor(),s=e.mod(t),a=u,u=d.minus(o.times(u)),d=a,a=f,f=p.minus(o.times(f)),p=a,e=t,t=s;var m=e.lt(c)?[e.neg(),d.neg(),p.neg()]:[e,e.isZero()?0:d,p];return n.matrix===`Array`?m:r(m)}}),op=`invmod`,sp=J(op,[`typed`,`config`,`BigNumber`,`xgcd`,`equal`,`smaller`,`mod`,`add`,`isInteger`],e=>{var{typed:t,config:n,BigNumber:r,xgcd:i,equal:a,smaller:o,mod:s,add:c,isInteger:l}=e;return t(op,{"number, number":u,"BigNumber, BigNumber":u});function u(e,t){if(!l(e)||!l(t))throw Error(`Parameters in function invmod must be integer numbers`);if(e=s(e,t),a(t,0))throw Error(`Divisor must be non zero`);var n=i(e,t);n=n.valueOf();var[u,d]=n;return a(u,r(1))?(d=s(d,t),o(d,r(0))&&(d=c(d,t)),d):NaN}}),cp=J(`matAlgo09xS0Sf`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new rc(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));var x=a&&u?[]:void 0,S=[],C=[],w=x?[]:void 0,T=[],E,D,O,k,A;for(D=0;D<g;D++){C[D]=S.length;var j=D+1;if(w)for(k=f[D],A=f[D+1],O=k;O<A;O++)E=d[O],T[E]=j,w[E]=u[O];for(k=s[D],A=s[D+1],O=k;O<A;O++)if(E=o[O],w){var M=T[E]===j?w[E]:y,N=b(a[O],M);v(N,y)||(S.push(E),x.push(N))}else S.push(E)}return C[g]=S.length,e.createSparseMatrix({values:x,index:S,ptr:C,size:[h,g],datatype:l===e._datatype&&m===r._datatype?_:void 0})}}),lp=`dotMultiply`,up=J(lp,[`typed`,`matrix`,`equalScalar`,`multiplyScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:i,concat:a}=e,o=_f({typed:t,equalScalar:r}),s=cp({typed:t,equalScalar:r}),c=qd({typed:t,equalScalar:r});return t(lp,Cf({typed:t,matrix:n,concat:a})({elop:i,SS:s,DS:o,Ss:c}))});function dp(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitAnd`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()===t.isNegative()?e:new n(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new n(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new n(0):e}return mp(e,t,function(e,t){return e&t})}function fp(e){if(e.isFinite()&&!e.isInteger())throw Error(`Integer expected in function bitNot`);var t=e.constructor,n=t.precision;t.config({precision:1e9});var r=e.plus(new t(1));return r.s=-r.s||null,t.config({precision:n}),r}function pp(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitOr`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);var r=new n(-1);return e.isZero()||t.eq(r)||e.eq(t)?t:t.isZero()||e.eq(r)?e:!e.isFinite()||!t.isFinite()?!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?r:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e:mp(e,t,function(e,t){return e|t})}function mp(e,t,n){var r=e.constructor,i,a,o=+(e.s<0),s=+(t.s<0);if(o){i=hp(fp(e));for(var c=0;c<i.length;++c)i[c]^=1}else i=hp(e);if(s){a=hp(fp(t));for(var l=0;l<a.length;++l)a[l]^=1}else a=hp(t);var u,d,f;i.length<=a.length?(u=i,d=a,f=o):(u=a,d=i,f=s);var p=u.length,m=d.length,h=n(o,s)^1,g=new r(h^1),_=new r(1),v=new r(2),y=r.precision;for(r.config({precision:1e9});p>0;)n(u[--p],d[--m])===h&&(g=g.plus(_)),_=_.times(v);for(;m>0;)n(f,d[--m])===h&&(g=g.plus(_)),_=_.times(v);return r.config({precision:y}),h===0&&(g.s=-g.s),g}function hp(e){for(var t=e.d,n=t[0]+``,r=1;r<t.length;++r){for(var i=t[r]+``,a=7-i.length;a--;)i=`0`+i;n+=i}for(var o=n.length;n.charAt(o)===`0`;)o--;var s=e.e,c=n.slice(0,o+1||1),l=c.length;if(s>0)if(++s>l)for(s-=l;s--;)c+=`0`;else s<l&&(c=c.slice(0,s)+`.`+c.slice(s));for(var u=[0],d=0;d<c.length;){for(var f=u.length;f--;)u[f]*=10;u[0]+=parseInt(c.charAt(d++));for(var p=0;p<u.length;++p)u[p]>1&&((u[p+1]===null||u[p+1]===void 0)&&(u[p+1]=0),u[p+1]+=u[p]>>1,u[p]&=1)}return u.reverse()}function gp(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function bitXor`);var n=e.constructor;if(e.isNaN()||t.isNaN())return new n(NaN);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new n(0);var r=new n(-1);return e.eq(r)?fp(t):t.eq(r)?fp(e):!e.isFinite()||!t.isFinite()?!e.isFinite()&&!t.isFinite()?r:new n(e.isNegative()===t.isNegative()?1/0:-1/0):mp(e,t,function(e,t){return e^t})}function _p(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function leftShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:!e.isFinite()&&!t.isFinite()?new n(NaN):t.lt(55)?e.times(2**t.toNumber()+``):e.times(new n(2).pow(t))}function vp(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw Error(`Integers expected in function rightArithShift`);var n=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new n(NaN):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(2**t.toNumber()+``).floor():e.div(new n(2).pow(t)).floor():e.isNegative()?new n(-1):e.isFinite()?new n(0):new n(NaN)}var yp=`bitAnd`,bp=J(yp,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=_f({typed:t,equalScalar:r}),o=If({typed:t,equalScalar:r}),s=qd({typed:t,equalScalar:r}),c=Cf({typed:t,matrix:n,concat:i});return t(yp,{"number, number":Pl,"BigNumber, BigNumber":dp,"bigint, bigint":(e,t)=>e&t},c({SS:o,DS:a,Ss:s}))}),xp=`bitNot`,Sp=J(xp,[`typed`],e=>{var{typed:t}=e;return t(xp,{number:Fl,BigNumber:fp,bigint:e=>~e,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Cp=`bitOr`,wp=J(Cp,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=Ef({typed:t}),s=Df({typed:t,equalScalar:r}),c=Of({typed:t,DenseMatrix:i}),l=Cf({typed:t,matrix:n,concat:a});return t(Cp,{"number, number":Il,"BigNumber, BigNumber":pp,"bigint, bigint":(e,t)=>e|t},l({SS:s,DS:o,Ss:c}))}),Tp=J(`matAlgo07xSSf`,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return function(e,i,a){var o=e._size,s=e._datatype||e._data===void 0?e._datatype:e.getDataType(),c=i._size,l=i._datatype||i._data===void 0?i._datatype:i.getDataType();if(o.length!==c.length)throw new rc(o.length,c.length);if(o[0]!==c[0]||o[1]!==c[1])throw RangeError(`Dimension mismatch. Matrix A (`+o+`) must match Matrix B (`+c+`)`);var u=o[0],d=o[1],f,p=0,m=a;typeof s==`string`&&s===l&&s!==`mixed`&&(f=s,p=t.convert(0,f),m=t.find(a,[f,f]));for(var h=[],g=[],_=Array(d+1).fill(0),v=[],y=[],b=[],x=[],S=0;S<d;S++){var C=S+1,w=0;r(e,S,b,v,C),r(i,S,x,y,C);for(var T=0;T<u;T++){var E=b[T]===C?v[T]:p,D=x[T]===C?y[T]:p,O=m(E,D);O!==0&&O!==!1&&(g.push(T),h.push(O),w++)}_[S+1]=_[S]+w}return new n({values:h,index:g,ptr:_,size:[u,d],datatype:s===e._datatype&&l===i._datatype?f:void 0})};function r(e,t,n,r,i){for(var a=e._values,o=e._index,s=e._ptr,c=s[t],l=s[t+1];c<l;c++){var u=o[c];n[u]=i,r[u]=a[c]}}}),Ep=`bitXor`,Dp=J(Ep,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=vf({typed:t}),s=Tp({typed:t,SparseMatrix:a}),c=Jd({typed:t,DenseMatrix:r}),l=Cf({typed:t,matrix:n,concat:i});return t(Ep,{"number, number":Ll,"BigNumber, BigNumber":gp,"bigint, bigint":(e,t)=>e^t},l({SS:s,DS:o,Ss:c}))}),Op=`arg`,kp=J(Op,[`typed`],e=>{var{typed:t}=e;return t(Op,{number:function(e){return Math.atan2(0,e)},BigNumber:function(e){return e.constructor.atan2(0,e)},Complex:function(e){return e.arg()},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Ap=`conj`,jp=J(Ap,[`typed`],e=>{var{typed:t}=e;return t(Ap,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.conjugate(),Unit:t.referToSelf(e=>t=>new t.constructor(e(t.toNumeric()),t.formatUnits())),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Mp=`im`,Np=J(Mp,[`typed`],e=>{var{typed:t}=e;return t(Mp,{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Pp=`re`,Fp=J(Pp,[`typed`],e=>{var{typed:t}=e;return t(Pp,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Ip=`not`,Lp=J(Ip,[`typed`],e=>{var{typed:t}=e;return t(Ip,{"null | undefined":()=>!0,number:Yl,Complex:function(e){return e.re===0&&e.im===0},BigNumber:function(e){return e.isZero()||e.isNaN()},bigint:e=>!e,Unit:t.referToSelf(e=>n=>t.find(e,n.valueType())(n.value)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Rp=`nullish`,zp=J(Rp,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=vf({typed:t}),s=Yd({typed:t}),c=bf({typed:t});return t(Rp,{"number|bigint|Complex|BigNumber|Fraction|Unit|string|boolean|SparseMatrix, any":(e,t)=>e,"null, any":(e,t)=>t,"undefined, any":(e,t)=>t,"SparseMatrix, Array | Matrix":(e,t)=>{var n=r(e),i=r(t);if(a(n,i))return e;throw new rc(n,i)},"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>c(t,n,e)),"DenseMatrix, SparseMatrix":t.referToSelf(e=>(t,n)=>o(t,n,e,!1)),"DenseMatrix, Array":t.referToSelf(e=>(t,r)=>c(t,n(r),e)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>s(t,n,e,!1)),"Array, Array":t.referToSelf(e=>(t,r)=>c(n(t),n(r),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,r)=>c(n(t),r,e)),"Array, SparseMatrix":t.referToSelf(e=>(t,r)=>o(n(t),r,e,!1)),"Array, any":t.referToSelf(e=>(t,r)=>s(n(t),r,e,!1).valueOf())})}),Bp=`or`,Vp=J(Bp,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=vf({typed:t}),s=yf({typed:t,equalScalar:r}),c=Jd({typed:t,DenseMatrix:i}),l=Cf({typed:t,matrix:n,concat:a});return t(Bp,{"number, number":Xl,"Complex, Complex":function(e,t){return e.re!==0||e.im!==0||t.re!==0||t.im!==0},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"bigint, bigint":Xl,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),Hp=`xor`,Up=J(Hp,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=vf({typed:t}),s=Tp({typed:t,SparseMatrix:a}),c=Jd({typed:t,DenseMatrix:r}),l=Cf({typed:t,matrix:n,concat:i});return t(Hp,{"number, number":Zl,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)!=(t.re!==0||t.im!==0)},"bigint, bigint":Zl,"BigNumber, BigNumber":function(e,t){return(!e.isZero()&&!e.isNaN())!=(!t.isZero()&&!t.isNaN())},"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),Wp=`concat`,Gp=J(Wp,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(Wp,{"...Array | Matrix | number | BigNumber":function(e){var t,i=e.length,a=-1,o,s=!1,c=[];for(t=0;t<i;t++){var l=e[t];if(Pr(l)&&(s=!0),Er(l)||Dr(l)){if(t!==i-1)throw Error(`Dimension must be specified as last argument`);if(o=a,a=l.valueOf(),!r(a))throw TypeError(`Integer number expected for dimension`);if(a<0||t>0&&a>o)throw new ic(a,o+1)}else{var u=_i(l).valueOf(),d=ac(u);if(c[t]=u,o=a,a=d.length-1,t>0&&a!==o)throw new rc(o+1,a+1)}}if(c.length===0)throw SyntaxError(`At least one matrix expected`);for(var f=c.shift();c.length;)f=jc(f,c.shift(),a);return s?n(f):f},"...string":function(e){return e.join(``)}})}),Kp=`column`,qp=J(Kp,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(Kp,{"Matrix, number":a,"Array, number":function(e,t){return a(r(_i(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);lc(t,e.size()[1]);var a=new n(i(0,e.size()[0]),[t]),o=e.subset(a);return Pr(o)?o:r([[o]])}}),Jp=`count`,Yp=J(Jp,[`typed`,`size`,`prod`],e=>{var{typed:t,size:n,prod:r}=e;return t(Jp,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})}),Xp=`cross`,Zp=J(Xp,[`typed`,`matrix`,`subtract`,`multiply`],e=>{var{typed:t,matrix:n,subtract:r,multiply:i}=e;return t(Xp,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function a(e,t){var n=Math.max(ac(e).length,ac(t).length);e=_c(e),t=_c(t);var a=ac(e),o=ac(t);if(a.length!==1||o.length!==1||a[0]!==3||o[0]!==3)throw RangeError(`Vectors with length 3 expected (Size A = [`+a.join(`, `)+`], B = [`+o.join(`, `)+`])`);var s=[r(i(e[1],t[2]),i(e[2],t[1])),r(i(e[2],t[0]),i(e[0],t[2])),r(i(e[0],t[1]),i(e[1],t[0]))];return n>1?[s]:s}}),Qp=`diag`,$p=J(Qp,[`typed`,`matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(Qp,{Array:function(e){return a(e,0,ac(e),null)},"Array, number":function(e,t){return a(e,t,ac(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),ac(e),null)},"Array, string":function(e,t){return a(e,0,ac(e),t)},"Array, number, string":function(e,t,n){return a(e,t,ac(e),n)},"Array, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),ac(e),n)},Matrix:function(e){return a(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return a(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return a(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return a(e,0,e.size(),t)},"Matrix, number, string":function(e,t,n){return a(e,t,e.size(),n)},"Matrix, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),e.size(),n)}});function a(e,t,n,r){if(!Li(t))throw TypeError(`Second parameter in function diag must be an integer`);var i=t>0?t:0,a=t<0?-t:0;switch(n.length){case 1:return o(e,t,r,n[0],a,i);case 2:return s(e,t,r,n,a,i)}throw RangeError(`Matrix for function diag must be 2 dimensional`)}function o(e,t,n,a,o,s){var c=[a+o,a+s];if(n&&n!==`sparse`&&n!==`dense`)throw TypeError(`Unknown matrix type ${n}"`);var l=n===`sparse`?i.diagonal(c,e,t):r.diagonal(c,e,t);return n===null?l.valueOf():l}function s(e,t,r,i,a,o){if(Pr(e)){var s=e.diagonal(t);return r===null?s.valueOf():r===s.storage()?s:n(s,r)}for(var c=Math.min(i[0]-a,i[1]-o),l=[],u=0;u<c;u++)l[u]=e[u+a][u+o];return r===null?l:n(l)}}),em=J(`filter`,[`typed`],e=>{var{typed:t}=e;return t(`filter`,{"Array, function":tm,"Matrix, function":function(e,t){return e.create(tm(e.valueOf(),t),e.datatype())},"Array, RegExp":Tc,"Matrix, RegExp":function(e,t){return e.create(Tc(e.valueOf(),t),e.datatype())}})});function tm(e,t){var n=Bc(t,e,`filter`);return n.isUnary?wc(e,n.fn):wc(e,function(e,t,r){return n.fn(e,[t],r)})}var nm=`flatten`,rm=J(nm,[`typed`],e=>{var{typed:t}=e;return t(nm,{Array:function(e){return xc(e)},DenseMatrix:function(e){return e.create(xc(e.valueOf(),!0),e.datatype())},SparseMatrix:function(e){throw TypeError(`SparseMatrix is not supported by function flatten because it does not support 1D vectors. Convert to a DenseMatrix or Array first. Example: flatten(x.toArray())`)}})}),im=`forEach`,am=J(im,[`typed`],e=>{var{typed:t}=e;return t(im,{"Array, function":om,"Matrix, function":function(e,t){e.forEach(t)}})});function om(e,t){var n=Bc(t,e,im);Rc(e,n.fn,n.isUnary)}var sm=`getMatrixDataType`,cm=J(sm,[`typed`],e=>{var{typed:t}=e;return t(sm,{Array:function(e){return kc(e,gi)},Matrix:function(e){return e.getDataType()}})}),lm=`identity`,um=J(lm,[`typed`,`config`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(lm,{"":function(){return n.matrix===`Matrix`?r([]):[]},string:function(e){return r(e)},"number | BigNumber":function(e){return c(e,e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, string":function(e,t){return c(e,e,t)},"number | BigNumber, number | BigNumber":function(e,t){return c(e,t,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,n){return c(e,t,n)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}});function s(e,t){switch(e.length){case 0:return t?r(t):[];case 1:return c(e[0],e[0],t);case 2:return c(e[0],e[1],t);default:throw Error(`Vector containing two values expected`)}}function c(e,t,n){var r=Dr(e)||Dr(t)?i:null;if(Dr(e)&&(e=e.toNumber()),Dr(t)&&(t=t.toNumber()),!Li(e)||e<1||!Li(t)||t<1)throw Error(`Parameters in function identity must be positive integers`);var s=r?new i(1):1,c=r?new r(0):0,l=[e,t];if(n){if(n===`sparse`)return o.diagonal(l,s,0,c);if(n===`dense`)return a.diagonal(l,s,0,c);throw TypeError(`Unknown matrix type "${n}"`)}for(var u=dc([],l,c),d=e<t?e:t,f=0;f<d;f++)u[f][f]=s;return u}}),dm=`kron`,fm=J(dm,[`typed`,`matrix`,`multiplyScalar`],e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(dm,{"Matrix, Matrix":function(e,t){return n(a(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return n(a(e.toArray(),t))},"Array, Matrix":function(e,t){return n(a(e,t.toArray()))},"Array, Array":a});function i(e,t){return e.flatMap(e=>t.map(t=>r(e,t)))}function a(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(n<0){var r=ac(e).length,o=ac(t).length;for(n=Math.max(r,o);r++<n;)e=[e];for(;o++<n;)t=[t]}return n===1?i(e,t):e.flatMap(e=>t.map(t=>a(e,t,n-1)))}}),pm=`map`,mm=J(pm,[`typed`],e=>{var{typed:t}=e;return t(pm,{"Array, function":s,"Matrix, function":function(e,t){return e.map(t)},"Array|Matrix, Array|Matrix, ...Array|Matrix|function":(e,t,r)=>n([e,t,...r.slice(0,r.length-1)],r[r.length-1])});function n(e,n){if(typeof n!=`function`)throw Error(`Last argument must be a callback function`);var c=e[0].isMatrix,l=e.map(e=>e.isMatrix?e.size():ac(e)),u=Mc(...l),d=e.length,f=c?(e,t)=>e.get(t):Ic,p=e.map((e,t)=>{var n=l[t].map(()=>0);return e.isMatrix?e.get(n):Ic(e,n)}),m=t.isTypedFunction(n)?o(n,p,u.map(()=>0),e):a(n,d);if(m<2)return r(e,i(m,n,null));var h=c?e.map(t=>t.isMatrix?t.create(Pc(t.toArray(),u),t.datatype()):e[0].create(Pc(t.valueOf(),u))):e.map(e=>e.isMatrix?Pc(e.toArray(),u):Pc(e,u)),g=i(m,n,h),_=(e,t)=>g([e,...h.slice(1).map(e=>f(e,t))],t);return c?h[0].map(_):s(h[0],_)}function r(e,t){var n=e[0],r=e.map(e=>e.isMatrix?e.valueOf():e),i=e.map(e=>e.isMatrix?e.size():ac(e)),a=Mc(...i),o=i.map(e=>a.length-e.length),s=a.length-1,c=t.length>1?[]:null,l=d(r,0);if(n.isMatrix){var u=n.create();return u._data=l,u._size=a,u}else return l;function d(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=a[n],i=Array(r);if(n<s)for(var l=function(t){c&&(c[n]=t),i[t]=d(e.map((e,r)=>o[r]>n?e:e.length===1?e[0]:e[t]),n+1)},u=0;u<r;u++)l(u);else for(var f=function(r){c&&(c[n]=r),i[r]=t(e.map(e=>e.length===1?e[0]:e[r]),c?c.slice():void 0)},p=0;p<r;p++)f(p);return i}}function i(e,t,n){switch(e){case 0:return e=>t(...e);case 1:return(e,n)=>t(...e,n);case 2:return(e,r)=>t(...e,r,...n)}}function a(e,t){var n=e.toString();if(/arguments/.test(n))return 2;var r=n.match(/\(.*?\)/);return/\.\.\./.test(r)||e.length>t+1?2:+(e.length===t+1)}function o(e,n,r,i){return t.resolve(e,[...n,r,...i])===null?t.resolve(e,[...n,r])===null?(t.resolve(e,n),0):1:2}function s(e,t){var n=Bc(t,e,pm);return Lc(e,n.fn,n.isUnary)}}),hm=`diff`,gm=J(hm,[`typed`,`matrix`,`subtract`,`number`],e=>{var{typed:t,matrix:n,subtract:r,number:i}=e;return t(hm,{"Array | Matrix":function(e){return Pr(e)?n(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!Li(t))throw RangeError(`Dimension must be a whole number`);return Pr(e)?n(a(e.toArray(),t)):a(e,t)},"Array, BigNumber":t.referTo(`Array,number`,e=>(t,n)=>e(t,i(n))),"Matrix, BigNumber":t.referTo(`Matrix,number`,e=>(t,n)=>e(t,i(n)))});function a(e,t){if(Pr(e)&&(e=e.toArray()),!Array.isArray(e))throw RangeError(`Array/Matrix does not have that many dimensions`);if(t>0){var n=[];return e.forEach(e=>{n.push(a(e,t-1))}),n}else if(t===0)return o(e);else throw RangeError(`Cannot have negative dimension`)}function o(e){for(var t=[],n=e.length,r=1;r<n;r++)t.push(s(e[r-1],e[r]));return t}function s(e,t){Pr(e)&&(e=e.toArray()),Pr(t)&&(t=t.toArray());var n=Array.isArray(e),i=Array.isArray(t);if(n&&i)return c(e,t);if(!n&&!i)return r(t,e);throw TypeError(`Cannot calculate difference between 1 array and 1 non-array`)}function c(e,t){if(e.length!==t.length)throw RangeError(`Not all sub-arrays have the same length`);for(var n=[],r=e.length,i=0;i<r;i++)n.push(s(e[i],t[i]));return n}}),_m=J(`ones`,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(`ones`,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(1):1;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?dc(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){Dr(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!Li(e)||e<0)throw Error(`Parameters in function ones must be positive integers`)})}});function vm(){throw Error(`No "bignumber" implementation available`)}function ym(){throw Error(`No "fraction" implementation available`)}function bm(){throw Error(`No "matrix" implementation available`)}var xm=`range`,Sm=J(xm,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,smaller:a,smallerEq:o,larger:s,largerEq:c,add:l,isZero:u,isPositive:d}=e;return t(xm,{string:p,"string, boolean":p,number:function(e){throw TypeError(`Too few arguments to function range(): ${e}`)},boolean:function(e){throw TypeError(`Unexpected type of argument 1 to function range(): ${e}, number|bigint|BigNumber|Fraction`)},"number, number":function(e,t){return f(m(e,t,1,!1))},"number, number, number":function(e,t,n){return f(m(e,t,n,!1))},"number, number, boolean":function(e,t,n){return f(m(e,t,1,n))},"number, number, number, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"bigint, bigint|number":function(e,t){return f(m(e,t,1n,!1))},"number, bigint":function(e,t){return f(m(BigInt(e),t,1n,!1))},"bigint, bigint|number, bigint|number":function(e,t,n){return f(m(e,t,BigInt(n),!1))},"number, bigint, bigint|number":function(e,t,n){return f(m(BigInt(e),t,BigInt(n),!1))},"bigint, bigint|number, boolean":function(e,t,n){return f(m(e,t,1n,n))},"number, bigint, boolean":function(e,t,n){return f(m(BigInt(e),t,1n,n))},"bigint, bigint|number, bigint|number, boolean":function(e,t,n,r){return f(m(e,t,BigInt(n),r))},"number, bigint, bigint|number, boolean":function(e,t,n,r){return f(m(BigInt(e),t,BigInt(n),r))},"BigNumber, BigNumber":function(e,t){var n=e.constructor;return f(m(e,t,new n(1),!1))},"BigNumber, BigNumber, BigNumber":function(e,t,n){return f(m(e,t,n,!1))},"BigNumber, BigNumber, boolean":function(e,t,n){var r=e.constructor;return f(m(e,t,new r(1),n))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Fraction, Fraction":function(e,t){return f(m(e,t,1,!1))},"Fraction, Fraction, Fraction":function(e,t,n){return f(m(e,t,n,!1))},"Fraction, Fraction, boolean":function(e,t,n){return f(m(e,t,1,n))},"Fraction, Fraction, Fraction, boolean":function(e,t,n,r){return f(m(e,t,n,r))},"Unit, Unit, Unit":function(e,t,n){return f(m(e,t,n,!1))},"Unit, Unit, Unit, boolean":function(e,t,n,r){return f(m(e,t,n,r))}});function f(e){return n.matrix===`Matrix`?r?r(e):bm():e}function p(e,t){var r=h(e);if(!r)throw SyntaxError(`String "`+e+`" is no valid range`);return n.number===`BigNumber`?(i===void 0&&vm(),f(m(i(r.start),i(r.end),i(r.step)),t)):f(m(r.start,r.end,r.step,t))}function m(e,t,n,r){var i=[];if(u(n))throw Error(`Step must be non-zero`);for(var f=d(n)?r?o:a:r?c:s,p=e;f(p,t);)i.push(p),p=l(p,n);return i}function h(e){var t=e.split(`:`).map(function(e){return Number(e)});if(t.some(function(e){return isNaN(e)}))return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}}),Cm=`reshape`,wm=J(Cm,[`typed`,`isInteger`,`matrix`],e=>{var{typed:t,isInteger:n}=e;return t(Cm,{"Matrix, Array":function(e,t){return e.reshape(t,!0)},"Array, Array":function(e,t){return t.forEach(function(e){if(!n(e))throw TypeError(`Invalid size for dimension: `+e)}),pc(e,t)}})}),Tm=J(`resize`,[`config`,`matrix`],e=>{var{config:t,matrix:n}=e;return function(e,i,a){if(arguments.length!==2&&arguments.length!==3)throw new kf(`resize`,arguments.length,2,3);if(Pr(i)&&(i=i.valueOf()),Dr(i[0])&&(i=i.map(function(e){return Dr(e)?e.toNumber():e})),Pr(e))return e.resize(i,a,!0);if(typeof e==`string`)return r(e,i,a);var o=Array.isArray(e)?!1:t.matrix!==`Array`;if(i.length===0){for(;Array.isArray(e);)e=e[0];return _i(e)}else{Array.isArray(e)||(e=[e]),e=_i(e);var s=dc(e,i,a);return o?n(s):s}};function r(e,t,n){if(n!==void 0){if(typeof n!=`string`||n.length!==1)throw TypeError(`Single character expected as defaultValue`)}else n=` `;if(t.length!==1)throw new rc(t.length,1);var r=t[0];if(typeof r!=`number`||!Li(r))throw TypeError(`Invalid size, must contain positive integers (size: `+Ys(t)+`)`);if(e.length>r)return e.substring(0,r);if(e.length<r){for(var i=e,a=0,o=r-e.length;a<o;a++)i+=n;return i}else return e}}),Em=`rotate`,Dm=J(Em,[`typed`,`multiply`,`rotationMatrix`],e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(Em,{"Array , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e).toArray()},"Matrix , number | BigNumber | Complex | Unit":function(e,t){return i(e,2),n(r(t),e)},"Array, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)},"Matrix, number | BigNumber | Complex | Unit, Array | Matrix":function(e,t,a){return i(e,3),n(r(t,a),e)}});function i(e,t){var n=Array.isArray(e)?ac(e):e.size();if(n.length>2||n.length===2&&n[1]!==1||n[0]!==t)throw RangeError(`Vector must be of dimensions 1x${t}`)}}),Om=`rotationMatrix`,km=J(Om,[`typed`,`config`,`multiplyScalar`,`addScalar`,`unaryMinus`,`norm`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`,`cos`,`sin`],e=>{var{typed:t,config:n,multiplyScalar:r,addScalar:i,unaryMinus:a,norm:o,BigNumber:s,matrix:c,DenseMatrix:l,SparseMatrix:u,cos:d,sin:f}=e;return t(Om,{"":function(){return n.matrix===`Matrix`?c([]):[]},string:function(e){return c(e)},"number | BigNumber | Complex | Unit":function(e){return p(e,n.matrix===`Matrix`?`dense`:void 0)},"number | BigNumber | Complex | Unit, string":function(e,t){return p(e,t)},"number | BigNumber | Complex | Unit, Array":function(e,t){var n=c(t);return m(n),_(e,n,void 0)},"number | BigNumber | Complex | Unit, Matrix":function(e,t){return m(t),_(e,t,t.storage()||(n.matrix===`Matrix`?`dense`:void 0))},"number | BigNumber | Complex | Unit, Array, string":function(e,t,n){var r=c(t);return m(r),_(e,r,n)},"number | BigNumber | Complex | Unit, Matrix, string":function(e,t,n){return m(t),_(e,t,n)}});function p(e,t){var n=Dr(e)?new s(-1):-1,i=d(e),a=f(e);return g([[i,r(n,a)],[a,i]],t)}function m(e){var t=e.size();if(t.length<1||t[0]!==3)throw RangeError(`Vector must be of dimensions 1x3`)}function h(e){return e.reduce((e,t)=>r(e,t))}function g(e,t){if(t){if(t===`sparse`)return new u(e);if(t===`dense`)return new l(e);throw TypeError(`Unknown matrix type "${t}"`)}return e}function _(e,t,n){var r=o(t);if(r===0)throw RangeError(`Rotation around zero vector`);var c=Dr(e)?s:null,l=c?new c(1):1,u=c?new c(-1):-1,p=c?new c(t.get([0])/r):t.get([0])/r,m=c?new c(t.get([1])/r):t.get([1])/r,_=c?new c(t.get([2])/r):t.get([2])/r,v=d(e),y=i(l,a(v)),b=f(e),x=i(v,h([p,p,y])),S=i(h([p,m,y]),h([u,_,b])),C=i(h([p,_,y]),h([m,b])),w=i(h([p,m,y]),h([_,b])),T=i(v,h([m,m,y])),E=i(h([m,_,y]),h([u,p,b])),D=i(h([p,_,y]),h([u,m,b])),O=i(h([m,_,y]),h([p,b])),k=i(v,h([_,_,y]));return g([[x,S,C],[w,T,E],[D,O,k]],n)}}),Am=`row`,jm=J(Am,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(Am,{"Matrix, number":a,"Array, number":function(e,t){return a(r(_i(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);lc(t,e.size()[0]);var a=i(0,e.size()[1]),o=new n([t],a),s=e.subset(o);return Pr(s)?s:r([[s]])}}),Mm=`size`,Nm=J(Mm,[`typed`],e=>{var{typed:t}=e;return t(Mm,{Matrix:e=>e.size(),Array:ac,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),Pm=`squeeze`,Fm=J(Pm,[`typed`],e=>{var{typed:t}=e;return t(Pm,{Array:function(e){return _c(_i(e))},Matrix:function(e){var t=_c(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:function(e){return _i(e)}})}),Im=`subset`,Lm=J(Im,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e;return t(Im,{"Matrix, Index":function(e,t){return uc(t)?n():(cc(e,t),e.subset(t))},"Array, Index":t.referTo(`Matrix, Index`,function(e){return function(t,r){var i=e(n(t),r);return r.isScalar()?i:i.valueOf()}}),"Object, Index":Bm,"string, Index":Rm,"Matrix, Index, any, any":function(e,t,n,r){return uc(t)?e:(cc(e,t),e.clone().subset(t,a(n,t),r))},"Array, Index, any, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i,a){var o=e(n(t),r,i,a);return o.isMatrix?o.valueOf():o}}),"Array, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,r,i){return e(n(t),r,i,void 0).valueOf()}}),"Matrix, Index, any":t.referTo(`Matrix, Index, any, any`,function(e){return function(t,n,r){return e(t,n,r,void 0)}}),"string, Index, string":zm,"string, Index, string, string":zm,"Object, Index, any":Vm});function a(e,t){if(typeof e==`string`)throw Error(`can't boradcast a string`);if(t.isScalar())return e;var n=t.size();if(n.every(e=>e>0))try{return i(e,r(n))}catch{return e}else return e}});function Rm(e,t){if(!zr(t))throw TypeError(`Index expected`);if(uc(t))return``;if(cc(Array.from(e),t),t.size().length!==1)throw new rc(t.size().length,1);var n=e.length;lc(t.min()[0],n),lc(t.max()[0],n);var r=t.dimension(0),i=``;function a(t){i+=e.charAt(t)}return Number.isInteger(r)?a(r):r.forEach(a),i}function zm(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Index expected`);if(uc(t))return e;if(cc(Array.from(e),t),t.size().length!==1)throw new rc(t.size().length,1);if(r!==void 0){if(typeof r!=`string`||r.length!==1)throw TypeError(`Single character expected as defaultValue`)}else r=` `;var i=t.dimension(0);if((Number.isInteger(i)?1:i.size()[0])!==n.length)throw new rc(i.size()[0],n.length);var a=e.length;lc(t.min()[0]),lc(t.max()[0]);for(var o=[],s=0;s<a;s++)o[s]=e.charAt(s);function c(e,t){o[e]=n.charAt(t[0])}if(Number.isInteger(i)?c(i,[0]):i.forEach(c),o.length>a)for(var l=a-1,u=o.length;l<u;l++)o[l]||(o[l]=r);return o.join(``)}function Bm(e,t){if(!uc(t)){if(t.size().length!==1)throw new rc(t.size(),1);var n=t.dimension(0);if(typeof n!=`string`)throw TypeError(`String expected as index to retrieve an object property`);return dr(e,n)}}function Vm(e,t,n){if(uc(t))return e;if(t.size().length!==1)throw new rc(t.size(),1);var r=t.dimension(0);if(typeof r!=`string`)throw TypeError(`String expected as index to retrieve an object property`);var i=_i(e);return fr(i,r,n),i}var Hm=`transpose`,Um=J(Hm,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e;return t(Hm,{Array:e=>r(n(e)).valueOf(),Matrix:r,any:_i});function r(e){var t=e.size(),n;switch(t.length){case 1:n=e.clone();break;case 2:var r=t[0],o=t[1];if(o===0)throw RangeError(`Cannot transpose a 2D matrix with no columns (size: `+Ys(t)+`)`);switch(e.storage()){case`dense`:n=i(e,r,o);break;case`sparse`:n=a(e,r,o);break}break;default:throw RangeError(`Matrix must be a vector or two dimensional (size: `+Ys(t)+`)`)}return n}function i(e,t,n){for(var r=e._data,i=[],a,o=0;o<n;o++){a=i[o]=[];for(var s=0;s<t;s++)a[s]=_i(r[s][o])}return e.createDenseMatrix({data:i,size:[n,t],datatype:e._datatype})}function a(e,t,n){for(var r=e._values,i=e._index,a=e._ptr,o=r?[]:void 0,s=[],c=[],l=[],u=0;u<t;u++)l[u]=0;var d,f,p;for(d=0,f=i.length;d<f;d++)l[i[d]]++;for(var m=0,h=0;h<t;h++)c.push(m),m+=l[h],l[h]=c[h];for(c.push(m),p=0;p<n;p++)for(var g=a[p],_=a[p+1],v=g;v<_;v++){var y=l[i[v]]++;s[y]=p,r&&(o[y]=_i(r[v]))}return e.createSparseMatrix({values:o,index:s,ptr:c,size:[n,t],datatype:e._datatype})}}),Wm=`ctranspose`,Gm=J(Wm,[`typed`,`transpose`,`conj`],e=>{var{typed:t,transpose:n,conj:r}=e;return t(Wm,{any:function(e){return r(n(e))}})}),Km=`zeros`,qm=J(Km,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(Km,{"":function(){return n.matrix===`Array`?a([]):a([],`default`)},"...number | BigNumber | string":function(e){return typeof e[e.length-1]==`string`?a(e,e.pop()):n.matrix===`Array`?a(e):a(e,`default`)},Array:a,Matrix:function(e){var t=e.storage();return a(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return a(e.valueOf(),t)}});function a(e,t){var n=o(e)?new i(0):0;if(s(e),t){var a=r(t);return e.length>0?a.resize(e,n):a}else{var c=[];return e.length>0?dc(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){Dr(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!Li(e)||e<0)throw Error(`Parameters in function zeros must be positive integers`)})}}),Jm=`fft`,Ym=J(Jm,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`divideScalar`,`exp`,`tau`,`i`,`dotDivide`,`conj`,`pow`,`ceil`,`log2`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,divideScalar:a,exp:o,tau:s,i:c,dotDivide:l,conj:u,pow:d,ceil:f,log2:p}=e;return t(Jm,{Array:m,Matrix:function(e){return e.create(m(e.valueOf()),e.datatype())}});function m(e){var t=ac(e);return t.length===1?_(e,t[0]):h(e.map(e=>m(e,t.slice(1))),0)}function h(e,t){var n=ac(e);if(t!==0)return Array(n[0]).fill(0).map((n,r)=>h(e[r],t-1));if(n.length===1)return _(e);function r(e){var t=ac(e);return Array(t[1]).fill(0).map((n,r)=>Array(t[0]).fill(0).map((t,n)=>e[n][r]))}return r(h(r(e),1))}function g(e){for(var t=e.length,n=o(a(i(-1,i(c,s)),t)),r=[],h=1-t;h<t;h++)r.push(d(n,a(d(h,2),2)));for(var g=d(2,f(p(t+t-1))),v=[...Array(t).fill(0).map((n,a)=>i(e[a],r[t-1+a])),...Array(g-t).fill(0)],y=[...Array(t+t-1).fill(0).map((e,t)=>a(1,r[t])),...Array(g-(t+t-1)).fill(0)],b=_(v),x=_(y),S=l(u(m(u(Array(g).fill(0).map((e,t)=>i(b[t],x[t]))))),g),C=[],w=t-1;w<t+t-1;w++)C.push(i(S[w],r[w]));return C}function _(e){var t=e.length;if(t===1)return[e[0]];if(t%2==0){for(var n=[..._(e.filter((e,t)=>t%2==0),t/2),..._(e.filter((e,t)=>t%2==1),t/2)],l=0;l<t/2;l++){var u=n[l],d=i(n[l+t/2],o(i(i(s,c),a(-l,t))));n[l]=r(u,d),n[l+t/2]=r(u,i(-1,d))}return n}else return g(e)}}),Xm=`ifft`,Zm=J(Xm,[`typed`,`fft`,`dotDivide`,`conj`],e=>{var{typed:t,fft:n,dotDivide:r,conj:i}=e;return t(Xm,{"Array | Matrix":function(e){var t=Pr(e)?e.size():ac(e);return r(i(n(i(e))),t.reduce((e,t)=>e*t,1))}})});function Qm(e){"@babel/helpers - typeof";return Qm=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Qm(e)}function $m(e,t){if(Qm(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Qm(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function eh(e){var t=$m(e,`string`);return Qm(t)==`symbol`?t:t+``}function th(e,t,n){return(t=eh(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function rh(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?nh(Object(n),!0).forEach(function(t){th(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nh(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var ih=J(`solveODE`,[`typed`,`add`,`subtract`,`multiply`,`divide`,`max`,`map`,`abs`,`isPositive`,`isNegative`,`larger`,`smaller`,`matrix`,`bignumber`,`unaryMinus`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,max:o,map:s,abs:c,isPositive:l,isNegative:u,larger:d,smaller:f,matrix:p,bignumber:m,unaryMinus:h}=e;function g(e){return function(t,p,g,_){if(!(p.length===2&&(p.every(S)||p.every(jr))))throw Error(`"tspan" must be an Array of two numeric values or two units [tStart, tEnd]`);var v=p[0],y=p[1],C=d(y,v),w=_.firstStep;if(w!==void 0&&!l(w))throw Error(`"firstStep" must be positive`);var T=_.maxStep;if(T!==void 0&&!l(T))throw Error(`"maxStep" must be positive`);var E=_.minStep;if(E&&u(E))throw Error(`"minStep" must be positive or zero`);var D=[v,y,w,E,T].filter(e=>e!==void 0);if(!(D.every(S)||D.every(jr)))throw Error(`Inconsistent type of "t" dependant variables`);for(var O=1,k=_.tol?_.tol:1e-4,A=_.minDelta?_.minDelta:.2,j=_.maxDelta?_.maxDelta:5,M=_.maxIter?_.maxIter:1e4,N=[v,y,...g,T,E].some(Dr),[P,F,I,L]=N?[m(e.a),m(e.c),m(e.b),m(e.bp)]:[e.a,e.c,e.b,e.bp],R=w?C?w:h(w):a(r(y,v),O),z=[v],B=[g],V=r(I,L),ee=0,te=0,H=b(C),ne=x(C);H(z[ee],y);){var re=[];R=ne(z[ee],y,R),re.push(t(z[ee],B[ee]));for(var ie=1;ie<F.length;++ie)re.push(t(n(z[ee],i(F[ie],R)),n(B[ee],i(R,P[ie],re))));var U=o(c(s(i(V,re),e=>jr(e)?e.value:e)));U<k&&k/U>1/4&&(z.push(n(z[ee],R)),B.push(n(B[ee],i(R,I,re))),ee++);var ae=.84*(k/U)**(1/5);if(f(ae,A)?ae=A:d(ae,j)&&(ae=j),ae=N?m(ae):ae,R=i(R,ae),T&&d(c(R),T)?R=C?T:h(T):E&&f(c(R),E)&&(R=C?E:h(E)),te++,te>M)throw Error(`Maximum number of iterations reached, try changing options`)}return{t:z,y:B}}}function _(e,t,n,r){return g({a:[[],[1/2],[0,3/4],[2/9,1/3,4/9]],c:[null,1/2,3/4,1],b:[2/9,1/3,4/9,0],bp:[7/24,1/4,1/3,1/8]})(e,t,n,r)}function v(e,t,n,r){return g({a:[[],[1/5],[3/40,9/40],[44/45,-56/15,32/9],[19372/6561,-25360/2187,64448/6561,-212/729],[9017/3168,-355/33,46732/5247,49/176,-5103/18656],[35/384,0,500/1113,125/192,-2187/6784,11/84]],c:[null,1/5,3/10,4/5,8/9,1,1],b:[35/384,0,500/1113,125/192,-2187/6784,11/84,0],bp:[5179/57600,0,7571/16695,393/640,-92097/339200,187/2100,1/40]})(e,t,n,r)}function y(e,t,n,r){var i=r.method?r.method:`RK45`,a={RK23:_,RK45:v};if(i.toUpperCase()in a){var o=rh({},r);return delete o.method,a[i.toUpperCase()](e,t,n,o)}else{var s=Object.keys(a).map(e=>`"${e}"`),c=`${s.slice(0,-1).join(`, `)} and ${s.slice(-1)}`;throw Error(`Unavailable method "${i}". Available methods are ${c}`)}}function b(e){return e?f:d}function x(e){var t=e?d:f;return function(e,i,a){return t(n(e,a),i)?r(i,e):a}}function S(e){return Dr(e)||Er(e)}function C(e,t,n,r){var i=y(e,t.toArray(),n.toArray(),r);return{t:p(i.t),y:p(i.y)}}return t(`solveODE`,{"function, Array, Array, Object":y,"function, Matrix, Matrix, Object":C,"function, Array, Array":(e,t,n)=>y(e,t,n,{}),"function, Matrix, Matrix":(e,t,n)=>C(e,t,n,{}),"function, Array, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t,[n],{});return{t:r.t,y:r.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit":(e,t,n)=>{var r=y(e,t.toArray(),[n],{});return{t:p(r.t),y:p(r.y.map(e=>e[0]))}},"function, Array, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t,[n],r);return{t:i.t,y:i.y.map(e=>e[0])}},"function, Matrix, number | BigNumber | Unit, Object":(e,t,n,r)=>{var i=y(e,t.toArray(),[n],r);return{t:p(i.t),y:p(i.y.map(e=>e[0]))}}})}),ah=J(`erf`,[`typed`],e=>{var{typed:t}=e;return t(`name`,{number:function(e){var t=Math.abs(e);return t>=uh?zi(e):t<=oh?zi(e)*n(t):t<=4?zi(e)*(1-r(t)):zi(e)*(1-i(t))},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))});function n(e){var t=e*e,n=ch[0][4]*t,r=t,i;for(i=0;i<3;i+=1)n=(n+ch[0][i])*t,r=(r+lh[0][i])*t;return e*(n+ch[0][3])/(r+lh[0][3])}function r(e){var t=ch[1][8]*e,n=e,r;for(r=0;r<7;r+=1)t=(t+ch[1][r])*e,n=(n+lh[1][r])*e;var i=(t+ch[1][7])/(n+lh[1][7]),a=parseInt(e*16)/16,o=(e-a)*(e+a);return Math.exp(-a*a)*Math.exp(-o)*i}function i(e){var t=1/(e*e),n=ch[2][5]*t,r=t,i;for(i=0;i<4;i+=1)n=(n+ch[2][i])*t,r=(r+lh[2][i])*t;var a=t*(n+ch[2][4])/(r+lh[2][4]);a=(sh-a)/e,t=parseInt(e*16)/16;var o=(e-t)*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}}),oh=.46875,sh=.5641895835477563,ch=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],lh=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]],uh=2**53,dh=`zeta`,fh=J(dh,[`typed`,`config`,`multiply`,`pow`,`divide`,`factorial`,`equal`,`smallerEq`,`isBounded`,`isNegative`,`gamma`,`sin`,`subtract`,`add`,`?Complex`,`?BigNumber`,`pi`],e=>{var{typed:t,config:n,multiply:r,pow:i,divide:a,factorial:o,equal:s,smallerEq:c,isBounded:l,isNegative:u,gamma:d,sin:f,subtract:p,add:m,Complex:h,BigNumber:g,pi:_}=e;return t(dh,{number:e=>v(e,e=>e,()=>20),BigNumber:e=>v(e,e=>new g(e),()=>Math.abs(Math.log10(n.relTol))),Complex:y});function v(e,t,n){return s(e,0)?t(-.5):s(e,1)?t(NaN):l(e)?b(e,t,n,e=>e):u(e)?t(NaN):t(1)}function y(e){return e.re===0&&e.im===0?new h(-.5):e.re===1?new h(NaN,NaN):e.re===1/0&&e.im===0?new h(1):e.im===1/0||e.re===-1/0?new h(NaN,NaN):b(e,e=>e,e=>Math.round(1.3*15+.9*Math.abs(e.im)),e=>e.re)}function b(e,t,n,o){var s=n(e);if(o(e)>-(s-1)/2)return S(e,t(s),t);var c=r(i(2,e),i(t(_),p(e,1)));return c=r(c,f(r(a(t(_),2),e))),c=r(c,d(p(1,e))),r(c,b(p(1,e),t,n,o))}function x(e,t){for(var n=e,s=e;c(s,t);s=m(s,1)){var l=a(r(o(m(t,p(s,1))),i(4,s)),r(o(p(t,s)),o(r(2,s))));n=m(n,l)}return r(t,n)}function S(e,t,n){for(var o=a(1,r(x(n(0),t),p(1,i(2,p(1,e))))),s=n(0),l=n(1);c(l,t);l=m(l,1))s=m(s,a(r((-1)**(l-1),x(l,t)),i(l,e)));return r(o,s)}}),ph=`mode`,mh=J(ph,[`typed`,`isNaN`,`isNumeric`],e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(ph,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(e=xc(e.valueOf()),e.length===0)throw Error(`Cannot calculate mode of an empty array`);for(var t={},i=[],a=0,o=0;o<e.length;o++){var s=e[o];if(r(s)&&n(s))throw Error(`Cannot calculate mode of an array containing NaN values`);s in t||(t[s]=0),t[s]++,t[s]===a?i.push(s):t[s]>a&&(a=t[s],i=[s])}return i}});function hh(e,t,n){var r;return String(e).includes(`Unexpected type`)?(r=arguments.length>2?` (type: `+gi(n)+`, value: `+JSON.stringify(n)+`)`:` (type: `+e.data.actual+`)`,TypeError(`Cannot calculate `+t+`, unexpected type of argument`+r)):String(e).includes(`complex numbers`)?(r=arguments.length>2?` (type: `+gi(n)+`, value: `+JSON.stringify(n)+`)`:``,TypeError(`Cannot calculate `+t+`, no ordering relation is defined for complex numbers`+r)):e}var gh=`prod`,_h=J(gh,[`typed`,`config`,`multiplyScalar`,`numeric`],e=>{var{typed:t,config:n,multiplyScalar:r,numeric:i}=e;return t(gh,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`prod(A, dim) is not yet supported`)},"...":function(e){return a(e)}});function a(e){var t;if(Zc(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw hh(t,`prod`,e)}}),typeof t==`string`&&(t=i(t,Ri(t,n))),t===void 0)throw Error(`Cannot calculate prod of an empty array`);return t}}),vh=`format`,yh=J(vh,[`typed`],e=>{var{typed:t}=e;return t(vh,{any:Ys,"any, Object | function | number | BigNumber":Ys})}),bh=`bin`,xh=J(bh,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(bh,{"number | BigNumber":function(e){return n(e,{notation:`bin`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`bin`,wordSize:t})}})}),Sh=`oct`,Ch=J(Sh,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(Sh,{"number | BigNumber":function(e){return n(e,{notation:`oct`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`oct`,wordSize:t})}})}),wh=`hex`,Th=J(wh,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(wh,{"number | BigNumber":function(e){return n(e,{notation:`hex`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`hex`,wordSize:t})}})}),Eh=/\$([\w.]+)/g,Dh=`print`,Oh=J(Dh,[`typed`],e=>{var{typed:t}=e;return t(Dh,{"string, Object | Array":kh,"string, Object | Array, number | Object":kh})});function kh(e,t,n){return e.replace(Eh,function(e,r){var i=r.split(`.`),a=t[i.shift()];for(a!==void 0&&a.isMatrix&&(a=a.toArray());i.length&&a!==void 0;){var o=i.shift();a=o?a[o]:a+`.`}return a===void 0?e:Mr(a)?a:Ys(a,n)})}var Ah=`to`,jh=J(Ah,[`typed`,`matrix`,`concat`],e=>{var{typed:t,matrix:n,concat:r}=e;return t(Ah,{"Unit, Unit | string":(e,t)=>e.to(t)},Cf({typed:t,matrix:n,concat:r})({Ds:!0}))}),Mh=`toBest`,Nh=J(Mh,[`typed`],e=>{var{typed:t}=e;return t(Mh,{Unit:e=>e.toBest(),"Unit, string":(e,t)=>e.toBest(t.split(`,`)),"Unit, string, Object":(e,t,n)=>e.toBest(t.split(`,`),n),"Unit, Array":(e,t)=>e.toBest(t),"Unit, Array, Object":(e,t,n)=>e.toBest(t,n)})}),Ph=`isPrime`,Fh=J(Ph,[`typed`],e=>{var{typed:t}=e;return t(Ph,{number:function(e){if(e<=3)return e>1;if(e%2==0||e%3==0)return!1;for(var t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0},bigint:function(e){if(e<=3n)return e>1n;if(e%2n==0n||e%3n==0n)return!1;for(var t=5n;t*t<=e;t+=6n)if(e%t===0n||e%(t+2n)===0n)return!1;return!0},BigNumber:function(e){if(e.lte(3))return e.gt(1);if(e.mod(2).eq(0)||e.mod(3).eq(0))return!1;if(e.lt(2**32)){for(var t=e.toNumber(),n=5;n*n<=t;n+=6)if(t%n===0||t%(n+2)===0)return!1;return!0}function r(e,t,n){for(var r=1;!t.eq(0);)t.mod(2).eq(0)?(t=t.div(2),e=e.mul(e).mod(n)):(t=t.sub(1),r=e.mul(r).mod(n));return r}e=new(e.constructor.clone({precision:e.toFixed(0).length*2}))(e);for(var i=0,a=e.sub(1);a.mod(2).eq(0);)a=a.div(2),i+=1;var o=null;if(e.lt(`3317044064679887385961981`))o=[2,3,5,7,11,13,17,19,23,29,31,37,41].filter(t=>t<e);else{var s=Math.min(e.toNumber()-2,Math.floor(2*(e.toFixed(0).length*Math.log(10))**2));o=[];for(var c=2;c<=s;c+=1)o.push(s)}for(var l=0;l<o.length;l+=1){var u=o[l],d=r(e.sub(e).add(u),a,e);if(!d.eq(1)){for(var f=0,p=d;!p.eq(e.sub(1));f+=1,p=p.mul(p).mod(e))if(f===i-1)return!1}}return!0},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),Ih=J(`numeric`,[`number`,`?bignumber`,`?fraction`],e=>{var{number:t,bignumber:n,fraction:r}=e,i={string:!0,number:!0,BigNumber:!0,Fraction:!0},a={number:e=>t(e),BigNumber:n?e=>n(e):vm,bigint:e=>BigInt(e),Fraction:r?e=>r(e):ym};return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`number`;if((arguments.length>2?arguments[2]:void 0)!==void 0)throw SyntaxError(`numeric() takes one or two arguments`);var n=gi(e);if(!(n in i))throw TypeError(`Cannot convert `+e+` of type "`+n+`"; valid input types are `+Object.keys(i).join(`, `));if(!(t in a))throw TypeError(`Cannot convert `+e+` to type "`+t+`"; valid output types are `+Object.keys(a).join(`, `));return t===n?e:a[t](e)}}),Lh=`divideScalar`,Rh=J(Lh,[`typed`,`numeric`],e=>{var{typed:t,numeric:n}=e;return t(Lh,{"number, number":function(e,t){return e/t},"Complex, Complex":function(e,t){return e.div(t)},"BigNumber, BigNumber":function(e,t){return e.div(t)},"bigint, bigint":function(e,t){return e/t},"Fraction, Fraction":function(e,t){return e.div(t)},"Unit, number | Complex | Fraction | BigNumber | Unit":(e,t)=>e.divide(t),"number | Fraction | Complex | BigNumber, Unit":(e,t)=>t.divideInto(e)})}),zh=`pow`,Bh=J(zh,[`typed`,`config`,`identity`,`multiply`,`matrix`,`inv`,`fraction`,`number`,`Complex`],e=>{var{typed:t,config:n,identity:r,multiply:i,matrix:a,inv:o,number:s,fraction:c,Complex:l}=e;return t(zh,{"number, number":u,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(e,t){return t.isInteger()||e>=0||n.predictable?e.pow(t):new l(e.toNumber(),0).pow(t.toNumber(),0)},"bigint, bigint":(e,t)=>e**t,"Fraction, Fraction":function(e,t){var r=e.pow(t);if(r!=null)return r;if(n.predictable)throw Error(`Result of pow is non-rational and cannot be expressed as a fraction`);return u(e.valueOf(),t.valueOf())},"Array, number":d,"Array, BigNumber":function(e,t){return d(e,t.toNumber())},"Matrix, number":f,"Matrix, BigNumber":function(e,t){return f(e,t.toNumber())},"Unit, number | BigNumber":function(e,t){return e.pow(t)}});function u(e,t){if(n.predictable&&!Li(t)&&e<0)try{var r=c(t),i=s(r);if((t===i||Math.abs((t-i)/t)<1e-14)&&r.d%2n==1n)return(r.n%2n==0n?1:-1)*(-e)**+t}catch{}return n.predictable&&(e<-1&&t===1/0||e>-1&&e<0&&t===-1/0)?NaN:Li(t)||e>=0||n.predictable?kl(e,t):e*e<1&&t===1/0||e*e>1&&t===-1/0?0:new l(e,0).pow(t,0)}function d(e,t){if(!Li(t))throw TypeError(`For A^b, b must be an integer (value is `+t+`)`);var n=ac(e);if(n.length!==2)throw Error(`For A^b, A must be 2 dimensional (A has `+n.length+` dimensions)`);if(n[0]!==n[1])throw Error(`For A^b, A must be square (size is `+n[0]+`x`+n[1]+`)`);if(t<0)try{return d(o(e),-t)}catch(e){throw e.message===`Cannot calculate inverse, determinant is zero`?TypeError(`For A^b, when A is not invertible, b must be a positive integer (value is `+t+`)`):e}for(var a=r(n[0]).valueOf(),s=e;t>=1;)(t&1)==1&&(a=i(s,a)),t>>=1,s=i(s,s);return a}function f(e,t){return a(d(e.valueOf(),t))}}),Vh=`Number of decimals in function round must be an integer`,Hh=`round`,Uh=J(Hh,[`typed`,`config`,`matrix`,`equalScalar`,`zeros`,`BigNumber`,`DenseMatrix`],e=>{var{typed:t,config:n,matrix:r,equalScalar:i,zeros:a,BigNumber:o,DenseMatrix:s}=e,c=qd({typed:t,equalScalar:i}),l=Jd({typed:t,DenseMatrix:s}),u=Yd({typed:t});function d(e){return Math.abs(Ji(e).exponent)}return t(Hh,{number:function(e){var t=Al(e,d(n.relTol));return Al(na(e,t,n.relTol,n.absTol)?t:e)},"number, number":function(e,t){var r=d(n.relTol);if(t>=r)return Al(e,t);var i=Al(e,r);return Al(na(e,i,n.relTol,n.absTol)?i:e,t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Vh);return new o(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw TypeError(Vh);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Vh);var n=t.toNumber();return e.round(n)},BigNumber:function(e){var t=new o(e).toDecimalPlaces(d(n.relTol));return(Ru(e,t,n.relTol,n.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Vh);var r=d(n.relTol);if(t>=r)return e.toDecimalPlaces(t.toNumber());var i=e.toDecimalPlaces(r);return(Ru(e,i,n.relTol,n.absTol)?i:e).toDecimalPlaces(t.toNumber())},bigint:e=>e,"bigint, number":(e,t)=>e,"bigint, BigNumber":(e,t)=>e,Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw TypeError(Vh);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(Vh);return e.round(t.toNumber())},"Unit, number, Unit":t.referToSelf(e=>function(t,n,r){var i=t.toNumeric(r);return r.multiply(e(i,n))}),"Unit, BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>e(t,n.toNumber(),r)),"Array | Matrix, number | BigNumber, Unit":t.referToSelf(e=>(t,n,r)=>Qc(t,t=>e(t,n,r),!0)),"Array | Matrix | Unit, Unit":t.referToSelf(e=>(t,n)=>e(t,0,n)),"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e,!0)),"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>c(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>u(t,n,e,!1)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>u(r(t),n,e,!1).valueOf()),"number | Complex | BigNumber | Fraction, SparseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):l(n,t,e,!0)),"number | Complex | BigNumber | Fraction, DenseMatrix":t.referToSelf(e=>(t,n)=>i(t,0)?a(n.size(),n.storage()):u(n,t,e,!0)),"number | Complex | BigNumber | Fraction, Array":t.referToSelf(e=>(t,n)=>u(r(n),t,e,!0).valueOf())})}),Wh=`log`,Gh=[`config`,`typed`,`typeOf`,`divideScalar`,`Complex`],Kh=Math.log(16),qh=J(Wh,Gh,e=>{var{typed:t,typeOf:n,config:r,divideScalar:i,Complex:a}=e;function o(e){return e.log()}function s(e){return o(new a(e,0))}return t(Wh,{number:function(e){return e>=0||r.predictable?yl(e):s(e)},bigint:zf(Kh,yl,r,s),Complex:o,BigNumber:function(e){return!e.isNegative()||r.predictable?e.ln():s(e.toNumber())},"any, any":t.referToSelf(e=>(t,r)=>{if(n(t)===`Fraction`&&n(r)===`Fraction`){var a=t.log(r);if(a!==null)return a}return i(e(t),e(r))})})}),Jh=`log1p`,Yh=J(Jh,[`typed`,`config`,`divideScalar`,`log`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,log:i,Complex:a}=e;return t(Jh,{number:function(e){return e>=-1||n.predictable?Hi(e):o(new a(e,0))},Complex:o,BigNumber:function(e){var t=e.plus(1);return!t.isNegative()||n.predictable?t.ln():o(new a(e.toNumber(),0))},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e)),"any, any":t.referToSelf(e=>(t,n)=>r(e(t),i(n)))});function o(e){var t=e.re+1;return new a(Math.log(Math.sqrt(t*t+e.im*e.im)),Math.atan2(e.im,t))}}),Xh=`nthRoots`,Zh=J(Xh,[`config`,`typed`,`divideScalar`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,Complex:i}=e,a=[function(e){return new i(e,0)},function(e){return new i(0,e)},function(e){return new i(-e,0)},function(e){return new i(0,-e)}];function o(e,t){if(t<0)throw Error(`Root must be greater than zero`);if(t===0)throw Error(`Root must be non-zero`);if(t%1!=0)throw Error(`Root must be an integer`);if(e===0||e.abs()===0)return[new i(0,0)];var n=typeof e==`number`,r;(n||e.re===0||e.im===0)&&(r=n?2*(e<0):e.im===0?2*(e.re<0):2*(e.im<0)+1);for(var o=e.arg(),s=e.abs(),c=[],l=s**(1/t),u=0;u<t;u++){var d=(r+4*u)/t;if(d===Math.round(d)){c.push(a[d%4](l));continue}c.push(new i({r:l,phi:(o+2*Math.PI*u)/t}))}return c}return t(Xh,{Complex:function(e){return o(e,2)},"Complex, number":o})}),Qh=`dotPow`,$h=J(Qh,[`typed`,`equalScalar`,`matrix`,`pow`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,equalScalar:n,matrix:r,pow:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=vf({typed:t}),l=Tp({typed:t,SparseMatrix:s}),u=qd({typed:t,equalScalar:n}),d=Jd({typed:t,DenseMatrix:a}),f=Cf({typed:t,matrix:r,concat:o}),p={};for(var m in i.signatures)Object.prototype.hasOwnProperty.call(i.signatures,m)&&!m.includes(`Matrix`)&&!m.includes(`Array`)&&(p[m]=i.signatures[m]);return t(Qh,f({elop:t(p),SS:l,DS:c,Ss:u,sS:d}))}),eg=`dotDivide`,tg=J(eg,[`typed`,`matrix`,`equalScalar`,`divideScalar`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,divideScalar:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=_f({typed:t,equalScalar:r}),l=vf({typed:t}),u=Tp({typed:t,SparseMatrix:s}),d=qd({typed:t,equalScalar:r}),f=Jd({typed:t,DenseMatrix:a});return t(eg,Cf({typed:t,matrix:n,concat:o})({elop:i,SS:u,DS:l,SD:c,Ss:d,sS:f}))});function ng(e){var{DenseMatrix:t}=e;return function(e,n,r){var i=e.size();if(i.length!==2)throw RangeError(`Matrix must be two dimensional (size: `+Ys(i)+`)`);var a=i[0];if(a!==i[1])throw RangeError(`Matrix must be square (size: `+Ys(i)+`)`);var o=[];if(Pr(n)){var s=n.size(),c=n._data;if(s.length===1){if(s[0]!==a)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);for(var l=0;l<a;l++)o[l]=[c[l]];return new t({data:o,size:[a,1],datatype:n._datatype})}if(s.length===2){if(s[0]!==a||s[1]!==1)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);if(Ir(n)){if(r){o=[];for(var u=0;u<a;u++)o[u]=[c[u][0]];return new t({data:o,size:[a,1],datatype:n._datatype})}return n}if(Lr(n)){for(var d=0;d<a;d++)o[d]=[0];for(var f=n._values,p=n._index,m=n._ptr,h=m[1],g=m[0];g<h;g++){var _=p[g];o[_][0]=f[g]}return new t({data:o,size:[a,1],datatype:n._datatype})}}throw RangeError(`Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.`)}if(Nr(n)){var v=ac(n);if(v.length===1){if(v[0]!==a)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);for(var y=0;y<a;y++)o[y]=[n[y]];return new t({data:o,size:[a,1]})}if(v.length===2){if(v[0]!==a||v[1]!==1)throw RangeError(`Dimension mismatch. Matrix columns must match vector length.`);for(var b=0;b<a;b++)o[b]=[n[b][0]];return new t({data:o,size:[a,1]})}throw RangeError(`Dimension mismatch. The right side has to be either 1- or 2-dimensional vector.`)}}}var rg=`lsolve`,ig=J(rg,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=ng({DenseMatrix:s});return t(rg,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=0;p<u;p++){var m=n[p][0]||0,h=void 0;if(o(m,0))h=0;else{var g=f[p][p];if(o(g,0))throw Error(`Linear system cannot be solved since matrix is singular`);h=r(m,g);for(var _=p+1;_<l;_++)n[_]=[a(n[_][0]||0,i(h,f[_][p]))]}d[p]=[h]}return new s({data:d,size:[l,1]})}function u(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=[],h=0;h<u;h++){var g=n[h][0]||0;if(o(g,0))m[h]=[0];else{for(var _=0,v=[],y=[],b=p[h],x=p[h+1],S=b;S<x;S++){var C=f[S];C===h?_=d[S]:C>h&&(v.push(d[S]),y.push(C))}if(o(_,0))throw Error(`Linear system cannot be solved since matrix is singular`);for(var w=r(g,_),T=0,E=y.length;T<E;T++){var D=y[T];n[D]=[a(n[D][0]||0,i(w,v[T]))]}m[h]=[w]}}return new s({data:m,size:[l,1]})}}),ag=`usolve`,og=J(ag,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=ng({DenseMatrix:s});return t(ag,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).valueOf()}});function l(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=[],f=e._data,p=u-1;p>=0;p--){var m=n[p][0]||0,h=void 0;if(o(m,0))h=0;else{var g=f[p][p];if(o(g,0))throw Error(`Linear system cannot be solved since matrix is singular`);h=r(m,g);for(var _=p-1;_>=0;_--)n[_]=[a(n[_][0]||0,i(h,f[_][p]))]}d[p]=[h]}return new s({data:d,size:[l,1]})}function u(e,t){t=c(e,t,!0);for(var n=t._data,l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=[],h=u-1;h>=0;h--){var g=n[h][0]||0;if(o(g,0))m[h]=[0];else{for(var _=0,v=[],y=[],b=p[h],x=p[h+1]-1;x>=b;x--){var S=f[x];S===h?_=d[x]:S<h&&(v.push(d[x]),y.push(S))}if(o(_,0))throw Error(`Linear system cannot be solved since matrix is singular`);for(var C=r(g,_),w=0,T=y.length;w<T;w++){var E=y[w];n[E]=[a(n[E][0],i(C,v[w]))]}m[h]=[C]}}return new s({data:m,size:[l,1]})}}),sg=`lsolveAll`,cg=J(sg,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=ng({DenseMatrix:s});return t(sg,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1],f=0;f<d;f++)for(var p=n.length,m=0;m<p;m++){var h=n[m];if(!o(l[f][f],0)){h[f]=r(h[f],l[f][f]);for(var g=f+1;g<d;g++)h[g]=a(h[g],i(h[f],l[g][f]))}else if(!o(h[f],0)){if(m===0)return[];n.splice(m,1),--m,--p}else if(m===0){var _=[...h];_[f]=1;for(var v=f+1;v<d;v++)_[v]=a(_[v],l[v][f]);n.push(_)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=0;m<u;m++)for(var h=n.length,g=0;g<h;g++){for(var _=n[g],v=[],y=[],b=p[m],x=p[m+1],S=0,C=b;C<x;C++){var w=f[C];w===m?S=d[C]:w>m&&(v.push(d[C]),y.push(w))}if(!o(S,0)){_[m]=r(_[m],S);for(var T=0,E=y.length;T<E;T++){var D=y[T];_[D]=a(_[D],i(_[m],v[T]))}}else if(!o(_[m],0)){if(g===0)return[];n.splice(g,1),--g,--h}else if(g===0){var O=[..._];O[m]=1;for(var k=0,A=y.length;k<A;k++){var j=y[k];O[j]=a(O[j],v[k])}n.push(O)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[l,1]}))}}),lg=`usolveAll`,ug=J(lg,[`typed`,`matrix`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`equalScalar`,`DenseMatrix`],e=>{var{typed:t,matrix:n,divideScalar:r,multiplyScalar:i,subtractScalar:a,equalScalar:o,DenseMatrix:s}=e,c=ng({DenseMatrix:s});return t(lg,{"SparseMatrix, Array | Matrix":function(e,t){return u(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return l(e,t)},"Array, Array | Matrix":function(e,t){return l(n(e),t).map(e=>e.valueOf())}});function l(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._data,u=e._size[0],d=e._size[1]-1;d>=0;d--)for(var f=n.length,p=0;p<f;p++){var m=n[p];if(!o(l[d][d],0)){m[d]=r(m[d],l[d][d]);for(var h=d-1;h>=0;h--)m[h]=a(m[h],i(m[d],l[h][d]))}else if(!o(m[d],0)){if(p===0)return[];n.splice(p,1),--p,--f}else if(p===0){var g=[...m];g[d]=1;for(var _=d-1;_>=0;_--)g[_]=a(g[_],l[_][d]);n.push(g)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[u,1]}))}function u(e,t){for(var n=[c(e,t,!0)._data.map(e=>e[0])],l=e._size[0],u=e._size[1],d=e._values,f=e._index,p=e._ptr,m=u-1;m>=0;m--)for(var h=n.length,g=0;g<h;g++){for(var _=n[g],v=[],y=[],b=p[m],x=p[m+1],S=0,C=x-1;C>=b;C--){var w=f[C];w===m?S=d[C]:w<m&&(v.push(d[C]),y.push(w))}if(!o(S,0)){_[m]=r(_[m],S);for(var T=0,E=y.length;T<E;T++){var D=y[T];_[D]=a(_[D],i(_[m],v[T]))}}else if(!o(_[m],0)){if(g===0)return[];n.splice(g,1),--g,--h}else if(g===0){var O=[..._];O[m]=1;for(var k=0,A=y.length;k<A;k++){var j=y[k];O[j]=a(O[j],v[k])}n.push(O)}}return n.map(e=>new s({data:e.map(e=>[e]),size:[l,1]}))}}),dg=J(`matAlgo08xS0Sid`,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return function(e,r,i){var a=e._values,o=e._index,s=e._ptr,c=e._size,l=e._datatype||e._data===void 0?e._datatype:e.getDataType(),u=r._values,d=r._index,f=r._ptr,p=r._size,m=r._datatype||r._data===void 0?r._datatype:r.getDataType();if(c.length!==p.length)throw new rc(c.length,p.length);if(c[0]!==p[0]||c[1]!==p[1])throw RangeError(`Dimension mismatch. Matrix A (`+c+`) must match Matrix B (`+p+`)`);if(!a||!u)throw Error(`Cannot perform operation on Pattern Sparse Matrices`);var h=c[0],g=c[1],_,v=n,y=0,b=i;typeof l==`string`&&l===m&&l!==`mixed`&&(_=l,v=t.find(n,[_,_]),y=t.convert(0,_),b=t.find(i,[_,_]));for(var x=[],S=[],C=[],w=[],T=[],E,D,O,k,A=0;A<g;A++){C[A]=S.length;var j=A+1;for(D=s[A],O=s[A+1],E=D;E<O;E++)k=o[E],T[k]=j,w[k]=a[E],S.push(k);for(D=f[A],O=f[A+1],E=D;E<O;E++)k=d[E],T[k]===j&&(w[k]=b(w[k],u[E]));for(E=C[A];E<S.length;){k=S[E];var M=w[k];v(M,y)?S.splice(E,1):(x.push(M),E++)}}return C[g]=S.length,e.createSparseMatrix({values:x,index:S,ptr:C,size:[h,g],datatype:l===e._datatype&&m===r._datatype?_:void 0})}}),fg=J(`useMatrixForArrayScalar`,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e;return{"Array, number":t.referTo(`DenseMatrix, number`,e=>(t,r)=>e(n(t),r).valueOf()),"Array, BigNumber":t.referTo(`DenseMatrix, BigNumber`,e=>(t,r)=>e(n(t),r).valueOf()),"number, Array":t.referTo(`number, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf()),"BigNumber, Array":t.referTo(`BigNumber, DenseMatrix`,e=>(t,r)=>e(t,n(r)).valueOf())}}),pg=`leftShift`,mg=J(pg,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=Ef({typed:t}),c=_f({typed:t,equalScalar:r}),l=dg({typed:t,equalScalar:r}),u=Of({typed:t,DenseMatrix:a}),d=qd({typed:t,equalScalar:r}),f=Yd({typed:t}),p=Cf({typed:t,matrix:n,concat:o}),m=fg({typed:t,matrix:n});return t(pg,{"number, number":Rl,"BigNumber, BigNumber":_p,"bigint, bigint":(e,t)=>e<<t,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),hg=`rightArithShift`,gg=J(hg,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=Ef({typed:t}),c=_f({typed:t,equalScalar:r}),l=dg({typed:t,equalScalar:r}),u=Of({typed:t,DenseMatrix:a}),d=qd({typed:t,equalScalar:r}),f=Yd({typed:t}),p=Cf({typed:t,matrix:n,concat:o}),m=fg({typed:t,matrix:n});return t(hg,{"number, number":zl,"BigNumber, BigNumber":vp,"bigint, bigint":(e,t)=>e>>t,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),_g=`rightLogShift`,vg=J(_g,[`typed`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,DenseMatrix:a,concat:o}=e,s=Ef({typed:t}),c=_f({typed:t,equalScalar:r}),l=dg({typed:t,equalScalar:r}),u=Of({typed:t,DenseMatrix:a}),d=qd({typed:t,equalScalar:r}),f=Yd({typed:t}),p=Cf({typed:t,matrix:n,concat:o}),m=fg({typed:t,matrix:n});return t(_g,{"number, number":Bl,"SparseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():d(t,n,e,!1)),"DenseMatrix, number | BigNumber":t.referToSelf(e=>(t,n)=>r(n,0)?t.clone():f(t,n,e,!1)),"number | BigNumber, SparseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):u(n,t,e,!0)),"number | BigNumber, DenseMatrix":t.referToSelf(e=>(t,n)=>r(t,0)?i(n.size(),n.storage()):f(n,t,e,!0))},m,p({SS:l,DS:s,SD:c}))}),yg=`and`,bg=J(yg,[`typed`,`matrix`,`equalScalar`,`zeros`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=_f({typed:t,equalScalar:r}),c=If({typed:t,equalScalar:r}),l=qd({typed:t,equalScalar:r}),u=Yd({typed:t}),d=Cf({typed:t,matrix:n,concat:o});return t(yg,{"number, number":Ql,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)&&(t.re!==0||t.im!==0)},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!t.isZero()&&!e.isNaN()&&!t.isNaN()},"bigint, bigint":Ql,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0)),"SparseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):l(t,n,e,!1)),"DenseMatrix, any":t.referToSelf(e=>(t,n)=>a(n)?i(t.size(),t.storage()):u(t,n,e,!1)),"any, SparseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):l(n,t,e,!0)),"any, DenseMatrix":t.referToSelf(e=>(t,n)=>a(t)?i(t.size(),t.storage()):u(n,t,e,!0)),"Array, any":t.referToSelf(e=>(t,r)=>e(n(t),r).valueOf()),"any, Array":t.referToSelf(e=>(t,r)=>e(t,n(r)).valueOf())},d({SS:c,DS:s}))}),xg=`compare`,Sg=J(xg,[`typed`,`config`,`matrix`,`equalScalar`,`BigNumber`,`Fraction`,`DenseMatrix`,`concat`],e=>{var{typed:t,config:n,equalScalar:r,matrix:i,BigNumber:a,Fraction:o,DenseMatrix:s,concat:c}=e,l=vf({typed:t}),u=yf({typed:t,equalScalar:r}),d=Jd({typed:t,DenseMatrix:s}),f=Cf({typed:t,matrix:i,concat:c}),p=id({typed:t});return t(xg,Cg({typed:t,config:n}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return Ru(e,t,n.relTol,n.absTol)?new a(0):new a(e.cmp(t))},"bigint, bigint":function(e,t){return e===t?0n:e>t?1n:-1n},"Fraction, Fraction":function(e,t){return new o(e.compare(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},p,f({SS:u,DS:l,Ss:d}))}),Cg=J(xg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(xg,{"number, number":function(e,t){return na(e,t,n.relTol,n.absTol)?0:e>t?1:-1}})}),wg=Dt(wt(((e,t)=>{t.exports=function e(t,n){var r=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,i=/(^[ ]*|[ ]*$)/g,a=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,o=/^0x[0-9a-f]+$/i,s=/^0/,c=function(t){return e.insensitive&&(``+t).toLowerCase()||``+t},l=c(t).replace(i,``)||``,u=c(n).replace(i,``)||``,d=l.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),f=u.replace(r,`\0$1\0`).replace(/\0$/,``).replace(/^\0/,``).split(`\0`),p=parseInt(l.match(o),16)||d.length!==1&&l.match(a)&&Date.parse(l),m=parseInt(u.match(o),16)||p&&u.match(a)&&Date.parse(u)||null,h,g;if(m){if(p<m)return-1;if(p>m)return 1}for(var _=0,v=Math.max(d.length,f.length);_<v;_++){if(h=!(d[_]||``).match(s)&&parseFloat(d[_])||d[_]||0,g=!(f[_]||``).match(s)&&parseFloat(f[_])||f[_]||0,isNaN(h)!==isNaN(g))return isNaN(h)?1:-1;if(typeof h!=typeof g&&(h+=``,g+=``),h<g)return-1;if(h>g)return 1}return 0}}))(),1),Tg=`compareNatural`,Eg=J(Tg,[`typed`,`compare`],e=>{var{typed:t,compare:n}=e,r=n.signatures[`boolean,boolean`];return t(Tg,{"any, any":i});function i(e,t){var c=gi(e),l=gi(t),u;if((c===`number`||c===`BigNumber`||c===`Fraction`||c===`bigint`)&&(l===`number`||l===`BigNumber`||l===`Fraction`||l===`bigint`))return u=n(e,t),u.toString()===`0`?(0,wg.default)(c,l):u>0?1:-1;var d=[`Array`,`DenseMatrix`,`SparseMatrix`];if(d.includes(c)||d.includes(l))return u=a(i,e,t),u===0?(0,wg.default)(c,l):u;if(c!==l)return(0,wg.default)(c,l);if(c===`Complex`)return Dg(e,t);if(c===`Unit`)return e.equalBase(t)?i(e.value,t.value):o(i,e.formatUnits(),t.formatUnits());if(c===`boolean`)return r(e,t);if(c===`string`)return(0,wg.default)(e,t);if(c===`Object`)return s(i,e,t);if(c===`null`||c===`undefined`)return 0;throw TypeError(`Unsupported type of value "`+c+`"`)}function a(e,t,n){return Lr(t)&&Lr(n)?o(e,t.toJSON().values,n.toJSON().values):Lr(t)?a(e,t.toArray(),n):Lr(n)?a(e,t,n.toArray()):Ir(t)?a(e,t.toJSON().data,n):Ir(n)?a(e,t,n.toJSON().data):Array.isArray(t)?Array.isArray(n)?o(e,t,n):a(e,t,[n]):a(e,[t],n)}function o(e,t,n){for(var r=0,i=Math.min(t.length,n.length);r<i;r++){var a=e(t[r],n[r]);if(a!==0)return a}return t.length>n.length?1:t.length<n.length?-1:0}function s(e,t,n){var r=Object.keys(t),i=Object.keys(n);r.sort(wg.default),i.sort(wg.default);var a=o(e,r,i);if(a!==0)return a;for(var s=0;s<r.length;s++){var c=e(t[r[s]],n[i[s]]);if(c!==0)return c}return 0}});function Dg(e,t){return e.re>t.re?1:e.re<t.re?-1:e.im>t.im?1:e.im<t.im?-1:0}var Og=`compareText`,kg=[`typed`,`matrix`,`concat`];nc.signature=`any, any`;var Ag=J(Og,kg,e=>{var{typed:t,matrix:n,concat:r}=e;return t(Og,nc,Cf({typed:t,matrix:n,concat:r})({elop:nc,Ds:!0}))}),jg=`equal`,Mg=J(jg,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=vf({typed:t}),c=Tp({typed:t,SparseMatrix:o}),l=Jd({typed:t,DenseMatrix:i}),u=Cf({typed:t,matrix:n});return t(jg,Ng({typed:t,equalScalar:r}),u({elop:r,SS:c,DS:s,Ss:l}))}),Ng=J(jg,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(jg,{"any, any":function(e,t){return e===null?t===null:t===null?e===null:e===void 0?t===void 0:t===void 0?e===void 0:n(e,t)}})}),Pg=`equalText`,Fg=J(Pg,[`typed`,`compareText`,`isZero`],e=>{var{typed:t,compareText:n,isZero:r}=e;return t(Pg,{"any, any":function(e,t){return r(n(e,t))}})}),Ig=`smaller`,Lg=J(Ig,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=vf({typed:t}),l=Tp({typed:t,SparseMatrix:s}),u=Jd({typed:t,DenseMatrix:a}),d=Cf({typed:t,matrix:i,concat:o}),f=id({typed:t});function p(e,t){return e.lt(t)&&!Ru(e,t,n.relTol,n.absTol)}return t(Ig,Rg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<t,"BigNumber, BigNumber":p,"bigint, bigint":(e,t)=>e<t,"Fraction, Fraction":(e,t)=>e.compare(t)===-1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(e,t){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),Rg=J(Ig,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Ig,{"number, number":function(e,t){return e<t&&!na(e,t,n.relTol,n.absTol)}})}),zg=`smallerEq`,Bg=J(zg,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=vf({typed:t}),c=Tp({typed:t,SparseMatrix:o}),l=Jd({typed:t,DenseMatrix:i}),u=Cf({typed:t,matrix:r,concat:a}),d=id({typed:t});return t(zg,Vg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||Ru(e,t,n.relTol,n.absTol)},"bigint, bigint":(e,t)=>e<=t,"Fraction, Fraction":(e,t)=>e.compare(t)!==1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),Vg=J(zg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(zg,{"number, number":function(e,t){return e<=t||na(e,t,n.relTol,n.absTol)}})}),Hg=`larger`,Ug=J(Hg,[`typed`,`config`,`bignumber`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,bignumber:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=vf({typed:t}),l=Tp({typed:t,SparseMatrix:s}),u=Jd({typed:t,DenseMatrix:a}),d=Cf({typed:t,matrix:i,concat:o}),f=id({typed:t});function p(e,t){return e.gt(t)&&!Ru(e,t,n.relTol,n.absTol)}return t(Hg,Wg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>t,"BigNumber, BigNumber":p,"bigint, bigint":(e,t)=>e>t,"Fraction, Fraction":(e,t)=>e.compare(t)===1,"Fraction, BigNumber":function(e,t){return p(r(e),t)},"BigNumber, Fraction":function(e,t){return p(e,r(t))},"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},f,d({SS:l,DS:c,Ss:u}))}),Wg=J(Hg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Hg,{"number, number":function(e,t){return e>t&&!na(e,t,n.relTol,n.absTol)}})}),Gg=`largerEq`,Kg=J(Gg,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=vf({typed:t}),c=Tp({typed:t,SparseMatrix:o}),l=Jd({typed:t,DenseMatrix:i}),u=Cf({typed:t,matrix:r,concat:a}),d=id({typed:t});return t(Gg,qg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||Ru(e,t,n.relTol,n.absTol)},"bigint, bigint":function(e,t){return e>=t},"Fraction, Fraction":(e,t)=>e.compare(t)!==-1,"Complex, Complex":function(){throw TypeError(`No ordering relation is defined for complex numbers`)}},d,u({SS:c,DS:s,Ss:l}))}),qg=J(Gg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Gg,{"number, number":function(e,t){return e>=t||na(e,t,n.relTol,n.absTol)}})}),Jg=`deepEqual`,Yg=J(Jg,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(Jg,{"any, any":function(e,t){return r(e.valueOf(),t.valueOf())}});function r(e,t){if(Array.isArray(e))if(Array.isArray(t)){var i=e.length;if(i!==t.length)return!1;for(var a=0;a<i;a++)if(!r(e[a],t[a]))return!1;return!0}else return!1;else if(Array.isArray(t))return!1;else return n(e,t)}}),Xg=`unequal`,Zg=J(Xg,[`typed`,`config`,`equalScalar`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,equalScalar:r,matrix:i,DenseMatrix:a,concat:o,SparseMatrix:s}=e,c=vf({typed:t}),l=Tp({typed:t,SparseMatrix:s}),u=Jd({typed:t,DenseMatrix:a}),d=Cf({typed:t,matrix:i,concat:o});return t(Xg,Qg({typed:t,equalScalar:r}),d({elop:f,SS:l,DS:c,Ss:u}));function f(e,t){return!r(e,t)}}),Qg=J(Xg,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(Xg,{"any, any":function(e,t){return e===null?t!==null:t===null?e!==null:e===void 0?t!==void 0:t===void 0?e!==void 0:!n(e,t)}})}),$g=`partitionSelect`,e_=J($g,[`typed`,`isNumeric`,`isNaN`,`compare`],e=>{var{typed:t,isNumeric:n,isNaN:r,compare:i}=e,a=i,o=(e,t)=>-i(e,t);return t($g,{"Array | Matrix, number":function(e,t){return s(e,t,a)},"Array | Matrix, number, string":function(e,t,n){if(n===`asc`)return s(e,t,a);if(n===`desc`)return s(e,t,o);throw Error(`Compare string must be "asc" or "desc"`)},"Array | Matrix, number, function":s});function s(e,t,n){if(!Li(t)||t<0)throw Error(`k must be a non-negative integer`);if(Pr(e)){if(e.size().length>1)throw Error(`Only one dimensional matrices supported`);return c(e.valueOf(),t,n)}if(Array.isArray(e))return c(e,t,n)}function c(e,t,i){if(t>=e.length)throw Error(`k out of bounds`);for(var a=0;a<e.length;a++)if(n(e[a])&&r(e[a]))return e[a];for(var o=0,s=e.length-1;o<s;){for(var c=o,l=s,u=e[Math.floor(Math.random()*(s-o+1))+o];c<l;)if(i(e[c],u)>=0){var d=e[l];e[l]=e[c],e[c]=d,--l}else ++c;i(e[c],u)>0&&--c,t<=c?s=c:o=c+1}return e[t]}}),t_=`sort`,n_=J(t_,[`typed`,`matrix`,`compare`,`compareNatural`],e=>{var{typed:t,matrix:n,compare:r,compareNatural:i}=e,a=r,o=(e,t)=>-r(e,t);return t(t_,{Array:function(e){return c(e),e.sort(a)},Matrix:function(e){return l(e),n(e.toArray().sort(a),e.storage())},"Array, function":function(e,t){return c(e),e.sort(t)},"Matrix, function":function(e,t){return l(e),n(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return c(e),e.sort(s(t))},"Matrix, string":function(e,t){return l(e),n(e.toArray().sort(s(t)),e.storage())}});function s(e){if(e===`asc`)return a;if(e===`desc`)return o;if(e===`natural`)return i;throw Error(`String "asc", "desc", or "natural" expected`)}function c(e){if(ac(e).length!==1)throw Error(`One dimensional array expected`)}function l(e){if(e.size().length!==1)throw Error(`One dimensional matrix expected`)}}),r_=`max`,i_=J(r_,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e;return t(r_,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return $c(e,t.valueOf(),o)},"...":function(e){if(Xc(e))throw TypeError(`Scalar values expected in function max`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw hh(e,`max`,t)}}function s(e){var t;if(Zc(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw hh(t,`max`,e)}}),t===void 0)throw Error(`Cannot calculate max of an empty array`);return typeof t==`string`&&(t=r(t,Ri(t,n))),t}}),a_=`min`,o_=J(a_,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e;return t(a_,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return $c(e,t.valueOf(),o)},"...":function(e){if(Xc(e))throw TypeError(`Scalar values expected in function min`);return s(e)}});function o(e,t){try{return i(e,t)?e:t}catch(e){throw hh(e,`min`,t)}}function s(e){var t;if(Zc(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw hh(t,`min`,e)}}),t===void 0)throw Error(`Cannot calculate min of an empty array`);return typeof t==`string`&&(t=r(t,Ri(t,n))),t}}),s_=J(`ImmutableDenseMatrix`,[`smaller`,`DenseMatrix`],e=>{var{smaller:t,DenseMatrix:n}=e;function r(e,t){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);if(t&&!Mr(t))throw Error(`Invalid datatype: `+t);if(Pr(e)||Nr(e)){var i=new n(e,t);this._data=i._data,this._size=i._size,this._datatype=i._datatype,this._min=null,this._max=null}else if(e&&Nr(e.data)&&Nr(e.size))this._data=e.data,this._size=e.size,this._datatype=e.datatype,this._min=e.min===void 0?null:e.min,this._max=e.max===void 0?null:e.max;else if(e)throw TypeError(`Unsupported type of data (`+gi(e)+`)`);else this._data=[],this._size=[0],this._datatype=t,this._min=null,this._max=null}return r.prototype=new n,r.prototype.type=`ImmutableDenseMatrix`,r.prototype.isImmutableDenseMatrix=!0,r.prototype.subset=function(e){switch(arguments.length){case 1:var t=n.prototype.subset.call(this,e);return Pr(t)?new r({data:t._data,size:t._size,datatype:t._datatype}):t;case 2:case 3:throw Error(`Cannot invoke set subset on an Immutable Matrix instance`);default:throw SyntaxError(`Wrong number of arguments`)}},r.prototype.set=function(){throw Error(`Cannot invoke set on an Immutable Matrix instance`)},r.prototype.resize=function(){throw Error(`Cannot invoke resize on an Immutable Matrix instance`)},r.prototype.reshape=function(){throw Error(`Cannot invoke reshape on an Immutable Matrix instance`)},r.prototype.clone=function(){return new r({data:_i(this._data),size:_i(this._size),datatype:this._datatype})},r.prototype.toJSON=function(){return{mathjs:`ImmutableDenseMatrix`,data:this._data,size:this._size,datatype:this._datatype}},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(){throw Error(`Cannot invoke swapRows on an Immutable Matrix instance`)},r.prototype.min=function(){if(this._min===null){var e=null;this.forEach(function(n){(e===null||t(n,e))&&(e=n)}),this._min=e===null?void 0:e}return this._min},r.prototype.max=function(){if(this._max===null){var e=null;this.forEach(function(n){(e===null||t(e,n))&&(e=n)}),this._max=e===null?void 0:e}return this._max},r},{isClass:!0}),c_=J(`Index`,[`ImmutableDenseMatrix`,`getMatrixDataType`],e=>{var{ImmutableDenseMatrix:t,getMatrixDataType:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);this._dimensions=[],this._sourceSize=[],this._isScalar=!0;for(var e=0,t=arguments.length;e<t;e++){var a=e<0||arguments.length<=e?void 0:arguments[e],o=Nr(a),s=Pr(a),c=typeof a,l=null;if(Rr(a))this._dimensions.push(a),this._isScalar=!1;else if(o||s){var u=void 0;this._isScalar=!1,n(a)===`boolean`?(o&&(u=i(l_(a).valueOf())),s&&(u=i(l_(a._data).valueOf())),l=a.valueOf().length):u=i(a.valueOf()),this._dimensions.push(u)}else if(c===`number`)this._dimensions.push(a);else if(c===`bigint`)this._dimensions.push(Number(a));else if(c===`string`)this._dimensions.push(a);else throw TypeError(`Dimension must be an Array, Matrix, number, bigint, string, or Range`);this._sourceSize.push(l)}}r.prototype.type=`Index`,r.prototype.isIndex=!0;function i(e){for(var n=0,r=e.length;n<r;n++)if(!Er(e[n])||!Li(e[n]))throw TypeError(`Index parameters must be positive integer numbers`);var i=new t;return i._data=e,i._size=[e.length],i}return r.prototype.clone=function(){var e=new r;return e._dimensions=_i(this._dimensions),e._isScalar=this._isScalar,e._sourceSize=this._sourceSize,e},r.create=function(e){var t=new r;return r.apply(t,e),t},r.prototype.size=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]=Mr(r)||Er(r)?1:r.size()[0]}return e},r.prototype.max=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]=Mr(r)||Er(r)?r:r.max()}return e},r.prototype.min=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e[t]=Mr(r)||Er(r)?r:r.min()}return e},r.prototype.forEach=function(e){for(var t=0,n=this._dimensions.length;t<n;t++)e(this._dimensions[t],t,this)},r.prototype.dimension=function(e){return Er(e)?this._dimensions[e]??null:null},r.prototype.isObjectProperty=function(){return this._dimensions.length===1&&Mr(this._dimensions[0])},r.prototype.getObjectProperty=function(){return this.isObjectProperty()?this._dimensions[0]:null},r.prototype.isScalar=function(){return this._isScalar},r.prototype.toArray=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];e.push(Mr(r)||Er(r)?r:r.toArray())}return e},r.prototype.valueOf=r.prototype.toArray,r.prototype.toString=function(){for(var e=[],t=0,n=this._dimensions.length;t<n;t++){var r=this._dimensions[t];Mr(r)?e.push(JSON.stringify(r)):e.push(r.toString())}return`[`+e.join(`, `)+`]`},r.prototype.toJSON=function(){return{mathjs:`Index`,dimensions:this._dimensions}},r.fromJSON=function(e){return r.create(e.dimensions)},r},{isClass:!0});function l_(e){var t=[];return e.forEach((e,n)=>{e&&t.push(n)}),t}var u_=J(`FibonacciHeap`,[`smaller`,`larger`],e=>{var{smaller:t,larger:n}=e,r=1/Math.log((1+Math.sqrt(5))/2);function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._minimum=null,this._size=0}i.prototype.type=`FibonacciHeap`,i.prototype.isFibonacciHeap=!0,i.prototype.insert=function(e,n){var r={key:e,value:n,degree:0};if(this._minimum){var i=this._minimum;r.left=i,r.right=i.right,i.right=r,r.right.left=r,t(e,i.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},i.prototype.size=function(){return this._size},i.prototype.clear=function(){this._minimum=null,this._size=0},i.prototype.isEmpty=function(){return this._size===0},i.prototype.extractMinimum=function(){var e=this._minimum;if(e===null)return e;for(var t=this._minimum,n=e.degree,r=e.child;n>0;){var i=r.right;r.left.right=r.right,r.right.left=r.left,r.left=t,r.right=t.right,t.right=r,r.right.left=r,r.parent=null,r=i,n--}return e.left.right=e.right,e.right.left=e.left,e===e.right?t=null:(t=e.right,t=l(t,this._size)),this._size--,this._minimum=t,e},i.prototype.remove=function(e){this._minimum=a(this._minimum,e,-1),this.extractMinimum()};function a(e,n,r){n.key=r;var i=n.parent;return i&&t(n.key,i.key)&&(o(e,n,i),s(e,i)),t(n.key,e.key)&&(e=n),e}function o(e,t,n){t.left.right=t.right,t.right.left=t.left,n.degree--,n.child===t&&(n.child=t.right),n.degree===0&&(n.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1}function s(e,t){var n=t.parent;n&&(t.mark?(o(e,t,n),s(n)):t.mark=!0)}var c=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1};function l(e,i){var a=Math.floor(Math.log(i)*r)+1,o=Array(a),s=0,l=e;if(l)for(s++,l=l.right;l!==e;)s++,l=l.right;for(var u;s>0;){for(var d=l.degree,f=l.right;u=o[d],u;){if(n(l.key,u.key)){var p=u;u=l,l=p}c(u,l),o[d]=null,d++}o[d]=l,l=f,s--}e=null;for(var m=0;m<a;m++)u=o[m],u&&(e?(u.left.right=u.right,u.right.left=u.left,u.left=e,u.right=e.right,e.right=u,u.right.left=u,t(u.key,e.key)&&(e=u)):e=u);return e}return i},{isClass:!0}),d_=J(`Spa`,[`addScalar`,`equalScalar`,`FibonacciHeap`],e=>{var{addScalar:t,equalScalar:n,FibonacciHeap:r}=e;function i(){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);this._values=[],this._heap=new r}return i.prototype.type=`Spa`,i.prototype.isSpa=!0,i.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var n=this._heap.insert(e,t);this._values[e]=n}},i.prototype.get=function(e){var t=this._values[e];return t?t.value:0},i.prototype.accumulate=function(e,n){var r=this._values[e];r?r.value=t(r.value,n):(r=this._heap.insert(e,n),this._values[e]=r)},i.prototype.forEach=function(e,t,r){var i=this._heap,a=this._values,o=[],s=i.extractMinimum();for(s&&o.push(s);s&&s.key<=t;)s.key>=e&&(n(s.value,0)||r(s.key,s.value,this)),s=i.extractMinimum(),s&&o.push(s);for(var c=0;c<o.length;c++){var l=o[c];s=i.insert(l.key,l.value),a[s.key]=s}},i.prototype.swap=function(e,t){var n=this._values[e],r=this._values[t];if(!n&&r)n=this._heap.insert(e,r.value),this._heap.remove(r),this._values[e]=n,this._values[t]=void 0;else if(n&&!r)r=this._heap.insert(t,n.value),this._heap.remove(n),this._values[t]=r,this._values[e]=void 0;else if(n&&r){var i=n.value;n.value=r.value,r.value=i}},i},{isClass:!0});function f_(e){var t=0,n=1,r=Object.create(null),i=Object.create(null),a=0,o=function(e){var o=i[e];if(o&&(delete r[o],delete i[e],--t,n===o)){if(!t){a=0,n=1;return}for(;!Object.prototype.hasOwnProperty.call(r,++n););}};return e=Math.abs(e),{hit:function(s){var c=i[s],l=++a;if(r[l]=s,i[s]=l,!c)return++t,t<=e?void 0:(s=r[n],o(s),s);if(delete r[c],n===c)for(;!Object.prototype.hasOwnProperty.call(r,++n););},delete:o,clear:function(){t=a=0,n=1,r=Object.create(null),i=Object.create(null)}}}function p_(e){var{hasher:t,limit:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return n??=1/0,t??=JSON.stringify,function r(){typeof r.cache!=`object`&&(r.cache={values:new Map,lru:f_(n||1/0)});var i=[...arguments],a=t(i);if(r.cache.values.has(a))return r.cache.lru.hit(a),r.cache.values.get(a);var o=e.apply(e,i);return r.cache.values.set(a,o),r.cache.values.delete(r.cache.lru.hit(a)),o}}var m_=p_(function(e){return new e(1).exp()},{hasher:v_}),h_=p_(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:v_}),g_=p_(function(e){return e.acos(-1)},{hasher:v_}),__=p_(function(e){return g_(e).times(2)},{hasher:v_});function v_(e){return e[0].precision}function y_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function b_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?y_(Object(n),!0).forEach(function(t){th(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var x_=J(`Unit`,[`?on`,`config`,`addScalar`,`subtractScalar`,`multiplyScalar`,`divideScalar`,`pow`,`abs`,`fix`,`round`,`equal`,`isNumeric`,`format`,`number`,`Complex`,`BigNumber`,`Fraction`],e=>{var{on:t,config:n,addScalar:r,subtractScalar:i,multiplyScalar:a,divideScalar:o,pow:s,abs:c,fix:l,round:u,equal:d,isNumeric:f,format:p,number:m,Complex:h,BigNumber:g,Fraction:_}=e,v=m,y=!1,b=!0;function x(e,t){if(!(this instanceof x))throw Error(`Constructor must be called with the new operator`);if(!(e==null||f(e)||kr(e)))throw TypeError(`First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined`);if(this.fixPrefix=y,this.skipAutomaticSimplification=b,t===void 0)this.units=[],this.dimensions=B.map(e=>0);else if(typeof t==`string`){var n=x.parse(t);this.units=n.units,this.dimensions=n.dimensions}else if(jr(t)&&t.value===null)this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map(e=>lr({},e));else throw TypeError(`Second parameter in Unit constructor must be a string or valueless Unit`);this.value=this._normalize(e)}Object.defineProperty(x,`name`,{value:`Unit`}),x.prototype.constructor=x,x.prototype.type=`Unit`,x.prototype.isUnit=!0;var S,C,w;function T(){for(;w===` `||w===` `;)O()}function E(e){return e>=`0`&&e<=`9`||e===`.`}function D(e){return e>=`0`&&e<=`9`}function O(){C++,w=S.charAt(C)}function k(e){C=e,w=S.charAt(C)}function A(){var e=``,t=C;if(w===`+`?O():w===`-`&&(e+=w,O()),!E(w))return k(t),null;if(w===`.`){if(e+=w,O(),!D(w))return k(t),null}else{for(;D(w);)e+=w,O();w===`.`&&(e+=w,O())}for(;D(w);)e+=w,O();if(w===`E`||w===`e`){var n=``,r=C;if(n+=w,O(),(w===`+`||w===`-`)&&(n+=w,O()),!D(w))return k(r),e;for(e+=n;D(w);)e+=w,O()}return e}function j(){for(var e=``;D(w)||x.isValidAlpha(w);)e+=w,O();var t=e.charAt(0);return x.isValidAlpha(t)?e:null}function M(e){return w===e?(O(),e):null}x.parse=function(e,t){if(t||={},S=e,C=-1,w=``,typeof S!=`string`)throw TypeError(`Invalid argument in Unit.parse, string expected`);var r=new x;r.units=[];var i=1,a=!1;O(),T();var o=A(),s=null;if(o){if(n.number===`BigNumber`)s=new g(o);else if(n.number===`Fraction`)try{s=new _(o)}catch{s=parseFloat(o)}else s=parseFloat(o);T(),M(`*`)?(i=1,a=!0):M(`/`)&&(i=-1,a=!0)}for(var c=[],l=1;;){for(T();w===`(`;)c.push(i),l*=i,i=1,O(),T();var u=void 0;if(w){var d=w;if(u=j(),u===null)throw SyntaxError(`Unexpected "`+d+`" in "`+S+`" at index `+C.toString())}else break;var f=N(u);if(f===null)throw SyntaxError(`Unit "`+u+`" not found.`);var p=i*l;if(T(),M(`^`)){T();var m=A();if(m===null)throw SyntaxError(`In "`+e+`", "^" must be followed by a floating-point number`);p*=m}r.units.push({unit:f.unit,prefix:f.prefix,power:p});for(var h=0;h<B.length;h++)r.dimensions[h]+=(f.unit.dimensions[h]||0)*p;for(T();w===`)`;){if(c.length===0)throw SyntaxError(`Unmatched ")" in "`+S+`" at index `+C.toString());l/=c.pop(),O(),T()}if(a=!1,M(`*`)?(i=1,a=!0):M(`/`)?(i=-1,a=!0):i=1,f.unit.base){var v=f.unit.base.key;ie.auto[v]={unit:f.unit,prefix:f.prefix}}}if(T(),w)throw SyntaxError(`Could not parse: "`+e+`"`);if(a)throw SyntaxError(`Trailing characters: "`+e+`"`);if(c.length!==0)throw SyntaxError(`Unmatched "(" in "`+S+`"`);if(r.units.length===0&&!t.allowNoUnits)throw SyntaxError(`"`+e+`" contains no units`);return r.value=s===void 0?null:r._normalize(s),r},x.prototype.clone=function(){var e=new x;e.fixPrefix=this.fixPrefix,e.skipAutomaticSimplification=this.skipAutomaticSimplification,e.value=_i(this.value),e.dimensions=this.dimensions.slice(0),e.units=[];for(var t=0;t<this.units.length;t++)for(var n in e.units[t]={},this.units[t])Ti(this.units[t],n)&&(e.units[t][n]=this.units[t][n]);return e},x.prototype.valueType=function(){return gi(this.value)},x.prototype._isDerived=function(){return this.units.length===0?!1:this.units.length>1||Math.abs(this.units[0].power-1)>1e-15},x.prototype._normalize=function(e){if(e==null||this.units.length===0)return e;for(var t=e,n=x._getNumberConverter(gi(e)),r=0;r<this.units.length;r++){var i=n(this.units[r].unit.value),o=n(this.units[r].prefix.value),c=n(this.units[r].power);t=a(t,s(a(i,o),c))}return t},x.prototype._denormalize=function(e,t){if(e==null||this.units.length===0)return e;for(var n=e,r=x._getNumberConverter(gi(e)),i=0;i<this.units.length;i++){var c=r(this.units[i].unit.value),l=r(this.units[i].prefix.value),u=r(this.units[i].power);n=o(n,s(a(c,l),u))}return n};var N=p_(e=>{if(Ti(H,e)){var t=H[e];return{unit:t,prefix:t.prefixes[``]}}for(var n in H)if(Ti(H,n)&&Js(e,n)){var r=H[n],i=e.length-n.length,a=e.substring(0,i),o=Ti(r.prefixes,a)?r.prefixes[a]:void 0;if(o!==void 0)return{unit:r,prefix:o}}return null},{hasher:e=>e[0],limit:100});x.isValuelessUnit=function(e){return N(e)!==null},x.prototype.hasBase=function(e){if(typeof e==`string`&&(e=V[e]),!e)return!1;for(var t=0;t<B.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},x.prototype.equalBase=function(e){for(var t=0;t<B.length;t++)if(Math.abs((this.dimensions[t]||0)-(e.dimensions[t]||0))>1e-12)return!1;return!0},x.prototype.equals=function(e){return this.equalBase(e)&&d(this.value,e.value)},x.prototype.multiply=function(e){for(var t=this.clone(),n=jr(e)?e:new x(e),r=0;r<B.length;r++)t.dimensions[r]=(this.dimensions[r]||0)+(n.dimensions[r]||0);for(var i=0;i<n.units.length;i++){var o=b_({},n.units[i]);t.units.push(o)}return this.value!==null||n.value!==null?t.value=a(this.value===null?this._normalize(F(n.value)):this.value,n.value===null?n._normalize(F(this.value)):n.value):t.value=null,jr(e)&&(t.skipAutomaticSimplification=!1),P(t)},x.prototype.divideInto=function(e){return new x(e).divide(this)},x.prototype.divide=function(e){for(var t=this.clone(),n=jr(e)?e:new x(e),r=0;r<B.length;r++)t.dimensions[r]=(this.dimensions[r]||0)-(n.dimensions[r]||0);for(var i=0;i<n.units.length;i++){var a=b_(b_({},n.units[i]),{},{power:-n.units[i].power});t.units.push(a)}return this.value!==null||n.value!==null?t.value=o(this.value===null?this._normalize(F(n.value)):this.value,n.value===null?n._normalize(F(this.value)):n.value):t.value=null,jr(e)&&(t.skipAutomaticSimplification=!1),P(t)},x.prototype.pow=function(e){for(var t=this.clone(),n=0;n<B.length;n++)t.dimensions[n]=(this.dimensions[n]||0)*e;for(var r=0;r<t.units.length;r++)t.units[r].power*=e;return t.value===null?t.value=null:t.value=s(t.value,e),t.skipAutomaticSimplification=!1,P(t)};function P(e){return e.equalBase(V.NONE)&&e.value!==null&&!n.predictable?e.value:e}function F(e){return x._getNumberConverter(gi(e))(1)}x.prototype.abs=function(){var e=this.clone();if(e.value!==null)if(e._isDerived()||e.units.length===0||e.units[0].unit.offset===0)e.value=c(e.value);else{var t=e._numberConverter(),n=a(t(e.units[0].unit.value),t(e.units[0].unit.offset));e.value=i(c(r(e.value,n)),n)}for(var o in e.units)(e.units[o].unit.name===`VA`||e.units[o].unit.name===`VAR`)&&(e.units[o].unit=H.W);return e},x.prototype.to=function(e){var t=this.value===null?this._normalize(1):this.value,n;if(typeof e==`string`)n=x.parse(e);else if(jr(e))n=e.clone();else throw Error(`String or Unit expected as parameter`);if(!this.equalBase(n))throw Error(`Units do not match ('${n.toString()}' != '${this.toString()}')`);if(n.value!==null)throw Error(`Cannot convert to a unit with a value`);if(this.value===null||this._isDerived()||this.units.length===0||n.units.length===0||this.units[0].unit.offset===n.units[0].unit.offset)n.value=_i(t);else{var o=x._getNumberConverter(gi(t)),s=this.units[0].unit.value,c=this.units[0].unit.offset,l=a(s,c),u=n.units[0].unit.value,d=n.units[0].unit.offset,f=a(u,d);n.value=r(t,o(i(l,f)))}return n.fixPrefix=!0,n.skipAutomaticSimplification=!0,n},x.prototype.toNumber=function(e){return v(this.toNumeric(e))},x.prototype.toNumeric=function(e){var t=e?this.to(e):this.clone();return t._isDerived()||t.units.length===0?t._denormalize(t.value):t._denormalize(t.value,t.units[0].prefix.value)},x.prototype.toString=function(){return this.format()},x.prototype.toJSON=function(){return{mathjs:`Unit`,value:this._denormalize(this.value),unit:this.units.length>0?this.formatUnits():null,fixPrefix:this.fixPrefix,skipSimp:this.skipAutomaticSimplification}},x.fromJSON=function(e){var t=new x(e.value,e.unit??void 0);return t.fixPrefix=e.fixPrefix??y,t.skipAutomaticSimplification=e.skipSimp??b,t},x.prototype.valueOf=x.prototype.toString,x.prototype.simplify=function(){var e=this.clone(),t=[],n;for(var r in U)if(Ti(U,r)&&e.hasBase(V[r])){n=r;break}if(n===`NONE`)e.units=[];else{var i;if(n&&Ti(U,n)&&(i=U[n]),i)e.units=[{unit:i.unit,prefix:i.prefix,power:1}];else{for(var a=!1,o=0;o<B.length;o++){var s=B[o];Math.abs(e.dimensions[o]||0)>1e-12&&(Ti(U,s)?t.push({unit:U[s].unit,prefix:U[s].prefix,power:e.dimensions[o]||0}):a=!0)}t.length<e.units.length&&!a&&(e.units=t)}}return e},x.prototype.toSI=function(){for(var e=this.clone(),t=[],n=0;n<B.length;n++){var r=B[n];if(Math.abs(e.dimensions[n]||0)>1e-12)if(Ti(ie.si,r))t.push({unit:ie.si[r].unit,prefix:ie.si[r].prefix,power:e.dimensions[n]||0});else throw Error(`Cannot express custom unit `+r+` in SI units`)}return e.units=t,e.fixPrefix=!0,e.skipAutomaticSimplification=!0,this.value===null?e:(e.value=null,this.to(e))},x.prototype.formatUnits=function(){for(var e=``,t=``,n=0,r=0,i=0;i<this.units.length;i++)this.units[i].power>0?(n++,e+=` `+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power-1)>1e-15&&(e+=`^`+this.units[i].power)):this.units[i].power<0&&r++;if(r>0)for(var a=0;a<this.units.length;a++)this.units[a].power<0&&(n>0?(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,Math.abs(this.units[a].power+1)>1e-15&&(t+=`^`+-this.units[a].power)):(t+=` `+this.units[a].prefix.name+this.units[a].unit.name,t+=`^`+this.units[a].power));e=e.substr(1),t=t.substr(1),n>1&&r>0&&(e=`(`+e+`)`),r>1&&n>0&&(t=`(`+t+`)`);var o=e;return n>0&&r>0&&(o+=` / `),o+=t,o},x.prototype.toBest=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e&&!Array.isArray(e))throw Error(`Invalid unit type. Expected string or Unit.`);var n=this.units[0].unit.prefixes;if(e&&e.length>0){var r=e.map(e=>{var t=null;if(typeof e==`string`){if(t=x.parse(e),!t)throw Error(`Invalid unit type. Expected compatible string or Unit.`)}else if(!jr(e))throw Error(`Invalid unit type. Expected compatible string or Unit.`);t===null&&(t=e.clone());try{return this.to(t.formatUnits()),t}catch{throw Error(`Invalid unit type. Expected compatible string or Unit.`)}}).map(e=>e.units[0].prefix);this.units[0].unit.prefixes=r.reduce((e,t)=>(e[t.name]=t,e),{}),this.units[0].prefix=r[0]}var i=I(this,t).simp;return this.units[0].unit.prefixes=n,i.fixPrefix=!0,i},x.prototype.format=function(e){var{simp:t,valueStr:n,unitStr:r}=I(this,e),i=n;return t.value&&kr(t.value)&&(i=`(`+i+`)`),r.length>0&&i.length>0&&(i+=` `),i+=r,i};function I(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=e.skipAutomaticSimplification||e.value===null?e.clone():e.simplify();L(n),R(n,t.offset);var r=n._denormalize(n.value);return{simp:n,valueStr:n.value===null?``:p(r,t||{}),unitStr:n.formatUnits()}}function L(e){var t=!1;for(var n in e.value!==void 0&&e.value!==null&&kr(e.value)&&(t=Math.abs(e.value.re)<1e-14),e.units)Ti(e.units,n)&&e.units[n].unit&&(e.units[n].unit.name===`VA`&&t?e.units[n].unit=H.VAR:e.units[n].unit.name===`VAR`&&!t&&(e.units[n].unit=H.VA))}function R(e,t){e.units.length===1&&!e.fixPrefix&&Math.abs(e.units[0].power-Math.round(e.units[0].power))<1e-14&&(e.units[0].prefix=e._bestPrefix(t))}x.prototype._bestPrefix=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1.2;if(this.units.length!==1||Math.abs(this.units[0].power-Math.round(this.units[0].power))>=1e-14)throw Error(`Can only compute the best prefix for single units with integer powers, like kg, s^2, N^-1, and so forth!`);var t=this.value===null?0:c(this.value),n=c(this.units[0].unit.value),r=this.units[0].prefix;if(t===0)return r;var i=this.units[0].power,a=Math.log(t/(r.value*n)**+i)/Math.LN10-e;if(a>-2.200001&&a<1.800001)return r;a=Math.abs(a);var o=this.units[0].unit.prefixes;for(var s in o)if(Ti(o,s)){var l=o[s];if(l.scientific){var u=Math.abs(Math.log(t/(l.value*n)**+i)/Math.LN10-e);(u<a||u===a&&l.name.length<r.name.length)&&(r=l,a=u)}}return r},x.prototype.splitUnit=function(e){for(var t=this.clone(),n=[],a=0;a<e.length&&(t=t.to(e[a]),a!==e.length-1);a++){var o=t.toNumeric(),s=u(o),c=void 0;c=d(s,o)?s:l(t.toNumeric());var f=new x(c,e[a].toString());n.push(f),t=i(t,f)}for(var p=0,m=0;m<n.length;m++)p=r(p,n[m].value);return d(p,this.value)&&(t.value=0),n.push(t),n};var z={NONE:{"":{name:``,value:1,scientific:!0}},SHORT:{"":{name:``,value:1,scientific:!0},da:{name:`da`,value:10,scientific:!1},h:{name:`h`,value:100,scientific:!1},k:{name:`k`,value:1e3,scientific:!0},M:{name:`M`,value:1e6,scientific:!0},G:{name:`G`,value:1e9,scientific:!0},T:{name:`T`,value:0xe8d4a51000,scientific:!0},P:{name:`P`,value:0x38d7ea4c68000,scientific:!0},E:{name:`E`,value:0xde0b6b3a7640000,scientific:!0},Z:{name:`Z`,value:1e21,scientific:!0},Y:{name:`Y`,value:1e24,scientific:!0},R:{name:`R`,value:1e27,scientific:!0},Q:{name:`Q`,value:1e30,scientific:!0},d:{name:`d`,value:.1,scientific:!1},c:{name:`c`,value:.01,scientific:!1},m:{name:`m`,value:.001,scientific:!0},u:{name:`u`,value:1e-6,scientific:!0},n:{name:`n`,value:1e-9,scientific:!0},p:{name:`p`,value:1e-12,scientific:!0},f:{name:`f`,value:1e-15,scientific:!0},a:{name:`a`,value:1e-18,scientific:!0},z:{name:`z`,value:1e-21,scientific:!0},y:{name:`y`,value:1e-24,scientific:!0},r:{name:`r`,value:1e-27,scientific:!0},q:{name:`q`,value:1e-30,scientific:!0}},LONG:{"":{name:``,value:1,scientific:!0},deca:{name:`deca`,value:10,scientific:!1},hecto:{name:`hecto`,value:100,scientific:!1},kilo:{name:`kilo`,value:1e3,scientific:!0},mega:{name:`mega`,value:1e6,scientific:!0},giga:{name:`giga`,value:1e9,scientific:!0},tera:{name:`tera`,value:0xe8d4a51000,scientific:!0},peta:{name:`peta`,value:0x38d7ea4c68000,scientific:!0},exa:{name:`exa`,value:0xde0b6b3a7640000,scientific:!0},zetta:{name:`zetta`,value:1e21,scientific:!0},yotta:{name:`yotta`,value:1e24,scientific:!0},ronna:{name:`ronna`,value:1e27,scientific:!0},quetta:{name:`quetta`,value:1e30,scientific:!0},deci:{name:`deci`,value:.1,scientific:!1},centi:{name:`centi`,value:.01,scientific:!1},milli:{name:`milli`,value:.001,scientific:!0},micro:{name:`micro`,value:1e-6,scientific:!0},nano:{name:`nano`,value:1e-9,scientific:!0},pico:{name:`pico`,value:1e-12,scientific:!0},femto:{name:`femto`,value:1e-15,scientific:!0},atto:{name:`atto`,value:1e-18,scientific:!0},zepto:{name:`zepto`,value:1e-21,scientific:!0},yocto:{name:`yocto`,value:1e-24,scientific:!0},ronto:{name:`ronto`,value:1e-27,scientific:!0},quecto:{name:`quecto`,value:1e-30,scientific:!0}},SQUARED:{"":{name:``,value:1,scientific:!0},da:{name:`da`,value:100,scientific:!1},h:{name:`h`,value:1e4,scientific:!1},k:{name:`k`,value:1e6,scientific:!0},M:{name:`M`,value:0xe8d4a51000,scientific:!0},G:{name:`G`,value:0xde0b6b3a7640000,scientific:!0},T:{name:`T`,value:1e24,scientific:!0},P:{name:`P`,value:1e30,scientific:!0},E:{name:`E`,value:1e36,scientific:!0},Z:{name:`Z`,value:1e42,scientific:!0},Y:{name:`Y`,value:1e48,scientific:!0},R:{name:`R`,value:1e54,scientific:!0},Q:{name:`Q`,value:1e60,scientific:!0},d:{name:`d`,value:.01,scientific:!1},c:{name:`c`,value:1e-4,scientific:!1},m:{name:`m`,value:1e-6,scientific:!0},u:{name:`u`,value:1e-12,scientific:!0},n:{name:`n`,value:1e-18,scientific:!0},p:{name:`p`,value:1e-24,scientific:!0},f:{name:`f`,value:1e-30,scientific:!0},a:{name:`a`,value:1e-36,scientific:!0},z:{name:`z`,value:1e-42,scientific:!0},y:{name:`y`,value:1e-48,scientific:!0},r:{name:`r`,value:1e-54,scientific:!0},q:{name:`q`,value:1e-60,scientific:!0}},CUBIC:{"":{name:``,value:1,scientific:!0},da:{name:`da`,value:1e3,scientific:!1},h:{name:`h`,value:1e6,scientific:!1},k:{name:`k`,value:1e9,scientific:!0},M:{name:`M`,value:0xde0b6b3a7640000,scientific:!0},G:{name:`G`,value:1e27,scientific:!0},T:{name:`T`,value:1e36,scientific:!0},P:{name:`P`,value:1e45,scientific:!0},E:{name:`E`,value:1e54,scientific:!0},Z:{name:`Z`,value:1e63,scientific:!0},Y:{name:`Y`,value:1e72,scientific:!0},R:{name:`R`,value:1e81,scientific:!0},Q:{name:`Q`,value:1e90,scientific:!0},d:{name:`d`,value:.001,scientific:!1},c:{name:`c`,value:1e-6,scientific:!1},m:{name:`m`,value:1e-9,scientific:!0},u:{name:`u`,value:1e-18,scientific:!0},n:{name:`n`,value:1e-27,scientific:!0},p:{name:`p`,value:1e-36,scientific:!0},f:{name:`f`,value:1e-45,scientific:!0},a:{name:`a`,value:1e-54,scientific:!0},z:{name:`z`,value:1e-63,scientific:!0},y:{name:`y`,value:1e-72,scientific:!0},r:{name:`r`,value:1e-81,scientific:!0},q:{name:`q`,value:1e-90,scientific:!0}},BINARY_SHORT_SI:{"":{name:``,value:1,scientific:!0},k:{name:`k`,value:1e3,scientific:!0},M:{name:`M`,value:1e6,scientific:!0},G:{name:`G`,value:1e9,scientific:!0},T:{name:`T`,value:0xe8d4a51000,scientific:!0},P:{name:`P`,value:0x38d7ea4c68000,scientific:!0},E:{name:`E`,value:0xde0b6b3a7640000,scientific:!0},Z:{name:`Z`,value:1e21,scientific:!0},Y:{name:`Y`,value:1e24,scientific:!0}},BINARY_SHORT_IEC:{"":{name:``,value:1,scientific:!0},Ki:{name:`Ki`,value:1024,scientific:!0},Mi:{name:`Mi`,value:1024**2,scientific:!0},Gi:{name:`Gi`,value:1024**3,scientific:!0},Ti:{name:`Ti`,value:1024**4,scientific:!0},Pi:{name:`Pi`,value:1024**5,scientific:!0},Ei:{name:`Ei`,value:1024**6,scientific:!0},Zi:{name:`Zi`,value:1024**7,scientific:!0},Yi:{name:`Yi`,value:1024**8,scientific:!0}},BINARY_LONG_SI:{"":{name:``,value:1,scientific:!0},kilo:{name:`kilo`,value:1e3,scientific:!0},mega:{name:`mega`,value:1e6,scientific:!0},giga:{name:`giga`,value:1e9,scientific:!0},tera:{name:`tera`,value:0xe8d4a51000,scientific:!0},peta:{name:`peta`,value:0x38d7ea4c68000,scientific:!0},exa:{name:`exa`,value:0xde0b6b3a7640000,scientific:!0},zetta:{name:`zetta`,value:1e21,scientific:!0},yotta:{name:`yotta`,value:1e24,scientific:!0}},BINARY_LONG_IEC:{"":{name:``,value:1,scientific:!0},kibi:{name:`kibi`,value:1024,scientific:!0},mebi:{name:`mebi`,value:1024**2,scientific:!0},gibi:{name:`gibi`,value:1024**3,scientific:!0},tebi:{name:`tebi`,value:1024**4,scientific:!0},pebi:{name:`pebi`,value:1024**5,scientific:!0},exi:{name:`exi`,value:1024**6,scientific:!0},zebi:{name:`zebi`,value:1024**7,scientific:!0},yobi:{name:`yobi`,value:1024**8,scientific:!0}},BTU:{"":{name:``,value:1,scientific:!0},MM:{name:`MM`,value:1e6,scientific:!0}}};z.SHORTLONG=lr({},z.SHORT,z.LONG),z.BINARY_SHORT=lr({},z.BINARY_SHORT_SI,z.BINARY_SHORT_IEC),z.BINARY_LONG=lr({},z.BINARY_LONG_SI,z.BINARY_LONG_IEC);var B=[`MASS`,`LENGTH`,`TIME`,`CURRENT`,`TEMPERATURE`,`LUMINOUS_INTENSITY`,`AMOUNT_OF_SUBSTANCE`,`ANGLE`,`BIT`],V={NONE:{dimensions:[0,0,0,0,0,0,0,0,0]},MASS:{dimensions:[1,0,0,0,0,0,0,0,0]},LENGTH:{dimensions:[0,1,0,0,0,0,0,0,0]},TIME:{dimensions:[0,0,1,0,0,0,0,0,0]},CURRENT:{dimensions:[0,0,0,1,0,0,0,0,0]},TEMPERATURE:{dimensions:[0,0,0,0,1,0,0,0,0]},LUMINOUS_INTENSITY:{dimensions:[0,0,0,0,0,1,0,0,0]},AMOUNT_OF_SUBSTANCE:{dimensions:[0,0,0,0,0,0,1,0,0]},FORCE:{dimensions:[1,1,-2,0,0,0,0,0,0]},SURFACE:{dimensions:[0,2,0,0,0,0,0,0,0]},VOLUME:{dimensions:[0,3,0,0,0,0,0,0,0]},ENERGY:{dimensions:[1,2,-2,0,0,0,0,0,0]},POWER:{dimensions:[1,2,-3,0,0,0,0,0,0]},PRESSURE:{dimensions:[1,-1,-2,0,0,0,0,0,0]},ELECTRIC_CHARGE:{dimensions:[0,0,1,1,0,0,0,0,0]},ELECTRIC_CAPACITANCE:{dimensions:[-1,-2,4,2,0,0,0,0,0]},ELECTRIC_POTENTIAL:{dimensions:[1,2,-3,-1,0,0,0,0,0]},ELECTRIC_RESISTANCE:{dimensions:[1,2,-3,-2,0,0,0,0,0]},ELECTRIC_INDUCTANCE:{dimensions:[1,2,-2,-2,0,0,0,0,0]},ELECTRIC_CONDUCTANCE:{dimensions:[-1,-2,3,2,0,0,0,0,0]},MAGNETIC_FLUX:{dimensions:[1,2,-2,-1,0,0,0,0,0]},MAGNETIC_FLUX_DENSITY:{dimensions:[1,0,-2,-1,0,0,0,0,0]},FREQUENCY:{dimensions:[0,0,-1,0,0,0,0,0,0]},ANGLE:{dimensions:[0,0,0,0,0,0,0,1,0]},BIT:{dimensions:[0,0,0,0,0,0,0,0,1]}};for(var ee in V)Ti(V,ee)&&(V[ee].key=ee);var te={name:``,base:{},value:1,offset:0,dimensions:B.map(e=>0)},H={meter:{name:`meter`,base:V.LENGTH,prefixes:z.LONG,value:1,offset:0},inch:{name:`inch`,base:V.LENGTH,prefixes:z.NONE,value:.0254,offset:0},foot:{name:`foot`,base:V.LENGTH,prefixes:z.NONE,value:.3048,offset:0},yard:{name:`yard`,base:V.LENGTH,prefixes:z.NONE,value:.9144,offset:0},mile:{name:`mile`,base:V.LENGTH,prefixes:z.NONE,value:1609.344,offset:0},link:{name:`link`,base:V.LENGTH,prefixes:z.NONE,value:.201168,offset:0},rod:{name:`rod`,base:V.LENGTH,prefixes:z.NONE,value:5.0292,offset:0},chain:{name:`chain`,base:V.LENGTH,prefixes:z.NONE,value:20.1168,offset:0},angstrom:{name:`angstrom`,base:V.LENGTH,prefixes:z.NONE,value:1e-10,offset:0},m:{name:`m`,base:V.LENGTH,prefixes:z.SHORT,value:1,offset:0},in:{name:`in`,base:V.LENGTH,prefixes:z.NONE,value:.0254,offset:0},ft:{name:`ft`,base:V.LENGTH,prefixes:z.NONE,value:.3048,offset:0},yd:{name:`yd`,base:V.LENGTH,prefixes:z.NONE,value:.9144,offset:0},mi:{name:`mi`,base:V.LENGTH,prefixes:z.NONE,value:1609.344,offset:0},li:{name:`li`,base:V.LENGTH,prefixes:z.NONE,value:.201168,offset:0},rd:{name:`rd`,base:V.LENGTH,prefixes:z.NONE,value:5.02921,offset:0},ch:{name:`ch`,base:V.LENGTH,prefixes:z.NONE,value:20.1168,offset:0},mil:{name:`mil`,base:V.LENGTH,prefixes:z.NONE,value:254e-7,offset:0},m2:{name:`m2`,base:V.SURFACE,prefixes:z.SQUARED,value:1,offset:0},sqin:{name:`sqin`,base:V.SURFACE,prefixes:z.NONE,value:64516e-8,offset:0},sqft:{name:`sqft`,base:V.SURFACE,prefixes:z.NONE,value:.09290304,offset:0},sqyd:{name:`sqyd`,base:V.SURFACE,prefixes:z.NONE,value:.83612736,offset:0},sqmi:{name:`sqmi`,base:V.SURFACE,prefixes:z.NONE,value:2589988.110336,offset:0},sqrd:{name:`sqrd`,base:V.SURFACE,prefixes:z.NONE,value:25.29295,offset:0},sqch:{name:`sqch`,base:V.SURFACE,prefixes:z.NONE,value:404.6873,offset:0},sqmil:{name:`sqmil`,base:V.SURFACE,prefixes:z.NONE,value:64516e-14,offset:0},acre:{name:`acre`,base:V.SURFACE,prefixes:z.NONE,value:4046.86,offset:0},hectare:{name:`hectare`,base:V.SURFACE,prefixes:z.NONE,value:1e4,offset:0},m3:{name:`m3`,base:V.VOLUME,prefixes:z.CUBIC,value:1,offset:0},L:{name:`L`,base:V.VOLUME,prefixes:z.SHORT,value:.001,offset:0},l:{name:`l`,base:V.VOLUME,prefixes:z.SHORT,value:.001,offset:0},litre:{name:`litre`,base:V.VOLUME,prefixes:z.LONG,value:.001,offset:0},cuin:{name:`cuin`,base:V.VOLUME,prefixes:z.NONE,value:16387064e-12,offset:0},cuft:{name:`cuft`,base:V.VOLUME,prefixes:z.NONE,value:.028316846592,offset:0},cuyd:{name:`cuyd`,base:V.VOLUME,prefixes:z.NONE,value:.764554857984,offset:0},teaspoon:{name:`teaspoon`,base:V.VOLUME,prefixes:z.NONE,value:5e-6,offset:0},tablespoon:{name:`tablespoon`,base:V.VOLUME,prefixes:z.NONE,value:15e-6,offset:0},drop:{name:`drop`,base:V.VOLUME,prefixes:z.NONE,value:5e-8,offset:0},gtt:{name:`gtt`,base:V.VOLUME,prefixes:z.NONE,value:5e-8,offset:0},minim:{name:`minim`,base:V.VOLUME,prefixes:z.NONE,value:6.1611519921875e-8,offset:0},fluiddram:{name:`fluiddram`,base:V.VOLUME,prefixes:z.NONE,value:36966911953125e-19,offset:0},fluidounce:{name:`fluidounce`,base:V.VOLUME,prefixes:z.NONE,value:295735295625e-16,offset:0},gill:{name:`gill`,base:V.VOLUME,prefixes:z.NONE,value:.00011829411825,offset:0},cc:{name:`cc`,base:V.VOLUME,prefixes:z.NONE,value:1e-6,offset:0},cup:{name:`cup`,base:V.VOLUME,prefixes:z.NONE,value:.0002365882365,offset:0},pint:{name:`pint`,base:V.VOLUME,prefixes:z.NONE,value:.000473176473,offset:0},quart:{name:`quart`,base:V.VOLUME,prefixes:z.NONE,value:.000946352946,offset:0},gallon:{name:`gallon`,base:V.VOLUME,prefixes:z.NONE,value:.003785411784,offset:0},beerbarrel:{name:`beerbarrel`,base:V.VOLUME,prefixes:z.NONE,value:.117347765304,offset:0},oilbarrel:{name:`oilbarrel`,base:V.VOLUME,prefixes:z.NONE,value:.158987294928,offset:0},hogshead:{name:`hogshead`,base:V.VOLUME,prefixes:z.NONE,value:.238480942392,offset:0},g:{name:`g`,base:V.MASS,prefixes:z.SHORT,value:.001,offset:0},gram:{name:`gram`,base:V.MASS,prefixes:z.LONG,value:.001,offset:0},ton:{name:`ton`,base:V.MASS,prefixes:z.SHORT,value:907.18474,offset:0},t:{name:`t`,base:V.MASS,prefixes:z.SHORT,value:1e3,offset:0},tonne:{name:`tonne`,base:V.MASS,prefixes:z.LONG,value:1e3,offset:0},grain:{name:`grain`,base:V.MASS,prefixes:z.NONE,value:6479891e-11,offset:0},dram:{name:`dram`,base:V.MASS,prefixes:z.NONE,value:.0017718451953125,offset:0},ounce:{name:`ounce`,base:V.MASS,prefixes:z.NONE,value:.028349523125,offset:0},poundmass:{name:`poundmass`,base:V.MASS,prefixes:z.NONE,value:.45359237,offset:0},hundredweight:{name:`hundredweight`,base:V.MASS,prefixes:z.NONE,value:45.359237,offset:0},stick:{name:`stick`,base:V.MASS,prefixes:z.NONE,value:.115,offset:0},stone:{name:`stone`,base:V.MASS,prefixes:z.NONE,value:6.35029318,offset:0},gr:{name:`gr`,base:V.MASS,prefixes:z.NONE,value:6479891e-11,offset:0},dr:{name:`dr`,base:V.MASS,prefixes:z.NONE,value:.0017718451953125,offset:0},oz:{name:`oz`,base:V.MASS,prefixes:z.NONE,value:.028349523125,offset:0},lbm:{name:`lbm`,base:V.MASS,prefixes:z.NONE,value:.45359237,offset:0},cwt:{name:`cwt`,base:V.MASS,prefixes:z.NONE,value:45.359237,offset:0},s:{name:`s`,base:V.TIME,prefixes:z.SHORT,value:1,offset:0},min:{name:`min`,base:V.TIME,prefixes:z.NONE,value:60,offset:0},h:{name:`h`,base:V.TIME,prefixes:z.NONE,value:3600,offset:0},second:{name:`second`,base:V.TIME,prefixes:z.LONG,value:1,offset:0},sec:{name:`sec`,base:V.TIME,prefixes:z.LONG,value:1,offset:0},minute:{name:`minute`,base:V.TIME,prefixes:z.NONE,value:60,offset:0},hour:{name:`hour`,base:V.TIME,prefixes:z.NONE,value:3600,offset:0},day:{name:`day`,base:V.TIME,prefixes:z.NONE,value:86400,offset:0},week:{name:`week`,base:V.TIME,prefixes:z.NONE,value:7*86400,offset:0},month:{name:`month`,base:V.TIME,prefixes:z.NONE,value:2629800,offset:0},year:{name:`year`,base:V.TIME,prefixes:z.NONE,value:31557600,offset:0},decade:{name:`decade`,base:V.TIME,prefixes:z.NONE,value:315576e3,offset:0},century:{name:`century`,base:V.TIME,prefixes:z.NONE,value:315576e4,offset:0},millennium:{name:`millennium`,base:V.TIME,prefixes:z.NONE,value:315576e5,offset:0},hertz:{name:`Hertz`,base:V.FREQUENCY,prefixes:z.LONG,value:1,offset:0,reciprocal:!0},Hz:{name:`Hz`,base:V.FREQUENCY,prefixes:z.SHORT,value:1,offset:0,reciprocal:!0},rad:{name:`rad`,base:V.ANGLE,prefixes:z.SHORT,value:1,offset:0},radian:{name:`radian`,base:V.ANGLE,prefixes:z.LONG,value:1,offset:0},deg:{name:`deg`,base:V.ANGLE,prefixes:z.SHORT,value:null,offset:0},degree:{name:`degree`,base:V.ANGLE,prefixes:z.LONG,value:null,offset:0},grad:{name:`grad`,base:V.ANGLE,prefixes:z.SHORT,value:null,offset:0},gradian:{name:`gradian`,base:V.ANGLE,prefixes:z.LONG,value:null,offset:0},cycle:{name:`cycle`,base:V.ANGLE,prefixes:z.NONE,value:null,offset:0},arcsec:{name:`arcsec`,base:V.ANGLE,prefixes:z.NONE,value:null,offset:0},arcmin:{name:`arcmin`,base:V.ANGLE,prefixes:z.NONE,value:null,offset:0},A:{name:`A`,base:V.CURRENT,prefixes:z.SHORT,value:1,offset:0},ampere:{name:`ampere`,base:V.CURRENT,prefixes:z.LONG,value:1,offset:0},K:{name:`K`,base:V.TEMPERATURE,prefixes:z.SHORT,value:1,offset:0},degC:{name:`degC`,base:V.TEMPERATURE,prefixes:z.SHORT,value:1,offset:273.15},degF:{name:`degF`,base:V.TEMPERATURE,prefixes:z.SHORT,value:new _(5,9),offset:459.67},degR:{name:`degR`,base:V.TEMPERATURE,prefixes:z.SHORT,value:new _(5,9),offset:0},kelvin:{name:`kelvin`,base:V.TEMPERATURE,prefixes:z.LONG,value:1,offset:0},celsius:{name:`celsius`,base:V.TEMPERATURE,prefixes:z.LONG,value:1,offset:273.15},fahrenheit:{name:`fahrenheit`,base:V.TEMPERATURE,prefixes:z.LONG,value:new _(5,9),offset:459.67},rankine:{name:`rankine`,base:V.TEMPERATURE,prefixes:z.LONG,value:new _(5,9),offset:0},mol:{name:`mol`,base:V.AMOUNT_OF_SUBSTANCE,prefixes:z.SHORT,value:1,offset:0},mole:{name:`mole`,base:V.AMOUNT_OF_SUBSTANCE,prefixes:z.LONG,value:1,offset:0},cd:{name:`cd`,base:V.LUMINOUS_INTENSITY,prefixes:z.SHORT,value:1,offset:0},candela:{name:`candela`,base:V.LUMINOUS_INTENSITY,prefixes:z.LONG,value:1,offset:0},N:{name:`N`,base:V.FORCE,prefixes:z.SHORT,value:1,offset:0},newton:{name:`newton`,base:V.FORCE,prefixes:z.LONG,value:1,offset:0},dyn:{name:`dyn`,base:V.FORCE,prefixes:z.SHORT,value:1e-5,offset:0},dyne:{name:`dyne`,base:V.FORCE,prefixes:z.LONG,value:1e-5,offset:0},lbf:{name:`lbf`,base:V.FORCE,prefixes:z.NONE,value:4.4482216152605,offset:0},poundforce:{name:`poundforce`,base:V.FORCE,prefixes:z.NONE,value:4.4482216152605,offset:0},kip:{name:`kip`,base:V.FORCE,prefixes:z.LONG,value:4448.2216,offset:0},kilogramforce:{name:`kilogramforce`,base:V.FORCE,prefixes:z.NONE,value:9.80665,offset:0},J:{name:`J`,base:V.ENERGY,prefixes:z.SHORT,value:1,offset:0},joule:{name:`joule`,base:V.ENERGY,prefixes:z.LONG,value:1,offset:0},erg:{name:`erg`,base:V.ENERGY,prefixes:z.SHORTLONG,value:1e-7,offset:0},Wh:{name:`Wh`,base:V.ENERGY,prefixes:z.SHORT,value:3600,offset:0},BTU:{name:`BTU`,base:V.ENERGY,prefixes:z.BTU,value:1055.05585262,offset:0},eV:{name:`eV`,base:V.ENERGY,prefixes:z.SHORT,value:1602176565e-28,offset:0},electronvolt:{name:`electronvolt`,base:V.ENERGY,prefixes:z.LONG,value:1602176565e-28,offset:0},W:{name:`W`,base:V.POWER,prefixes:z.SHORT,value:1,offset:0},watt:{name:`watt`,base:V.POWER,prefixes:z.LONG,value:1,offset:0},hp:{name:`hp`,base:V.POWER,prefixes:z.NONE,value:745.6998715386,offset:0},VAR:{name:`VAR`,base:V.POWER,prefixes:z.SHORT,value:h.I,offset:0},VA:{name:`VA`,base:V.POWER,prefixes:z.SHORT,value:1,offset:0},Pa:{name:`Pa`,base:V.PRESSURE,prefixes:z.SHORT,value:1,offset:0},psi:{name:`psi`,base:V.PRESSURE,prefixes:z.NONE,value:6894.75729276459,offset:0},atm:{name:`atm`,base:V.PRESSURE,prefixes:z.NONE,value:101325,offset:0},bar:{name:`bar`,base:V.PRESSURE,prefixes:z.SHORTLONG,value:1e5,offset:0},torr:{name:`torr`,base:V.PRESSURE,prefixes:z.NONE,value:133.322,offset:0},mmHg:{name:`mmHg`,base:V.PRESSURE,prefixes:z.NONE,value:133.322,offset:0},mmH2O:{name:`mmH2O`,base:V.PRESSURE,prefixes:z.NONE,value:9.80665,offset:0},cmH2O:{name:`cmH2O`,base:V.PRESSURE,prefixes:z.NONE,value:98.0665,offset:0},coulomb:{name:`coulomb`,base:V.ELECTRIC_CHARGE,prefixes:z.LONG,value:1,offset:0},C:{name:`C`,base:V.ELECTRIC_CHARGE,prefixes:z.SHORT,value:1,offset:0},Ah:{name:`Ah`,base:V.ELECTRIC_CHARGE,prefixes:z.SHORT,value:3600,offset:0},farad:{name:`farad`,base:V.ELECTRIC_CAPACITANCE,prefixes:z.LONG,value:1,offset:0},F:{name:`F`,base:V.ELECTRIC_CAPACITANCE,prefixes:z.SHORT,value:1,offset:0},volt:{name:`volt`,base:V.ELECTRIC_POTENTIAL,prefixes:z.LONG,value:1,offset:0},V:{name:`V`,base:V.ELECTRIC_POTENTIAL,prefixes:z.SHORT,value:1,offset:0},ohm:{name:`ohm`,base:V.ELECTRIC_RESISTANCE,prefixes:z.SHORTLONG,value:1,offset:0},henry:{name:`henry`,base:V.ELECTRIC_INDUCTANCE,prefixes:z.LONG,value:1,offset:0},H:{name:`H`,base:V.ELECTRIC_INDUCTANCE,prefixes:z.SHORT,value:1,offset:0},siemens:{name:`siemens`,base:V.ELECTRIC_CONDUCTANCE,prefixes:z.LONG,value:1,offset:0},S:{name:`S`,base:V.ELECTRIC_CONDUCTANCE,prefixes:z.SHORT,value:1,offset:0},weber:{name:`weber`,base:V.MAGNETIC_FLUX,prefixes:z.LONG,value:1,offset:0},Wb:{name:`Wb`,base:V.MAGNETIC_FLUX,prefixes:z.SHORT,value:1,offset:0},tesla:{name:`tesla`,base:V.MAGNETIC_FLUX_DENSITY,prefixes:z.LONG,value:1,offset:0},T:{name:`T`,base:V.MAGNETIC_FLUX_DENSITY,prefixes:z.SHORT,value:1,offset:0},b:{name:`b`,base:V.BIT,prefixes:z.BINARY_SHORT,value:1,offset:0},bits:{name:`bits`,base:V.BIT,prefixes:z.BINARY_LONG,value:1,offset:0},B:{name:`B`,base:V.BIT,prefixes:z.BINARY_SHORT,value:8,offset:0},bytes:{name:`bytes`,base:V.BIT,prefixes:z.BINARY_LONG,value:8,offset:0}},ne={meters:`meter`,inches:`inch`,feet:`foot`,yards:`yard`,miles:`mile`,links:`link`,rods:`rod`,chains:`chain`,angstroms:`angstrom`,lt:`l`,litres:`litre`,liter:`litre`,liters:`litre`,teaspoons:`teaspoon`,tablespoons:`tablespoon`,minims:`minim`,fldr:`fluiddram`,fluiddrams:`fluiddram`,floz:`fluidounce`,fluidounces:`fluidounce`,gi:`gill`,gills:`gill`,cp:`cup`,cups:`cup`,pt:`pint`,pints:`pint`,qt:`quart`,quarts:`quart`,gal:`gallon`,gallons:`gallon`,bbl:`beerbarrel`,beerbarrels:`beerbarrel`,obl:`oilbarrel`,oilbarrels:`oilbarrel`,hogsheads:`hogshead`,gtts:`gtt`,grams:`gram`,tons:`ton`,tonnes:`tonne`,grains:`grain`,drams:`dram`,ounces:`ounce`,poundmasses:`poundmass`,hundredweights:`hundredweight`,sticks:`stick`,lb:`lbm`,lbs:`lbm`,kips:`kip`,kgf:`kilogramforce`,acres:`acre`,hectares:`hectare`,sqfeet:`sqft`,sqyard:`sqyd`,sqmile:`sqmi`,sqmiles:`sqmi`,mmhg:`mmHg`,mmh2o:`mmH2O`,cmh2o:`cmH2O`,seconds:`second`,secs:`second`,minutes:`minute`,mins:`minute`,hours:`hour`,hr:`hour`,hrs:`hour`,days:`day`,weeks:`week`,months:`month`,years:`year`,decades:`decade`,centuries:`century`,millennia:`millennium`,hertz:`hertz`,radians:`radian`,degrees:`degree`,gradians:`gradian`,cycles:`cycle`,arcsecond:`arcsec`,arcseconds:`arcsec`,arcminute:`arcmin`,arcminutes:`arcmin`,BTUs:`BTU`,watts:`watt`,joules:`joule`,amperes:`ampere`,amps:`ampere`,amp:`ampere`,coulombs:`coulomb`,volts:`volt`,ohms:`ohm`,farads:`farad`,webers:`weber`,teslas:`tesla`,electronvolts:`electronvolt`,moles:`mole`,bit:`bits`,byte:`bytes`};function re(e){if(e.number===`BigNumber`){var t=g_(g);H.rad.value=new g(1),H.deg.value=t.div(180),H.grad.value=t.div(200),H.cycle.value=t.times(2),H.arcsec.value=t.div(648e3),H.arcmin.value=t.div(10800)}else H.rad.value=1,H.deg.value=Math.PI/180,H.grad.value=Math.PI/200,H.cycle.value=Math.PI*2,H.arcsec.value=Math.PI/648e3,H.arcmin.value=Math.PI/10800;H.radian.value=H.rad.value,H.degree.value=H.deg.value,H.gradian.value=H.grad.value}re(n),t&&t(`config`,function(e,t){e.number!==t.number&&re(e)});var ie={si:{NONE:{unit:te,prefix:z.NONE[``]},LENGTH:{unit:H.m,prefix:z.SHORT[``]},MASS:{unit:H.g,prefix:z.SHORT.k},TIME:{unit:H.s,prefix:z.SHORT[``]},CURRENT:{unit:H.A,prefix:z.SHORT[``]},TEMPERATURE:{unit:H.K,prefix:z.SHORT[``]},LUMINOUS_INTENSITY:{unit:H.cd,prefix:z.SHORT[``]},AMOUNT_OF_SUBSTANCE:{unit:H.mol,prefix:z.SHORT[``]},ANGLE:{unit:H.rad,prefix:z.SHORT[``]},BIT:{unit:H.bits,prefix:z.SHORT[``]},FORCE:{unit:H.N,prefix:z.SHORT[``]},ENERGY:{unit:H.J,prefix:z.SHORT[``]},POWER:{unit:H.W,prefix:z.SHORT[``]},PRESSURE:{unit:H.Pa,prefix:z.SHORT[``]},ELECTRIC_CHARGE:{unit:H.C,prefix:z.SHORT[``]},ELECTRIC_CAPACITANCE:{unit:H.F,prefix:z.SHORT[``]},ELECTRIC_POTENTIAL:{unit:H.V,prefix:z.SHORT[``]},ELECTRIC_RESISTANCE:{unit:H.ohm,prefix:z.SHORT[``]},ELECTRIC_INDUCTANCE:{unit:H.H,prefix:z.SHORT[``]},ELECTRIC_CONDUCTANCE:{unit:H.S,prefix:z.SHORT[``]},MAGNETIC_FLUX:{unit:H.Wb,prefix:z.SHORT[``]},MAGNETIC_FLUX_DENSITY:{unit:H.T,prefix:z.SHORT[``]},FREQUENCY:{unit:H.Hz,prefix:z.SHORT[``]}}};ie.cgs=JSON.parse(JSON.stringify(ie.si)),ie.cgs.LENGTH={unit:H.m,prefix:z.SHORT.c},ie.cgs.MASS={unit:H.g,prefix:z.SHORT[``]},ie.cgs.FORCE={unit:H.dyn,prefix:z.SHORT[``]},ie.cgs.ENERGY={unit:H.erg,prefix:z.NONE[``]},ie.us=JSON.parse(JSON.stringify(ie.si)),ie.us.LENGTH={unit:H.ft,prefix:z.NONE[``]},ie.us.MASS={unit:H.lbm,prefix:z.NONE[``]},ie.us.TEMPERATURE={unit:H.degF,prefix:z.NONE[``]},ie.us.FORCE={unit:H.lbf,prefix:z.NONE[``]},ie.us.ENERGY={unit:H.BTU,prefix:z.BTU[``]},ie.us.POWER={unit:H.hp,prefix:z.NONE[``]},ie.us.PRESSURE={unit:H.psi,prefix:z.NONE[``]},ie.auto=JSON.parse(JSON.stringify(ie.si));var U=ie.auto;for(var ae in x.setUnitSystem=function(e){if(Ti(ie,e))U=ie[e];else throw Error(`Unit system `+e+` does not exist. Choices are: `+Object.keys(ie).join(`, `))},x.getUnitSystem=function(){for(var e in ie)if(Ti(ie,e)&&ie[e]===U)return e},x.typeConverters={BigNumber:function(e){return e!=null&&e.isFraction?new g(String(e.n)).div(String(e.d)).times(String(e.s)):new g(e+``)},Fraction:function(e){return new _(e)},Complex:function(e){return e},number:function(e){return e!=null&&e.isFraction?m(e):e}},x.prototype._numberConverter=function(){var e=x.typeConverters[this.valueType()];if(e)return e;throw TypeError(`Unsupported Unit value type "`+this.valueType()+`"`)},x._getNumberConverter=function(e){if(!x.typeConverters[e])throw TypeError(`Unsupported type "`+e+`"`);return x.typeConverters[e]},H)if(Ti(H,ae)){var oe=H[ae];oe.dimensions=oe.base.dimensions}for(var se in ne)if(Ti(ne,se)){var ce=H[ne[se]],le={};for(var ue in ce)Ti(ce,ue)&&(le[ue]=ce[ue]);le.name=se,H[se]=le}x.isValidAlpha=function(e){return/^[a-zA-Z]$/.test(e)};function de(e){for(var t=0;t<e.length;t++){if(w=e.charAt(t),t===0&&!x.isValidAlpha(w))throw Error(`Invalid unit name (must begin with alpha character): "`+e+`"`);if(t>0&&!(x.isValidAlpha(w)||D(w)))throw Error(`Invalid unit name (only alphanumeric characters are allowed): "`+e+`"`)}}return x.createUnit=function(e,t){if(typeof e!=`object`)throw TypeError(`createUnit expects first parameter to be of type 'Object'`);if(t&&t.override){for(var n in e)if(Ti(e,n)&&x.deleteUnit(n),e[n].aliases)for(var r=0;r<e[n].aliases.length;r++)x.deleteUnit(e[n].aliases[r])}var i;for(var a in e)Ti(e,a)&&(i=x.createUnitSingle(a,e[a]));return i},x.createUnitSingle=function(e,t){if(t??={},typeof e!=`string`)throw TypeError(`createUnitSingle expects first parameter to be of type 'string'`);if(Ti(H,e))throw Error(`Cannot create unit "`+e+`": a unit with that name already exists`);de(e);var n=null,r=[],i=0,a,o,s;if(t&&t.type===`Unit`)n=t.clone();else if(typeof t==`string`)t!==``&&(a=t);else if(typeof t==`object`)a=t.definition,o=t.prefixes,i=t.offset,s=t.baseName,t.aliases&&(r=t.aliases.valueOf());else throw TypeError(`Cannot create unit "`+e+`" from "`+t.toString()+`": expecting "string" or "Unit" or "Object"`);if(r){for(var c=0;c<r.length;c++)if(Ti(H,r[c]))throw Error(`Cannot create alias "`+r[c]+`": a unit with that name already exists`)}if(a&&typeof a==`string`&&!n)try{n=x.parse(a,{allowNoUnits:!0})}catch(t){throw t.message=`Could not create unit "`+e+`" from "`+a+`": `+t.message,t}else a&&a.type===`Unit`&&(n=a.clone());r||=[],i||=0,o=o&&o.toUpperCase&&z[o.toUpperCase()]||z.NONE;var l={};if(n){l={name:e,value:n.value,dimensions:n.dimensions.slice(0),prefixes:o,offset:i};var u=!1;for(var d in V)if(Ti(V,d)){for(var f=!0,p=0;p<B.length;p++)if(Math.abs((l.dimensions[p]||0)-(V[d].dimensions[p]||0))>1e-12){f=!1;break}if(f){u=!0,l.base=V[d];break}}if(!u){s||=e+`_STUFF`;var m={dimensions:n.dimensions.slice(0)};m.key=s,V[s]=m,U[s]={unit:l,prefix:z.NONE[``]},l.base=V[s]}}else{if(s||=e+`_STUFF`,B.indexOf(s)>=0)throw Error(`Cannot create new base unit "`+e+`": a base unit with that name already exists (and cannot be overridden)`);for(var h in B.push(s),V)Ti(V,h)&&(V[h].dimensions[B.length-1]=0);for(var g={dimensions:[]},_=0;_<B.length;_++)g.dimensions[_]=0;g.dimensions[B.length-1]=1,g.key=s,V[s]=g,l={name:e,value:1,dimensions:V[s].dimensions.slice(0),prefixes:o,offset:i,base:V[s]},U[s]={unit:l,prefix:z.NONE[``]}}x.UNITS[e]=l;for(var v=0;v<r.length;v++){var y=r[v],b={};for(var S in l)Ti(l,S)&&(b[S]=l[S]);b.name=y,x.UNITS[y]=b}return delete N.cache,new x(null,e)},x.deleteUnit=function(e){delete x.UNITS[e],delete N.cache},x.PREFIXES=z,x.BASE_DIMENSIONS=B,x.BASE_UNITS=V,x.UNIT_SYSTEMS=ie,x.UNITS=H,x},{isClass:!0}),S_=`unit`,C_=J(S_,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(S_,{Unit:function(e){return e.clone()},string:function(e){return n.isValuelessUnit(e)?new n(null,e):n.parse(e,{allowNoUnits:!0})},"number | BigNumber | Fraction | Complex, string | Unit":function(e,t){return new n(e,t)},"number | BigNumber | Fraction":function(e){return new n(e)},"Array | Matrix":t.referToSelf(e=>t=>Qc(t,e))})}),w_=`sparse`,T_=J(w_,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return t(w_,{"":function(){return new n([])},string:function(e){return new n([],e)},"Array | Matrix":function(e){return new n(e)},"Array | Matrix, string":function(e,t){return new n(e,t)}})}),E_=`createUnit`,D_=J(E_,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(E_,{"Object, Object":function(e,t){return n.createUnit(e,t)},Object:function(e){return n.createUnit(e,{})},"string, Unit | string | Object, Object":function(e,t,r){var i={};return i[e]=t,n.createUnit(i,r)},"string, Unit | string | Object":function(e,t){var r={};return r[e]=t,n.createUnit(r,{})},string:function(e){var t={};return t[e]={},n.createUnit(t,{})}})}),O_=`acos`,k_=J(O_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(O_,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.acos(e):new r(e,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()}})}),A_=`acosh`,j_=J(A_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(A_,{number:function(e){return e>=1||n.predictable?cu(e):e<=-1?new r(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r(e,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()}})}),M_=`acot`,N_=J(M_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(M_,{number:lu,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()}})}),P_=`acoth`,F_=J(P_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(P_,{number:function(e){return e>=1||e<=-1||n.predictable?uu(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})}),I_=`acsc`,L_=J(I_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(I_,{number:function(e){return e<=-1||e>=1||n.predictable?du(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})}),R_=`acsch`,z_=J(R_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(R_,{number:fu,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()}})}),B_=`asec`,V_=J(B_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(B_,{number:function(e){return e<=-1||e>=1||n.predictable?pu(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})}),H_=`asech`,U_=J(H_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(H_,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return mu(e);var i=Math.sqrt(t*t-1);return new r(Math.log(i-t),Math.PI)}return new r(e,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(e){return new i(1).div(e).acosh()}})}),W_=`asin`,G_=J(W_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(W_,{number:function(e){return e>=-1&&e<=1||n.predictable?Math.asin(e):new r(e,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()}})}),K_=J(`asinh`,[`typed`],e=>{var{typed:t}=e;return t(`asinh`,{number:gu,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})}),q_=J(`atan`,[`typed`],e=>{var{typed:t}=e;return t(`atan`,{number:function(e){return Math.atan(e)},Complex:function(e){return e.atan()},BigNumber:function(e){return e.atan()}})}),J_=`atan2`,Y_=J(J_,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,DenseMatrix:a,concat:o}=e,s=_f({typed:t,equalScalar:r}),c=vf({typed:t}),l=cp({typed:t,equalScalar:r}),u=qd({typed:t,equalScalar:r}),d=Jd({typed:t,DenseMatrix:a}),f=Cf({typed:t,matrix:n,concat:o});return t(J_,{"number, number":Math.atan2,"BigNumber, BigNumber":(e,t)=>i.atan2(e,t)},f({scalar:`number | BigNumber`,SS:l,DS:c,SD:s,Ss:u,sS:d}))}),X_=`atanh`,Z_=J(X_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(X_,{number:function(e){return e<=1&&e>=-1||n.predictable?yu(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})}),Q_=J(`trigUnit`,[`typed`],e=>{var{typed:t}=e;return{Unit:t.referToSelf(e=>n=>{if(!n.hasBase(n.constructor.BASE_UNITS.ANGLE))throw TypeError(`Unit in function cot is no angle`);return t.find(e,n.valueType())(n.value)})}}),$_=`cos`,ev=J($_,[`typed`],e=>{var{typed:t}=e,n=Q_({typed:t});return t($_,{number:Math.cos,"Complex | BigNumber":e=>e.cos()},n)}),tv=`cosh`,nv=J(tv,[`typed`],e=>{var{typed:t}=e;return t(tv,{number:oa,"Complex | BigNumber":e=>e.cosh()})}),rv=`cot`,iv=J(rv,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=Q_({typed:t});return t(rv,{number:Su,Complex:e=>e.cot(),BigNumber:e=>new n(1).div(e.tan())},r)}),av=`coth`,ov=J(av,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(av,{number:Cu,Complex:e=>e.coth(),BigNumber:e=>new n(1).div(e.tanh())})}),sv=`csc`,cv=J(sv,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=Q_({typed:t});return t(sv,{number:wu,Complex:e=>e.csc(),BigNumber:e=>new n(1).div(e.sin())},r)}),lv=`csch`,uv=J(lv,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(lv,{number:Tu,Complex:e=>e.csch(),BigNumber:e=>new n(1).div(e.sinh())})}),dv=`sec`,fv=J(dv,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=Q_({typed:t});return t(dv,{number:Eu,Complex:e=>e.sec(),BigNumber:e=>new n(1).div(e.cos())},r)}),pv=`sech`,mv=J(pv,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(pv,{number:Du,Complex:e=>e.sech(),BigNumber:e=>new n(1).div(e.cosh())})}),hv=`sin`,gv=J(hv,[`typed`],e=>{var{typed:t}=e,n=Q_({typed:t});return t(hv,{number:Math.sin,"Complex | BigNumber":e=>e.sin()},n)}),_v=`sinh`,vv=J(_v,[`typed`],e=>{var{typed:t}=e;return t(_v,{number:ku,"Complex | BigNumber":e=>e.sinh()})}),yv=`tan`,bv=J(yv,[`typed`],e=>{var{typed:t}=e,n=Q_({typed:t});return t(yv,{number:Math.tan,"Complex | BigNumber":e=>e.tan()},n)}),xv=J(`tanh`,[`typed`],e=>{var{typed:t}=e;return t(`tanh`,{number:ca,"Complex | BigNumber":e=>e.tanh()})}),Sv=`setCartesian`,Cv=J(Sv,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Sv,{"Array | Matrix, Array | Matrix":function(e,t){var s=[];if(r(n(e),new a(0))!==0&&r(n(t),new a(0))!==0){var c=xc(Array.isArray(e)?e:e.toArray()).sort(i),l=xc(Array.isArray(t)?t:t.toArray()).sort(i);s=[];for(var u=0;u<c.length;u++)for(var d=0;d<l.length;d++)s.push([c[u],l[d]])}return Array.isArray(e)&&Array.isArray(t)?s:new o(s)}})}),wv=`setDifference`,Tv=J(wv,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(wv,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0)s=[];else if(r(n(t),new a(0))===0)return xc(e.toArray());else{var c=Dc(xc(Array.isArray(e)?e:e.toArray()).sort(i)),l=Dc(xc(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u,d=0;d<c.length;d++){u=!1;for(var f=0;f<l.length;f++)if(i(c[d].value,l[f].value)===0&&c[d].identifier===l[f].identifier){u=!0;break}u||s.push(c[d])}}return Array.isArray(e)&&Array.isArray(t)?Oc(s):new o(Oc(s))}})}),Ev=`setDistinct`,Dv=J(Ev,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Ev,{"Array | Matrix":function(e){var t;if(r(n(e),new a(0))===0)t=[];else{var s=xc(Array.isArray(e)?e:e.toArray()).sort(i);t=[],t.push(s[0]);for(var c=1;c<s.length;c++)i(s[c],s[c-1])!==0&&t.push(s[c])}return Array.isArray(e)?t:new o(t)}})}),Ov=`setIntersect`,kv=J(Ov,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Ov,{"Array | Matrix, Array | Matrix":function(e,t){var s;if(r(n(e),new a(0))===0||r(n(t),new a(0))===0)s=[];else{var c=Dc(xc(Array.isArray(e)?e:e.toArray()).sort(i)),l=Dc(xc(Array.isArray(t)?t:t.toArray()).sort(i));s=[];for(var u=0;u<c.length;u++)for(var d=0;d<l.length;d++)if(i(c[u].value,l[d].value)===0&&c[u].identifier===l[d].identifier){s.push(c[u]);break}}return Array.isArray(e)&&Array.isArray(t)?Oc(s):new o(Oc(s))}})}),Av=`setIsSubset`,jv=J(Av,[`typed`,`size`,`subset`,`compareNatural`,`Index`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(Av,{"Array | Matrix, Array | Matrix":function(e,t){if(r(n(e),new a(0))===0)return!0;if(r(n(t),new a(0))===0)return!1;for(var o=Dc(xc(Array.isArray(e)?e:e.toArray()).sort(i)),s=Dc(xc(Array.isArray(t)?t:t.toArray()).sort(i)),c,l=0;l<o.length;l++){c=!1;for(var u=0;u<s.length;u++)if(i(o[l].value,s[u].value)===0&&o[l].identifier===s[u].identifier){c=!0;break}if(c===!1)return!1}return!0}})}),Mv=`setMultiplicity`,Nv=J(Mv,[`typed`,`size`,`subset`,`compareNatural`,`Index`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(Mv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(r(n(t),new a(0))===0)return 0;for(var o=xc(Array.isArray(t)?t:t.toArray()),s=0,c=0;c<o.length;c++)i(o[c],e)===0&&s++;return s}})}),Pv=`setPowerset`,Fv=J(Pv,[`typed`,`size`,`subset`,`compareNatural`,`Index`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(Pv,{"Array | Matrix":function(e){if(r(n(e),new a(0))===0)return[];for(var t=xc(Array.isArray(e)?e:e.toArray()).sort(i),c=[],l=0;l.toString(2).length<=t.length;)c.push(o(t,l.toString(2).split(``).reverse())),l++;return s(c)}});function o(e,t){for(var n=[],r=0;r<t.length;r++)t[r]===`1`&&n.push(e[r]);return n}function s(e){for(var t=[],n=e.length-1;n>0;n--)for(var r=0;r<n;r++)e[r].length>e[r+1].length&&(t=e[r],e[r]=e[r+1],e[r+1]=t);return e}}),Iv=`setSize`,Lv=J(Iv,[`typed`,`compareNatural`],e=>{var{typed:t,compareNatural:n}=e;return t(Iv,{"Array | Matrix":function(e){return Array.isArray(e)?xc(e).length:xc(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(t===!1||e.length===0)return Array.isArray(e)?xc(e).length:xc(e.toArray()).length;for(var r=xc(Array.isArray(e)?e:e.toArray()).sort(n),i=1,a=1;a<r.length;a++)n(r[a],r[a-1])!==0&&i++;return i}})}),Rv=`setSymDifference`,zv=J(Rv,[`typed`,`size`,`concat`,`subset`,`setDifference`,`Index`],e=>{var{typed:t,size:n,concat:r,subset:i,setDifference:a,Index:o}=e;return t(Rv,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new o(0))===0)return xc(t);if(i(n(t),new o(0))===0)return xc(e);var s=xc(e),c=xc(t);return r(a(s,c),a(c,s))}})}),Bv=`setUnion`,Vv=J(Bv,[`typed`,`size`,`concat`,`subset`,`setIntersect`,`setSymDifference`,`Index`],e=>{var{typed:t,size:n,concat:r,subset:i,setIntersect:a,setSymDifference:o,Index:s}=e;return t(Bv,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new s(0))===0)return xc(t);if(i(n(t),new s(0))===0)return xc(e);var c=xc(e),l=xc(t);return r(o(c,l),a(c,l))}})}),Hv=`add`,Uv=J(Hv,[`typed`,`matrix`,`addScalar`,`equalScalar`,`DenseMatrix`,`SparseMatrix`,`concat`],e=>{var{typed:t,matrix:n,addScalar:r,equalScalar:i,DenseMatrix:a,SparseMatrix:o,concat:s}=e,c=Ef({typed:t}),l=Df({typed:t,equalScalar:i}),u=Of({typed:t,DenseMatrix:a}),d=Cf({typed:t,matrix:n,concat:s});return t(Hv,{"any, any":r,"any, any, ...any":t.referToSelf(e=>(t,n,r)=>{for(var i=e(t,n),a=0;a<r.length;a++)i=e(i,r[a]);return i})},d({elop:r,DS:c,SS:l,Ss:u}))}),Wv=`hypot`,Gv=J(Wv,[`typed`,`abs`,`addScalar`,`divideScalar`,`multiplyScalar`,`sqrt`,`smaller`,`isPositive`],e=>{var{typed:t,abs:n,addScalar:r,divideScalar:i,multiplyScalar:a,sqrt:o,smaller:s,isPositive:c}=e;return t(Wv,{"... number | BigNumber":l,Array:l,Matrix:e=>l(xc(e.toArray(),!0))});function l(e){for(var t=0,l=0,u=0;u<e.length;u++){if(kr(e[u]))throw TypeError(`Unexpected type of argument to hypot`);var d=n(e[u]);s(l,d)?(t=a(t,a(i(l,d),i(l,d))),t=r(t,1),l=d):t=r(t,c(d)?a(i(d,l),i(d,l)):d)}return a(l,o(t))}}),Kv=`norm`,qv=J(Kv,[`typed`,`abs`,`add`,`pow`,`conj`,`sqrt`,`multiply`,`equalScalar`,`larger`,`smaller`,`matrix`,`ctranspose`,`eigs`],e=>{var{typed:t,abs:n,add:r,pow:i,conj:a,sqrt:o,multiply:s,equalScalar:c,larger:l,smaller:u,matrix:d,ctranspose:f,eigs:p}=e;return t(Kv,{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},boolean:function(e){return Math.abs(e)},Array:function(e){return S(d(e),2)},Matrix:function(e){return S(e,2)},"Array, number | BigNumber | string":function(e,t){return S(d(e),t)},"Matrix, number | BigNumber | string":function(e,t){return S(e,t)}});function m(e){var t=0;return e.forEach(function(e){var r=n(e);l(r,t)&&(t=r)},!0),t}function h(e){var t;return e.forEach(function(e){var r=n(e);(!t||u(r,t))&&(t=r)},!0),t||0}function g(e,t){if(t===1/0||t===`inf`)return m(e);if(t===-1/0||t===`-inf`)return h(e);if(t===`fro`)return S(e,2);if(typeof t==`number`&&!isNaN(t)){if(!c(t,0)){var a=0;return e.forEach(function(e){a=r(i(n(e),t),a)},!0),i(a,1/t)}return 1/0}throw Error(`Unsupported parameter value`)}function _(e){var t=0;return e.forEach(function(e,n){t=r(t,s(e,a(e)))}),n(o(t))}function v(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[1],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function y(e){var t=e.size();if(t[0]!==t[1])throw RangeError(`Invalid matrix dimensions`);var r=p(s(f(e),e)).values.toArray(),i=r[r.length-1];return n(o(i))}function b(e){var t=[],i=0;return e.forEach(function(e,a){var o=a[0],s=r(t[o]||0,n(e));l(s,i)&&(i=s),t[o]=s},!0),i}function x(e,t){if(t===1)return v(e);if(t===1/0||t===`inf`)return b(e);if(t===`fro`)return _(e);if(t===2)return y(e);throw Error(`Unsupported parameter value `+t)}function S(e,t){var n=e.size();if(n.length===1)return g(e,t);if(n.length===2){if(n[0]&&n[1])return x(e,t);throw RangeError(`Invalid matrix dimensions`)}}}),Jv=`dot`,Yv=J(Jv,[`typed`,`addScalar`,`multiplyScalar`,`conj`,`size`],e=>{var{typed:t,addScalar:n,multiplyScalar:r,conj:i,size:a}=e;return t(Jv,{"Array | DenseMatrix, Array | DenseMatrix":s,"SparseMatrix, SparseMatrix":c});function o(e,t){var n=a(e),r=a(t),i,o;if(n.length===1)i=n[0];else if(n.length===2&&n[1]===1)i=n[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+n.join(`, `)+`)`);if(r.length===1)o=r[0];else if(r.length===2&&r[1]===1)o=r[0];else throw RangeError(`Expected a column vector, instead got a matrix of size (`+r.join(`, `)+`)`);if(i!==o)throw RangeError(`Vectors must have equal length (`+i+` != `+o+`)`);if(i===0)throw RangeError(`Cannot calculate the dot product of empty vectors`);return i}function s(e,s){var c=o(e,s),l=Pr(e)?e._data:e,u=Pr(e)?e._datatype||e.getDataType():void 0,d=Pr(s)?s._data:s,f=Pr(s)?s._datatype||s.getDataType():void 0,p=a(e).length===2,m=a(s).length===2,h=n,g=r;if(u&&f&&u===f&&typeof u==`string`&&u!==`mixed`){var _=u;h=t.find(n,[_,_]),g=t.find(r,[_,_])}if(!p&&!m){for(var v=g(i(l[0]),d[0]),y=1;y<c;y++)v=h(v,g(i(l[y]),d[y]));return v}if(!p&&m){for(var b=g(i(l[0]),d[0][0]),x=1;x<c;x++)b=h(b,g(i(l[x]),d[x][0]));return b}if(p&&!m){for(var S=g(i(l[0][0]),d[0]),C=1;C<c;C++)S=h(S,g(i(l[C][0]),d[C]));return S}if(p&&m){for(var w=g(i(l[0][0]),d[0][0]),T=1;T<c;T++)w=h(w,g(i(l[T][0]),d[T][0]));return w}}function c(e,t){o(e,t);for(var i=e._index,a=e._values,s=t._index,c=t._values,l=0,u=n,d=r,f=0,p=0;f<i.length&&p<s.length;){var m=i[f],h=s[p];if(m<h){f++;continue}if(m>h){p++;continue}m===h&&(l=u(l,d(a[f],c[p])),f++,p++)}return l}}),Xv=J(`trace`,[`typed`,`matrix`,`add`],e=>{var{typed:t,matrix:n,add:r}=e;return t(`trace`,{Array:function(e){return i(n(e))},SparseMatrix:a,DenseMatrix:i,any:_i});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(t[0]===1)return _i(n[0]);throw RangeError(`Matrix must be square (size: `+Ys(t)+`)`);case 2:var i=t[0];if(i===t[1]){for(var a=0,o=0;o<i;o++)a=r(a,n[o][o]);return a}else throw RangeError(`Matrix must be square (size: `+Ys(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+Ys(t)+`)`)}}function a(e){var t=e._values,n=e._index,i=e._ptr,a=e._size,o=a[0],s=a[1];if(o===s){var c=0;if(t.length>0)for(var l=0;l<s;l++)for(var u=i[l],d=i[l+1],f=u;f<d;f++){var p=n[f];if(p===l){c=r(c,t[f]);break}if(p>l)break}return c}throw RangeError(`Matrix must be square (size: `+Ys(a)+`)`)}}),Zv=`index`,Qv=J(Zv,[`typed`,`Index`],e=>{var{typed:t,Index:n}=e;return t(Zv,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return Dr(e)?e.toNumber():Nr(e)||Pr(e)?e.map(function(e){return Dr(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),$v=new Set([`end`]),ey=J(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...$v])if(e.has(t))throw Error(`Scope contains an illegal symbol, "`+t+`" is a reserved keyword`)}class r{get type(){return`Node`}get isNode(){return!0}evaluate(e){return this.compile().evaluate(e)}compile(){var e=this._compile(t,{}),r={},i=null;function a(t){var a=wr(t);return n(a),e(a,r,i)}return{evaluate:a}}_compile(e,t){throw Error(`Method _compile must be implemented by type `+this.type)}forEach(e){throw Error(`Cannot run forEach on a Node interface`)}map(e){throw Error(`Cannot run map on a Node interface`)}_ifNode(e){if(!ci(e))throw TypeError(`Callback function must return a Node`);return e}traverse(e){e(this,null,null);function t(e,n){e.forEach(function(e,r,i){n(e,r,i),t(e,n)})}t(this,e)}transform(e){function t(n,r,i){var a=e(n,r,i);return a===n?n.map(t):a}return t(this,null,null)}filter(e){var t=[];return this.traverse(function(n,r,i){e(n,r,i)&&t.push(n)}),t}clone(){throw Error(`Cannot clone a Node interface`)}cloneDeep(){return this.map(function(e){return e.cloneDeep()})}equals(e){return e?this.type===e.type&&xi(this,e):!1}toString(e){var t=this._getCustomString(e);return t===void 0?this._toString(e):t}_toString(){throw Error(`_toString not implemented for `+this.type)}toJSON(){throw Error(`Cannot serialize object: toJSON not implemented by `+this.type)}toHTML(e){var t=this._getCustomString(e);return t===void 0?this._toHTML(e):t}_toHTML(){throw Error(`_toHTML not implemented for `+this.type)}toTex(e){var t=this._getCustomString(e);return t===void 0?this._toTex(e):t}_toTex(e){throw Error(`_toTex not implemented for `+this.type)}_getCustomString(e){if(e&&typeof e==`object`)switch(typeof e.handler){case`object`:case`undefined`:return;case`function`:return e.handler(this,e);default:throw TypeError(`Object or function expected as callback`)}}getIdentifier(){return this.type}getContent(){return this}}return r},{isClass:!0,isNode:!0});function ty(e){return e&&e.isIndexError?new ic(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function ny(e){var{subset:t}=e;return function(e,n){try{if(Array.isArray(e))return t(e,n);if(e&&typeof e.subset==`function`)return e.subset(n);if(typeof e==`string`)return t(e,n);if(typeof e==`object`){if(!n.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return dr(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw ty(e)}}}var ry=`AccessorNode`,iy=J(ry,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=ny({subset:t});function i(e){return!(Qr(e)||$r(e)||ri(e)||oi(e)||li(e)||di(e)||mi(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!ci(e))throw TypeError(`Node expected for parameter "object"`);if(!si(t))throw TypeError(`IndexNode expected for parameter "index"`);this.object=e,this.index=t,this.optionalChaining=n}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return ry}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=Qr(this.object)&&this.object.optionalChaining;if(this.index.isObjectProperty()){var s=this.index.getObjectProperty();return function(e,t,r){var i=r||{},c=n(e,t,i);if(a&&c==null){i.optionalShortCircuit=!0;return}if(!(o&&i!=null&&i.optionalShortCircuit))return dr(c,s)}}else return function(e,t,s){var c=s||{},l=n(e,t,c);if(a&&l==null){c.optionalShortCircuit=!0;return}if(!(o&&c!=null&&c.optionalShortCircuit))return r(l,i(e,t,l))}}forEach(e){e(this.object,`object`,this),e(this.index,`index`,this)}map(e){return new a(this._ifNode(e(this.object,`object`,this)),this._ifNode(e(this.index,`index`,this)),this.optionalChaining)}clone(){return new a(this.object,this.index,this.optionalChaining)}_toString(e){var t=this.object.toString(e);i(this.object)&&(t=`(`+t+`)`);var n=this.optionalChaining?this.index.dotNotation?`?`:`?.`:``;return t+n+this.index.toString(e)}_toHTML(e){var t=this.object.toHTML(e);return i(this.object)&&(t=`<span class="math-parenthesis math-round-parenthesis">(</span>`+t+`<span class="math-parenthesis math-round-parenthesis">)</span>`),t+this.index.toHTML(e)}_toTex(e){var t=this.object.toTex(e);return i(this.object)&&(t=`\\left(' + object + '\\right)`),t+this.index.toTex(e)}toJSON(){return{mathjs:ry,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return th(a,`name`,ry),a},{isClass:!0,isNode:!0}),ay=`ArrayNode`,oy=J(ay,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(ci))throw TypeError(`Array containing Nodes expected`)}get type(){return ay}get isArrayNode(){return!0}_compile(e,t){var n=Sc(this.items,function(n){return n._compile(e,t)});if(e.config.matrix!==`Array`){var r=e.matrix;return function(e,t,i){return r(Sc(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return Sc(n,function(n){return n(e,t,r)})}}forEach(e){for(var t=0;t<this.items.length;t++){var n=this.items[t];e(n,`items[`+t+`]`,this)}}map(e){for(var t=[],r=0;r<this.items.length;r++)t[r]=this._ifNode(e(this.items[r],`items[`+r+`]`,this));return new n(t)}clone(){return new n(this.items.slice(0))}_toString(e){return`[`+this.items.map(function(t){return t.toString(e)}).join(`, `)+`]`}toJSON(){return{mathjs:ay,items:this.items}}static fromJSON(e){return new n(e.items)}_toHTML(e){return`<span class="math-parenthesis math-square-parenthesis">[</span>`+this.items.map(function(t){return t.toHTML(e)}).join(`<span class="math-separator">,</span>`)+`<span class="math-parenthesis math-square-parenthesis">]</span>`}_toTex(e){function t(n,r){var i=n.some($r)&&!n.every($r),a=r||i,o=a?`&`:`\\\\`,s=n.map(function(n){return n.items?t(n.items,!r):n.toTex(e)}).join(o);return i||!a||a&&!r?`\\begin{bmatrix}`+s+`\\end{bmatrix}`:s}return t(this.items,!1)}}return th(n,`name`,ay),n},{isClass:!0,isNode:!0});function sy(e){var{subset:t,matrix:n}=e;return function(e,r,i){try{if(Array.isArray(e))return n(e).subset(r,i).valueOf().forEach((t,n)=>{e[n]=t}),e;if(e&&typeof e.subset==`function`)return e.subset(r,i);if(typeof e==`string`)return t(e,r,i);if(typeof e==`object`){if(!r.isObjectProperty())throw TypeError(`Cannot apply a numeric index as object property`);return fr(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw ty(e)}}}var cy=[{AssignmentNode:{},FunctionAssignmentNode:{}},{ConditionalNode:{latexLeftParens:!1,latexRightParens:!1,latexParens:!1}},{"OperatorNode:or":{op:`or`,associativity:`left`,associativeWith:[]}},{"OperatorNode:xor":{op:`xor`,associativity:`left`,associativeWith:[]}},{"OperatorNode:and":{op:`and`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitOr":{op:`|`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitXor":{op:`^|`,associativity:`left`,associativeWith:[]}},{"OperatorNode:bitAnd":{op:`&`,associativity:`left`,associativeWith:[]}},{"OperatorNode:equal":{op:`==`,associativity:`left`,associativeWith:[]},"OperatorNode:unequal":{op:`!=`,associativity:`left`,associativeWith:[]},"OperatorNode:smaller":{op:`<`,associativity:`left`,associativeWith:[]},"OperatorNode:larger":{op:`>`,associativity:`left`,associativeWith:[]},"OperatorNode:smallerEq":{op:`<=`,associativity:`left`,associativeWith:[]},"OperatorNode:largerEq":{op:`>=`,associativity:`left`,associativeWith:[]},RelationalNode:{associativity:`left`,associativeWith:[]}},{"OperatorNode:leftShift":{op:`<<`,associativity:`left`,associativeWith:[]},"OperatorNode:rightArithShift":{op:`>>`,associativity:`left`,associativeWith:[]},"OperatorNode:rightLogShift":{op:`>>>`,associativity:`left`,associativeWith:[]}},{"OperatorNode:to":{op:`to`,associativity:`left`,associativeWith:[]}},{RangeNode:{}},{"OperatorNode:add":{op:`+`,associativity:`left`,associativeWith:[`OperatorNode:add`,`OperatorNode:subtract`]},"OperatorNode:subtract":{op:`-`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{op:`*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]},"OperatorNode:divide":{op:`/`,associativity:`left`,associativeWith:[],latexLeftParens:!1,latexRightParens:!1,latexParens:!1},"OperatorNode:dotMultiply":{op:`.*`,associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`OperatorNode:dotMultiply`,`OperatorNode:doDivide`]},"OperatorNode:dotDivide":{op:`./`,associativity:`left`,associativeWith:[]},"OperatorNode:mod":{op:`mod`,associativity:`left`,associativeWith:[]}},{"OperatorNode:multiply":{associativity:`left`,associativeWith:[`OperatorNode:multiply`,`OperatorNode:divide`,`Operator:dotMultiply`,`Operator:dotDivide`]}},{"OperatorNode:unaryPlus":{op:`+`,associativity:`right`},"OperatorNode:unaryMinus":{op:`-`,associativity:`right`},"OperatorNode:bitNot":{op:`~`,associativity:`right`},"OperatorNode:not":{op:`not`,associativity:`right`}},{"OperatorNode:pow":{op:`^`,associativity:`right`,associativeWith:[],latexRightParens:!1},"OperatorNode:dotPow":{op:`.^`,associativity:`right`,associativeWith:[]}},{"OperatorNode:nullish":{op:`??`,associativity:`left`,associativeWith:[]}},{"OperatorNode:factorial":{op:`!`,associativity:`left`}},{"OperatorNode:ctranspose":{op:`'`,associativity:`left`}}];function ly(e,t){if(!t||t!==`auto`)return e;for(var n=e;di(n);)n=n.content;return n}function uy(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s<cy.length;s++)if(a in cy[s]){o=s;break}if(a===`OperatorNode:multiply`&&i.implicit&&n!==`show`){var c=ly(i.args[0],t);!(ri(c)&&r&&r.getIdentifier()===`OperatorNode:divide`&&ii(ly(r.args[0],t)))&&!(c.getIdentifier()===`OperatorNode:divide`&&ii(ly(c.args[0],t))&&ri(ly(c.args[1])))&&(o+=1)}return o}function dy(e,t){var n=e;t!==`keep`&&(n=e.getContent());var r=n.getIdentifier(),i=uy(n,t);if(i===null)return null;var a=cy[i][r];if(Ti(a,`associativity`)){if(a.associativity===`left`)return`left`;if(a.associativity===`right`)return`right`;throw Error(`'`+r+`' has the invalid associativity '`+a.associativity+`'.`)}return null}function fy(e,t,n){var r=n===`keep`?e:e.getContent(),i=n===`keep`?t:e.getContent(),a=r.getIdentifier(),o=i.getIdentifier(),s=uy(r,n);if(s===null)return null;var c=cy[s][a];if(Ti(c,`associativeWith`)&&c.associativeWith instanceof Array){for(var l=0;l<c.associativeWith.length;l++)if(c.associativeWith[l]===o)return!0;return!1}return null}function py(e){var t=`OperatorNode:`+e;for(var n of cy)if(t in n)return n[t].op;return null}var my=`AssignmentNode`,hy=J(my,[`subset`,`?matrix`,`Node`],e=>{var{subset:t,matrix:n,Node:r}=e,i=ny({subset:t}),a=sy({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=uy(e,t,n),i=uy(e.value,t,n);return t===`all`||i!==null&&i<=r}class s extends r{constructor(e,t,n){if(super(),this.object=e,this.index=n?t:null,this.value=n||t,!mi(e)&&!Qr(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(mi(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!si(this.index))throw TypeError(`IndexNode expected as "index"`);if(!ci(this.value))throw TypeError(`Node expected as "value"`)}get name(){return this.index?this.index.isObjectProperty()?this.index.getObjectProperty():``:this.object.name||``}get type(){return my}get isAssignmentNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),r=this.index?this.index._compile(e,t):null,o=this.value._compile(e,t),s=this.object.name;if(!this.index){if(!mi(this.object))throw TypeError(`SymbolNode expected as object`);return function(e,t,n){var r=o(e,t,n);return e.set(s,r),r}}else if(this.index.isObjectProperty()){var c=this.index.getObjectProperty();return function(e,t,r){var i=n(e,t,r),a=o(e,t,r);return fr(i,c,a),a}}else if(mi(this.object))return function(e,t,i){var c=n(e,t,i),l=o(e,t,i),u=r(e,t,c);return e.set(s,a(c,u,l)),l};else{var l=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var u=this.object.index.getObjectProperty();return function(e,t,n){var i=l(e,t,n),s=dr(i,u),c=r(e,t,s),d=o(e,t,n);return fr(i,u,a(s,c,d)),d}}else{var d=this.object.index._compile(e,t);return function(e,t,n){var s=l(e,t,n),c=d(e,t,s),u=i(s,c),f=r(e,t,u),p=o(e,t,n);return a(s,c,a(u,f,p)),p}}}}forEach(e){e(this.object,`object`,this),this.index&&e(this.index,`index`,this),e(this.value,`value`,this)}map(e){return new s(this._ifNode(e(this.object,`object`,this)),this.index?this._ifNode(e(this.index,`index`,this)):null,this._ifNode(e(this.value,`value`,this)))}clone(){return new s(this.object,this.index,this.value)}_toString(e){var t=this.object.toString(e),n=this.index?this.index.toString(e):``,r=this.value.toString(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`(`+r+`)`),t+n+` = `+r}toJSON(){return{mathjs:my,object:this.object,index:this.index,value:this.value}}static fromJSON(e){return new s(e.object,e.index,e.value)}_toHTML(e){var t=this.object.toHTML(e),n=this.index?this.index.toHTML(e):``,r=this.value.toHTML(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`<span class="math-paranthesis math-round-parenthesis">(</span>`+r+`<span class="math-paranthesis math-round-parenthesis">)</span>`),t+n+`<span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>`+r}_toTex(e){var t=this.object.toTex(e),n=this.index?this.index.toTex(e):``,r=this.value.toTex(e);return o(this,e&&e.parenthesis,e&&e.implicit)&&(r=`\\left(${r}\\right)`),t+n+`=`+r}}return th(s,`name`,my),s},{isClass:!0,isNode:!0}),gy=`BlockNode`,_y=J(gy,[`ResultSet`,`Node`],e=>{var{ResultSet:t,Node:n}=e;class r extends n{constructor(e){if(super(),!Array.isArray(e))throw Error(`Array expected`);this.blocks=e.map(function(e){var t=e&&e.node,n=e&&e.visible!==void 0?e.visible:!0;if(!ci(t))throw TypeError(`Property "node" must be a Node`);if(typeof n!=`boolean`)throw TypeError(`Property "visible" must be a boolean`);return{node:t,visible:n}})}get type(){return gy}get isBlockNode(){return!0}_compile(e,n){var r=Sc(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return Cc(r,function(t){var r=t.evaluate(e,n,i);t.visible&&a.push(r)}),new t(a)}}forEach(e){for(var t=0;t<this.blocks.length;t++)e(this.blocks[t].node,`blocks[`+t+`].node`,this)}map(e){for(var t=[],n=0;n<this.blocks.length;n++){var i=this.blocks[n];t[n]={node:this._ifNode(e(i.node,`blocks[`+n+`].node`,this)),visible:i.visible}}return new r(t)}clone(){return new r(this.blocks.map(function(e){return{node:e.node,visible:e.visible}}))}_toString(e){return this.blocks.map(function(t){return t.node.toString(e)+(t.visible?``:`;`)}).join(`
|
|
@@ -67,7 +67,7 @@ In case of a (multi dimensional) array or matrix, the prob order quantile of all
|
|
|
67
67
|
return false;
|
|
68
68
|
}`),e.length!==n.length&&(t=`if (x !== x) return false;\n${t}`),Function(`x`,`${t}\nreturn true;`)}function XM(e){return typeof e==`bigint`?`${AO(e)}n`:AO(e)}function ZM(e,t){let n=Math.ceil(e)*t-1;return(n-n%64+64||64)/t}function QM(e,t=0){return e.length>=t?e.subarray(0,t):pD(new e.constructor(t),e,0)}var $M=class{constructor(e,t=0,n=1){this.length=Math.ceil(t/n),this.buffer=new e(this.length),this.stride=n,this.BYTES_PER_ELEMENT=e.BYTES_PER_ELEMENT,this.ArrayType=e}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(e,t){return this}append(e){return this.set(this.length,e)}reserve(e){if(e>0){this.length+=e;let t=this.stride,n=this.length*t,r=this.buffer.length;n>=r&&this._resize(ZM(r===0?n*1:n*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=ZM(e*this.stride,this.BYTES_PER_ELEMENT);let t=QM(this.buffer,e);return this.clear(),t}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=QM(this.buffer,e)}},eN=class extends $M{last(){return this.get(this.length-1)}get(e){return this.buffer[e]}set(e,t){return this.reserve(e-this.length+1),this.buffer[e*this.stride]=t,this}},tN=class extends eN{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(e){return this.buffer[e>>3]>>e%8&1}set(e,t){let{buffer:n}=this.reserve(e-this.length+1),r=e>>3,i=e%8,a=n[r]>>i&1;return t?a===0&&(n[r]|=1<<i,++this.numValid):a===1&&(n[r]&=~(1<<i),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},nN=class extends eN{constructor(e){super(e.OffsetArrayType,1,1)}append(e){return this.set(this.length-1,e)}set(e,t){let n=this.length-1,r=this.reserve(e-n+1).buffer;return n<e++&&n>=0&&r.fill(r[n],n,e),r[e]=r[e-1]+t,this}flush(e=this.length-1){return e>this.length&&this.set(e-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(e+1)}},rN=class{static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e){throw Error(`"throughDOM" not available in this environment`)}constructor({type:e,nullValues:t}){this.length=0,this.finished=!1,this.type=e,this.children=[],this.nullValues=t,this.stride=qk(e),this._nulls=new tN,t&&t.length>0&&(this._isValid=YM(t))}toVector(){return new GM([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let e=0,{_offsets:t,_values:n,_nulls:r,_typeIds:i,children:a}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),a.reduce((e,t)=>e+t.byteLength,e)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let e=0;return this._offsets&&(e+=this._offsets.reservedByteLength),this._values&&(e+=this._values.reservedByteLength),this._nulls&&(e+=this._nulls.reservedByteLength),this._typeIds&&(e+=this._typeIds.reservedByteLength),this.children.reduce((e,t)=>e+t.reservedByteLength,e)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(e){return this.set(this.length,e)}isValid(e){return this._isValid(e)}set(e,t){return this.setValid(e,this.isValid(t))&&this.setValue(e,t),this}setValue(e,t){this._setValue(this,e,t)}setValid(e,t){return this.length=this._nulls.set(e,+t).length,t}addChild(e,t=`${this.numChildren}`){throw Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(e){return this.children[e]||null}flush(){let e,t,n,r,{type:i,length:a,nullCount:o,_typeIds:s,_offsets:c,_values:l,_nulls:u}=this;(t=s?.flush(a))?r=c?.flush(a):e=(r=c?.flush(a))?l?.flush(c.last()):l?.flush(a),o>0&&(n=u?.flush(a));let d=this.children.map(e=>e.flush());return this.clear(),xM({type:i,length:a,nullCount:o,children:d,child:d[0],data:e,typeIds:t,nullBitmap:n,valueOffsets:r})}finish(){this.finished=!0;for(let e of this.children)e.finish();return this}clear(){var e,t,n,r;this.length=0,(e=this._nulls)==null||e.clear(),(t=this._values)==null||t.clear(),(n=this._offsets)==null||n.clear(),(r=this._typeIds)==null||r.clear();for(let e of this.children)e.clear();return this}};rN.prototype.length=1,rN.prototype.stride=1,rN.prototype.children=null,rN.prototype.finished=!1,rN.prototype.nullValues=null,rN.prototype._isValid=()=>!0;var iN=class extends rN{constructor(e){super(e),this._values=new eN(this.ArrayType,0,this.stride)}setValue(e,t){let n=this._values;return n.reserve(e-n.length+1),super.setValue(e,t)}},aN=class extends rN{constructor(e){super(e),this._pendingLength=0,this._offsets=new nN(e.type)}setValue(e,t){let n=this._pending||=new Map,r=n.get(e);r&&(this._pendingLength-=r.length),this._pendingLength+=t instanceof Yj?t[Gj].length:t.length,n.set(e,t)}setValid(e,t){return super.setValid(e,t)?!0:((this._pending||=new Map).set(e,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let e=this._pending,t=this._pendingLength;return this._pendingLength=0,this._pending=void 0,e&&e.size>0&&this._flushPending(e,t),this}},oN=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,t,n,r){return e.prep(8,24),e.writeInt64(BigInt(r??0)),e.pad(4),e.writeInt32(n),e.writeInt64(BigInt(t??0)),e.offset()}},sN=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):PD.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new EO).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new oN).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){let n=this.bb.__offset(this.bb_pos,10);return n?(t||new oN).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new iO).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,PD.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}},cN=class e{constructor(e=[],t,n,r=PD.V5){this.fields=e||[],this.metadata=t||new Map,n||=dN(this.fields),this.dictionaries=n,this.metadataVersion=r}get[Symbol.toStringTag](){return`Schema`}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(`, `)} }>`}select(t){let n=new Set(t);return new e(this.fields.filter(e=>n.has(e.name)),this.metadata)}selectAt(t){return new e(t.map(e=>this.fields[e]).filter(Boolean),this.metadata)}assign(...t){let n=t[0]instanceof e?t[0]:Array.isArray(t[0])?new e(t[0]):new e(t),r=[...this.fields],i=uN(uN(new Map,this.metadata),n.metadata),a=n.fields.filter(e=>{let t=r.findIndex(t=>t.name===e.name);return~t?(r[t]=e.clone({metadata:uN(uN(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=dN(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};cN.prototype.fields=null,cN.prototype.metadata=null,cN.prototype.dictionaries=null;var lN=class e{static new(...t){let[n,r,i,a]=t;return t[0]&&typeof t[0]==`object`&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),a===void 0&&(a=t[0].metadata)),new e(`${n}`,r,i,a)}constructor(e,t,n=!1,r){this.name=e,this.type=t,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return`Field`}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,a]=t;return!t[0]||typeof t[0]!=`object`?[n=this.name,r=this.type,i=this.nullable,a=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:a=this.metadata}=t[0],e.new(n,r,i,a)}};lN.prototype.type=null,lN.prototype.name=null,lN.prototype.nullable=null,lN.prototype.metadata=null;function uN(e,t){return new Map([...e||new Map,...t||new Map])}function dN(e,t=new Map){for(let n=-1,r=e.length;++n<r;){let r=e[n].type;if(fk.isDictionary(r)){if(!t.has(r.id))t.set(r.id,r.dictionary);else if(t.get(r.id)!==r.dictionary)throw Error(`Cannot create Schema containing two different dictionaries with the same Id`)}r.children&&r.children.length>0&&dN(r.children,t)}return t}var fN=KD,pN=GD,mN=class{static decode(e){e=new pN(vD(e));let t=sN.getRootAsFooter(e);return new hN(cN.decode(t.schema(),new Map,t.version()),t)}static encode(e){let t=new fN,n=cN.encode(t,e.schema);sN.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())gN.encode(t,n);let r=t.endVector();sN.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())gN.encode(t,n);let i=t.endVector();return sN.startFooter(t),sN.addSchema(t,n),sN.addVersion(t,PD.V5),sN.addRecordBatches(t,r),sN.addDictionaries(t,i),sN.finishFooterBuffer(t,sN.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=PD.V5,n,r){this.schema=e,this.version=t,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}*recordBatches(){for(let e,t=-1,n=this.numRecordBatches;++t<n;)(e=this.getRecordBatch(t))&&(yield e)}*dictionaryBatches(){for(let e,t=-1,n=this.numDictionaries;++t<n;)(e=this.getDictionaryBatch(t))&&(yield e)}getRecordBatch(e){return e>=0&&e<this.numRecordBatches&&this._recordBatches[e]||null}getDictionaryBatch(e){return e>=0&&e<this.numDictionaries&&this._dictionaryBatches[e]||null}},hN=class extends mN{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(e,t){super(e,t.version()),this._footer=t}getRecordBatch(e){if(e>=0&&e<this.numRecordBatches){let t=this._footer.recordBatches(e);if(t)return gN.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){let t=this._footer.dictionaries(e);if(t)return gN.decode(t)}return null}},gN=class e{static decode(t){return new e(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(e,t){let{metaDataLength:n}=t,r=BigInt(t.offset),i=BigInt(t.bodyLength);return oN.createBlock(e,r,n,i)}constructor(e,t,n){this.metaDataLength=e,this.offset=jO(n),this.bodyLength=jO(t)}},_N=Object.freeze({done:!0,value:void 0}),vN=class{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},yN=class{tee(){return this._getDOMStream().tee()}pipe(e,t){return this._getNodeStream().pipe(e,t)}pipeTo(e,t){return this._getDOMStream().pipeTo(e,t)}pipeThrough(e,t){return this._getDOMStream().pipeThrough(e,t)}_getDOMStream(){return this._DOMStream||=this.toDOMStream()}_getNodeStream(){return this._nodeStream||=this.toNodeStream()}},bN=class extends yN{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return RE(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(_N);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return ED.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return ED.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return RE(this,void 0,void 0,function*(){return yield this.abort(e),_N})}return(e){return RE(this,void 0,void 0,function*(){return yield this.close(),_N})}read(e){return RE(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return RE(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,t)=>{this.resolvers.push({resolve:e,reject:t})}):Promise.resolve(_N)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},xN=class extends bN{write(e){if((e=vD(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?GE(this.toUint8Array(!0)):this.toUint8Array(!1).then(GE)}toUint8Array(e=!1){return e?mD(this._values)[0]:RE(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=UE(this),c;c=yield s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;i.push(e),a+=e.byteLength}}catch(e){t={error:e}}finally{try{!o&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return mD(i,a)[0]})}},SN=class{constructor(e){e&&(this.source=new wN(ED.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},CN=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof xN?this.source=new TN(ED.fromAsyncIterable(t)):lD(t)?this.source=new TN(ED.fromNodeStream(t)):sD(t)?this.source=new TN(ED.fromDOMStream(t)):iD(t)?this.source=new TN(ED.fromDOMStream(t.body)):$E(t)?this.source=new TN(ED.fromIterable(t)):(QE(t)||eD(t))&&(this.source=new TN(ED.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},wN=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,`peek`).value}read(e){return this.next(e,`read`).value}next(e,t=`read`){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||_N)}return(e){return Object.create(this.source.return&&this.source.return(e)||_N)}},TN=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return RE(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return RE(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return RE(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return RE(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return RE(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||_N;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return RE(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||_N;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},EN=class extends SN{constructor(e,t){super(),this.position=0,this.buffer=vD(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){let{buffer:t,byteOffset:n}=this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e<this.size}read(e){let{buffer:t,size:n,position:r}=this;return t&&r<n?(typeof e!=`number`&&(e=1/0),this.position=Math.min(n,r+Math.min(n-r,e)),t.subarray(r,this.position)):null}readAt(e,t){let n=this.buffer,r=Math.min(this.size,e+t);return n?n.subarray(e,r):new Uint8Array(t)}close(){this.buffer&&=null}throw(e){return this.close(),{done:!0,value:e}}return(e){return this.close(),{done:!0,value:e}}},DN=class extends CN{constructor(e,t){super(),this.position=0,this._handle=e,typeof t==`number`?this.size=t:this._pending=RE(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending})}readInt32(e){return RE(this,void 0,void 0,function*(){let{buffer:t,byteOffset:n}=yield this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)})}seek(e){return RE(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e<this.size})}read(e){return RE(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:t,size:n,position:r}=this;if(t&&r<n){typeof e!=`number`&&(e=1/0);let i=r,a=0,o=0,s=Math.min(n,i+Math.min(n-i,e)),c=new Uint8Array(Math.max(0,(this.position=s)-i));for(;(i+=o)<s&&(a+=o)<c.byteLength;)({bytesRead:o}=yield t.read(c,a,c.byteLength-a,i));return c}return null})}readAt(e,t){return RE(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:r}=this;if(n&&e+t<r){let i=Math.min(r,e+t),a=new Uint8Array(i-e);return(yield n.read(a,0,t,e)).buffer}return new Uint8Array(t)})}close(){return RE(this,void 0,void 0,function*(){let e=this._handle;this._handle=null,e&&(yield e.close())})}throw(e){return RE(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}return(e){return RE(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}},ON=65536;function kN(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}var AN=8,jN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],MN=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0<r?ON:0,this.buffer[1]+=i>>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]<e.buffer[1]||this.buffer[1]===e.buffer[1]&&this.buffer[0]<e.buffer[0]}equals(e){return this.buffer[1]===e.buffer[1]&&this.buffer[0]==e.buffer[0]}greaterThan(e){return e.lessThan(this)}hex(){return`${kN(this.buffer[1])} ${kN(this.buffer[0])}`}},NN=class e extends MN{times(e){return this._times(e),this}plus(e){return this._plus(e),this}static from(t,n=new Uint32Array(2)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){let r=t.length,i=new e(n);for(let n=0;n<r;){let a=AN<r-n?AN:r-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+a),10),0])),s=new e(new Uint32Array([jN[a],0]));i.times(s),i.plus(o),n+=a}return i}static convertArray(t){let n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}},PN=class e extends MN{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(e){return this._times(e),this}plus(e){return this._plus(e),this}lessThan(e){let t=this.buffer[1]<<0,n=e.buffer[1]<<0;return t<n||t===n&&this.buffer[0]<e.buffer[0]}static from(t,n=new Uint32Array(2)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=+!!r;n<i;){let r=AN<i-n?AN:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0])),s=new e(new Uint32Array([jN[r],0]));a.times(s),a.plus(o),n+=r}return r?a.negate():a}static convertArray(t){let n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}},FN=class e{constructor(e){this.buffer=e}high(){return new PN(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new PN(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(e){let t=new NN(new Uint32Array([this.buffer[3],0])),n=new NN(new Uint32Array([this.buffer[2],0])),r=new NN(new Uint32Array([this.buffer[1],0])),i=new NN(new Uint32Array([this.buffer[0],0])),a=new NN(new Uint32Array([e.buffer[3],0])),o=new NN(new Uint32Array([e.buffer[2],0])),s=new NN(new Uint32Array([e.buffer[1],0])),c=new NN(new Uint32Array([e.buffer[0],0])),l=NN.multiply(i,c);this.buffer[0]=l.low();let u=new NN(new Uint32Array([l.high(),0]));return l=NN.multiply(r,c),u.plus(l),l=NN.multiply(i,s),u.plus(l),this.buffer[1]=u.low(),this.buffer[3]=+!!u.lessThan(l),this.buffer[2]=u.high(),new NN(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(NN.multiply(n,c)).plus(NN.multiply(r,s)).plus(NN.multiply(i,o)),this.buffer[3]+=NN.multiply(t,c).plus(NN.multiply(n,s)).plus(NN.multiply(r,o)).plus(NN.multiply(i,a)).low(),this}plus(e){let t=new Uint32Array(4);return t[3]=this.buffer[3]+e.buffer[3]>>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]<this.buffer[0]>>>0&&++t[1],t[1]<this.buffer[1]>>>0&&++t[2],t[2]<this.buffer[2]>>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${kN(this.buffer[3])} ${kN(this.buffer[2])} ${kN(this.buffer[1])} ${kN(this.buffer[0])}`}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=+!!r;n<i;){let r=AN<i-n?AN:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0,0,0])),s=new e(new Uint32Array([jN[r],0,0,0]));a.times(s),a.plus(o),n+=r}return r?a.negate():a}static convertArray(t){let n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}},IN=class extends Jk{constructor(e,t,n,r,i=PD.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=e,this.nodes=t,this.buffers=n,this.dictionaries=r,this.metadataVersion=i}visit(e){return super.visit(e instanceof lN?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return xM({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitFixedSizeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}visitStruct(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),children:this.visitMany(e.children)})}visitUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<PD.V5&&this.readNullBitmap(e,n),e.mode===FD.Sparse?this.visitSparseUnion(e,{length:t,nullCount:n}):this.visitDenseUnion(e,{length:t,nullCount:n})}visitDenseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),valueOffsets:this.readOffsets(e),children:this.visitMany(e.children)})}visitSparseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e.indices),dictionary:this.readDictionary(e)})}visitInterval(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),child:this.visit(e.children[0])})}visitMap(e,{length:t,nullCount:n}=this.nextFieldNode()){return xM({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(e,t,n=this.nextBufferRange()){return t>0&&this.readData(e,n)||new Uint8Array}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+t)}readDictionary(e){return this.dictionaries.get(e.id)}},LN=class extends IN{constructor(e,t,n,r,i){super(new Uint8Array,t,n,r,i),this.sources=e}readNullBitmap(e,t,{offset:n}=this.nextBufferRange()){return t<=0?new Uint8Array:mM(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return hD(Uint8Array,hD(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return hD(Uint8Array,hD(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return fk.isTimestamp(e)||(fk.isInt(e)||fk.isTime(e))&&e.bitWidth===64||fk.isDuration(e)||fk.isDate(e)&&e.unit===LD.MILLISECOND?hD(Uint8Array,PN.convertArray(n[t])):fk.isDecimal(e)?hD(Uint8Array,FN.convertArray(n[t])):fk.isBinary(e)||fk.isLargeBinary(e)||fk.isFixedSizeBinary(e)?RN(n[t]):fk.isBool(e)?mM(n[t]):fk.isUtf8(e)||fk.isLargeUtf8(e)?qE(n[t].join(``)):hD(Uint8Array,hD(e.ArrayType,n[t].map(e=>+e)))}};function RN(e){let t=e.join(``),n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e>>1]=Number.parseInt(t.slice(e,e+2),16);return n}var zN=class extends aN{constructor(e){super(e),this._values=new $M(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,vD(t))}_flushPending(e,t){let n=this._offsets,r=this._values.reserve(t).buffer,i=0;for(let[t,a]of e)if(a===void 0)n.set(t,0);else{let e=a.length;r.set(a,i),n.set(t,e),i+=e}}},BN=class extends aN{constructor(e){super(e),this._values=new $M(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,vD(t))}_flushPending(e,t){let n=this._offsets,r=this._values.reserve(t).buffer,i=0;for(let[t,a]of e)if(a===void 0)n.set(t,BigInt(0));else{let e=a.length;r.set(a,i),n.set(t,BigInt(e)),i+=e}}},VN=class extends rN{constructor(e){super(e),this._values=new tN}setValue(e,t){this._values.set(e,+t)}},HN=class extends iN{};HN.prototype._setValue=gA;var UN=class extends HN{};UN.prototype._setValue=dA;var WN=class extends HN{};WN.prototype._setValue=fA;var GN=class extends iN{};GN.prototype._setValue=DA;var KN=class extends rN{constructor({type:e,nullValues:t,dictionaryHashFunction:n}){super({type:new Kk(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=nF({type:this.type.indices,nullValues:t}),this.dictionary=nF({type:this.type.dictionary,nullValues:null}),typeof n==`function`&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(e){return this.indices.isValid(e)}setValid(e,t){let n=this.indices;return t=n.setValid(e,t),this.length=n.length,t}setValue(e,t){let n=this._keysToIndices,r=this.valueToKey(t),i=n[r];return i===void 0&&(n[r]=i=this._dictionaryOffset+this.dictionary.append(t).length-1),this.indices.setValue(e,i)}flush(){let e=this.type,t=this._dictionary,n=this.dictionary.toVector(),r=this.indices.flush().clone(e);return r.dictionary=t?t.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=r.dictionary,this.clear(),r}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(e){return typeof e==`string`?e:`${e}`}},qN=class extends iN{};qN.prototype._setValue=pA;var JN=class extends rN{setValue(e,t){let[n]=this.children,r=e*this.stride;for(let e=-1,i=t.length;++e<i;)n.set(r+e,t[e])}addChild(e,t=`0`){if(this.numChildren>0)throw Error(`FixedSizeListBuilder can only have one child.`);let n=this.children.push(e);return this.type=new Uk(this.type.listSize,new lN(t,e.type,!0)),n}},YN=class extends iN{setValue(e,t){this._values.set(e,t)}},XN=class extends YN{setValue(e,t){super.setValue(e,tA(t))}},ZN=class extends YN{},QN=class extends YN{},$N=class extends iN{};$N.prototype._setValue=zA;var eP=class extends $N{};eP.prototype._setValue=BA;var tP=class extends $N{};tP.prototype._setValue=VA;var nP=class extends iN{};nP.prototype._setValue=KA;var rP=class extends nP{};rP.prototype._setValue=HA;var iP=class extends nP{};iP.prototype._setValue=UA;var aP=class extends nP{};aP.prototype._setValue=WA;var oP=class extends nP{};oP.prototype._setValue=GA;var sP=class extends iN{setValue(e,t){this._values.set(e,t)}},cP=class extends sP{},lP=class extends sP{},uP=class extends sP{},dP=class extends sP{},fP=class extends sP{},pP=class extends sP{},mP=class extends sP{},hP=class extends sP{},gP=class extends aN{constructor(e){super(e),this._offsets=new nN(e.type)}addChild(e,t=`0`){if(this.numChildren>0)throw Error(`ListBuilder can only have one child.`);return this.children[this.numChildren]=e,this.type=new zk(new lN(t,e.type,!0)),this.numChildren-1}_flushPending(e){let t=this._offsets,[n]=this.children;for(let[r,i]of e)if(i===void 0)t.set(r,0);else{let e=i,a=e.length,o=t.set(r,a).buffer[r];for(let t=-1;++t<a;)n.set(o+t,e[t])}}},_P=class extends aN{set(e,t){return super.set(e,t)}setValue(e,t){let n=t instanceof Map?t:new Map(Object.entries(t)),r=this._pending||=new Map,i=r.get(e);i&&(this._pendingLength-=i.size),this._pendingLength+=n.size,r.set(e,n)}addChild(e,t=`${this.numChildren}`){if(this.numChildren>0)throw Error(`ListBuilder can only have one child.`);return this.children[this.numChildren]=e,this.type=new Wk(new lN(t,e.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(e){let t=this._offsets,[n]=this.children;for(let[r,i]of e)if(i===void 0)t.set(r,0);else{let{[r]:e,[r+1]:a}=t.set(r,i.size).buffer;for(let t of i.entries())if(n.set(e,t),++e>=a)break}}},vP=class extends rN{setValue(e,t){}setValid(e,t){return this.length=Math.max(e+1,this.length),t}},yP=class extends rN{setValue(e,t){let{children:n,type:r}=this;switch(Array.isArray(t)||t.constructor){case!0:return r.children.forEach((r,i)=>n[i].set(e,t[i]));case Map:return r.children.forEach((r,i)=>n[i].set(e,t.get(r.name)));default:return r.children.forEach((r,i)=>n[i].set(e,t[r.name]))}}setValid(e,t){return super.setValid(e,t)||this.children.forEach(n=>n.setValid(e,t)),t}addChild(e,t=`${this.numChildren}`){let n=this.children.push(e);return this.type=new Bk([...this.type.children,new lN(t,e.type,!0)]),n}},bP=class extends iN{};bP.prototype._setValue=xA;var xP=class extends bP{};xP.prototype._setValue=_A;var SP=class extends bP{};SP.prototype._setValue=vA;var CP=class extends bP{};CP.prototype._setValue=yA;var wP=class extends bP{};wP.prototype._setValue=bA;var TP=class extends iN{};TP.prototype._setValue=EA;var EP=class extends TP{};EP.prototype._setValue=SA;var DP=class extends TP{};DP.prototype._setValue=CA;var OP=class extends TP{};OP.prototype._setValue=wA;var kP=class extends TP{};kP.prototype._setValue=TA;var AP=class extends rN{constructor(e){super(e),this._typeIds=new eN(Int8Array,0,1),typeof e.valueToChildTypeId==`function`&&(this._valueToChildTypeId=e.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(e,t){return this.set(this.length,e,t)}set(e,t,n){return n===void 0&&(n=this._valueToChildTypeId(this,t,e)),this.setValue(e,t,n),this}setValue(e,t,n){this._typeIds.set(e,n);let r=this.type.typeIdToChildIndex[n];this.children[r]?.set(e,t)}addChild(e,t=`${this.children.length}`){let n=this.children.push(e),{type:{children:r,mode:i,typeIds:a}}=this,o=[...r,new lN(t,e.type)];return this.type=new Vk(i,[...a,n],o),n}_valueToChildTypeId(e,t,n){throw Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},jP=class extends AP{},MP=class extends AP{constructor(e){super(e),this._offsets=new eN(Int32Array)}setValue(e,t,n){let r=this._typeIds.set(e,n).buffer[e],i=this.getChildAt(this.type.typeIdToChildIndex[r]),a=this._offsets.set(e,i.length).buffer[e];i?.set(a,t)}},NP=class extends aN{constructor(e){super(e),this._values=new $M(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,qE(t))}_flushPending(e,t){}};NP.prototype._flushPending=zN.prototype._flushPending;var PP=class extends aN{constructor(e){super(e),this._values=new $M(Uint8Array)}get byteLength(){let e=this._pendingLength+this.length*4;return this._offsets&&(e+=this._offsets.byteLength),this._values&&(e+=this._values.byteLength),this._nulls&&(e+=this._nulls.byteLength),e}setValue(e,t){return super.setValue(e,qE(t))}_flushPending(e,t){}};PP.prototype._flushPending=BN.prototype._flushPending;var FP=new class extends Jk{visitNull(){return vP}visitBool(){return VN}visitInt(){return sP}visitInt8(){return cP}visitInt16(){return lP}visitInt32(){return uP}visitInt64(){return dP}visitUint8(){return fP}visitUint16(){return pP}visitUint32(){return mP}visitUint64(){return hP}visitFloat(){return YN}visitFloat16(){return XN}visitFloat32(){return ZN}visitFloat64(){return QN}visitUtf8(){return NP}visitLargeUtf8(){return PP}visitBinary(){return zN}visitLargeBinary(){return BN}visitFixedSizeBinary(){return qN}visitDate(){return HN}visitDateDay(){return UN}visitDateMillisecond(){return WN}visitTimestamp(){return bP}visitTimestampSecond(){return xP}visitTimestampMillisecond(){return SP}visitTimestampMicrosecond(){return CP}visitTimestampNanosecond(){return wP}visitTime(){return TP}visitTimeSecond(){return EP}visitTimeMillisecond(){return DP}visitTimeMicrosecond(){return OP}visitTimeNanosecond(){return kP}visitDecimal(){return GN}visitList(){return gP}visitStruct(){return yP}visitUnion(){return AP}visitDenseUnion(){return MP}visitSparseUnion(){return jP}visitDictionary(){return KN}visitInterval(){return $N}visitIntervalDayTime(){return eP}visitIntervalYearMonth(){return tP}visitDuration(){return nP}visitDurationSecond(){return rP}visitDurationMillisecond(){return iP}visitDurationMicrosecond(){return aP}visitDurationNanosecond(){return oP}visitFixedSizeList(){return JN}visitMap(){return _P}},IP=class extends Jk{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function LP(e,t){return t instanceof e.constructor}function RP(e,t){return e===t||LP(e,t)}function zP(e,t){return e===t||LP(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function BP(e,t){return e===t||LP(e,t)&&e.precision===t.precision}function VP(e,t){return e===t||LP(e,t)&&e.byteWidth===t.byteWidth}function HP(e,t){return e===t||LP(e,t)&&e.unit===t.unit}function UP(e,t){return e===t||LP(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function WP(e,t){return e===t||LP(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function GP(e,t){return e===t||LP(e,t)&&e.children.length===t.children.length&&$P.compareManyFields(e.children,t.children)}function KP(e,t){return e===t||LP(e,t)&&e.children.length===t.children.length&&$P.compareManyFields(e.children,t.children)}function qP(e,t){return e===t||LP(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&$P.compareManyFields(e.children,t.children)}function JP(e,t){return e===t||LP(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&$P.visit(e.indices,t.indices)&&$P.visit(e.dictionary,t.dictionary)}function YP(e,t){return e===t||LP(e,t)&&e.unit===t.unit}function XP(e,t){return e===t||LP(e,t)&&e.unit===t.unit}function ZP(e,t){return e===t||LP(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&$P.compareManyFields(e.children,t.children)}function QP(e,t){return e===t||LP(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&$P.compareManyFields(e.children,t.children)}IP.prototype.visitNull=RP,IP.prototype.visitBool=RP,IP.prototype.visitInt=zP,IP.prototype.visitInt8=zP,IP.prototype.visitInt16=zP,IP.prototype.visitInt32=zP,IP.prototype.visitInt64=zP,IP.prototype.visitUint8=zP,IP.prototype.visitUint16=zP,IP.prototype.visitUint32=zP,IP.prototype.visitUint64=zP,IP.prototype.visitFloat=BP,IP.prototype.visitFloat16=BP,IP.prototype.visitFloat32=BP,IP.prototype.visitFloat64=BP,IP.prototype.visitUtf8=RP,IP.prototype.visitLargeUtf8=RP,IP.prototype.visitBinary=RP,IP.prototype.visitLargeBinary=RP,IP.prototype.visitFixedSizeBinary=VP,IP.prototype.visitDate=HP,IP.prototype.visitDateDay=HP,IP.prototype.visitDateMillisecond=HP,IP.prototype.visitTimestamp=UP,IP.prototype.visitTimestampSecond=UP,IP.prototype.visitTimestampMillisecond=UP,IP.prototype.visitTimestampMicrosecond=UP,IP.prototype.visitTimestampNanosecond=UP,IP.prototype.visitTime=WP,IP.prototype.visitTimeSecond=WP,IP.prototype.visitTimeMillisecond=WP,IP.prototype.visitTimeMicrosecond=WP,IP.prototype.visitTimeNanosecond=WP,IP.prototype.visitDecimal=RP,IP.prototype.visitList=GP,IP.prototype.visitStruct=KP,IP.prototype.visitUnion=qP,IP.prototype.visitDenseUnion=qP,IP.prototype.visitSparseUnion=qP,IP.prototype.visitDictionary=JP,IP.prototype.visitInterval=YP,IP.prototype.visitIntervalDayTime=YP,IP.prototype.visitIntervalYearMonth=YP,IP.prototype.visitDuration=XP,IP.prototype.visitDurationSecond=XP,IP.prototype.visitDurationMillisecond=XP,IP.prototype.visitDurationMicrosecond=XP,IP.prototype.visitDurationNanosecond=XP,IP.prototype.visitFixedSizeList=ZP,IP.prototype.visitMap=QP;var $P=new IP;function eF(e,t){return $P.compareSchemas(e,t)}function tF(e,t){return $P.visit(e,t)}function nF(e){let t=e.type,n=new(FP.getVisitFn(t)())(e);if(t.children&&t.children.length>0){let r=e.children||[],i={nullValues:e.nullValues},a=Array.isArray(r)?((e,t)=>r[t]||i):(({name:e})=>r[e]||i);for(let[e,r]of t.children.entries()){let{type:t}=r,i=a(r,e);n.children.push(nF(Object.assign(Object.assign({},i),{type:t})))}}return n}function rF(e,t){if(e instanceof yM||e instanceof GM||e.type instanceof fk||ArrayBuffer.isView(e))return qM(e);let n=[...aF({type:t??iF(e),nullValues:[null]})(e)],r=n.length===1?n[0]:n.reduce((e,t)=>e.concat(t));return fk.isDictionary(r.type)?r.memoize():r}function iF(e){if(e.length===0)return new pk;let t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0;for(let l of e){if(l==null){++t;continue}switch(typeof l){case`bigint`:++o;continue;case`boolean`:++s;continue;case`number`:++i;continue;case`string`:++a;continue;case`object`:Array.isArray(l)?++n:Object.prototype.toString.call(l)===`[object Date]`?++c:++r;continue}throw TypeError(`Unable to infer Vector type from input values, explicit type declaration expected.`)}if(i+t===e.length)return new Ek;if(a+t===e.length)return new Kk(new kk,new _k);if(o+t===e.length)return new vk;if(s+t===e.length)return new jk;if(c+t===e.length)return new Ik;if(n+t===e.length){let t=e,n=iF(t[t.findIndex(e=>e!=null)]);if(t.every(e=>e==null||tF(n,iF(e))))return new zk(new lN(``,n,!0))}else if(r+t===e.length){let t=new Map;for(let n of e)for(let e of Object.keys(n))!t.has(e)&&n[e]!=null&&t.set(e,new lN(e,iF([n[e]]),!0));return new Bk([...t.values()])}throw TypeError(`Unable to infer Vector type from input values, explicit type declaration expected.`)}function aF(e){let{queueingStrategy:t=`count`}=e,{highWaterMark:n=t===`bytes`?2**14:1/0}=e,r=t===`bytes`?`byteLength`:`length`;return function*(t){let i=0,a=nF(e);for(let e of t)a.append(e)[r]>=n&&++i&&(yield a.toVector());(a.finish().length>0||i===0)&&(yield a.toVector())}}function oF(e,t){return sF(e,t.map(e=>e.data.concat()))}function sF(e,t){let n=[...e.fields],r=[],i={numBatches:t.reduce((e,t)=>Math.max(e,t.length),0)},a=0,o=0,s=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=1/0,s=-1;++s<c;)u[s]=l=t[s].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=cF(n,o,u,t,i),o>0&&(r[a++]=xM({type:new Bk(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new pF(e,t))]}function cF(e,t,n,r,i){let a=(t+63&-64)>>3;for(let o=-1,s=r.length;++o<s;){let s=n[o],c=s?.length;if(c>=t)c===t?n[o]=s:(n[o]=s.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(s.slice(t,c-t))));else{let r=e[o];e[o]=r.clone({nullable:!0}),n[o]=s?._changeLengthAndBackfillNullBitmap(t)??xM({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var lF,uF=class e{constructor(...t){if(t.length===0)return this.batches=[],this.schema=new cN([]),this._offsets=[0],this;let n,r;t[0]instanceof cN&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());let i=t=>{if(t){if(t instanceof pF)return[t];if(t instanceof e)return t.batches;if(t instanceof yM){if(t.type instanceof Bk)return[new pF(new cN(t.type.children),t)]}else if(Array.isArray(t))return t.flatMap(e=>i(e));else if(typeof t[Symbol.iterator]==`function`)return[...t].flatMap(e=>i(e));else if(typeof t==`object`){let e=Object.keys(t),r=e.map(e=>new GM([t[e]])),[,i]=oF(n??new cN(e.map((e,t)=>new lN(String(e),r[t].type,r[t].nullable))),r);return i.length===0?[new pF(t)]:i}}return[]},a=t.flatMap(e=>i(e));if(n=n??a[0]?.schema??new cN([]),!(n instanceof cN))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of a){if(!(e instanceof pF))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!eF(n,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=n,this.batches=a,this._offsets=r??TM(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=wM(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(eM(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?VM.visit(new GM(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`,
|
|
69
69
|
`)}\n]`}concat(...t){let n=this.schema;return new e(n,this.data.concat(t.flatMap(({data:e})=>e)).map(e=>new pF(n,e)))}slice(t,n){let r=this.schema;return[t,n]=$j({length:this.numRows},t,n),new e(r,EM(this.data,this._offsets,t,n).map(e=>new pF(r,e)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&e<this.schema.fields.length){let t=this.data.map(t=>t.children[e]);if(t.length===0){let{type:n}=this.schema.fields[e],r=xM({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new GM(t)}return null}setChild(e,t){return this.setChildAt(this.schema.fields?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||=new GM([xM({type:new pk,length:this.numRows})]);let e=r.fields.slice(),a=e[t].clone({type:n.type}),o=this.schema.fields.map((e,t)=>this.getChildAt(t));[e[t],o[t]]=[a,n],[r,i]=oF(r,o)}return new e(r,i)}select(e){let t=this.schema.fields.reduce((e,t,n)=>e.set(t.name,n),new Map);return this.selectAt(e.map(e=>t.get(e)).filter(e=>e>-1))}selectAt(t){return new e(this.schema.selectAt(t),this.batches.map(e=>e.selectAt(t)))}assign(t){let n=this.schema.fields,[r,i]=t.schema.fields.reduce((e,t,r)=>{let[i,a]=e,o=n.findIndex(e=>e.name===t.name);return~o?a[o]=r:i.push(r),e},[[],[]]);return new e(...oF(this.schema.assign(t.schema),[...n.map((e,t)=>[t,i[t]]).map(([e,n])=>n===void 0?this.getChildAt(e):t.getChildAt(n)),...r.map(e=>t.getChildAt(e))].filter(Boolean)))}};lF=Symbol.toStringTag,uF[lF]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=kM(OM),e.get=kM(Wj.getVisitFn(Z.Struct)),e.set=AM(JA.getVisitFn(Z.Struct)),e.indexOf=jM(LM.getVisitFn(Z.Struct)),`Table`))(uF.prototype);function dF(e){let t={},n=Object.entries(e);for(let[e,r]of n)t[e]=rF(r);return new uF(t)}var fF,pF=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof cN)||([,this.data=xM({nullCount:0,type:new Bk(this.schema.fields),children:this.schema.fields.map(e=>xM({type:e.type,nullCount:0}))})]=e,!(this.data instanceof yM)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=mF(this.schema,this.data.children);break;case 1:{let[t]=e,{fields:n,children:r,length:i}=Object.keys(t).reduce((e,n,r)=>(e.children[r]=t[n],e.length=Math.max(e.length,t[n].length),e.fields[r]=lN.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new cN(n),o=xM({type:new Bk(n),length:i,children:r,nullCount:0});[this.schema,this.data]=mF(a,o.children,i);break}default:throw TypeError(`RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.`)}}get dictionaries(){return this._dictionaries||=hF(this.schema.fields,this.data.children)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Wj.visit(this.data,e)}at(e){return this.get(eM(e,this.numRows))}set(e,t){return JA.visit(this.data,e,t)}indexOf(e,t){return LM.visit(this.data,e,t)}[Symbol.iterator](){return VM.visit(new GM([this.data]))}toArray(){return[...this]}concat(...e){return new uF(this.schema,[this,...e])}slice(t,n){let[r]=new GM([this.data]).slice(t,n).data;return new e(this.schema,r)}getChild(e){return this.getChildAt(this.schema.fields?.findIndex(t=>t.name===e))}getChildAt(e){return e>-1&&e<this.schema.fields.length?new GM([this.data.children[e]]):null}setChild(e,t){return this.setChildAt(this.schema.fields?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||=new GM([xM({type:new pk,length:this.numRows})]);let e=r.fields.slice(),a=i.children.slice(),o=e[t].clone({type:n.type});[e[t],a[t]]=[o,n.data[0]],r=new cN(e,new Map(this.schema.metadata)),i=xM({type:new Bk(e),children:a})}return new e(r,i)}select(t){let n=this.schema.select(t),r=new Bk(n.fields),i=[];for(let e of t){let t=this.schema.fields.findIndex(t=>t.name===e);~t&&(i[t]=this.data.children[t])}return new e(n,xM({type:r,length:this.numRows,children:i}))}selectAt(t){let n=this.schema.selectAt(t),r=t.map(e=>this.data.children[e]).filter(Boolean);return new e(n,xM({type:new Bk(n.fields),length:this.numRows,children:r}))}};fF=Symbol.toStringTag,pF[fF]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(pF.prototype);function mF(e,t,n=t.reduce((e,t)=>Math.max(e,t.length),0)){let r=[...e.fields],i=[...t],a=(n+63&-64)>>3;for(let[o,s]of e.fields.entries()){let e=t[o];(!e||e.length!==n)&&(r[o]=s.clone({nullable:!0}),i[o]=e?._changeLengthAndBackfillNullBitmap(n)??xM({type:s.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),xM({type:new Bk(r),length:n,children:i})]}function hF(e,t,n=new Map){if((e?.length??0)>0&&e?.length===t?.length)for(let r=-1,i=e.length;++r<i;){let{type:i}=e[r],a=t[r];for(let e of[a,...a?.dictionary?.data||[]])hF(i.children,e?.children,n);if(fk.isDictionary(i)){let{id:e}=i;if(!n.has(e))a?.dictionary&&n.set(e,a.dictionary);else if(n.get(e)!==a.dictionary)throw Error(`Cannot create Schema containing two different dictionaries with the same Id`)}}return n}var gF=class extends pF{constructor(e){let t=e.fields.map(e=>xM({type:e.type})),n=xM({type:new Bk(e.fields),nullCount:0,children:t});super(e,n)}},_F=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):PD.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):DO.NONE}header(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new iO).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,PD.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,DO.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt(`0`))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(t,n,r,i,a,o){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,r),e.addHeader(t,i),e.addBodyLength(t,a),e.addCustomMetadata(t,o),e.endMessage(t)}},vF=new class extends Jk{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return vO.startNull(t),vO.endNull(t)}visitInt(e,t){return nO.startInt(t),nO.addBitWidth(t,e.bitWidth),nO.addIsSigned(t,e.isSigned),nO.endInt(t)}visitFloat(e,t){return fO.startFloatingPoint(t),fO.addPrecision(t,e.precision),fO.endFloatingPoint(t)}visitBinary(e,t){return aO.startBinary(t),aO.endBinary(t)}visitLargeBinary(e,t){return mO.startLargeBinary(t),mO.endLargeBinary(t)}visitBool(e,t){return oO.startBool(t),oO.endBool(t)}visitUtf8(e,t){return CO.startUtf8(t),CO.endUtf8(t)}visitLargeUtf8(e,t){return hO.startLargeUtf8(t),hO.endLargeUtf8(t)}visitDecimal(e,t){return cO.startDecimal(t),cO.addScale(t,e.scale),cO.addPrecision(t,e.precision),cO.addBitWidth(t,e.bitWidth),cO.endDecimal(t)}visitDate(e,t){return sO.startDate(t),sO.addUnit(t,e.unit),sO.endDate(t)}visitTime(e,t){return bO.startTime(t),bO.addUnit(t,e.unit),bO.addBitWidth(t,e.bitWidth),bO.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return xO.startTimestamp(t),xO.addUnit(t,e.unit),n!==void 0&&xO.addTimezone(t,n),xO.endTimestamp(t)}visitInterval(e,t){return pO.startInterval(t),pO.addUnit(t,e.unit),pO.endInterval(t)}visitDuration(e,t){return lO.startDuration(t),lO.addUnit(t,e.unit),lO.endDuration(t)}visitList(e,t){return gO.startList(t),gO.endList(t)}visitStruct(e,t){return yO.startStruct_(t),yO.endStruct_(t)}visitUnion(e,t){SO.startTypeIdsVector(t,e.typeIds.length);let n=SO.createTypeIdsVector(t,e.typeIds);return SO.startUnion(t),SO.addMode(t,e.mode),SO.addTypeIds(t,n),SO.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return rO.startDictionaryEncoding(t),rO.addId(t,BigInt(e.id)),rO.addIsOrdered(t,e.isOrdered),n!==void 0&&rO.addIndexType(t,n),rO.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return uO.startFixedSizeBinary(t),uO.addByteWidth(t,e.byteWidth),uO.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return dO.startFixedSizeList(t),dO.addListSize(t,e.listSize),dO.endFixedSizeList(t)}visitMap(e,t){return _O.startMap(t),_O.addKeysSorted(t,e.keysSorted),_O.endMap(t)}};function yF(e,t=new Map){return new cN(SF(e,t),OF(e.metadata),t)}function bF(e){return new PF(e.count,wF(e.columns),TF(e.columns))}function xF(e){return new FF(bF(e.data),e.id,e.isDelta)}function SF(e,t){return(e.fields||[]).filter(Boolean).map(e=>lN.fromJSON(e,t))}function CF(e,t){return(e.children||[]).filter(Boolean).map(e=>lN.fromJSON(e,t))}function wF(e){return(e||[]).reduce((e,t)=>[...e,new LF(t.count,EF(t.VALIDITY)),...wF(t.children)],[])}function TF(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){let r=e[n];r.VALIDITY&&t.push(new IF(t.length,r.VALIDITY.length)),r.TYPE_ID&&t.push(new IF(t.length,r.TYPE_ID.length)),r.OFFSET&&t.push(new IF(t.length,r.OFFSET.length)),r.DATA&&t.push(new IF(t.length,r.DATA.length)),t=TF(r.children,t)}return t}function EF(e){return(e||[]).reduce((e,t)=>e+ +(t===0),0)}function DF(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=AF(e,CF(e,t)),i=new lN(e.name,o,e.nullable,OF(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?kF(r):new _k,s=new Kk(t.get(n),r,n,a.isOrdered),i=new lN(e.name,s,e.nullable,OF(e.metadata))):(r=(r=a.indexType)?kF(r):new _k,t.set(n,o=AF(e,CF(e,t))),s=new Kk(o,r,n,a.isOrdered),i=new lN(e.name,s,e.nullable,OF(e.metadata))),i||null}function OF(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function kF(e){return new mk(e.isSigned,e.bitWidth)}function AF(e,t){let n=e.type.name;switch(n){case`NONE`:return new pk;case`null`:return new pk;case`binary`:return new Dk;case`largebinary`:return new Ok;case`utf8`:return new kk;case`largeutf8`:return new Ak;case`bool`:return new jk;case`list`:return new zk((t||[])[0]);case`struct`:return new Bk(t||[]);case`struct_`:return new Bk(t||[])}switch(n){case`int`:{let t=e.type;return new mk(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new Ck(ID[t.precision])}case`decimal`:{let t=e.type;return new Mk(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new Nk(LD[t.unit])}case`time`:{let t=e.type;return new Pk(RD[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new Fk(RD[t.unit],t.timezone)}case`interval`:{let t=e.type;return new Lk(zD[t.unit])}case`duration`:{let t=e.type;return new Rk(RD[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase();return new Vk(FD[r.toUpperCase()+i.join(``)],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new Hk(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new Uk(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new Wk((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var jF=KD,MF=GD,NF=class e{static fromJSON(t,n){let r=new e(0,PD.V5,n);return r._createHeader=RF(t,n),r}static decode(t){t=new MF(vD(t));let n=_F.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=zF(n,a),o}static encode(e){let t=new jF,n=-1;return e.isSchema()?n=cN.encode(t,e.header()):e.isRecordBatch()?n=PF.encode(t,e.header()):e.isDictionaryBatch()&&(n=FF.encode(t,e.header())),_F.startMessage(t),_F.addVersion(t,PD.V5),_F.addHeader(t,n),_F.addHeaderType(t,e.headerType),_F.addBodyLength(t,BigInt(e.bodyLength)),_F.finishMessageBuffer(t,_F.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof cN)return new e(0,PD.V5,DO.Schema,t);if(t instanceof PF)return new e(n,PD.V5,DO.RecordBatch,t);if(t instanceof FF)return new e(n,PD.V5,DO.DictionaryBatch,t);throw Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===DO.Schema}isRecordBatch(){return this.headerType===DO.RecordBatch}isDictionaryBatch(){return this.headerType===DO.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=jO(e)}},PF=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,n){this._nodes=t,this._buffers=n,this._length=jO(e)}},FF=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(e,t,n=!1){this._data=e,this._isDelta=n,this._id=jO(t)}},IF=class{constructor(e,t){this.offset=jO(e),this.length=jO(t)}},LF=class{constructor(e,t){this.length=jO(e),this.nullCount=jO(t)}};function RF(e,t){return(()=>{switch(t){case DO.Schema:return cN.fromJSON(e);case DO.RecordBatch:return PF.fromJSON(e);case DO.DictionaryBatch:return FF.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${DO[t]}, type: ${t} }`)})}function zF(e,t){return(()=>{switch(t){case DO.Schema:return cN.decode(e.header(new EO),new Map,e.version());case DO.RecordBatch:return PF.decode(e.header(new QD),e.version());case DO.DictionaryBatch:return FF.decode(e.header(new $D),e.version())}throw Error(`Unrecognized Message type: { name: ${DO[t]}, type: ${t} }`)})}lN.encode=eI,lN.decode=YF,lN.fromJSON=DF,cN.encode=$F,cN.decode=BF,cN.fromJSON=yF,PF.encode=tI,PF.decode=VF,PF.fromJSON=bF,FF.encode=nI,FF.decode=HF,FF.fromJSON=xF,LF.encode=rI,LF.decode=WF,IF.encode=iI,IF.decode=UF;function BF(e,t=new Map,n=PD.V5){return new cN(qF(e,t),XF(e),t,n)}function VF(e,t=PD.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new PF(e.length(),GF(e),KF(e,t))}function HF(e,t=PD.V5){return new FF(PF.decode(e.data(),t),e.id(),e.isDelta())}function UF(e){return new IF(e.offset(),e.length())}function WF(e){return new LF(e.length(),e.nullCount())}function GF(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++r<a;)(n=e.nodes(r))&&(t[++i]=LF.decode(n));return t}function KF(e,t){let n=[];for(let r,i=-1,a=-1,o=e.buffersLength();++i<o;)(r=e.buffers(i))&&(t<PD.V4&&(r.bb_pos+=8*(i+1)),n[++a]=IF.decode(r));return n}function qF(e,t){let n=[];for(let r,i=-1,a=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++a]=lN.decode(r,t));return n}function JF(e,t){let n=[];for(let r,i=-1,a=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++a]=lN.decode(r,t));return n}function YF(e,t){let n,r,i,a,o,s;return!t||!(s=e.dictionary())?(i=QF(e,JF(e,t)),r=new lN(e.name(),i,e.nullable(),XF(e))):t.has(n=jO(s.id()))?(a=(a=s.indexType())?ZF(a):new _k,o=new Kk(t.get(n),a,n,s.isOrdered()),r=new lN(e.name(),o,e.nullable(),XF(e))):(a=(a=s.indexType())?ZF(a):new _k,t.set(n,i=QF(e,JF(e,t))),o=new Kk(i,a,n,s.isOrdered()),r=new lN(e.name(),o,e.nullable(),XF(e))),r||null}function XF(e){let t=new Map;if(e)for(let n,r,i=-1,a=Math.trunc(e.customMetadataLength());++i<a;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function ZF(e){return new mk(e.isSigned(),e.bitWidth())}function QF(e,t){let n=e.typeType();switch(n){case wO.NONE:return new pk;case wO.Null:return new pk;case wO.Binary:return new Dk;case wO.LargeBinary:return new Ok;case wO.Utf8:return new kk;case wO.LargeUtf8:return new Ak;case wO.Bool:return new jk;case wO.List:return new zk((t||[])[0]);case wO.Struct_:return new Bk(t||[])}switch(n){case wO.Int:{let t=e.type(new nO);return new mk(t.isSigned(),t.bitWidth())}case wO.FloatingPoint:return new Ck(e.type(new fO).precision());case wO.Decimal:{let t=e.type(new cO);return new Mk(t.scale(),t.precision(),t.bitWidth())}case wO.Date:return new Nk(e.type(new sO).unit());case wO.Time:{let t=e.type(new bO);return new Pk(t.unit(),t.bitWidth())}case wO.Timestamp:{let t=e.type(new xO);return new Fk(t.unit(),t.timezone())}case wO.Interval:return new Lk(e.type(new pO).unit());case wO.Duration:return new Rk(e.type(new lO).unit());case wO.Union:{let n=e.type(new SO);return new Vk(n.mode(),n.typeIdsArray()||[],t||[])}case wO.FixedSizeBinary:return new Hk(e.type(new uO).byteWidth());case wO.FixedSizeList:return new Uk(e.type(new dO).listSize(),(t||[])[0]);case wO.Map:{let n=e.type(new _O);return new Wk((t||[])[0],n.keysSorted())}}throw Error(`Unrecognized type: "${wO[n]}" (${n})`)}function $F(e,t){let n=t.fields.map(t=>lN.encode(e,t));EO.startFieldsVector(e,n.length);let r=EO.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?EO.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return iO.startKeyValue(e),iO.addKey(e,r),iO.addValue(e,i),iO.endKeyValue(e)})):-1;return EO.startSchema(e),EO.addFields(e,r),EO.addEndianness(e,aI?eO.Little:eO.Big),i!==-1&&EO.addCustomMetadata(e,i),EO.endSchema(e)}function eI(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;fk.isDictionary(a)?(o=a.dictionary.typeId,i=vF.visit(a,e),r=vF.visit(a.dictionary,e)):r=vF.visit(a,e);let s=(a.children||[]).map(t=>lN.encode(e,t)),c=TO.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?TO.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return iO.startKeyValue(e),iO.addKey(e,r),iO.addValue(e,i),iO.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),TO.startField(e),TO.addType(e,r),TO.addTypeType(e,o),TO.addChildren(e,c),TO.addNullable(e,!!t.nullable),n!==-1&&TO.addName(e,n),i!==-1&&TO.addDictionary(e,i),l!==-1&&TO.addCustomMetadata(e,l),TO.endField(e)}function tI(e,t){let n=t.nodes||[],r=t.buffers||[];QD.startNodesVector(e,n.length);for(let t of n.slice().reverse())LF.encode(e,t);let i=e.endVector();QD.startBuffersVector(e,r.length);for(let t of r.slice().reverse())IF.encode(e,t);let a=e.endVector();return QD.startRecordBatch(e),QD.addLength(e,BigInt(t.length)),QD.addNodes(e,i),QD.addBuffers(e,a),QD.endRecordBatch(e)}function nI(e,t){let n=PF.encode(e,t.data);return $D.startDictionaryBatch(e),$D.addId(e,BigInt(t.id)),$D.addIsDelta(e,t.isDelta),$D.addData(e,n),$D.endDictionaryBatch(e)}function rI(e,t){return ZD.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function iI(e,t){return XD.createBuffer(e,BigInt(t.offset),BigInt(t.length))}var aI=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),oI=e=>`Expected ${DO[e]} Message in stream, but was null or length 0.`,sI=e=>`Header pointer of flatbuffer-encoded ${DO[e]} Message is null or length 0.`,cI=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,lI=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`,uI=class{constructor(e){this.source=e instanceof SN?e:new SN(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?_N:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(oI(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=vD(this.source.read(e));if(t.byteLength<e)throw Error(lI(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()}readSchema(e=!1){let t=DO.Schema,n=this.readMessage(t)?.header();if(e&&!n)throw Error(sI(t));return n}readMetadataLength(){let e=this.source.read(4),t=(e&&new GD(e))?.readInt32(0)||0;return{done:t===0,value:t}}readMetadata(e){let t=this.source.read(e);if(!t)return _N;if(t.byteLength<e)throw Error(cI(e,t.byteLength));return{done:!1,value:NF.decode(t)}}},dI=class{constructor(e,t){this.source=e instanceof CN?e:rD(e)?new DN(e,t):new CN(e)}[Symbol.asyncIterator](){return this}next(){return RE(this,void 0,void 0,function*(){let e;return(e=yield this.readMetadataLength()).done||e.value===-1&&(e=yield this.readMetadataLength()).done||(e=yield this.readMetadata(e.value)).done?_N:e})}throw(e){return RE(this,void 0,void 0,function*(){return yield this.source.throw(e)})}return(e){return RE(this,void 0,void 0,function*(){return yield this.source.return(e)})}readMessage(e){return RE(this,void 0,void 0,function*(){let t;if((t=yield this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(oI(e));return t.value})}readMessageBody(e){return RE(this,void 0,void 0,function*(){if(e<=0)return new Uint8Array;let t=vD(yield this.source.read(e));if(t.byteLength<e)throw Error(lI(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()})}readSchema(){return RE(this,arguments,void 0,function*(e=!1){let t=DO.Schema,n=(yield this.readMessage(t))?.header();if(e&&!n)throw Error(sI(t));return n})}readMetadataLength(){return RE(this,void 0,void 0,function*(){let e=yield this.source.read(4),t=(e&&new GD(e))?.readInt32(0)||0;return{done:t===0,value:t}})}readMetadata(e){return RE(this,void 0,void 0,function*(){let t=yield this.source.read(e);if(!t)return _N;if(t.byteLength<e)throw Error(cI(e,t.byteLength));return{done:!1,value:NF.decode(t)}})}},fI=class extends uI{constructor(e){super(new Uint8Array),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof vN?e:new vN(e)}next(){let{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:NF.fromJSON(e.schema,DO.Schema)};if(this._dictionaryIndex<e.dictionaries.length){let t=e.dictionaries[this._dictionaryIndex++];return this._body=t.data.columns,{done:!1,value:NF.fromJSON(t,DO.DictionaryBatch)}}if(this._batchIndex<e.batches.length){let t=e.batches[this._batchIndex++];return this._body=t.columns,{done:!1,value:NF.fromJSON(t,DO.RecordBatch)}}return this._body=[],_N}readMessageBody(e){return t(this._body);function t(e){return(e||[]).reduce((e,n)=>[...e,...n.VALIDITY&&[n.VALIDITY]||[],...n.TYPE_ID&&[n.TYPE_ID]||[],...n.OFFSET&&[n.OFFSET]||[],...n.DATA&&[n.DATA]||[],...t(n.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(oI(e));return t.value}readSchema(){let e=DO.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(sI(e));return n}},pI=`ARROW1`,mI=new Uint8Array(6);for(let e=0;e<6;e+=1)mI[e]=pI.codePointAt(e);function hI(e,t=0){for(let n=-1,r=mI.length;++n<r;)if(mI[n]!==e[t+n])return!1;return!0}var gI=mI.length,_I=gI+4,vI=gI*2+4,yI=class e extends yN{constructor(e){super(),this._impl=e}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(e){return this._impl.throw(e)}return(e){return this._impl.return(e)}cancel(){return this._impl.cancel()}reset(e){return this._impl.reset(e),this._DOMStream=void 0,this._nodeStream=void 0,this}open(e){let t=this._impl.open(e);return QE(t)?t.then(()=>this):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return ED.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ED.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}static from(t){return t instanceof e?t:tD(t)?NI(t):rD(t)?II(t):QE(t)?RE(this,void 0,void 0,function*(){return yield e.from(yield t)}):iD(t)||sD(t)||lD(t)||eD(t)?FI(new CN(t)):PI(new SN(t))}static readAll(t){return t instanceof e?t.isSync()?jI(t):MI(t):tD(t)||ArrayBuffer.isView(t)||$E(t)||nD(t)?jI(t):MI(t)}},bI=class extends yI{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return VE(this,arguments,function*(){yield BE(yield*HE(UE(this[Symbol.iterator]())))})}},xI=class extends yI{constructor(e){super(e),this._impl=e}readAll(){return RE(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=UE(this),s;s=yield o.next(),e=s.done,!e;a=!0){r=s.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=o.return)&&(yield n.call(o))}finally{if(t)throw t.error}}return i})}[Symbol.iterator](){throw Error(`AsyncRecordBatchStreamReader is not Iterable`)}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},SI=class extends bI{constructor(e){super(e),this._impl=e}},CI=class extends xI{constructor(e){super(e),this._impl=e}},wI=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){let n=this._loadVectors(e,t,this.schema.fields),r=xM({type:new Bk(this.schema.fields),length:e.length,children:n});return new pF(this.schema,r)}_loadDictionaryBatch(e,t){let{id:n,isDelta:r}=e,{dictionaries:i,schema:a}=this,o=i.get(n),s=a.dictionaries.get(n),c=this._loadVectors(e.data,t,[s]);return(o&&r?o.concat(new GM(c)):new GM(c)).memoize()}_loadVectors(e,t,n){return new IN(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},TI=class extends wI{constructor(e,t){super(t),this._reader=tD(e)?new fI(this._handle=e):new uI(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=AI(this,e),(this.schema||=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):_N}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):_N}next(){if(this.closed)return _N;let e,{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gF(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},EI=class extends wI{constructor(e,t){super(t),this._reader=new dI(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return RE(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return RE(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=AI(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return RE(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):_N})}return(e){return RE(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):_N})}next(){return RE(this,void 0,void 0,function*(){if(this.closed)return _N;let e,{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new gF(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return RE(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},DI=class extends TI{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof EN?e:new EN(e),t)}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){if(this.closed)return null;this._footer||this.open();let t=this._footer?.getRecordBatch(e);if(t&&this._handle.seek(t.offset)){let e=this._reader.readMessage(DO.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength);return this._loadRecordBatch(t,n)}}return null}_readDictionaryBatch(e){let t=this._footer?.getDictionaryBatch(e);if(t&&this._handle.seek(t.offset)){let e=this._reader.readMessage(DO.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}}_readFooter(){let{_handle:e}=this,t=e.size-_I,n=e.readInt32(t),r=e.readAt(t-n,n);return mN.decode(r)}_readNextMessageAndValidate(e){if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let t=this._footer?.getRecordBatch(this._recordBatchIndex);if(t&&this._handle.seek(t.offset))return this._reader.readMessage(e)}return null}},OI=class extends EI{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,...t){let n=typeof t[0]==`number`?void 0:t.shift(),r=t[0]instanceof Map?t.shift():void 0;super(e instanceof DN?e:new DN(e,n),r)}isFile(){return!0}isAsync(){return!0}open(e){let t=Object.create(null,{open:{get:()=>super.open}});return RE(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield t.open.call(this,e)})}readRecordBatch(e){return RE(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let t=this._footer?.getRecordBatch(e);if(t&&(yield this._handle.seek(t.offset))){let e=yield this._reader.readMessage(DO.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength);return this._loadRecordBatch(t,n)}}return null})}_readDictionaryBatch(e){return RE(this,void 0,void 0,function*(){let t=this._footer?.getDictionaryBatch(e);if(t&&(yield this._handle.seek(t.offset))){let e=yield this._reader.readMessage(DO.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}})}_readFooter(){return RE(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-_I,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return mN.decode(r)})}_readNextMessageAndValidate(e){return RE(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let t=this._footer.getRecordBatch(this._recordBatchIndex);if(t&&(yield this._handle.seek(t.offset)))return yield this._reader.readMessage(e)}return null})}},kI=class extends TI{constructor(e,t){super(e,t)}_loadVectors(e,t,n){return new LN(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function AI(e,t){return t&&typeof t.autoDestroy==`boolean`?t.autoDestroy:e.autoDestroy}function*jI(e){let t=yI.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function MI(e){return VE(this,arguments,function*(){let t=yield BE(yI.from(e));try{if(!(yield BE(t.open({autoDestroy:!1}))).closed)do yield yield BE(t);while(!(yield BE(t.reset().open())).closed)}finally{yield BE(t.cancel())}})}function NI(e){return new bI(new kI(e))}function PI(e){let t=e.peek(gI+7&-8);return t&&t.byteLength>=4?hI(t)?new SI(new DI(e.read())):new bI(new TI(e)):new bI(new TI(function*(){}()))}function FI(e){return RE(this,void 0,void 0,function*(){let t=yield e.peek(gI+7&-8);return t&&t.byteLength>=4?hI(t)?new SI(new DI(yield e.read())):new xI(new EI(e)):new xI(new EI(function(){return VE(this,arguments,function*(){})}()))})}function II(e){return RE(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new DN(e,t);return t>=vI&&hI(yield n.readAt(0,gI+7&-8))?new CI(new OI(n)):new xI(new EI(n))})}var LI=class e extends Jk{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof pF?e.data.children:e.data),r=new e;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof GM)return this.visitMany(e.data),this;let{type:t}=e;if(!fk.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(fk.isUnion(t))this.nodes.push(new LF(n,0));else{let{nullCount:r}=e;fk.isNull(t)||RI.call(this,r<=0?new Uint8Array:pM(e.offset,n,e.nullBitmap)),this.nodes.push(new LF(n,r))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function RI(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new IF(this._byteLength,t)),this._byteLength+=t,this}function zI(e){let{type:t,length:n,typeIds:r,valueOffsets:i}=e;if(RI.call(this,r),t.mode===FD.Sparse)return WI.call(this,e);if(t.mode===FD.Dense){if(e.offset<=0)return RI.call(this,i),WI.call(this,e);{let a=new Int32Array(n),o=Object.create(null),s=Object.create(null);for(let e,t,c=-1;++c<n;)(e=r[c])!==void 0&&((t=o[e])===void 0&&(t=o[e]=i[c]),a[c]=i[c]-t,s[e]=(s[e]??0)+1);RI.call(this,a),this.visitMany(e.children.map((e,r)=>{let i=t.typeIds[r],a=o[i],c=s[i];return e.slice(a,Math.min(n,c))}))}}return this}function BI(e){let t;return e.nullCount>=e.length?RI.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?RI.call(this,pM(e.offset,e.length,t)):RI.call(this,mM(e.values))}function VI(e){return RI.call(this,e.values.subarray(0,e.length*e.stride))}function HI(e){let{length:t,values:n,valueOffsets:r}=e,i=jO(r[0]),a=jO(r[t]),o=Math.min(a-i,n.byteLength-i);return RI.call(this,wD(-i,t+1,r)),RI.call(this,n.subarray(i,i+o)),this}function UI(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return RI.call(this,wD(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function WI(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}LI.prototype.visitBool=BI,LI.prototype.visitInt=VI,LI.prototype.visitFloat=VI,LI.prototype.visitUtf8=HI,LI.prototype.visitLargeUtf8=HI,LI.prototype.visitBinary=HI,LI.prototype.visitLargeBinary=HI,LI.prototype.visitFixedSizeBinary=VI,LI.prototype.visitDate=VI,LI.prototype.visitTimestamp=VI,LI.prototype.visitTime=VI,LI.prototype.visitDecimal=VI,LI.prototype.visitList=UI,LI.prototype.visitStruct=WI,LI.prototype.visitUnion=zI,LI.prototype.visitInterval=VI,LI.prototype.visitDuration=VI,LI.prototype.visitFixedSizeList=UI,LI.prototype.visitMap=UI;var GI=class extends yN{static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}constructor(e){super(),this._position=0,this._started=!1,this._sink=new xN,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ZE(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy==`boolean`?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`?e.writeLegacyIpcFormat:!1}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return QE(e)?e.then(e=>this.writeAll(e)):eD(e)?YI(this,e):JI(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof xN?this._sink=e:(this._sink=new xN,e&&oD(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&cD(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!t||!eF(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(!this._sink)throw Error(`RecordBatchWriter is closed`);if(e==null||e instanceof uF&&!(t=e.schema)||e instanceof pF&&!(t=e.schema))return this.finish()&&void 0;if(t&&!eF(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof pF?e instanceof gF||this._writeRecordBatch(e):e instanceof uF?this.writeAll(e.batches):$E(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=NF.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===DO.RecordBatch?this._recordBatchBlocks.push(new gN(o,e.bodyLength,this._position)):e.headerType===DO.DictionaryBatch&&this._dictionaryBlocks.push(new gN(o,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),i>0&&this._write(r),this._writePadding(s)}_write(e){if(this._started){let t=vD(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(NF.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(mI)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=LI.assemble(e),a=new PF(e.numRows,n,r),o=NF.from(a,t);return this._writeDictionaries(e)._writeMessage(o)._writeBodyBuffers(i)}_writeDictionaryBatch(e,t,n=!1){let{byteLength:r,nodes:i,bufferRegions:a,buffers:o}=LI.assemble(new GM([e])),s=new FF(new PF(e.length,i,a),t,n),c=NF.from(s,r);return this._writeMessage(c)._writeBodyBuffers(o)}_writeBodyBuffers(e){let t,n,r;for(let i=-1,a=e.length;++i<a;)(t=e[i])&&(n=t.byteLength)>0&&(this._write(t),(r=(n+7&-8)-n)>0&&this._writePadding(r));return this}_writeDictionaries(e){for(let[t,n]of e.dictionaries){let e=n?.data??[],r=this._seenDictionaries.get(t),i=this._dictionaryDeltaOffsets.get(t)??0;if(!r||r.data[0]!==e[0])for(let[n,r]of e.entries())this._writeDictionaryBatch(r,t,n>0);else if(i<e.length)for(let n of e.slice(i))this._writeDictionaryBatch(n,t,!0);this._seenDictionaries.set(t,n),this._dictionaryDeltaOffsets.set(t,e.length)}return this}},KI=class e extends GI{static writeAll(t,n){let r=new e(n);return QE(t)?t.then(e=>r.writeAll(e)):eD(t)?YI(r,t):JI(r,t)}},qI=class e extends GI{static writeAll(t){let n=new e;return QE(t)?t.then(e=>n.writeAll(e)):eD(t)?YI(n,t):JI(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,t,n=!1){if(!n&&this._seenDictionaries.has(t))throw Error(`The Arrow File format does not support replacement dictionaries. `);return super._writeDictionaryBatch(e,t,n)}_writeFooter(e){let t=mN.encode(new mN(e,PD.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function JI(e,t){let n=t;t instanceof uF&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function YI(e,t){return RE(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=UE(t);i=yield r.next(),a=i.done,!a;n=!0){c=i.value,n=!1;let t=c;e.write(t)}}catch(e){o={error:e}}finally{try{!n&&!a&&(s=r.return)&&(yield s.call(r))}finally{if(o)throw o.error}}return e.finish()})}function XI(e,t=`stream`){return(t===`stream`?KI:qI).writeAll(e).toUint8Array(!0)}var ZI=Object.create,QI=Object.defineProperty,$I=Object.getOwnPropertyDescriptor,eL=Object.getOwnPropertyNames,tL=Object.getPrototypeOf,nL=Object.prototype.hasOwnProperty,rL=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),iL=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of eL(t))!nL.call(e,i)&&i!==n&&QI(e,i,{get:()=>t[i],enumerable:!(r=$I(t,i))||r.enumerable});return e},aL=(e,t,n)=>(n=e==null?{}:ZI(tL(e)),iL(t||!e||!e.__esModule?QI(n,`default`,{value:e,enumerable:!0}):n,e)),oL=rL((e,t)=>{t.exports=Worker}),sL=(e=>(e[e.UNDEFINED=0]=`UNDEFINED`,e[e.AUTOMATIC=1]=`AUTOMATIC`,e[e.READ_ONLY=2]=`READ_ONLY`,e[e.READ_WRITE=3]=`READ_WRITE`,e))(sL||{}),cL=(e=>(e[e.IDENTIFIER=0]=`IDENTIFIER`,e[e.NUMERIC_CONSTANT=1]=`NUMERIC_CONSTANT`,e[e.STRING_CONSTANT=2]=`STRING_CONSTANT`,e[e.OPERATOR=3]=`OPERATOR`,e[e.KEYWORD=4]=`KEYWORD`,e[e.COMMENT=5]=`COMMENT`,e))(cL||{}),lL=(e=>(e[e.NONE=0]=`NONE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARNING=3]=`WARNING`,e[e.ERROR=4]=`ERROR`,e))(lL||{}),uL=(e=>(e[e.NONE=0]=`NONE`,e[e.CONNECT=1]=`CONNECT`,e[e.DISCONNECT=2]=`DISCONNECT`,e[e.OPEN=3]=`OPEN`,e[e.QUERY=4]=`QUERY`,e[e.INSTANTIATE=5]=`INSTANTIATE`,e))(uL||{}),dL=(e=>(e[e.NONE=0]=`NONE`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`,e[e.START=3]=`START`,e[e.RUN=4]=`RUN`,e[e.CAPTURE=5]=`CAPTURE`,e))(dL||{}),fL=(e=>(e[e.NONE=0]=`NONE`,e[e.WEB_WORKER=1]=`WEB_WORKER`,e[e.NODE_WORKER=2]=`NODE_WORKER`,e[e.BINDINGS=3]=`BINDINGS`,e[e.ASYNC_DUCKDB=4]=`ASYNC_DUCKDB`,e))(fL||{}),pL=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},mL=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.MAX_ARROW_ERROR=255]=`MAX_ARROW_ERROR`,e[e.DUCKDB_WASM_RETRY=256]=`DUCKDB_WASM_RETRY`,e))(mL||{}),hL=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=yI.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new uF(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;){if(this._bindings.isDetached()){console.error(`cannot send a message since the worker is not set!`);return}n=await this._bindings.pollPendingQuery(this._conn)}let r=new gL(this._bindings,this._conn,n),i=await yI.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new _L(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=XI(e,`stream`);await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},gL=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;for(this._inFlight!=null&&(e=await this._inFlight,this._inFlight=null);e==null;)e=await this.db.fetchQueryResults(this.conn);return this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},_L=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=yI.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new uF(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new gL(this.bindings,this.connectionId,t),r=await yI.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},vL=(e=>(e.CANCEL_PENDING_QUERY=`CANCEL_PENDING_QUERY`,e.CLOSE_PREPARED=`CLOSE_PREPARED`,e.COLLECT_FILE_STATISTICS=`COLLECT_FILE_STATISTICS`,e.REGISTER_OPFS_FILE_NAME=`REGISTER_OPFS_FILE_NAME`,e.CONNECT=`CONNECT`,e.COPY_FILE_TO_BUFFER=`COPY_FILE_TO_BUFFER`,e.COPY_FILE_TO_PATH=`COPY_FILE_TO_PATH`,e.CREATE_PREPARED=`CREATE_PREPARED`,e.DISCONNECT=`DISCONNECT`,e.DROP_FILE=`DROP_FILE`,e.DROP_FILES=`DROP_FILES`,e.EXPORT_FILE_STATISTICS=`EXPORT_FILE_STATISTICS`,e.FETCH_QUERY_RESULTS=`FETCH_QUERY_RESULTS`,e.FLUSH_FILES=`FLUSH_FILES`,e.GET_FEATURE_FLAGS=`GET_FEATURE_FLAGS`,e.GET_TABLE_NAMES=`GET_TABLE_NAMES`,e.GET_VERSION=`GET_VERSION`,e.GLOB_FILE_INFOS=`GLOB_FILE_INFOS`,e.INSERT_ARROW_FROM_IPC_STREAM=`INSERT_ARROW_FROM_IPC_STREAM`,e.INSERT_CSV_FROM_PATH=`IMPORT_CSV_FROM_PATH`,e.INSERT_JSON_FROM_PATH=`IMPORT_JSON_FROM_PATH`,e.INSTANTIATE=`INSTANTIATE`,e.OPEN=`OPEN`,e.PING=`PING`,e.POLL_PENDING_QUERY=`POLL_PENDING_QUERY`,e.REGISTER_FILE_BUFFER=`REGISTER_FILE_BUFFER`,e.REGISTER_FILE_HANDLE=`REGISTER_FILE_HANDLE`,e.REGISTER_FILE_URL=`REGISTER_FILE_URL`,e.RESET=`RESET`,e.RUN_PREPARED=`RUN_PREPARED`,e.RUN_QUERY=`RUN_QUERY`,e.SEND_PREPARED=`SEND_PREPARED`,e.START_PENDING_QUERY=`START_PENDING_QUERY`,e.TOKENIZE=`TOKENIZE`,e))(vL||{}),yL=(e=>(e.CONNECTION_INFO=`CONNECTION_INFO`,e.ERROR=`ERROR`,e.FEATURE_FLAGS=`FEATURE_FLAGS`,e.FILE_BUFFER=`FILE_BUFFER`,e.FILE_INFOS=`FILE_INFOS`,e.FILE_SIZE=`FILE_SIZE`,e.FILE_STATISTICS=`FILE_STATISTICS`,e.INSTANTIATE_PROGRESS=`INSTANTIATE_PROGRESS`,e.LOG=`LOG`,e.PROGRESS_UPDATE=`PROGRESS_UPDATE`,e.OK=`OK`,e.PREPARED_STATEMENT_ID=`PREPARED_STATEMENT_ID`,e.QUERY_PLAN=`QUERY_PLAN`,e.QUERY_RESULT=`QUERY_RESULT`,e.QUERY_RESULT_CHUNK=`QUERY_RESULT_CHUNK`,e.QUERY_RESULT_HEADER=`QUERY_RESULT_HEADER`,e.QUERY_RESULT_HEADER_OR_NULL=`QUERY_RESULT_HEADER_OR_NULL`,e.REGISTERED_FILE=`REGISTERED_FILE`,e.SCRIPT_TOKENS=`SCRIPT_TOKENS`,e.SUCCESS=`SUCCESS`,e.TABLE_NAMES=`TABLE_NAMES`,e.VERSION_STRING=`VERSION_STRING`,e))(yL||{}),bL=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((e,t)=>{this.promiseResolver=e,this.promiseRejecter=t})}};function xL(e){switch(e.typeId){case Z.Binary:return{sqlType:`binary`};case Z.Bool:return{sqlType:`bool`};case Z.Date:return{sqlType:`date`};case Z.DateDay:return{sqlType:`date32[d]`};case Z.DateMillisecond:return{sqlType:`date64[ms]`};case Z.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case Z.Float:return{sqlType:`float`};case Z.Float16:return{sqlType:`float16`};case Z.Float32:return{sqlType:`float32`};case Z.Float64:return{sqlType:`float64`};case Z.Int:return{sqlType:`int32`};case Z.Int16:return{sqlType:`int16`};case Z.Int32:return{sqlType:`int32`};case Z.Int64:return{sqlType:`int64`};case Z.Uint16:return{sqlType:`uint16`};case Z.Uint32:return{sqlType:`uint32`};case Z.Uint64:return{sqlType:`uint64`};case Z.Uint8:return{sqlType:`uint8`};case Z.IntervalDayTime:return{sqlType:`interval[dt]`};case Z.IntervalYearMonth:return{sqlType:`interval[m]`};case Z.List:return{sqlType:`list`,valueType:xL(e.valueType)};case Z.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case Z.Null:return{sqlType:`null`};case Z.Utf8:return{sqlType:`utf8`};case Z.Struct:return{sqlType:`struct`,fields:e.children.map(e=>SL(e.name,e.type))};case Z.Map:{let t=e;return{sqlType:`map`,keyType:xL(t.keyType),valueType:xL(t.valueType)}}case Z.Time:return{sqlType:`time[s]`};case Z.TimeMicrosecond:return{sqlType:`time[us]`};case Z.TimeMillisecond:return{sqlType:`time[ms]`};case Z.TimeNanosecond:return{sqlType:`time[ns]`};case Z.TimeSecond:return{sqlType:`time[s]`};case Z.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case Z.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case Z.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case Z.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case Z.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function SL(e,t){let n=xL(t);return n.name=e,n}var CL=/'(opfs:\/\/\S*?)'/g,wL=/(opfs:\/\/\S*?)/g;function TL(e){return e.search(wL)>-1}function EL(e){return[...e.matchAll(CL)].map(e=>e[1])}var DL=new TextEncoder,OL=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._config={},this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}get config(){return this._config}attach(e){this._worker=e,this._worker.addEventListener(`message`,this._onMessageHandler),this._worker.addEventListener(`error`,this._onErrorHandler),this._worker.addEventListener(`close`,this._onCloseHandler),this._workerShutdownPromise=new Promise((e,t)=>{this._workerShutdownResolver=e})}detach(){this._worker&&(this._worker.removeEventListener(`message`,this._onMessageHandler),this._worker.removeEventListener(`error`,this._onErrorHandler),this._worker.removeEventListener(`close`,this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error(`cannot send a message since the worker is not set!:`+e.type+`,`+e.data);return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case`PROGRESS_UPDATE`:for(let e of this._onExecutionProgress)e(n.data);return;case`LOG`:this._logger.log(n.data);return;case`INSTANTIATE_PROGRESS`:for(let e of this._onInstantiationProgress)e(n.data);return}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn(`unassociated response: [${n.requestId}, ${n.type.toString()}]`);return}if(this._pendingRequests.delete(n.requestId),n.type==`ERROR`){let e=Error(n.data.message);e.name=n.data.name,(t=Object.getOwnPropertyDescriptor(e,`stack`))!=null&&t.writable&&(e.stack=n.data.stack),r.promiseRejecter(e);return}switch(r.type){case`CLOSE_PREPARED`:case`COLLECT_FILE_STATISTICS`:case`REGISTER_OPFS_FILE_NAME`:case`COPY_FILE_TO_PATH`:case`DISCONNECT`:case`DROP_FILE`:case`DROP_FILES`:case`FLUSH_FILES`:case`INSERT_ARROW_FROM_IPC_STREAM`:case`IMPORT_CSV_FROM_PATH`:case`IMPORT_JSON_FROM_PATH`:case`OPEN`:case`PING`:case`REGISTER_FILE_BUFFER`:case`REGISTER_FILE_HANDLE`:case`REGISTER_FILE_URL`:case`RESET`:if(n.type==`OK`){r.promiseResolver(n.data);return}break;case`INSTANTIATE`:if(this._onInstantiationProgress=[],n.type==`OK`){r.promiseResolver(n.data);return}break;case`GLOB_FILE_INFOS`:if(n.type==`FILE_INFOS`){r.promiseResolver(n.data);return}break;case`GET_VERSION`:if(n.type==`VERSION_STRING`){r.promiseResolver(n.data);return}break;case`GET_FEATURE_FLAGS`:if(n.type==`FEATURE_FLAGS`){r.promiseResolver(n.data);return}break;case`GET_TABLE_NAMES`:if(n.type==`TABLE_NAMES`){r.promiseResolver(n.data);return}break;case`TOKENIZE`:if(n.type==`SCRIPT_TOKENS`){r.promiseResolver(n.data);return}break;case`COPY_FILE_TO_BUFFER`:if(n.type==`FILE_BUFFER`){r.promiseResolver(n.data);return}break;case`EXPORT_FILE_STATISTICS`:if(n.type==`FILE_STATISTICS`){r.promiseResolver(n.data);return}break;case`CONNECT`:if(n.type==`CONNECTION_INFO`){r.promiseResolver(n.data);return}break;case`RUN_PREPARED`:case`RUN_QUERY`:if(n.type==`QUERY_RESULT`){r.promiseResolver(n.data);return}break;case`SEND_PREPARED`:if(n.type==`QUERY_RESULT_HEADER`){r.promiseResolver(n.data);return}break;case`START_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`POLL_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`CANCEL_PENDING_QUERY`:if(this._onInstantiationProgress=[],n.type==`SUCCESS`){r.promiseResolver(n.data);return}break;case`FETCH_QUERY_RESULTS`:if(n.type==`QUERY_RESULT_CHUNK`){r.promiseResolver(n.data);return}break;case`CREATE_PREPARED`:if(n.type==`PREPARED_STATEMENT_ID`){r.promiseResolver(n.data);return}break}r.promiseRejecter(Error(`unexpected response type: ${n.type.toString()}`))}onError(e){console.error(e),console.error(`error in duckdb worker: ${e.message}`),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);return}this._pendingRequests.clear()}isDetached(){return!this._worker}async reset(){let e=new bL(`RESET`,null);return await this.postTask(e)}async ping(){let e=new bL(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new bL(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(e){let t=new bL(`DROP_FILES`,e);return await this.postTask(t)}async flushFiles(){let e=new bL(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new bL(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new bL(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new bL(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){this._config=e;let t=new bL(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new bL(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new bL(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new hL(this,e)}async disconnect(e){let t=new bL(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){if(this.shouldOPFSFileHandling()){let n=await this.registerOPFSFileFromSQL(t);try{return await this._runQueryAsync(e,t)}finally{n.length>0&&await this.dropFiles(n)}}else return await this._runQueryAsync(e,t)}async _runQueryAsync(e,t){let n=new bL(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){if(this.shouldOPFSFileHandling()){let r=await this.registerOPFSFileFromSQL(t);try{return await this._startPendingQueryAsync(e,t,n)}finally{r.length>0&&await this.dropFiles(r)}}else return await this._startPendingQueryAsync(e,t,n)}async _startPendingQueryAsync(e,t,n=!1){let r=new bL(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new bL(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new bL(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new bL(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new bL(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new bL(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new bL(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new bL(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new bL(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new bL(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=DL.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new bL(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new bL(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new bL(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new bL(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new bL(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new bL(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new bL(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new bL(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new bL(`INSERT_ARROW_FROM_IPC_STREAM`,[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(SL(t,r))}n.columnsFlat=e,delete n.columns}let r=new bL(`IMPORT_CSV_FROM_PATH`,[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(SL(t,r))}n.columnsFlat=e,delete n.columns}let r=new bL(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}shouldOPFSFileHandling(){return TL(this.config.path??``)?this.config.opfs?.fileHandling==`auto`:!1}async registerOPFSFileFromSQL(e){let t=EL(e),n=[];for(let e of t)try{await this.registerOPFSFileName(e),n.push(e)}catch(t){throw console.error(t),Error(`File Not found:`+e)}return n}};function kL(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}kL();var AL=(e=>(e[e.BUFFER=0]=`BUFFER`,e[e.NODE_FS=1]=`NODE_FS`,e[e.BROWSER_FILEREADER=2]=`BROWSER_FILEREADER`,e[e.BROWSER_FSACCESS=3]=`BROWSER_FSACCESS`,e[e.HTTP=4]=`HTTP`,e[e.S3=5]=`S3`,e))(AL||{}),jL={name:`@duckdb/duckdb-wasm`,version:`1.33.1-dev45.0`,description:`DuckDB powered by WebAssembly`,license:`MIT`,repository:{type:`git`,url:`https://github.com/duckdb/duckdb-wasm.git`},keywords:[`sql`,`duckdb`,`relational`,`database`,`data`,`query`,`wasm`,`analytics`,`olap`,`arrow`,`parquet`,`json`,`csv`],dependencies:{"apache-arrow":`^17.0.0`,qs:`^6.14.1`},devDependencies:{"@types/emscripten":`^1.39.10`,"@types/jasmine":`^5.1.13`,"@typescript-eslint/eslint-plugin":`^6.21.0`,"@typescript-eslint/parser":`^6.21.0`,esbuild:`^0.20.2`,eslint:`^8.57.0`,"eslint-plugin-jasmine":`^4.1.3`,"eslint-plugin-react":`^7.37.5`,"fast-glob":`^3.3.2`,jasmine:`^5.13.0`,"jasmine-core":`^5.1.2`,"jasmine-spec-reporter":`^7.0.0`,"js-sha256":`^0.11.1`,karma:`^6.4.2`,"karma-chrome-launcher":`^3.2.0`,"karma-coverage":`^2.2.1`,"karma-firefox-launcher":`^2.1.3`,"karma-jasmine":`^5.1.0`,"karma-jasmine-html-reporter":`^2.1.0`,"karma-sourcemap-loader":`^0.4.0`,"karma-spec-reporter":`^0.0.36`,"make-dir":`^4.0.0`,nyc:`^15.1.0`,prettier:`^3.2.5`,puppeteer:`^22.8.0`,rimraf:`^5.0.5`,s3rver:`^3.7.1`,typedoc:`^0.28.15`,typescript:`^5.3.3`,"wasm-feature-detect":`^1.6.1`,"web-worker":`^1.2.0`},scripts:{"build:debug":`node bundle.mjs debug && tsc --emitDeclarationOnly`,"build:release":`node bundle.mjs release && tsc --emitDeclarationOnly`,docs:`typedoc`,format:`prettier --write "**/*.+(js|ts)"`,report:`node ./coverage.mjs`,"test:node":`node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:debug":`node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:coverage":`nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:firefox":`karma start ./karma/tests-firefox.cjs`,"test:chrome":`karma start ./karma/tests-chrome.cjs`,"test:chrome:eh":`karma start ./karma/tests-chrome-eh.cjs`,"test:chrome:coverage":`karma start ./karma/tests-chrome-coverage.cjs`,"test:browser":`karma start ./karma/tests-all.cjs`,"test:browser:debug":`karma start ./karma/tests-debug.cjs`,test:`npm run test:chrome && npm run test:node`,"test:coverage":`npm run test:chrome:coverage && npm run test:node:coverage && npm run report`,lint:`eslint src test`},files:[`dist`,`!dist/tests-*`,`!dist/duckdb-browser-mvp.worker.js.map`,`!dist/types/test`],main:`dist/duckdb-browser.cjs`,module:`dist/duckdb-browser.mjs`,types:`dist/duckdb-browser.d.ts`,jsdelivr:`dist/duckdb-browser.cjs`,unpkg:`dist/duckdb-browser.mjs`,sideEffects:!1,browser:{fs:!1,path:!1,perf_hooks:!1,os:!1,worker_threads:!1},exports:{"./dist/duckdb-mvp.wasm":`./dist/duckdb-mvp.wasm`,"./dist/duckdb-eh.wasm":`./dist/duckdb-eh.wasm`,"./dist/duckdb-coi.wasm":`./dist/duckdb-coi.wasm`,"./dist/duckdb-browser":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser.cjs":`./dist/duckdb-browser.cjs`,"./dist/duckdb-browser.mjs":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser-coi.pthread.worker.js":`./dist/duckdb-browser-coi.pthread.worker.js`,"./dist/duckdb-browser-coi.worker.js":`./dist/duckdb-browser-coi.worker.js`,"./dist/duckdb-browser-eh.worker.js":`./dist/duckdb-browser-eh.worker.js`,"./dist/duckdb-browser-mvp.worker.js":`./dist/duckdb-browser-mvp.worker.js`,"./dist/duckdb-node":`./dist/duckdb-node.cjs`,"./dist/duckdb-node.cjs":`./dist/duckdb-node.cjs`,"./dist/duckdb-node-blocking":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-blocking.cjs":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-eh.worker.cjs":`./dist/duckdb-node-eh.worker.cjs`,"./dist/duckdb-node-mvp.worker.cjs":`./dist/duckdb-node-mvp.worker.cjs`,"./blocking":{node:{types:`./dist/duckdb-node-blocking.d.ts`,require:`./dist/duckdb-node-blocking.cjs`,import:`./dist/duckdb-node-blocking.cjs`},types:`./dist/duckdb-node-blocking.d.ts`,import:`./dist/duckdb-node-blocking.mjs`,require:`./dist/duckdb-node-blocking.cjs`},".":{browser:{types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`},node:{types:`./dist/duckdb-node.d.ts`,import:`./dist/duckdb-node.cjs`,require:`./dist/duckdb-node.cjs`},types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`}}};jL.name,jL.version;var ML=jL.version.split(`.`);ML[0],ML[1],ML[2],aL(oL());var NL=``+new URL(`assets/duckdb-browser-eh.worker--3HUwN9R.js`,import.meta.url).href,PL=``+new URL(`assets/duckdb-eh-D-nnNw7L.wasm.gz`,import.meta.url).href;async function FL(e){if(!e.endsWith(`.gz`))return e;let t=await fetch(e);if(!t.ok)throw Error(`DuckDB-WASM did not load (${t.status})`);let n=new Uint8Array(await t.arrayBuffer());return n[0]===31&&n[1]===139&&(n=new Uint8Array(await new Response(new Blob([n]).stream().pipeThrough(new DecompressionStream(`gzip`))).arrayBuffer())),URL.createObjectURL(new Blob([n],{type:`application/wasm`}))}var IL=null;function LL(){return IL||(IL=(async()=>{let e=e=>new URL(e,location.href).href,t=URL.createObjectURL(new Blob([`importScripts(${JSON.stringify(e(NL))});`],{type:`text/javascript`})),n=new Worker(t),r=new OL(new pL(lL.WARNING),n),i=await FL(e(PL));await r.instantiate(i,null),URL.revokeObjectURL(t),i.startsWith(`blob:`)&&URL.revokeObjectURL(i);let a=await r.connect();return await a.query(`SET checkpoint_threshold = '1TB'`),await a.query(`SET autoinstall_known_extensions = false`),await a.query(`SET autoload_known_extensions = false`),await a.close(),r})(),IL)}var RL=null;function zL(){return RL??=(async()=>{let e=await LL(),t=await e.connect();try{await t.query(`SET custom_extension_repository = '${new URL(`/duckdb-ext`,location.href).href}'`),await t.query(`LOAD parquet`)}finally{await t.close()}return e})().catch(e=>{throw RL=null,e}),RL}function BL(e){return`"`+e.replace(/"/g,`""`)+`"`}function VL(e){if(!(e.x1>e.x0))throw Error(`buildDecimationSql: x1 must be greater than x0`);if(e.maxPoints<1)throw Error(`buildDecimationSql: maxPoints must be >= 1`);if(!e.table||!e.xcol||!e.ycol)throw Error(`buildDecimationSql: table, xcol and ycol are required`);let t=(e.x1-e.x0)/e.maxPoints,n=BL(e.xcol),r=BL(e.ycol);return{sql:`SELECT least(floor((${n} - ?) / ?), ? - 1) AS b, min(${r}) AS lo, max(${r}) AS hi, arg_min(${r}, ${n}) AS first, arg_max(${r}, ${n}) AS last FROM ${BL(e.table)} WHERE ${n} BETWEEN ? AND ? GROUP BY 1 ORDER BY 1`,params:[e.x0,t,e.maxPoints,e.x0,e.x1]}}function HL(e){if(!(e.x1>e.x0))throw Error(`buildMultiDecimationSql: x1 must be greater than x0`);if(e.maxPoints<1)throw Error(`buildMultiDecimationSql: maxPoints must be >= 1`);if(!e.table||!e.xcol||e.ycols.length===0)throw Error(`buildMultiDecimationSql: table, xcol and at least one ycol are required`);let t=(e.x1-e.x0)/e.maxPoints,n=BL(e.xcol),r=BL(e.table);return{sql:`SELECT least(floor((${n} - ?) / ?), ? - 1) AS b, ${e.ycols.map((e,t)=>`min(${BL(e)}) AS y${t}lo, max(${BL(e)}) AS y${t}hi`).join(`, `)} FROM ${r} WHERE ${n} BETWEEN ? AND ? GROUP BY 1 ORDER BY 1`,params:[e.x0,t,e.maxPoints,e.x0,e.x1]}}var UL=`__kym_bin`;function WL(e){if(!(e.binWidth>0))throw Error(`buildPyramidBuildL0Sql: binWidth must be > 0`);if(e.ycols.length===0)throw Error(`buildPyramidBuildL0Sql: at least one ycol is required`);let t=BL(e.xcol),n=BL(e.srcTable);return`CREATE OR REPLACE TABLE ${BL(e.dstTable)} AS SELECT ${`CAST(floor((${t} - ${qL(e.x0base)}) / ${qL(e.binWidth)}) AS BIGINT)`} AS ${UL}, ${e.ycols.map(e=>`min(${BL(e)}) AS ${BL(e+`__lo`)}, max(${BL(e)}) AS ${BL(e+`__hi`)}`).join(`, `)} FROM ${n} WHERE ${t} IS NOT NULL GROUP BY 1`}function GL(e){let t=BL(e.srcTable);return`CREATE OR REPLACE TABLE ${BL(e.dstTable)} AS SELECT CAST(floor(${UL} / 2.0) AS BIGINT) AS ${UL}, ${e.ycols.map(e=>`min(${BL(e+`__lo`)}) AS ${BL(e+`__lo`)}, max(${BL(e+`__hi`)}) AS ${BL(e+`__hi`)}`).join(`, `)} FROM ${t} GROUP BY 1`}function KL(e){if(!(e.x1>e.x0))throw Error(`buildPyramidQuerySql: x1 must be greater than x0`);if(e.maxPoints<1)throw Error(`buildPyramidQuerySql: maxPoints must be >= 1`);if(e.ycols.length===0)throw Error(`buildPyramidQuerySql: at least one ycol is required`);let t=(e.x1-e.x0)/e.maxPoints,n=e.binWidth/t,r=(e.x0base-e.x0)/t+.5*n,i=Math.max(0,Math.floor((e.x0-e.x0base)/e.binWidth)),a=Math.floor((e.x1-e.x0base)/e.binWidth),o=BL(e.levelTable);return{sql:`SELECT least(greatest(CAST(floor(? + ${UL} * ?) AS BIGINT), 0), ?) AS b, ${e.ycols.map((e,t)=>`min(${BL(e+`__lo`)}) AS y${t}lo, max(${BL(e+`__hi`)}) AS y${t}hi`).join(`, `)} FROM ${o} WHERE ${UL} BETWEEN ? AND ? GROUP BY 1 ORDER BY 1`,params:[r,n,e.maxPoints-1,i,a]}}function qL(e){if(!Number.isFinite(e))throw Error(`num: value must be finite`);return Number.isInteger(e)?String(e):e.toExponential(17)}function JL(e){let t=BL(e.table);return e.range?{sql:`SELECT count(*) AS n FROM ${t} WHERE ${BL(e.range.xcol)} BETWEEN ? AND ?`,params:[e.range.x0,e.range.x1]}:{sql:`SELECT count(*) AS n FROM ${t}`,params:[]}}function YL(e){if(!Number.isInteger(e.stride)||e.stride<1)throw Error(`buildSampleRowsSql: stride must be a positive integer`);let t=BL(e.table),n=e.range?` WHERE ${BL(e.range.xcol)} BETWEEN ? AND ?`:``,r=e.range?[e.range.x0,e.range.x1]:[];return e.stride===1?{sql:`SELECT * FROM ${t}${n}`,params:r}:{sql:`SELECT * EXCLUDE(__kym_rn) FROM (SELECT *, row_number() OVER () - 1 AS __kym_rn FROM ${t}${n}) WHERE __kym_rn % ${e.stride} = 0`,params:r}}function XL(e){return`'`+e.replace(/'/g,`''`)+`'`}function ZL(e){let t=e.columnNames.map(XL).join(`, `),n=e.delim===` `?`'\\t'`:XL(e.delim),r=e.decimalComma?`decimal_separator=',', `:``;return`SELECT * FROM read_csv(${XL(e.handle)}, header=false, skip=${e.dataStartRow}, delim=${n}, `+r+`names=[${t}], auto_type_candidates=['DOUBLE', 'VARCHAR'])`}function QL(e,t,n){let r=e.length,i={x:new Float64Array(r),min:new Float64Array(r),max:new Float64Array(r),first:new Float64Array(r),last:new Float64Array(r)};for(let a=0;a<r;a++){let r=e[a],o=Number(r.b);i.x[a]=t+(o+.5)*n,i.min[a]=Number(r.lo),i.max[a]=Number(r.hi),i.first[a]=Number(r.first),i.last[a]=Number(r.last)}return i}var $L=class{#e;#t=new Map;constructor(e){this.#e=Math.max(1,e)}get(e){let t=this.#t.get(e);return t!==void 0&&(this.#t.delete(e),this.#t.set(e,t)),t}set(e,t){if(this.#t.has(e)&&this.#t.delete(e),this.#t.set(e,t),this.#t.size>this.#e){let e=this.#t.keys().next().value;this.#t.delete(e)}}get size(){return this.#t.size}},eR=0,tR=()=>`t_${++eR}`,nR=5e4,rR=65536,iR=512,aR=2;function oR(e){return e<1?1:2**Math.floor(Math.log2(e))}var sR=class e{#e;#t;#n;#r;#i=new $L(96);#a=new Map;#o=new Map;#s=[];#c=0;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n,this.#r=new Set(t.map(e=>e.name))}static async open(t,n){let r=await LL(),i=await r.connect(),a=await t.slice(0,256*1024).text(),o=ze(a),s=y(a),c=H(o,s.headerRow),l=s.unitsRow===null?``:o[s.unitsRow]??``,u=x(o[s.headerRow]??``),d=m(o.slice(s.dataStartRow,s.dataStartRow+10),u);n?.({phase:`reading`,message:`Reading file…`});let f=new Uint8Array(await t.arrayBuffer());await r.dropFile(`input.csv`).catch(()=>{}),await r.registerFileBuffer(`input.csv`,f),n?.({phase:`parsing`,message:`Parsing CSV…`});let p=tR(),h=ZL({handle:`input.csv`,columnNames:c,delim:u,dataStartRow:s.dataStartRow,decimalComma:d});await i.query(`CREATE OR REPLACE TABLE ${BL(p)} AS ${h}`),await r.dropFile(`input.csv`).catch(()=>{});let g=l?l.split(u).map(e=>e.trim()):[],_=new Map;c.forEach((e,t)=>_.set(e,g[t]??``));let v=await e.attach(i,p,_);return n?.({phase:`done`,message:`Ready.`}),v}static async attach(t,n,r){return new e(t,(await t.query(`DESCRIBE ${BL(n)}`)).toArray().map(e=>{let t=String(e.column_type??``),n=/INT|DECIMAL|DOUBLE|FLOAT|REAL|HUGEINT|BIGINT/i.test(t),i=String(e.column_name);return{name:i,type:n?`number`:`string`,unit:r.get(i)??``}}),n)}async getSchema(){return this.#t}async getSeries(e){if(!Number.isFinite(e.viewport.x0)||!Number.isFinite(e.viewport.x1)||e.viewport.x1<=e.viewport.x0){let e=new Float64Array;return{x:e,min:e,max:e,first:e,last:e}}let t=(e.viewport.x1-e.viewport.x0)/e.maxPoints,{sql:n,params:r}=VL({table:this.#n,xcol:e.viewport.xKey,ycol:e.column,x0:e.viewport.x0,x1:e.viewport.x1,maxPoints:e.maxPoints}),i=await this.#e.prepare(n);try{return QL((await i.query(...r)).toArray(),e.viewport.x0,t)}finally{await i.close()}}async getSeriesMulti(e,t,n){let r=(t.x1-t.x0)/n,i=this.#r.has(t.xKey)?e.filter(e=>this.#r.has(e)):[];if(i.length===0||!Number.isFinite(t.x0)||!Number.isFinite(t.x1)||t.x1<=t.x0)return{x0:t.x0,bucket:r,rows:[],columns:i};let a=`${t.xKey}|${i.join(`,`)}|${t.x0}|${t.x1}|${n}`,o=this.#i.get(a);if(o)return o;let s=this.#o.get(t.xKey);s===void 0&&this.#l(t.xKey);let{sql:c,params:l}=this.#u(s??null,i,t,n)??HL({table:this.#n,xcol:t.xKey,ycols:i,x0:t.x0,x1:t.x1,maxPoints:n}),u=await this.#e.prepare(c);try{let e=(await u.query(...l)).toArray(),n={x0:t.x0,bucket:r,rows:e,columns:i};return this.#i.set(a,n),n}finally{await u.close()}}#l(e){let t=this.#a.get(e);if(t)return t;let n=this.#d(e).then(t=>(this.#o.set(e,t),t)).catch(()=>(this.#o.set(e,null),null));return this.#a.set(e,n),n}#u(e,t,n,r){if(!e)return null;for(let n of t)if(!e.cols.has(n))return null;let i=(n.x1-n.x0)/r/aR,a=null;for(let t of e.levels)t.binWidth<=i&&(a=t);return a?KL({levelTable:a.table,ycols:t,x0base:e.x0base,binWidth:a.binWidth,x0:n.x0,x1:n.x1,maxPoints:r}):null}async#d(e){if(!this.#r.has(e))return null;let t=await(await LL()).connect();try{let n=JL({table:this.#n}),r=await t.query(n.sql),i=Number(r.getChild(`n`)?.get(0)??0);if(i<nR)return null;let a=await t.query(`SELECT min(${BL(e)}) AS lo, max(${BL(e)}) AS hi FROM ${BL(this.#n)}`),o=Number(a.getChild(`lo`)?.get(0)),s=Number(a.getChild(`hi`)?.get(0));if(!Number.isFinite(o)||!Number.isFinite(s)||!(s>o))return null;let c=this.#t.filter(t=>t.type===`number`&&t.name!==e).map(e=>e.name);if(c.length===0)return null;let l=s-o,u=Math.min(rR,oR(i));if(u<iR*2)return null;let d=++this.#c,f=[],p=u,m=0,h=`${this.#n}_p${d}_0`;await t.query(WL({srcTable:this.#n,dstTable:h,xcol:e,ycols:c,x0base:o,binWidth:l/u})),this.#s.push(h),f.push({table:h,binWidth:l/u,nbins:p});let g=h;for(;p/2>=iR;){p/=2,m+=1;let e=`${this.#n}_p${d}_${m}`;await t.query(GL({srcTable:g,dstTable:e,ycols:c})),this.#s.push(e),f.push({table:e,binWidth:l/p,nbins:p}),g=e}return{x0base:o,cols:new Set(c),levels:f}}finally{await t.close()}}async sampleRows(e,t){let n=t&&this.#r.has(t.xcol)?t:void 0,r=JL({table:this.#n,range:n}),i=await this.#e.prepare(r.sql),a;try{let e=await i.query(...r.params);a=Number(e.getChild(`n`)?.get(0)??0)}finally{await i.close()}if(a===0)return[];let o=Math.max(1,Math.ceil(a/e)),{sql:s,params:c}=YL({table:this.#n,stride:o,range:n}),l=await this.#e.prepare(s),u=this.#t.map(e=>e.name),d=[];try{let e=await l.query(...c);for(let t=0;t<e.numRows;t++)d.push({});for(let t of u){let n=e.getChild(t);if(!n){for(let e of d)e[t]=null;continue}let r=n.toArray(),i=ArrayBuffer.isView(r),a=n.nullCount>0;for(let e=0;e<d.length;e++){let o=a&&!n.isValid(e)?null:i?r[e]:n.get(e);d[e][t]=typeof o==`bigint`?Number(o):o}}}finally{await l.close()}return d}async readColumns(e,t,n){let r=[...new Set(e)].filter(e=>this.#r.has(e));if(!r.length)return{};let i=r.map((e,t)=>`coalesce(TRY_CAST(${BL(e)} AS DOUBLE), 'NaN'::DOUBLE) AS "c${t}"`).join(`, `),a=await this.#e.prepare(`SELECT ${i} FROM ${BL(this.#n)} ORDER BY rowid LIMIT ? OFFSET ?`);try{let e=await a.query(n,t),i={};return r.forEach((t,n)=>{let r=e.getChild(`c${n}`)?.toArray();i[t]=r instanceof Float64Array?r:Float64Array.from(r??[],Number)}),i}finally{await a.close()}}async xBounds(e){if(!this.#r.has(e))return{x0:0,x1:0};let t=await this.#e.query(`SELECT min(${BL(e)}) AS lo, max(${BL(e)}) AS hi FROM ${BL(this.#n)}`);return{x0:Number(t.getChild(`lo`)?.get(0)),x1:Number(t.getChild(`hi`)?.get(0))}}async dispose(){for(let e of this.#s)try{await this.#e.query(`DROP TABLE IF EXISTS ${BL(e)}`)}catch{}try{await this.#e.query(`DROP TABLE IF EXISTS ${BL(this.#n)}`)}catch{}await this.#e.close()}},cR=1e8,lR=256*1024;function uR(e,t,n=0,r=cR){return e>314572800||n+t>r?`duckdb`:`memory`}function dR(e,t){let n=ze(t);t.length<e&&n.length>1&&(n=n.slice(0,-1));try{let t=y(n.join(`
|
|
70
|
-
`)),r=H(n,t.headerRow).length,i=n.slice(t.dataStartRow);if(i.length===0)return Math.ceil(e/8);let a=n.slice(0,t.dataStartRow).reduce((e,t)=>e+t.length+1,0),o=i.reduce((e,t)=>e+t.length+1,0)/i.length;return Math.ceil(Math.max(0,e-a)/o)*r}catch{return Math.ceil(e/8)}}var fR=12e3;async function pR(e,t,n){let r=y(n),i=typeof Worker>`u`?k(n,r):await NE({rawText:n,config:r}),a=new LE(i);return{id:e,name:t,kind:`memory`,source:a,schema:await a.getSchema(),data:i,rawText:n,parseConfig:r}}async function mR(e,t,n,r,i=e=>e.text(),a){let o=y(r),s=typeof Worker>`u`?await PE({rawText:await i(n),config:o},a):await PE({file:n,config:o},a),c=new LE(s);return{id:e,name:t,kind:`memory`,source:c,schema:await c.getSchema(),data:s,rawText:r,file:n,parseConfig:o}}async function hR(e,t,n){let r=await sR.open(t,n),i=await r.getSchema(),a=await r.sampleRows(fR),o={meta:``,columnNames:i.map(e=>e.name),units:i.map(e=>e.unit),rows:a},s=await t.slice(0,lR).text();return{id:e,name:t.name,kind:`duckdb`,source:r,schema:i,data:o,rawText:s,parseConfig:y(s)}}async function gR(e,t,n,r,i=0,a){let o=await t.slice(0,lR).text();return uR(t.size,dR(t.size,o),i)===`memory`?mR(e,t.name,t,o,e=>n(e),a):hR(e,t,r)}function _R(e,t){return e instanceof File&&e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}async function vR(e,t,n){let r=n.find(e=>e.kind===`memory`&&e.parseConfig&&_R(e.file,t)&&Ue(e.data.rows));if(!r)return null;let i=await t.slice(0,lR).text();if(!ee(r.parseConfig,y(i)))return null;let a={...r.data,rows:Me(Ue(r.data.rows))};return{id:e,name:t.name,kind:`memory`,source:new LE(a),schema:r.schema,data:a,rawText:r.rawText,file:t,parseConfig:r.parseConfig}}function yR(e){let t=new Set,n=0;for(let r of e){if(r.kind!==`memory`)continue;let e=Ue(r.data.rows)??r.data.rows;t.has(e)||(t.add(e),n+=r.data.rows.length*r.data.columnNames.length)}return n}var bR=4096,xR=[`.dat`,`.txt`,`.csv`,`.tsv`],SR=[we,r,Ee,E,l,d,P],CR=e=>{let t=e.lastIndexOf(`.`);return t<=0?``:e.slice(t).toLowerCase()},wR=e=>{let t=e.lastIndexOf(`.`);return(t<=0?e:e.slice(0,t)).toLowerCase()};async function TR(e){let t=new Uint8Array(await e.slice(0,bR).arrayBuffer()),n=CR(e.name),r=SR.filter(e=>e.extensions.includes(n));for(let n of[...r,...SR.filter(e=>!r.includes(e))])if(n.sniff(t,e.name))return n;return null}async function ER(e){return new Uint8Array(await e.slice(0,bR).arrayBuffer()).includes(0)}async function DR(e){let t=await Promise.all(e.map(TR)),n=[],r=new Set;e.forEach((e,i)=>{let a=t[i];a&&(n.push({main:e,companions:[],format:a}),r.add(e))});for(let i of[...n])for(let n of i.format.companions??[]){let a=e.filter((e,r)=>!t[r]&&CR(e.name)===n.ext),o=a.find(e=>wR(e.name)===wR(i.main.name))??(n.anyName&&a.length===1?a[0]:void 0);o&&(i.companions.push(o),r.add(o))}let i=new Set(SR.flatMap(e=>(e.companions??[]).map(e=>e.ext))),a=[];for(let t of e){if(r.has(t))continue;let e=CR(t.name);e===`.dat`&&await ER(t)?a.push({file:t.name,error:Error(`This COMTRADE .dat needs its .cfg file — drop both together.`)}):xR.includes(e)?n.push({main:t,companions:[],format:null}):i.has(e)?a.push({file:t.name,error:Error(`${t.name} is read together with its main file (same name). Drop both files together.`)}):a.push({file:t.name,error:Error(`${t.name}: Kymoscope cannot read this file type.`)})}return n.sort((t,n)=>e.indexOf(t.main)-e.indexOf(n.main)),{items:n,errors:a}}var OR=[...new Set([...xR,...SR.flatMap(e=>[...e.extensions,...(e.companions??[]).map(e=>e.ext)])])];function kR(e){let t=0;for(let n=0;n<e.length;n++)e[n]!==e[n]&&t++;if(t===0)return qM(e);let n=new Uint8Array(e.length+7>>3);for(let t=0;t<e.length;t++)e[t]===e[t]&&(n[t>>3]|=1<<(t&7));return qM(xM({type:new Ek,data:e,nullBitmap:n,length:e.length,nullCount:t}))}var AR=122880,jR=class{#e;#t;#n;#r=!1;#i=[];#a=0;#o;rows=0;constructor(e,t,n,r=AR){this.#e=e,this.#t=t,this.#n=new cN(n.map(e=>new lN(e.name,e.text?new kk:new Ek,!0))),this.#o=r}async append(e){let t=e.length;if(t===0)return;let n=this.#n.fields.map((n,r)=>{let i=e.columns[r];return(i instanceof Float64Array?kR(i.subarray(0,t)):rF(i.slice(0,t),new kk)).data[0]});this.#i.push(new pF(this.#n,xM({type:new Bk(this.#n.fields),length:t,nullCount:0,children:n}))),this.#a+=t,this.rows+=t,this.#a>=this.#o&&await this.flush()}async flush(){if(this.#a===0)return;let e=new uF(this.#n,this.#i);this.#i=[],this.#a=0,await this.#e.insertArrowTable(e,{name:this.#t,create:!this.#r}),this.#r=!0}},MR=`This file's groups do not interleave in time: reading them together would hold too much in memory. Choose fewer groups, or split them.`,NR=e=>e.length*(1+e.columns.length);function PR(e){let t=e[Symbol.asyncIterator]();return{pull:async()=>{let e=await t.next();return e.done?null:e.value}}}function FR(e,t){let n=Array.from({length:t.size},()=>[]),r=!1,i=0,a=async a=>{for(;;){if(n[a].length){let e=n[a].shift();return i-=NR(e),e}if(r)return null;let o=await e.next();if(o.done){r=!0;continue}let s=t.get(o.value.group);if(s!==void 0&&(n[s].push(o.value),(i+=NR(o.value))>128e6))throw Error(MR)}};return n.map((e,t)=>({pull:()=>a(t)}))}function IR(e,t){if(e.time)return e.time;let n=new Float64Array(e.length);if(t.time.kind===`rate`){let{rate:r,start:i}=t.time;for(let t=0;t<e.length;t++)n[t]=i+(e.start+t)/r}else for(let t=0;t<e.length;t++)n[t]=e.start+t;return n}var LR=new Int32Array,RR={t:new Float64Array,cols:[],from:0};function zR(e,t,n,r){let i=n,a=r;for(;i<a;){let n=i+a>>>1;e[n]<=t?i=n+1:a=n}return i}var BR=class{group;channels;feed;pending=[];done=!1;last;scratch=[];#e=-1/0;constructor(e,t,n){this.group=e,this.channels=t,this.feed=n,this.last=t.map(e=>e.text?null:NaN)}rows(){let e=0;for(let t of this.pending)e+=t.t.length-t.from;return e}lastTime(){let e=this.pending[this.pending.length-1];return e&&e.t.length>e.from?e.t[e.t.length-1]:-1/0}async fill(){let e=await this.feed.pull();if(!e){this.done=!0;return}if(e.length===0)return;let t=VR(IR(e,this.group),this.#e);if(t.length&&(this.#e=t[t.length-1]),this.pending.push({t,cols:e.columns,from:0}),this.rows()*(1+this.channels.length)>128e6)throw Error(MR)}};function VR(e,t){let n=t,r=0;for(;r<e.length;r++){let t=e[r];if(!(t>=n&&t>-1/0&&t<1/0))break;n=t}if(r===e.length)return e;for(n===-1/0&&(n=0);r<e.length;r++){let t=e[r];t>=n&&t<1/0?n=t:e[r]=n}return e}function HR(e,t){let n=e.length,r=e.map(e=>e.t),i=Int32Array.from(e,e=>e.from),a=Int32Array.from(e,e=>zR(e.t,t,e.from,e.t.length));if(n===1)return r[0].subarray(i[0],a[0]);let o=0;for(let e=0;e<n;e++)o+=a[e]-i[e];let s=new Float64Array(o),c=0;for(;;){let e=1/0;for(let t=0;t<n;t++)i[t]<a[t]&&r[t][i[t]]<e&&(e=r[t][i[t]]);if(e===1/0)break;s[c++]=e;for(let t=0;t<n;t++){let n=r[t],o=a[t],s=i[t];for(;s<o&&n[s]===e;)s++;i[t]=s}}return s.subarray(0,c)}function UR(e,t,n,r,i,a){if(i-r>8)e.set(t.subarray(n+r,n+i),a);else for(let o=r;o<i;o++)e[a+o-r]=t[n+o]}function WR(e,t,n,r,i,a){let o=0;for(let s=0;s<n.length;s++){let c=n[s],l=c.length;if(l===0)continue;let u=i[s].from,d=i[s].cols[a];e.fill(t,o,c[0]);let f=r[s],p=0;for(let t=0;t<f.length;t++){let n=f[t];UR(e,d,u,p,n,c[p]);let r=c[n],i=c[n+1],a=d[u+n];if(i-r>16)e.fill(a,r,i);else for(let t=r;t<i;t++)e[t]=a;p=n+1}UR(e,d,u,p,l-1,c[p]),o=c[l-1],t=d[u+l-1]}e.fill(t,o,e.length)}function GR(e,t,n,r,i){let a=0;for(let o=0;o<n.length;o++){let s=n[o],c=s.length;if(c===0)continue;let l=r[o].from,u=r[o].cols[i];e.fill(t,a,s[0]);for(let t=0;t<c-1;t++)e.fill(u[l+t],s[t],s[t+1]);a=s[c-1],t=u[l+c-1]}e.fill(t,a,e.length)}function KR(e,t,n,r,i){let a=n.length,o=null,s=0;for(let c=0;c<i.length;c++){let l=e[t+c],u=r;if(n[r]<l){let e=r,t=1;for(;e+t<a&&n[e+t]<l;)e+=t,t*=2;let i=Math.min(e+t,a-1);for(;i-e>1;){let t=e+i>>>1;n[t]<l?e=t:i=t}r=i}i[c]=r,c>0&&r!==u+1&&((o??=new Int32Array(i.length-1))[s++]=c-1)}return o?o.subarray(0,s):LR}function qR(e,t,n,r,i){let a=t.length;if(r){let t=e.pending[0],n=t.from+a,r=t.cols.map(e=>e instanceof Float64Array?e.subarray(t.from,n):e.slice(t.from,n));if(a>0)for(let i=0;i<r.length;i++)e.last[i]=t.cols[i][n-1];return e.pending=n<t.t.length?[{...t,from:n}]:[],r}let o=e.pending,s=[],c=[];if(a>0){let e=t[a-1],n=0;for(let r of o){let i=r.t,a=zR(i,e,r.from,i.length),o=new Int32Array(a-r.from);if(c.push(KR(i,r.from,t,n,o)),o.length&&(n=o[o.length-1]),s.push(o),a<i.length)break}}let l=e.channels.map((r,l)=>{if(r.sparse&&n){let e=r.text?Array(a).fill(null):new Float64Array(a).fill(NaN);for(let n=0;n<s.length;n++){let r=s[n],{t:i,from:c}=o[n],u=o[n].cols[l];for(let n=0;n<r.length;n++){let o=r[n];o<a&&t[o]===i[c+n]&&(e[o]=u[c+n])}}return e}if(r.text){let t=Array(a);return GR(t,e.last[l],s,o,l),t}let u;return i?(e.scratch[l]?.length>=a||(e.scratch[l]=new Float64Array(a)),u=e.scratch[l].subarray(0,a)):u=new Float64Array(a),WR(u,e.last[l],s,c,o,l),u}),u=[];for(let t=0;t<o.length;t++){let n=o[t],r=t<s.length?s[t].length:0;if(r>0)for(let t=0;t<e.channels.length;t++)e.last[t]=n.cols[t][n.from+r-1];n.from+r<n.t.length&&u.push(r?{...n,from:n.from+r}:n)}return e.pending=u,l}async function JR(e,t,n,r,i,a=!1){let o=e.map((e,r)=>new BR(e,t[r],n[r])),s=-1;e.forEach((t,n)=>{!t.irregular&&(s<0||t.samples>e[s].samples)&&(s=n)});let c=e.map((e,t)=>t===s||!!e.irregular),l=o.filter((e,t)=>c[t]),u=l.length===1,d=0;for(;;){i?.throwIfAborted();for(let e of l)for(;!e.done&&e.rows()===0;)await e.fill();if(l.every(e=>e.rows()===0))break;let e=1/0;for(let t of l)t.done||(e=Math.min(e,t.lastTime()));for(let t=0;t<o.length;t++)if(!c[t])for(;!o[t].done&&o[t].lastTime()<=e;)await o[t].fill();let t=HR(l.map(e=>e.pending[0]??RR),e),n=[t];for(let e=0;e<o.length;e++)n.push(...qR(o[e],t,c[e],u&&c[e],a));d+=t.length,t.length&&await r({length:t.length,columns:n})}return d}var YR=class{#e;#t;#n;#r=0;constructor(e,t){let n=Math.max(1024,t);this.#e=e.map(e=>e.name),this.#t=e.map(()=>new Float64Array(n)),this.#n=e.map(()=>null)}append(e){let t=this.#r,n=t+e.length;if(n>this.#t[0].length){let e=Math.max(n,Math.ceil(this.#t[0].length*1.5));this.#t=this.#t.map(n=>{let r=new Float64Array(e);return r.set(n.subarray(0,t)),r})}e.columns.forEach((n,r)=>{let i=this.#t[r];if(n instanceof Float64Array){i.set(n.subarray(0,e.length),t);return}let a=this.#n[r];for(let o=0;o<e.length;o++){i[t+o]=NaN;let e=n[o];e!=null&&((a??=this.#n[r]=[])[t+o]=e)}}),this.#r=n}table(){let e=this.#r,t=this.#t.map(t=>t.length-e>t.length/100?t.slice(0,e):t.subarray(0,e));return{keys:this.#e,length:e,values:t,text:this.#n}}};async function XR(e,t,n){return M(await e.plan(t,n))}var ZR=(e,t,n)=>Math.max(0,Math.min(e,Math.max(1<<20,n),Math.floor(1e8/t)));function QR(e,t){let n=t.flatMap(t=>t.channels.map(n=>({ch:e.groups[t.group].channels[n],group:e.groups[t.group].name}))),r=new Map;for(let{ch:e}of n)r.set(e.name.toLowerCase(),(r.get(e.name.toLowerCase())??0)+1);let i=Ze(n.map(({ch:e,group:n})=>t.length>1&&r.get(e.name.toLowerCase())>1?`${e.name} [${n}]`:e.name));return[{name:`Time`,unit:t.every(t=>e.groups[t.group].time.kind===`index`)?``:`s`,text:!1},...n.map(({ch:e},t)=>({name:i[t],unit:e.unit,text:!!e.text}))]}function $R(e,t){let n=t.map(t=>e.groups[t.group]);if(n.some(e=>e.samples<0))return-1;let r=0,i=0;for(let e of n)e.irregular?i+=e.samples:r=Math.max(r,e.samples);return r+i}function ez(e,t,n){let r=$R(e,t);return r<0?Math.ceil(n/4):r*(1+t.reduce((e,t)=>e+t.channels.length,0))}async function tz(e,t,n,r,i,a,o={}){let s=QR(n,i),c=i.map(e=>n.groups[e.group]),l=i.map(e=>e.channels.map(t=>n.groups[e.group].channels[t])),u=[...n.events];async function*d(e){for await(let t of e)t.events&&u.push(...t.events),yield t}let f={files:t,plan:n,io:r,selection:i,signal:o.signal},p=e.streamGroup&&i.length>1&&!n.interleaved?i.map(t=>PR(d(e.streamGroup({...f,selection:[t]},t.group)))):FR(d(e.stream(f)),new Map(i.map((e,t)=>[e.group,t]))),m=$R(n,i),h=a===`memory`?new YR(s,ZR(m,s.length,r.size)):null,g=0,_=await JR(c,l,p,async e=>{h?h.append(e):await o.chunk(e);let t=Date.now();o.progress&&t-g>100&&(g=t,o.progress(Math.min(.99,r.bytesRead/Math.max(1,r.size))))},o.signal,!!h);return o.progress?.(1),u.sort((e,t)=>e.time-t.time),{columns:s,rows:_,table:h?.table(),events:u}}var nz=``+new URL(`assets/importer.worker-CLBGjz4d.js`,import.meta.url).href,rz=``+new URL(`assets/h5wasmModule-BCQWU2Gw.js`,import.meta.url).href,iz=()=>new kE(`cancelled`);function az(){let e=AE(nz);return e.postMessage({type:`init`,h5Url:new URL(rz,location.href).href}),e}var oz=null,sz=e=>{typeof requestIdleCallback==`function`?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,1e3)};function cz(e,t=az){t===az&&typeof Worker>`u`||(oz&&oz.make!==t&&(oz.w.terminate(),oz=null),oz??={w:t(),h5:!1,make:t},e&&!oz.h5&&(oz.h5=!0,oz.w.postMessage({type:`warm`})))}function lz(e){if(oz?.make!==e)return{w:e(),rewarm:null};let{w:t,h5:n}=oz;return oz=null,{w:t,rewarm:n}}function uz(e,t,n,r,i){return!r&&typeof Worker>`u`?dz(e,t,n,i):pz(e,t,n,r??az)}function dz(e,t,n,r=async e=>(await import(`./importers-rg_Kg8Bl.js`)).importerFor(e)){let i=new U(t.main),a=null,o=null,c=e=>e.catch(e=>{throw n?.aborted?iz():s(e)});return{plan:()=>c((async()=>(a=await r(e),o=await XR(a,t,i)))()),read:(e,r,s={})=>(i.bytesRead=0,c(tz(a,t,o,i,e,r,{...s,signal:n}))),close(){}}}var fz=3e4;function pz(e,t,n,r){let{w:i,rewarm:a}=lz(r),o=null,s=Promise.resolve(),c=Date.now(),l=-1,u=0,d=!1,f=e=>{let t=o;o=null,t?.reject(e)},p=e=>{d=!0,i.terminate(),f(e)},m=setInterval(()=>{o&&u===0&&Date.now()-c>fz&&p(Error(ce))},1e3),h=()=>p(iz());n?.addEventListener(`abort`,h,{once:!0}),i.onmessage=e=>{let t=e.data,n=o;n&&((t.type!==`alive`||t.work!==l)&&(c=Date.now()),t.type===`alive`?l=t.work:t.type===`plan`?(o=null,n.resolve(t.plan)):t.type===`progress`?n.on.progress?.(t.fraction):t.type===`chunk`?(u++,s=s.then(()=>n.on.chunk(t.chunk)).then(()=>{u--,c=Date.now(),i.postMessage({type:`ack`})},e=>{u--,p(e instanceof Error?e:Error(String(e)))})):t.type===`done`?s.then(()=>{o===n&&(o=null,n.resolve(t.result))}):f(Error(t.message)))},i.onerror=e=>f(e instanceof Error?e:Error(`The import worker failed.`));let g=(e,t={})=>new Promise((r,a)=>{if(n?.aborted){a(iz());return}if(d){a(Error(ce));return}o={resolve:r,reject:a,on:t},c=Date.now(),i.postMessage(e)});return{plan:()=>g({type:`plan`,importer:e,files:t}),read:(e,t,n)=>g({type:`read`,selection:e,mode:t},n),close:()=>{clearInterval(m),n?.removeEventListener(`abort`,h),i.terminate(),a!==null&&sz(()=>cz(a,r))}}}var mz=12e3,hz=(e,t)=>t.map(t=>({group:t,channels:e.groups[t].channels.map((e,t)=>t)}));function gz(e,t){let n=null;for(let r of t){let t=e.groups[r.group];!t.irregular&&(!n||t.samples>n.samples)&&(n={samples:t.samples,rate:t.rateHz})}return n?.rate??null}function _z(e,t,n,r){return{format:e.format,importer:t,startTime:e.startTime,groups:e.groups.map(e=>({name:e.name,channels:e.channels.length,samples:e.samples,rateHz:e.rateHz})),selection:n,combined:n.length>1?{groups:n.length,rateHz:gz(e,n)}:null,splitKey:r,channels:n.reduce((e,t)=>e+t.channels.length,0),notes:e.notes,meta:e.meta,events:[]}}async function vz(e,t,n,r,i,a){let o={meta:``,columnNames:n.columns.map(e=>e.name),units:n.columns.map(e=>e.unit),rows:Me(n.table)},s=new LE(o);return{id:e,name:t,kind:`memory`,source:s,schema:await s.getSchema(),data:o,file:r,companions:i,info:{...a,events:n.events}}}async function yz(e,t,n,r,i,a,o,s,c){let l=LL().then(e=>e.connect());l.catch(()=>void 0);let u=tR(),d=QR(r,i),f=new jR({insertArrowTable:async(e,t)=>(await l).insertArrowTable(e,t)},u,d);try{let r=await n.read(i,`stream`,{progress:c,chunk:e=>f.append(e)});if(await f.flush(),f.rows===0)throw Error(`${t}: the file has no samples.`);let p=await l,m=await sR.attach(p,u,new Map(d.map(e=>[e.name,e.unit]))),h=await m.getSchema(),g=await m.sampleRows(mz);return{id:e,name:t,kind:`duckdb`,source:m,schema:h,data:{meta:``,columnNames:h.map(e=>e.name),units:h.map(e=>e.unit),rows:g},file:a,companions:o,info:{...s,events:r.events}}}catch(e){let t=await l.catch(()=>null);throw await t?.query(`DROP TABLE IF EXISTS ${BL(u)}`).catch(()=>void 0),await t?.close().catch(()=>void 0),e}}async function bz(e,t){let{main:n,companions:r}=e,i=uz(e.format,{main:n,companions:r,keys:e.keys},t.signal,t.createWorker,t.find),a=[];try{t.priorInMemoryValues+n.size/8>1e8&&LL().catch(()=>void 0);let o=await i.plan(),s=t.selection??t.initial??hz(o,o.defaultGroups??o.groups.map((e,t)=>t)),c=s.reduce((e,t)=>e+t.channels.length,0);if(!t.selection&&t.chooseChannels&&(t.pickChannels||o.pick||c>2e3)){let e=await t.chooseChannels({file:n.name,format:o.format,groups:o.groups.map(e=>({name:e.name,rateHz:e.rateHz,samples:e.samples,channels:e.channels.map(e=>({name:e.name,unit:e.unit}))})),selection:s,estimate:e=>ez(o,e,n.size),budget:cR,used:t.priorInMemoryValues,notes:o.notes});if(!e)throw new kE(`cancelled`);s=e.filter(e=>e.channels.length>0)}if(s.length===0)throw Error(`${n.name}: no channels to read.`);let l=!t.split&&(s.length===1||s.every(e=>o.groups[e.group].time.kind!==`index`))?[s]:s.map(e=>[e]),u=l.length>1?crypto.randomUUID():null,d=t.priorInMemoryValues;for(let s of l){let c=ez(o,s,n.size),f=l.length>1?`${n.name} · ${o.groups[s[0].group].name}`:n.name,p=_z(o,e.format,s,u),m=crypto.randomUUID();if(uR(0,c,d)===`memory`){let e=await i.read(s,`memory`,{progress:t.onProgress});a.push(await vz(m,f,e,n,r,p)),d+=c}else a.push(await yz(m,f,i,o,s,n,r,p,t.onProgress))}return a}catch(e){for(let e of a)e.source.dispose().catch(()=>void 0);throw t.signal?.aborted?new kE(`cancelled`):e}finally{i.close()}}function xz(e){return e.filter(e=>e.type===`number`).map(e=>e.name)}function Sz(e,t,n=5e5){let r=1/0,i=-1/0,a=Math.max(1,Math.ceil(e.length/n));for(let n=0;n<e.length;n+=a){let a=e[n][t];typeof a==`number`&&(a<r&&(r=a),a>i&&(i=a))}if(!Number.isFinite(r)||!Number.isFinite(i))return{min:0,max:1};if(r===i){let e=Math.abs(r)*.05||1;return{min:r-e,max:i+e}}let o=(i-r)*.04;return{min:r-o,max:i+o}}function Cz(e){switch(e.kind){case`multiband`:return e.series.length;case`parallelcoords`:return e.pcColumns.length;case`barchart`:return e.bcValueCols.length;case`radar`:return e.rdAxesCols.length;case`areachart`:return e.acYCols.length;case`cdfchart`:return e.cdValueCols.length;case`losscurve`:return e.lcLeftCols.length+e.lcRightCols.length;case`gauge`:return e.ggGauges.length;case`camera`:return 0;case`heatmap`:return e.hmColumns.length;case`xyzmesh`:return e.xyzColumns?.length??0;default:return 0}}function wz(e,t=6){if(!Number.isFinite(e)||e<=0)return 1;let n=e/t,r=10**Math.floor(Math.log10(n)),i=n/r,a=1;return a=i<=1?1:i<=2?2:i<=5?5:10,a*r}function Tz(e){return Math.max(2,Math.min(6,Math.floor(e/64)))}function Ez(e,t,n,r){let i=Math.max(e,t)-Math.min(e,t),a=n!==void 0&&n>0&&Number.isFinite(n)?n:wz(i,6);(a<=0||!Number.isFinite(a))&&(a=wz(Math.max(i,1),6));let o=r!==void 0&&r>0&&Number.isFinite(r)?r:a/5;return(o<=0||!Number.isFinite(o))&&(o=a/5),{majorStep:a,minorStep:o}}function Dz(e,t,n){let r=Math.min(e,t),i=Math.max(e,t);if(n<=0||!Number.isFinite(n))return[];let a=[],o=Math.ceil(r/n-1e-12)*n,s=0;for(;o<=i+n*1e-9&&s++<1e4;)a.push(o),o+=n;return a}function Oz(e,t,n,r){let i=Math.min(e,t),a=Math.max(e,t);if(n<=0||!Number.isFinite(n))return[];let o=e=>r.some(t=>Math.abs(e-t)<=(Math.abs(t)+1)*1e-9+1e-9),s=[],c=Math.ceil(i/n-1e-12)*n,l=0;for(;c<=a+n*1e-9&&l++<2e4;)o(c)||s.push(c),c+=n;return s}var kz={[-12]:`p`,[-9]:`n`,[-6]:`µ`,[-3]:`m`,0:``,3:`k`,6:`M`,9:`G`,12:`T`};function Az(e){if(!(e>0)||!Number.isFinite(e))return 0;let t=Math.max(0,-Math.floor(Math.log10(e)+1e-9));for(let n=t;n<=t+2;n++){let t=e*10**n;if(Math.abs(t-Math.round(t))<=1e-6*t)return n}return t+1}function jz(e,t){if(!Number.isFinite(e))return`—`;if(!(t>0)||!Number.isFinite(t))return Mz(e);if(Math.abs(e)<t*1e-6)return`0`;let n=Math.floor(Math.log10(t)+1e-9);if(n>=3||n<-3){let r=3*Math.ceil((n-1)/3);if(r<-12||r>12)return e.toExponential(2);let i=e/10**r;if(r>0||Math.abs(i)<1e3)return i.toFixed(Az(t/10**r))+kz[r]}return e.toFixed(Az(t))}function Mz(e){if(!Number.isFinite(e))return`—`;if(e===0)return`0`;let t=Math.abs(e);if(t<1e-12||t>=0x38d7ea4c68000)return e.toExponential(3);let n=0;(t<.001||t>=1e6)&&(n=3*Math.floor(Math.log10(t)/3));let r=e/10**n,i=Math.max(0,3-Math.floor(Math.log10(Math.abs(r))));return n!==0&&Math.abs(+r.toFixed(i))>=1e3&&(n+=3,r/=1e3,i=3),r.toFixed(i)+kz[n]}var Nz=946684800,Pz=4102444800;function Fz(e,t,n){return/\(([^)]*)\)\s*$/.exec(e)?.[1].trim()===`s`&&n>t&&t>=Nz&&n<=Pz}var Iz=new Map;function Lz(e){let t=Iz.get(e);if(!t){let n={day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`};try{t=new Intl.DateTimeFormat(`en-GB`,{...n,timeZone:e})}catch{t=Lz(void 0)}Iz.set(e,t)}return t}var Rz=new Map,zz=(e,t)=>{let n=Math.round(e*1e3),r=Math.floor(n/1e3),i=`${t??``}|${r}`,a=Rz.get(i);if(!a){let e={};for(let{type:n,value:i}of Lz(t).formatToParts(r*1e3))e[n]=i;let n=`${e.hour}:${e.minute}`;a={date:`${e.day} ${e.month}`,year:e.year,hm:n,hms:`${n}:${e.second}`},Rz.size>=1024&&Rz.clear(),Rz.set(i,a)}return{...a,ms:String(n-r*1e3).padStart(3,`0`)}},Bz,Vz=new Set;function Hz(e){if(e!==void 0)try{new Intl.DateTimeFormat(void 0,{timeZone:e})}catch{e=void 0}if(e!==Bz){Bz=e;for(let e of Vz)e()}}var Uz=()=>Bz;function Wz(e){return Vz.add(e),()=>{Vz.delete(e)}}function Gz(e,t,n,r=Bz){let i=zz(e,r);return t>=86400?i.date:n>86400?`${i.date} ${i.hm}`:t>=60?i.hm:t>=1?i.hms:`${i.hms}.${i.ms}`}function Kz(e,t=Bz){let n=zz(e,t);return`${n.date} ${n.year} ${n.hms}.${n.ms}`}var qz=[`#fb923c`,`#60a5fa`,`#4ade80`,`#f87171`,`#facc15`,`#22d3ee`,`#f472b6`,`#2dd4bf`,`#94a3b8`,`#a3e635`];function Jz(e,t,n,r=qz){let i=r.length>0?r:qz;return e[t]??i[n%i.length]}function Yz(e){return[e===`light`?`#000000`:`#ffffff`,...qz.slice(0,9)]}function Xz(e,t=`dark`){let n=(e??[]).filter(e=>typeof e==`string`&&/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(e));return n.length>0?n:Yz(t)}var Zz=[`class`,`data-theme`,`data-color-scheme`];function Qz(e){return e?.closest(`[data-color-scheme]`)??document.documentElement}function $z(e){return Qz(e).getAttribute(`data-color-scheme`)===`light`?`light`:`dark`}function eB(e,t){let n=new MutationObserver(t),r=new Set([document.documentElement,Qz(e)]);for(let e of r)n.observe(e,{attributes:!0,attributeFilter:Zz});return()=>n.disconnect()}function tB(e,t){return!!t&&e.composedPath().includes(t)}var nB=[`min`,`max`,`mean`,`integral`,`first`,`last`,`delta`],rB=e=>`${e.channel}:${e.stat}`,iB=e=>`channel`in e?[e.channel]:[];function aB(e,t,n){switch(e){case`>`:return t>n;case`>=`:return t>=n;case`<`:return t<n;case`<=`:return t<=n;case`==`:return t===n;default:return t!==n}}function oB(e,t,n,r){switch(e){case`>`:case`>=`:return t<n-r;case`<`:case`<=`:return t>n+r;case`==`:return t!==n;default:return t===n}}var sB=()=>({prev:NaN,lo:0,hi:0});function cB(e,t){if(e.prev!==e.prev)return e.prev=e.lo=e.hi=t,!1;let n=t<e.prev&&e.prev-t>(e.hi-e.lo)/2;return n?e.lo=e.hi=t:(t<e.lo&&(e.lo=t),t>e.hi&&(e.hi=t)),e.prev=t,n}var lB=new Map,uB=e=>{let t=lB.get(e);return t||(t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),lB.set(e,t)),t};function dB(e,t){let n={};for(let r of uB(t).formatToParts(new Date(Math.floor(e)*1e3)))n[r.type]=r.value;return(Date.UTC(+n.year,n.month-1,+n.day,+n.hour,+n.minute,+n.second)-Math.floor(e)*1e3)/1e3}function fB(e,t){let n=e+dB(e,t);return new Date(Math.floor(n)*1e3).toISOString().slice(0,10)}function pB(e,t,n){let[r,i,a]=e.split(`-`).map(Number),[o,s]=t.split(`:`).map(Number),c=Date.UTC(r,i-1,a,o,s)/1e3;return c-dB(c-dB(c,n),n)}var mB=(e,t)=>{let[n,r,i]=e.split(`-`).map(Number);return new Date(Date.UTC(n,r-1,i+t)).toISOString().slice(0,10)},hB=class{n=0;sum=0;min=1/0;max=-1/0;first=NaN;last=NaN;integral=0;lastT=NaN;add(e,t){t===t&&(this.n>0?this.integral+=(t+this.last)/2*(e-this.lastT):this.first=t,this.n++,this.sum+=t,t<this.min&&(this.min=t),t>this.max&&(this.max=t),this.last=t,this.lastT=e)}value(e){if(this.n===0)return null;switch(e){case`min`:return this.min;case`max`:return this.max;case`mean`:return this.sum/this.n;case`integral`:return this.integral;case`first`:return this.first;case`last`:return this.last;default:return this.last-this.first}}},gB=class{rule;kpis;#e;#t=null;#n=NaN;#r=sB();#i=!1;#a=NaN;#o=NaN;#s=NaN;#c=new Map;constructor(e,t=[]){this.rule=e,this.kpis=t,this.#e=[...new Set(t.map(e=>e.channel))]}#l(e){this.#t={tstart:e,acc:new Map(this.#e.map(e=>[e,new hB]))}}#u(e,t,n){let r={duration:(t??n)-e.tstart};for(let t of this.kpis)r[rB(t)]=e.acc.get(t.channel).value(t.stat);return{tstart:e.tstart,tend:t,kpis:r}}#d(e){let t=this.#t;return this.#t=null,t?this.#u(t,e,e):null}assumeOpen(e){this.#t||(this.#l(e),this.rule.kind===`condition`&&(this.#i=!0))}#f(e){let t=this.#c.get(e);if(!t){let n=this.rule;t=n.starts.map(t=>pB(e,t,n.tz)).sort((e,t)=>e-t),this.#c.set(e,t)}return t}#p(e){let t=this.rule.tz,n=fB(e,t),r=-1/0;for(let t of this.#f(n))t<=e&&(r=t);if(r>-1/0)return r;let i=this.#f(mB(n,-1));return i[i.length-1]}#m(e){let t=this.rule.tz,n=fB(e,t);for(let t of this.#f(n))if(t>e)return t;return this.#f(mB(n,1))[0]}feed(e,t,n){let r=[],i=this.rule,a=i.kind===`edge`||i.kind===`condition`?t(i.channel):void 0,o=this.#e.map(e=>[e,t(e)]);for(let t=0;t<e.length;t++){let s=e[t];if(i.kind===`window`){if(!(s>=this.#a&&s<this.#o)){let e=this.#p(s);if(this.#t){let t=this.#d(this.#o<=e?this.#o:e);t&&r.push(t)}this.#a=e,this.#o=this.#m(e),this.#l(e)}}else if(a&&i.kind!==`manual`){let e=a[t];if(e===e){if(i.kind===`edge`){let t=!1;if(i.on===`reset`){let n=this.#r.prev!==this.#r.prev;t=cB(this.#r,e),n&&!this.#t&&this.#l(s)}else if(this.#n===this.#n){let n=i.value??0;t=i.on===`change`?e!==this.#n:i.on===`rise`?this.#n<n&&e>=n:this.#n>n&&e<=n}if(this.#n=e,t){let e=this.#d(s);e&&r.push(e),this.#l(s)}}else if(!this.#i)aB(i.op,e,i.value)&&(this.#i=!0,this.#l(s));else if(oB(i.op,e,i.value,i.hysteresis??0)){this.#i=!1;let e=this.#d(s);e&&s-e.tstart>=(i.min_s??0)&&r.push(e)}}}let c=this.#t;if(c)for(let[e,n]of o)n&&c.acc.get(e).add(s,n[t]);this.#s=s,n?.(t,c?c.tstart:null)}return r}open(){let e=this.#t;return!e||this.rule.kind===`condition`&&this.#s-e.tstart<(this.rule.min_s??0)?null:this.#u(e,null,this.#s)}},_B=[{value:`span`,label:`Span (max − min)`},{value:`mean`,label:`Mean`},{value:`max`,label:`Max`},{value:`min`,label:`Min`}];function vB(e,t){let n=[],r=sB(),i=-1;for(let a=0;a<e.length;a++){let o=e[a][t];if(typeof o!=`number`)continue;let s=cB(r,o);i<0?i=0:s&&(n.push({start:i,end:a}),i=a)}return i>=0&&n.push({start:i,end:e.length}),n}function yB(e,t){let n=[],r=e.length-1,i=Math.max(1,Math.floor(e.length/256)),a=t=>{let n=0,r=0,a=0;for(let o=0;o+1<e.length;o+=i){let i=e[o][t],s=e[o+1][t];typeof i!=`number`||typeof s!=`number`||(n++,s<i?r++:s===i&&a++)}return n<32||r<=.3*n&&a<=.9*n};for(let o of t){if(i>1&&!a(o))continue;let t=0,s=0,c=0,l=null,u=!1;for(let n of e){let e=n[o];if(typeof e==`number`){if(l!==null&&(c++,e>l?t++:e===l&&s++,c-t-s>.1*r||s>.5*r)){u=!0;break}l=e}}if(u||c===0||(t+s)/c<.9||t/c<.5)continue;let d=vB(e,o).length;d>1&&n.push({col:o,laps:d})}return n.sort((e,t)=>t.laps-e.laps).map(e=>e.col)}function bB(e,t){return yB(e,t)[0]??t[0]??``}function xB(e,t,n){if(n&&t.includes(n.channel)&&vB(e,n.channel).length>1)return{...n,metric:t.includes(n.metric)?n.metric:n.channel};let r=yB(e,t);if(r.length===0)return null;let i=r.find(e=>/time/i.test(e));return{channel:r[0],metric:i??r[0],stat:`span`}}function SB(e,t,n,r){let i=0,a=0,o=1/0,s=-1/0;for(let r=t.start;r<t.end;r++){let t=e[r][n];typeof t==`number`&&(i++,a+=t,t<o&&(o=t),t>s&&(s=t))}return i===0?null:r===`mean`?a/i:r===`max`?s:r===`min`?o:s-o}function CB(e){let t=e.filter(e=>e!==null);if(t.length===0)return null;let n=[...t].sort((e,t)=>e-t)[Math.floor(t.length/2)],r=t.filter(e=>e>=n*.8),i=Math.min(...r.length>1?r:t);return e.indexOf(i)}function wB(e,t){return t.trim()===`s`||/time/i.test(e)}function TB(e,t,n){if(e===null)return`—`;if(n&&e>=0){let t=Math.round(e*1e3),n=Math.floor(t/6e4);return`${n}:${((t-n*6e4)/1e3).toFixed(3).padStart(6,`0`)}`}let r=Math.abs(e),i=r!==0&&r<.01?Mz(e):e.toFixed(r>=1e3?0:r>=100?1:3);return t.trim()?`${i} ${t.trim()}`:i}function EB(e,t){return`${e}::lap${t}`}function DB(e){let t=new Map,n=n=>{let r=t.get(n);return r||t.set(n,r=e.at.map(t=>pB(n,t,e.tz)).sort((e,t)=>e-t)),r},r=t=>{let r=fB(t,e.tz),i=-1/0;for(let e of n(r))e<=t&&(i=e);if(i>-1/0)return i;let a=n(mB(r,-1));return a[a.length-1]},i=t=>{let r=fB(t,e.tz);for(let e of n(r))if(e>t)return e;return n(mB(r,1))[0]},a=NaN,o=NaN,s={on:!1,edge:!1,at:NaN,event:!0,step(e){if(s.edge=s.on=!(e.t>=a&&e.t<o),!s.edge)return;let t=r(e.t);s.closeAt=o<=t?o:t,s.at=a=t,o=i(t)}};return s}function OB(e){switch(e.kind){case`compare`:{let t={on:!1,edge:!1,at:NaN,event:!1,step(n){let r=n.v(e.channel);r===r&&(t.on=aB(e.op,r,e.value)),t.at=n.t}};return t}case`elapsed`:{let t={on:!1,edge:!1,at:NaN,event:!1,step(n){let r=n.t-(e.from===`start`?n.start:n.ps);t.on=r===r&&(e.op===`>=`?r>=e.seconds:r<=e.seconds),t.at=n.t}};return t}case`change`:case`cross`:{let t=NaN,n={on:!1,edge:!1,at:NaN,event:!0,step(r){let i=r.v(e.channel);n.edge=!1,i===i&&(t===t&&(n.edge=e.kind===`change`?i!==t:e.dir===`rise`?t<e.value&&i>=e.value:t>e.value&&i<=e.value),t=i),n.on=n.edge,n.at=r.t}};return n}case`reset`:{let t=sB(),n={on:!1,edge:!1,at:NaN,event:!0,step(r){let i=r.v(e.channel);n.edge=i===i&&(t.prev===t.prev?cB(t,i):(cB(t,i),!0)),n.on=n.edge,n.at=r.t}};return n}case`clock`:return DB(e);case`parent-start`:{let e=!1,t={on:!1,edge:!1,at:NaN,event:!0,step(n){t.on=t.edge=!e,e=!0,t.at=n.ps}};return t}case`all`:case`any`:{let t=e.of.map(OB),n={on:!1,edge:!1,at:NaN,event:t.some(e=>e.event),step(r){for(let e of t)e.step(r);n.on=e.kind===`all`?t.every(e=>e.on):t.some(e=>e.on),n.edge=n.on&&t.some(e=>e.edge),n.at=r.t}};return n}default:return{on:!1,edge:!1,at:NaN,event:!0,step(){}}}}var kB=(e,t)=>e.kind===t||(e.kind===`all`||e.kind===`any`)&&e.of.some(e=>kB(e,t));function AB(e){let t=new Set,n=e=>{`channel`in e&&t.add(e.channel),(e.kind===`all`||e.kind===`any`)&&e.of.forEach(n)};return n(e.start),n(e.end),[...t]}var jB=class{rule;#e;#t;#n=NaN;#r=!1;#i=NaN;#a=NaN;#o=NaN;#s=NaN;#c;#l;constructor(e){this.rule=e,this.#c=kB(e.end,`parent-end`),this.#l=e.end.kind===`next-start`,this.#u()}#u(){this.#e=OB(this.rule.start),this.#t=OB(this.rule.end),this.#r=!1}#d(e,t,n){let r=this.rule.limits;if(!r)return[];let i=[],a=r.from===`start`?e:this.#n;return r.expectedWithin_s!=null&&t-a>r.expectedWithin_s&&i.push(`late`),r.max_s!=null&&t-e>r.max_s&&i.push(`too-long`),n&&r.min_s!=null&&t-e<r.min_s&&i.push(`too-short`),i}#f(e,t,n=!1){let r={tstart:this.#i,tend:e,flags:this.#d(this.#i,e,!0)};n&&(r.incomplete=!0),t.push(r),this.#i=this.#o=NaN}parentStart(e){this.#n=e,this.#i=this.#a=this.#o=NaN,this.#u()}parentEnd(e,t){this.#i===this.#i&&this.#f(e,t,!this.#c),this.#a=NaN,this.#n=NaN}step(e,t,n){this.#n!==this.#n&&(this.#n=e);let r={t:e,v:t,ps:this.#n,start:this.#i},i=this.#e,a=this.#t;i.step(r),a.step(r);let o=i.on&&(!this.#r||i.edge);this.#r=i.on;let s=i.event&&!(this.rule.start.kind===`all`||this.rule.start.kind===`any`)?i.at:e;if(this.#i===this.#i&&!this.#l&&e>this.#i){let t=this.rule.ignoreDips_s??0;a.on?t>0&&!a.event?(this.#o!==this.#o&&(this.#o=e),e-this.#o>=t&&this.#f(this.#o,n)):this.#f(e,n):this.#o=NaN}let c=e=>{this.#i===this.#i&&this.#f(this.#l&&i.closeAt!==void 0?i.closeAt:e,n),this.#i=e},l=this.#i!==this.#i||this.#l,u=this.rule.minHold_s??0;this.#a===this.#a?i.on?e-this.#a>=u&&(l&&c(this.#a),this.#a=NaN):this.#a=NaN:o&&l&&(u>0&&!i.event?this.#a=s:c(s)),this.#s=e}open(){return this.#i===this.#i?{tstart:this.#i,tend:null,flags:this.#d(this.#i,this.#s,!1)}:null}},MB=class{#e;constructor(e){let t=[],n=r=>{for(let i of e)i.parentId===r&&(t.push(i),n(i.id))};n(null),this.#e=t.map(e=>({...e,runner:new jB(e.rule),count:0,current:0,kids:[]})),this.#e.forEach((e,t)=>{e.parentId&&this.#e.find(t=>t.id===e.parentId).kids.push(t)})}#t(e,t,n,r){let i=this.#e[e];for(let e of t)n.push({...e,definitionId:i.id,index:i.current,...r?{parentIndex:r}:{}})}#n(e){let t=this.#e[e].parentId;return t?this.#e.find(e=>e.id===t).current:void 0}#r(e,t,n){for(let r of this.#e[e].kids){this.#r(r,t,n);let i=[];this.#e[r].runner.parentEnd(t,i),this.#t(r,i,n,this.#e[e].current)}}#i(e,t,n,r){let i=this.#e[e],a=i.runner.open()?.tstart,o=[];i.runner.step(t,n,o);let s=i.runner.open()?.tstart;if(o.length)for(let t of o)this.#r(e,t.tend,r),r.push({...t,definitionId:i.id,index:i.current,...this.#n(e)?{parentIndex:this.#n(e)}:{}});if(s!==void 0&&s!==a){i.current=++i.count;for(let e of i.kids)this.#e[e].current=this.#e[e].count=0,this.#e[e].runner.parentStart(s)}if(s!==void 0)for(let e of i.kids)this.#i(e,t,n,r)}feed(e,t){let n=new Map,r=e=>(n.has(e)||n.set(e,t(e)),n.get(e)),i=[],a=0,o=e=>{let t=r(e);return t?t[a]:NaN};for(;a<e.length;a++)for(let t=0;t<this.#e.length;t++)this.#e[t].parentId||this.#i(t,e[a],o,i);return i}open(){let e=[];return this.#e.forEach((t,n)=>{let r=t.runner.open(),i=this.#n(n);r&&(!t.parentId||this.#e.find(e=>e.id===t.parentId).runner.open())&&e.push({...r,definitionId:t.id,index:t.current,...i?{parentIndex:i}:{}})}),e}},NB=new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]),PB=e=>typeof e==`number`&&Number.isFinite(e),FB=e=>typeof e==`string`&&e.length>0;function IB(e,t){let n=e;if(!n||typeof n!=`object`)return!1;switch(n.kind){case`parent-start`:case`parent-end`:case`next-start`:case`manual`:return!0;case`all`:case`any`:return t<3&&Array.isArray(n.of)&&n.of.length>0&&n.of.every(e=>IB(e,t+1));case`compare`:return FB(n.channel)&&NB.has(n.op)&&PB(n.value);case`change`:case`reset`:return FB(n.channel);case`cross`:return FB(n.channel)&&(n.dir===`rise`||n.dir===`fall`)&&PB(n.value);case`elapsed`:return(n.from===`parent-start`||n.from===`start`)&&(n.op===`>=`||n.op===`<=`)&&PB(n.seconds);case`clock`:return Array.isArray(n.at)&&n.at.length>0&&n.at.every(e=>typeof e==`string`&&/^\d\d:\d\d$/.test(e))&&FB(n.tz);default:return!1}}function LB(e){if(!Array.isArray(e))return[];let t=e.filter(e=>{let t=e?.rule,n=t?.limits;return FB(e?.id)&&FB(e?.name)&&(e.parentId===null||FB(e.parentId))&&!!t&&IB(t.start,1)&&IB(t.end,1)&&(t.minHold_s===void 0||PB(t.minHold_s))&&(t.ignoreDips_s===void 0||PB(t.ignoreDips_s))&&(n===void 0||typeof n==`object`&&[`expectedWithin_s`,`min_s`,`max_s`].every(e=>n[e]===void 0||PB(n[e])))}),n=new Set(t.map(e=>e.id));return t.filter(e=>e.parentId===null||n.has(e.parentId)).map(e=>{let t=Array.isArray(e.kpis)?e.kpis.filter(e=>FB(e?.channel)&&nB.includes(e.stat)).slice(0,50):[],n=FB(e.show?.channel)&&nB.includes(e.show.stat)?{channel:e.show.channel,stat:e.show.stat}:void 0;return{id:e.id,name:e.name,parentId:e.parentId,rule:e.rule,...t.length?{kpis:t}:{},...n?{show:n}:{}}})}var RB=`Cycle time`,zB=65536;async function BB(e,t,n){let r=[...new Set([t,...n])],i=[];for(let n=0;;n+=zB){let a=await e.readColumns(r,n,zB),o=a[t]?.length??0;if(o>0&&i.push(a),o<zB)break}let a=e=>{if(!i.some(t=>t[e]))return;let n=new Float64Array(i.reduce((e,n)=>e+n[t].length,0)).fill(NaN),r=0;for(let a of i)a[e]&&n.set(a[e],r),r+=a[t].length;return n},o=new Map;for(let e of r){let n=e===t?void 0:a(e);n&&o.set(e,n)}return{t:a(t)??new Float64Array,cols:o}}function VB(e,t){let n=new MB(t);return[...n.feed(e.t,t=>e.cols.get(t)),...n.open()]}var HB=e=>[...new Set(e.flatMap(e=>[...AB(e.rule),...(e.kpis??[]).map(e=>e.channel)]))],UB=e=>`${e.channel} ${e.stat}`;function WB(e,t,n){let r=GB(e.t,t.tstart),i=t.tend===null?e.t.length:GB(e.t,t.tend),a={};for(let t of n){let n=e.cols.get(t.channel),o=new hB;if(n)for(let t=r;t<i;t++)o.add(e.t[t],n[t]);a[UB(t)]=o.value(t.stat)}return a}function GB(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}function KB(e,t,n){let r=GB(e.t,n.tstart),i=n.tend===null?e.t.length:GB(e.t,n.tend),a=e.t.subarray(r,i),o={[RB]:a.map(e=>e-n.tstart),[t]:a};for(let[t,n]of e.cols)o[t]=n.subarray(r,i);return o}var qB=e=>e.replace(`-`,` `);function JB(e,t,n,r){let i=Object.fromEntries(n.map(e=>[e.id,e.name])),a=e=>n.find(t=>t.id===e)?.kpis??[],o=e=>r?WB(r,e,a(e.definitionId)):{},s=n.filter(e=>e.parentId===t).map(e=>e.id),c=e=>e.tend===null?null:e.tend-e.tstart,l=e.filter(e=>s.includes(e.definitionId)).sort((e,t)=>e.tstart-t.tstart);return{cycles:e.filter(e=>e.definitionId===t).sort((e,t)=>e.index-t.index).map(e=>{let t=l.filter(t=>t.parentIndex===e.index),n={Cycle:e.index,Start:e.tstart,End:e.tend,Duration:c(e)};for(let e of s){let r=t.filter(t=>t.definitionId===e);n[`${i[e]??e} duration`]=r.length&&r.every(e=>e.tend!==null)?r.reduce((e,t)=>e+t.tend-t.tstart,0):null}return Object.assign(n,o(e)),n.Flags=[...e.flags.map(qB),...t.flatMap(e=>e.flags.map(t=>`${i[e.definitionId]??e.definitionId} ${qB(t)}`))].join(`, `),n}),phases:l.map(e=>({Cycle:e.parentIndex,Phase:i[e.definitionId]??e.definitionId,Start:e.tstart,End:e.tend,Duration:c(e),...o(e),Flags:e.flags.map(qB).join(`, `)}))}}function YB(e){if(e.length===0)return``;let t=Object.keys(e[0]),n=e=>e===null?``:typeof e==`number`?String(e):/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e;return[t.map(n).join(`,`),...e.map(e=>t.map(t=>n(e[t]??null)).join(`,`))].join(`
|
|
70
|
+
`)),r=H(n,t.headerRow).length,i=n.slice(t.dataStartRow);if(i.length===0)return Math.ceil(e/8);let a=n.slice(0,t.dataStartRow).reduce((e,t)=>e+t.length+1,0),o=i.reduce((e,t)=>e+t.length+1,0)/i.length;return Math.ceil(Math.max(0,e-a)/o)*r}catch{return Math.ceil(e/8)}}var fR=12e3;async function pR(e,t,n){let r=y(n),i=typeof Worker>`u`?k(n,r):await NE({rawText:n,config:r}),a=new LE(i);return{id:e,name:t,kind:`memory`,source:a,schema:await a.getSchema(),data:i,rawText:n,parseConfig:r}}async function mR(e,t,n,r,i=e=>e.text(),a){let o=y(r),s=typeof Worker>`u`?await PE({rawText:await i(n),config:o},a):await PE({file:n,config:o},a),c=new LE(s);return{id:e,name:t,kind:`memory`,source:c,schema:await c.getSchema(),data:s,rawText:r,file:n,parseConfig:o}}async function hR(e,t,n){let r=await sR.open(t,n),i=await r.getSchema(),a=await r.sampleRows(fR),o={meta:``,columnNames:i.map(e=>e.name),units:i.map(e=>e.unit),rows:a},s=await t.slice(0,lR).text();return{id:e,name:t.name,kind:`duckdb`,source:r,schema:i,data:o,rawText:s,parseConfig:y(s)}}async function gR(e,t,n,r,i=0,a){let o=await t.slice(0,lR).text();return uR(t.size,dR(t.size,o),i)===`memory`?mR(e,t.name,t,o,e=>n(e),a):hR(e,t,r)}function _R(e,t){return e instanceof File&&e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}async function vR(e,t,n){let r=n.find(e=>e.kind===`memory`&&e.parseConfig&&_R(e.file,t)&&Ue(e.data.rows));if(!r)return null;let i=await t.slice(0,lR).text();if(!ee(r.parseConfig,y(i)))return null;let a={...r.data,rows:Me(Ue(r.data.rows))};return{id:e,name:t.name,kind:`memory`,source:new LE(a),schema:r.schema,data:a,rawText:r.rawText,file:t,parseConfig:r.parseConfig}}function yR(e){let t=new Set,n=0;for(let r of e){if(r.kind!==`memory`)continue;let e=Ue(r.data.rows)??r.data.rows;t.has(e)||(t.add(e),n+=r.data.rows.length*r.data.columnNames.length)}return n}var bR=4096,xR=[`.dat`,`.txt`,`.csv`,`.tsv`],SR=[we,r,Ee,E,l,d,P],CR=e=>{let t=e.lastIndexOf(`.`);return t<=0?``:e.slice(t).toLowerCase()},wR=e=>{let t=e.lastIndexOf(`.`);return(t<=0?e:e.slice(0,t)).toLowerCase()};async function TR(e){let t=new Uint8Array(await e.slice(0,bR).arrayBuffer()),n=CR(e.name),r=SR.filter(e=>e.extensions.includes(n));for(let n of[...r,...SR.filter(e=>!r.includes(e))])if(n.sniff(t,e.name))return n;return null}async function ER(e){return new Uint8Array(await e.slice(0,bR).arrayBuffer()).includes(0)}async function DR(e){let t=await Promise.all(e.map(TR)),n=[],r=new Set;e.forEach((e,i)=>{let a=t[i];a&&(n.push({main:e,companions:[],format:a}),r.add(e))});for(let i of[...n])for(let n of i.format.companions??[]){let a=e.filter((e,r)=>!t[r]&&CR(e.name)===n.ext),o=a.find(e=>wR(e.name)===wR(i.main.name))??(n.anyName&&a.length===1?a[0]:void 0);o&&(i.companions.push(o),r.add(o))}let i=new Set(SR.flatMap(e=>(e.companions??[]).map(e=>e.ext))),a=[];for(let t of e){if(r.has(t))continue;let e=CR(t.name);e===`.dat`&&await ER(t)?a.push({file:t.name,error:Error(`This COMTRADE .dat needs its .cfg file — drop both together.`)}):xR.includes(e)?n.push({main:t,companions:[],format:null}):i.has(e)?a.push({file:t.name,error:Error(`${t.name} is read together with its main file (same name). Drop both files together.`)}):a.push({file:t.name,error:Error(`${t.name}: Kymoscope cannot read this file type.`)})}return n.sort((t,n)=>e.indexOf(t.main)-e.indexOf(n.main)),{items:n,errors:a}}var OR=[...new Set([...xR,...SR.flatMap(e=>[...e.extensions,...(e.companions??[]).map(e=>e.ext)])])];function kR(e){let t=0;for(let n=0;n<e.length;n++)e[n]!==e[n]&&t++;if(t===0)return qM(e);let n=new Uint8Array(e.length+7>>3);for(let t=0;t<e.length;t++)e[t]===e[t]&&(n[t>>3]|=1<<(t&7));return qM(xM({type:new Ek,data:e,nullBitmap:n,length:e.length,nullCount:t}))}var AR=122880,jR=class{#e;#t;#n;#r=!1;#i=[];#a=0;#o;rows=0;constructor(e,t,n,r=AR){this.#e=e,this.#t=t,this.#n=new cN(n.map(e=>new lN(e.name,e.text?new kk:new Ek,!0))),this.#o=r}async append(e){let t=e.length;if(t===0)return;let n=this.#n.fields.map((n,r)=>{let i=e.columns[r];return(i instanceof Float64Array?kR(i.subarray(0,t)):rF(i.slice(0,t),new kk)).data[0]});this.#i.push(new pF(this.#n,xM({type:new Bk(this.#n.fields),length:t,nullCount:0,children:n}))),this.#a+=t,this.rows+=t,this.#a>=this.#o&&await this.flush()}async flush(){if(this.#a===0)return;let e=new uF(this.#n,this.#i);this.#i=[],this.#a=0,await this.#e.insertArrowTable(e,{name:this.#t,create:!this.#r}),this.#r=!0}},MR=`This file's groups do not interleave in time: reading them together would hold too much in memory. Choose fewer groups, or split them.`,NR=e=>e.length*(1+e.columns.length);function PR(e){let t=e[Symbol.asyncIterator]();return{pull:async()=>{let e=await t.next();return e.done?null:e.value}}}function FR(e,t){let n=Array.from({length:t.size},()=>[]),r=!1,i=0,a=async a=>{for(;;){if(n[a].length){let e=n[a].shift();return i-=NR(e),e}if(r)return null;let o=await e.next();if(o.done){r=!0;continue}let s=t.get(o.value.group);if(s!==void 0&&(n[s].push(o.value),(i+=NR(o.value))>128e6))throw Error(MR)}};return n.map((e,t)=>({pull:()=>a(t)}))}function IR(e,t){if(e.time)return e.time;let n=new Float64Array(e.length);if(t.time.kind===`rate`){let{rate:r,start:i}=t.time;for(let t=0;t<e.length;t++)n[t]=i+(e.start+t)/r}else for(let t=0;t<e.length;t++)n[t]=e.start+t;return n}var LR=new Int32Array,RR={t:new Float64Array,cols:[],from:0};function zR(e,t,n,r){let i=n,a=r;for(;i<a;){let n=i+a>>>1;e[n]<=t?i=n+1:a=n}return i}var BR=class{group;channels;feed;pending=[];done=!1;last;scratch=[];#e=-1/0;constructor(e,t,n){this.group=e,this.channels=t,this.feed=n,this.last=t.map(e=>e.text?null:NaN)}rows(){let e=0;for(let t of this.pending)e+=t.t.length-t.from;return e}lastTime(){let e=this.pending[this.pending.length-1];return e&&e.t.length>e.from?e.t[e.t.length-1]:-1/0}async fill(){let e=await this.feed.pull();if(!e){this.done=!0;return}if(e.length===0)return;let t=VR(IR(e,this.group),this.#e);if(t.length&&(this.#e=t[t.length-1]),this.pending.push({t,cols:e.columns,from:0}),this.rows()*(1+this.channels.length)>128e6)throw Error(MR)}};function VR(e,t){let n=t,r=0;for(;r<e.length;r++){let t=e[r];if(!(t>=n&&t>-1/0&&t<1/0))break;n=t}if(r===e.length)return e;for(n===-1/0&&(n=0);r<e.length;r++){let t=e[r];t>=n&&t<1/0?n=t:e[r]=n}return e}function HR(e,t){let n=e.length,r=e.map(e=>e.t),i=Int32Array.from(e,e=>e.from),a=Int32Array.from(e,e=>zR(e.t,t,e.from,e.t.length));if(n===1)return r[0].subarray(i[0],a[0]);let o=0;for(let e=0;e<n;e++)o+=a[e]-i[e];let s=new Float64Array(o),c=0;for(;;){let e=1/0;for(let t=0;t<n;t++)i[t]<a[t]&&r[t][i[t]]<e&&(e=r[t][i[t]]);if(e===1/0)break;s[c++]=e;for(let t=0;t<n;t++){let n=r[t],o=a[t],s=i[t];for(;s<o&&n[s]===e;)s++;i[t]=s}}return s.subarray(0,c)}function UR(e,t,n,r,i,a){if(i-r>8)e.set(t.subarray(n+r,n+i),a);else for(let o=r;o<i;o++)e[a+o-r]=t[n+o]}function WR(e,t,n,r,i,a){let o=0;for(let s=0;s<n.length;s++){let c=n[s],l=c.length;if(l===0)continue;let u=i[s].from,d=i[s].cols[a];e.fill(t,o,c[0]);let f=r[s],p=0;for(let t=0;t<f.length;t++){let n=f[t];UR(e,d,u,p,n,c[p]);let r=c[n],i=c[n+1],a=d[u+n];if(i-r>16)e.fill(a,r,i);else for(let t=r;t<i;t++)e[t]=a;p=n+1}UR(e,d,u,p,l-1,c[p]),o=c[l-1],t=d[u+l-1]}e.fill(t,o,e.length)}function GR(e,t,n,r,i){let a=0;for(let o=0;o<n.length;o++){let s=n[o],c=s.length;if(c===0)continue;let l=r[o].from,u=r[o].cols[i];e.fill(t,a,s[0]);for(let t=0;t<c-1;t++)e.fill(u[l+t],s[t],s[t+1]);a=s[c-1],t=u[l+c-1]}e.fill(t,a,e.length)}function KR(e,t,n,r,i){let a=n.length,o=null,s=0;for(let c=0;c<i.length;c++){let l=e[t+c],u=r;if(n[r]<l){let e=r,t=1;for(;e+t<a&&n[e+t]<l;)e+=t,t*=2;let i=Math.min(e+t,a-1);for(;i-e>1;){let t=e+i>>>1;n[t]<l?e=t:i=t}r=i}i[c]=r,c>0&&r!==u+1&&((o??=new Int32Array(i.length-1))[s++]=c-1)}return o?o.subarray(0,s):LR}function qR(e,t,n,r,i){let a=t.length;if(r){let t=e.pending[0],n=t.from+a,r=t.cols.map(e=>e instanceof Float64Array?e.subarray(t.from,n):e.slice(t.from,n));if(a>0)for(let i=0;i<r.length;i++)e.last[i]=t.cols[i][n-1];return e.pending=n<t.t.length?[{...t,from:n}]:[],r}let o=e.pending,s=[],c=[];if(a>0){let e=t[a-1],n=0;for(let r of o){let i=r.t,a=zR(i,e,r.from,i.length),o=new Int32Array(a-r.from);if(c.push(KR(i,r.from,t,n,o)),o.length&&(n=o[o.length-1]),s.push(o),a<i.length)break}}let l=e.channels.map((r,l)=>{if(r.sparse&&n){let e=r.text?Array(a).fill(null):new Float64Array(a).fill(NaN);for(let n=0;n<s.length;n++){let r=s[n],{t:i,from:c}=o[n],u=o[n].cols[l];for(let n=0;n<r.length;n++){let o=r[n];o<a&&t[o]===i[c+n]&&(e[o]=u[c+n])}}return e}if(r.text){let t=Array(a);return GR(t,e.last[l],s,o,l),t}let u;return i?(e.scratch[l]?.length>=a||(e.scratch[l]=new Float64Array(a)),u=e.scratch[l].subarray(0,a)):u=new Float64Array(a),WR(u,e.last[l],s,c,o,l),u}),u=[];for(let t=0;t<o.length;t++){let n=o[t],r=t<s.length?s[t].length:0;if(r>0)for(let t=0;t<e.channels.length;t++)e.last[t]=n.cols[t][n.from+r-1];n.from+r<n.t.length&&u.push(r?{...n,from:n.from+r}:n)}return e.pending=u,l}async function JR(e,t,n,r,i,a=!1){let o=e.map((e,r)=>new BR(e,t[r],n[r])),s=-1;e.forEach((t,n)=>{!t.irregular&&(s<0||t.samples>e[s].samples)&&(s=n)});let c=e.map((e,t)=>t===s||!!e.irregular),l=o.filter((e,t)=>c[t]),u=l.length===1,d=0;for(;;){i?.throwIfAborted();for(let e of l)for(;!e.done&&e.rows()===0;)await e.fill();if(l.every(e=>e.rows()===0))break;let e=1/0;for(let t of l)t.done||(e=Math.min(e,t.lastTime()));for(let t=0;t<o.length;t++)if(!c[t])for(;!o[t].done&&o[t].lastTime()<=e;)await o[t].fill();let t=HR(l.map(e=>e.pending[0]??RR),e),n=[t];for(let e=0;e<o.length;e++)n.push(...qR(o[e],t,c[e],u&&c[e],a));d+=t.length,t.length&&await r({length:t.length,columns:n})}return d}var YR=class{#e;#t;#n;#r=0;constructor(e,t){let n=Math.max(1024,t);this.#e=e.map(e=>e.name),this.#t=e.map(()=>new Float64Array(n)),this.#n=e.map(()=>null)}append(e){let t=this.#r,n=t+e.length;if(n>this.#t[0].length){let e=Math.max(n,Math.ceil(this.#t[0].length*1.5));this.#t=this.#t.map(n=>{let r=new Float64Array(e);return r.set(n.subarray(0,t)),r})}e.columns.forEach((n,r)=>{let i=this.#t[r];if(n instanceof Float64Array){i.set(n.subarray(0,e.length),t);return}let a=this.#n[r];for(let o=0;o<e.length;o++){i[t+o]=NaN;let e=n[o];e!=null&&((a??=this.#n[r]=[])[t+o]=e)}}),this.#r=n}table(){let e=this.#r,t=this.#t.map(t=>t.length-e>t.length/100?t.slice(0,e):t.subarray(0,e));return{keys:this.#e,length:e,values:t,text:this.#n}}};async function XR(e,t,n){return M(await e.plan(t,n))}var ZR=(e,t,n)=>Math.max(0,Math.min(e,Math.max(1<<20,n),Math.floor(1e8/t)));function QR(e,t){let n=t.flatMap(t=>t.channels.map(n=>({ch:e.groups[t.group].channels[n],group:e.groups[t.group].name}))),r=new Map;for(let{ch:e}of n)r.set(e.name.toLowerCase(),(r.get(e.name.toLowerCase())??0)+1);let i=Ze(n.map(({ch:e,group:n})=>t.length>1&&r.get(e.name.toLowerCase())>1?`${e.name} [${n}]`:e.name));return[{name:`Time`,unit:t.every(t=>e.groups[t.group].time.kind===`index`)?``:`s`,text:!1},...n.map(({ch:e},t)=>({name:i[t],unit:e.unit,text:!!e.text}))]}function $R(e,t){let n=t.map(t=>e.groups[t.group]);if(n.some(e=>e.samples<0))return-1;let r=0,i=0;for(let e of n)e.irregular?i+=e.samples:r=Math.max(r,e.samples);return r+i}function ez(e,t,n){let r=$R(e,t);return r<0?Math.ceil(n/4):r*(1+t.reduce((e,t)=>e+t.channels.length,0))}async function tz(e,t,n,r,i,a,o={}){let s=QR(n,i),c=i.map(e=>n.groups[e.group]),l=i.map(e=>e.channels.map(t=>n.groups[e.group].channels[t])),u=[...n.events];async function*d(e){for await(let t of e)t.events&&u.push(...t.events),yield t}let f={files:t,plan:n,io:r,selection:i,signal:o.signal},p=e.streamGroup&&i.length>1&&!n.interleaved?i.map(t=>PR(d(e.streamGroup({...f,selection:[t]},t.group)))):FR(d(e.stream(f)),new Map(i.map((e,t)=>[e.group,t]))),m=$R(n,i),h=a===`memory`?new YR(s,ZR(m,s.length,r.size)):null,g=0,_=await JR(c,l,p,async e=>{h?h.append(e):await o.chunk(e);let t=Date.now();o.progress&&t-g>100&&(g=t,o.progress(Math.min(.99,r.bytesRead/Math.max(1,r.size))))},o.signal,!!h);return o.progress?.(1),u.sort((e,t)=>e.time-t.time),{columns:s,rows:_,table:h?.table(),events:u}}var nz=``+new URL(`assets/importer.worker-CLBGjz4d.js`,import.meta.url).href,rz=``+new URL(`assets/h5wasmModule-BCQWU2Gw.js`,import.meta.url).href,iz=()=>new kE(`cancelled`);function az(){let e=AE(nz);return e.postMessage({type:`init`,h5Url:new URL(rz,location.href).href}),e}var oz=null,sz=e=>{typeof requestIdleCallback==`function`?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,1e3)};function cz(e,t=az){t===az&&typeof Worker>`u`||(oz&&oz.make!==t&&(oz.w.terminate(),oz=null),oz??={w:t(),h5:!1,make:t},e&&!oz.h5&&(oz.h5=!0,oz.w.postMessage({type:`warm`})))}function lz(e){if(oz?.make!==e)return{w:e(),rewarm:null};let{w:t,h5:n}=oz;return oz=null,{w:t,rewarm:n}}function uz(e,t,n,r,i){return!r&&typeof Worker>`u`?dz(e,t,n,i):pz(e,t,n,r??az)}function dz(e,t,n,r=async e=>(await import(`./importers-BVYsv8Vy.js`)).importerFor(e)){let i=new U(t.main),a=null,o=null,c=e=>e.catch(e=>{throw n?.aborted?iz():s(e)});return{plan:()=>c((async()=>(a=await r(e),o=await XR(a,t,i)))()),read:(e,r,s={})=>(i.bytesRead=0,c(tz(a,t,o,i,e,r,{...s,signal:n}))),close(){}}}var fz=3e4;function pz(e,t,n,r){let{w:i,rewarm:a}=lz(r),o=null,s=Promise.resolve(),c=Date.now(),l=-1,u=0,d=!1,f=e=>{let t=o;o=null,t?.reject(e)},p=e=>{d=!0,i.terminate(),f(e)},m=setInterval(()=>{o&&u===0&&Date.now()-c>fz&&p(Error(ce))},1e3),h=()=>p(iz());n?.addEventListener(`abort`,h,{once:!0}),i.onmessage=e=>{let t=e.data,n=o;n&&((t.type!==`alive`||t.work!==l)&&(c=Date.now()),t.type===`alive`?l=t.work:t.type===`plan`?(o=null,n.resolve(t.plan)):t.type===`progress`?n.on.progress?.(t.fraction):t.type===`chunk`?(u++,s=s.then(()=>n.on.chunk(t.chunk)).then(()=>{u--,c=Date.now(),i.postMessage({type:`ack`})},e=>{u--,p(e instanceof Error?e:Error(String(e)))})):t.type===`done`?s.then(()=>{o===n&&(o=null,n.resolve(t.result))}):f(Error(t.message)))},i.onerror=e=>f(e instanceof Error?e:Error(`The import worker failed.`));let g=(e,t={})=>new Promise((r,a)=>{if(n?.aborted){a(iz());return}if(d){a(Error(ce));return}o={resolve:r,reject:a,on:t},c=Date.now(),i.postMessage(e)});return{plan:()=>g({type:`plan`,importer:e,files:t}),read:(e,t,n)=>g({type:`read`,selection:e,mode:t},n),close:()=>{clearInterval(m),n?.removeEventListener(`abort`,h),i.terminate(),a!==null&&sz(()=>cz(a,r))}}}var mz=12e3,hz=(e,t)=>t.map(t=>({group:t,channels:e.groups[t].channels.map((e,t)=>t)}));function gz(e,t){let n=null;for(let r of t){let t=e.groups[r.group];!t.irregular&&(!n||t.samples>n.samples)&&(n={samples:t.samples,rate:t.rateHz})}return n?.rate??null}function _z(e,t,n,r){return{format:e.format,importer:t,startTime:e.startTime,groups:e.groups.map(e=>({name:e.name,channels:e.channels.length,samples:e.samples,rateHz:e.rateHz})),selection:n,combined:n.length>1?{groups:n.length,rateHz:gz(e,n)}:null,splitKey:r,channels:n.reduce((e,t)=>e+t.channels.length,0),notes:e.notes,meta:e.meta,events:[]}}async function vz(e,t,n,r,i,a){let o={meta:``,columnNames:n.columns.map(e=>e.name),units:n.columns.map(e=>e.unit),rows:Me(n.table)},s=new LE(o);return{id:e,name:t,kind:`memory`,source:s,schema:await s.getSchema(),data:o,file:r,companions:i,info:{...a,events:n.events}}}async function yz(e,t,n,r,i,a,o,s,c){let l=LL().then(e=>e.connect());l.catch(()=>void 0);let u=tR(),d=QR(r,i),f=new jR({insertArrowTable:async(e,t)=>(await l).insertArrowTable(e,t)},u,d);try{let r=await n.read(i,`stream`,{progress:c,chunk:e=>f.append(e)});if(await f.flush(),f.rows===0)throw Error(`${t}: the file has no samples.`);let p=await l,m=await sR.attach(p,u,new Map(d.map(e=>[e.name,e.unit]))),h=await m.getSchema(),g=await m.sampleRows(mz);return{id:e,name:t,kind:`duckdb`,source:m,schema:h,data:{meta:``,columnNames:h.map(e=>e.name),units:h.map(e=>e.unit),rows:g},file:a,companions:o,info:{...s,events:r.events}}}catch(e){let t=await l.catch(()=>null);throw await t?.query(`DROP TABLE IF EXISTS ${BL(u)}`).catch(()=>void 0),await t?.close().catch(()=>void 0),e}}async function bz(e,t){let{main:n,companions:r}=e,i=uz(e.format,{main:n,companions:r,keys:e.keys},t.signal,t.createWorker,t.find),a=[];try{t.priorInMemoryValues+n.size/8>1e8&&LL().catch(()=>void 0);let o=await i.plan(),s=t.selection??t.initial??hz(o,o.defaultGroups??o.groups.map((e,t)=>t)),c=s.reduce((e,t)=>e+t.channels.length,0);if(!t.selection&&t.chooseChannels&&(t.pickChannels||o.pick||c>2e3)){let e=await t.chooseChannels({file:n.name,format:o.format,groups:o.groups.map(e=>({name:e.name,rateHz:e.rateHz,samples:e.samples,channels:e.channels.map(e=>({name:e.name,unit:e.unit}))})),selection:s,estimate:e=>ez(o,e,n.size),budget:cR,used:t.priorInMemoryValues,notes:o.notes});if(!e)throw new kE(`cancelled`);s=e.filter(e=>e.channels.length>0)}if(s.length===0)throw Error(`${n.name}: no channels to read.`);let l=!t.split&&(s.length===1||s.every(e=>o.groups[e.group].time.kind!==`index`))?[s]:s.map(e=>[e]),u=l.length>1?crypto.randomUUID():null,d=t.priorInMemoryValues;for(let s of l){let c=ez(o,s,n.size),f=l.length>1?`${n.name} · ${o.groups[s[0].group].name}`:n.name,p=_z(o,e.format,s,u),m=crypto.randomUUID();if(uR(0,c,d)===`memory`){let e=await i.read(s,`memory`,{progress:t.onProgress});a.push(await vz(m,f,e,n,r,p)),d+=c}else a.push(await yz(m,f,i,o,s,n,r,p,t.onProgress))}return a}catch(e){for(let e of a)e.source.dispose().catch(()=>void 0);throw t.signal?.aborted?new kE(`cancelled`):e}finally{i.close()}}function xz(e){return e.filter(e=>e.type===`number`).map(e=>e.name)}function Sz(e,t,n=5e5){let r=1/0,i=-1/0,a=Math.max(1,Math.ceil(e.length/n));for(let n=0;n<e.length;n+=a){let a=e[n][t];typeof a==`number`&&(a<r&&(r=a),a>i&&(i=a))}if(!Number.isFinite(r)||!Number.isFinite(i))return{min:0,max:1};if(r===i){let e=Math.abs(r)*.05||1;return{min:r-e,max:i+e}}let o=(i-r)*.04;return{min:r-o,max:i+o}}function Cz(e){switch(e.kind){case`multiband`:return e.series.length;case`parallelcoords`:return e.pcColumns.length;case`barchart`:return e.bcValueCols.length;case`radar`:return e.rdAxesCols.length;case`areachart`:return e.acYCols.length;case`cdfchart`:return e.cdValueCols.length;case`losscurve`:return e.lcLeftCols.length+e.lcRightCols.length;case`gauge`:return e.ggGauges.length;case`camera`:return 0;case`heatmap`:return e.hmColumns.length;case`xyzmesh`:return e.xyzColumns?.length??0;default:return 0}}function wz(e,t=6){if(!Number.isFinite(e)||e<=0)return 1;let n=e/t,r=10**Math.floor(Math.log10(n)),i=n/r,a=1;return a=i<=1?1:i<=2?2:i<=5?5:10,a*r}function Tz(e){return Math.max(2,Math.min(6,Math.floor(e/64)))}function Ez(e,t,n,r){let i=Math.max(e,t)-Math.min(e,t),a=n!==void 0&&n>0&&Number.isFinite(n)?n:wz(i,6);(a<=0||!Number.isFinite(a))&&(a=wz(Math.max(i,1),6));let o=r!==void 0&&r>0&&Number.isFinite(r)?r:a/5;return(o<=0||!Number.isFinite(o))&&(o=a/5),{majorStep:a,minorStep:o}}function Dz(e,t,n){let r=Math.min(e,t),i=Math.max(e,t);if(n<=0||!Number.isFinite(n))return[];let a=[],o=Math.ceil(r/n-1e-12)*n,s=0;for(;o<=i+n*1e-9&&s++<1e4;)a.push(o),o+=n;return a}function Oz(e,t,n,r){let i=Math.min(e,t),a=Math.max(e,t);if(n<=0||!Number.isFinite(n))return[];let o=e=>r.some(t=>Math.abs(e-t)<=(Math.abs(t)+1)*1e-9+1e-9),s=[],c=Math.ceil(i/n-1e-12)*n,l=0;for(;c<=a+n*1e-9&&l++<2e4;)o(c)||s.push(c),c+=n;return s}var kz={[-12]:`p`,[-9]:`n`,[-6]:`µ`,[-3]:`m`,0:``,3:`k`,6:`M`,9:`G`,12:`T`};function Az(e){if(!(e>0)||!Number.isFinite(e))return 0;let t=Math.max(0,-Math.floor(Math.log10(e)+1e-9));for(let n=t;n<=t+2;n++){let t=e*10**n;if(Math.abs(t-Math.round(t))<=1e-6*t)return n}return t+1}function jz(e,t){if(!Number.isFinite(e))return`—`;if(!(t>0)||!Number.isFinite(t))return Mz(e);if(Math.abs(e)<t*1e-6)return`0`;let n=Math.floor(Math.log10(t)+1e-9);if(n>=3||n<-3){let r=3*Math.ceil((n-1)/3);if(r<-12||r>12)return e.toExponential(2);let i=e/10**r;if(r>0||Math.abs(i)<1e3)return i.toFixed(Az(t/10**r))+kz[r]}return e.toFixed(Az(t))}function Mz(e){if(!Number.isFinite(e))return`—`;if(e===0)return`0`;let t=Math.abs(e);if(t<1e-12||t>=0x38d7ea4c68000)return e.toExponential(3);let n=0;(t<.001||t>=1e6)&&(n=3*Math.floor(Math.log10(t)/3));let r=e/10**n,i=Math.max(0,3-Math.floor(Math.log10(Math.abs(r))));return n!==0&&Math.abs(+r.toFixed(i))>=1e3&&(n+=3,r/=1e3,i=3),r.toFixed(i)+kz[n]}var Nz=946684800,Pz=4102444800;function Fz(e,t,n){return/\(([^)]*)\)\s*$/.exec(e)?.[1].trim()===`s`&&n>t&&t>=Nz&&n<=Pz}var Iz=new Map;function Lz(e){let t=Iz.get(e);if(!t){let n={day:`numeric`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`};try{t=new Intl.DateTimeFormat(`en-GB`,{...n,timeZone:e})}catch{t=Lz(void 0)}Iz.set(e,t)}return t}var Rz=new Map,zz=(e,t)=>{let n=Math.round(e*1e3),r=Math.floor(n/1e3),i=`${t??``}|${r}`,a=Rz.get(i);if(!a){let e={};for(let{type:n,value:i}of Lz(t).formatToParts(r*1e3))e[n]=i;let n=`${e.hour}:${e.minute}`;a={date:`${e.day} ${e.month}`,year:e.year,hm:n,hms:`${n}:${e.second}`},Rz.size>=1024&&Rz.clear(),Rz.set(i,a)}return{...a,ms:String(n-r*1e3).padStart(3,`0`)}},Bz,Vz=new Set;function Hz(e){if(e!==void 0)try{new Intl.DateTimeFormat(void 0,{timeZone:e})}catch{e=void 0}if(e!==Bz){Bz=e;for(let e of Vz)e()}}var Uz=()=>Bz;function Wz(e){return Vz.add(e),()=>{Vz.delete(e)}}function Gz(e,t,n,r=Bz){let i=zz(e,r);return t>=86400?i.date:n>86400?`${i.date} ${i.hm}`:t>=60?i.hm:t>=1?i.hms:`${i.hms}.${i.ms}`}function Kz(e,t=Bz){let n=zz(e,t);return`${n.date} ${n.year} ${n.hms}.${n.ms}`}var qz=[`#fb923c`,`#60a5fa`,`#4ade80`,`#f87171`,`#facc15`,`#22d3ee`,`#f472b6`,`#2dd4bf`,`#94a3b8`,`#a3e635`];function Jz(e,t,n,r=qz){let i=r.length>0?r:qz;return e[t]??i[n%i.length]}function Yz(e){return[e===`light`?`#000000`:`#ffffff`,...qz.slice(0,9)]}function Xz(e,t=`dark`){let n=(e??[]).filter(e=>typeof e==`string`&&/^#[0-9a-f]{3}([0-9a-f]{3})?$/i.test(e));return n.length>0?n:Yz(t)}var Zz=[`class`,`data-theme`,`data-color-scheme`];function Qz(e){return e?.closest(`[data-color-scheme]`)??document.documentElement}function $z(e){return Qz(e).getAttribute(`data-color-scheme`)===`light`?`light`:`dark`}function eB(e,t){let n=new MutationObserver(t),r=new Set([document.documentElement,Qz(e)]);for(let e of r)n.observe(e,{attributes:!0,attributeFilter:Zz});return()=>n.disconnect()}function tB(e,t){return!!t&&e.composedPath().includes(t)}var nB=[`min`,`max`,`mean`,`integral`,`first`,`last`,`delta`],rB=e=>`${e.channel}:${e.stat}`,iB=e=>`channel`in e?[e.channel]:[];function aB(e,t,n){switch(e){case`>`:return t>n;case`>=`:return t>=n;case`<`:return t<n;case`<=`:return t<=n;case`==`:return t===n;default:return t!==n}}function oB(e,t,n,r){switch(e){case`>`:case`>=`:return t<n-r;case`<`:case`<=`:return t>n+r;case`==`:return t!==n;default:return t===n}}var sB=()=>({prev:NaN,lo:0,hi:0});function cB(e,t){if(e.prev!==e.prev)return e.prev=e.lo=e.hi=t,!1;let n=t<e.prev&&e.prev-t>(e.hi-e.lo)/2;return n?e.lo=e.hi=t:(t<e.lo&&(e.lo=t),t>e.hi&&(e.hi=t)),e.prev=t,n}var lB=new Map,uB=e=>{let t=lB.get(e);return t||(t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),lB.set(e,t)),t};function dB(e,t){let n={};for(let r of uB(t).formatToParts(new Date(Math.floor(e)*1e3)))n[r.type]=r.value;return(Date.UTC(+n.year,n.month-1,+n.day,+n.hour,+n.minute,+n.second)-Math.floor(e)*1e3)/1e3}function fB(e,t){let n=e+dB(e,t);return new Date(Math.floor(n)*1e3).toISOString().slice(0,10)}function pB(e,t,n){let[r,i,a]=e.split(`-`).map(Number),[o,s]=t.split(`:`).map(Number),c=Date.UTC(r,i-1,a,o,s)/1e3;return c-dB(c-dB(c,n),n)}var mB=(e,t)=>{let[n,r,i]=e.split(`-`).map(Number);return new Date(Date.UTC(n,r-1,i+t)).toISOString().slice(0,10)},hB=class{n=0;sum=0;min=1/0;max=-1/0;first=NaN;last=NaN;integral=0;lastT=NaN;add(e,t){t===t&&(this.n>0?this.integral+=(t+this.last)/2*(e-this.lastT):this.first=t,this.n++,this.sum+=t,t<this.min&&(this.min=t),t>this.max&&(this.max=t),this.last=t,this.lastT=e)}value(e){if(this.n===0)return null;switch(e){case`min`:return this.min;case`max`:return this.max;case`mean`:return this.sum/this.n;case`integral`:return this.integral;case`first`:return this.first;case`last`:return this.last;default:return this.last-this.first}}},gB=class{rule;kpis;#e;#t=null;#n=NaN;#r=sB();#i=!1;#a=NaN;#o=NaN;#s=NaN;#c=new Map;constructor(e,t=[]){this.rule=e,this.kpis=t,this.#e=[...new Set(t.map(e=>e.channel))]}#l(e){this.#t={tstart:e,acc:new Map(this.#e.map(e=>[e,new hB]))}}#u(e,t,n){let r={duration:(t??n)-e.tstart};for(let t of this.kpis)r[rB(t)]=e.acc.get(t.channel).value(t.stat);return{tstart:e.tstart,tend:t,kpis:r}}#d(e){let t=this.#t;return this.#t=null,t?this.#u(t,e,e):null}assumeOpen(e){this.#t||(this.#l(e),this.rule.kind===`condition`&&(this.#i=!0))}#f(e){let t=this.#c.get(e);if(!t){let n=this.rule;t=n.starts.map(t=>pB(e,t,n.tz)).sort((e,t)=>e-t),this.#c.set(e,t)}return t}#p(e){let t=this.rule.tz,n=fB(e,t),r=-1/0;for(let t of this.#f(n))t<=e&&(r=t);if(r>-1/0)return r;let i=this.#f(mB(n,-1));return i[i.length-1]}#m(e){let t=this.rule.tz,n=fB(e,t);for(let t of this.#f(n))if(t>e)return t;return this.#f(mB(n,1))[0]}feed(e,t,n){let r=[],i=this.rule,a=i.kind===`edge`||i.kind===`condition`?t(i.channel):void 0,o=this.#e.map(e=>[e,t(e)]);for(let t=0;t<e.length;t++){let s=e[t];if(i.kind===`window`){if(!(s>=this.#a&&s<this.#o)){let e=this.#p(s);if(this.#t){let t=this.#d(this.#o<=e?this.#o:e);t&&r.push(t)}this.#a=e,this.#o=this.#m(e),this.#l(e)}}else if(a&&i.kind!==`manual`){let e=a[t];if(e===e){if(i.kind===`edge`){let t=!1;if(i.on===`reset`){let n=this.#r.prev!==this.#r.prev;t=cB(this.#r,e),n&&!this.#t&&this.#l(s)}else if(this.#n===this.#n){let n=i.value??0;t=i.on===`change`?e!==this.#n:i.on===`rise`?this.#n<n&&e>=n:this.#n>n&&e<=n}if(this.#n=e,t){let e=this.#d(s);e&&r.push(e),this.#l(s)}}else if(!this.#i)aB(i.op,e,i.value)&&(this.#i=!0,this.#l(s));else if(oB(i.op,e,i.value,i.hysteresis??0)){this.#i=!1;let e=this.#d(s);e&&s-e.tstart>=(i.min_s??0)&&r.push(e)}}}let c=this.#t;if(c)for(let[e,n]of o)n&&c.acc.get(e).add(s,n[t]);this.#s=s,n?.(t,c?c.tstart:null)}return r}open(){let e=this.#t;return!e||this.rule.kind===`condition`&&this.#s-e.tstart<(this.rule.min_s??0)?null:this.#u(e,null,this.#s)}},_B=[{value:`span`,label:`Span (max − min)`},{value:`mean`,label:`Mean`},{value:`max`,label:`Max`},{value:`min`,label:`Min`}];function vB(e,t){let n=[],r=sB(),i=-1;for(let a=0;a<e.length;a++){let o=e[a][t];if(typeof o!=`number`)continue;let s=cB(r,o);i<0?i=0:s&&(n.push({start:i,end:a}),i=a)}return i>=0&&n.push({start:i,end:e.length}),n}function yB(e,t){let n=[],r=e.length-1,i=Math.max(1,Math.floor(e.length/256)),a=t=>{let n=0,r=0,a=0;for(let o=0;o+1<e.length;o+=i){let i=e[o][t],s=e[o+1][t];typeof i!=`number`||typeof s!=`number`||(n++,s<i?r++:s===i&&a++)}return n<32||r<=.3*n&&a<=.9*n};for(let o of t){if(i>1&&!a(o))continue;let t=0,s=0,c=0,l=null,u=!1;for(let n of e){let e=n[o];if(typeof e==`number`){if(l!==null&&(c++,e>l?t++:e===l&&s++,c-t-s>.1*r||s>.5*r)){u=!0;break}l=e}}if(u||c===0||(t+s)/c<.9||t/c<.5)continue;let d=vB(e,o).length;d>1&&n.push({col:o,laps:d})}return n.sort((e,t)=>t.laps-e.laps).map(e=>e.col)}function bB(e,t){return yB(e,t)[0]??t[0]??``}function xB(e,t,n){if(n&&t.includes(n.channel)&&vB(e,n.channel).length>1)return{...n,metric:t.includes(n.metric)?n.metric:n.channel};let r=yB(e,t);if(r.length===0)return null;let i=r.find(e=>/time/i.test(e));return{channel:r[0],metric:i??r[0],stat:`span`}}function SB(e,t,n,r){let i=0,a=0,o=1/0,s=-1/0;for(let r=t.start;r<t.end;r++){let t=e[r][n];typeof t==`number`&&(i++,a+=t,t<o&&(o=t),t>s&&(s=t))}return i===0?null:r===`mean`?a/i:r===`max`?s:r===`min`?o:s-o}function CB(e){let t=e.filter(e=>e!==null);if(t.length===0)return null;let n=[...t].sort((e,t)=>e-t)[Math.floor(t.length/2)],r=t.filter(e=>e>=n*.8),i=Math.min(...r.length>1?r:t);return e.indexOf(i)}function wB(e,t){return t.trim()===`s`||/time/i.test(e)}function TB(e,t,n){if(e===null)return`—`;if(n&&e>=0){let t=Math.round(e*1e3),n=Math.floor(t/6e4);return`${n}:${((t-n*6e4)/1e3).toFixed(3).padStart(6,`0`)}`}let r=Math.abs(e),i=r!==0&&r<.01?Mz(e):e.toFixed(r>=1e3?0:r>=100?1:3);return t.trim()?`${i} ${t.trim()}`:i}function EB(e,t){return`${e}::lap${t}`}function DB(e){let t=new Map,n=n=>{let r=t.get(n);return r||t.set(n,r=e.at.map(t=>pB(n,t,e.tz)).sort((e,t)=>e-t)),r},r=t=>{let r=fB(t,e.tz),i=-1/0;for(let e of n(r))e<=t&&(i=e);if(i>-1/0)return i;let a=n(mB(r,-1));return a[a.length-1]},i=t=>{let r=fB(t,e.tz);for(let e of n(r))if(e>t)return e;return n(mB(r,1))[0]},a=NaN,o=NaN,s={on:!1,edge:!1,at:NaN,event:!0,step(e){if(s.edge=s.on=!(e.t>=a&&e.t<o),!s.edge)return;let t=r(e.t);s.closeAt=o<=t?o:t,s.at=a=t,o=i(t)}};return s}function OB(e){switch(e.kind){case`compare`:{let t={on:!1,edge:!1,at:NaN,event:!1,step(n){let r=n.v(e.channel);r===r&&(t.on=aB(e.op,r,e.value)),t.at=n.t}};return t}case`elapsed`:{let t={on:!1,edge:!1,at:NaN,event:!1,step(n){let r=n.t-(e.from===`start`?n.start:n.ps);t.on=r===r&&(e.op===`>=`?r>=e.seconds:r<=e.seconds),t.at=n.t}};return t}case`change`:case`cross`:{let t=NaN,n={on:!1,edge:!1,at:NaN,event:!0,step(r){let i=r.v(e.channel);n.edge=!1,i===i&&(t===t&&(n.edge=e.kind===`change`?i!==t:e.dir===`rise`?t<e.value&&i>=e.value:t>e.value&&i<=e.value),t=i),n.on=n.edge,n.at=r.t}};return n}case`reset`:{let t=sB(),n={on:!1,edge:!1,at:NaN,event:!0,step(r){let i=r.v(e.channel);n.edge=i===i&&(t.prev===t.prev?cB(t,i):(cB(t,i),!0)),n.on=n.edge,n.at=r.t}};return n}case`clock`:return DB(e);case`parent-start`:{let e=!1,t={on:!1,edge:!1,at:NaN,event:!0,step(n){t.on=t.edge=!e,e=!0,t.at=n.ps}};return t}case`all`:case`any`:{let t=e.of.map(OB),n={on:!1,edge:!1,at:NaN,event:t.some(e=>e.event),step(r){for(let e of t)e.step(r);n.on=e.kind===`all`?t.every(e=>e.on):t.some(e=>e.on),n.edge=n.on&&t.some(e=>e.edge),n.at=r.t}};return n}default:return{on:!1,edge:!1,at:NaN,event:!0,step(){}}}}var kB=(e,t)=>e.kind===t||(e.kind===`all`||e.kind===`any`)&&e.of.some(e=>kB(e,t));function AB(e){let t=new Set,n=e=>{`channel`in e&&t.add(e.channel),(e.kind===`all`||e.kind===`any`)&&e.of.forEach(n)};return n(e.start),n(e.end),[...t]}var jB=class{rule;#e;#t;#n=NaN;#r=!1;#i=NaN;#a=NaN;#o=NaN;#s=NaN;#c;#l;constructor(e){this.rule=e,this.#c=kB(e.end,`parent-end`),this.#l=e.end.kind===`next-start`,this.#u()}#u(){this.#e=OB(this.rule.start),this.#t=OB(this.rule.end),this.#r=!1}#d(e,t,n){let r=this.rule.limits;if(!r)return[];let i=[],a=r.from===`start`?e:this.#n;return r.expectedWithin_s!=null&&t-a>r.expectedWithin_s&&i.push(`late`),r.max_s!=null&&t-e>r.max_s&&i.push(`too-long`),n&&r.min_s!=null&&t-e<r.min_s&&i.push(`too-short`),i}#f(e,t,n=!1){let r={tstart:this.#i,tend:e,flags:this.#d(this.#i,e,!0)};n&&(r.incomplete=!0),t.push(r),this.#i=this.#o=NaN}parentStart(e){this.#n=e,this.#i=this.#a=this.#o=NaN,this.#u()}parentEnd(e,t){this.#i===this.#i&&this.#f(e,t,!this.#c),this.#a=NaN,this.#n=NaN}step(e,t,n){this.#n!==this.#n&&(this.#n=e);let r={t:e,v:t,ps:this.#n,start:this.#i},i=this.#e,a=this.#t;i.step(r),a.step(r);let o=i.on&&(!this.#r||i.edge);this.#r=i.on;let s=i.event&&!(this.rule.start.kind===`all`||this.rule.start.kind===`any`)?i.at:e;if(this.#i===this.#i&&!this.#l&&e>this.#i){let t=this.rule.ignoreDips_s??0;a.on?t>0&&!a.event?(this.#o!==this.#o&&(this.#o=e),e-this.#o>=t&&this.#f(this.#o,n)):this.#f(e,n):this.#o=NaN}let c=e=>{this.#i===this.#i&&this.#f(this.#l&&i.closeAt!==void 0?i.closeAt:e,n),this.#i=e},l=this.#i!==this.#i||this.#l,u=this.rule.minHold_s??0;this.#a===this.#a?i.on?e-this.#a>=u&&(l&&c(this.#a),this.#a=NaN):this.#a=NaN:o&&l&&(u>0&&!i.event?this.#a=s:c(s)),this.#s=e}open(){return this.#i===this.#i?{tstart:this.#i,tend:null,flags:this.#d(this.#i,this.#s,!1)}:null}},MB=class{#e;constructor(e){let t=[],n=r=>{for(let i of e)i.parentId===r&&(t.push(i),n(i.id))};n(null),this.#e=t.map(e=>({...e,runner:new jB(e.rule),count:0,current:0,kids:[]})),this.#e.forEach((e,t)=>{e.parentId&&this.#e.find(t=>t.id===e.parentId).kids.push(t)})}#t(e,t,n,r){let i=this.#e[e];for(let e of t)n.push({...e,definitionId:i.id,index:i.current,...r?{parentIndex:r}:{}})}#n(e){let t=this.#e[e].parentId;return t?this.#e.find(e=>e.id===t).current:void 0}#r(e,t,n){for(let r of this.#e[e].kids){this.#r(r,t,n);let i=[];this.#e[r].runner.parentEnd(t,i),this.#t(r,i,n,this.#e[e].current)}}#i(e,t,n,r){let i=this.#e[e],a=i.runner.open()?.tstart,o=[];i.runner.step(t,n,o);let s=i.runner.open()?.tstart;if(o.length)for(let t of o)this.#r(e,t.tend,r),r.push({...t,definitionId:i.id,index:i.current,...this.#n(e)?{parentIndex:this.#n(e)}:{}});if(s!==void 0&&s!==a){i.current=++i.count;for(let e of i.kids)this.#e[e].current=this.#e[e].count=0,this.#e[e].runner.parentStart(s)}if(s!==void 0)for(let e of i.kids)this.#i(e,t,n,r)}feed(e,t){let n=new Map,r=e=>(n.has(e)||n.set(e,t(e)),n.get(e)),i=[],a=0,o=e=>{let t=r(e);return t?t[a]:NaN};for(;a<e.length;a++)for(let t=0;t<this.#e.length;t++)this.#e[t].parentId||this.#i(t,e[a],o,i);return i}open(){let e=[];return this.#e.forEach((t,n)=>{let r=t.runner.open(),i=this.#n(n);r&&(!t.parentId||this.#e.find(e=>e.id===t.parentId).runner.open())&&e.push({...r,definitionId:t.id,index:t.current,...i?{parentIndex:i}:{}})}),e}},NB=new Set([`>`,`>=`,`<`,`<=`,`==`,`!=`]),PB=e=>typeof e==`number`&&Number.isFinite(e),FB=e=>typeof e==`string`&&e.length>0;function IB(e,t){let n=e;if(!n||typeof n!=`object`)return!1;switch(n.kind){case`parent-start`:case`parent-end`:case`next-start`:case`manual`:return!0;case`all`:case`any`:return t<3&&Array.isArray(n.of)&&n.of.length>0&&n.of.every(e=>IB(e,t+1));case`compare`:return FB(n.channel)&&NB.has(n.op)&&PB(n.value);case`change`:case`reset`:return FB(n.channel);case`cross`:return FB(n.channel)&&(n.dir===`rise`||n.dir===`fall`)&&PB(n.value);case`elapsed`:return(n.from===`parent-start`||n.from===`start`)&&(n.op===`>=`||n.op===`<=`)&&PB(n.seconds);case`clock`:return Array.isArray(n.at)&&n.at.length>0&&n.at.every(e=>typeof e==`string`&&/^\d\d:\d\d$/.test(e))&&FB(n.tz);default:return!1}}function LB(e){if(!Array.isArray(e))return[];let t=e.filter(e=>{let t=e?.rule,n=t?.limits;return FB(e?.id)&&FB(e?.name)&&(e.parentId===null||FB(e.parentId))&&!!t&&IB(t.start,1)&&IB(t.end,1)&&(t.minHold_s===void 0||PB(t.minHold_s))&&(t.ignoreDips_s===void 0||PB(t.ignoreDips_s))&&(n===void 0||typeof n==`object`&&[`expectedWithin_s`,`min_s`,`max_s`].every(e=>n[e]===void 0||PB(n[e])))}),n=new Set(t.map(e=>e.id));return t.filter(e=>e.parentId===null||n.has(e.parentId)).map(e=>{let t=Array.isArray(e.kpis)?e.kpis.filter(e=>FB(e?.channel)&&nB.includes(e.stat)).slice(0,50):[],n=FB(e.show?.channel)&&nB.includes(e.show.stat)?{channel:e.show.channel,stat:e.show.stat}:void 0;return{id:e.id,name:e.name,parentId:e.parentId,rule:e.rule,...t.length?{kpis:t}:{},...n?{show:n}:{}}})}var RB=`Cycle time`,zB=65536;async function BB(e,t,n){let r=[...new Set([t,...n])],i=[];for(let n=0;;n+=zB){let a=await e.readColumns(r,n,zB),o=a[t]?.length??0;if(o>0&&i.push(a),o<zB)break}let a=e=>{if(!i.some(t=>t[e]))return;let n=new Float64Array(i.reduce((e,n)=>e+n[t].length,0)).fill(NaN),r=0;for(let a of i)a[e]&&n.set(a[e],r),r+=a[t].length;return n},o=new Map;for(let e of r){let n=e===t?void 0:a(e);n&&o.set(e,n)}return{t:a(t)??new Float64Array,cols:o}}function VB(e,t){let n=new MB(t);return[...n.feed(e.t,t=>e.cols.get(t)),...n.open()]}var HB=e=>[...new Set(e.flatMap(e=>[...AB(e.rule),...(e.kpis??[]).map(e=>e.channel)]))],UB=e=>`${e.channel} ${e.stat}`;function WB(e,t,n){let r=GB(e.t,t.tstart),i=t.tend===null?e.t.length:GB(e.t,t.tend),a={};for(let t of n){let n=e.cols.get(t.channel),o=new hB;if(n)for(let t=r;t<i;t++)o.add(e.t[t],n[t]);a[UB(t)]=o.value(t.stat)}return a}function GB(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n}function KB(e,t,n){let r=GB(e.t,n.tstart),i=n.tend===null?e.t.length:GB(e.t,n.tend),a=e.t.subarray(r,i),o={[RB]:a.map(e=>e-n.tstart),[t]:a};for(let[t,n]of e.cols)o[t]=n.subarray(r,i);return o}var qB=e=>e.replace(`-`,` `);function JB(e,t,n,r){let i=Object.fromEntries(n.map(e=>[e.id,e.name])),a=e=>n.find(t=>t.id===e)?.kpis??[],o=e=>r?WB(r,e,a(e.definitionId)):{},s=n.filter(e=>e.parentId===t).map(e=>e.id),c=e=>e.tend===null?null:e.tend-e.tstart,l=e.filter(e=>s.includes(e.definitionId)).sort((e,t)=>e.tstart-t.tstart);return{cycles:e.filter(e=>e.definitionId===t).sort((e,t)=>e.index-t.index).map(e=>{let t=l.filter(t=>t.parentIndex===e.index),n={Cycle:e.index,Start:e.tstart,End:e.tend,Duration:c(e)};for(let e of s){let r=t.filter(t=>t.definitionId===e);n[`${i[e]??e} duration`]=r.length&&r.every(e=>e.tend!==null)?r.reduce((e,t)=>e+t.tend-t.tstart,0):null}return Object.assign(n,o(e)),n.Flags=[...e.flags.map(qB),...t.flatMap(e=>e.flags.map(t=>`${i[e.definitionId]??e.definitionId} ${qB(t)}`))].join(`, `),n}),phases:l.map(e=>({Cycle:e.parentIndex,Phase:i[e.definitionId]??e.definitionId,Start:e.tstart,End:e.tend,Duration:c(e),...o(e),Flags:e.flags.map(qB).join(`, `)}))}}function YB(e){if(e.length===0)return``;let t=Object.keys(e[0]),n=e=>e===null?``:typeof e==`number`?String(e):/[",\n]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e;return[t.map(n).join(`,`),...e.map(e=>t.map(t=>n(e[t]??null)).join(`,`))].join(`
|
|
71
71
|
`)}var XB=(e,t,n)=>`kymoscope-workbook-export|3|${e}|${t??``}|${n??``}`,ZB=e=>new TextEncoder().encode(e);async function QB(e,t){return{format:`kymoscope-workbook`,v:2,...await oe(t,ZB(JSON.stringify(e)),C)}}async function $B(e,t){let n=t.password?JSON.stringify(await QB(e,t.password)):JSON.stringify(e),r=await Se(await z(t.key),ZB(n),XB(t.scope,t.scopeId,t.password?`password`:void 0));return{format:`kymoscope-workbook`,v:3,scope:t.scope,scope_id:t.scopeId,alg:`AES-256-GCM`,...r,...t.password?{inner:`password`}:{}}}function eV(e){return!!e&&typeof e==`object`&&e.format===`kymoscope-workbook`}function tV(e){return eV(e)?e.v===2?{v:2,scope:null,scopeId:null,password:!0}:e.v!==3||e.alg!==`AES-256-GCM`||typeof e.iv!=`string`||typeof e.ct!=`string`||![`user`,`org`,`any`].includes(e.scope)||e.scope===`any`!=(e.scope_id===null)||e.scope_id!==null&&typeof e.scope_id!=`string`||e.inner!==void 0&&e.inner!==`password`?null:{v:3,scope:e.scope,scopeId:e.scope_id,password:e.inner===`password`}:null}var nV=e=>{try{return JSON.parse(new TextDecoder().decode(e))}catch{throw new kE(`bad_file`)}};async function rV(e,t){let n=tV(e);if(!n)throw new kE(`bad_file`);let r=e;if(n.v===3){let i=e;if(!t.key)throw new kE(`scope_key_required`,{scope:n.scope,scopeId:n.scopeId});let a;try{a=await Re(await z(t.key),i,XB(i.scope,i.scope_id,i.inner))}catch{throw new kE(`bad_file`)}if(r=nV(a),!n.password)return r;if(r?.v!==2||!eV(r))throw new kE(`bad_file`)}if(!t.password)throw new kE(`password_required`);let i;try{i=await v(t.password,r,C)}catch{throw new kE(`wrong_password`)}return nV(i)}var iV=new Set(Object.keys(Ut));function aV(e){return Array.isArray(e)?e.flatMap(e=>{if(!e||typeof e!=`object`)return[];let{id:t,kind:n,rect:r}=e;return typeof t!=`string`||!iV.has(n)||!r||![r.x,r.y,r.w,r.h].every(e=>typeof e==`number`&&Number.isFinite(e))?[]:[{...e,rect:Kt(n,r,96)}]}):[]}var oV=e=>({name:e.name,xKey:e.xKey,panels:e.panels,panelChartSettings:e.panelChartSettings,panelChartBackgrounds:e.panelChartBackgrounds,...e.liveWindowSeconds===void 0?{}:{liveWindowSeconds:e.liveWindowSeconds}});function sV(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.beacon;return[e,n?.datasetId?{...t,beacon:{...n,datasetId:null}}:t]}))}function cV(e){return{version:2,worksheets:e.worksheets.map(e=>({...oV(e),panelChartSettings:sV(e.panelChartSettings)})),activeWorksheet:Math.max(0,e.worksheets.findIndex(t=>t.id===e.activeWorksheetId)),mathChannels:e.channels.map(e=>({name:e.name,formula:e.formula,units:e.units,enabled:e.enabled,...e.description?{description:e.description}:{}})),liveWindowSeconds:e.liveWindowSeconds,laps:e.laps?{channel:e.laps.channel,metric:e.laps.metric,stat:e.laps.stat}:null,segments:e.segments??null,...e.cycles?.length?{cycles:e.cycles}:{}}}function lV(e){return{version:1,kind:`worksheet`,exportedAt:new Date().toISOString(),worksheet:{name:e.name,xKey:e.xKey,panels:e.panels,panelChartSettings:e.panelChartSettings,panelChartBackgrounds:e.panelChartBackgrounds,...e.liveWindowSeconds===void 0?{}:{liveWindowSeconds:e.liveWindowSeconds}}}}function uV(e,t,n){let r={kind:e.kind,settings:t,background:n},i=e.title?.trim();return i&&(r.title=i),{version:1,kind:`chart`,exportedAt:new Date().toISOString(),chart:r}}function dV(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(r.error),r.readAsText(e)})}async function fV(e){let t=await dV(e),n;try{n=JSON.parse(t)}catch{return{worksheets:[],errors:[`Not a valid JSON file.`]}}return vV(n)}var pV=new Set(_B.map(e=>e.value)),mV=/^(#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?)\([0-9.,%\s/deg+-]+\)|[a-z]{3,24})$/i;function hV(e){return typeof e!=`string`||e.length>64||/[;{}<>\\]|\b(?:var|env|attr|url)\(/i.test(e)?!1:typeof CSS<`u`&&typeof CSS.supports==`function`?CSS.supports(`color`,e):mV.test(e.trim())}function gV(e){if(Array.isArray(e))return e.map(gV);if(!e||typeof e!=`object`)return e??{};let t={};for(let[n,r]of Object.entries(e))/colou?r$/i.test(n)&&typeof r==`string`&&!hV(r)||(t[n]=r&&typeof r==`object`?gV(r):r);return t}function _V(e){return!e||typeof e!=`object`?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===null||hV(e)))}function vV(e){let t=e,n=t&&typeof t==`object`?t.version:void 0;if(!t||n!==1&&n!==2||!Array.isArray(t.worksheets))return{worksheets:[],errors:[`Unrecognized format. Is this a Kymoscope workbook file?`],activeIndex:0,mathChannels:[],liveWindowSeconds:void 0,laps:void 0,segments:void 0,cycles:[]};let r=[],i=[];if(t.worksheets.forEach((e,t)=>{let n=e;if(typeof n?.name!=`string`||typeof n.xKey!=`string`){i.push(`Worksheet #${t+1} skipped: missing name or xKey.`);return}r.push({id:crypto.randomUUID(),name:n.name,xKey:n.xKey,panels:aV(n.panels),panelChartSettings:gV(n.panelChartSettings),panelChartBackgrounds:_V(n.panelChartBackgrounds),...ar(n.liveWindowSeconds)})}),n===1)return{worksheets:r,errors:i,activeIndex:0,mathChannels:[],liveWindowSeconds:void 0,laps:void 0,segments:void 0,cycles:[]};let a=(Array.isArray(t.mathChannels)?t.mathChannels:[]).flatMap(e=>{let t=e;return typeof t?.name!=`string`||!t.name.trim()||typeof t.formula!=`string`?[]:[{name:t.name,formula:t.formula,units:typeof t.units==`string`?t.units:``,enabled:t.enabled!==!1,...typeof t.description==`string`&&t.description?{description:t.description}:{}}]}),o=t.liveWindowSeconds,s=t.laps,c=s&&typeof s.channel==`string`&&typeof s.metric==`string`&&pV.has(s.stat)?{channel:s.channel,metric:s.metric,stat:s.stat}:null,l=t.segments,u=e=>typeof e==`string`&&/^[0-9a-f-]{36}$/i.test(e),d=l===void 0?void 0:l&&u(l.historyId)&&(l.definitionId==null||u(l.definitionId))&&(l.referenceId==null||u(l.referenceId))?{historyId:l.historyId,definitionId:l.definitionId??null,referenceId:l.referenceId??null}:null,f=typeof t.activeWorksheet==`number`&&Number.isInteger(t.activeWorksheet)?t.activeWorksheet:0;return{worksheets:r,errors:i,mathChannels:a,laps:c,segments:d,cycles:LB(t.cycles),activeIndex:Math.min(Math.max(0,f),Math.max(0,r.length-1)),liveWindowSeconds:o===null||typeof o==`number`&&o>0?o:void 0}}function yV(e){return e.some(e=>e.panels.length>0)}function bV(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.name!=`string`||typeof t.xKey!=`string`?null:{id:crypto.randomUUID(),name:t.name,xKey:t.xKey,panels:aV(t.panels),panelChartSettings:gV(t.panelChartSettings),panelChartBackgrounds:_V(t.panelChartBackgrounds),...ar(t.liveWindowSeconds)}}function xV(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(typeof n!=`string`||!iV.has(n))return null;let r=rr({__chart:t.settings},``,1).__chart;if(!r||r.kind!==n)return null;let i={kind:n,settings:r,background:t.background===null||typeof t.background==`string`&&/^#[0-9a-fA-F]{6}$/.test(t.background)?t.background:null};return typeof t.title==`string`&&t.title.trim()&&(i.title=t.title),i}async function SV(e){let t=await dV(e),n;try{n=JSON.parse(t)}catch{return{type:`error`,errors:[`Not a valid JSON file.`]}}if(!n||typeof n!=`object`)return{type:`error`,errors:[`Unrecognized file.`]};if(n.format===`kymoscope-workbook`){let e=tV(n);return e?{type:`encrypted`,...e}:{type:`error`,errors:[`This file is from a newer version of Kymoscope.`]}}let r=n.kind;if(r===`worksheet`){let e=bV(n.worksheet);return e?{type:`worksheet`,worksheet:e}:{type:`error`,errors:[`Worksheet file is missing a name or X key.`]}}if(r===`chart`){let e=xV(n.chart);return e?{type:`chart`,chart:e}:{type:`error`,errors:[`Chart file is malformed or its settings do not match its type.`]}}let i=await fV(e);return i.worksheets.length===0&&i.errors.length>0?{type:`error`,errors:i.errors}:{type:`workspace`,worksheets:i.worksheets,errors:i.errors}}var CV=OR;function wV(e){let t=e.toLowerCase();return!t.startsWith(`.`)&&CV.some(e=>t.endsWith(e))}function TV(e,t=``){let n={name:t,path:``,dirs:[],files:[],allPaths:[]};for(let t of e){if(!wV(t.file.name))continue;let e=t.path.split(`/`).filter(Boolean),r=n;for(let t of e.slice(0,-1)){let e=r.path?`${r.path}/${t}`:t,n=r.dirs.find(e=>e.name===t);n||(n={name:t,path:e,dirs:[],files:[],allPaths:[]},r.dirs.push(n)),r=n}r.files.push(t)}let r=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}).compare,i=e=>(e.dirs.sort((e,t)=>r(e.name,t.name)),e.files.sort((e,t)=>r(e.file.name,t.file.name)),e.allPaths=[...e.dirs.flatMap(i),...e.files.map(e=>e.path)],e.allPaths);return i(n),!n.files.length&&n.dirs.length===1?n.dirs[0]:n}function EV(e){return e.map(e=>({path:e.webkitRelativePath||e.name,file:e}))}async function DV(e){let t=[],n=async(e,r)=>{let i=r?`${r}/${e.name}`:e.name;if(e.isFile){let n=await new Promise((t,n)=>e.file(t,n));t.push({path:i,file:n});return}if(!e.isDirectory)return;let a=e.createReader();for(;;){let e=await new Promise((e,t)=>a.readEntries(e,t));if(!e.length)break;for(let t of e)await n(t,i)}};for(let t of e)await n(t,``);return t}function OV(){return typeof window.showDirectoryPicker==`function`}async function kV(){let e;try{e=await window.showDirectoryPicker({mode:`read`})}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return null;throw e}let t=[],n=async(e,r)=>{for await(let i of e.values()){let e=`${r}/${i.name}`;i.kind===`file`?t.push({path:e,file:await i.getFile()}):await n(i,e)}};return await n(e,e.name),t}var AV={1:`dohstRIUBeOkkAXOTXhhEkXanWzz-V4M518JBqTehRM`};function jV(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`)+`===`.slice((e.length+3)%4),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function MV(e,t){let n=e.toLowerCase(),r=t.toLowerCase();return n.startsWith(`*.`)?r.endsWith(n.slice(1))&&r.length>n.length-1:n===r}function NV(e){try{let t=JSON.parse(new TextDecoder().decode(jV(e)));return typeof t.sub!=`string`||typeof t.exp!=`number`||!Array.isArray(t.domains)||!t.domains.every(e=>typeof e==`string`)||t.kid!==void 0&&typeof t.kid!=`string`?null:t}catch{return null}}async function PV(e,t,n,r){if(!e)return{ok:!1,reason:`missing`};if(typeof e!=`string`)return{ok:!1,reason:`malformed`};let i=e.trim().split(`.`);if(i.length!==2||!i[0]||!i[1])return{ok:!1,reason:`malformed`};let a=NV(i[0]);if(!a)return{ok:!1,reason:`malformed`};let o=a.kid??`1`,s=typeof n==`string`?n:Object.hasOwn(n,o)?n[o]:void 0;if(!s)return{ok:!1,reason:`bad_signature`};let c;try{let e=await crypto.subtle.importKey(`raw`,jV(s),`Ed25519`,!1,[`verify`]);c=await crypto.subtle.verify(`Ed25519`,e,jV(i[1]),new TextEncoder().encode(i[0]))}catch{return{ok:!1,reason:`unsupported`}}return c?a.exp<r?{ok:!1,reason:`expired`}:a.domains.some(e=>MV(e,t))?{ok:!0,sub:a.sub,exp:a.exp}:{ok:!1,reason:`domain`}:{ok:!1,reason:`bad_signature`}}function FV(e,t){return PV(e,t,AV,Date.now()/1e3)}var Q={sans:`system-ui, sans-serif`,mono:`ui-monospace, monospace`};function IV(){let e=new Set;return{publish(t,n){for(let r of e)r(t,n)},subscribe(t){return e.add(t),()=>{e.delete(t)}}}}function LV(){return _t(`span`,{className:`kymoscope-attribution`,role:`note`,style:{position:`absolute`,right:10,bottom:8,zIndex:50,pointerEvents:`none`,font:`500 11px/1.2 var(--font-sans, system-ui)`,letterSpacing:`0.02em`,padding:`4px 8px`,borderRadius:999,color:`var(--text-muted, #8a93a6)`,background:`color-mix(in oklch, var(--bg-elevated, #1b2130) 88%, transparent)`,border:`1px solid var(--border, #33405a)`},children:[`Powered by `,q(`strong`,{style:{color:`var(--accent, #f5a524)`,fontWeight:700},children:`Kymoscope`})]})}function RV(){let e=new Map;return{on(t,n){let r=e.get(t);return r||e.set(t,r=new Set),r.add(n),()=>{r.delete(n)}},emit(t,n){for(let r of e.get(t)??[])try{r(n)}catch(e){console.error(`[kymoscope] listener failed`,e)}},clear(){e.clear()}}}function zV(e,t=1){let n=e.trim().replace(/^#/,``);n.length===3&&(n=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]);let r=n.length===8?parseInt(n.slice(6),16)/255:1;n.length===8&&(n=n.slice(0,6));let i=parseInt(n,16);return n.length!==6||Number.isNaN(i)||Number.isNaN(r)?[0,0,0,t]:[(i>>16&255)/255,(i>>8&255)/255,(i&255)/255,r*t]}function BV(e){return Math.max(0,(e>>1)-1)}var VV=2.5,HV=`#version 300 es
|
|
72
72
|
in vec2 a_corner; // static quad corner: (±1, ±1)
|
|
73
73
|
in vec2 a_a; // per-instance: segment start (CSS px)
|
|
@@ -604,7 +604,7 @@ void main() {
|
|
|
604
604
|
float t = u_range.y > u_range.x ? clamp((v - u_range.x) / (u_range.y - u_range.x), 0.0, 1.0) : 0.5;
|
|
605
605
|
vec4 c = texture(u_palette, vec2((floor(t * 255.0) + 0.5) / 256.0, 0.5));
|
|
606
606
|
outColor = vec4(c.rgb * c.a, c.a);
|
|
607
|
-
}`,PK=-3e38;function FK(e){for(let t=0;t<e.length;t++)if(e[t]-e[t]===0)return e[t];return 0}function IK(e){let t=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!t)return null;let n=(e,n,i,a)=>lH(t,`glPlot|${e}|${n}`,()=>r(e,n,i,a)),r=(e,n,r,i)=>{let a=WV(t,t.VERTEX_SHADER,e),o=WV(t,t.FRAGMENT_SHADER,n);if(!a||!o)return null;let s=t.createProgram();if(t.attachShader(s,a),t.attachShader(s,o),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))return console.error(`glPlot program link failed:`,t.getProgramInfoLog(s)),null;let c=[`u_resolution`,`u_plot`,`u_view`,`u_clip`,`u_dpr`,`u_height`];return{prog:s,shaders:[a,o],a:Object.fromEntries([`a_corner`,...r].map(e=>[e,t.getAttribLocation(s,e)])),u:Object.fromEntries([...c,...i].map(e=>[e,t.getUniformLocation(s,e)]))}},i=n(EK,OK,[`a_xa`,`a_xb`,`a_loa`,`a_lob`,`a_hia`,`a_hib`,`a_bstart`],[`u_color`]),a=n(DK,kK,[`a_x0`,`a_x1`,`a_y0`,`a_y1`,`a_k`],[`u_palette`]),o=n(AK,jK,[`a_ax`,`a_ay`,`a_bx`,`a_by`,`a_bstart`],[`u_color`,`u_half`,`u_ext`]),s=n(MK,NK,[],[`u_extent`,`u_values`,`u_palette`,`u_range`]);if(!i||!a||!o||!s)return null;let c=t.getParameter(t.MAX_TEXTURE_SIZE),l=t.createVertexArray(),u=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,u),t.bufferData(t.ARRAY_BUFFER,Float32Array.from([0,0,1,0,0,1,1,1]),t.STATIC_DRAW);let d=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,d),t.bufferData(t.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),t.STATIC_DRAW);let f=new Map,p=1,m=1,h=1,g={xmin:0,xmax:1,ymin:0,ymax:1},_={left:0,top:0,width:1,height:1},v=new WeakMap,y=new Float32Array,b=e=>{for(let n of Object.values(e.buffers))t.deleteBuffer(n);e.palette&&t.deleteTexture(e.palette),e.values&&t.deleteTexture(e.values)},x=new Float32Array,S=(e,n)=>{t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)},C=(e,t)=>{let n=f.get(e);if(n&&n.kind===t)return n;n&&b(n);let r={kind:t,n:0,ox:0,oy:0,buffers:{},color:[0,0,0,1],width:1};return f.set(e,r),r},w=(e,n,r)=>{let i=e.buffers[n]??=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),r.byteLength<=(v.get(i)??0)?t.bufferSubData(t.ARRAY_BUFFER,0,r):(t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),v.set(i,r.byteLength))},T=(e,t,n,r)=>{let i=n.length;y.length<i&&(y=new Float32Array(i));for(let e=0;e<i;e++)y[e]=n[e]-r;w(e,t,y.subarray(0,i))},E=(e,t,n)=>{let r=new Uint8Array(e);t&&r.set(t.subarray(0,e)),e&&(r[0]=255);for(let t=0;t<e;t++)n(t)||(r[t]=255,t+1<e&&(r[t+1]=255));return r},D=(e,n,r=0,i=t.FLOAT)=>{if(e<0)return;t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(e);let a=i===t.FLOAT?4:1;t.vertexAttribPointer(e,1,i,i!==t.FLOAT,a,r*a),t.vertexAttribDivisor(e,1)},O=(n,r,i)=>{t.useProgram(n.prog),t.uniform2f(n.u.u_resolution,p,m),t.uniform4f(n.u.u_plot,_.left,_.top,_.width,_.height),t.uniform4f(n.u.u_view,g.xmin-r.ox,g.xmax-r.ox,g.ymin-r.oy,g.ymax-r.oy),t.uniform4f(n.u.u_clip,_.left,_.top,_.left+_.width,_.top+_.height),t.uniform1f(n.u.u_dpr,h),t.uniform1f(n.u.u_height,e.height),t.bindBuffer(t.ARRAY_BUFFER,i),t.enableVertexAttribArray(n.a.a_corner),t.vertexAttribPointer(n.a.a_corner,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(n.a.a_corner,0)},k=e=>{for(let n of Object.values(e.a))n>=0&&t.vertexAttribDivisor(n,0)};return{resize(t,n,r){p=Math.max(1,t),m=Math.max(1,n),h=r,e.width=Math.round(p*h),e.height=Math.round(m*h)},setView(e,t,n,r,i){g={xmin:e,xmax:t,ymin:n,ymax:r},_=i},setBands(e,t,n,r,i,a){let o=C(e,`bands`),s=Math.min(t.length,n.length,r.length);o.ox=FK(t),o.oy=FK(r),T(o,`x`,t,o.ox),T(o,`lo`,n,o.oy),T(o,`hi`,r,o.oy),w(o,`start`,E(s,a,e=>t[e]-t[e]===0&&n[e]-n[e]===0&&r[e]-r[e]===0)),o.n=Math.max(0,s-1),o.color=i},setRects(e,n,r,i,a,o,s){let c=C(e,`rects`),l=Math.min(n.length,r.length,i.length,a.length);c.ox=FK(n),c.oy=FK(i),T(c,`x0`,n,c.ox),T(c,`x1`,r,c.ox),T(c,`y0`,i,c.oy),T(c,`y1`,a,c.oy),s?T(c,`k`,s,0):delete c.buffers.k;let u=new Uint8Array(256*4);for(let e=0;e<256;e++){let t=o[Math.min(e,o.length-1)]??[0,0,0,1];u.set([t[0]*255,t[1]*255,t[2]*255,t[3]*255],e*4)}c.palette??=t.createTexture(),t.bindTexture(t.TEXTURE_2D,c.palette),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,u),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),c.n=l},setLine(e,t,n,r,i,a){let o=C(e,`line`),s=Math.min(t.length,n.length);o.ox=FK(t),o.oy=FK(n),T(o,`x`,t,o.ox),T(o,`y`,n,o.oy),w(o,`start`,E(s,a,e=>t[e]-t[e]===0&&n[e]-n[e]===0)),o.n=Math.max(0,s-1),o.color=r,o.width=i},maxTextureSize:c,setGrid(e,n,r,i,a,o,s,c){let l=C(e,`grid`),u=r*i,d=0;for(let e=0;e<u;e++)d+=n[e]*0;let f=n.subarray(0,u);if(d!==0){x.length<u&&(x=new Float32Array(u));for(let e=0;e<u;e++){let t=n[e];x[e]=t===t?t:PK}f=x.subarray(0,u)}let p=!l.values;l.values??=t.createTexture(),t.bindTexture(t.TEXTURE_2D,l.values),t.pixelStorei(t.UNPACK_ALIGNMENT,4),!p&&l.grid&&l.grid.w===r&&l.grid.h===i?t.texSubImage2D(t.TEXTURE_2D,0,0,0,r,i,t.RED,t.FLOAT,f):(t.texImage2D(t.TEXTURE_2D,0,t.R32F,r,i,0,t.RED,t.FLOAT,f),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),l.palette??=t.createTexture(),S(l.palette,o);let[m,h,g,_]=a;l.ox=m,l.oy=g,l.grid={w:r,h:i,x0:m,x1:h,y0:g,y1:_,vmin:s,vmax:c},l.n=1},setGridRange(e,t,n){let r=f.get(e);r?.grid&&(r.grid.vmin=t,r.grid.vmax=n)},remove(e){let t=f.get(e);t&&(b(t),f.delete(e))},keep(e){let t=new Set(e);for(let e of[...f.keys()])t.has(e)||this.remove(e)},render(){t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,e.width,e.height),t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(l),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);for(let e of f.values()){if(e.n<=0)continue;let n=e.buffers;if(e.kind===`bands`)O(i,e,u),t.uniform4f(i.u.u_color,...e.color),D(i.a.a_xa,n.x,0),D(i.a.a_xb,n.x,1),D(i.a.a_loa,n.lo,0),D(i.a.a_lob,n.lo,1),D(i.a.a_hia,n.hi,0),D(i.a.a_hib,n.hi,1),D(i.a.a_bstart,n.start,1,t.UNSIGNED_BYTE),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(i);else if(e.kind===`grid`){let n=e.grid;O(s,e,u),t.uniform4f(s.u.u_extent,0,n.x1-n.x0,0,n.y1-n.y0),t.uniform2f(s.u.u_range,n.vmin,n.vmax),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e.values),t.uniform1i(s.u.u_values,0),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,e.palette),t.uniform1i(s.u.u_palette,1),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.activeTexture(t.TEXTURE0)}else e.kind===`rects`?(O(a,e,u),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e.palette),t.uniform1i(a.u.u_palette,0),D(a.a.a_x0,n.x0),D(a.a.a_x1,n.x1),D(a.a.a_y0,n.y0),D(a.a.a_y1,n.y1),n.k?D(a.a.a_k,n.k):(t.disableVertexAttribArray(a.a.a_k),t.vertexAttrib1f(a.a.a_k,0)),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(a)):(O(o,e,d),t.uniform4f(o.u.u_color,...e.color),t.uniform1f(o.u.u_half,e.width/2),t.uniform1f(o.u.u_ext,e.width/2+1.5),D(o.a.a_ax,n.x,0),D(o.a.a_bx,n.x,1),D(o.a.a_ay,n.y,0),D(o.a.a_by,n.y,1),D(o.a.a_bstart,n.start,1,t.UNSIGNED_BYTE),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(o))}t.bindVertexArray(null)},dispose(){for(let e of f.values())b(e);f.clear(),t.deleteBuffer(u),t.deleteBuffer(d),t.deleteVertexArray(l)}}}function LK(e){let t=K({plot:null,failed:!1,size:``});return W(()=>()=>{t.current.plot?.dispose(),t.current.plot=null},[]),ct((n,r)=>{let i=t.current,a=e.current;if(!i.plot&&!i.failed&&a&&(i.plot=uH(a,IK),i.failed=!i.plot),!i.plot||!a)return null;let o=Math.min(2,window.devicePixelRatio||1),s=`${n}x${r}@${o}`;return i.size!==s&&(i.plot.resize(n,r,o),a.style.width=`${n}px`,a.style.height=`${r}px`,i.size=s),i.plot},[e])}function RK(e){let t=!1;for(let n=0;n<e.length;n++)if(Math.abs(e[n])>Math.PI*2){t=!0;break}let n=new Float64Array(e.length);for(let r=0;r<e.length;r++)n[r]=t?e[r]*Math.PI/180:e[r];return n}var zK=16;function BK(e,t,n,r){let i=RK(e),a=Math.min(i.length,t.length),o=1/0,s=-1/0;for(let e=0;e<a;e++){let n=t[e];n<o&&(o=n),n>s&&(s=n)}let c=n??Math.min(0,o),l=r??s,u=l-c||1,d=new Float64Array(a),f=new Float64Array(a),p=new Float64Array(zK),m=new Int32Array(zK);for(let e=0;e<a;e++){let n=Math.max(0,(t[e]-c)/u),r=i[e];n>1.0001?d[e]=f[e]=NaN:(d[e]=Math.sin(r)*n,f[e]=Math.cos(r)*n);let a=r%(2*Math.PI);a<0&&(a+=2*Math.PI);let o=Math.min(zK-1,Math.floor(a/(2*Math.PI)*zK));p[o]+=t[e],m[o]++}return{n:a,rMin:c,rMax:l,x:d,y:f,means:Array.from({length:zK},(e,t)=>m[t]>0?p[t]/m[t]:0)}}function VK({angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i=`#a78bfa`,mode:a=`waveform`,radiusMin:o,radiusMax:s,height:c=400,backgroundToken:l=``,onPlotContextMenu:u}){let d=K(null),f=K(null),p=K(null),m=K(u);G(()=>{m.current=u},[u]);let h=K({angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i,mode:a,radiusMin:o,radiusMax:s,height:c});G(()=>{h.current={angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i,mode:a,radiusMin:o,radiusMax:s,height:c}},[e,t,n,r,i,a,o,s,c]);let g=dt(()=>BK(e,t,o,s),[e,t,o,s]),_=K(g);G(()=>{_.current=g},[g]);let v=K(null),y=LK(v),b=K({geo:null,color:``});function x(){if(p.current)return p.current;let e=f.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return p.current=n,n}function S(){let e=f.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||h.current.height)}}function C(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function w(){let e=d.current;if(!e)return;let{w:t,h:n}=S(),r=C(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=x(),{angleLabel:s,radiusLabel:c,color:l,mode:u}=h.current,f=_.current,{n:p,rMin:m,rMax:g}=f;r.fillStyle=i,r.fillRect(0,0,t,n);let v=y(t,n);if(p===0){v?.keep([]),v?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,16,16);return}let w=g-m||1,T=(Math.min(t-64,n-32-24)-4)/2,E=t/2,D=32+T,O=wz(w,4),k=Dz(m,g,O);r.strokeStyle=o,r.lineWidth=1,r.setLineDash([3,3]);for(let e of k){let t=(e-m)/w*T;t<0||(r.beginPath(),r.arc(E,D,t,0,Math.PI*2),r.stroke())}r.setLineDash([]),r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<360;e+=30){let t=e*Math.PI/180;r.beginPath(),r.moveTo(E,D),r.lineTo(E+Math.cos(-t+Math.PI/2)*T,D+Math.sin(-t+Math.PI/2)*T),r.stroke()}r.fillStyle=a,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`;for(let e=0;e<360;e+=30){let t=e*Math.PI/180,n=E+Math.sin(t)*(T+14),i=D-Math.cos(t)*(T+14);r.fillText(`${e}°`,n,i)}r.textAlign=`left`,r.textBaseline=`middle`;for(let e of k){let t=(e-m)/w*T;t<4||r.fillText(jz(e,O),E+4,D-t)}if(r.strokeStyle=a,r.lineWidth=1,r.setLineDash([]),r.beginPath(),r.arc(E,D,T,0,Math.PI*2),r.stroke(),r.save(),r.beginPath(),r.arc(E,D,T,0,Math.PI*2),r.clip(),u===`waveform`)if(v)(b.current.geo!==f||b.current.color!==l)&&(v.setLine(`wave`,f.x,f.y,XG(l,.9),1),b.current={geo:f,color:l}),v.keep([`wave`]),v.setView(-1,1,-1,1,{left:E-T,top:D-T,width:T*2,height:T*2}),v.render();else{r.strokeStyle=l,r.lineWidth=1,r.globalAlpha=.9,r.beginPath();let e=!1;for(let t=0;t<p;t++){let n=E+f.x[t]*T,i=D-f.y[t]*T;if(n!==n){e=!1;continue}e?r.lineTo(n,i):(r.moveTo(n,i),e=!0)}r.stroke(),r.globalAlpha=1}else{v?.keep([]),v?.render();let e=f.means,t=Math.max(...e,1e-10),n=2*Math.PI/zK;r.fillStyle=l,r.globalAlpha=.75;for(let i=0;i<zK;i++){let a=e[i]/t*T,o=i*n-Math.PI/2-n/2;r.beginPath(),r.moveTo(E,D),r.arc(E,D,a,o,o+n),r.closePath(),r.fill()}r.globalAlpha=1,r.strokeStyle=l,r.lineWidth=.5,r.globalAlpha=.4;for(let i=0;i<zK;i++){let a=e[i]/t*T,o=i*n-Math.PI/2-n/2;r.beginPath(),r.moveTo(E,D),r.arc(E,D,a,o,o+n),r.closePath(),r.stroke()}r.globalAlpha=1}r.restore(),r.fillStyle=a,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`${s} / ${c}`,E,n-4)}let T=K(w);T.current=w;let E=K(null);E.current??=DH(()=>T.current(),()=>f.current);let D=()=>E.current.schedule();return W(()=>{E.current.now()}),W(()=>()=>E.current?.cancel(),[]),W(()=>{p.current=null,D()},[l]),G(()=>{let e=f.current;if(!e)return;let t=new EH(()=>{p.current=null,D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=d.current;if(!e)return;let t=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),_t(`div`,{ref:f,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:d,className:`chart-canvas`,role:`img`,"aria-label":`Polar chart: ${n} vs ${r}`}),q(`canvas`,{ref:v,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}})]})}function HK(e,t,n,r,i){let a=Math.min(e.length,t.length),o=(t,n)=>{let r=0,i=a;for(;r<i;){let a=r+i>>>1;(n?e[a]<=t:e[a]<t)?r=a+1:i=a}return r},s=o(n,!1),c=o(r,!0),l=Math.max(0,s-1),u=Math.min(a,c+1);if(u-l<=2*i){let e=new Uint32Array(u-l);for(let t=0;t<e.length;t++)e[t]=l+t;return e}let d=new Uint32Array(2*i+2),f=0;s>0&&(d[f++]=s-1);let p=(r-n)/i,m=s;for(let r=0;r<i&&m<c;r++){let a=r===i-1?1/0:n+(r+1)*p,o=1/0,s=-1/0,l=-1,u=-1;for(;m<c&&e[m]<a;m++){let e=t[m];e<o&&(o=e,l=m),e>s&&(s=e,u=m)}l<0||(l===u?d[f++]=l:l<u?(d[f++]=l,d[f++]=u):(d[f++]=u,d[f++]=l))}return c<a&&(d[f++]=c),d.subarray(0,f)}function UK(e,t){let n=e.length;if(n<=2*t)return Uint32Array.from({length:n},(e,t)=>t);let r=new Uint32Array(2*t),i=0;for(let a=0;a<t;a++){let o=Math.floor(a*n/t),s=Math.floor((a+1)*n/t),c=1/0,l=-1/0,u=-1,d=-1;for(let t=o;t<s;t++){let n=e[t];n<c&&(c=n,u=t),n>l&&(l=n,d=t)}u<0||(u===d?r[i++]=u:u<d?(r[i++]=u,r[i++]=d):(r[i++]=d,r[i++]=u))}return r.subarray(0,i)}function WK(e,t){let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n}function GK(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return e.length===0||e[0]===e[0]}function KK(e,t){let n=e.length;for(let r=1,i=0;r<n;r++){let a=n>>1;for(;i&a;a>>=1)i^=a;if(i^=a,r<i){let n=e[r];e[r]=e[i],e[i]=n,n=t[r],t[r]=t[i],t[i]=n}}for(let r=2;r<=n;r<<=1){let i=r>>1,a=-2*Math.PI/r,o=Math.cos(a),s=Math.sin(a);for(let a=0;a<n;a+=r){let n=1,r=0;for(let c=0;c<i;c++){let l=a+c,u=l+i,d=e[u]*n-t[u]*r,f=e[u]*r+t[u]*n;e[u]=e[l]-d,t[u]=t[l]-f,e[l]+=d,t[l]+=f;let p=n*o-r*s;r=n*s+r*o,n=p}}}}var qK=new Float64Array,JK=new Float64Array;function YK(e,t,n){let r=t>>1;qK.length<r&&(qK=new Float64Array(r),JK=new Float64Array(r));let i=qK.subarray(0,r),a=JK.subarray(0,r),o=e.length;for(let t=0;t<r;t++){let r=2*t,s=r+1;i[t]=r<o?e[r]*(n?n[r]:1):0,a[t]=s<o?e[s]*(n?n[s]:1):0}KK(i,a);let s=new Float64Array(r),c=-2*Math.PI/t,l=Math.cos(c),u=Math.sin(c),d=1,f=0;for(let e=0;e<r;e++){let t=e===0?0:r-e,n=i[e],o=a[e],c=i[t],p=-a[t],m=(n+c)/2,h=(o+p)/2,g=(o-p)/2,_=-(n-c)/2,v=m+d*g-f*_,y=h+d*_+f*g;s[e]=Math.sqrt(v*v+y*y);let b=d*l-f*u;f=d*u+f*l,d=b}return s}var XK=new Float64Array,ZK=0;function QK(e){if(ZK===e)return XK.subarray(0,e);XK.length<e&&(XK=new Float64Array(Math.max(e,XK.length*2)));let t=2*Math.PI/Math.max(1,e-1),n=Math.cos(t),r=Math.sin(t),i=1,a=0;for(let t=0;t<e;t++){XK[t]=.5*(1-i);let e=i*n-a*r;a=a*n+i*r,i=e}return ZK=e,XK.subarray(0,e)}var $K={top:14,right:24,bottom:40,left:64},eq=5;function tq(e){let t=1;for(;t<e;)t<<=1;return t}function nq(e,t,n,r){let i=e.length,a=Math.max(2,tq(i)),o=YK(e,a,n===`hann`?QK(i):void 0),s=a/2,c=new Float64Array(s),l=2/a;for(let e=0;e<s;e++){c[e]=e*t/a;let n=o[e]*l;o[e]=r===`db`?20*Math.log10(Math.max(n,1e-12)):n}return{freqs:c,amps:o}}function rq({signal:e,sampleRate:t=1,label:n,xMode:r=`hz`,yMode:i=`amplitude`,window:a=`hann`,color:o=`#34d399`,logX:s=!1,height:c=400,backgroundToken:l=``,onPlotContextMenu:u}){let d=nU(),f=K(null),p=K(null),m=K(null),h=K(u);G(()=>{h.current=u},[u]);let g=K({signal:e,sampleRate:t,label:n,xMode:r,yMode:i,window:a,color:o,logX:s,height:c});G(()=>{g.current={signal:e,sampleRate:t,label:n,xMode:r,yMode:i,window:a,color:o,logX:s,height:c}},[e,t,n,r,i,a,o,s,c]);let _=dt(()=>e.length>=4?nq(e,t,a,i):null,[e,t,a,i]),v=dt(()=>_&&s?_.freqs.map(e=>Math.log10(e)):null,[_,s]),y=K(_&&{..._,logFreqs:v});G(()=>{y.current=_&&{..._,logFreqs:v}},[_,v]);function b(){if(m.current)return m.current;let e=p.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return m.current=n,n}function x(){let e=p.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||g.current.height)}}function S(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function C(){let e=f.current;if(!e)return;let{w:t,h:n}=x(),r=S(e,t,n);if(!r)return;let{top:i,right:a,bottom:o,left:s}=$K,c=t-s-a,l=n-i-o,{bg:u,muted:p,grid:m}=b(),{sampleRate:h,label:_,xMode:v,yMode:C,color:w,logX:T}=g.current,E=y.current;if(r.fillStyle=u,r.fillRect(0,0,t,n),!E||c<=0||l<=0){r.fillStyle=p,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,s+8,i+8);return}let{freqs:D,amps:O,logFreqs:k}=E,A=D.length,j=v===`hz`?`${_} (Hz)`:`${_} (order)`,M=v===`order`&&h>0?h:1,N=D[1]/M,P=D[A-1]/M,F=1/0,I=-1/0;for(let e=1;e<A;e++)O[e]<F&&(F=O[e]),O[e]>I&&(I=O[e]);if(!Number.isFinite(F)||!Number.isFinite(I)){r.fillStyle=p,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,s+8,i+8);return}let L=(I-F)*.05||.1;F-=L,I+=L;let R=T?e=>{if(e<=0||N<=0)return s;let t=Math.log10(N),n=Math.log10(P);return s+(Math.log10(e)-t)/(n-t)*c}:e=>s+(e-N)/(P-N)*c;T&&N<=0&&(N=D[1]>0?D[1]/M:.001),d({left:s,top:i,width:c,height:l,x:{v0:N,v1:P,log:T},y:{v0:F,v1:I}});let z=e=>i+(I-e)/(I-F)*l,B=wz(I-F,5),V=Dz(F,I,B);r.strokeStyle=m,r.lineWidth=1,r.setLineDash([3,3]);for(let e of V)r.beginPath(),r.moveTo(s,z(e)),r.lineTo(s+c,z(e)),r.stroke();r.setLineDash([]);let ee=T?1:wz(P-N,Tz(c)),te=T?(()=>{let e=[],t=Math.ceil(Math.log10(Math.max(N,1e-12))),n=Math.floor(Math.log10(P));for(let r=t;r<=n;r++)for(let t of[1,2,5]){let n=t*10**r;n>=N&&n<=P&&e.push(n)}return e})():Dz(N,P,ee);r.strokeStyle=m,r.lineWidth=1,r.setLineDash([3,3]);for(let e of te)r.beginPath(),r.moveTo(R(e),i),r.lineTo(R(e),i+l),r.stroke();r.setLineDash([]),r.strokeStyle=p,r.lineWidth=1,r.fillStyle=p,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of V)r.beginPath(),r.moveTo(s-eq,z(e)),r.lineTo(s,z(e)),r.stroke(),r.fillText(jz(e,B),s-4,z(e));r.textAlign=`center`,r.textBaseline=`top`;for(let e of te)r.beginPath(),r.moveTo(R(e),i+l),r.lineTo(R(e),i+l+eq),r.stroke(),r.fillText(jz(e,T?e:ee),R(e),i+l+eq+2);r.strokeStyle=m,r.lineWidth=1,r.strokeRect(s,i,c,l),r.save(),r.beginPath(),r.rect(s,i,c,l),r.clip(),r.strokeStyle=w,r.lineWidth=1,r.beginPath();let H=!1,ne=Math.min(2,window.devicePixelRatio||1),re=Math.max(1,Math.round(c*ne)),ie=A>re*4?T&&k?HK(k,O,Math.log10(N*M),Math.log10(P*M),re):HK(D,O,N*M,P*M,re):null;for(let e=+!ie;e<(ie?ie.length:A);e++){let t=ie?ie[e]:e;if(t<1)continue;let n=D[t]/M;if(n<N||n>P)continue;let i=R(n),a=z(O[t]);H?r.lineTo(i,a):(r.moveTo(i,a),H=!0)}r.stroke(),r.restore(),r.fillStyle=p,r.font=`11px ${Q.mono}`,r.save(),r.translate(14,i+l/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(C===`db`?`dB`:`Amplitude`,0,0),r.restore(),r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(j,s+c/2,n-4)}let w=K(C);w.current=C;let T=K(null);T.current??=DH(()=>w.current(),()=>p.current);let E=()=>T.current.schedule();return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{m.current=null,E()},[l]),G(()=>{let e=p.current;if(!e)return;let t=new EH(()=>{m.current=null,E()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=f.current;if(!e)return;let t=e=>{e.preventDefault(),h.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:p,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:f,className:`chart-canvas`,role:`img`,"aria-label":`Spectrum of ${n}`})})}function iq(e,t,n=0,r=e.length-1){for(;r>n;){let i=n+r>>>1,a=e[n],o=e[i],s=e[r];if(a>o){let e=a;a=o,o=e}o>s&&(o=s),a>o&&(o=a);let c=o,l=n,u=r;for(;l<=u;){for(;e[l]<c;)l++;for(;e[u]>c;)u--;if(l<=u){let t=e[l];e[l]=e[u],e[u]=t,l++,u--}}if(t<=u)r=u;else if(t>=l)n=l;else break}return e[t]}function aq(e,t){let n=e.length;if(n===0)return t.map(()=>0);let r=[...new Set(t.flatMap(e=>{let t=e/100*(n-1);return[Math.floor(t),Math.ceil(t)]}))].sort((e,t)=>e-t),i=new Map,a=0;for(let t of r)i.set(t,iq(e,t,a)),a=t;return t.map(e=>{let t=e/100*(n-1),r=Math.floor(t);return i.get(r)+(i.get(Math.ceil(t))-i.get(r))*(t-r)})}var oq={top:14,right:24,bottom:48,left:64},sq=5;function cq(e,t){let n=e.length;if(n===0)return null;let[r,i,a,o,s]=aq(Float64Array.from(e),[0,25,50,75,100]),c=0;for(let t=0;t<n;t++)c+=e[t];let l=c/n;if(t!==`1.5iqr`)return{q1:i,median:a,q3:o,mean:l,whiskerLo:r,whiskerHi:s,outliers:new Float64Array};let u=o-i,d=i-1.5*u,f=o+1.5*u,p=1/0,m=-1/0,h=0;for(let t=0;t<n;t++){let n=e[t];if(n<d||n>f){h++;continue}n<p&&(p=n),n>m&&(m=n)}let g=new Float64Array(h);for(let t=0,r=0;t<n;t++){let n=e[t];(n<d||n>f)&&(g[r++]=n)}return g.sort(),{q1:i,median:a,q3:o,mean:l,whiskerLo:p<=m?p:i,whiskerHi:p<=m?m:o,outliers:g}}function lq({groups:e,color:t=`#fb923c`,whiskers:n=`1.5iqr`,height:r=400,backgroundToken:i=``,onPlotContextMenu:a}){let o=nU(),s=K(null),c=K(null),l=K(null),u=K(a);G(()=>{u.current=a},[a]);let d=K({groups:e,color:t,whiskers:n,height:r});G(()=>{d.current={groups:e,color:t,whiskers:n,height:r}},[e,t,n,r]);let f=dt(()=>e.filter(e=>e.values.length>0).map(e=>({label:e.label,box:cq(e.values,n)})),[e,n]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||d.current.height)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:a,bottom:c,left:l}=oq,u=t-l-a,f=n-i-c,{bg:_,muted:v,grid:y}=m(),{color:b}=d.current;r.fillStyle=_,r.fillRect(0,0,t,n);let x=p.current;if(x.length===0||u<=0||f<=0){r.fillStyle=v,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let S=1/0,C=-1/0;for(let e of x){e.box.whiskerLo<S&&(S=e.box.whiskerLo),e.box.whiskerHi>C&&(C=e.box.whiskerHi);for(let t of e.box.outliers)t<S&&(S=t),t>C&&(C=t)}let w=(C-S)*.08||1;S-=w,C+=w;let T=e=>i+(C-e)/(C-S)*f;o({left:l,top:i,width:u,height:f,y:{v0:S,v1:C}});let E=wz(C-S,5),D=Dz(S,C,E);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of D)r.beginPath(),r.moveTo(l,T(e)),r.lineTo(l+u,T(e)),r.stroke();r.setLineDash([]),r.strokeStyle=v,r.lineWidth=1,r.fillStyle=v,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of D)r.beginPath(),r.moveTo(l-sq,T(e)),r.lineTo(l,T(e)),r.stroke(),r.fillText(jz(e,E),l-4,T(e));r.strokeStyle=y,r.lineWidth=1,r.strokeRect(l,i,u,f),r.save(),r.beginPath(),r.rect(l,i,u,f),r.clip();let O=x.length,k=u/O,A=Math.min(k*.55,60);for(let e=0;e<O;e++){let{box:t}=x[e],n=l+k*e+k/2;r.strokeStyle=b,r.lineWidth=1.5,r.beginPath(),r.moveTo(n,T(t.whiskerLo)),r.lineTo(n,T(t.whiskerHi)),r.stroke();let i=A*.35;r.beginPath(),r.moveTo(n-i,T(t.whiskerLo)),r.lineTo(n+i,T(t.whiskerLo)),r.moveTo(n-i,T(t.whiskerHi)),r.lineTo(n+i,T(t.whiskerHi)),r.stroke();let a=n-A/2,o=T(t.q3),s=Math.max(1,T(t.q1)-o);r.fillStyle=b,r.globalAlpha=.25,r.fillRect(a,o,A,s),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=1.5,r.strokeRect(a,o,A,s),r.strokeStyle=b,r.lineWidth=2.5,r.beginPath(),r.moveTo(a,T(t.median)),r.lineTo(a+A,T(t.median)),r.stroke();let c=T(t.mean);r.fillStyle=b,r.beginPath(),r.moveTo(n,c-5),r.lineTo(n+5,c),r.lineTo(n,c+5),r.lineTo(n-5,c),r.closePath(),r.fill(),r.fillStyle=b,r.globalAlpha=.6;let u=NaN;for(let e of t.outliers){let t=T(e);Math.abs(t-u)<.5||(u=t,r.beginPath(),r.arc(n,t,2.5,0,Math.PI*2),r.fill())}r.globalAlpha=1}r.restore(),r.fillStyle=v,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<O;e++){let t=l+k*e+k/2,n=x[e].label;r.save(),r.rect(l+k*e+2,i+f+sq+2,k-4,c-sq-4),r.clip(),r.fillText(n,t,i+f+sq+2),r.restore()}}let v=K(_);v.current=_;let y=K(null);y.current??=DH(()=>v.current(),()=>c.current);let b=()=>y.current.schedule();return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{l.current=null,b()},[i]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:s,className:`chart-canvas`,role:`img`,"aria-label":`Box plot`})})}function uq(e,t){if(e.w<=t)return{grid:e,per:1};let n=e.w/t,r=new Float32Array(t*e.h);for(let i=0;i<e.h;i++){let a=i*e.w;for(let o=0;o<t;o++){let s=Math.floor(o*n),c=Math.min(e.w,Math.floor((o+1)*n)),l=0,u=0;for(let t=s;t<c;t++){let n=e.values[a+t];n===n&&(l+=n,u++)}r[i*t+o]=u?l/u:NaN}}let i=e.xLabels;return{grid:{w:t,h:e.h,values:r,xLabels:e=>typeof i==`function`?i(Math.floor(e*n)):i[Math.floor(e*n)],yLabels:e.yLabels},per:n}}var dq=e=>e.includes(`.`)&&!e.includes(`e`)?e.replace(/\.?0+$/,``):e;function fq(e){return e>=1e3?`${dq((e/1e3).toPrecision(3))}k`:dq(e.toPrecision(3))}function pq(e,t,n,r,i,a,o){let s=t>>1,c=e.length,l=c>=t?Math.floor((c-t)/n)+1:0,u=`${t}|${n}|${r}|${i}|${a?a.join(`,`):``}`,d=-1,f=0;if(o&&o.key===u&&o.frames>0&&c>0){let r=o.sig;for(let i=0;i*n<r.length&&f===0;i++){let a=i*n;if(r[a]!==e[0])continue;let s=Math.min(r.length-a,c),u=!0;for(let t=0;t<s;t++)if(r[a+t]!==e[t]){u=!1;break}if(!u)continue;let p=s>=t?Math.floor((s-t)/n)+1:0;d=i,f=Math.max(0,Math.min(p,o.frames-i,l))}}let p=new Float32Array(l*s),m=new Float32Array(l);if(f>0){for(let e=0;e<s;e++)p.set(o.values.subarray(e*o.frames+d,e*o.frames+d+f),e*l);m.set(o.frameMax.subarray(d,d+f))}let h=new Float64Array(t);for(let e=0;e<t;e++)h[e]=r?.5*(1-Math.cos(2*Math.PI*e/(t-1))):1;let g=Math.log2(t),_=new Uint32Array(t);for(let e=0;e<t;e++){let t=0,n=e;for(let e=0;e<g;e++)t=t<<1|n&1,n>>=1;_[e]=t}let v=new Float64Array(t),y=new Float64Array(t),b=new Float64Array(s);for(let r=f;r<l;r++){let o=r*n;for(let n=0;n<t;n++){let t=_[n];v[n]=e[o+t]*h[t],y[n]=0}for(let e=2;e<=t;e<<=1){let n=e>>1,r=-2*Math.PI/e,i=Math.cos(r),a=Math.sin(r);for(let r=0;r<t;r+=e){let e=1,t=0;for(let o=0;o<n;o++){let s=r+o,c=s+n,l=v[c]*e-y[c]*t,u=v[c]*t+y[c]*e;v[c]=v[s]-l,y[c]=y[s]-u,v[s]+=l,y[s]+=u;let d=e*i-t*a;t=e*a+t*i,e=d}}}let c=0;for(let e=0;e<s;e++){let n=Math.sqrt(v[e]*v[e]+y[e]*y[e])/t;b[e]=n,n>c&&(c=n)}m[r]=c;for(let e=0;e<s;e++){let t=b[a?a[e]:e];p[e*l+r]=i?20*Math.log10(Math.max(t,1e-12)):t}}let x=1e-10;for(let e=0;e<l;e++)m[e]>x&&(x=m[e]);return{values:p,frames:l,bins:s,max:x,computed:l-f,sig:Float64Array.from(e),frameMax:m,key:u}}var mq={top:14,right:24,bottom:40,left:68},hq=[[8,0,16],[48,0,96],[104,0,144],[160,0,128],[200,32,64],[230,100,16],[250,200,32],[255,255,220]],gq=-80;function _q(e){let t=hq.length-1,n=Math.min(t-1,Math.floor(e*t)),r=e*t-n,[i,a,o]=hq[n],[s,c,l]=hq[n+1];return[i+(s-i)*r,a+(c-a)*r,o+(l-o)*r]}var vq=(()=>{let e=new Uint8Array(256*4);for(let t=0;t<256;t++){let[n,r,i]=_q(t/255);e.set([n,r,i,255],t*4)}return e})();function yq(e){let t=1;for(;t<e;)t<<=1;return t}var bq=(e,t)=>Math.log(1+e/t*9)/Math.log(10),xq=(e,t)=>t*(10**e-1)/9;function Sq({signal:e,sampleRate:t=1e3,windowSize:n=512,overlap:r=.5,winFunc:i=`hann`,yMode:a=`db`,logFreq:o=!1,label:s=``,backgroundToken:c=``,onPlotContextMenu:l}){let u=nU(),d=K(null),f=K(null),p=K(null),m=K(null),h=K(null),g=K(l);G(()=>{g.current=l},[l]);let _=yq(Math.max(4,Math.min(n,4096))),v=Math.max(1,Math.round(_*(1-Math.max(0,Math.min(.95,r))))),y=dt(()=>{if(!o)return null;let e=_>>1,n=t/2;return Int32Array.from({length:e},(t,r)=>Math.min(e-1,Math.floor(xq((r+.5)/e,n)/n*e)))},[o,_,t]),b=K(null),x=dt(()=>b.current=pq(e,_,v,i===`hann`,a===`db`,y,b.current),[e,_,v,i,a,y]),S=dt(()=>({w:x.frames,h:x.bins,values:x.values,xLabels:[],yLabels:[]}),[x]),C=a===`db`?20*Math.log10(x.max):x.max,w=a===`db`?[C+gq,C]:[0,C],T=K({grid:S,range:w,sampleRate:t,winSz:_,step:v,yMode:a,logFreq:o,label:s});G(()=>{T.current={grid:S,range:w,sampleRate:t,winSz:_,step:v,yMode:a,logFreq:o,label:s}},[S,w[0],w[1],t,_,v,a,o,s]);let E=K({plot:null,failed:!1,size:``,grid:null,shown:null});W(()=>()=>{E.current.plot?.dispose(),E.current.plot=null},[]);function D(){if(h.current)return h.current;let e=m.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return h.current=n,n}function O(){let e=m.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function k(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function A(e,t){let n=E.current;if(!n.plot&&!n.failed&&f.current&&(n.plot=uH(f.current,IK),n.failed=!n.plot),!n.plot||!f.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),f.current.style.width=`${e}px`,f.current.style.height=`${t}px`,n.size=i),n.plot}function j(){let e=d.current;if(!e)return;let{w:t,h:n}=O(),r=k(e,t,n);if(!r)return;let i=p.current?k(p.current,t,n):null;i?.clearRect(0,0,t,n);let a=YW(mq,t,n),{top:o,right:s,bottom:c,left:l}=a,f=t-l-s,h=n-o-c,{bg:g,muted:_,grid:v}=D(),{grid:y,sampleRate:b,winSz:x,step:S,logFreq:C,label:w}=T.current;r.fillStyle=g,r.fillRect(0,0,t,n);let j=A(t,n);if(y.w===0||f<=0||h<=0){if(j?.keep([]),j?.render(),a.tiny)return;r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,o+8);return}let M=Math.min(2,window.devicePixelRatio||1),N=j?j.maxTextureSize:Math.max(1,Math.round(f*M)),[P,F]=T.current.range;if(E.current.grid!==y||!E.current.shown||!j&&E.current.shown.w>N){let e=uq(y,N).grid;j&&j.setGrid(`cells`,e.values,e.w,Math.min(e.h,j.maxTextureSize),[0,e.w,0,e.h],vq,P,F),E.current.grid=y,E.current.shown=e,CH(m.current)}let I=E.current.shown;if(j)j.keep([`cells`]),j.setGridRange(`cells`,P,F),j.setView(0,I.w,0,I.h,{left:l,top:o,width:f,height:h}),j.render();else{let e=document.createElement(`canvas`);e.width=I.w,e.height=I.h;let t=e.getContext(`2d`),n=t.createImageData(I.w,I.h);for(let e=0;e<I.h;e++)for(let t=0;t<I.w;t++){let[r,i,a]=_q(Math.max(0,Math.min(1,(I.values[e*I.w+t]-P)/(F-P)))),o=(t+(I.h-1-e)*I.w)*4;n.data[o]=r,n.data[o+1]=i,n.data[o+2]=a,n.data[o+3]=255}t.putImageData(n,0,0),r.drawImage(e,l,o,f,h)}if(a.tiny)return;let L=i??r,R=b/2,z=e=>o+h*(1-(C?bq(e,R):e/R));L.strokeStyle=v,L.lineWidth=.5,L.globalAlpha=.4;let B=Dz(0,R,wz(R,5));L.setLineDash([3,4]);for(let e of B){let t=z(e);L.beginPath(),L.moveTo(l,t),L.lineTo(l+f,t),L.stroke()}L.setLineDash([]),L.globalAlpha=1,L.strokeStyle=v,L.strokeRect(l,o,f,h),r.fillStyle=_,r.font=`10px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.strokeStyle=_,r.lineWidth=1;for(let e of B){let t=z(e);r.beginPath(),r.moveTo(l-4,t),r.lineTo(l,t),r.stroke(),r.fillText(fq(e),l-6,t)}let V=(y.w*S+x)/b;u({left:l,top:o,width:f,height:h,x:{v0:0,v1:V}});let ee=wz(V,6),te=Dz(0,V,ee);r.textAlign=`center`,r.textBaseline=`top`;for(let e of te){let t=l+e/V*f;r.beginPath(),r.moveTo(t,o+h),r.lineTo(t,o+h+4),r.stroke(),r.fillText(jz(e,ee),t,o+h+6)}r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(w||`Time (s)`,l+f/2,n-4),r.save(),r.translate(12,o+h/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(`Frequency (Hz)`,0,0),r.restore()}let M=K(j);G(()=>{M.current=j});let N=K(null);return N.current??=DH(()=>M.current(),()=>m.current),W(()=>{N.current.now()},[S,w[0],w[1],t,_,v,a,o,s]),W(()=>()=>N.current?.cancel(),[]),W(()=>{h.current=null,N.current.schedule()},[c]),G(()=>{let e=m.current;if(!e)return;let t=new EH(()=>{h.current=null,N.current.schedule()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=p.current;if(!e)return;let t=e=>{e.preventDefault(),g.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),_t(`div`,{ref:m,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:d,className:`chart-canvas`,role:`img`,"aria-label":`Spectrogram`}),q(`canvas`,{ref:f,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:p,className:`chart-canvas chart-overlay`})]})}var Cq=300,wq=256,Tq=-60,Eq=[];function Dq({signal:e,sampleRate:t,windowSize:n,overlap:r,winFunc:i,yMode:a,backgroundToken:o,onPlotContextMenu:s}){let c=2**Math.ceil(Math.log2(Math.max(4,Math.min(n,4096)))),l=Math.max(1,Math.round(c*(1-Math.max(0,Math.min(.95,r))))),u=a===`db`,d=dt(()=>pq(e,c,l,i===`hann`,u,null),[e,c,l,i,u]);return q(gK,{points:Eq,surface:dt(()=>Oq(d,t,c,l,u),[d,t,c,l,u]),xLabel:`Time (s)`,yLabel:`Frequency (Hz)`,zLabel:u?`Level (dB)`:`Amplitude`,viewMode:`3d`,showMesh:!0,meshStyle:`filled`,meshOpacity:1,backgroundToken:o,onPlotContextMenu:s})}function Oq(e,t,n,r,i){let{frames:a,bins:o,values:s}=e;if(a<2||o<2)return;let c=Math.min(a,Cq),l=Math.min(o,wq),u=i?20*Math.log10(Math.max(e.max,1e-12))+Tq:-1/0,d=new Float32Array(c*l);for(let e=0;e<l;e++){let t=Math.floor(e*o/l),n=Math.max(t+1,Math.floor((e+1)*o/l));for(let r=0;r<c;r++){let i=Math.floor(r*a/c),o=Math.max(i+1,Math.floor((r+1)*a/c)),l=-1/0;for(let e=t;e<n;e++)for(let t=i;t<o;t++){let n=s[e*a+t];n>l&&(l=n)}d[e*c+r]=Math.max(u,l)}}let f=e=>(e*r+n/2)/t;return{w:c,h:l,values:d,x:[f(0),f(a-1)],y:[0,(o-1)*t/n]}}function kq(e,t,n){return Array.from({length:n},(r,i)=>e+(i+1)/(n+1)*(t-e))}function Aq(e,t,n,r){let i=[],a=(n,r)=>e[r*t+n],o=(e,t)=>(r-e)/(t-e);for(let e=0;e+1<n;e++)for(let n=0;n+1<t;n++){let t=a(n,e),s=a(n+1,e),c=a(n+1,e+1),l=a(n,e+1);if(t!==t||s!==s||c!==c||l!==l)continue;let u=(t>=r?8:0)|(s>=r?4:0)|(c>=r?2:0)|l>=r;if(u===0||u===15)continue;let d=()=>[n+o(t,s),e],f=()=>[n+1,e+o(s,c)],p=()=>[n+o(l,c),e+1],m=()=>[n,e+o(t,l)],h=(e,t)=>i.push([e[0],e[1],t[0],t[1]]);switch(u){case 1:case 14:h(m(),p());break;case 2:case 13:h(p(),f());break;case 3:case 12:h(m(),f());break;case 4:case 11:h(d(),f());break;case 6:case 9:h(d(),p());break;case 7:case 8:h(m(),d());break;case 5:case 10:{let e=(t+s+c+l)/4>=r;u===5===e?(h(m(),d()),h(p(),f())):(h(d(),f()),h(m(),p()));break}}}return i}function jq(e){let t=e.length,n=new Float64Array(t+1);if(t===1)return n[0]=e[0]-.5,n[1]=e[0]+.5,n;for(let r=1;r<t;r++)n[r]=(e[r-1]+e[r])/2;return n[0]=e[0]-(n[1]-e[0]),n[t]=e[t-1]+(e[t-1]-n[t-1]),n}function Mq(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!Number.isFinite(e[t])||t>0&&!(e[t]>e[t-1]))return!1;return!0}var Nq={top:14,right:32,bottom:80,left:80};function Pq(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}var Fq=[[33,102,172],[103,169,207],[209,229,240],[247,247,247],[253,219,199],[239,138,98],[178,24,43]],Iq=[[13,8,135],[84,2,163],[139,10,165],[185,50,137],[219,92,104],[244,136,73],[254,188,43],[240,249,33]],Lq=[[68,1,84],[72,40,120],[62,83,160],[49,120,178],[38,153,185],[31,184,187],[53,213,158],[117,231,101],[198,239,82],[253,231,37]];function Rq(e,t){let n=e.length-1,r=Math.min(n-1,Math.floor(t*n));return Pq(e[r],e[r+1],t*n-r)}function zq(e,t){return Rq(t===`plasma`?Iq:t===`viridis`?Lq:Fq,e)}function Bq(e){let t=new Uint8Array(256*4);for(let n=0;n<256;n++){let[r,i,a]=zq(n/255,e);t.set([r,i,a,255],n*4)}return t}function Vq(e){return Math.abs(e)>=1e4||Math.abs(e)<.01&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(3)))}function Hq(e,t,n){let r=new Map(t.map((e,t)=>[e,t])),i=new Map(n.map((e,t)=>[e,t])),a=new Float32Array(t.length*n.length);for(let n of e){let e=r.get(n.x),o=i.get(n.y);e!==void 0&&o!==void 0&&(a[o*t.length+e]=n.value)}return{w:t.length,h:n.length,values:a,xLabels:t,yLabels:n}}function Uq(e,t,n,r,i,a,o){let s=(e,t,n)=>Float64Array.from({length:e+1},(r,i)=>t+i/e*n),c=!!a&&a.length===e.w,l=!!o&&o.length===e.h,u=s(e.w,t,r),d=s(e.h,n,i);if(c){let n=jq(a),i=n[e.w]-n[0];u=Float64Array.from(n,e=>t+(e-n[0])/i*r)}if(l){let t=jq(Float64Array.from(o).reverse()),r=e.h,a=t[r]-t[0];d=Float64Array.from({length:r+1},(e,o)=>n+(t[r]-t[r-o])/a*i)}return{xB:u,yB:d,byValue:c||l}}function Wq(e,t){if(t<e[0]||t>=e[e.length-1])return-1;let n=0,r=e.length-1;for(;r-n>1;){let i=n+r>>1;e[i]<=t?n=i:r=i}return n}function Gq(e,t,n,r,i,a){let o=Math.max(1,i),s=Math.max(1,a),c=Int32Array.from({length:o},(e,r)=>Wq(t.xB,n+r+.5)),l=new Float32Array(o*s);for(let n=0;n<s;n++){let i=Wq(t.yB,r+n+.5),a=i*e.w;for(let t=0;t<o;t++)l[n*o+t]=i<0||c[t]<0?NaN:e.values[a+c[t]]}return{w:o,h:s,values:l,xLabels:e.xLabels,yLabels:e.yLabels}}function Kq({cells:e,xLabels:t,yLabels:n,grid:r,showValues:i=!0,colorScheme:a=`diverging`,vMin:o,vMax:s,xCentres:c,yCentres:l,contours:u=0,backgroundToken:d=``,onPlotContextMenu:f}){let p=K(null),m=K(null),h=K(null),g=K(null),_=K(null),v=K(null),y=K(null),b=K(0),x=K(f);G(()=>{x.current=f},[f]);let S=dt(()=>r??Hq(e??[],t??[],n??[]),[r,e,t,n]),C=dt(()=>{let e=o??1/0,t=s??-1/0;if(o===void 0||s===void 0){let n=1/0,r=-1/0;for(let e=0;e<S.w*S.h;e++){let t=S.values[e];t<n&&(n=t),t>r&&(r=t)}o===void 0&&(e=n),s===void 0&&(t=r)}return t>e||(e=Number.isFinite(e)?e-1:0,t=e+2),{lo:e,hi:t}},[S,o,s]),w=K({data:S,range:C,showValues:i,colorScheme:a,xCentres:c,yCentres:l,contours:u});G(()=>{w.current={data:S,range:C,showValues:i,colorScheme:a,xCentres:c,yCentres:l,contours:u}},[S,C,i,a,c,l,u]);let T=K({plot:null,failed:!1,size:``,data:null,key:``,shown:null,geo:null}),E=K({key:``,grid:null,segs:[]});W(()=>()=>{T.current.plot?.dispose(),T.current.plot=null},[]);let D=K({data:null,range:``});function O(){if(v.current)return v.current;let e=_.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return v.current=n,n}function k(){let e=_.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function A(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function j(e,t){let n=T.current;if(!n.plot&&!n.failed&&m.current&&(n.plot=uH(m.current,IK),n.failed=!n.plot),!n.plot||!m.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),m.current.style.width=`${e}px`,m.current.style.height=`${t}px`,n.size=i),n.plot}let M=(e,t)=>typeof e==`function`?e(t):e[t];function N(){let e=p.current;if(!e)return;let{w:t,h:n}=k(),r=A(e,t,n);if(!r)return;let i=h.current?A(h.current,t,n):null;i?.clearRect(0,0,t,n);let a=YW(Nq,t,n),{top:o,right:s,bottom:c,left:l}=a,{bg:u,muted:d,grid:f}=O(),{data:m,range:{lo:g,hi:v},showValues:y,colorScheme:b}=w.current;r.fillStyle=u,r.fillRect(0,0,t,n);let x=j(t,n);if(m.w===0||m.h===0){x?.keep([]),x?.render(),r.fillStyle=d,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,o+8);return}let S=t-l-s,C=n-o-c,N=Math.min(2,window.devicePixelRatio||1),P=D.current;(P.data!==m||P.range!==`${g}|${v}`)&&(D.current={data:m,range:`${g}|${v}`},CH(_.current));let{xCentres:F,yCentres:I,contours:L}=w.current,R=x?x.maxTextureSize:Math.max(1,Math.round(S*N)),z=uq(m,R).grid,B=Uq(z,l,o,S,C,z===m?F:void 0,z===m?I:void 0),V=B.byValue,ee=`${R}|${b}|${V?`${S}x${C}`:``}`,te=T.current.shown;if(T.current.data!==m||T.current.key!==ee||!te){te=z;let e=V?Gq(te,B,l,o,Math.round(S),Math.round(C)):te;x&&x.setGrid(`cells`,e.values,e.w,Math.min(e.h,x.maxTextureSize),[0,e.w,0,e.h],Bq(b),g,v),T.current.data=m,T.current.key=ee,T.current.shown=te}T.current.geo=B;let H=V?Math.round(S):te.w,ne=V?Math.round(C):te.h,re=e=>B.xB[e+1]-B.xB[e],ie=e=>B.yB[e+1]-B.yB[e];if(x)x.keep([`cells`]),x.setGridRange(`cells`,g,v),x.setView(0,H,ne,0,{left:l,top:o,width:S,height:C}),x.render();else for(let e=0;e<te.h;e++)for(let t=0;t<te.w;t++){let n=te.values[e*te.w+t];if(Number.isNaN(n))continue;let[i,a,o]=zq(Math.max(0,Math.min(1,(n-g)/(v-g))),b);r.fillStyle=`rgb(${i|0},${a|0},${o|0})`,r.fillRect(B.xB[t],B.yB[e],re(t)+.5,ie(e)+.5)}let U=i??r;if(y){for(let e=0;e<te.h;e++)if(!(ie(e)<=16)){U.font=`${Math.min(12,Math.max(8,ie(e)*.4))}px ${Q.mono}`,U.textAlign=`center`,U.textBaseline=`middle`;for(let t=0;t<te.w;t++){let n=te.values[e*te.w+t];if(Number.isNaN(n)||re(t)<=28)continue;let[r,i,a]=zq(Math.max(0,Math.min(1,(n-g)/(v-g))),b);U.fillStyle=.299*r+.587*i+.114*a>128?`#000`:`#fff`,U.fillText(Vq(n),(B.xB[t]+B.xB[t+1])/2,(B.yB[e]+B.yB[e+1])/2)}}}if(S/te.w>=4&&C/te.h>=4){U.strokeStyle=u,U.lineWidth=.5;for(let e=0;e<=te.w;e++)U.beginPath(),U.moveTo(B.xB[e],o),U.lineTo(B.xB[e],o+C),U.stroke();for(let e=0;e<=te.h;e++)U.beginPath(),U.moveTo(l,B.yB[e]),U.lineTo(l+S,B.yB[e]),U.stroke()}let ae=L>0?kq(g,v,L):[];if(ae.length&&te.w>=2&&te.h>=2&&te.w*te.h<=4e6){let e=`${g}|${v}|${L}`;if(E.current.grid!==te||E.current.key!==e){let t=te;E.current={key:e,grid:t,segs:ae.map(e=>Aq(t.values,t.w,t.h,e))}}let t=(e,t)=>{let n=Math.min(t.length-3,Math.max(0,Math.floor(e))),r=(t[n]+t[n+1])/2;return r+((t[n+1]+t[n+2])/2-r)*(e-n)};U.save(),U.beginPath(),U.rect(l,o,S,C),U.clip(),U.lineCap=`round`,U.lineJoin=`round`;for(let[e,n]of[[2.6,`rgba(0,0,0,0.38)`],[1.1,`rgba(255,255,255,0.92)`]]){U.lineWidth=e,U.strokeStyle=n,U.beginPath();for(let e of E.current.segs)for(let[n,r,i,a]of e)U.moveTo(t(n,B.xB),t(r,B.yB)),U.lineTo(t(i,B.xB),t(a,B.yB));U.stroke()}U.restore()}r.fillStyle=d,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`;let oe=-1/0;for(let e=0;e<(a.tiny?0:te.w);e++){let t=(B.xB[e]+B.xB[e+1])/2;t-oe<18||(oe=t,r.save(),r.translate(t,o+C+4),r.rotate(-Math.PI/4),r.fillText(M(te.xLabels,e),0,0),r.restore())}r.textAlign=`right`,r.textBaseline=`middle`;let se=-1/0;for(let e=0;e<(a.tiny?0:te.h);e++){let t=(B.yB[e]+B.yB[e+1])/2;t-se<12||(se=t,r.fillText(te.yLabels[e]??``,l-4,t))}if(a.tiny)return;let ce=t-s+4,le=o,ue=C;for(let e=0;e<ue;e++){let[t,n,i]=zq(1-e/ue,b);r.fillStyle=`rgb(${t|0},${n|0},${i|0})`,r.fillRect(ce,le+e,12,1)}r.strokeStyle=f,r.lineWidth=.5,r.strokeRect(ce,le,12,ue),r.fillStyle=d,r.font=`9px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`,r.fillText(Vq(v),ce+12+2,le),r.fillText(Vq(g),ce+12+2,le+ue),r.fillText(Vq((g+v)/2),ce+12+2,le+ue/2),r.strokeStyle=`rgba(255,255,255,0.92)`,r.lineWidth=1;for(let e of ae){let t=le+ue*(1-(e-g)/(v-g));r.beginPath(),r.moveTo(ce-2,t),r.lineTo(ce+12+2,t),r.stroke()}}function P(){let e=g.current;if(!e)return;let{w:t,h:n}=k(),r=A(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=y.current,a=T.current.shown,o=T.current.geo;if(!i||!a||!o)return;let{top:s,right:c,bottom:l}=YW(Nq,t,n),{xi:u,yi:d}=i;if(u>=a.w||d>=a.h)return;let f=o.xB[u],p=o.xB[u+1],m=o.yB[d],h=o.yB[d+1];r.strokeStyle=`rgba(255,255,255,0.7)`,r.lineWidth=1.5,r.strokeRect(f+.5,m+.5,Math.max(1,p-f-1),Math.max(1,h-m-1));let _=a.values[d*a.w+u];if(!Number.isNaN(_)){let e=`${M(a.xLabels,u)} × ${a.yLabels[d]}: ${Vq(_)}`;r.font=`11px ${Q.mono}`;let n=r.measureText(e).width,i=Math.min(p+.1*(p-f),t-c-n-6),o=Math.max(s+4,m-.3*(h-m));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(i-3,o-3,n+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(e,i,o)}}let F=K(N);F.current=N;let I=K(null);I.current??=DH(()=>F.current(),()=>_.current);let L=()=>{b.current||=bH(()=>{b.current=0,P()})};return W(()=>{I.current.now()},[S,C,i,a,c,l,u]),W(()=>()=>{I.current?.cancel(),xH(b.current)},[]),W(()=>{v.current=null,I.current.schedule()},[d]),G(()=>{let e=_.current;if(!e)return;let t=new EH(()=>{v.current=null,I.current.schedule(),L()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=g.current;if(!e)return;let t=e=>{e.preventDefault(),x.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{shown:r,geo:i}=T.current;if(!r||!i)return;let a=Wq(i.xB,t.clientX-n.left),o=Wq(i.yB,t.clientY-n.top);y.current=a>=0&&a<r.w&&o>=0&&o<r.h?{xi:a,yi:o}:null,L()},r=()=>{y.current=null,L()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:_,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:p,className:`chart-canvas`,role:`img`,"aria-label":`Heatmap`}),q(`canvas`,{ref:m,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:h,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:g,className:`chart-canvas chart-overlay`})]})}var qq=2e3,Jq=1024;function Yq(e,t,n,r,i){let a=e.length,o=1/(a*t*Math.sqrt(2*Math.PI)),s=new Float64Array(n.length);if(a<=qq){for(let r=0;r<n.length;r++){let i=0;for(let o=0;o<a;o++){let a=(n[r]-e[o])/t;i+=Math.exp(-.5*a*a)}s[r]=i*o}return s}let c=new Float64Array(Jq),l=(i-r)/Jq||1;for(let t=0;t<a;t++)c[Math.max(0,Math.min(Jq-1,Math.floor((e[t]-r)/l)))]++;for(let e=0;e<n.length;e++){let i=0;for(let a=0;a<Jq;a++){if(c[a]===0)continue;let o=(n[e]-(r+(a+.5)*l))/t;i+=c[a]*Math.exp(-.5*o*o)}s[e]=i*o}return s}var Xq={top:14,right:24,bottom:48,left:64},Zq=120;function Qq(e,t,n){let r=e.length;if(r<2)return 1;let i=0;for(let t=0;t<r;t++)i+=e[t];let a=i/r,o=0;for(let t=0;t<r;t++)o+=(e[t]-a)**2;let s=Math.sqrt(o/(r-1));return .9*Math.min(s,(n-t)/1.34)*r**-.2}function $q(e,t){let n=e.filter(e=>e.values.length>=2),r=1/0,i=-1/0,a=n.map(e=>{let[t,n,a,o,s]=aq(Float64Array.from(e.values),[0,25,50,75,100]);return t<r&&(r=t),s>i&&(i=s),{q1:n,median:a,q3:o}}),o=(i-r)*.1||1;r-=o,i+=o;let s=Float64Array.from({length:Zq},(e,t)=>r+t/(Zq-1)*(i-r));return{shapes:n.map((e,n)=>{let{q1:o,median:c,q3:l}=a[n],u=Yq(e.values,t>0?t:Qq(e.values,o,l),s,r,i),d=1e-10;for(let e of u)e>d&&(d=e);return{label:e.label,density:u,maxDensity:d,q1:o,median:c,q3:l}}),pts:s,yMin:r,yMax:i}}function eJ({groups:e,color:t=`#818cf8`,showBox:n=!0,bandwidth:r=0,orientation:i=`vertical`,backgroundToken:a=``,onPlotContextMenu:o}){let s=nU(),c=K(null),l=K(null),u=K(null),d=K(o);G(()=>{d.current=o},[o]);let f=K({groups:e,color:t,showBox:n,bandwidth:r,orientation:i});G(()=>{f.current={groups:e,color:t,showBox:n,bandwidth:r,orientation:i}},[e,t,n,r,i]);let p=dt(()=>$q(e,r),[e,r]),m=K(p);G(()=>{m.current=p},[p]);function h(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function g(){let e=l.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function _(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function v(){let e=c.current;if(!e)return;let{w:t,h:n}=g(),r=_(e,t,n);if(!r)return;let{top:i,right:a,bottom:o,left:l}=Xq,u=t-l-a,d=n-i-o,{bg:p,muted:v,grid:y}=h(),{color:b,showBox:x,orientation:S}=f.current;r.fillStyle=p,r.fillRect(0,0,t,n);let{shapes:C,pts:w,yMin:T,yMax:E}=m.current;if(C.length===0||u<=0||d<=0){r.fillStyle=v,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let D=S===`vertical`,O=D?e=>i+d*(1-(e-T)/(E-T)):e=>l+u*((e-T)/(E-T));s({left:l,top:i,width:u,height:d,...D?{y:{v0:T,v1:E}}:{x:{v0:T,v1:E}}});let k=wz(E-T,5),A=Dz(T,E,k);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of A)D?(r.beginPath(),r.moveTo(l,O(e)),r.lineTo(l+u,O(e)),r.stroke()):(r.beginPath(),r.moveTo(O(e),i),r.lineTo(O(e),i+d),r.stroke());if(r.setLineDash([]),r.fillStyle=v,r.font=`11px ${Q.mono}`,r.strokeStyle=v,r.lineWidth=1,D){r.textAlign=`right`,r.textBaseline=`middle`;for(let e of A)r.beginPath(),r.moveTo(l-4,O(e)),r.lineTo(l,O(e)),r.stroke(),r.fillText(jz(e,k),l-6,O(e))}else{r.textAlign=`center`,r.textBaseline=`top`;for(let e of A)r.beginPath(),r.moveTo(O(e),i+d),r.lineTo(O(e),i+d+4),r.stroke(),r.fillText(jz(e,k),O(e),i+d+6)}r.strokeStyle=y,r.strokeRect(l,i,u,d),r.save(),r.beginPath(),r.rect(l,i,u,d),r.clip();let j=C.length,M=D?u/j:d/j;for(let e=0;e<j;e++){let{density:t,maxDensity:n,q1:a,median:o,q3:s}=C[e],c=D?l+M*e+M/2:i+M*e+M/2,u=M*.45;r.beginPath();for(let e=0;e<Zq;e++){let i=t[e]/n*u,a=O(w[e]);D?e===0?r.moveTo(c-i,a):r.lineTo(c-i,a):e===0?r.moveTo(a,c-i):r.lineTo(a,c-i)}for(let e=Zq-1;e>=0;e--){let i=t[e]/n*u,a=O(w[e]);D?r.lineTo(c+i,a):r.lineTo(a,c+i)}if(r.closePath(),r.fillStyle=b,r.globalAlpha=.35,r.fill(),r.strokeStyle=b,r.lineWidth=1,r.globalAlpha=.9,r.stroke(),r.globalAlpha=1,x){let e=u*.22;D?(r.fillStyle=b,r.globalAlpha=.7,r.fillRect(c-e,O(s),e*2,O(a)-O(s)),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=2,r.beginPath(),r.moveTo(c-e,O(o)),r.lineTo(c+e,O(o)),r.stroke()):(r.fillStyle=b,r.globalAlpha=.7,r.fillRect(O(a),c-e,O(s)-O(a),e*2),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=2,r.beginPath(),r.moveTo(O(o),c-e),r.lineTo(O(o),c+e),r.stroke())}}if(r.restore(),r.fillStyle=v,r.font=`11px ${Q.mono}`,D){r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<j;e++)r.fillText(C[e].label,l+M*e+M/2,i+d+6)}else{r.textAlign=`right`,r.textBaseline=`middle`;for(let e=0;e<j;e++)r.fillText(C[e].label,l-6,i+M*e+M/2)}}let y=K(v);y.current=v;let b=K(null);b.current??=DH(()=>y.current(),()=>l.current);let x=()=>b.current.schedule();return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{u.current=null,x()},[a]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,x()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=c.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:c,className:`chart-canvas`,role:`img`,"aria-label":`Violin plot`})})}var tJ={top:48,right:16,bottom:72,left:80},nJ=[8,24,64],rJ=[56,189,248];function iJ(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function aJ(e){return`${(e*100).toFixed(1)}%`}function oJ(e,t,n){if(e.length===0)return null;let r=Math.min(e.length,t.length),i=Array(r),a=Array(r),o=new Set,s=0;for(let n=0;n<r;n++)i[n]=String(e[n]),a[n]=String(t[n]),o.add(i[n]),o.add(a[n]),i[n]===a[n]&&s++;let c=[...o].sort(),l=c.length,u=new Map(c.map((e,t)=>[e,t])),d=Array.from({length:l},()=>Array(l).fill(0));for(let e=0;e<r;e++)d[u.get(i[e])][u.get(a[e])]++;let f=d.map(e=>e.reduce((e,t)=>e+t,0));return{classes:c,matrix:n?d.map((e,t)=>e.map(e=>f[t]>0?e/f[t]:0)):d,raw:d,accuracy:s/e.length}}function sJ({actual:e,predicted:t,normalize:n=!1,backgroundToken:r=``,onPlotContextMenu:i}){let a=K(null),o=K(null),s=K(null),c=K(null),l=K(null),u=K(0),d=K(i);G(()=>{d.current=i},[i]);let f=K({actual:e,predicted:t,normalize:n});G(()=>{f.current={actual:e,predicted:t,normalize:n}},[e,t,n]);function p(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function m(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let g=dt(()=>oJ(e,t,n),[e,t,n]),_=K(g);G(()=>{_.current=g},[g]);let v=()=>_.current;function y(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{top:i,right:o,bottom:s,left:c}=tJ,{bg:l,muted:u,grid:d}=p();r.fillStyle=l,r.fillRect(0,0,t,n);let g=v();if(!g){r.fillStyle=u,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,c+8,i+8);return}let{classes:_,matrix:y,accuracy:b}=g,x=_.length,S=t-c-o,C=n-i-s,w=S/x,T=C/x,E=0;for(let e of y)for(let t of e)t>E&&(E=t);for(let e=0;e<x;e++)for(let t=0;t<x;t++){let n=y[e][t],[a,o,s]=iJ(nJ,rJ,E>0?n/E:0);if(r.fillStyle=`rgb(${a|0},${o|0},${s|0})`,r.fillRect(c+t*w,i+e*T,w,T),w>24&&T>14){r.fillStyle=.299*a+.587*o+.114*s>100?`#000`:`#fff`,r.font=`${Math.min(12,Math.max(8,T*.38))}px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`;let l=f.current.normalize;r.fillText(l?aJ(n):String(n|0),c+(t+.5)*w,i+(e+.5)*T)}}r.strokeStyle=l,r.lineWidth=.5;for(let e=0;e<=x;e++)r.beginPath(),r.moveTo(c+e*w,i),r.lineTo(c+e*w,i+C),r.stroke(),r.beginPath(),r.moveTo(c,i+e*T),r.lineTo(c+S,i+e*T),r.stroke();r.strokeStyle=d,r.strokeRect(c,i,S,C),r.fillStyle=u,r.font=`10px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e=0;e<x;e++)r.fillText(_[e],c-4,i+(e+.5)*T);r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<x;e++)r.save(),r.translate(c+(e+.5)*w,i+C+4),r.rotate(-Math.PI/4),r.fillText(_[e],0,0),r.restore();r.fillStyle=u,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Predicted`,c+S/2,n-4),r.save(),r.translate(12,i+C/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(`Actual`,0,0),r.restore(),r.fillStyle=u,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Accuracy: ${aJ(b)}`,c+S/2,i/2)}function b(){let e=o.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(!i)return;let{top:a,right:s,bottom:c,left:u}=tJ,d=v();if(!d)return;let{classes:p,matrix:g}=d,_=p.length,y=t-u-s,b=n-a-c,x=y/_,S=b/_;r.strokeStyle=`rgba(255,255,255,0.8)`,r.lineWidth=2,r.strokeRect(u+i.c*x+1,a+i.r*S+1,x-2,S-2);let C=g[i.r][i.c],w=f.current.normalize,T=`${p[i.r]} → ${p[i.c]}: ${w?aJ(C):C|0}`;r.font=`11px ${Q.mono}`;let E=r.measureText(T).width,D=Math.min(u+(i.c+1.1)*x,t-E-6),O=Math.max(6,a+(i.r-.3)*S);r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(D-3,O-3,E+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(T,D,O)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>s.current);let C=()=>S.current.schedule(),w=()=>{xH(u.current),u.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{c.current=null,C()},[r]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{top:r,right:i,bottom:a,left:o}=tJ,s=v();if(!s)return;let c=s.classes.length,u=n.width-o-i,d=n.height-r-a,f=Math.floor((t.clientX-n.left-o)/(u/c)),p=Math.floor((t.clientY-n.top-r)/(d/c));l.current=p>=0&&p<c&&f>=0&&f<c?{r:p,c:f}:null,w()},r=()=>{l.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:a,className:`chart-canvas`,role:`img`,"aria-label":`Confusion matrix`}),q(`canvas`,{ref:o,className:`chart-canvas chart-overlay`})]})}var cJ={top:24,right:24,bottom:48,left:64};function lJ(e,t){let n=0,r=0,i=Math.min(e.length,t.length);for(let a=0;a<i;a++)e[a]-e[a]!==0||t[a]-t[a]!==0||(t[a]===1?n++:r++);let a=new Float64Array(n),o=new Float64Array(r);for(let n=0,r=0,s=0;n<i;n++)e[n]-e[n]!==0||t[n]-t[n]!==0||(t[n]===1?a[r++]=e[n]:o[s++]=e[n]);a.sort(),o.sort();let s=new Uint8Array(n+r);for(let e=0,t=n-1,i=r-1;e<s.length;e++)i<0||t>=0&&a[t]>=o[i]?(s[e]=1,t--):(s[e]=0,i--);return s}function uJ(e){let t=0;for(let n of e)t+=n;let n=e.length-t;if(t===0||n===0)return null;let r=new Float64Array(e.length+2),i=new Float64Array(e.length+2),a=0,o=0,s=0;for(let c=0;c<e.length;c++)e[c]===1?a++:o++,r[c+1]=o/n,i[c+1]=a/t,s+=(r[c+1]-r[c])*(i[c+1]+i[c])/2;return r[e.length+1]=1,i[e.length+1]=1,{fpr:r,tpr:i,auc:s}}function dJ(e){let t=0;for(let n of e)t+=n;if(t===0)return null;let n=new Float64Array(e.length),r=new Float64Array(e.length),i=0,a=0,o=0;for(let s=0;s<e.length;s++)e[s]===1?i++:a++,n[s]=i/t,r[s]=i/(i+a),s>0&&(o+=(n[s]-n[s-1])*r[s]);return{recall:n,precision:r,ap:o}}function fJ(e,t,n,r){let i=n(0),a=r(0);e.moveTo(i,a);for(let o=1;o<t;o++){let s=n(o),c=r(o);o<t-1&&Math.abs(s-i)<.5&&Math.abs(c-a)<.5||(e.lineTo(s,c),i=s,a=c)}}function pJ({scores:e,labels:t,mode:n=`roc`,color:r=`#f472b6`,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(a);G(()=>{l.current=a},[a]);let u=K({scores:e,labels:t,mode:n,color:r});G(()=>{u.current={scores:e,labels:t,mode:n,color:r}},[e,t,n,r]);let d=dt(()=>lJ(e,t),[e,t]),f=dt(()=>n===`pr`?{roc:null,pr:dJ(d)}:{roc:uJ(d),pr:null},[d,n]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function h(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:a,bottom:s,left:c}=cJ,l=t-c-a,d=n-i-s,{bg:f,muted:_,grid:v}=m(),{scores:y,mode:b,color:x}=u.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),y.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,c+8,i+8);return}let S=e=>c+e*l,C=e=>i+(1-e)*d,w=Dz(0,1,wz(1,5));r.strokeStyle=v,r.lineWidth=1,r.setLineDash([3,3]);for(let e of w)r.beginPath(),r.moveTo(S(e),i),r.lineTo(S(e),i+d),r.stroke(),r.beginPath(),r.moveTo(c,C(e)),r.lineTo(c+l,C(e)),r.stroke();if(r.setLineDash([]),b===`roc`&&(r.strokeStyle=_,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(S(0),C(0)),r.lineTo(S(1),C(1)),r.stroke(),r.setLineDash([])),b===`roc`){let e=p.current.roc;if(e){let t=e.fpr.length,n=t=>S(e.fpr[t]),a=t=>C(e.tpr[t]);r.beginPath(),fJ(r,t,n,a),r.strokeStyle=x,r.lineWidth=1,r.stroke(),r.beginPath(),fJ(r,t,n,a),r.lineTo(S(1),C(0)),r.lineTo(S(0),C(0)),r.closePath(),r.fillStyle=x,r.globalAlpha=.15,r.fill(),r.globalAlpha=1,r.fillStyle=x,r.font=`bold 13px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`AUC = ${e.auc.toFixed(3)}`,c+8,i+8)}}else{let e=p.current.pr;if(e){let t=HK(e.recall,e.precision,0,1,Math.max(1,Math.round(l*Math.min(2,window.devicePixelRatio||1))));r.beginPath();for(let n=0;n<t.length;n++){let i=S(e.recall[t[n]]),a=C(e.precision[t[n]]);n===0?r.moveTo(i,a):r.lineTo(i,a)}r.strokeStyle=x,r.lineWidth=1,r.stroke(),r.fillStyle=x,r.font=`bold 13px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`AP = ${e.ap.toFixed(3)}`,c+8,i+8)}}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of w)r.beginPath(),r.moveTo(c-4,C(e)),r.lineTo(c,C(e)),r.stroke(),r.fillText(e.toFixed(1),c-6,C(e));r.textAlign=`center`,r.textBaseline=`top`;for(let e of w)r.beginPath(),r.moveTo(S(e),i+d),r.lineTo(S(e),i+d+4),r.stroke(),r.fillText(e.toFixed(1),S(e),i+d+6);r.strokeStyle=v,r.strokeRect(c,i,l,d),r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(b===`roc`?`False Positive Rate`:`Recall`,c+l/2,n-4),r.save(),r.translate(12,i+d/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(b===`roc`?`True Positive Rate`:`Precision`,0,0),r.restore()}let v=K(_);v.current=_;let y=K(null);y.current??=DH(()=>v.current(),()=>s.current);let b=()=>y.current.schedule();return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{c.current=null,b()},[i]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),l.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`ROC / PR curve`})})}var mJ={top:20,right:64,bottom:48,left:64};function hJ({xValues:e,series:t,xLabel:n=`Epoch`,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({xValues:e,series:t,xLabel:n});G(()=>{p.current={xValues:e,series:t,xLabel:n}},[e,t,n]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let _=dt(()=>{let n=e=>{let t=1/0,n=-1/0;for(let r of e)for(let e=0;e<r.values.length;e++){let i=r.values[e];i<t&&(t=i),i>n&&(n=i)}if(!Number.isFinite(t))return{lo:0,hi:1};let r=(n-t)*.06||.1;return{lo:t-r,hi:n+r}},r=t.filter(e=>e.axis===`left`),i=t.filter(e=>e.axis===`right`),a=1/0,o=-1/0;for(let t=0;t<e.length;t++){let n=e[t];n<a&&(a=n),n>o&&(o=n)}return{leftExt:n(r.length?r:t),rightExt:n(i.length?i:t),hasRight:i.length>0,xMin:a,xMax:o,ascending:GK(e)}},[e,t]),v=K(_);G(()=>{v.current=_},[_]);function y(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:s,bottom:c,left:l}=mJ,u=t-l-s,d=n-i-c,{bg:f,muted:_,grid:y}=m(),{xValues:b,series:x,xLabel:S}=p.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),b.length===0||x.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let{leftExt:C,rightExt:w,hasRight:T,xMin:E,xMax:D,ascending:O}=v.current,k=e=>l+(e-E)/(D-E||1)*u;a({left:l,top:i,width:u,height:d,x:{v0:E,v1:D},y:{v0:C.lo,v1:C.hi}});let A=e=>i+(1-(e-C.lo)/(C.hi-C.lo))*d,j=e=>i+(1-(e-w.lo)/(w.hi-w.lo))*d,M=wz(C.hi-C.lo,5),N=Dz(C.lo,C.hi,M);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of N)r.beginPath(),r.moveTo(l,A(e)),r.lineTo(l+u,A(e)),r.stroke();let P=wz(D-E,6),F=Dz(E,D,P);for(let e of F)r.beginPath(),r.moveTo(k(e),i),r.lineTo(k(e),i+d),r.stroke();r.setLineDash([]);let I=Math.min(2,window.devicePixelRatio||1),L=Math.max(1,Math.round(u*I));for(let e of x){let t=e.axis===`right`&&T?j:A,n=Math.min(b.length,e.values.length),i=O&&n>4*L?HK(b,e.values,E,D,L):null;r.beginPath();let a=!1;for(let o=0;o<(i?i.length:n);o++){let n=i?i[o]:o,s=b[n],c=e.values[n];if(s-s!==0||c-c!==0){a=!1;continue}let l=k(s),u=t(c);a?r.lineTo(l,u):(r.moveTo(l,u),a=!0)}r.strokeStyle=e.color,r.lineWidth=1,r.stroke()}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of N)r.beginPath(),r.moveTo(l-4,A(e)),r.lineTo(l,A(e)),r.stroke(),r.fillText(jz(e,M),l-6,A(e));if(T){let e=wz(w.hi-w.lo,5),t=Dz(w.lo,w.hi,e);r.textAlign=`left`;for(let n of t)r.beginPath(),r.moveTo(l+u,j(n)),r.lineTo(l+u+4,j(n)),r.stroke(),r.fillText(jz(n,e),l+u+6,j(n))}r.textAlign=`center`,r.textBaseline=`top`;for(let e of F)r.beginPath(),r.moveTo(k(e),i+d),r.lineTo(k(e),i+d+4),r.stroke(),r.fillText(jz(e,P),k(e),i+d+6);r.strokeStyle=y,r.strokeRect(l,i,u,d),r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(S,l+u/2,n-4);let R=l+8,z=i+6;r.font=`10px ${Q.mono}`,r.textBaseline=`middle`;for(let e of x)r.fillStyle=e.color,r.fillRect(R,z-4,16,3),r.fillStyle=_,r.textAlign=`left`,r.fillText(e.label,R+20,z),R+=r.measureText(e.label).width+36,R>l+u-60&&(R=l+8,z+=14)}function b(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,right:o,bottom:c,left:l}=mJ,d=t-l-o,f=n-a-c,{muted:_}=m(),{xValues:y,series:b}=p.current;if(y.length===0)return;let{xMin:x,xMax:S,ascending:C}=v.current,w=e=>l+(e-x)/(S-x||1)*d,T=Math.max(l,Math.min(l+d,i));r.strokeStyle=_,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(T,a),r.lineTo(T,a+f),r.stroke(),r.setLineDash([]);let E=(T-l)/d,D=Math.round(E*(y.length-1));if(C){let e=x+E*(S-x),t=0,n=y.length;for(;t<n;){let r=t+n>>>1;y[r]<e?t=r+1:n=r}D=t>0&&(t>=y.length||e-y[t-1]<y[t]-e)?t-1:t}if(D<0||D>=y.length)return;let O=a+8;r.font=`10px ${Q.mono}`,r.textBaseline=`top`;for(let e of b)D<e.values.length&&Number.isFinite(e.values[D])&&(r.fillStyle=e.color,r.textAlign=`left`,r.fillText(`${e.label}: ${Mz(e.values[D])}`,T+6,O),O+=14);w(0)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>c.current);let C=()=>S.current.schedule(),w=()=>{xH(d.current),d.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{l.current=null,C()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,w()},r=()=>{u.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Loss curves`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var gJ={top:40,right:24,bottom:40,left:72},_J=`#ef4444`,vJ=`#f97316`,yJ=`#22d3ee`;function bJ(e,t){let n=e.length,r=e.value;if(n===0)return null;let i=0;for(let e=0;e<n;e++)i+=r[e];let a=i/n,o=0;for(let e=0;e<n;e++)o+=(r[e]-a)**2;let s=Math.sqrt(o/n),c=a+t*s,l=a-t*s,u=l,d=c,f=0;for(let e=0;e<n;e++){let t=r[e];t<u&&(u=t),t>d&&(d=t),(t>c||t<l)&&f++}let p=(d-u)*.08||.5,m=new Uint32Array(f);for(let e=0,t=0;e<n;e++)(r[e]>c||r[e]<l)&&(m[t++]=e);return{mean:a,sd:s,ucl:c,lcl:l,yMin:u-p,yMax:d+p,ooc:m}}function xJ({points:e,sigmaLevel:t=3,color:n=`#22d3ee`,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({points:e,sigmaLevel:t,color:n});G(()=>{p.current={points:e,sigmaLevel:t,color:n}},[e,t,n]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let _=dt(()=>bJ(e,t),[e,t]),v=K(_);G(()=>{v.current=_},[_]);let y=()=>v.current;function b(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:s,bottom:c,left:l}=gJ,u=t-l-s,d=n-i-c,{bg:f,muted:_,grid:v}=m(),{points:b,color:x}=p.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),b.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let S=y(),{mean:C,ucl:w,lcl:T,yMin:E,yMax:D}=S,O=e=>l+e/(b.length-1||1)*u;a({left:l,top:i,width:u,height:d,x:{v0:0,v1:b.length-1||1}});let k=e=>i+(1-(e-E)/(D-E))*d,A=wz(D-E,5),j=Dz(E,D,A);r.strokeStyle=v,r.lineWidth=1,r.setLineDash([3,3]);for(let e of j)r.beginPath(),r.moveTo(l,k(e)),r.lineTo(l+u,k(e)),r.stroke();r.setLineDash([]);let M=(e,t,n,a=[])=>{let o=k(e);o<i||o>i+d||(r.strokeStyle=t,r.lineWidth=1.2,r.setLineDash(a),r.beginPath(),r.moveTo(l,o),r.lineTo(l+u,o),r.stroke(),r.setLineDash([]),r.fillStyle=t,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(`${n} ${Mz(e)}`,l+u-2,o-5))};M(w,vJ,`UCL`,[5,3]),M(C,yJ,`CL`,[]),M(T,vJ,`LCL`,[5,3]);let N=Math.min(2,window.devicePixelRatio||1),P=Math.max(1,Math.round(u*N)),F=b.length,I=b.value,L=UK(I,P);r.beginPath();for(let e=0;e<L.length;e++){let t=L[e],n=O(t),i=k(I[t]);e===0?r.moveTo(n,i):r.lineTo(n,i)}r.strokeStyle=x,r.lineWidth=1,r.stroke();let R=(e,t)=>{r.beginPath(),r.arc(O(e),k(I[e]),t?4:3,0,Math.PI*2),r.fillStyle=t?_J:x,r.fill()};if(F<=u/4)for(let e=0;e<F;e++)R(e,I[e]>w||I[e]<T);else{let e=NaN,t=NaN;for(let n of S.ooc){let r=Math.round(O(n)),i=Math.round(k(I[n]));r===e&&i===t||(e=r,t=i,R(n,!0))}}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of j)r.beginPath(),r.moveTo(l-4,k(e)),r.lineTo(l,k(e)),r.stroke(),r.fillText(jz(e,A),l-6,k(e));r.strokeStyle=v,r.strokeRect(l,i,u,d)}function x(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,right:o,bottom:c,left:l}=gJ,d=t-l-o,f=n-a-c,{muted:_}=m(),{points:v}=p.current;if(v.length===0)return;let{ucl:b,lcl:x,yMin:S,yMax:C}=y(),w=e=>l+e/(v.length-1||1)*d,T=e=>a+(1-(e-S)/(C-S))*f,E=Math.round((i-l)/d*(v.length-1));if(E<0||E>=v.length)return;let D=v.value[E],O=w(E),k=T(D);r.strokeStyle=_,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(O,a),r.lineTo(O,a+f),r.stroke(),r.setLineDash([]);let A=v.subgroup?.(E),j=`${A?`${A}: `:`#${E+1}: `}${Mz(D)}`;r.font=`11px ${Q.mono}`;let M=r.measureText(j).width,N=O+8+M>l+d?O-M-10:O+8;r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(N-3,k-12,M+6,18),r.fillStyle=D>b||D<x?_J:_,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(j,N,k-11)}let S=K(b);S.current=b;let C=K(null);C.current??=DH(()=>S.current(),()=>c.current);let w=()=>C.current.schedule(),T=()=>{xH(d.current),d.current=bH(x)};return W(()=>{C.current.now()}),W(()=>()=>C.current?.cancel(),[]),W(()=>{l.current=null,w()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,w(),T()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,T()},r=()=>{u.current=null,T()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Control chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var SJ={top:32,right:24,bottom:24,left:24},CJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],wJ=16;function TJ(e){return`rgb(${Math.round(255*Math.min(1,Math.max(0,3.5*e-.5)))},${Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e)))},${Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))})`}function EJ(e,t,n,r){let i=Math.min(t,e.columns.length),a=e.columns.slice(0,i).map(t=>{let n=1/0,r=-1/0;for(let i=0;i<e.length;i++){let e=t[i];e<n&&(n=e),e>r&&(r=e)}if(!Number.isFinite(n))return{lo:0,hi:1};let i=(r-n)*.05||.5;return{lo:n-i,hi:r+i}}),o={lo:0,hi:1},s=new Int32Array(e.length),c=[r];if(n&&e.colorValue){let t=e.colorValue,n=1/0,r=-1/0;for(let i=0;i<e.length;i++)t[i]<n&&(n=t[i]),t[i]>r&&(r=t[i]);Number.isFinite(n)&&(o={lo:n,hi:r}),c=Array.from({length:wJ},(e,t)=>TJ((t+.5)/wJ));for(let n=0;n<e.length;n++){let e=(t[n]-o.lo)/(o.hi-o.lo||1);s[n]=t[n]===t[n]?Math.max(0,Math.min(wJ-1,Math.floor(e*wJ))):-1}for(let t=0;t<e.length;t++)s[t]<0&&(s[t]=0)}else if(!n&&e.colorIndex){c=CJ;for(let t=0;t<e.length;t++)s[t]=Math.max(0,e.colorIndex[t])%CJ.length}let l=new Int32Array(c.length);for(let t=0;t<e.length;t++)l[s[t]]++;let u=c.map((e,t)=>({color:e,x:new Float64Array(l[t]*i),y:new Float64Array(l[t]*i),starts:new Uint8Array(l[t]*i)})),d=new Int32Array(c.length);for(let t=0;t<e.length;t++){let n=u[s[t]],r=d[s[t]]++*i;n.starts[r]=1;for(let o=0;o<i;o++,r++){let i=a[o];n.x[r]=o,n.y[r]=(e.columns[o][t]-i.lo)/(i.hi-i.lo)}}return{k:i,extents:a,colorExt:o,groups:u.filter(e=>e.x.length>0)}}function DJ({rows:e,axes:t,color:n=`#64748b`,colorByNumeric:r=!1,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(null),p=K(0),m=K(a);G(()=>{m.current=a},[a]);let h=dt(()=>EJ(e,t.length,r,n),[e,t.length,r,n]),g=K({rows:e,axes:t,colorByNumeric:r,model:h});G(()=>{g.current={rows:e,axes:t,colorByNumeric:r,model:h}},[e,t,r,h]);let _=LK(s),v=K(null);function y(){if(d.current)return d.current;let e=u.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return d.current=n,n}function b(){let e=u.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function x(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function S(){let e=o.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;let i=c.current?x(c.current,t,n):null;i?.clearRect(0,0,t,n);let a=i??r,{top:s,right:l,bottom:d,left:f}=SJ,{bg:p,muted:m}=y(),{rows:h,axes:S,colorByNumeric:C,model:w}=g.current;r.fillStyle=p,r.fillRect(0,0,t,n);let T=_(t,n);if(S.length<2||h.length===0||w.k<2){T?.keep([]),T?.render(),r.fillStyle=m,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`Select ≥ 2 axes`,f+8,s+8);return}let E=t-f-l,D=n-s-d,O=w.k,k=Array.from({length:O},(e,t)=>f+t/(O-1)*E),A=(e,t)=>{let n=w.extents[t];return s+(1-(e-n.lo)/(n.hi-n.lo))*D},j=Math.max(.05,Math.min(.7,60/h.length));if(T)v.current!==w&&(w.groups.forEach((e,t)=>T.setLine(`c${t}`,e.x,e.y,XG(e.color,j),1,e.starts)),v.current=w,CH(u.current)),T.keep(w.groups.map((e,t)=>`c${t}`)),T.setView(0,O-1,0,1,{left:f,top:s,width:E,height:D}),T.render();else{r.globalAlpha=j;for(let e of w.groups){r.beginPath();let t=!1;for(let n=0;n<e.x.length;n++){let i=e.y[n];if(e.starts[n]&&(t=!1),i!==i){t=!1;continue}let a=f+e.x[n]/(O-1)*E,o=s+(1-i)*D;t?r.lineTo(a,o):(r.moveTo(a,o),t=!0)}r.strokeStyle=e.color,r.lineWidth=1,r.stroke()}r.globalAlpha=1}a.strokeStyle=m,a.lineWidth=1.5;for(let e=0;e<O;e++)a.beginPath(),a.moveTo(k[e],s),a.lineTo(k[e],s+D),a.stroke();a.fillStyle=m,a.font=`9px ${Q.mono}`;for(let e=0;e<O;e++){let t=w.extents[e];for(let n of[0,.25,.5,.75,1]){let r=t.lo+n*(t.hi-t.lo),i=A(r,e);a.beginPath(),a.moveTo(k[e]-3,i),a.lineTo(k[e]+3,i),a.stroke(),a.textAlign=e===O-1?`left`:`right`,a.textBaseline=`middle`,a.fillText(jz(r,(t.hi-t.lo)/4),k[e]+(e===O-1?5:-5),i)}a.font=`10px ${Q.mono}`,a.textAlign=`center`,a.textBaseline=`bottom`,a.fillText(S[e],k[e],s-4)}let M=h.colorLabels??[];if(!C&&M.length>0&&M.length<=10){let e=f,t=s+D+8;a.font=`9px ${Q.mono}`,a.textBaseline=`top`,M.forEach((n,r)=>{a.fillStyle=CJ[r%CJ.length],a.fillRect(e,t,10,8),a.fillStyle=m,a.textAlign=`left`,a.fillText(n,e+13,t),e+=a.measureText(n).width+26,e>f+E-40&&(e=f,t+=12)})}}function C(){let e=l.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=f.current;if(i===null)return;let{top:a,right:o,bottom:s,left:c}=SJ,{axes:u}=g.current;if(u.length<2)return;let d=t-c-o,p=c+i/(u.length-1)*d;r.strokeStyle=`rgba(255,255,255,0.6)`,r.lineWidth=2,r.beginPath(),r.moveTo(p,a-4),r.lineTo(p,a+(n-a-s)+4),r.stroke()}let w=K(S);w.current=S;let T=K(null);T.current??=DH(()=>w.current(),()=>u.current);let E=()=>T.current.schedule(),D=()=>{xH(p.current),p.current=bH(C)};return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{d.current=null,E()},[i]),G(()=>{let e=u.current;if(!e)return;let t=new EH(()=>{d.current=null,E(),D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=l.current;if(!e)return;let t=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{axes:r}=g.current;if(r.length<2)return;let i=n.width-SJ.left-SJ.right,a=r.length,o=t.clientX-n.left-SJ.left,s=Math.round(o/i*(a-1));f.current=Math.abs(o-s/(a-1)*i)<20&&s>=0&&s<a?s:null,D()},r=()=>{f.current=null,D()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:u,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Parallel coordinates`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:l,className:`chart-canvas chart-overlay`})]})}function OJ(e,t,n,r,i,a){let o=Math.max(1,Math.ceil(t/r)),s=Math.max(1,Math.ceil(n/r)),c=e=>{let s=i(e),c=a(e);return s>=0&&s<t&&c>=0&&c<n?Math.floor(c/r)*o+Math.floor(s/r):-1},l=new Uint32Array(o*s+1);for(let t=0;t<e;t++){let e=c(t);e>=0&&l[e+1]++}for(let e=0;e<o*s;e++)l[e+1]+=l[e];let u=l.slice(0,o*s),d=new Uint32Array(l[o*s]);for(let t=0;t<e;t++){let e=c(t);e>=0&&(d[u[e]++]=t)}return{cell:r,nx:o,ny:s,start:l,ix:d}}function kJ(e,t,n,r,i,a,o){let s=Math.floor(t/e.cell),c=Math.floor(n/e.cell),l=-1,u=r*r;for(let r=c-1;r<=c+1;r++)if(!(r<0||r>=e.ny))for(let c=s-1;c<=s+1;c++){if(c<0||c>=e.nx)continue;let s=r*e.nx+c;for(let r=e.start[s];r<e.start[s+1];r++){let s=e.ix[r],c=(i(s)-t)**2+(a(s)-n)**2;c<u&&(!o||c<o(s)**2)&&(u=c,l=s)}}return l<0?null:l}var AJ={top:16,right:16,bottom:16,left:16},jJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function MJ(e){return[Math.round(255*Math.min(1,Math.max(0,3.5*e-.5))),Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e))),Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))]}function NJ(e){let[t,n,r]=MJ(e);return`rgb(${t},${n},${r})`}var PJ=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...MJ(t/255),255],t*4);return e})(),FJ=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=XG(jJ[t%jJ.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e});function IJ(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(let t=0;t<e.length;t++){let o=e.x[t],s=e.y[t];o<n&&(n=o),o>r&&(r=o),s<i&&(i=s),s>a&&(a=s)}let o=!Number.isFinite(n)||!Number.isFinite(i)?{xLo:-1,xHi:1,yLo:-1,yHi:1}:(()=>{let e=(r-n)*.05||.5,t=(a-i)*.05||.5;return{xLo:n-e,xHi:r+e,yLo:i-t,yHi:a+t}})(),s={lo:0,hi:1},c=null,l=`single`;if(t&&e.colorValue){let t=e.colorValue,n=1/0,r=-1/0;for(let i=0;i<e.length;i++){let e=t[i];e<n&&(n=e),e>r&&(r=e)}Number.isFinite(n)&&(s={lo:n,hi:r}),c=new Float32Array(e.length);let i=s.hi-s.lo;for(let n=0;n<e.length;n++)c[n]=t[n]===t[n]?Math.max(0,Math.min(1,i>0?(t[n]-s.lo)/i:.5)):0;l=`colormap`}else !t&&e.colorIndex&&(c=Float32Array.from(e.colorIndex,e=>e>=0?e%256:0),l=`dataset`);return{ext:o,colorExt:s,key:c,mode:l}}function LJ({points:e,color:t=`#64748b`,colorByNumeric:n=!1,pointSize:r=4,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(0),p=K(a);G(()=>{p.current=a},[a]);let m=dt(()=>IJ(e,n),[e,n]),h=K({points:e,color:t,colorByNumeric:n,pointSize:r,model:m});G(()=>{h.current={points:e,color:t,colorByNumeric:n,pointSize:r,model:m}},[e,t,n,r,m]);let g=K({r:null,failed:!1,size:``,model:null,style:``});W(()=>()=>{g.current.r?.dispose(),g.current.r=null},[]);function _(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function v(){let e=l.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function y(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function b(e,t){let{top:n,right:r,bottom:i,left:a}=AJ,o=e-a-r,s=t-n-i,c=h.current.model.ext;return{xToPx:e=>a+(e-c.xLo)/(c.xHi-c.xLo)*o,yToPx:e=>n+(1-(e-c.yLo)/(c.yHi-c.yLo))*s,plotW:o,plotH:s,ext:c}}function x(e,t){let n=g.current;!n.r&&!n.failed&&s.current&&(n.r=uH(s.current,qW),n.failed=!n.r);let r=n.r;if(!r||!s.current)return null;let i=Math.min(2,window.devicePixelRatio||1),a=`${e}x${t}@${i}`;n.size!==a&&(r.resize(e,t,i),s.current.style.width=`${e}px`,s.current.style.height=`${t}px`,n.size=a);let{points:o,model:c,color:u,pointSize:d}=h.current;n.model!==c&&(r.setData(o.x,o.y,c.key??void 0),n.model=c,CH(l.current));let f=`${c.mode}|${u}|${d}`;return n.style!==f&&(r.setStyle(c.mode===`single`?{kind:`single`,rgba:XG(u,1)}:{kind:c.mode,palette:c.mode===`colormap`?PJ:FJ()},d,.8),r.setDraw(!0,!1,0),n.style=f),r}function S(){let e=o.current;if(!e)return;let{w:t,h:n}=v(),r=y(e,t,n);if(!r)return;let{bg:i,muted:a}=_(),{points:s,color:c,colorByNumeric:l,pointSize:u,model:d}=h.current;r.fillStyle=i,r.fillRect(0,0,t,n);let f=x(t,n);if(s.length===0){f?.setData([],[]),g.current.model=null,f?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,AJ.left+8,AJ.top+8);return}let p=d.colorExt,{xToPx:m,yToPx:S,plotW:C,plotH:w,ext:T}=b(t,n);if(f)f.setView(T.xLo,T.xHi,T.yLo,T.yHi,{left:AJ.left,top:AJ.top,width:C,height:w}),f.render();else{for(let e=0;e<s.length;e++){let t=s.x[e],n=s.y[e];if(t!==t||n!==n)continue;let i=d.key?.[e]??0;r.beginPath(),r.arc(m(t),S(n),u,0,Math.PI*2),r.fillStyle=d.mode===`colormap`?NJ(i):d.mode===`dataset`?jJ[i%jJ.length]:c,r.globalAlpha=.8,r.fill()}r.globalAlpha=1}if(l){let e=Math.min(120,Math.floor((n-AJ.top-AJ.bottom)*.4)),i=t-AJ.right-12,o=AJ.top+8;for(let t=0;t<e;t++)r.fillStyle=NJ(1-t/(e-1)),r.fillRect(i,o+t,8,1);r.fillStyle=a,r.font=`9px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`;let s=e=>Math.abs(e)>=1e4||Math.abs(e)<.001&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(3)));r.fillText(s(p.hi),i+10,o),r.fillText(s(p.lo),i+10,o+e)}let E=s.colorLabels??[];if(!l&&E.length>0&&E.length<=10){let e=AJ.left,i=n-AJ.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`,E.forEach((n,o)=>{e>t-AJ.right-60&&(e=AJ.left,i-=14),r.fillStyle=jJ[o%jJ.length],r.beginPath(),r.arc(e+4,i+4,4,0,Math.PI*2),r.fill(),r.fillStyle=a,r.textAlign=`left`,r.fillText(n,e+10,i),e+=r.measureText(n).width+20})}}function C(){let e=c.current;if(!e)return;let{w:t,h:n}=v(),r=y(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=d.current;if(i===null)return;let{points:a,pointSize:o}=h.current;if(i<0||i>=a.length)return;let{xToPx:s,yToPx:l}=b(t,n),u=a.x[i],f=a.y[i],p=s(u),m=l(f);r.beginPath(),r.arc(p,m,o+3,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let g=[],_=a.label?.(i);_&&g.push(_);let x=a.colorIndex?.[i];x!==void 0&&x>=0&&a.colorLabels?g.push(a.colorLabels[x]):a.colorValue&&g.push(a.colorValue[i].toFixed(3)),g.push(`(${u.toFixed(3)}, ${f.toFixed(3)})`);let S=g.join(` · `);r.font=`11px ${Q.mono}`;let C=r.measureText(S).width,w=Math.max(4,Math.min(t-C-8,p+10)),T=m-20<AJ.top?m+10:m-20;r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(w-3,T-3,C+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(S,w,T)}let w=K(S);w.current=S;let T=K(null);T.current??=DH(()=>w.current(),()=>l.current);let E=()=>T.current.schedule(),D=()=>{xH(f.current),f.current=bH(C)};return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{u.current=null,E()},[i]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,E(),D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=c.current;if(!e)return;let t=null,n=e=>{e.preventDefault(),p.current?.({clientX:e.clientX,clientY:e.clientY})},r=n=>{let r=e.getBoundingClientRect(),{points:i,pointSize:a,model:o}=h.current,{w:s,h:c}=v(),{xToPx:l,yToPx:u,plotW:f,plotH:p}=b(s,c),m=e=>l(i.x[e])-AJ.left,g=e=>u(i.y[e])-AJ.top,_=a+8,y=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==y)&&(t={model:o,key:y,g:OJ(i.length,f,p,_,m,g)}),d.current=kJ(t.g,n.clientX-r.left-AJ.left,n.clientY-r.top-AJ.top,_,m,g),D()},i=()=>{d.current=null,D()};return e.addEventListener(`contextmenu`,n),e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,i),()=>{e.removeEventListener(`contextmenu`,n),e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,i)}},[]),_t(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Embedding / scatter`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`})]})}var RJ={top:8,right:8,bottom:8,left:8},zJ=20,BJ=[`#f97316`,`#fb923c`,`#fdba74`,`#fbbf24`,`#fcd34d`,`#4ade80`,`#34d399`,`#38bdf8`,`#818cf8`,`#a78bfa`];function VJ(e){let t=new Map;for(let n of e){let e=n.parent??``;t.has(e)||t.set(e,[]),t.get(e).push(n)}function n(r,i){let a=(t.get(r)??[]).map(e=>n(e.name,i+1)),o=e.find(e=>e.name===r),s=a.reduce((e,t)=>e+t.value,0);return{name:r,value:o?Math.max(o.value,s):s,children:a,depth:i,x0:0,x1:1}}let r=new Set(e.map(e=>e.name)),i=e.filter(e=>!e.parent||!r.has(e.parent)).map(e=>n(e.name,0)),a=i.reduce((e,t)=>e+t.value,0)||1;function o(e,t,n){e.x0=t,e.x1=n;let r=n-t,i=t;for(let t of e.children){let n=t.value/e.value*r;o(t,i,i+n),i+=n}}let s=0;for(let e of i){let t=e.value/a;o(e,s,s+t),s+=t}return i}function HJ(e){let t=[];function n(e){t.push(e);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function UJ(e){let t=0;function n(e){e.depth>t&&(t=e.depth);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function WJ(e){return BJ[e%BJ.length]}function GJ({nodes:e,direction:t=`bottomup`,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(r);G(()=>{u.current=r},[r]);let d=K({nodes:e,direction:t});G(()=>{d.current={nodes:e,direction:t}},[e,t]);let f=dt(()=>{let t=VJ(e);return{roots:t,flat:HJ(t),numRows:UJ(t)+1}},[e]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function h(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(e,t,n,r,i){let a=RJ.left+e.x0*t,o=(e.x1-e.x0)*t;return{x:a,y:i===`topdown`?RJ.top+e.depth*zJ:RJ.top+n-(e.depth+1)*zJ,w:o,h:zJ-1}}function v(){let e=i.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{bg:a,muted:o}=m(),{nodes:s,direction:c}=d.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),s.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,RJ.left+8,RJ.top+8);return}let{flat:l,numRows:u}=p.current,f=t-RJ.left-RJ.right,v=u*zJ;for(let e of l){let t=_(e,f,v,u,c);if(!(t.w<1)&&(r.fillStyle=WJ(e.depth),r.fillRect(t.x,t.y,t.w,t.h),t.w>24)){r.fillStyle=`rgba(0,0,0,0.75)`,r.font=`${Math.min(11,zJ-4)}px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`;let n=e.name,i=Math.floor((t.w-4)/7),a=n.length>i?n.slice(0,i-1)+`…`:n;r.fillText(a,t.x+3,t.y+zJ/2)}}}function y(){let e=a.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(!i)return;let{direction:o}=d.current,{roots:s,numRows:l}=p.current;if(s.length===0)return;let u=_(i,t-RJ.left-RJ.right,l*zJ,l,o);r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.strokeRect(u.x+1,u.y+1,u.w-2,u.h-2);let f=`${i.name} (${i.value.toLocaleString()})`;r.font=`11px ${Q.mono}`;let m=r.measureText(f).width,v=Math.max(4,Math.min(t-m-8,u.x+u.w/2-m/2)),y=u.y<30?u.y+zJ+4:u.y-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(v-3,y-3,m+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(f,v,y)}let b=K(v);b.current=v;let x=K(null);x.current??=DH(()=>b.current(),()=>o.current);let S=()=>x.current.schedule(),C=()=>{xH(l.current),l.current=bH(y)};return W(()=>{x.current.now()}),W(()=>()=>x.current?.cancel(),[]),W(()=>{s.current=null,S()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,S(),C()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{direction:r}=d.current,{roots:i,flat:a,numRows:o}=p.current;if(i.length===0){c.current=null,C();return}let s=t.clientX-n.left,l=t.clientY-n.top,u=n.width-RJ.left-RJ.right,f=o*zJ,m=null;for(let e of a){let t=_(e,u,f,o,r);if(s>=t.x&&s<=t.x+t.w&&l>=t.y&&l<=t.y+t.h){m=e;break}}c.current=m,C()},r=()=>{c.current=null,C()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Flame graph`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var KJ={top:24,right:24,bottom:52,left:56},qJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],JJ=.8;function YJ(e,t,n,r){let i,a,o;if(t)a=t.length,i=t.values,o=e=>String(e+1);else{let t=e??[];a=t.length,i=Array.from({length:n},(e,n)=>Float64Array.from(t,e=>e.values[n]??0)),o=e=>t[e].label}let s=0,c=0;if(r===`stacked`)for(let e=0;e<a;e++){let t=0,n=0;for(let r of i){let i=r[e];i>0?t+=i:i<0&&(n+=i)}t>c&&(c=t),n<s&&(s=n)}else for(let e of i)for(let t=0;t<a;t++){let n=e[t];n>c&&(c=n),n<s&&(s=n)}return c===s&&(c=s+1),{n:a,values:i,label:o,lo:s,hi:c}}function XJ(e,t,n){let r=e.values.length,i=[],a=[],o=[],s=[],c=[],l=(e,t,n,r,l)=>{i.push(e),a.push(t),o.push(n),s.push(r),c.push(l)};if(e.n<=n)for(let n=0;n<e.n;n++)if(t===`grouped`){let t=.8/r;for(let i=0;i<r;i++){let r=e.values[i][n];r===r&&l(n-.4+i*t,n-.4+(i+1)*t-t*.05,0,r,i)}}else{let t=0,i=0;for(let a=0;a<r;a++){let r=e.values[a][n];r!==r||r===0||(r>0?(l(n-.4,n+.4,t,t+r,a),t+=r):(l(n-.4,n+.4,i,i+r,a),i+=r))}}else{let i=e.n/n,a=new Float64Array(r),o=new Float64Array(r);for(let s=0;s<n;s++){let n=Math.floor(s*i),c=Math.min(e.n,Math.floor((s+1)*i));if(!(c<=n)){a.fill(0),o.fill(0);for(let i=n;i<c;i++){let n=0,s=0;for(let c=0;c<r;c++){let r=e.values[c][i];r===r&&(t===`stacked`?r>0?(n+=r,n>o[c]&&(o[c]=n)):(s+=r,s<a[c]&&(a[c]=s)):(r>o[c]&&(o[c]=r),r<a[c]&&(a[c]=r)))}}for(let e=t===`stacked`?r-1:0;t===`stacked`?e>=0:e<r;t===`stacked`?e--:e++)(o[e]!==0||a[e]!==0)&&l(n-.5,c-.5,a[e],o[e],e)}}}return{x0:Float64Array.from(i),x1:Float64Array.from(a),y0:Float64Array.from(o),y1:Float64Array.from(s),k:Float64Array.from(c)}}function ZJ({groups:e,columns:t,seriesNames:n,colors:r,mode:i=`grouped`,horizontal:a=!1,valueRange:o,backgroundToken:s=``,onPlotContextMenu:c}){let l=nU(),u=K(null),d=K(null),f=K(null),p=K(null),m=K(null),h=K(null),g=K(0),_=K(c);G(()=>{_.current=c},[c]);let v=K(null),y=dt(()=>{let r=[e,i,n.length,t?.length,...t?.values??[]],a=v.current;if(a&&a.key.length===r.length&&a.key.every((e,t)=>e===r[t]))return a.value;let o=YJ(e,t,n.length,i);return v.current={key:r,value:o},o},[e,t,n.length,i]),b=K({bars:y,seriesNames:n,colors:r,mode:i,horizontal:a,valueRange:o});G(()=>{b.current={bars:y,seriesNames:n,colors:r,mode:i,horizontal:a,valueRange:o}},[y,n,r,i,a,o]);let x=K({plot:null,failed:!1,key:``,data:null,size:``});W(()=>()=>{x.current.plot?.dispose(),x.current.plot=null},[]);let S=K({bars:null,view:``});function C(){if(m.current)return m.current;let e=p.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return m.current=n,n}function w(){let e=p.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function T(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function E(e){let t=b.current.colors??[];return Array.from({length:e},(e,n)=>t[n]??qJ[n%qJ.length])}function D(e,t){let{bars:n,valueRange:r}=b.current,i=n.lo,a=n.hi;r?.min!==void 0&&Number.isFinite(r.min)&&(i=r.min),r?.max!==void 0&&Number.isFinite(r.max)&&(a=r.max);let o=YW(KJ,e,t),{top:s,right:c,bottom:l,left:u}=o;return{lo:i,hi:a,top:s,left:u,plotW:e-u-c,plotH:t-s-l,tiny:o.tiny}}function O(e,t){let n=x.current;if(!n.plot&&!n.failed&&d.current&&(n.plot=uH(d.current,IK),n.failed=!n.plot),!n.plot||!d.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),d.current.style.width=`${e}px`,d.current.style.height=`${t}px`,n.size=i),n.plot}function k(){let e=u.current;if(!e)return;let{w:t,h:n}=w(),r=T(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=C(),{bars:s,seriesNames:c,mode:d,horizontal:f}=b.current;r.fillStyle=i,r.fillRect(0,0,t,n);let m=O(t,n);if(s.n===0||c.length===0){m?.keep([]),m?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,KJ.left+8,KJ.top+8);return}let{lo:h,hi:g,top:_,left:v,plotW:y,plotH:k,tiny:A}=D(t,n),j=E(c.length),M=f?k:y,N=e=>f?v+(e-h)/(g-h)*y:_+k-(e-h)/(g-h)*k,P=e=>(f?_:v)+(e+.5)/s.n*M;l({left:v,top:_,width:y,height:k,...f?{x:{v0:h,v1:g}}:{y:{v0:h,v1:g}}}),r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<=5;e++){let t=h+e/5*(g-h),n=N(t);r.beginPath(),f?(r.moveTo(n,_),r.lineTo(n,_+k)):(r.moveTo(v,n),r.lineTo(v+y,n)),r.stroke(),r.fillStyle=a,r.font=`9px ${Q.mono}`,!A&&(f?(r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(g-h)/5),n,_+k+4)):(r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(t,(g-h)/5),v-4,n)))}let F=`${h}|${g}|${f}`;(S.current.bars!==s||S.current.view!==F)&&(S.current={bars:s,view:F},CH(p.current));let I=Math.min(2,window.devicePixelRatio||1),L=Math.max(1,Math.round(M*I)),R=j.map(e=>{let t=zV(e);return[t[0],t[1],t[2],JJ]}),z={left:v,top:_,width:y,height:k};if(m){let e=`${d}|${f}|${L}|${j.join(`,`)}`;if(x.current.key!==e||x.current.data!==s){let t=XJ(s,d,L);f?m.setRects(`bars`,t.y0,t.y1,t.x0,t.x1,R,t.k):m.setRects(`bars`,t.x0,t.x1,t.y0,t.y1,R,t.k),m.keep([`bars`]),x.current.key=e,x.current.data=s}f?m.setView(h,g,s.n-.5,-.5,z):m.setView(-.5,s.n-.5,h,g,z),m.render()}else{let e=XJ(s,d,L);r.globalAlpha=JJ;for(let t=0;t<e.x0.length;t++){r.fillStyle=j[e.k[t]];let n=P(e.x0[t]-.5),i=P(e.x1[t]-.5),a=N(e.y0[t]),o=N(e.y1[t]);f?r.fillRect(Math.min(a,o),n,Math.max(1,Math.abs(o-a)),Math.max(1,i-n)):r.fillRect(n,Math.min(a,o),Math.max(1,i-n),Math.max(1,Math.abs(o-a)))}r.globalAlpha=1}if(h<0&&g>0){let e=N(0);r.strokeStyle=a,r.lineWidth=1.5,r.beginPath(),f?(r.moveTo(e,_),r.lineTo(e,_+k)):(r.moveTo(v,e),r.lineTo(v+y,e)),r.stroke()}r.fillStyle=a,r.font=`9px ${Q.mono}`;let B=Math.max(1,Math.ceil(s.n/Math.max(1,Math.floor(M/(f?14:48)))));for(let e=0;e<(A?0:s.n);e+=B){let t=P(e),n=s.label(e),i=n.length>14?n.slice(0,13)+`…`:n;f?(r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(i,v-4,t)):(r.textAlign=`center`,r.textBaseline=`top`,r.fillText(i,t,_+k+4))}if(c.length>1&&!A){let e=f?_-14:_+k+32,t=v;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<c.length&&(r.fillStyle=j[n],r.fillRect(t,e,10,8),r.fillStyle=a,r.textAlign=`left`,r.fillText(c[n],t+13,e),t+=r.measureText(c[n]).width+26,!(t>v+y-30));n++);}}function A(){let e=f.current;if(!e)return;let{w:t,h:n}=w(),r=T(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=h.current,{bars:a,seriesNames:o,horizontal:s}=b.current;if(i===null||i>=a.n)return;let{top:c,left:l,plotW:u,plotH:d}=D(t,n),p=s?d:u,m=(s?c:l)+(i+.5)/a.n*p,g=Math.max(1,p/a.n);r.fillStyle=`rgba(255,255,255,0.08)`,s?r.fillRect(l,m-g/2,u,g):r.fillRect(m-g/2,c,g,d);let _=a.values.map((e,t)=>`${o.length>1?o[t]+` `:``}${Mz(e[i])}`).join(` `),v=`${a.label(i)}: ${_}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,x=s?l+u/2:m,S=s?m:c+d/2,C=Math.max(4,Math.min(t-y-8,x-y/2)),E=S-28<c?S+10:S-24;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(C-3,E-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,E)}let j=K(k);j.current=k;let M=K(null);M.current??=DH(()=>j.current(),()=>p.current);let N=()=>{g.current||=bH(()=>{g.current=0,A()})};return W(()=>{M.current.now()},[y,n,r,i,a,o]),W(()=>()=>{M.current?.cancel(),xH(g.current)},[]),W(()=>{m.current=null,M.current.schedule()},[s]),G(()=>{let e=p.current;if(!e)return;let t=new EH(()=>{m.current=null,M.current.schedule(),N()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=f.current;if(!e)return;let t=e=>{e.preventDefault(),_.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{bars:r,horizontal:i}=b.current,{w:a,h:o}=w(),{top:s,left:c,plotW:l,plotH:u}=D(a,o),d=i?t.clientY-n.top-s:t.clientX-n.left-c,f=i?u:l,p=d>=0&&d<f&&r.n>0?Math.min(r.n-1,Math.floor(d/f*r.n)):null;p!==h.current&&(h.current=p,N())},r=()=>{h.current=null,N()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:p,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:u,className:`chart-canvas`,role:`img`,"aria-label":`Bar chart`}),q(`canvas`,{ref:d,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:f,className:`chart-canvas chart-overlay`})]})}var QJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function $J(e,t){if(!t)return QJ[e%QJ.length];if(e===0)return t;let n=QJ.filter(e=>e.toLowerCase()!==t.toLowerCase());return n[(e-1)%n.length]}var eY={top:36,right:36,bottom:36,left:36};function tY({axes:e,series:t,fill:n=!0,color:r,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(a);G(()=>{u.current=a},[a]);let d=K({axes:e,series:t,fill:n,color:r});G(()=>{d.current={axes:e,series:t,fill:n,color:r}},[e,t,n,r]);function f(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function p(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=o.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;let{bg:i,muted:a,grid:s}=f(),{axes:c,series:l,fill:u}=d.current;if(r.fillStyle=i,r.fillRect(0,0,t,n),c.length<3||l.length===0){r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`Select ≥ 3 axes`,eY.left+8,eY.top+8);return}let h=c.length,g=t/2,_=n/2,v=Math.min(t-eY.left-eY.right,n-eY.top-eY.bottom)/2,y=c.map((e,t)=>{let n=0;for(let e of l){let r=e.values[t]??0;r>n&&(n=r)}return n||1});function b(e){return Math.PI*2*e/h-Math.PI/2}function x(e,t){let n=b(e);return{x:g+Math.cos(n)*v*t,y:_+Math.sin(n)*v*t}}for(let e=1;e<=4;e++){let t=e/4;r.beginPath();for(let e=0;e<h;e++){let n=x(e,t);e===0?r.moveTo(n.x,n.y):r.lineTo(n.x,n.y)}r.closePath(),r.strokeStyle=s,r.lineWidth=1,r.stroke()}r.strokeStyle=a,r.lineWidth=1;for(let e=0;e<h;e++){let t=x(e,1);r.beginPath(),r.moveTo(g,_),r.lineTo(t.x,t.y),r.stroke(),r.fillStyle=a,r.font=`10px ${Q.mono}`;let n=b(e),i=x(e,1+10/v);r.textAlign=Math.abs(Math.cos(n))<.1?`center`:Math.cos(n)<0?`right`:`left`,r.textBaseline=Math.abs(Math.sin(n))<.1?`middle`:Math.sin(n)<0?`bottom`:`top`;let o=c[e].length>12?c[e].slice(0,11)+`…`:c[e];r.fillText(o,i.x,i.y)}for(let e=0;e<l.length;e++){let t=l[e],n=$J(e,d.current.color);r.beginPath();for(let e=0;e<h;e++){let n=Math.max(0,Math.min(1,(t.values[e]??0)/y[e])),i=x(e,n);e===0?r.moveTo(i.x,i.y):r.lineTo(i.x,i.y)}r.closePath(),u&&(r.fillStyle=n,r.globalAlpha=.15,r.fill()),r.globalAlpha=1,r.strokeStyle=n,r.lineWidth=1,r.stroke();for(let e=0;e<h;e++){let i=Math.max(0,Math.min(1,(t.values[e]??0)/y[e])),a=x(e,i);r.beginPath(),r.arc(a.x,a.y,3,0,Math.PI*2),r.fillStyle=n,r.globalAlpha=.9,r.fill()}r.globalAlpha=1}if(l.length>1){let e=eY.left,i=n-eY.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<l.length&&(r.fillStyle=$J(n,d.current.color),r.fillRect(e,i,10,8),r.fillStyle=a,r.textAlign=`left`,r.fillText(l[n].name,e+13,i),e+=r.measureText(l[n].name).width+26,!(e>t-eY.right-30));n++);}}let g=K(h);g.current=h;let _=K(null);_.current??=DH(()=>g.current(),()=>c.current);let v=()=>_.current.schedule();return W(()=>{_.current.now()}),W(()=>()=>_.current?.cancel(),[]),W(()=>{l.current=null,v()},[i]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,v()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>{e.removeEventListener(`contextmenu`,t)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Radar chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var nY={top:16,right:16,bottom:40,left:52},rY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function iY(e,t){let n=e.length>0&&e.every(t=>t.x===e[0].x||t.x.length===e[0].x.length),r=t&&n,i=e.map(e=>e.x),a=[],o=[],s=null;for(let t of e){if(!r){a.push(t.y),o.push(null);continue}let e=t.x.length,n=new Float64Array(e);for(let r=0;r<e;r++){let e=t.y[r];n[r]=(s?s[r]:0)+(e>0?e:0)}a.push(n),o.push(s??null),s=n}let c=1/0,l=-1/0,u=0,d=0;for(let e of i)for(let t=0;t<e.length;t++){let n=e[t];n<c&&(c=n),n>l&&(l=n)}for(let e of a)for(let t=0;t<e.length;t++){let n=e[t];n<u&&(u=n),n>d&&(d=n)}return Number.isFinite(c)||(c=0,l=1),{x:i,lo:o,hi:a,ascending:i.map(e=>GK(e)),xLo:c,xHi:l,yLo:u,yHi:d}}function aY({series:e,stacked:t=!1,yRange:n,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(0),p=K(i);G(()=>{p.current=i},[i]);let m=K(null),h=dt(()=>{let n=m.current;if(n&&n.stacked===t&&n.series.length===e.length&&n.series.every((t,n)=>t.x===e[n].x&&t.y===e[n].y&&t.name===e[n].name))return n.value;let r=iY(e,t);return m.current={series:e,stacked:t,value:r},r},[e,t]),g=K({series:e,prepared:h,yRange:n});G(()=>{g.current={series:e,prepared:h,yRange:n}},[e,h,n]);let _=K({plot:null,failed:!1,key:``,size:``});W(()=>()=>{_.current.plot?.dispose(),_.current.plot=null},[]);let v=K({prepared:null,view:``});function y(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function b(){let e=l.current;return{w:Math.max(1,e?.clientWidth||600),h:Math.max(1,e?.clientHeight||300)}}function x(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function S(e,t){let n=(e.xHi-e.xLo)*.01||.5,r=e.yLo,i=e.yHi;return i===r&&(i=r+1),i+=(i-r)*.05,t?.min!==void 0&&Number.isFinite(t.min)&&(r=t.min),t?.max!==void 0&&Number.isFinite(t.max)&&(i=t.max),{xLo:e.xLo-n,xHi:e.xHi+n,yLo:r,yHi:i}}function C(e,t,n,r,i){let a=e.x[t],o=e.hi[t],s=e.lo[t];if(!e.ascending[t]||a.length<=2*i)return{x:a,hi:o,lo:s??new Float64Array(a.length)};let c=HK(a,o,n,r,i);return{x:WK(a,c),hi:WK(o,c),lo:s?WK(s,c):new Float64Array(c.length)}}function w(){let e=o.current;if(!e)return;let{w:n,h:r}=b(),i=x(e,n,r);if(!i)return;let{bg:s,muted:c,grid:u}=y(),{series:d,prepared:f,yRange:p}=g.current;i.fillStyle=s,i.fillRect(0,0,n,r);let m=_.current.plot;if(d.length===0){m?.keep([]),m?.render(),i.fillStyle=c,i.font=`13px ${Q.sans}`,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(`No data`,nY.left+8,nY.top+8);return}let h=YW(nY,n,r),{top:w,right:D,bottom:O,left:k}=h,A=n-k-D,j=r-w-O,{xLo:M,xHi:N,yLo:P,yHi:F}=S(f,p),I=e=>k+(e-M)/(N-M)*A,L=e=>w+j-(e-P)/(F-P)*j;a({left:k,top:w,width:A,height:j,x:{v0:M,v1:N},y:{v0:P,v1:F}}),i.strokeStyle=u,i.lineWidth=1;for(let e=0;e<=5;e++){let t=P+e/5*(F-P),n=L(t);i.beginPath(),i.moveTo(k,n),i.lineTo(k+A,n),i.stroke(),i.fillStyle=c,i.font=`9px ${Q.mono}`,i.textAlign=`right`,i.textBaseline=`middle`,h.tiny||i.fillText(jz(t,(F-P)/5),k-4,n)}let R=Math.min(8,f.x[0]?.length??5);for(let e=0;e<=R;e++){let t=M+e/R*(N-M),n=I(t);i.beginPath(),i.moveTo(n,w),i.lineTo(n,w+j),i.stroke(),i.fillStyle=c,i.font=`9px ${Q.mono}`,i.textAlign=`center`,i.textBaseline=`top`,h.tiny||i.fillText(jz(t,(N-M)/R),n,w+j+4)}let z=`${M}|${N}|${P}|${F}`;(v.current.prepared!==f||v.current.view!==z)&&(v.current={prepared:f,view:z},CH(l.current));let B=E(n,r),V=Math.min(2,window.devicePixelRatio||1),ee=Math.max(1,Math.round(A*V)),te=d.map((e,t)=>zV(rY[t%rY.length]));if(B){let e=`${M}|${N}|${ee}`;if(_.current.key!==e||T.current!==f){let n=[];for(let e=0;e<d.length;e++){let r=C(f,e,M,N,ee),i=te[e],a=[i[0],i[1],i[2],f.lo[e]||t?.7:.25];B.setBands(`b${e}`,r.x,r.lo,r.hi,a),B.setLine(`l${e}`,r.x,r.hi,i,1),n.push(`b${e}`,`l${e}`)}B.keep(n),_.current.key=e,T.current=f}B.setView(M,N,P,F,{left:k,top:w,width:A,height:j}),B.render()}else for(let e=0;e<d.length;e++){let n=C(f,e,M,N,ee),r=rY[e%rY.length];i.save(),i.beginPath(),i.rect(k,w,A,j),i.clip(),i.beginPath();for(let e=0;e<n.x.length;e++){let t=I(n.x[e]);e===0?i.moveTo(t,L(n.lo[e])):i.lineTo(t,L(n.lo[e]))}for(let e=n.x.length-1;e>=0;e--)i.lineTo(I(n.x[e]),L(n.hi[e]));i.closePath(),i.fillStyle=r,i.globalAlpha=f.lo[e]||t?.7:.25,i.fill(),i.beginPath();for(let e=0;e<n.x.length;e++){let t=I(n.x[e]),r=L(n.hi[e]);e===0?i.moveTo(t,r):i.lineTo(t,r)}i.globalAlpha=1,i.strokeStyle=r,i.lineWidth=1,i.stroke(),i.restore()}if(d.length>1&&!h.tiny){let e=k,t=w+j+24;i.font=`9px ${Q.mono}`,i.textBaseline=`top`;for(let n=0;n<d.length&&(i.fillStyle=rY[n%rY.length],i.fillRect(e,t,10,8),i.fillStyle=c,i.textAlign=`left`,i.fillText(d[n].name,e+13,t),e+=i.measureText(d[n].name).width+26,!(e>k+A-30));n++);}}let T=K(null);function E(e,t){let n=_.current;if(!n.plot&&!n.failed&&s.current&&(n.plot=uH(s.current,IK),n.failed=!n.plot),!n.plot||!s.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),s.current.style.width=`${e}px`,s.current.style.height=`${t}px`,n.size=i),n.plot}function D(){let e=c.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=d.current;if(i===null)return;let{prepared:a,yRange:o}=g.current,{top:s,right:l,left:u,bottom:f}=YW(nY,t,n),p=n-s-f;r.strokeStyle=`rgba(255,255,255,0.4)`,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(i,s),r.lineTo(i,s+p),r.stroke(),r.setLineDash([]);let{xLo:m,xHi:h}=S(a,o),_=t-u-l,v=`x=${Mz(m+(i-u)/_*(h-m))}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,C=Math.max(4,Math.min(t-y-8,i-y/2));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(C-3,s-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,s)}let O=K(w);O.current=w;let k=K(null);k.current??=DH(()=>O.current(),()=>l.current);let A=()=>{f.current||=bH(()=>{f.current=0,D()})};return W(()=>{k.current.now()},[e,h,n]),W(()=>()=>{k.current?.cancel(),xH(f.current)},[]),W(()=>{u.current=null,k.current.schedule()},[r]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,k.current.schedule(),A()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=c.current;if(!e)return;let t=e=>{e.preventDefault(),p.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();d.current=t.clientX-n.left,A()},r=()=>{d.current=null,A()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Area chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`})]})}var oY={top:16,right:16,bottom:40,left:52},sY=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function cY({series:e,complement:t=!1,logX:n=!1,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({series:e,complement:t,logX:n});G(()=>{p.current={series:e,complement:t,logX:n}},[e,t,n]);let m=dt(()=>{let t=e.map(e=>Float64Array.from(e.values).sort()),n=1/0,r=-1/0;for(let e of t)e.length&&(n=Math.min(n,e[0]),r=Math.max(r,e[e.length-1]));return{all:t,xLo:n,xHi:r}},[e]),h=K(m);G(()=>{h.current=m},[m]);function g(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function _(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function v(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function y(){let e=o.current;if(!e)return;let{w:t,h:n}=_(),r=v(e,t,n);if(!r)return;let{bg:i,muted:s,grid:c}=g(),{series:l,complement:u,logX:d}=p.current;if(r.fillStyle=i,r.fillRect(0,0,t,n),l.length===0){r.fillStyle=s,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,oY.left+8,oY.top+8);return}let{top:f,right:m,bottom:y,left:b}=oY,x=t-b-m,S=n-f-y,{xLo:C,xHi:w}=h.current;Number.isFinite(C)||(C=0,w=1);let T=e=>Math.log10(Math.max(1e-10,e)),E=d?T(C):C,D=d?T(w):w,O=e=>b+((d?T(e):e)-E)/(D-E||1)*x,k=e=>f+S-e*S;a({left:b,top:f,width:x,height:S,x:{v0:C,v1:w,log:d}});for(let e=0;e<=5;e++){let t=e/5,n=k(t);r.strokeStyle=c,r.lineWidth=1,r.beginPath(),r.moveTo(b,n),r.lineTo(b+x,n),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(String(t.toFixed(2)),b-4,n)}for(let e=0;e<=6;e++){let t=C+e/6*(w-C),n=O(t);r.strokeStyle=c,r.lineWidth=1,r.beginPath(),r.moveTo(n,f),r.lineTo(n,f+S),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(w-C)/6),n,f+S+4)}for(let e=0;e<l.length;e++){let t=h.current.all[e],n=t?.length??0;if(n===0)continue;let i=e=>k(u?1-(e+1)/n:(e+1)/n),a=O(t[0]),o=k(+!!u);r.beginPath(),r.moveTo(a,o);for(let e=0;e<n;e++){if(e+1<n&&t[e+1]===t[e])continue;let s=O(t[e]),c=i(e);if(Math.abs(s-a)<.5){o=c;continue}r.lineTo(a,o),r.lineTo(s,o),a=s,o=c}r.lineTo(a,o),r.strokeStyle=sY[e%sY.length],r.lineWidth=1,r.stroke()}if(l.length>1){let e=b,t=f+S+24;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<l.length&&(r.fillStyle=sY[n%sY.length],r.fillRect(e,t,16,2),r.fillStyle=s,r.textAlign=`left`,r.fillText(l[n].name,e+20,t-3),e+=r.measureText(l[n].name).width+30,!(e>b+x-30));n++);}r.save(),r.translate(12,f+S/2),r.rotate(-Math.PI/2),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(u?`CCDF`:`CDF`,0,0),r.restore()}function b(){let e=s.current;if(!e)return;let{w:t,h:n}=_(),r=v(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,left:o,right:c}=oY,l=n-a-oY.bottom,d=t-o-c;r.strokeStyle=`rgba(255,255,255,0.4)`,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(i,a),r.lineTo(i,a+l),r.stroke(),r.setLineDash([]);let{xLo:f,xHi:p}=h.current;if(!Number.isFinite(f))return;let m=Mz(f+(i-o)/d*(p-f));r.font=`11px ${Q.mono}`;let g=r.measureText(m).width,y=Math.max(4,Math.min(t-g-8,i-g/2));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(y-3,a+l+2,g+6,16),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(m,y,a+l+4)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>c.current);let C=()=>S.current.schedule(),w=()=>{xH(d.current),d.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{l.current=null,C()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,w()},r=()=>{u.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`CDF chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var lY={top:16,right:40,bottom:40,left:52},uY=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function dY(e){return[Math.round(255*Math.min(1,Math.max(0,3.5*e-.5))),Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e))),Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))]}function fY(e){let[t,n,r]=dY(e);return`rgb(${t},${n},${r})`}var pY=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...dY(t/255),255],t*4);return e})(),mY=()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=XG(uY[t%uY.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e};function hY(e,t,n){let r=e.length,i=1/0,a=-1/0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(let t=0;t<r;t++){let n=e.x[t],r=e.y[t],u=e.size[t];n<i&&(i=n),n>a&&(a=n),r<o&&(o=r),r>s&&(s=r),u<c&&(c=u),u>l&&(l=u)}let u=Number.isFinite(i)?(()=>{let e=(a-i)*.1||1,t=(s-o)*.1||1;return{xLo:i-e,xHi:a+e,yLo:o-t,yHi:s+t,sLo:c,sHi:l}})():{xLo:-1,xHi:1,yLo:-1,yHi:1,sLo:1,sHi:1},d=u.sHi-u.sLo||1,f=new Float32Array(r);for(let t=0;t<r;t++)f[t]=3+(e.size[t]-u.sLo)/d*(n-3);let p=0,m=1,h=null,g=`single`;if(t&&e.colorValue){let t=e.colorValue,n=1/0,i=-1/0;for(let e=0;e<r;e++)t[e]<n&&(n=t[e]),t[e]>i&&(i=t[e]);Number.isFinite(n)&&(p=n,m=i),h=new Float32Array(r);for(let e=0;e<r;e++)h[e]=t[e]===t[e]?Math.max(0,Math.min(1,(t[e]-p)/(m-p||1))):0;g=`colormap`}else !t&&e.colorIndex&&(h=Float32Array.from(e.colorIndex,e=>e>=0?e%256:0),g=`dataset`);let _=Uint32Array.from({length:r},(e,t)=>t).sort((e,t)=>(f[t]||0)-(f[e]||0)),v=e=>{let t=new Float64Array(r);for(let n=0;n<r;n++)t[n]=e[_[n]];return t};return{ext:u,radius:f,key:h,mode:g,colorLo:p,colorHi:m,drawn:{x:v(e.x),y:v(e.y),r:v(f),k:h?v(h):void 0}}}function gY({points:e,color:t=`#64748b`,colorByNumeric:n=!1,maxRadius:r=24,backgroundToken:i=``,onPlotContextMenu:a}){let o=nU(),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(null),p=K(0),m=K(a);G(()=>{m.current=a},[a]);let h=dt(()=>hY(e,n,r),[e,n,r]),g=K({points:e,color:t,colorByNumeric:n,maxRadius:r,model:h});G(()=>{g.current={points:e,color:t,colorByNumeric:n,maxRadius:r,model:h}},[e,t,n,r,h]);let _=K({r:null,failed:!1,size:``,model:null,style:``});W(()=>()=>{_.current.r?.dispose(),_.current.r=null},[]);function v(){if(d.current)return d.current;let e=u.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return d.current=n,n}function y(){let e=u.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function b(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function x(e,t){let{xLo:n,xHi:r,yLo:i,yHi:a}=g.current.model.ext,{top:s,right:c,bottom:l,left:u}=lY,d=e-u-c,f=t-s-l;return o({left:u,top:s,width:d,height:f,x:{v0:n,v1:r},y:{v0:i,v1:a}}),{plotW:d,plotH:f,xToPx:e=>u+(e-n)/(r-n)*d,yToPx:e=>s+(1-(e-i)/(a-i))*f}}function S(e,t){let n=_.current;!n.r&&!n.failed&&c.current&&(n.r=uH(c.current,qW),n.failed=!n.r);let r=n.r;if(!r||!c.current)return null;let i=Math.min(2,window.devicePixelRatio||1),a=`${e}x${t}@${i}`;n.size!==a&&(r.resize(e,t,i),c.current.style.width=`${e}px`,c.current.style.height=`${t}px`,n.size=a);let{model:o,color:s}=g.current;n.model!==o&&(r.setData(o.drawn.x,o.drawn.y,o.drawn.k,!1,o.drawn.r),n.model=o,CH(u.current));let l=`${o.mode}|${s}`;return n.style!==l&&(r.setStyle(o.mode===`single`?{kind:`single`,rgba:XG(s,1)}:{kind:o.mode,palette:o.mode===`colormap`?pY:mY()},3,.65),r.setDraw(!0,!1,0),n.style=l),r}function C(){let e=s.current;if(!e)return;let{w:t,h:n}=y(),r=b(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=v(),{points:c,color:l,colorByNumeric:u,model:d}=g.current;r.fillStyle=i,r.fillRect(0,0,t,n);let f=S(t,n);if(c.length===0){f?.setData([],[]),_.current.model=null,f?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,lY.left+8,lY.top+8);return}let{xLo:p,xHi:m,yLo:h,yHi:C}=d.ext,{top:w,left:T}=lY,{plotW:E,plotH:D,xToPx:O,yToPx:k}=x(t,n);r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<=5;e++){let t=p+e/5*(m-p),n=O(t);r.beginPath(),r.moveTo(n,w),r.lineTo(n,w+D),r.stroke(),r.fillStyle=a,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(m-p)/5),n,w+D+4);let i=h+e/5*(C-h),o=k(i);r.beginPath(),r.moveTo(T,o),r.lineTo(T+E,o),r.stroke(),r.fillStyle=a,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(i,(C-h)/5),T-4,o)}if(f)f.setView(p,m,h,C,{left:T,top:w,width:E,height:D}),f.render();else{let e=d.drawn;r.globalAlpha=.65;for(let t=0;t<e.x.length;t++){if(e.x[t]!==e.x[t]||e.y[t]!==e.y[t])continue;let n=e.k?.[t]??0;r.fillStyle=d.mode===`colormap`?fY(n):d.mode===`dataset`?uY[n%uY.length]:l,r.beginPath(),r.arc(O(e.x[t]),k(e.y[t]),e.r[t],0,Math.PI*2),r.fill()}r.globalAlpha=1}let A=c.colorLabels??[];if(!u&&A.length>0&&A.length<=10){let e=T,t=n-lY.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<A.length;n++){let i=A[n];if(r.fillStyle=uY[n%uY.length],r.beginPath(),r.arc(e+4,t+4,4,0,Math.PI*2),r.fill(),r.fillStyle=a,r.textAlign=`left`,r.fillText(i,e+10,t),e+=r.measureText(i).width+20,e>T+E-60)break}}}function w(){let e=l.current;if(!e)return;let{w:t,h:n}=y(),r=b(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=f.current;if(i===null)return;let{points:a,model:o}=g.current;if(i<0||i>=a.length)return;let{xToPx:s,yToPx:c}=x(t,n),u=o.radius[i],d=s(a.x[i]),p=c(a.y[i]);r.beginPath(),r.arc(d,p,u+2,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let m=[],h=a.label?.(i);h&&m.push(h),m.push(`(${Mz(a.x[i])}, ${Mz(a.y[i])})`),m.push(`size=${Mz(a.size[i])}`);let _=a.colorIndex?.[i];_!==void 0&&_>=0&&a.colorLabels?m.push(a.colorLabels[_]):a.colorValue&&m.push(Mz(a.colorValue[i]));let v=m.join(` · `);r.font=`11px ${Q.mono}`;let S=r.measureText(v).width,C=Math.max(4,Math.min(t-S-8,d+u+4)),w=p-20<lY.top?p+u+4:p-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(C-3,w-3,S+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,w)}let T=K(C);T.current=C;let E=K(null);E.current??=DH(()=>T.current(),()=>u.current);let D=()=>E.current.schedule(),O=()=>{xH(p.current),p.current=bH(w)};return W(()=>{E.current.now()}),W(()=>()=>E.current?.cancel(),[]),W(()=>{d.current=null,D()},[i]),G(()=>{let e=u.current;if(!e)return;let t=new EH(()=>{d.current=null,D(),O()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=l.current;if(!e)return;let t=null,n=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})},r=n=>{let r=e.getBoundingClientRect(),{points:i,maxRadius:a,model:o}=g.current,{w:s,h:c}=y(),{plotW:l,plotH:u,xToPx:d,yToPx:p}=x(s,c),m=e=>d(i.x[e])-lY.left,h=e=>p(i.y[e])-lY.top,_=a+6,v=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==v)&&(t={model:o,key:v,g:OJ(i.length,l,u,_,m,h)}),f.current=kJ(t.g,n.clientX-r.left-lY.left,n.clientY-r.top-lY.top,_,m,h,e=>o.radius[e]+6),O()},i=()=>{f.current=null,O()};return e.addEventListener(`contextmenu`,n),e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,i),()=>{e.removeEventListener(`contextmenu`,n),e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,i)}},[]),_t(`div`,{ref:u,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:s,className:`chart-canvas`,role:`img`,"aria-label":`Bubble chart`}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:l,className:`chart-canvas chart-overlay`})]})}var _Y={top:8,right:8,bottom:8,left:8},vY=[`#f97316`,`#38bdf8`,`#4ade80`,`#a78bfa`,`#fbbf24`,`#fb7185`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function yY(e){let t=new Map;for(let n of e){let e=n.parent??``;t.has(e)||t.set(e,[]),t.get(e).push(n)}function n(r,i){let a=(t.get(r)??[]).map(e=>n(e.name,i+1)),o=e.find(e=>e.name===r),s=a.reduce((e,t)=>e+t.value,0);return{name:r,value:o?Math.max(o.value,s):s,children:a,depth:i}}let r=new Set(e.map(e=>e.name));return e.filter(e=>!e.parent||!r.has(e.parent)).map(e=>n(e.name,0))}function bY(e,t,n,r,i,a){if(e.length===0||r<=0||i<=0||e.reduce((e,t)=>e+t.value,0)===0)return[];let o=[],s=[...e].sort((e,t)=>t.value-e.value),c=t,l=n,u=r,d=i;for(;s.length>0;){let e=u*d,t=s.reduce((e,t)=>e+t.value,0),n=e/t,r=[],i=1/0;for(let e=1;e<=s.length;e++){let a=s.slice(0,e),o=a.reduce((e,t)=>e+t.value,0)/t*(u<=d?d:u),c=0;for(let e of a){let t=e.value*n/o,r=Math.max(t/o,o/t);r>c&&(c=r)}if(c<i)i=c,r=a;else break}let f=r.reduce((e,t)=>e+t.value,0),p=u<=d,m=f/t*(p?d:u),h=0;for(let e of r){let t=e.value/f,n=p?u:t*u,r=p?t*d:d,i=p?c:c+h,s=p?l+h:l,g=p?m:n,_=p?r:m;if(o.push({node:e,x:i,y:s,w:g,h:_,depth:a}),e.children.length>0&&g>4&&_>4){let t=bY(e.children,i+1,s+1,g-2,_-2,a+1);for(let e of t)o.push(e)}h+=p?r:n}s=s.slice(r.length),p?(c+=m,u-=m):(l+=m,d-=m)}return o}function xY({nodes:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=K(null),i=K(null),a=K(null),o=K(null),s=K([]),c=K(null),l=K(0),u=K(n);G(()=>{u.current=n},[n]);let d=K({nodes:e});G(()=>{d.current={nodes:e}},[e]);let f=dt(()=>yY(e),[e]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(o.current)return o.current;let e=a.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return o.current=n,n}function h(){let e=a.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=r.current;if(!e)return;let{w:t,h:n}=h(),i=g(e,t,n);if(!i)return;let{bg:a,muted:o}=m(),{nodes:l}=d.current;if(i.fillStyle=a,i.fillRect(0,0,t,n),l.length===0){i.fillStyle=o,i.font=`13px ${Q.sans}`,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(`No data`,_Y.left+8,_Y.top+8);return}let u=p.current,f=t-_Y.left-_Y.right,_=n-_Y.top-_Y.bottom,v=bY(u,_Y.left,_Y.top,f,_,0);s.current=v;for(let e=0;e<v.length;e++){let{node:t,x:n,y:r,w:o,h:s,depth:l}=v[e];if(o<2||s<2)continue;let u=vY[l%vY.length],d=c.current===e;if(i.fillStyle=u,i.globalAlpha=d?.95:.75,i.fillRect(n,r,o,s),i.globalAlpha=1,i.strokeStyle=a,i.lineWidth=1,i.strokeRect(n,r,o,s),o>20&&s>14){i.fillStyle=`rgba(0,0,0,0.75)`,i.font=`${Math.min(11,s-4)}px ${Q.mono}`,i.textAlign=`left`,i.textBaseline=`top`;let e=Math.floor((o-4)/6),a=t.name.length>e?t.name.slice(0,e-1)+`…`:t.name;i.fillText(a,n+3,r+3)}}i.globalAlpha=1}function v(){let e=i.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let a=c.current;if(a===null)return;let o=s.current;if(a<0||a>=o.length)return;let{node:l,x:u,y:d,w:f,h:p}=o[a];r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.strokeRect(u+1,d+1,f-2,p-2);let m=`${l.name}: ${l.value.toLocaleString()}`;r.font=`11px ${Q.mono}`;let _=r.measureText(m).width,v=Math.max(4,Math.min(t-_-8,u+f/2-_/2)),y=d<30?d+p+4:d-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(v-3,y-3,_+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(m,v,y)}let y=K(_);y.current=_;let b=K(null);b.current??=DH(()=>y.current(),()=>a.current);let x=()=>b.current.schedule(),S=()=>{xH(l.current),l.current=bH(v)};return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{o.current=null,x()},[t]),G(()=>{let e=a.current;if(!e)return;let t=new EH(()=>{o.current=null,x(),S()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=i.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=s.current,o=null;for(let e=0;e<a.length;e++){let t=a[e];r>=t.x&&r<=t.x+t.w&&i>=t.y&&i<=t.y+t.h&&(o=e)}c.current=o,S()},r=()=>{c.current=null,S()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:a,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:r,className:`chart-canvas`,role:`img`,"aria-label":`Treemap`}),q(`canvas`,{ref:i,className:`chart-canvas chart-overlay`})]})}var SY={top:8,right:8,bottom:8,left:8},CY=14,wY=8,TY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function EY(e,t,n,r){if(e.length===0||t.length===0)return{nodes:[],links:[]};let i=n-SY.left-SY.right,a=r-SY.top-SY.bottom,o=new Map;for(let t of e)o.set(t,0);let s=!0;for(;s;){s=!1;for(let e of t){let t=o.get(e.source)??0;(o.get(e.target)??0)<=t&&(o.set(e.target,t+1),s=!0)}}let c=Math.max(0,...Array.from(o.values())),l=e=>SY.left+e/Math.max(1,c)*(i-CY),u=new Map;for(let[e,t]of o)u.has(t)||u.set(t,[]),u.get(t).push(e);let d=new Map;for(let t of e)d.set(t,0);for(let e of t)d.set(e.source,(d.get(e.source)??0)+e.value),d.set(e.target,(d.get(e.target)??0)+e.value);let f=Math.max(1,...Array.from(d.values())),p=new Map;for(let[t,n]of u){let r=a-(n.length-1)*wY,i=0;for(let e of n)i+=Math.max(8,(d.get(e)??0)/f*r*.8);let o=SY.top+(a-i-(n.length-1)*wY)/2;for(let i=0;i<n.length;i++){let a=n[i],s=Math.max(8,(d.get(a)??0)/f*r*.8);p.set(a,{name:a,x:l(t),y:o,h:s,color:TY[e.indexOf(a)%TY.length]}),o+=s+wY}}let m=new Map,h=new Map;for(let[e,t]of p)m.set(e,t.y),h.set(e,t.y);let g=[];for(let e of t){let t=p.get(e.source),n=p.get(e.target);if(!t||!n)continue;let r=Math.max(1,e.value/f*t.h),i=m.get(e.source)??t.y,a=h.get(e.target)??n.y;m.set(e.source,i+r),h.set(e.target,a+r),g.push({sx:t.x+CY,sy:i+r/2,tx:n.x,ty:a+r/2,h:r,color:t.color,label:`${e.source} → ${e.target}: ${e.value.toLocaleString()}`})}return{nodes:Array.from(p.values()),links:g}}function DY({nodeNames:e,links:t,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K({nodes:[],links:[]}),l=K(null),u=K(0),d=K(r);G(()=>{d.current=r},[r]);let f=K({nodeNames:e,links:t});G(()=>{f.current={nodeNames:e,links:t}},[e,t]);function p(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function m(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function g(){let e=i.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{bg:a,muted:o}=p(),{nodeNames:s,links:u}=f.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),s.length===0||u.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data — set source/target/value columns`,SY.left+8,SY.top+8);return}let d=EY(s,u,t,n);c.current=d;for(let e=0;e<d.links.length;e++){let t=d.links[e],n=l.current===e,i=(t.tx-t.sx)/2;r.beginPath(),r.moveTo(t.sx,t.sy-t.h/2),r.bezierCurveTo(t.sx+i,t.sy-t.h/2,t.tx-i,t.ty-t.h/2,t.tx,t.ty-t.h/2),r.lineTo(t.tx,t.ty+t.h/2),r.bezierCurveTo(t.tx-i,t.ty+t.h/2,t.sx+i,t.sy+t.h/2,t.sx,t.sy+t.h/2),r.closePath(),r.fillStyle=t.color,r.globalAlpha=n?.55:.3,r.fill()}r.globalAlpha=1;for(let e of d.nodes)r.fillStyle=e.color,r.globalAlpha=.9,r.fillRect(e.x,e.y,CY,e.h),r.globalAlpha=1,r.fillStyle=o,r.font=`9px ${Q.mono}`,r.textBaseline=`middle`,e.x>t/2?(r.textAlign=`right`,r.fillText(e.name,e.x-3,e.y+e.h/2)):(r.textAlign=`left`,r.fillText(e.name,e.x+CY+3,e.y+e.h/2));r.globalAlpha=1}function _(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(i===null)return;let o=c.current;if(i<0||i>=o.links.length)return;let s=o.links[i],u=s.label;r.font=`11px ${Q.mono}`;let d=r.measureText(u).width,f=Math.max(4,Math.min(t-d-8,(s.sx+s.tx)/2-d/2)),p=Math.max(4,(s.sy+s.ty)/2-10);r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(f-3,p-3,d+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(u,f,p)}let v=K(g);v.current=g;let y=K(null);y.current??=DH(()=>v.current(),()=>o.current);let b=()=>y.current.schedule(),x=()=>{xH(u.current),u.current=bH(_)};return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{s.current=null,b()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,b(),x()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=c.current,o=null;for(let e=0;e<a.links.length;e++){let t=a.links[e];if(r>=t.sx&&r<=t.tx&&Math.abs(i-(t.sy+t.ty)/2)<t.h/2+6){o=e;break}}l.current=o,x()},r=()=>{l.current=null,x()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Sankey diagram`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var OY={top:24,right:24,bottom:52,left:52};function kY({bins:e,color:t=`#38bdf8`,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(r);G(()=>{u.current=r},[r]);let d=K({bins:e,color:t});G(()=>{d.current={bins:e,color:t}},[e,t]);function f(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function p(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=i.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;let{bg:a,muted:o,grid:s}=f(),{bins:l,color:u}=d.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),l.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,OY.left+8,OY.top+8);return}let{top:h,right:g,bottom:_,left:v}=OY,y=t-v-g,b=n-h-_,x=e=>v+e*y,S=e=>h+(1-e)*b;for(let e=0;e<=5;e++){let t=e/5;r.strokeStyle=s,r.lineWidth=1,r.beginPath(),r.moveTo(v,S(t)),r.lineTo(v+y,S(t)),r.stroke(),r.beginPath(),r.moveTo(x(t),h),r.lineTo(x(t),h+b),r.stroke(),r.fillStyle=o,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(t.toFixed(2),v-4,S(t)),r.textAlign=`center`,r.textBaseline=`top`,r.fillText(t.toFixed(2),x(t),h+b+4)}r.strokeStyle=o,r.lineWidth=1.5,r.setLineDash([6,4]),r.beginPath(),r.moveTo(x(0),S(0)),r.lineTo(x(1),S(1)),r.stroke(),r.setLineDash([]);let C=Math.max(1,...l.map(e=>e.count)),w=b*.15;for(let e of l){let t=Math.max(1,y/l.length*.7),n=x(e.center)-t/2,i=e.count/C*w;r.fillStyle=u,r.globalAlpha=.3,r.fillRect(n,h+b-i,t,i)}r.globalAlpha=1,r.beginPath();for(let e=0;e<l.length;e++){let t=x(l[e].center),n=S(l[e].actual);e===0?r.moveTo(t,n):r.lineTo(t,n)}r.strokeStyle=u,r.lineWidth=1,r.stroke();for(let e=0;e<l.length;e++){let t=c.current===e;r.beginPath(),r.arc(x(l[e].center),S(l[e].actual),t?6:4,0,Math.PI*2),r.fillStyle=u,r.globalAlpha=t?1:.85,r.fill()}r.globalAlpha=1,r.fillStyle=o,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Predicted probability`,v+y/2,n-4),r.save(),r.translate(12,h+b/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Actual rate`,0,0),r.restore()}function g(){let e=a.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(i===null)return;let{bins:o}=d.current;if(i<0||i>=o.length)return;let s=o[i],{top:l,left:u}=OY,f=t-u-OY.right,h=n-l-OY.bottom,g=u+s.center*f,_=l+(1-s.actual)*h,v=`pred=${s.center.toFixed(2)} actual=${s.actual.toFixed(3)} n=${s.count}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,b=Math.max(4,Math.min(t-y-8,g-y/2)),x=_-28<l?_+12:_-24;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(b-3,x-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,b,x)}let _=K(h);_.current=h;let v=K(null);v.current??=DH(()=>_.current(),()=>o.current);let y=()=>v.current.schedule(),b=()=>{xH(l.current),l.current=bH(g)};return W(()=>{v.current.now()}),W(()=>()=>v.current?.cancel(),[]),W(()=>{s.current=null,y()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,y(),b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{bins:r}=d.current,{w:i}=p(),a=t.clientX-n.left,o=i-OY.left-OY.right,s=-1,l=20;for(let e=0;e<r.length;e++){let t=OY.left+r[e].center*o,n=Math.abs(a-t);n<l&&(l=n,s=e)}c.current=s>=0?s:null,b()},r=()=>{c.current=null,b()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Calibration curve`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var AY={top:24,right:24,bottom:48,left:52};function jY({points:e,color:t=`#a78bfa`,backgroundToken:n=``,onPlotContextMenu:r}){let i=nU(),a=K(null),o=K(null),s=K(null),c=K(null),l=K(null),u=K(0),d=K(r);G(()=>{d.current=r},[r]);let f=K({points:e,color:t});G(()=>{f.current={points:e,color:t}},[e,t]);function p(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function m(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function g(){let{points:e}=f.current,t=1/0,n=-1/0,r=1/0,i=-1/0;if(e.length>0&&(t=e.theoretical[0],n=e.theoretical[e.length-1],r=e.sample[0],i=e.sample[e.length-1]),!Number.isFinite(t))return{xLo:-3,xHi:3,yLo:-3,yHi:3};let a=(n-t)*.05||.5,o=(i-r)*.05||.5;return{xLo:t-a,xHi:n+a,yLo:r-o,yHi:i+o}}function _(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{bg:o,muted:s,grid:c}=p(),{points:u,color:d}=f.current;if(r.fillStyle=o,r.fillRect(0,0,t,n),u.length===0){r.fillStyle=s,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,AY.left+8,AY.top+8);return}let{xLo:_,xHi:v,yLo:y,yHi:b}=g(),{top:x,right:S,bottom:C,left:w}=AY,T=t-w-S,E=n-x-C,D=e=>w+(e-_)/(v-_)*T,O=e=>x+(1-(e-y)/(b-y))*E;i({left:w,top:x,width:T,height:E,x:{v0:_,v1:v}}),r.strokeStyle=c,r.lineWidth=1;for(let e=0;e<=5;e++){let t=_+e/5*(v-_),n=D(t);r.beginPath(),r.moveTo(n,x),r.lineTo(n,x+E),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(v-_)/5),n,x+E+4);let i=y+e/5*(b-y),a=O(i);r.beginPath(),r.moveTo(w,a),r.lineTo(w+T,a),r.stroke(),r.fillStyle=s,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(i,(b-y)/5),w-4,a)}let k=Math.max(_,y),A=Math.min(v,b);k<A&&(r.strokeStyle=s,r.lineWidth=1.5,r.setLineDash([6,4]),r.beginPath(),r.moveTo(D(k),O(k)),r.lineTo(D(A),O(A)),r.stroke(),r.setLineDash([])),r.fillStyle=d,r.globalAlpha=.75;let j=NaN,M=NaN;for(let e=0;e<u.length;e++){let t=Math.round(D(u.theoretical[e])),n=Math.round(O(u.sample[e]));t===j&&n===M||(j=t,M=n,r.beginPath(),r.arc(t,n,3,0,Math.PI*2),r.fill())}let N=l.current;N!==null&&N<u.length&&(r.globalAlpha=1,r.beginPath(),r.arc(D(u.theoretical[N]),O(u.sample[N]),5,0,Math.PI*2),r.fill()),r.globalAlpha=1,r.fillStyle=s,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Theoretical quantiles`,w+T/2,n-4),r.save(),r.translate(12,x+E/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Sample quantiles`,0,0),r.restore()}function v(){let e=o.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(i===null)return;let{points:a}=f.current;if(i<0||i>=a.length)return;let s={theoretical:a.theoretical[i],sample:a.sample[i]},{xLo:c,xHi:u,yLo:d,yHi:p}=g(),{top:_,left:v}=AY,y=t-v-AY.right,b=n-_-AY.bottom,x=v+(s.theoretical-c)/(u-c)*y,S=_+(1-(s.sample-d)/(p-d))*b;r.beginPath(),r.arc(x,S,6,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let C=`(${Mz(s.theoretical)}, ${Mz(s.sample)})`;r.font=`11px ${Q.mono}`;let w=r.measureText(C).width,T=Math.max(4,Math.min(t-w-8,x+10)),E=S-20<_?S+10:S-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(T-3,E-3,w+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(C,T,E)}let y=K(_);y.current=_;let b=K(null);b.current??=DH(()=>y.current(),()=>s.current);let x=()=>b.current.schedule(),S=()=>{xH(u.current),u.current=bH(v)};return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{c.current=null,x()},[n]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,x(),S()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{points:r}=f.current,{w:i}=m(),{xLo:a,xHi:o,yLo:s,yHi:c}=g(),{top:u,left:d}=AY,p=i-d-AY.right,h=n.height-u-AY.bottom,_=t.clientX-n.left,v=t.clientY-n.top,y=e=>a+(e-d)/p*(o-a),b=e=>{let t=0,n=r.length;for(;t<n;){let i=t+n>>>1;r.theoretical[i]<e?t=i+1:n=i}return t},x=b(y(_-10)),C=Math.min(r.length,b(y(_+10))+1),w=-1,T=10**2;for(let e=x;e<C;e++){let t=d+(r.theoretical[e]-a)/(o-a)*p,n=u+(1-(r.sample[e]-s)/(c-s))*h,i=(_-t)**2+(v-n)**2;i<T&&(T=i,w=e)}l.current=w>=0?w:null,S()},r=()=>{l.current=null,S()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:a,className:`chart-canvas`,role:`img`,"aria-label":`Q-Q plot`}),q(`canvas`,{ref:o,className:`chart-canvas chart-overlay`})]})}var MY={top:8,right:16,bottom:40,left:120},NY=22,PY=3,FY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function IY({tasks:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=nU(),i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(n);G(()=>{u.current=n},[n]);let d=K({tasks:e});G(()=>{d.current={tasks:e}},[e]);function f(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function p(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=i.current;if(!e)return;let{w:t,h:n}=p(),a=m(e,t,n);if(!a)return;let{bg:o,muted:s,grid:l}=f(),{tasks:u}=d.current;if(a.fillStyle=o,a.fillRect(0,0,t,n),u.length===0){a.fillStyle=s,a.font=`13px ${Q.sans}`,a.textAlign=`left`,a.textBaseline=`top`,a.fillText(`No data`,MY.left+8,MY.top+8);return}let h=1/0,g=-1/0;for(let e of u)e.start<h&&(h=e.start),e.end>g&&(g=e.end);Number.isFinite(h)||(h=0,g=1);let _=(g-h)*.02||1;h-=_,g+=_;let{top:v,right:y,bottom:b,left:x}=MY,S=t-x-y,C=e=>x+(e-h)/(g-h)*S;r({left:x,top:v,width:S,height:n-v-b,x:{v0:h,v1:g}});let w=new Map;for(let e of u){let t=e.group??e.label;w.has(t)||w.set(t,w.size)}let T=Math.min(8,Math.floor(S/60));a.strokeStyle=l,a.lineWidth=1;for(let e=0;e<=T;e++){let t=h+e/T*(g-h),n=C(t),r=u.length*(NY+PY)+v;a.beginPath(),a.moveTo(n,v),a.lineTo(n,r),a.stroke(),a.fillStyle=s,a.font=`9px ${Q.mono}`,a.textAlign=`center`,a.textBaseline=`top`,a.fillText(jz(t,(g-h)/T),n,r+4)}for(let e=0;e<u.length;e++){let t=u[e],n=v+e*(NY+PY),r=FY[(w.get(t.group??t.label)??0)%FY.length],i=c.current===e,o=C(t.start),l=C(t.end),d=Math.max(2,l-o);a.fillStyle=r,a.globalAlpha=i?.95:.75,a.fillRect(o,n,d,NY-PY),a.globalAlpha=1,a.fillStyle=s,a.font=`9px ${Q.mono}`,a.textAlign=`right`,a.textBaseline=`middle`;let f=t.label.length>16?t.label.slice(0,15)+`…`:t.label;a.fillText(f,x-4,n+(NY-PY)/2)}a.globalAlpha=1}function g(){let e=a.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(i===null)return;let{tasks:o}=d.current;if(i<0||i>=o.length)return;let s=o[i],l=s.end-s.start,u=`${s.label}: ${Mz(s.start)} → ${Mz(s.end)} (${Mz(l)})`;r.font=`11px ${Q.mono}`;let f=r.measureText(u).width,h=1/0,g=-1/0;for(let e of o)e.start<h&&(h=e.start),e.end>g&&(g=e.end);let _=(g-h)*.02||1;h-=_,g+=_;let v=t-MY.left-MY.right,y=e=>MY.left+(e-h)/(g-h)*v,b=MY.top+i*(NY+PY),x=(y(s.start)+y(s.end))/2,S=Math.max(4,Math.min(t-f-8,x-f/2)),C=b-22<MY.top?b+NY+4:b-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(S-3,C-3,f+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(u,S,C)}let _=K(h);_.current=h;let v=K(null);v.current??=DH(()=>_.current(),()=>o.current);let y=()=>v.current.schedule(),b=()=>{xH(l.current),l.current=bH(g)};return W(()=>{v.current.now()}),W(()=>()=>v.current?.cancel(),[]),W(()=>{s.current=null,y()},[t]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,y(),b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{tasks:r}=d.current,i=t.clientY-n.top,a=Math.floor((i-MY.top)/(NY+PY));c.current=a>=0&&a<r.length?a:null,b()},r=()=>{c.current=null,b()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Gantt chart`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var LY=e=>[...e].filter(e=>Number.isFinite(e.at)).sort((e,t)=>e.at-t.at),RY=e=>{let t=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[128,128,128]},zY=e=>`#${e.map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`;function BY(e,t,n,r){let i=t?LY(t):[];if(!e||e===`solid`||i.length===0||!Number.isFinite(r))return n;if(e===`zones`){let e=i[0].color;for(let t of i)r>=t.at&&(e=t.color);return e}if(r<=i[0].at)return i[0].color;if(r>=i[i.length-1].at)return i[i.length-1].color;let a=0;for(;i[a+1].at<r;)a++;let o=i[a],s=i[a+1],c=(r-o.at)/(s.at-o.at||1),l=RY(o.color),u=RY(s.color);return zY([l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c])}function VY(e,t,n,r,i,a=96){let o=i-r||1,s=t?LY(t):[];if(!e||e===`solid`||s.length===0)return[{f0:0,f1:1,color:n}];if(e===`zones`){let e=[0,...s.slice(1).map(e=>(e.at-r)/o).filter(e=>e>0&&e<1),1];return e.slice(0,-1).map((t,i)=>({f0:t,f1:e[i+1],color:BY(`zones`,s,n,r+(t+e[i+1])/2*o)}))}return Array.from({length:a},(e,t)=>({f0:t/a,f1:(t+1)/a,color:BY(`gradient`,s,n,r+(t+.5)/a*o)}))}function HY(e,t,n){let r=e=>+(t+e*(n-t)).toPrecision(6),i=`#22c55e`,a=`#ef4444`;if(e===`traffic`)return{mode:`zones`,stops:[{at:r(0),color:i},{at:r(.7),color:`#f5a524`},{at:r(.9),color:a}]};let o=[{at:r(0),color:i},{at:r(.5),color:`#eab308`},{at:r(1),color:a}];return{mode:`gradient`,stops:e===`green-red`?o:o.map((e,t)=>({...e,color:o[o.length-1-t].color}))}}function UY(e,t,n){let r=t?LY(t):[];if(!e||e===`solid`||r.length===0)return n;let i=r[0].at,a=r[r.length-1].at,o=e=>`${((e-i)/(a-i||1)*100).toFixed(1)}%`;if(e===`gradient`)return`linear-gradient(90deg, ${r.map(e=>`${e.color} ${o(e.at)}`).join(`, `)})`;let s=100/r.length;return`linear-gradient(90deg, ${r.map((e,t)=>`${e.color} ${(t*s).toFixed(1)}% ${((t+1)*s).toFixed(1)}%`).join(`, `)})`}var WY=.75*Math.PI,GY=1.5*Math.PI;function KY({gauges:e,live:t,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(r);G(()=>{s.current=r},[r]);let c=K({gauges:e,live:t});G(()=>{c.current={gauges:e,live:t}},[e,t]);let l=K(RH()),u=K(0);function d(){if(o.current)return o.current;let e=a.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`,ink:`#e4e4e7`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`,ink:t.getPropertyValue(`--chart-fg`).trim()||`#e4e4e7`};return o.current=n,n}function f(){let e=i.current,t=a.current;if(!e||!t)return;let n=Math.max(1,t.clientWidth),r=Math.max(1,t.clientHeight),o=Math.min(2,window.devicePixelRatio||1),s=Math.floor(n*o),f=Math.floor(r*o);(e.width!==s||e.height!==f)&&(e.width=s,e.height=f),e.style.width=`${n}px`,e.style.height=`${r}px`;let p=e.getContext(`2d`);if(!p)return;p.setTransform(o,0,0,o,0,0);let h=d(),{gauges:g,live:_}=c.current,v=g;if(_){let e=performance.now(),t=KH(l.current,_.latestT(),e-u.current);u.current=e,v=g.map(e=>{if((e.stat??`last`)!==`last`)return e;let n=_.valueAt(e.name,t);return Number.isFinite(n)?{...e,value:n}:e}),m.current.schedule()}if(p.fillStyle=h.bg,p.fillRect(0,0,n,r),v.length===0){p.fillStyle=h.muted,p.font=`13px ${Q.sans}`,p.textAlign=`left`,p.textBaseline=`top`,p.fillText(`No data`,16,16);return}let{cols:y,rows:b}=qY(v.length,n,r,v.some(e=>e.style===`arc`)?1.15:3.2),x=n/y,S=r/b;v.forEach((e,t)=>{let n=t%y*x,r=Math.floor(t/y)*S;e.style===`arc`?rX(p,e,n,r,x,S,e.color,e.alarm??null,h):iX(p,e,n,r,x,S,e.color,e.alarm??null,h)})}let p=K(f);p.current=f;let m=K(null);return m.current??=DH(()=>p.current(),()=>a.current),W(()=>{m.current.now()}),W(()=>()=>m.current?.cancel(),[]),W(()=>{o.current=null,m.current.schedule()},[n]),G(()=>{let e=a.current;if(!e)return;let t=new EH(()=>{o.current=null,m.current.schedule()});return t.observe(e),()=>t.disconnect()},[]),q(`div`,{ref:a,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Gauges: ${e.map(e=>`${e.name} ${Number.isFinite(e.value)?JY(e.value,e.max-e.min):`no value`}${e.unit?` ${e.unit}`:``}`).join(`, `)}`,onContextMenu:e=>{e.preventDefault(),s.current?.({clientX:e.clientX,clientY:e.clientY})}})})}function qY(e,t,n,r){let i={cols:1,rows:e,size:-1};for(let a=1;a<=e;a++){let o=Math.ceil(e/a),s=t/a,c=n/o,l=Math.min(s,c*r);l>i.size&&(i={cols:a,rows:o,size:l})}return{cols:i.cols,rows:i.rows}}var JY=(e,t)=>jz(e,wz(Math.abs(t),100)),YY=(e,t)=>Math.max(0,Math.min(1,(t-e.min)/(e.max-e.min||1))),XY=(e,t)=>{let n=e.fromZero?YY(e,0):0;return[Math.min(n,t),Math.max(n,t)]},ZY=(e,t)=>!!t&&(t.linked?t.linked===`active`:Number.isFinite(e.value)&&e.value>=t.value),QY=e=>(e.colorMode===`gradient`||e.colorMode===`zones`)&&!!e.stops?.length,$Y=(e,t)=>ZY(e,t)?t.color:BY(e.colorMode,e.stops,e.color,e.value);function eX(e,t,n){for(let r of VY(t.colorMode,t.stops,t.color,t.min,t.max))e.addColorStop(n(r.f0),r.color),e.addColorStop(n(r.f1),r.color);return e}function tX(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return n>0?`${r}…`:``}var nX=Math.SQRT1_2;function rX(e,t,n,r,i,a,o,s,c){let l=Math.max(6,Math.min(i,a)*.06),u=t.max-t.min,d=JY(t.min,u),f=JY(t.max,u),p=e=>Math.max(9,Math.min(22,e*.1)),m=e=>Math.max(4,e*.13),h=Math.max(8,Math.min((i-2*l)/2,(a-2*l)/1.9)),g=0;for(let t=0;t<2;t++){e.font=`${p(h)}px ${Q.mono}`,g=Math.max(e.measureText(d).width,e.measureText(f).width);let t=m(h),n=Math.max(h+t/2,nX*h+g/2),r=h+t/2+nX*h+t/2+6+p(h)*1.2;h=Math.max(8,Math.min(h*(i-2*l)/(2*n),h*(a-2*l)/r))}let _=m(h),v=p(h),y=h+_/2+nX*h+_/2+6+v*1.2,b=n+i/2,x=r+l+h+_/2+Math.max(0,(a-2*l-y)/2),S=e=>WY+e*GY;e.lineCap=`round`,e.lineWidth=_,e.strokeStyle=c.grid,e.beginPath(),e.arc(b,x,h,WY,WY+GY),e.stroke(),s&&s.value<t.max&&(e.globalAlpha=.3,e.strokeStyle=s.color,e.lineCap=`butt`,e.beginPath(),e.arc(b,x,h,S(YY(t,s.value)),WY+GY),e.stroke(),e.globalAlpha=1,e.lineCap=`round`);let[C,w]=XY(t,Number.isFinite(t.value)?YY(t,t.value):0),T=()=>{e.lineCap=t.fromZero?`butt`:`round`,e.beginPath(),e.arc(b,x,h,S(C),Math.max(S(C)+1e-4,S(w))),e.stroke(),e.lineCap=`round`};if(QY(t)){let n=GY/(2*Math.PI),r=eX(e.createConicGradient(WY,b,x),t,e=>e*n);r.addColorStop(1,BY(t.colorMode,t.stops,t.color,t.min)),e.strokeStyle=r,e.globalAlpha=.24,e.beginPath(),e.arc(b,x,h,WY,WY+GY),e.stroke(),e.globalAlpha=1,Number.isFinite(t.value)&&!ZY(t,s)&&T()}if(Number.isFinite(t.value)&&(!QY(t)||ZY(t,s))&&(e.strokeStyle=ZY(t,s)?s.color:o,T()),t.fromZero&&t.min<0&&t.max>0){let n=S(YY(t,0));e.strokeStyle=c.muted,e.lineWidth=1.5,e.lineCap=`butt`,e.beginPath(),e.moveTo(b+Math.cos(n)*(h-_*.75),x+Math.sin(n)*(h-_*.75)),e.lineTo(b+Math.cos(n)*(h+_*.75),x+Math.sin(n)*(h+_*.75)),e.stroke(),e.lineWidth=_,e.lineCap=`round`}if(s&&s.value>=t.min&&s.value<=t.max){let n=S(YY(t,s.value));e.strokeStyle=s.color,e.lineWidth=Math.max(1.5,s.width),e.lineCap=`butt`,e.beginPath(),e.moveTo(b+Math.cos(n)*(h-_*.9),x+Math.sin(n)*(h-_*.9)),e.lineTo(b+Math.cos(n)*(h+_*.9),x+Math.sin(n)*(h+_*.9)),e.stroke();let r=h+_*.9+10*.7;s.linked&&oU(e,b+Math.cos(n)*r-10/2,x+Math.sin(n)*r-10/2,s.color)}let E=Number.isFinite(t.value)?JY(t.value,u):`—`,D=2*(h-_)*.82,O=Math.max(11,h*.42);e.font=`650 ${O}px ${Q.sans}`;let k=e.measureText(E).width;k>D&&(O=Math.max(9,O*D/k),e.font=`650 ${O}px ${Q.sans}`),e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=ZY(t,s)||QY(t)?$Y(t,s):c.ink,e.fillText(E,b,x+O*.32),e.fillStyle=c.muted,t.unit&&(e.font=`600 ${Math.max(9,h*.13)}px ${Q.sans}`,e.fillText(tX(e,t.unit,D),b,x+O*.32+Math.max(11,h*.19)));let A=x+nX*h+_/2+6,j=nX*h;e.textBaseline=`top`,e.font=`${v}px ${Q.mono}`,e.fillText(d,b-j,A),e.fillText(f,b+j,A);let M=2*j-g-16,N=Math.max(10,Math.min(26,h*.13));e.font=`600 ${N}px ${Q.sans}`;let P=e.measureText(t.name).width;P>M&&N>9&&(N=Math.max(9,N*M/P),e.font=`600 ${N}px ${Q.sans}`),e.fillText(tX(e,t.name,M),b,A+(v-N)/2)}function iX(e,t,n,r,i,a,o,s,c){let l=Math.max(14,i*.06),u=n+l,d=n+i-l,f=d-u,p=Math.max(6,Math.min(16,a*.14)),m=Math.max(12,Math.min(34,a*.28)),h=r+a/2+m*.35,g=e=>u+YY(t,e)*f;e.textBaseline=`alphabetic`,e.fillStyle=c.muted,e.font=`600 ${Math.max(10,m*.42)}px ${Q.sans}`,e.textAlign=`left`,e.fillText(tX(e,t.name,f),u,h-p/2-m-4),e.textAlign=`right`,e.fillStyle=ZY(t,s)?s.color:c.ink,e.font=`650 ${m}px ${Q.sans}`;let _=t.unit?(e.font=`600 ${Math.max(9,m*.4)}px ${Q.sans}`,e.measureText(` ${t.unit}`).width):0;t.unit&&(e.fillStyle=c.muted,e.fillText(` ${t.unit}`,d,h-p/2-8)),e.fillStyle=ZY(t,s)||QY(t)?$Y(t,s):c.ink,e.font=`650 ${m}px ${Q.sans}`,e.fillText(Number.isFinite(t.value)?JY(t.value,t.max-t.min):`—`,d-_,h-p/2-8),e.lineCap=`round`,e.lineWidth=p,e.strokeStyle=c.grid,e.beginPath(),e.moveTo(u,h),e.lineTo(d,h),e.stroke(),s&&s.value<t.max&&(e.globalAlpha=.3,e.strokeStyle=s.color,e.lineCap=`butt`,e.beginPath(),e.moveTo(g(s.value),h),e.lineTo(d,h),e.stroke(),e.globalAlpha=1,e.lineCap=`round`);let v=Number.isFinite(t.value)?YY(t,t.value):0,y=e=>u+e*f,[b,x]=XY(t,v),S=()=>{e.lineCap=t.fromZero?`butt`:`round`,e.beginPath(),e.moveTo(y(b),h),e.lineTo(Math.max(y(b)+.5,y(x)),h),e.stroke(),e.lineCap=`round`};QY(t)&&(e.strokeStyle=eX(e.createLinearGradient(u,0,d,0),t,e=>e),e.globalAlpha=.24,e.beginPath(),e.moveTo(u,h),e.lineTo(d,h),e.stroke(),e.globalAlpha=1,Number.isFinite(t.value)&&!ZY(t,s)&&S()),Number.isFinite(t.value)&&(!QY(t)||ZY(t,s))&&(e.strokeStyle=ZY(t,s)?s.color:o,S()),t.fromZero&&t.min<0&&t.max>0&&(e.strokeStyle=c.muted,e.lineWidth=1.5,e.lineCap=`butt`,e.beginPath(),e.moveTo(g(0),h-p*.75),e.lineTo(g(0),h+p*.75),e.stroke(),e.lineWidth=p,e.lineCap=`round`),s&&s.value>=t.min&&s.value<=t.max&&(e.strokeStyle=s.color,e.lineWidth=Math.max(1.5,s.width),e.lineCap=`butt`,e.beginPath(),e.moveTo(g(s.value),h-p),e.lineTo(g(s.value),h+p),e.stroke(),s.linked&&oU(e,g(s.value)-10/2,h-p-10-2,s.color)),e.fillStyle=c.muted,e.font=`${Math.max(9,m*.34)}px ${Q.mono}`,e.textBaseline=`top`,e.textAlign=`left`,e.fillText(JY(t.min,t.max-t.min),u,h+p/2+4),e.textAlign=`right`,e.fillText(JY(t.max,t.max-t.min),d,h+p/2+4)}var aX=720;function oX(e,t){return t?e<aX:e<640}function sX(e){return e<=1?{cols:1,rows:1}:e===2?{cols:2,rows:1}:e<=4?{cols:2,rows:2}:{cols:3,rows:3}}function cX(e,t){return e.flatMap(e=>{let n=e.info?.meta;if(!n?.recordingId)return[];let r=n.wallOrigin?Number(n.wallOrigin):NaN,i=n.wallQuality;return[{recordingId:n.recordingId,wallOrigin:Number.isFinite(r)?r:null,wallQuality:i===`exact`||i===`approx`?i:null,xOffset:t[e.id]??0}]})}var lX={get:()=>null,subscribe:()=>()=>{}};function uX(e){let[t,n]=ft(null);return G(()=>{let t=e.current;if(!t)return;let r=e=>n(t=>oX(e,t??!1));if(r(t.clientWidth),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(e=>{for(let t of e)r(t.contentRect.width)});return i.observe(t),()=>i.disconnect()},[e]),t}function dX(e){let t=Wn(e.settings),[n,r]=ft(null),[i,a]=ft(null),o=K(null);W(()=>{i&&o.current?.querySelector(`[data-camera="${CSS.escape(i)}"]`)?.focus()},[i]);let s=e.recordings??[],c=e=>s.findIndex(t=>t.recordingId===e.recordingId),l=(e.video??[]).filter(e=>e.kind===`recorded`&&c(e)>=0).sort((e,t)=>c(e)-c(t)),u=e.onContextMenu?t=>{t.preventDefault(),e.onContextMenu({clientX:t.clientX,clientY:t.clientY})}:void 0;if(!t.length){let t=[...new Set([...e.live.filter(e=>e.kind===`camera`&&!e.lowOf),...l].map(t=>Vn(t,e.live)))].sort();return q(pX,{onContextMenu:u,title:`Choose a camera in this panel's settings`,detail:t.length?t.join(`, `):void 0})}let d={panel:e,recorded:l,recIndex:c};if(t.length===1)return q(fX,{...d,id:t[0],onMenu:u});let f=n&&t.includes(n)?n:null,p=f?[f]:t,{cols:m,rows:h}=sX(p.length),g=()=>{a(f),r(null)};return _t(`div`,{ref:o,className:`kymo-camera-wall`,style:{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${h}, minmax(0, 1fr))`},onContextMenu:u,onKeyDown:e=>{e.key===`Escape`&&f&&(e.stopPropagation(),g())},children:[p.map(e=>q(fX,{...d,id:e,multi:!0,wall:!f,onPick:f?void 0:()=>{a(null),r(e)}},e)),f?_t(`button`,{type:`button`,className:`kymo-camera__all`,onClick:g,autoFocus:!0,children:[_t(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[q(`rect`,{x:`2`,y:`2`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`9`,y:`2`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`2`,y:`9`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`9`,y:`9`,width:`5`,height:`5`,rx:`1`})]}),`All cameras`]}):null]})}function fX({panel:e,recorded:t,recIndex:n,id:r,multi:i,wall:a,onPick:o,onMenu:s}){let c=e.recordings??[],l={onMenu:s,wall:a,onPick:o},u=t.find(e=>e.id===r);if(u)return q(mX,{...e,...l,source:u,name:i?Vn(u,e.live):u.name,rec:c[n(u)]},`rec:${u.recordingId}:${u.id}`);let d=e.live.find(e=>e.id===r&&e.kind===`camera`);if(!d?.video||d.status===`error`)return q(pX,{onContextMenu:s,title:`Camera offline`,detail:d?Vn(d,e.live):void 0});let f=e.live.find(e=>e.kind===`camera`&&e.lowOf===d.id&&e.video&&e.status!==`error`),p=f?.video?DE({...f,video:f.video}):void 0;return q(mX,{...e,...l,source:DE({...d,video:d.video}),low:p,name:i?Vn(d,e.live):d.name,conn:d},d.id)}function pX({title:e,detail:t,onContextMenu:n}){return q(`div`,{className:`kymo-camera`,onContextMenu:n,children:_t(`div`,{className:`kymo-camera__empty`,children:[_t(`svg`,{className:`kymo-camera__empty-icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[q(`rect`,{x:`2.5`,y:`6`,width:`13`,height:`12`,rx:`2.5`}),q(`path`,{d:`M15.5 10.5 21.5 7v10l-6-3.5`})]}),q(`p`,{className:`kymo-camera__empty-title`,children:e}),t?q(`p`,{className:`kymo-camera__empty-detail`,children:t}):null]})})}function mX(e){let{settings:t,source:n}=e,r=e.cursor??lX,i=pt(r.subscribe,r.get),a=e=>e.kind===`data`,o=e.rec?void 0:t.syncStreamId?e.live.find(e=>e.id===t.syncStreamId&&a(e)):e.live.find(t=>t.id===e.conn.parentId&&a(t))??e.live.find(t=>a(t)&&e.selection.includes(t.id))??e.live.find(a),s=i??e.viewXRange?.[1]??null,c=null,l=null,u=o?.clock?.quality()??`none`;if(e.rec){let{wallOrigin:r,wallQuality:i,xOffset:a}=e.rec;u=i??`none`;let o=n.range()?.[0]??null;s===null?c=o:r===null?(c=o,l=`This recording has no wall clock`):e.xKey===`Time`?c=r+s-a+t.offsetMs/1e3:e.xKey===`ElapsedTime`&&i===`exact`?c=s-a+t.offsetMs/1e3:(c=o,l=`Sync needs a time X axis`)}else s!==null&&(e.xIsTime?(c=o?.clock?.toWall(s,t.offsetMs)??null,c===null&&(l=`No data stream to sync with`)):l=`Sync needs a time X axis`);let d=K(null),f=K(null),p=uX(d),m=p===null?null:e.low&&(p||e.wall)?e.low:n,h=K(t.fit),g=K(c);G(()=>{h.current=t.fit,g.current=c});let _=K(null),v=K(null),[y,b]=ft(null),x=y??m??n,[S,C]=ft(!1),[w,T]=ft(!0);W(()=>{if(!m||_.current?.source===m)return;let e=!_.current,t=null,n=!1,r=()=>t?_.current===t:e,i=t=gX(m,f.current,()=>h.current,g.current,{unsupported:()=>{r()&&C(!0)},buffered:e=>{r()&&T(e)},frame:()=>{if(_.current===t){n||(n=!0,b(m));return}_.current?.dispose(),_.current=i,v.current=null,i.show(),n=!0,b(m),T(i.buffered())}},e);if(e){_.current=i;return}return v.current=i,()=>{_.current!==i&&(i.dispose(),v.current===i&&(v.current=null))}},[m]),W(()=>()=>{_.current?.dispose(),_.current=null},[]),W(()=>{_.current?.setTarget(c),v.current?.setTarget(c)},[c]);let E=!!x.lowOf,D=x.info().latestT,O=!e.rec&&c!==null&&D!==null?c-D:null,k=e.rec?`No video at this time`:`Not buffered`;return _t(`div`,{ref:d,className:`kymo-camera${e.onPick?` is-tile`:``}`,onContextMenu:e.onMenu,...e.onPick?{role:`button`,tabIndex:0,"data-camera":n.id,"aria-label":`Show ${e.name} alone`,onClick:e.onPick,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onPick())}}:{},children:[q(`canvas`,{ref:f,className:`kymo-camera__video`,role:`img`,"aria-label":`Video from ${e.name}`}),S?q(`div`,{className:`kymo-camera__empty`,children:q(`p`,{className:`kymo-camera__empty-title`,children:`This browser can't decode this camera`})}):_t(`div`,{className:`kymo-camera__overlay`,children:[q(`span`,{className:`kymo-camera__name`,children:e.name}),e.rec?q(`span`,{className:`kymo-camera__rec`,children:`Recording`}):c===null?q(`span`,{className:`kymo-camera__live`,children:`LIVE`}):q(`span`,{className:`kymo-camera__ago`,children:O===null?``:hX(O)}),E?q(`span`,{className:`kymo-camera__badge`,title:`Low-quality copy (small panel)`,children:`LQ`}):null,c!==null&&u!==`none`?q(`span`,{className:`kymo-camera__badge${u===`exact`?` is-exact`:``}`,children:u===`exact`?`Exact`:`Approx.`}):null,l??(c!==null&&!w?k:null)?q(`span`,{className:`kymo-camera__note`,children:l??k}):null]})]})}function hX(e){let t=Math.abs(e).toFixed(1);return t===`0.0`?`0.0 s`:`${e<0?`−`:`+`}${t} s`}function gX(e,t,n,r,i,a=!0){let o=e.acquire?.(),s=!1,c=!0,l=e=>{c=e,i.buffered(e)},u=null,d=null,f=r,p=`live`,m=!0,h=!1,g=!1,_=null,v=null,y=null,b=[],x=e=>{if(s){e.close();return}p===`seek`?(_?.close(),_=e):(v?.close(),v=e,i.frame?.())},S=()=>{!d||d.state===`closed`?d=new VideoDecoder({output:x,error:()=>{}}):d.reset(),d.configure(u),m=!0},C=e=>{d?.state===`closed`&&e.key&&S(),!(d?.state!==`configured`||m&&!e.key)&&(m=!1,d.decode(new EncodedVideoChunk({type:e.key?`key`:`delta`,timestamp:Math.round(e.t*1e6),data:e.data})))},w=()=>{p=`live`,l(!0),S();for(let t of e.livePlan?.()??[])C(t)},T=async()=>{if(!h){h=!0;try{for(;!s&&p===`seek`&&g;){g=!1;let t=[];try{t=await e.seekPlan(f)}catch{}if(!(s||p!==`seek`||g)&&(l(t.length>0),t.length)){S();for(let e of t)C(e);try{await d.flush()}catch{}p===`seek`&&_&&(v?.close(),v=_,_=null,i.frame?.())}}}finally{h=!1,_?.close(),_=null}}},E=()=>{f===null?p!==`live`&&w():(p=`seek`,g=!0,T())};e.onUnit&&b.push(e.onUnit(e=>{u&&p===`live`&&C(e)})),(async()=>{if(typeof VideoDecoder>`u`){i.unsupported();return}if(e.info().codec||(e.ready?await e.ready():e.onUnit&&await new Promise(t=>{let n=e.onUnit(()=>{e.info().codec&&(n(),t())});b.push(n)})),s)return;if(!e.info().codec){l(!1);return}let t={codec:e.info().codec,optimizeForLatency:!0,hardwareAcceleration:`no-preference`},n=!1;try{n=(await VideoDecoder.isConfigSupported(t)).supported===!0}catch{}if(!s){if(!n){i.unsupported();return}u=t,f===null?w():E()}})();let D=n(),O=()=>{if(!a)return;let e=window.devicePixelRatio||1,r=Math.max(1,Math.round(t.clientWidth*e)),i=Math.max(1,Math.round(t.clientHeight*e)),o=!1;if((t.width!==r||t.height!==i)&&(t.width=r,t.height=i,o=!0),v&&(y?.close(),y=v,v=null,o=!0),n()!==D&&(D=n(),o=!0),!o||!y)return;let s=t.getContext(`2d`);if(!s)return;let c=y.displayWidth,l=y.displayHeight,u=D===`cover`?Math.max(r/c,i/l):Math.min(r/c,i/l),d=c*u,f=l*u;s.clearRect(0,0,r,i),s.drawImage(y,(r-d)/2,(i-f)/2,d,f)},k=0,A=()=>{k=bH(A),O()};return k=bH(A),{source:e,show(){a=!0},buffered:()=>c,setTarget(e){e!==f&&(f=e,u&&E())},dispose(){s=!0,xH(k),b.forEach(e=>e()),d&&d.state!==`closed`&&d.close();for(let e of[_,v,y])e?.close();_=v=y=null,o?.()}}}function _X(e,t){let n=e.filter(e=>e.x.length>=2&&vX(e.x));if(n.length<2)return null;let r=1/0,i=-1/0;for(let e of n)e.x[0]<r&&(r=e.x[0]),e.x[e.x.length-1]>i&&(i=e.x[e.x.length-1]);if(!(i>r))return null;let a=Math.max(2,t),o=Float64Array.from({length:a},(e,t)=>r+t/(a-1)*(i-r)),s=new Float64Array(a).fill(1/0),c=new Float64Array(a).fill(-1/0),l=new Uint16Array(a);for(let e of n){let t=0;for(let n=0;n<a;n++){let r=o[n];if(r<e.x[0]||r>e.x[e.x.length-1])continue;for(;t<e.x.length-2&&e.x[t+1]<r;)t++;let i=e.x[t],a=e.x[t+1],u=e.y[t],d=e.y[t+1],f=a===i?u:u+(d-u)*(r-i)/(a-i);f-f===0&&(f<s[n]&&(s[n]=f),f>c[n]&&(c[n]=f),l[n]++)}}for(let e=0;e<a;e++)l[e]<2&&(s[e]=NaN,c[e]=NaN);return{x:o,lo:s,hi:c}}function vX(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return!0}function yX(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=new Set,n={};for(let r of e)for(let e=0;e<r.columnNames.length;e++){let i=r.columnNames[e];t.add(i),r.units[e]?.trim()&&(n[i]=r.units[e])}let r=[...t];return{meta:``,columnNames:r,units:r.map(e=>n[e]??``),rows:e.flatMap(e=>e.rows)}}function bX(e,t,n,r,i){return n||e.length===0||(t>0?e.length!==1:e.length<2||r!==`ElapsedTime`)?null:e.map((e,n)=>({conn:e,keySuffix:`__${t+n}`,offset:i[e.id]??0}))}function xX(e,t,n,r,i){if(e.length===1){let a=e[0];return SX(a.conn,t,n,a.keySuffix,a.offset,r,i)}let a=e.map(e=>SX(e.conn,t,n,e.keySuffix,e.offset,[],null)),o=()=>a.reduce((e,t)=>t.latestT()>e.latestT()?t:e);return{pull:(e,t,n,i)=>[...r,...a.flatMap(r=>r.pull(e,t,n,i))],xBounds:()=>{let e=i;for(let t of a){let n=t.xBounds();n&&(e=e?[Math.min(e[0],n[0]),Math.max(e[1],n[1])]:n)}return e},latestX:()=>o().latestX(),version:()=>a.reduce((e,t)=>e+t.version(),0),latestT:()=>o().latestT(),xAtTime:e=>o().xAtTime(e),latestValues:e=>new Map(a.flatMap(t=>[...t.latestValues(e)]))}}function SX(e,t,n,r,i,a,s){let l=null;return{pull:(s,u,d,f)=>{let p=e.source.version();if(!l||l.ver!==p||l.x0!==s||l.x1!==u||l.mp!==d){let a=e.source.getPointsSync(n,{xKey:t,x0:s-i,x1:u-i},d),o=i===0?a.x:a.x.map(e=>e+i);l={ver:p,x0:s,x1:u,mp:d,pts:{...a,x:o,cols:new Map([...a.cols].map(([e,t])=>[e+r,t]))}}}let m=o(l.pts,f);if(t!==`ElapsedTime`)return[...a,m];let h=Math.min(e.source.latestTimeSync(),f===void 0?1/0:f-i),g=c(n,t=>e.source.lastKnownSync(t),s-i,u-i,h);if(!g)return[...a,m];let _=i===0?g.x:g.x.map(e=>e+i);return[...a,m,{...g,x:_,cols:new Map([...g.cols].map(([e,t])=>[e+r,t]))}]},xBounds:()=>{let n=e.source.xBoundsSync(t);return n.x1>n.x0?s?[Math.min(s[0],n.x0+i),Math.max(s[1],n.x1+i)]:[n.x0+i,n.x1+i]:s},latestX:()=>{let n=e.source.latestSync(t);return Number.isFinite(n)?n+i:null},version:()=>e.source.version(),id:e.id,latestT:()=>e.source.latestTimeSync(),xAtTime:n=>e.source.xAtTimeSync(t,n)+i,latestValues:t=>{let n=new Map,i=t.filter(e=>e.endsWith(r)),a=e.source.latestValuesSync(i.map(e=>e.slice(0,-r.length)));for(let e of i){let t=a.get(e.slice(0,-r.length));t!==void 0&&n.set(e,t)}return n}}}function CX(e,t){return e.filter(e=>B(t,e))}var wX=`__ref`,TX=8e3;function EX(e,t){return e.map(e=>({...e,id:`${e.id}${wX}`,column:`${e.column}${wX}`,color:t}))}var DX=new WeakMap;function OX(e,t,r){let i=e.data.rows,a=`${t}\n${r.join(`
|
|
607
|
+
}`,PK=-3e38;function FK(e){for(let t=0;t<e.length;t++)if(e[t]-e[t]===0)return e[t];return 0}function IK(e){let t=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!t)return null;let n=(e,n,i,a)=>lH(t,`glPlot|${e}|${n}`,()=>r(e,n,i,a)),r=(e,n,r,i)=>{let a=WV(t,t.VERTEX_SHADER,e),o=WV(t,t.FRAGMENT_SHADER,n);if(!a||!o)return null;let s=t.createProgram();if(t.attachShader(s,a),t.attachShader(s,o),t.linkProgram(s),!t.getProgramParameter(s,t.LINK_STATUS))return console.error(`glPlot program link failed:`,t.getProgramInfoLog(s)),null;let c=[`u_resolution`,`u_plot`,`u_view`,`u_clip`,`u_dpr`,`u_height`];return{prog:s,shaders:[a,o],a:Object.fromEntries([`a_corner`,...r].map(e=>[e,t.getAttribLocation(s,e)])),u:Object.fromEntries([...c,...i].map(e=>[e,t.getUniformLocation(s,e)]))}},i=n(EK,OK,[`a_xa`,`a_xb`,`a_loa`,`a_lob`,`a_hia`,`a_hib`,`a_bstart`],[`u_color`]),a=n(DK,kK,[`a_x0`,`a_x1`,`a_y0`,`a_y1`,`a_k`],[`u_palette`]),o=n(AK,jK,[`a_ax`,`a_ay`,`a_bx`,`a_by`,`a_bstart`],[`u_color`,`u_half`,`u_ext`]),s=n(MK,NK,[],[`u_extent`,`u_values`,`u_palette`,`u_range`]);if(!i||!a||!o||!s)return null;let c=t.getParameter(t.MAX_TEXTURE_SIZE),l=t.createVertexArray(),u=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,u),t.bufferData(t.ARRAY_BUFFER,Float32Array.from([0,0,1,0,0,1,1,1]),t.STATIC_DRAW);let d=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,d),t.bufferData(t.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),t.STATIC_DRAW);let f=new Map,p=1,m=1,h=1,g={xmin:0,xmax:1,ymin:0,ymax:1},_={left:0,top:0,width:1,height:1},v=new WeakMap,y=new Float32Array,b=e=>{for(let n of Object.values(e.buffers))t.deleteBuffer(n);e.palette&&t.deleteTexture(e.palette),e.values&&t.deleteTexture(e.values)},x=new Float32Array,S=(e,n)=>{t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,n),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE)},C=(e,t)=>{let n=f.get(e);if(n&&n.kind===t)return n;n&&b(n);let r={kind:t,n:0,ox:0,oy:0,buffers:{},color:[0,0,0,1],width:1};return f.set(e,r),r},w=(e,n,r)=>{let i=e.buffers[n]??=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,i),r.byteLength<=(v.get(i)??0)?t.bufferSubData(t.ARRAY_BUFFER,0,r):(t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),v.set(i,r.byteLength))},T=(e,t,n,r)=>{let i=n.length;y.length<i&&(y=new Float32Array(i));for(let e=0;e<i;e++)y[e]=n[e]-r;w(e,t,y.subarray(0,i))},E=(e,t,n)=>{let r=new Uint8Array(e);t&&r.set(t.subarray(0,e)),e&&(r[0]=255);for(let t=0;t<e;t++)n(t)||(r[t]=255,t+1<e&&(r[t+1]=255));return r},D=(e,n,r=0,i=t.FLOAT)=>{if(e<0)return;t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(e);let a=i===t.FLOAT?4:1;t.vertexAttribPointer(e,1,i,i!==t.FLOAT,a,r*a),t.vertexAttribDivisor(e,1)},O=(n,r,i)=>{t.useProgram(n.prog),t.uniform2f(n.u.u_resolution,p,m),t.uniform4f(n.u.u_plot,_.left,_.top,_.width,_.height),t.uniform4f(n.u.u_view,g.xmin-r.ox,g.xmax-r.ox,g.ymin-r.oy,g.ymax-r.oy),t.uniform4f(n.u.u_clip,_.left,_.top,_.left+_.width,_.top+_.height),t.uniform1f(n.u.u_dpr,h),t.uniform1f(n.u.u_height,e.height),t.bindBuffer(t.ARRAY_BUFFER,i),t.enableVertexAttribArray(n.a.a_corner),t.vertexAttribPointer(n.a.a_corner,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(n.a.a_corner,0)},k=e=>{for(let n of Object.values(e.a))n>=0&&t.vertexAttribDivisor(n,0)};return{resize(t,n,r){p=Math.max(1,t),m=Math.max(1,n),h=r,e.width=Math.round(p*h),e.height=Math.round(m*h)},setView(e,t,n,r,i){g={xmin:e,xmax:t,ymin:n,ymax:r},_=i},setBands(e,t,n,r,i,a){let o=C(e,`bands`),s=Math.min(t.length,n.length,r.length);o.ox=FK(t),o.oy=FK(r),T(o,`x`,t,o.ox),T(o,`lo`,n,o.oy),T(o,`hi`,r,o.oy),w(o,`start`,E(s,a,e=>t[e]-t[e]===0&&n[e]-n[e]===0&&r[e]-r[e]===0)),o.n=Math.max(0,s-1),o.color=i},setRects(e,n,r,i,a,o,s){let c=C(e,`rects`),l=Math.min(n.length,r.length,i.length,a.length);c.ox=FK(n),c.oy=FK(i),T(c,`x0`,n,c.ox),T(c,`x1`,r,c.ox),T(c,`y0`,i,c.oy),T(c,`y1`,a,c.oy),s?T(c,`k`,s,0):delete c.buffers.k;let u=new Uint8Array(256*4);for(let e=0;e<256;e++){let t=o[Math.min(e,o.length-1)]??[0,0,0,1];u.set([t[0]*255,t[1]*255,t[2]*255,t[3]*255],e*4)}c.palette??=t.createTexture(),t.bindTexture(t.TEXTURE_2D,c.palette),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,u),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),c.n=l},setLine(e,t,n,r,i,a){let o=C(e,`line`),s=Math.min(t.length,n.length);o.ox=FK(t),o.oy=FK(n),T(o,`x`,t,o.ox),T(o,`y`,n,o.oy),w(o,`start`,E(s,a,e=>t[e]-t[e]===0&&n[e]-n[e]===0)),o.n=Math.max(0,s-1),o.color=r,o.width=i},maxTextureSize:c,setGrid(e,n,r,i,a,o,s,c){let l=C(e,`grid`),u=r*i,d=0;for(let e=0;e<u;e++)d+=n[e]*0;let f=n.subarray(0,u);if(d!==0){x.length<u&&(x=new Float32Array(u));for(let e=0;e<u;e++){let t=n[e];x[e]=t===t?t:PK}f=x.subarray(0,u)}let p=!l.values;l.values??=t.createTexture(),t.bindTexture(t.TEXTURE_2D,l.values),t.pixelStorei(t.UNPACK_ALIGNMENT,4),!p&&l.grid&&l.grid.w===r&&l.grid.h===i?t.texSubImage2D(t.TEXTURE_2D,0,0,0,r,i,t.RED,t.FLOAT,f):(t.texImage2D(t.TEXTURE_2D,0,t.R32F,r,i,0,t.RED,t.FLOAT,f),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),l.palette??=t.createTexture(),S(l.palette,o);let[m,h,g,_]=a;l.ox=m,l.oy=g,l.grid={w:r,h:i,x0:m,x1:h,y0:g,y1:_,vmin:s,vmax:c},l.n=1},setGridRange(e,t,n){let r=f.get(e);r?.grid&&(r.grid.vmin=t,r.grid.vmax=n)},remove(e){let t=f.get(e);t&&(b(t),f.delete(e))},keep(e){let t=new Set(e);for(let e of[...f.keys()])t.has(e)||this.remove(e)},render(){t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,e.width,e.height),t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(l),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA);for(let e of f.values()){if(e.n<=0)continue;let n=e.buffers;if(e.kind===`bands`)O(i,e,u),t.uniform4f(i.u.u_color,...e.color),D(i.a.a_xa,n.x,0),D(i.a.a_xb,n.x,1),D(i.a.a_loa,n.lo,0),D(i.a.a_lob,n.lo,1),D(i.a.a_hia,n.hi,0),D(i.a.a_hib,n.hi,1),D(i.a.a_bstart,n.start,1,t.UNSIGNED_BYTE),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(i);else if(e.kind===`grid`){let n=e.grid;O(s,e,u),t.uniform4f(s.u.u_extent,0,n.x1-n.x0,0,n.y1-n.y0),t.uniform2f(s.u.u_range,n.vmin,n.vmax),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e.values),t.uniform1i(s.u.u_values,0),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,e.palette),t.uniform1i(s.u.u_palette,1),t.drawArrays(t.TRIANGLE_STRIP,0,4),t.activeTexture(t.TEXTURE0)}else e.kind===`rects`?(O(a,e,u),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,e.palette),t.uniform1i(a.u.u_palette,0),D(a.a.a_x0,n.x0),D(a.a.a_x1,n.x1),D(a.a.a_y0,n.y0),D(a.a.a_y1,n.y1),n.k?D(a.a.a_k,n.k):(t.disableVertexAttribArray(a.a.a_k),t.vertexAttrib1f(a.a.a_k,0)),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(a)):(O(o,e,d),t.uniform4f(o.u.u_color,...e.color),t.uniform1f(o.u.u_half,e.width/2),t.uniform1f(o.u.u_ext,e.width/2+1.5),D(o.a.a_ax,n.x,0),D(o.a.a_bx,n.x,1),D(o.a.a_ay,n.y,0),D(o.a.a_by,n.y,1),D(o.a.a_bstart,n.start,1,t.UNSIGNED_BYTE),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,e.n),k(o))}t.bindVertexArray(null)},dispose(){for(let e of f.values())b(e);f.clear(),t.deleteBuffer(u),t.deleteBuffer(d),t.deleteVertexArray(l)}}}function LK(e){let t=K({plot:null,failed:!1,size:``});return W(()=>()=>{t.current.plot?.dispose(),t.current.plot=null},[]),ct((n,r)=>{let i=t.current,a=e.current;if(!i.plot&&!i.failed&&a&&(i.plot=uH(a,IK),i.failed=!i.plot),!i.plot||!a)return null;let o=Math.min(2,window.devicePixelRatio||1),s=`${n}x${r}@${o}`;return i.size!==s&&(i.plot.resize(n,r,o),a.style.width=`${n}px`,a.style.height=`${r}px`,i.size=s),i.plot},[e])}function RK(e){let t=!1;for(let n=0;n<e.length;n++)if(Math.abs(e[n])>Math.PI*2){t=!0;break}let n=new Float64Array(e.length);for(let r=0;r<e.length;r++)n[r]=t?e[r]*Math.PI/180:e[r];return n}var zK=16;function BK(e,t,n,r){let i=RK(e),a=Math.min(i.length,t.length),o=1/0,s=-1/0;for(let e=0;e<a;e++){let n=t[e];n<o&&(o=n),n>s&&(s=n)}let c=n??Math.min(0,o),l=r??s,u=l-c||1,d=new Float64Array(a),f=new Float64Array(a),p=new Float64Array(zK),m=new Int32Array(zK);for(let e=0;e<a;e++){let n=Math.max(0,(t[e]-c)/u),r=i[e];n>1.0001?d[e]=f[e]=NaN:(d[e]=Math.sin(r)*n,f[e]=Math.cos(r)*n);let a=r%(2*Math.PI);a<0&&(a+=2*Math.PI);let o=Math.min(zK-1,Math.floor(a/(2*Math.PI)*zK));p[o]+=t[e],m[o]++}return{n:a,rMin:c,rMax:l,x:d,y:f,means:Array.from({length:zK},(e,t)=>m[t]>0?p[t]/m[t]:0)}}function VK({angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i=`#a78bfa`,mode:a=`waveform`,radiusMin:o,radiusMax:s,height:c=400,backgroundToken:l=``,onPlotContextMenu:u}){let d=K(null),f=K(null),p=K(null),m=K(u);G(()=>{m.current=u},[u]);let h=K({angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i,mode:a,radiusMin:o,radiusMax:s,height:c});G(()=>{h.current={angles:e,radii:t,angleLabel:n,radiusLabel:r,color:i,mode:a,radiusMin:o,radiusMax:s,height:c}},[e,t,n,r,i,a,o,s,c]);let g=dt(()=>BK(e,t,o,s),[e,t,o,s]),_=K(g);G(()=>{_.current=g},[g]);let v=K(null),y=LK(v),b=K({geo:null,color:``});function x(){if(p.current)return p.current;let e=f.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return p.current=n,n}function S(){let e=f.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||h.current.height)}}function C(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function w(){let e=d.current;if(!e)return;let{w:t,h:n}=S(),r=C(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=x(),{angleLabel:s,radiusLabel:c,color:l,mode:u}=h.current,f=_.current,{n:p,rMin:m,rMax:g}=f;r.fillStyle=i,r.fillRect(0,0,t,n);let v=y(t,n);if(p===0){v?.keep([]),v?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,16,16);return}let w=g-m||1,T=(Math.min(t-64,n-32-24)-4)/2,E=t/2,D=32+T,O=wz(w,4),k=Dz(m,g,O);r.strokeStyle=o,r.lineWidth=1,r.setLineDash([3,3]);for(let e of k){let t=(e-m)/w*T;t<0||(r.beginPath(),r.arc(E,D,t,0,Math.PI*2),r.stroke())}r.setLineDash([]),r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<360;e+=30){let t=e*Math.PI/180;r.beginPath(),r.moveTo(E,D),r.lineTo(E+Math.cos(-t+Math.PI/2)*T,D+Math.sin(-t+Math.PI/2)*T),r.stroke()}r.fillStyle=a,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`;for(let e=0;e<360;e+=30){let t=e*Math.PI/180,n=E+Math.sin(t)*(T+14),i=D-Math.cos(t)*(T+14);r.fillText(`${e}°`,n,i)}r.textAlign=`left`,r.textBaseline=`middle`;for(let e of k){let t=(e-m)/w*T;t<4||r.fillText(jz(e,O),E+4,D-t)}if(r.strokeStyle=a,r.lineWidth=1,r.setLineDash([]),r.beginPath(),r.arc(E,D,T,0,Math.PI*2),r.stroke(),r.save(),r.beginPath(),r.arc(E,D,T,0,Math.PI*2),r.clip(),u===`waveform`)if(v)(b.current.geo!==f||b.current.color!==l)&&(v.setLine(`wave`,f.x,f.y,XG(l,.9),1),b.current={geo:f,color:l}),v.keep([`wave`]),v.setView(-1,1,-1,1,{left:E-T,top:D-T,width:T*2,height:T*2}),v.render();else{r.strokeStyle=l,r.lineWidth=1,r.globalAlpha=.9,r.beginPath();let e=!1;for(let t=0;t<p;t++){let n=E+f.x[t]*T,i=D-f.y[t]*T;if(n!==n){e=!1;continue}e?r.lineTo(n,i):(r.moveTo(n,i),e=!0)}r.stroke(),r.globalAlpha=1}else{v?.keep([]),v?.render();let e=f.means,t=Math.max(...e,1e-10),n=2*Math.PI/zK;r.fillStyle=l,r.globalAlpha=.75;for(let i=0;i<zK;i++){let a=e[i]/t*T,o=i*n-Math.PI/2-n/2;r.beginPath(),r.moveTo(E,D),r.arc(E,D,a,o,o+n),r.closePath(),r.fill()}r.globalAlpha=1,r.strokeStyle=l,r.lineWidth=.5,r.globalAlpha=.4;for(let i=0;i<zK;i++){let a=e[i]/t*T,o=i*n-Math.PI/2-n/2;r.beginPath(),r.moveTo(E,D),r.arc(E,D,a,o,o+n),r.closePath(),r.stroke()}r.globalAlpha=1}r.restore(),r.fillStyle=a,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`${s} / ${c}`,E,n-4)}let T=K(w);T.current=w;let E=K(null);E.current??=DH(()=>T.current(),()=>f.current);let D=()=>E.current.schedule();return W(()=>{E.current.now()}),W(()=>()=>E.current?.cancel(),[]),W(()=>{p.current=null,D()},[l]),G(()=>{let e=f.current;if(!e)return;let t=new EH(()=>{p.current=null,D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=d.current;if(!e)return;let t=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),_t(`div`,{ref:f,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:d,className:`chart-canvas`,role:`img`,"aria-label":`Polar chart: ${n} vs ${r}`}),q(`canvas`,{ref:v,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}})]})}function HK(e,t,n,r,i){let a=Math.min(e.length,t.length),o=(t,n)=>{let r=0,i=a;for(;r<i;){let a=r+i>>>1;(n?e[a]<=t:e[a]<t)?r=a+1:i=a}return r},s=o(n,!1),c=o(r,!0),l=Math.max(0,s-1),u=Math.min(a,c+1);if(u-l<=2*i){let e=new Uint32Array(u-l);for(let t=0;t<e.length;t++)e[t]=l+t;return e}let d=new Uint32Array(2*i+2),f=0;s>0&&(d[f++]=s-1);let p=(r-n)/i,m=s;for(let r=0;r<i&&m<c;r++){let a=r===i-1?1/0:n+(r+1)*p,o=1/0,s=-1/0,l=-1,u=-1;for(;m<c&&e[m]<a;m++){let e=t[m];e<o&&(o=e,l=m),e>s&&(s=e,u=m)}l<0||(l===u?d[f++]=l:l<u?(d[f++]=l,d[f++]=u):(d[f++]=u,d[f++]=l))}return c<a&&(d[f++]=c),d.subarray(0,f)}function UK(e,t){let n=e.length;if(n<=2*t)return Uint32Array.from({length:n},(e,t)=>t);let r=new Uint32Array(2*t),i=0;for(let a=0;a<t;a++){let o=Math.floor(a*n/t),s=Math.floor((a+1)*n/t),c=1/0,l=-1/0,u=-1,d=-1;for(let t=o;t<s;t++){let n=e[t];n<c&&(c=n,u=t),n>l&&(l=n,d=t)}u<0||(u===d?r[i++]=u:u<d?(r[i++]=u,r[i++]=d):(r[i++]=d,r[i++]=u))}return r.subarray(0,i)}function WK(e,t){let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n}function GK(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return e.length===0||e[0]===e[0]}function KK(e,t){let n=e.length;for(let r=1,i=0;r<n;r++){let a=n>>1;for(;i&a;a>>=1)i^=a;if(i^=a,r<i){let n=e[r];e[r]=e[i],e[i]=n,n=t[r],t[r]=t[i],t[i]=n}}for(let r=2;r<=n;r<<=1){let i=r>>1,a=-2*Math.PI/r,o=Math.cos(a),s=Math.sin(a);for(let a=0;a<n;a+=r){let n=1,r=0;for(let c=0;c<i;c++){let l=a+c,u=l+i,d=e[u]*n-t[u]*r,f=e[u]*r+t[u]*n;e[u]=e[l]-d,t[u]=t[l]-f,e[l]+=d,t[l]+=f;let p=n*o-r*s;r=n*s+r*o,n=p}}}}var qK=new Float64Array,JK=new Float64Array;function YK(e,t,n){let r=t>>1;qK.length<r&&(qK=new Float64Array(r),JK=new Float64Array(r));let i=qK.subarray(0,r),a=JK.subarray(0,r),o=e.length;for(let t=0;t<r;t++){let r=2*t,s=r+1;i[t]=r<o?e[r]*(n?n[r]:1):0,a[t]=s<o?e[s]*(n?n[s]:1):0}KK(i,a);let s=new Float64Array(r),c=-2*Math.PI/t,l=Math.cos(c),u=Math.sin(c),d=1,f=0;for(let e=0;e<r;e++){let t=e===0?0:r-e,n=i[e],o=a[e],c=i[t],p=-a[t],m=(n+c)/2,h=(o+p)/2,g=(o-p)/2,_=-(n-c)/2,v=m+d*g-f*_,y=h+d*_+f*g;s[e]=Math.sqrt(v*v+y*y);let b=d*l-f*u;f=d*u+f*l,d=b}return s}var XK=new Float64Array,ZK=0;function QK(e){if(ZK===e)return XK.subarray(0,e);XK.length<e&&(XK=new Float64Array(Math.max(e,XK.length*2)));let t=2*Math.PI/Math.max(1,e-1),n=Math.cos(t),r=Math.sin(t),i=1,a=0;for(let t=0;t<e;t++){XK[t]=.5*(1-i);let e=i*n-a*r;a=a*n+i*r,i=e}return ZK=e,XK.subarray(0,e)}var $K={top:14,right:24,bottom:40,left:64},eq=5;function tq(e){let t=1;for(;t<e;)t<<=1;return t}function nq(e,t,n,r){let i=e.length,a=Math.max(2,tq(i)),o=YK(e,a,n===`hann`?QK(i):void 0),s=a/2,c=new Float64Array(s),l=2/a;for(let e=0;e<s;e++){c[e]=e*t/a;let n=o[e]*l;o[e]=r===`db`?20*Math.log10(Math.max(n,1e-12)):n}return{freqs:c,amps:o}}function rq({signal:e,sampleRate:t=1,label:n,xMode:r=`hz`,yMode:i=`amplitude`,window:a=`hann`,color:o=`#34d399`,logX:s=!1,height:c=400,backgroundToken:l=``,onPlotContextMenu:u}){let d=nU(),f=K(null),p=K(null),m=K(null),h=K(u);G(()=>{h.current=u},[u]);let g=K({signal:e,sampleRate:t,label:n,xMode:r,yMode:i,window:a,color:o,logX:s,height:c});G(()=>{g.current={signal:e,sampleRate:t,label:n,xMode:r,yMode:i,window:a,color:o,logX:s,height:c}},[e,t,n,r,i,a,o,s,c]);let _=dt(()=>e.length>=4?nq(e,t,a,i):null,[e,t,a,i]),v=dt(()=>_&&s?_.freqs.map(e=>Math.log10(e)):null,[_,s]),y=K(_&&{..._,logFreqs:v});G(()=>{y.current=_&&{..._,logFreqs:v}},[_,v]);function b(){if(m.current)return m.current;let e=p.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return m.current=n,n}function x(){let e=p.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||g.current.height)}}function S(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function C(){let e=f.current;if(!e)return;let{w:t,h:n}=x(),r=S(e,t,n);if(!r)return;let{top:i,right:a,bottom:o,left:s}=$K,c=t-s-a,l=n-i-o,{bg:u,muted:p,grid:m}=b(),{sampleRate:h,label:_,xMode:v,yMode:C,color:w,logX:T}=g.current,E=y.current;if(r.fillStyle=u,r.fillRect(0,0,t,n),!E||c<=0||l<=0){r.fillStyle=p,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,s+8,i+8);return}let{freqs:D,amps:O,logFreqs:k}=E,A=D.length,j=v===`hz`?`${_} (Hz)`:`${_} (order)`,M=v===`order`&&h>0?h:1,N=D[1]/M,P=D[A-1]/M,F=1/0,I=-1/0;for(let e=1;e<A;e++)O[e]<F&&(F=O[e]),O[e]>I&&(I=O[e]);if(!Number.isFinite(F)||!Number.isFinite(I)){r.fillStyle=p,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,s+8,i+8);return}let L=(I-F)*.05||.1;F-=L,I+=L;let R=T?e=>{if(e<=0||N<=0)return s;let t=Math.log10(N),n=Math.log10(P);return s+(Math.log10(e)-t)/(n-t)*c}:e=>s+(e-N)/(P-N)*c;T&&N<=0&&(N=D[1]>0?D[1]/M:.001),d({left:s,top:i,width:c,height:l,x:{v0:N,v1:P,log:T},y:{v0:F,v1:I}});let z=e=>i+(I-e)/(I-F)*l,B=wz(I-F,5),V=Dz(F,I,B);r.strokeStyle=m,r.lineWidth=1,r.setLineDash([3,3]);for(let e of V)r.beginPath(),r.moveTo(s,z(e)),r.lineTo(s+c,z(e)),r.stroke();r.setLineDash([]);let ee=T?1:wz(P-N,Tz(c)),te=T?(()=>{let e=[],t=Math.ceil(Math.log10(Math.max(N,1e-12))),n=Math.floor(Math.log10(P));for(let r=t;r<=n;r++)for(let t of[1,2,5]){let n=t*10**r;n>=N&&n<=P&&e.push(n)}return e})():Dz(N,P,ee);r.strokeStyle=m,r.lineWidth=1,r.setLineDash([3,3]);for(let e of te)r.beginPath(),r.moveTo(R(e),i),r.lineTo(R(e),i+l),r.stroke();r.setLineDash([]),r.strokeStyle=p,r.lineWidth=1,r.fillStyle=p,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of V)r.beginPath(),r.moveTo(s-eq,z(e)),r.lineTo(s,z(e)),r.stroke(),r.fillText(jz(e,B),s-4,z(e));r.textAlign=`center`,r.textBaseline=`top`;for(let e of te)r.beginPath(),r.moveTo(R(e),i+l),r.lineTo(R(e),i+l+eq),r.stroke(),r.fillText(jz(e,T?e:ee),R(e),i+l+eq+2);r.strokeStyle=m,r.lineWidth=1,r.strokeRect(s,i,c,l),r.save(),r.beginPath(),r.rect(s,i,c,l),r.clip(),r.strokeStyle=w,r.lineWidth=1,r.beginPath();let H=!1,ne=Math.min(2,window.devicePixelRatio||1),re=Math.max(1,Math.round(c*ne)),ie=A>re*4?T&&k?HK(k,O,Math.log10(N*M),Math.log10(P*M),re):HK(D,O,N*M,P*M,re):null;for(let e=+!ie;e<(ie?ie.length:A);e++){let t=ie?ie[e]:e;if(t<1)continue;let n=D[t]/M;if(n<N||n>P)continue;let i=R(n),a=z(O[t]);H?r.lineTo(i,a):(r.moveTo(i,a),H=!0)}r.stroke(),r.restore(),r.fillStyle=p,r.font=`11px ${Q.mono}`,r.save(),r.translate(14,i+l/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(C===`db`?`dB`:`Amplitude`,0,0),r.restore(),r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(j,s+c/2,n-4)}let w=K(C);w.current=C;let T=K(null);T.current??=DH(()=>w.current(),()=>p.current);let E=()=>T.current.schedule();return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{m.current=null,E()},[l]),G(()=>{let e=p.current;if(!e)return;let t=new EH(()=>{m.current=null,E()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=f.current;if(!e)return;let t=e=>{e.preventDefault(),h.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:p,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:f,className:`chart-canvas`,role:`img`,"aria-label":`Spectrum of ${n}`})})}function iq(e,t,n=0,r=e.length-1){for(;r>n;){let i=n+r>>>1,a=e[n],o=e[i],s=e[r];if(a>o){let e=a;a=o,o=e}o>s&&(o=s),a>o&&(o=a);let c=o,l=n,u=r;for(;l<=u;){for(;e[l]<c;)l++;for(;e[u]>c;)u--;if(l<=u){let t=e[l];e[l]=e[u],e[u]=t,l++,u--}}if(t<=u)r=u;else if(t>=l)n=l;else break}return e[t]}function aq(e,t){let n=e.length;if(n===0)return t.map(()=>0);let r=[...new Set(t.flatMap(e=>{let t=e/100*(n-1);return[Math.floor(t),Math.ceil(t)]}))].sort((e,t)=>e-t),i=new Map,a=0;for(let t of r)i.set(t,iq(e,t,a)),a=t;return t.map(e=>{let t=e/100*(n-1),r=Math.floor(t);return i.get(r)+(i.get(Math.ceil(t))-i.get(r))*(t-r)})}var oq={top:14,right:24,bottom:48,left:64},sq=5;function cq(e,t){let n=e.length;if(n===0)return null;let[r,i,a,o,s]=aq(Float64Array.from(e),[0,25,50,75,100]),c=0;for(let t=0;t<n;t++)c+=e[t];let l=c/n;if(t!==`1.5iqr`)return{q1:i,median:a,q3:o,mean:l,whiskerLo:r,whiskerHi:s,outliers:new Float64Array};let u=o-i,d=i-1.5*u,f=o+1.5*u,p=1/0,m=-1/0,h=0;for(let t=0;t<n;t++){let n=e[t];if(n<d||n>f){h++;continue}n<p&&(p=n),n>m&&(m=n)}let g=new Float64Array(h);for(let t=0,r=0;t<n;t++){let n=e[t];(n<d||n>f)&&(g[r++]=n)}return g.sort(),{q1:i,median:a,q3:o,mean:l,whiskerLo:p<=m?p:i,whiskerHi:p<=m?m:o,outliers:g}}function lq({groups:e,color:t=`#fb923c`,whiskers:n=`1.5iqr`,height:r=400,backgroundToken:i=``,onPlotContextMenu:a}){let o=nU(),s=K(null),c=K(null),l=K(null),u=K(a);G(()=>{u.current=a},[a]);let d=K({groups:e,color:t,whiskers:n,height:r});G(()=>{d.current={groups:e,color:t,whiskers:n,height:r}},[e,t,n,r]);let f=dt(()=>e.filter(e=>e.values.length>0).map(e=>({label:e.label,box:cq(e.values,n)})),[e,n]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||d.current.height)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:a,bottom:c,left:l}=oq,u=t-l-a,f=n-i-c,{bg:_,muted:v,grid:y}=m(),{color:b}=d.current;r.fillStyle=_,r.fillRect(0,0,t,n);let x=p.current;if(x.length===0||u<=0||f<=0){r.fillStyle=v,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let S=1/0,C=-1/0;for(let e of x){e.box.whiskerLo<S&&(S=e.box.whiskerLo),e.box.whiskerHi>C&&(C=e.box.whiskerHi);for(let t of e.box.outliers)t<S&&(S=t),t>C&&(C=t)}let w=(C-S)*.08||1;S-=w,C+=w;let T=e=>i+(C-e)/(C-S)*f;o({left:l,top:i,width:u,height:f,y:{v0:S,v1:C}});let E=wz(C-S,5),D=Dz(S,C,E);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of D)r.beginPath(),r.moveTo(l,T(e)),r.lineTo(l+u,T(e)),r.stroke();r.setLineDash([]),r.strokeStyle=v,r.lineWidth=1,r.fillStyle=v,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of D)r.beginPath(),r.moveTo(l-sq,T(e)),r.lineTo(l,T(e)),r.stroke(),r.fillText(jz(e,E),l-4,T(e));r.strokeStyle=y,r.lineWidth=1,r.strokeRect(l,i,u,f),r.save(),r.beginPath(),r.rect(l,i,u,f),r.clip();let O=x.length,k=u/O,A=Math.min(k*.55,60);for(let e=0;e<O;e++){let{box:t}=x[e],n=l+k*e+k/2;r.strokeStyle=b,r.lineWidth=1.5,r.beginPath(),r.moveTo(n,T(t.whiskerLo)),r.lineTo(n,T(t.whiskerHi)),r.stroke();let i=A*.35;r.beginPath(),r.moveTo(n-i,T(t.whiskerLo)),r.lineTo(n+i,T(t.whiskerLo)),r.moveTo(n-i,T(t.whiskerHi)),r.lineTo(n+i,T(t.whiskerHi)),r.stroke();let a=n-A/2,o=T(t.q3),s=Math.max(1,T(t.q1)-o);r.fillStyle=b,r.globalAlpha=.25,r.fillRect(a,o,A,s),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=1.5,r.strokeRect(a,o,A,s),r.strokeStyle=b,r.lineWidth=2.5,r.beginPath(),r.moveTo(a,T(t.median)),r.lineTo(a+A,T(t.median)),r.stroke();let c=T(t.mean);r.fillStyle=b,r.beginPath(),r.moveTo(n,c-5),r.lineTo(n+5,c),r.lineTo(n,c+5),r.lineTo(n-5,c),r.closePath(),r.fill(),r.fillStyle=b,r.globalAlpha=.6;let u=NaN;for(let e of t.outliers){let t=T(e);Math.abs(t-u)<.5||(u=t,r.beginPath(),r.arc(n,t,2.5,0,Math.PI*2),r.fill())}r.globalAlpha=1}r.restore(),r.fillStyle=v,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<O;e++){let t=l+k*e+k/2,n=x[e].label;r.save(),r.rect(l+k*e+2,i+f+sq+2,k-4,c-sq-4),r.clip(),r.fillText(n,t,i+f+sq+2),r.restore()}}let v=K(_);v.current=_;let y=K(null);y.current??=DH(()=>v.current(),()=>c.current);let b=()=>y.current.schedule();return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{l.current=null,b()},[i]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:s,className:`chart-canvas`,role:`img`,"aria-label":`Box plot`})})}function uq(e,t){if(e.w<=t)return{grid:e,per:1};let n=e.w/t,r=new Float32Array(t*e.h);for(let i=0;i<e.h;i++){let a=i*e.w;for(let o=0;o<t;o++){let s=Math.floor(o*n),c=Math.min(e.w,Math.floor((o+1)*n)),l=0,u=0;for(let t=s;t<c;t++){let n=e.values[a+t];n===n&&(l+=n,u++)}r[i*t+o]=u?l/u:NaN}}let i=e.xLabels;return{grid:{w:t,h:e.h,values:r,xLabels:e=>typeof i==`function`?i(Math.floor(e*n)):i[Math.floor(e*n)],yLabels:e.yLabels},per:n}}var dq=e=>e.includes(`.`)&&!e.includes(`e`)?e.replace(/\.?0+$/,``):e;function fq(e){return e>=1e3?`${dq((e/1e3).toPrecision(3))}k`:dq(e.toPrecision(3))}function pq(e,t,n,r,i,a,o){let s=t>>1,c=e.length,l=c>=t?Math.floor((c-t)/n)+1:0,u=`${t}|${n}|${r}|${i}|${a?a.join(`,`):``}`,d=-1,f=0;if(o&&o.key===u&&o.frames>0&&c>0){let r=o.sig;for(let i=0;i*n<r.length&&f===0;i++){let a=i*n;if(r[a]!==e[0])continue;let s=Math.min(r.length-a,c),u=!0;for(let t=0;t<s;t++)if(r[a+t]!==e[t]){u=!1;break}if(!u)continue;let p=s>=t?Math.floor((s-t)/n)+1:0;d=i,f=Math.max(0,Math.min(p,o.frames-i,l))}}let p=new Float32Array(l*s),m=new Float32Array(l);if(f>0){for(let e=0;e<s;e++)p.set(o.values.subarray(e*o.frames+d,e*o.frames+d+f),e*l);m.set(o.frameMax.subarray(d,d+f))}let h=new Float64Array(t);for(let e=0;e<t;e++)h[e]=r?.5*(1-Math.cos(2*Math.PI*e/(t-1))):1;let g=Math.log2(t),_=new Uint32Array(t);for(let e=0;e<t;e++){let t=0,n=e;for(let e=0;e<g;e++)t=t<<1|n&1,n>>=1;_[e]=t}let v=new Float64Array(t),y=new Float64Array(t),b=new Float64Array(s);for(let r=f;r<l;r++){let o=r*n;for(let n=0;n<t;n++){let t=_[n];v[n]=e[o+t]*h[t],y[n]=0}for(let e=2;e<=t;e<<=1){let n=e>>1,r=-2*Math.PI/e,i=Math.cos(r),a=Math.sin(r);for(let r=0;r<t;r+=e){let e=1,t=0;for(let o=0;o<n;o++){let s=r+o,c=s+n,l=v[c]*e-y[c]*t,u=v[c]*t+y[c]*e;v[c]=v[s]-l,y[c]=y[s]-u,v[s]+=l,y[s]+=u;let d=e*i-t*a;t=e*a+t*i,e=d}}}let c=0;for(let e=0;e<s;e++){let n=Math.sqrt(v[e]*v[e]+y[e]*y[e])/t;b[e]=n,n>c&&(c=n)}m[r]=c;for(let e=0;e<s;e++){let t=b[a?a[e]:e];p[e*l+r]=i?20*Math.log10(Math.max(t,1e-12)):t}}let x=1e-10;for(let e=0;e<l;e++)m[e]>x&&(x=m[e]);return{values:p,frames:l,bins:s,max:x,computed:l-f,sig:Float64Array.from(e),frameMax:m,key:u}}var mq={top:14,right:24,bottom:40,left:68},hq=[[8,0,16],[48,0,96],[104,0,144],[160,0,128],[200,32,64],[230,100,16],[250,200,32],[255,255,220]],gq=-80;function _q(e){let t=hq.length-1,n=Math.min(t-1,Math.floor(e*t)),r=e*t-n,[i,a,o]=hq[n],[s,c,l]=hq[n+1];return[i+(s-i)*r,a+(c-a)*r,o+(l-o)*r]}var vq=(()=>{let e=new Uint8Array(256*4);for(let t=0;t<256;t++){let[n,r,i]=_q(t/255);e.set([n,r,i,255],t*4)}return e})();function yq(e){let t=1;for(;t<e;)t<<=1;return t}var bq=(e,t)=>Math.log(1+e/t*9)/Math.log(10),xq=(e,t)=>t*(10**e-1)/9;function Sq({signal:e,sampleRate:t=1e3,windowSize:n=512,overlap:r=.5,winFunc:i=`hann`,yMode:a=`db`,logFreq:o=!1,label:s=``,backgroundToken:c=``,onPlotContextMenu:l}){let u=nU(),d=K(null),f=K(null),p=K(null),m=K(null),h=K(null),g=K(l);G(()=>{g.current=l},[l]);let _=yq(Math.max(4,Math.min(n,4096))),v=Math.max(1,Math.round(_*(1-Math.max(0,Math.min(.95,r))))),y=dt(()=>{if(!o)return null;let e=_>>1,n=t/2;return Int32Array.from({length:e},(t,r)=>Math.min(e-1,Math.floor(xq((r+.5)/e,n)/n*e)))},[o,_,t]),b=K(null),x=dt(()=>b.current=pq(e,_,v,i===`hann`,a===`db`,y,b.current),[e,_,v,i,a,y]),S=dt(()=>({w:x.frames,h:x.bins,values:x.values,xLabels:[],yLabels:[]}),[x]),C=a===`db`?20*Math.log10(x.max):x.max,w=a===`db`?[C+gq,C]:[0,C],T=K({grid:S,range:w,sampleRate:t,winSz:_,step:v,yMode:a,logFreq:o,label:s});G(()=>{T.current={grid:S,range:w,sampleRate:t,winSz:_,step:v,yMode:a,logFreq:o,label:s}},[S,w[0],w[1],t,_,v,a,o,s]);let E=K({plot:null,failed:!1,size:``,grid:null,shown:null});W(()=>()=>{E.current.plot?.dispose(),E.current.plot=null},[]);function D(){if(h.current)return h.current;let e=m.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return h.current=n,n}function O(){let e=m.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function k(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function A(e,t){let n=E.current;if(!n.plot&&!n.failed&&f.current&&(n.plot=uH(f.current,IK),n.failed=!n.plot),!n.plot||!f.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),f.current.style.width=`${e}px`,f.current.style.height=`${t}px`,n.size=i),n.plot}function j(){let e=d.current;if(!e)return;let{w:t,h:n}=O(),r=k(e,t,n);if(!r)return;let i=p.current?k(p.current,t,n):null;i?.clearRect(0,0,t,n);let a=YW(mq,t,n),{top:o,right:s,bottom:c,left:l}=a,f=t-l-s,h=n-o-c,{bg:g,muted:_,grid:v}=D(),{grid:y,sampleRate:b,winSz:x,step:S,logFreq:C,label:w}=T.current;r.fillStyle=g,r.fillRect(0,0,t,n);let j=A(t,n);if(y.w===0||f<=0||h<=0){if(j?.keep([]),j?.render(),a.tiny)return;r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,o+8);return}let M=Math.min(2,window.devicePixelRatio||1),N=j?j.maxTextureSize:Math.max(1,Math.round(f*M)),[P,F]=T.current.range;if(E.current.grid!==y||!E.current.shown||!j&&E.current.shown.w>N){let e=uq(y,N).grid;j&&j.setGrid(`cells`,e.values,e.w,Math.min(e.h,j.maxTextureSize),[0,e.w,0,e.h],vq,P,F),E.current.grid=y,E.current.shown=e,CH(m.current)}let I=E.current.shown;if(j)j.keep([`cells`]),j.setGridRange(`cells`,P,F),j.setView(0,I.w,0,I.h,{left:l,top:o,width:f,height:h}),j.render();else{let e=document.createElement(`canvas`);e.width=I.w,e.height=I.h;let t=e.getContext(`2d`),n=t.createImageData(I.w,I.h);for(let e=0;e<I.h;e++)for(let t=0;t<I.w;t++){let[r,i,a]=_q(Math.max(0,Math.min(1,(I.values[e*I.w+t]-P)/(F-P)))),o=(t+(I.h-1-e)*I.w)*4;n.data[o]=r,n.data[o+1]=i,n.data[o+2]=a,n.data[o+3]=255}t.putImageData(n,0,0),r.drawImage(e,l,o,f,h)}if(a.tiny)return;let L=i??r,R=b/2,z=e=>o+h*(1-(C?bq(e,R):e/R));L.strokeStyle=v,L.lineWidth=.5,L.globalAlpha=.4;let B=Dz(0,R,wz(R,5));L.setLineDash([3,4]);for(let e of B){let t=z(e);L.beginPath(),L.moveTo(l,t),L.lineTo(l+f,t),L.stroke()}L.setLineDash([]),L.globalAlpha=1,L.strokeStyle=v,L.strokeRect(l,o,f,h),r.fillStyle=_,r.font=`10px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.strokeStyle=_,r.lineWidth=1;for(let e of B){let t=z(e);r.beginPath(),r.moveTo(l-4,t),r.lineTo(l,t),r.stroke(),r.fillText(fq(e),l-6,t)}let V=(y.w*S+x)/b;u({left:l,top:o,width:f,height:h,x:{v0:0,v1:V}});let ee=wz(V,6),te=Dz(0,V,ee);r.textAlign=`center`,r.textBaseline=`top`;for(let e of te){let t=l+e/V*f;r.beginPath(),r.moveTo(t,o+h),r.lineTo(t,o+h+4),r.stroke(),r.fillText(jz(e,ee),t,o+h+6)}r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(w||`Time (s)`,l+f/2,n-4),r.save(),r.translate(12,o+h/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(`Frequency (Hz)`,0,0),r.restore()}let M=K(j);G(()=>{M.current=j});let N=K(null);return N.current??=DH(()=>M.current(),()=>m.current),W(()=>{N.current.now()},[S,w[0],w[1],t,_,v,a,o,s]),W(()=>()=>N.current?.cancel(),[]),W(()=>{h.current=null,N.current.schedule()},[c]),G(()=>{let e=m.current;if(!e)return;let t=new EH(()=>{h.current=null,N.current.schedule()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=p.current;if(!e)return;let t=e=>{e.preventDefault(),g.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),_t(`div`,{ref:m,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:d,className:`chart-canvas`,role:`img`,"aria-label":`Spectrogram`}),q(`canvas`,{ref:f,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:p,className:`chart-canvas chart-overlay`})]})}var Cq=300,wq=256,Tq=-60,Eq=[];function Dq({signal:e,sampleRate:t,windowSize:n,overlap:r,winFunc:i,yMode:a,backgroundToken:o,onPlotContextMenu:s}){let c=2**Math.ceil(Math.log2(Math.max(4,Math.min(n,4096)))),l=Math.max(1,Math.round(c*(1-Math.max(0,Math.min(.95,r))))),u=a===`db`,d=dt(()=>pq(e,c,l,i===`hann`,u,null),[e,c,l,i,u]);return q(gK,{points:Eq,surface:dt(()=>Oq(d,t,c,l,u),[d,t,c,l,u]),xLabel:`Time (s)`,yLabel:`Frequency (Hz)`,zLabel:u?`Level (dB)`:`Amplitude`,viewMode:`3d`,showMesh:!0,meshStyle:`filled`,meshOpacity:1,backgroundToken:o,onPlotContextMenu:s})}function Oq(e,t,n,r,i){let{frames:a,bins:o,values:s}=e;if(a<2||o<2)return;let c=Math.min(a,Cq),l=Math.min(o,wq),u=i?20*Math.log10(Math.max(e.max,1e-12))+Tq:-1/0,d=new Float32Array(c*l);for(let e=0;e<l;e++){let t=Math.floor(e*o/l),n=Math.max(t+1,Math.floor((e+1)*o/l));for(let r=0;r<c;r++){let i=Math.floor(r*a/c),o=Math.max(i+1,Math.floor((r+1)*a/c)),l=-1/0;for(let e=t;e<n;e++)for(let t=i;t<o;t++){let n=s[e*a+t];n>l&&(l=n)}d[e*c+r]=Math.max(u,l)}}let f=e=>(e*r+n/2)/t;return{w:c,h:l,values:d,x:[f(0),f(a-1)],y:[0,(o-1)*t/n]}}function kq(e,t,n){return Array.from({length:n},(r,i)=>e+(i+1)/(n+1)*(t-e))}function Aq(e,t,n,r){let i=[],a=(n,r)=>e[r*t+n],o=(e,t)=>(r-e)/(t-e);for(let e=0;e+1<n;e++)for(let n=0;n+1<t;n++){let t=a(n,e),s=a(n+1,e),c=a(n+1,e+1),l=a(n,e+1);if(t!==t||s!==s||c!==c||l!==l)continue;let u=(t>=r?8:0)|(s>=r?4:0)|(c>=r?2:0)|l>=r;if(u===0||u===15)continue;let d=()=>[n+o(t,s),e],f=()=>[n+1,e+o(s,c)],p=()=>[n+o(l,c),e+1],m=()=>[n,e+o(t,l)],h=(e,t)=>i.push([e[0],e[1],t[0],t[1]]);switch(u){case 1:case 14:h(m(),p());break;case 2:case 13:h(p(),f());break;case 3:case 12:h(m(),f());break;case 4:case 11:h(d(),f());break;case 6:case 9:h(d(),p());break;case 7:case 8:h(m(),d());break;case 5:case 10:{let e=(t+s+c+l)/4>=r;u===5===e?(h(m(),d()),h(p(),f())):(h(d(),f()),h(m(),p()));break}}}return i}function jq(e){let t=e.length,n=new Float64Array(t+1);if(t===1)return n[0]=e[0]-.5,n[1]=e[0]+.5,n;for(let r=1;r<t;r++)n[r]=(e[r-1]+e[r])/2;return n[0]=e[0]-(n[1]-e[0]),n[t]=e[t-1]+(e[t-1]-n[t-1]),n}function Mq(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!Number.isFinite(e[t])||t>0&&!(e[t]>e[t-1]))return!1;return!0}var Nq={top:14,right:32,bottom:80,left:80};function Pq(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}var Fq=[[33,102,172],[103,169,207],[209,229,240],[247,247,247],[253,219,199],[239,138,98],[178,24,43]],Iq=[[13,8,135],[84,2,163],[139,10,165],[185,50,137],[219,92,104],[244,136,73],[254,188,43],[240,249,33]],Lq=[[68,1,84],[72,40,120],[62,83,160],[49,120,178],[38,153,185],[31,184,187],[53,213,158],[117,231,101],[198,239,82],[253,231,37]];function Rq(e,t){let n=e.length-1,r=Math.min(n-1,Math.floor(t*n));return Pq(e[r],e[r+1],t*n-r)}function zq(e,t){return Rq(t===`plasma`?Iq:t===`viridis`?Lq:Fq,e)}function Bq(e){let t=new Uint8Array(256*4);for(let n=0;n<256;n++){let[r,i,a]=zq(n/255,e);t.set([r,i,a,255],n*4)}return t}function Vq(e){return Math.abs(e)>=1e4||Math.abs(e)<.01&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(3)))}function Hq(e,t,n){let r=new Map(t.map((e,t)=>[e,t])),i=new Map(n.map((e,t)=>[e,t])),a=new Float32Array(t.length*n.length);for(let n of e){let e=r.get(n.x),o=i.get(n.y);e!==void 0&&o!==void 0&&(a[o*t.length+e]=n.value)}return{w:t.length,h:n.length,values:a,xLabels:t,yLabels:n}}function Uq(e,t,n,r,i,a,o){let s=(e,t,n)=>Float64Array.from({length:e+1},(r,i)=>t+i/e*n),c=!!a&&a.length===e.w,l=!!o&&o.length===e.h,u=s(e.w,t,r),d=s(e.h,n,i);if(c){let n=jq(a),i=n[e.w]-n[0];u=Float64Array.from(n,e=>t+(e-n[0])/i*r)}if(l){let t=jq(Float64Array.from(o).reverse()),r=e.h,a=t[r]-t[0];d=Float64Array.from({length:r+1},(e,o)=>n+(t[r]-t[r-o])/a*i)}return{xB:u,yB:d,byValue:c||l}}function Wq(e,t){if(t<e[0]||t>=e[e.length-1])return-1;let n=0,r=e.length-1;for(;r-n>1;){let i=n+r>>1;e[i]<=t?n=i:r=i}return n}function Gq(e,t,n,r,i,a){let o=Math.max(1,i),s=Math.max(1,a),c=Int32Array.from({length:o},(e,r)=>Wq(t.xB,n+r+.5)),l=new Float32Array(o*s);for(let n=0;n<s;n++){let i=Wq(t.yB,r+n+.5),a=i*e.w;for(let t=0;t<o;t++)l[n*o+t]=i<0||c[t]<0?NaN:e.values[a+c[t]]}return{w:o,h:s,values:l,xLabels:e.xLabels,yLabels:e.yLabels}}function Kq({cells:e,xLabels:t,yLabels:n,grid:r,showValues:i=!0,colorScheme:a=`diverging`,vMin:o,vMax:s,xCentres:c,yCentres:l,contours:u=0,backgroundToken:d=``,onPlotContextMenu:f}){let p=K(null),m=K(null),h=K(null),g=K(null),_=K(null),v=K(null),y=K(null),b=K(0),x=K(f);G(()=>{x.current=f},[f]);let S=dt(()=>r??Hq(e??[],t??[],n??[]),[r,e,t,n]),C=dt(()=>{let e=o??1/0,t=s??-1/0;if(o===void 0||s===void 0){let n=1/0,r=-1/0;for(let e=0;e<S.w*S.h;e++){let t=S.values[e];t<n&&(n=t),t>r&&(r=t)}o===void 0&&(e=n),s===void 0&&(t=r)}return t>e||(e=Number.isFinite(e)?e-1:0,t=e+2),{lo:e,hi:t}},[S,o,s]),w=K({data:S,range:C,showValues:i,colorScheme:a,xCentres:c,yCentres:l,contours:u});G(()=>{w.current={data:S,range:C,showValues:i,colorScheme:a,xCentres:c,yCentres:l,contours:u}},[S,C,i,a,c,l,u]);let T=K({plot:null,failed:!1,size:``,data:null,key:``,shown:null,geo:null}),E=K({key:``,grid:null,segs:[]});W(()=>()=>{T.current.plot?.dispose(),T.current.plot=null},[]);let D=K({data:null,range:``});function O(){if(v.current)return v.current;let e=_.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return v.current=n,n}function k(){let e=_.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function A(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function j(e,t){let n=T.current;if(!n.plot&&!n.failed&&m.current&&(n.plot=uH(m.current,IK),n.failed=!n.plot),!n.plot||!m.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),m.current.style.width=`${e}px`,m.current.style.height=`${t}px`,n.size=i),n.plot}let M=(e,t)=>typeof e==`function`?e(t):e[t];function N(){let e=p.current;if(!e)return;let{w:t,h:n}=k(),r=A(e,t,n);if(!r)return;let i=h.current?A(h.current,t,n):null;i?.clearRect(0,0,t,n);let a=YW(Nq,t,n),{top:o,right:s,bottom:c,left:l}=a,{bg:u,muted:d,grid:f}=O(),{data:m,range:{lo:g,hi:v},showValues:y,colorScheme:b}=w.current;r.fillStyle=u,r.fillRect(0,0,t,n);let x=j(t,n);if(m.w===0||m.h===0){x?.keep([]),x?.render(),r.fillStyle=d,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,o+8);return}let S=t-l-s,C=n-o-c,N=Math.min(2,window.devicePixelRatio||1),P=D.current;(P.data!==m||P.range!==`${g}|${v}`)&&(D.current={data:m,range:`${g}|${v}`},CH(_.current));let{xCentres:F,yCentres:I,contours:L}=w.current,R=x?x.maxTextureSize:Math.max(1,Math.round(S*N)),z=uq(m,R).grid,B=Uq(z,l,o,S,C,z===m?F:void 0,z===m?I:void 0),V=B.byValue,ee=`${R}|${b}|${V?`${S}x${C}`:``}`,te=T.current.shown;if(T.current.data!==m||T.current.key!==ee||!te){te=z;let e=V?Gq(te,B,l,o,Math.round(S),Math.round(C)):te;x&&x.setGrid(`cells`,e.values,e.w,Math.min(e.h,x.maxTextureSize),[0,e.w,0,e.h],Bq(b),g,v),T.current.data=m,T.current.key=ee,T.current.shown=te}T.current.geo=B;let H=V?Math.round(S):te.w,ne=V?Math.round(C):te.h,re=e=>B.xB[e+1]-B.xB[e],ie=e=>B.yB[e+1]-B.yB[e];if(x)x.keep([`cells`]),x.setGridRange(`cells`,g,v),x.setView(0,H,ne,0,{left:l,top:o,width:S,height:C}),x.render();else for(let e=0;e<te.h;e++)for(let t=0;t<te.w;t++){let n=te.values[e*te.w+t];if(Number.isNaN(n))continue;let[i,a,o]=zq(Math.max(0,Math.min(1,(n-g)/(v-g))),b);r.fillStyle=`rgb(${i|0},${a|0},${o|0})`,r.fillRect(B.xB[t],B.yB[e],re(t)+.5,ie(e)+.5)}let U=i??r;if(y){for(let e=0;e<te.h;e++)if(!(ie(e)<=16)){U.font=`${Math.min(12,Math.max(8,ie(e)*.4))}px ${Q.mono}`,U.textAlign=`center`,U.textBaseline=`middle`;for(let t=0;t<te.w;t++){let n=te.values[e*te.w+t];if(Number.isNaN(n)||re(t)<=28)continue;let[r,i,a]=zq(Math.max(0,Math.min(1,(n-g)/(v-g))),b);U.fillStyle=.299*r+.587*i+.114*a>128?`#000`:`#fff`,U.fillText(Vq(n),(B.xB[t]+B.xB[t+1])/2,(B.yB[e]+B.yB[e+1])/2)}}}if(S/te.w>=4&&C/te.h>=4){U.strokeStyle=u,U.lineWidth=.5;for(let e=0;e<=te.w;e++)U.beginPath(),U.moveTo(B.xB[e],o),U.lineTo(B.xB[e],o+C),U.stroke();for(let e=0;e<=te.h;e++)U.beginPath(),U.moveTo(l,B.yB[e]),U.lineTo(l+S,B.yB[e]),U.stroke()}let ae=L>0?kq(g,v,L):[];if(ae.length&&te.w>=2&&te.h>=2&&te.w*te.h<=4e6){let e=`${g}|${v}|${L}`;if(E.current.grid!==te||E.current.key!==e){let t=te;E.current={key:e,grid:t,segs:ae.map(e=>Aq(t.values,t.w,t.h,e))}}let t=(e,t)=>{let n=Math.min(t.length-3,Math.max(0,Math.floor(e))),r=(t[n]+t[n+1])/2;return r+((t[n+1]+t[n+2])/2-r)*(e-n)};U.save(),U.beginPath(),U.rect(l,o,S,C),U.clip(),U.lineCap=`round`,U.lineJoin=`round`;for(let[e,n]of[[2.6,`rgba(0,0,0,0.38)`],[1.1,`rgba(255,255,255,0.92)`]]){U.lineWidth=e,U.strokeStyle=n,U.beginPath();for(let e of E.current.segs)for(let[n,r,i,a]of e)U.moveTo(t(n,B.xB),t(r,B.yB)),U.lineTo(t(i,B.xB),t(a,B.yB));U.stroke()}U.restore()}r.fillStyle=d,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`;let oe=-1/0;for(let e=0;e<(a.tiny?0:te.w);e++){let t=(B.xB[e]+B.xB[e+1])/2;t-oe<18||(oe=t,r.save(),r.translate(t,o+C+4),r.rotate(-Math.PI/4),r.fillText(M(te.xLabels,e),0,0),r.restore())}r.textAlign=`right`,r.textBaseline=`middle`;let se=-1/0;for(let e=0;e<(a.tiny?0:te.h);e++){let t=(B.yB[e]+B.yB[e+1])/2;t-se<12||(se=t,r.fillText(te.yLabels[e]??``,l-4,t))}if(a.tiny)return;let ce=t-s+4,le=o,ue=C;for(let e=0;e<ue;e++){let[t,n,i]=zq(1-e/ue,b);r.fillStyle=`rgb(${t|0},${n|0},${i|0})`,r.fillRect(ce,le+e,12,1)}r.strokeStyle=f,r.lineWidth=.5,r.strokeRect(ce,le,12,ue),r.fillStyle=d,r.font=`9px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`,r.fillText(Vq(v),ce+12+2,le),r.fillText(Vq(g),ce+12+2,le+ue),r.fillText(Vq((g+v)/2),ce+12+2,le+ue/2),r.strokeStyle=`rgba(255,255,255,0.92)`,r.lineWidth=1;for(let e of ae){let t=le+ue*(1-(e-g)/(v-g));r.beginPath(),r.moveTo(ce-2,t),r.lineTo(ce+12+2,t),r.stroke()}}function P(){let e=g.current;if(!e)return;let{w:t,h:n}=k(),r=A(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=y.current,a=T.current.shown,o=T.current.geo;if(!i||!a||!o)return;let{top:s,right:c,bottom:l}=YW(Nq,t,n),{xi:u,yi:d}=i;if(u>=a.w||d>=a.h)return;let f=o.xB[u],p=o.xB[u+1],m=o.yB[d],h=o.yB[d+1];r.strokeStyle=`rgba(255,255,255,0.7)`,r.lineWidth=1.5,r.strokeRect(f+.5,m+.5,Math.max(1,p-f-1),Math.max(1,h-m-1));let _=a.values[d*a.w+u];if(!Number.isNaN(_)){let e=`${M(a.xLabels,u)} × ${a.yLabels[d]}: ${Vq(_)}`;r.font=`11px ${Q.mono}`;let n=r.measureText(e).width,i=Math.min(p+.1*(p-f),t-c-n-6),o=Math.max(s+4,m-.3*(h-m));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(i-3,o-3,n+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(e,i,o)}}let F=K(N);F.current=N;let I=K(null);I.current??=DH(()=>F.current(),()=>_.current);let L=()=>{b.current||=bH(()=>{b.current=0,P()})};return W(()=>{I.current.now()},[S,C,i,a,c,l,u]),W(()=>()=>{I.current?.cancel(),xH(b.current)},[]),W(()=>{v.current=null,I.current.schedule()},[d]),G(()=>{let e=_.current;if(!e)return;let t=new EH(()=>{v.current=null,I.current.schedule(),L()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=g.current;if(!e)return;let t=e=>{e.preventDefault(),x.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{shown:r,geo:i}=T.current;if(!r||!i)return;let a=Wq(i.xB,t.clientX-n.left),o=Wq(i.yB,t.clientY-n.top);y.current=a>=0&&a<r.w&&o>=0&&o<r.h?{xi:a,yi:o}:null,L()},r=()=>{y.current=null,L()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:_,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:p,className:`chart-canvas`,role:`img`,"aria-label":`Heatmap`}),q(`canvas`,{ref:m,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:h,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:g,className:`chart-canvas chart-overlay`})]})}var qq=2e3,Jq=1024;function Yq(e,t,n,r,i){let a=e.length,o=1/(a*t*Math.sqrt(2*Math.PI)),s=new Float64Array(n.length);if(a<=qq){for(let r=0;r<n.length;r++){let i=0;for(let o=0;o<a;o++){let a=(n[r]-e[o])/t;i+=Math.exp(-.5*a*a)}s[r]=i*o}return s}let c=new Float64Array(Jq),l=(i-r)/Jq||1;for(let t=0;t<a;t++)c[Math.max(0,Math.min(Jq-1,Math.floor((e[t]-r)/l)))]++;for(let e=0;e<n.length;e++){let i=0;for(let a=0;a<Jq;a++){if(c[a]===0)continue;let o=(n[e]-(r+(a+.5)*l))/t;i+=c[a]*Math.exp(-.5*o*o)}s[e]=i*o}return s}var Xq={top:14,right:24,bottom:48,left:64},Zq=120;function Qq(e,t,n){let r=e.length;if(r<2)return 1;let i=0;for(let t=0;t<r;t++)i+=e[t];let a=i/r,o=0;for(let t=0;t<r;t++)o+=(e[t]-a)**2;let s=Math.sqrt(o/(r-1));return .9*Math.min(s,(n-t)/1.34)*r**-.2}function $q(e,t){let n=e.filter(e=>e.values.length>=2),r=1/0,i=-1/0,a=n.map(e=>{let[t,n,a,o,s]=aq(Float64Array.from(e.values),[0,25,50,75,100]);return t<r&&(r=t),s>i&&(i=s),{q1:n,median:a,q3:o}}),o=(i-r)*.1||1;r-=o,i+=o;let s=Float64Array.from({length:Zq},(e,t)=>r+t/(Zq-1)*(i-r));return{shapes:n.map((e,n)=>{let{q1:o,median:c,q3:l}=a[n],u=Yq(e.values,t>0?t:Qq(e.values,o,l),s,r,i),d=1e-10;for(let e of u)e>d&&(d=e);return{label:e.label,density:u,maxDensity:d,q1:o,median:c,q3:l}}),pts:s,yMin:r,yMax:i}}function eJ({groups:e,color:t=`#818cf8`,showBox:n=!0,bandwidth:r=0,orientation:i=`vertical`,backgroundToken:a=``,onPlotContextMenu:o}){let s=nU(),c=K(null),l=K(null),u=K(null),d=K(o);G(()=>{d.current=o},[o]);let f=K({groups:e,color:t,showBox:n,bandwidth:r,orientation:i});G(()=>{f.current={groups:e,color:t,showBox:n,bandwidth:r,orientation:i}},[e,t,n,r,i]);let p=dt(()=>$q(e,r),[e,r]),m=K(p);G(()=>{m.current=p},[p]);function h(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function g(){let e=l.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function _(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function v(){let e=c.current;if(!e)return;let{w:t,h:n}=g(),r=_(e,t,n);if(!r)return;let{top:i,right:a,bottom:o,left:l}=Xq,u=t-l-a,d=n-i-o,{bg:p,muted:v,grid:y}=h(),{color:b,showBox:x,orientation:S}=f.current;r.fillStyle=p,r.fillRect(0,0,t,n);let{shapes:C,pts:w,yMin:T,yMax:E}=m.current;if(C.length===0||u<=0||d<=0){r.fillStyle=v,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let D=S===`vertical`,O=D?e=>i+d*(1-(e-T)/(E-T)):e=>l+u*((e-T)/(E-T));s({left:l,top:i,width:u,height:d,...D?{y:{v0:T,v1:E}}:{x:{v0:T,v1:E}}});let k=wz(E-T,5),A=Dz(T,E,k);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of A)D?(r.beginPath(),r.moveTo(l,O(e)),r.lineTo(l+u,O(e)),r.stroke()):(r.beginPath(),r.moveTo(O(e),i),r.lineTo(O(e),i+d),r.stroke());if(r.setLineDash([]),r.fillStyle=v,r.font=`11px ${Q.mono}`,r.strokeStyle=v,r.lineWidth=1,D){r.textAlign=`right`,r.textBaseline=`middle`;for(let e of A)r.beginPath(),r.moveTo(l-4,O(e)),r.lineTo(l,O(e)),r.stroke(),r.fillText(jz(e,k),l-6,O(e))}else{r.textAlign=`center`,r.textBaseline=`top`;for(let e of A)r.beginPath(),r.moveTo(O(e),i+d),r.lineTo(O(e),i+d+4),r.stroke(),r.fillText(jz(e,k),O(e),i+d+6)}r.strokeStyle=y,r.strokeRect(l,i,u,d),r.save(),r.beginPath(),r.rect(l,i,u,d),r.clip();let j=C.length,M=D?u/j:d/j;for(let e=0;e<j;e++){let{density:t,maxDensity:n,q1:a,median:o,q3:s}=C[e],c=D?l+M*e+M/2:i+M*e+M/2,u=M*.45;r.beginPath();for(let e=0;e<Zq;e++){let i=t[e]/n*u,a=O(w[e]);D?e===0?r.moveTo(c-i,a):r.lineTo(c-i,a):e===0?r.moveTo(a,c-i):r.lineTo(a,c-i)}for(let e=Zq-1;e>=0;e--){let i=t[e]/n*u,a=O(w[e]);D?r.lineTo(c+i,a):r.lineTo(a,c+i)}if(r.closePath(),r.fillStyle=b,r.globalAlpha=.35,r.fill(),r.strokeStyle=b,r.lineWidth=1,r.globalAlpha=.9,r.stroke(),r.globalAlpha=1,x){let e=u*.22;D?(r.fillStyle=b,r.globalAlpha=.7,r.fillRect(c-e,O(s),e*2,O(a)-O(s)),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=2,r.beginPath(),r.moveTo(c-e,O(o)),r.lineTo(c+e,O(o)),r.stroke()):(r.fillStyle=b,r.globalAlpha=.7,r.fillRect(O(a),c-e,O(s)-O(a),e*2),r.globalAlpha=1,r.strokeStyle=b,r.lineWidth=2,r.beginPath(),r.moveTo(O(o),c-e),r.lineTo(O(o),c+e),r.stroke())}}if(r.restore(),r.fillStyle=v,r.font=`11px ${Q.mono}`,D){r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<j;e++)r.fillText(C[e].label,l+M*e+M/2,i+d+6)}else{r.textAlign=`right`,r.textBaseline=`middle`;for(let e=0;e<j;e++)r.fillText(C[e].label,l-6,i+M*e+M/2)}}let y=K(v);y.current=v;let b=K(null);b.current??=DH(()=>y.current(),()=>l.current);let x=()=>b.current.schedule();return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{u.current=null,x()},[a]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,x()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=c.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:c,className:`chart-canvas`,role:`img`,"aria-label":`Violin plot`})})}var tJ={top:48,right:16,bottom:72,left:80},nJ=[8,24,64],rJ=[56,189,248];function iJ(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function aJ(e){return`${(e*100).toFixed(1)}%`}function oJ(e,t,n){if(e.length===0)return null;let r=Math.min(e.length,t.length),i=Array(r),a=Array(r),o=new Set,s=0;for(let n=0;n<r;n++)i[n]=String(e[n]),a[n]=String(t[n]),o.add(i[n]),o.add(a[n]),i[n]===a[n]&&s++;let c=[...o].sort(),l=c.length,u=new Map(c.map((e,t)=>[e,t])),d=Array.from({length:l},()=>Array(l).fill(0));for(let e=0;e<r;e++)d[u.get(i[e])][u.get(a[e])]++;let f=d.map(e=>e.reduce((e,t)=>e+t,0));return{classes:c,matrix:n?d.map((e,t)=>e.map(e=>f[t]>0?e/f[t]:0)):d,raw:d,accuracy:s/e.length}}function sJ({actual:e,predicted:t,normalize:n=!1,backgroundToken:r=``,onPlotContextMenu:i}){let a=K(null),o=K(null),s=K(null),c=K(null),l=K(null),u=K(0),d=K(i);G(()=>{d.current=i},[i]);let f=K({actual:e,predicted:t,normalize:n});G(()=>{f.current={actual:e,predicted:t,normalize:n}},[e,t,n]);function p(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function m(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let g=dt(()=>oJ(e,t,n),[e,t,n]),_=K(g);G(()=>{_.current=g},[g]);let v=()=>_.current;function y(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{top:i,right:o,bottom:s,left:c}=tJ,{bg:l,muted:u,grid:d}=p();r.fillStyle=l,r.fillRect(0,0,t,n);let g=v();if(!g){r.fillStyle=u,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,c+8,i+8);return}let{classes:_,matrix:y,accuracy:b}=g,x=_.length,S=t-c-o,C=n-i-s,w=S/x,T=C/x,E=0;for(let e of y)for(let t of e)t>E&&(E=t);for(let e=0;e<x;e++)for(let t=0;t<x;t++){let n=y[e][t],[a,o,s]=iJ(nJ,rJ,E>0?n/E:0);if(r.fillStyle=`rgb(${a|0},${o|0},${s|0})`,r.fillRect(c+t*w,i+e*T,w,T),w>24&&T>14){r.fillStyle=.299*a+.587*o+.114*s>100?`#000`:`#fff`,r.font=`${Math.min(12,Math.max(8,T*.38))}px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`;let l=f.current.normalize;r.fillText(l?aJ(n):String(n|0),c+(t+.5)*w,i+(e+.5)*T)}}r.strokeStyle=l,r.lineWidth=.5;for(let e=0;e<=x;e++)r.beginPath(),r.moveTo(c+e*w,i),r.lineTo(c+e*w,i+C),r.stroke(),r.beginPath(),r.moveTo(c,i+e*T),r.lineTo(c+S,i+e*T),r.stroke();r.strokeStyle=d,r.strokeRect(c,i,S,C),r.fillStyle=u,r.font=`10px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e=0;e<x;e++)r.fillText(_[e],c-4,i+(e+.5)*T);r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<x;e++)r.save(),r.translate(c+(e+.5)*w,i+C+4),r.rotate(-Math.PI/4),r.fillText(_[e],0,0),r.restore();r.fillStyle=u,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Predicted`,c+S/2,n-4),r.save(),r.translate(12,i+C/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(`Actual`,0,0),r.restore(),r.fillStyle=u,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Accuracy: ${aJ(b)}`,c+S/2,i/2)}function b(){let e=o.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(!i)return;let{top:a,right:s,bottom:c,left:u}=tJ,d=v();if(!d)return;let{classes:p,matrix:g}=d,_=p.length,y=t-u-s,b=n-a-c,x=y/_,S=b/_;r.strokeStyle=`rgba(255,255,255,0.8)`,r.lineWidth=2,r.strokeRect(u+i.c*x+1,a+i.r*S+1,x-2,S-2);let C=g[i.r][i.c],w=f.current.normalize,T=`${p[i.r]} → ${p[i.c]}: ${w?aJ(C):C|0}`;r.font=`11px ${Q.mono}`;let E=r.measureText(T).width,D=Math.min(u+(i.c+1.1)*x,t-E-6),O=Math.max(6,a+(i.r-.3)*S);r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(D-3,O-3,E+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(T,D,O)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>s.current);let C=()=>S.current.schedule(),w=()=>{xH(u.current),u.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{c.current=null,C()},[r]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{top:r,right:i,bottom:a,left:o}=tJ,s=v();if(!s)return;let c=s.classes.length,u=n.width-o-i,d=n.height-r-a,f=Math.floor((t.clientX-n.left-o)/(u/c)),p=Math.floor((t.clientY-n.top-r)/(d/c));l.current=p>=0&&p<c&&f>=0&&f<c?{r:p,c:f}:null,w()},r=()=>{l.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:a,className:`chart-canvas`,role:`img`,"aria-label":`Confusion matrix`}),q(`canvas`,{ref:o,className:`chart-canvas chart-overlay`})]})}var cJ={top:24,right:24,bottom:48,left:64};function lJ(e,t){let n=0,r=0,i=Math.min(e.length,t.length);for(let a=0;a<i;a++)e[a]-e[a]!==0||t[a]-t[a]!==0||(t[a]===1?n++:r++);let a=new Float64Array(n),o=new Float64Array(r);for(let n=0,r=0,s=0;n<i;n++)e[n]-e[n]!==0||t[n]-t[n]!==0||(t[n]===1?a[r++]=e[n]:o[s++]=e[n]);a.sort(),o.sort();let s=new Uint8Array(n+r);for(let e=0,t=n-1,i=r-1;e<s.length;e++)i<0||t>=0&&a[t]>=o[i]?(s[e]=1,t--):(s[e]=0,i--);return s}function uJ(e){let t=0;for(let n of e)t+=n;let n=e.length-t;if(t===0||n===0)return null;let r=new Float64Array(e.length+2),i=new Float64Array(e.length+2),a=0,o=0,s=0;for(let c=0;c<e.length;c++)e[c]===1?a++:o++,r[c+1]=o/n,i[c+1]=a/t,s+=(r[c+1]-r[c])*(i[c+1]+i[c])/2;return r[e.length+1]=1,i[e.length+1]=1,{fpr:r,tpr:i,auc:s}}function dJ(e){let t=0;for(let n of e)t+=n;if(t===0)return null;let n=new Float64Array(e.length),r=new Float64Array(e.length),i=0,a=0,o=0;for(let s=0;s<e.length;s++)e[s]===1?i++:a++,n[s]=i/t,r[s]=i/(i+a),s>0&&(o+=(n[s]-n[s-1])*r[s]);return{recall:n,precision:r,ap:o}}function fJ(e,t,n,r){let i=n(0),a=r(0);e.moveTo(i,a);for(let o=1;o<t;o++){let s=n(o),c=r(o);o<t-1&&Math.abs(s-i)<.5&&Math.abs(c-a)<.5||(e.lineTo(s,c),i=s,a=c)}}function pJ({scores:e,labels:t,mode:n=`roc`,color:r=`#f472b6`,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(a);G(()=>{l.current=a},[a]);let u=K({scores:e,labels:t,mode:n,color:r});G(()=>{u.current={scores:e,labels:t,mode:n,color:r}},[e,t,n,r]);let d=dt(()=>lJ(e,t),[e,t]),f=dt(()=>n===`pr`?{roc:null,pr:dJ(d)}:{roc:uJ(d),pr:null},[d,n]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function h(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:a,bottom:s,left:c}=cJ,l=t-c-a,d=n-i-s,{bg:f,muted:_,grid:v}=m(),{scores:y,mode:b,color:x}=u.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),y.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,c+8,i+8);return}let S=e=>c+e*l,C=e=>i+(1-e)*d,w=Dz(0,1,wz(1,5));r.strokeStyle=v,r.lineWidth=1,r.setLineDash([3,3]);for(let e of w)r.beginPath(),r.moveTo(S(e),i),r.lineTo(S(e),i+d),r.stroke(),r.beginPath(),r.moveTo(c,C(e)),r.lineTo(c+l,C(e)),r.stroke();if(r.setLineDash([]),b===`roc`&&(r.strokeStyle=_,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(S(0),C(0)),r.lineTo(S(1),C(1)),r.stroke(),r.setLineDash([])),b===`roc`){let e=p.current.roc;if(e){let t=e.fpr.length,n=t=>S(e.fpr[t]),a=t=>C(e.tpr[t]);r.beginPath(),fJ(r,t,n,a),r.strokeStyle=x,r.lineWidth=1,r.stroke(),r.beginPath(),fJ(r,t,n,a),r.lineTo(S(1),C(0)),r.lineTo(S(0),C(0)),r.closePath(),r.fillStyle=x,r.globalAlpha=.15,r.fill(),r.globalAlpha=1,r.fillStyle=x,r.font=`bold 13px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`AUC = ${e.auc.toFixed(3)}`,c+8,i+8)}}else{let e=p.current.pr;if(e){let t=HK(e.recall,e.precision,0,1,Math.max(1,Math.round(l*Math.min(2,window.devicePixelRatio||1))));r.beginPath();for(let n=0;n<t.length;n++){let i=S(e.recall[t[n]]),a=C(e.precision[t[n]]);n===0?r.moveTo(i,a):r.lineTo(i,a)}r.strokeStyle=x,r.lineWidth=1,r.stroke(),r.fillStyle=x,r.font=`bold 13px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`AP = ${e.ap.toFixed(3)}`,c+8,i+8)}}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of w)r.beginPath(),r.moveTo(c-4,C(e)),r.lineTo(c,C(e)),r.stroke(),r.fillText(e.toFixed(1),c-6,C(e));r.textAlign=`center`,r.textBaseline=`top`;for(let e of w)r.beginPath(),r.moveTo(S(e),i+d),r.lineTo(S(e),i+d+4),r.stroke(),r.fillText(e.toFixed(1),S(e),i+d+6);r.strokeStyle=v,r.strokeRect(c,i,l,d),r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(b===`roc`?`False Positive Rate`:`Recall`,c+l/2,n-4),r.save(),r.translate(12,i+d/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.fillText(b===`roc`?`True Positive Rate`:`Precision`,0,0),r.restore()}let v=K(_);v.current=_;let y=K(null);y.current??=DH(()=>v.current(),()=>s.current);let b=()=>y.current.schedule();return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{c.current=null,b()},[i]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),l.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>e.removeEventListener(`contextmenu`,t)},[]),q(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`ROC / PR curve`})})}var mJ={top:20,right:64,bottom:48,left:64};function hJ({xValues:e,series:t,xLabel:n=`Epoch`,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({xValues:e,series:t,xLabel:n});G(()=>{p.current={xValues:e,series:t,xLabel:n}},[e,t,n]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let _=dt(()=>{let n=e=>{let t=1/0,n=-1/0;for(let r of e)for(let e=0;e<r.values.length;e++){let i=r.values[e];i<t&&(t=i),i>n&&(n=i)}if(!Number.isFinite(t))return{lo:0,hi:1};let r=(n-t)*.06||.1;return{lo:t-r,hi:n+r}},r=t.filter(e=>e.axis===`left`),i=t.filter(e=>e.axis===`right`),a=1/0,o=-1/0;for(let t=0;t<e.length;t++){let n=e[t];n<a&&(a=n),n>o&&(o=n)}return{leftExt:n(r.length?r:t),rightExt:n(i.length?i:t),hasRight:i.length>0,xMin:a,xMax:o,ascending:GK(e)}},[e,t]),v=K(_);G(()=>{v.current=_},[_]);function y(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:s,bottom:c,left:l}=mJ,u=t-l-s,d=n-i-c,{bg:f,muted:_,grid:y}=m(),{xValues:b,series:x,xLabel:S}=p.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),b.length===0||x.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let{leftExt:C,rightExt:w,hasRight:T,xMin:E,xMax:D,ascending:O}=v.current,k=e=>l+(e-E)/(D-E||1)*u;a({left:l,top:i,width:u,height:d,x:{v0:E,v1:D},y:{v0:C.lo,v1:C.hi}});let A=e=>i+(1-(e-C.lo)/(C.hi-C.lo))*d,j=e=>i+(1-(e-w.lo)/(w.hi-w.lo))*d,M=wz(C.hi-C.lo,5),N=Dz(C.lo,C.hi,M);r.strokeStyle=y,r.lineWidth=1,r.setLineDash([3,3]);for(let e of N)r.beginPath(),r.moveTo(l,A(e)),r.lineTo(l+u,A(e)),r.stroke();let P=wz(D-E,6),F=Dz(E,D,P);for(let e of F)r.beginPath(),r.moveTo(k(e),i),r.lineTo(k(e),i+d),r.stroke();r.setLineDash([]);let I=Math.min(2,window.devicePixelRatio||1),L=Math.max(1,Math.round(u*I));for(let e of x){let t=e.axis===`right`&&T?j:A,n=Math.min(b.length,e.values.length),i=O&&n>4*L?HK(b,e.values,E,D,L):null;r.beginPath();let a=!1;for(let o=0;o<(i?i.length:n);o++){let n=i?i[o]:o,s=b[n],c=e.values[n];if(s-s!==0||c-c!==0){a=!1;continue}let l=k(s),u=t(c);a?r.lineTo(l,u):(r.moveTo(l,u),a=!0)}r.strokeStyle=e.color,r.lineWidth=1,r.stroke()}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of N)r.beginPath(),r.moveTo(l-4,A(e)),r.lineTo(l,A(e)),r.stroke(),r.fillText(jz(e,M),l-6,A(e));if(T){let e=wz(w.hi-w.lo,5),t=Dz(w.lo,w.hi,e);r.textAlign=`left`;for(let n of t)r.beginPath(),r.moveTo(l+u,j(n)),r.lineTo(l+u+4,j(n)),r.stroke(),r.fillText(jz(n,e),l+u+6,j(n))}r.textAlign=`center`,r.textBaseline=`top`;for(let e of F)r.beginPath(),r.moveTo(k(e),i+d),r.lineTo(k(e),i+d+4),r.stroke(),r.fillText(jz(e,P),k(e),i+d+6);r.strokeStyle=y,r.strokeRect(l,i,u,d),r.fillStyle=_,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(S,l+u/2,n-4);let R=l+8,z=i+6;r.font=`10px ${Q.mono}`,r.textBaseline=`middle`;for(let e of x)r.fillStyle=e.color,r.fillRect(R,z-4,16,3),r.fillStyle=_,r.textAlign=`left`,r.fillText(e.label,R+20,z),R+=r.measureText(e.label).width+36,R>l+u-60&&(R=l+8,z+=14)}function b(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,right:o,bottom:c,left:l}=mJ,d=t-l-o,f=n-a-c,{muted:_}=m(),{xValues:y,series:b}=p.current;if(y.length===0)return;let{xMin:x,xMax:S,ascending:C}=v.current,w=e=>l+(e-x)/(S-x||1)*d,T=Math.max(l,Math.min(l+d,i));r.strokeStyle=_,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(T,a),r.lineTo(T,a+f),r.stroke(),r.setLineDash([]);let E=(T-l)/d,D=Math.round(E*(y.length-1));if(C){let e=x+E*(S-x),t=0,n=y.length;for(;t<n;){let r=t+n>>>1;y[r]<e?t=r+1:n=r}D=t>0&&(t>=y.length||e-y[t-1]<y[t]-e)?t-1:t}if(D<0||D>=y.length)return;let O=a+8;r.font=`10px ${Q.mono}`,r.textBaseline=`top`;for(let e of b)D<e.values.length&&Number.isFinite(e.values[D])&&(r.fillStyle=e.color,r.textAlign=`left`,r.fillText(`${e.label}: ${Mz(e.values[D])}`,T+6,O),O+=14);w(0)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>c.current);let C=()=>S.current.schedule(),w=()=>{xH(d.current),d.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{l.current=null,C()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,w()},r=()=>{u.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Loss curves`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var gJ={top:40,right:24,bottom:40,left:72},_J=`#ef4444`,vJ=`#f97316`,yJ=`#22d3ee`;function bJ(e,t){let n=e.length,r=e.value;if(n===0)return null;let i=0;for(let e=0;e<n;e++)i+=r[e];let a=i/n,o=0;for(let e=0;e<n;e++)o+=(r[e]-a)**2;let s=Math.sqrt(o/n),c=a+t*s,l=a-t*s,u=l,d=c,f=0;for(let e=0;e<n;e++){let t=r[e];t<u&&(u=t),t>d&&(d=t),(t>c||t<l)&&f++}let p=(d-u)*.08||.5,m=new Uint32Array(f);for(let e=0,t=0;e<n;e++)(r[e]>c||r[e]<l)&&(m[t++]=e);return{mean:a,sd:s,ucl:c,lcl:l,yMin:u-p,yMax:d+p,ooc:m}}function xJ({points:e,sigmaLevel:t=3,color:n=`#22d3ee`,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({points:e,sigmaLevel:t,color:n});G(()=>{p.current={points:e,sigmaLevel:t,color:n}},[e,t,n]);function m(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function h(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}let _=dt(()=>bJ(e,t),[e,t]),v=K(_);G(()=>{v.current=_},[_]);let y=()=>v.current;function b(){let e=o.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{top:i,right:s,bottom:c,left:l}=gJ,u=t-l-s,d=n-i-c,{bg:f,muted:_,grid:v}=m(),{points:b,color:x}=p.current;if(r.fillStyle=f,r.fillRect(0,0,t,n),b.length===0){r.fillStyle=_,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,l+8,i+8);return}let S=y(),{mean:C,ucl:w,lcl:T,yMin:E,yMax:D}=S,O=e=>l+e/(b.length-1||1)*u;a({left:l,top:i,width:u,height:d,x:{v0:0,v1:b.length-1||1}});let k=e=>i+(1-(e-E)/(D-E))*d,A=wz(D-E,5),j=Dz(E,D,A);r.strokeStyle=v,r.lineWidth=1,r.setLineDash([3,3]);for(let e of j)r.beginPath(),r.moveTo(l,k(e)),r.lineTo(l+u,k(e)),r.stroke();r.setLineDash([]);let M=(e,t,n,a=[])=>{let o=k(e);o<i||o>i+d||(r.strokeStyle=t,r.lineWidth=1.2,r.setLineDash(a),r.beginPath(),r.moveTo(l,o),r.lineTo(l+u,o),r.stroke(),r.setLineDash([]),r.fillStyle=t,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(`${n} ${Mz(e)}`,l+u-2,o-5))};M(w,vJ,`UCL`,[5,3]),M(C,yJ,`CL`,[]),M(T,vJ,`LCL`,[5,3]);let N=Math.min(2,window.devicePixelRatio||1),P=Math.max(1,Math.round(u*N)),F=b.length,I=b.value,L=UK(I,P);r.beginPath();for(let e=0;e<L.length;e++){let t=L[e],n=O(t),i=k(I[t]);e===0?r.moveTo(n,i):r.lineTo(n,i)}r.strokeStyle=x,r.lineWidth=1,r.stroke();let R=(e,t)=>{r.beginPath(),r.arc(O(e),k(I[e]),t?4:3,0,Math.PI*2),r.fillStyle=t?_J:x,r.fill()};if(F<=u/4)for(let e=0;e<F;e++)R(e,I[e]>w||I[e]<T);else{let e=NaN,t=NaN;for(let n of S.ooc){let r=Math.round(O(n)),i=Math.round(k(I[n]));r===e&&i===t||(e=r,t=i,R(n,!0))}}r.fillStyle=_,r.font=`11px ${Q.mono}`,r.strokeStyle=_,r.lineWidth=1,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of j)r.beginPath(),r.moveTo(l-4,k(e)),r.lineTo(l,k(e)),r.stroke(),r.fillText(jz(e,A),l-6,k(e));r.strokeStyle=v,r.strokeRect(l,i,u,d)}function x(){let e=s.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,right:o,bottom:c,left:l}=gJ,d=t-l-o,f=n-a-c,{muted:_}=m(),{points:v}=p.current;if(v.length===0)return;let{ucl:b,lcl:x,yMin:S,yMax:C}=y(),w=e=>l+e/(v.length-1||1)*d,T=e=>a+(1-(e-S)/(C-S))*f,E=Math.round((i-l)/d*(v.length-1));if(E<0||E>=v.length)return;let D=v.value[E],O=w(E),k=T(D);r.strokeStyle=_,r.lineWidth=1,r.setLineDash([3,3]),r.beginPath(),r.moveTo(O,a),r.lineTo(O,a+f),r.stroke(),r.setLineDash([]);let A=v.subgroup?.(E),j=`${A?`${A}: `:`#${E+1}: `}${Mz(D)}`;r.font=`11px ${Q.mono}`;let M=r.measureText(j).width,N=O+8+M>l+d?O-M-10:O+8;r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(N-3,k-12,M+6,18),r.fillStyle=D>b||D<x?_J:_,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(j,N,k-11)}let S=K(b);S.current=b;let C=K(null);C.current??=DH(()=>S.current(),()=>c.current);let w=()=>C.current.schedule(),T=()=>{xH(d.current),d.current=bH(x)};return W(()=>{C.current.now()}),W(()=>()=>C.current?.cancel(),[]),W(()=>{l.current=null,w()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,w(),T()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,T()},r=()=>{u.current=null,T()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Control chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var SJ={top:32,right:24,bottom:24,left:24},CJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],wJ=16;function TJ(e){return`rgb(${Math.round(255*Math.min(1,Math.max(0,3.5*e-.5)))},${Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e)))},${Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))})`}function EJ(e,t,n,r){let i=Math.min(t,e.columns.length),a=e.columns.slice(0,i).map(t=>{let n=1/0,r=-1/0;for(let i=0;i<e.length;i++){let e=t[i];e<n&&(n=e),e>r&&(r=e)}if(!Number.isFinite(n))return{lo:0,hi:1};let i=(r-n)*.05||.5;return{lo:n-i,hi:r+i}}),o={lo:0,hi:1},s=new Int32Array(e.length),c=[r];if(n&&e.colorValue){let t=e.colorValue,n=1/0,r=-1/0;for(let i=0;i<e.length;i++)t[i]<n&&(n=t[i]),t[i]>r&&(r=t[i]);Number.isFinite(n)&&(o={lo:n,hi:r}),c=Array.from({length:wJ},(e,t)=>TJ((t+.5)/wJ));for(let n=0;n<e.length;n++){let e=(t[n]-o.lo)/(o.hi-o.lo||1);s[n]=t[n]===t[n]?Math.max(0,Math.min(wJ-1,Math.floor(e*wJ))):-1}for(let t=0;t<e.length;t++)s[t]<0&&(s[t]=0)}else if(!n&&e.colorIndex){c=CJ;for(let t=0;t<e.length;t++)s[t]=Math.max(0,e.colorIndex[t])%CJ.length}let l=new Int32Array(c.length);for(let t=0;t<e.length;t++)l[s[t]]++;let u=c.map((e,t)=>({color:e,x:new Float64Array(l[t]*i),y:new Float64Array(l[t]*i),starts:new Uint8Array(l[t]*i)})),d=new Int32Array(c.length);for(let t=0;t<e.length;t++){let n=u[s[t]],r=d[s[t]]++*i;n.starts[r]=1;for(let o=0;o<i;o++,r++){let i=a[o];n.x[r]=o,n.y[r]=(e.columns[o][t]-i.lo)/(i.hi-i.lo)}}return{k:i,extents:a,colorExt:o,groups:u.filter(e=>e.x.length>0)}}function DJ({rows:e,axes:t,color:n=`#64748b`,colorByNumeric:r=!1,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(null),p=K(0),m=K(a);G(()=>{m.current=a},[a]);let h=dt(()=>EJ(e,t.length,r,n),[e,t.length,r,n]),g=K({rows:e,axes:t,colorByNumeric:r,model:h});G(()=>{g.current={rows:e,axes:t,colorByNumeric:r,model:h}},[e,t,r,h]);let _=LK(s),v=K(null);function y(){if(d.current)return d.current;let e=u.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return d.current=n,n}function b(){let e=u.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function x(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function S(){let e=o.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;let i=c.current?x(c.current,t,n):null;i?.clearRect(0,0,t,n);let a=i??r,{top:s,right:l,bottom:d,left:f}=SJ,{bg:p,muted:m}=y(),{rows:h,axes:S,colorByNumeric:C,model:w}=g.current;r.fillStyle=p,r.fillRect(0,0,t,n);let T=_(t,n);if(S.length<2||h.length===0||w.k<2){T?.keep([]),T?.render(),r.fillStyle=m,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`Select ≥ 2 axes`,f+8,s+8);return}let E=t-f-l,D=n-s-d,O=w.k,k=Array.from({length:O},(e,t)=>f+t/(O-1)*E),A=(e,t)=>{let n=w.extents[t];return s+(1-(e-n.lo)/(n.hi-n.lo))*D},j=Math.max(.05,Math.min(.7,60/h.length));if(T)v.current!==w&&(w.groups.forEach((e,t)=>T.setLine(`c${t}`,e.x,e.y,XG(e.color,j),1,e.starts)),v.current=w,CH(u.current)),T.keep(w.groups.map((e,t)=>`c${t}`)),T.setView(0,O-1,0,1,{left:f,top:s,width:E,height:D}),T.render();else{r.globalAlpha=j;for(let e of w.groups){r.beginPath();let t=!1;for(let n=0;n<e.x.length;n++){let i=e.y[n];if(e.starts[n]&&(t=!1),i!==i){t=!1;continue}let a=f+e.x[n]/(O-1)*E,o=s+(1-i)*D;t?r.lineTo(a,o):(r.moveTo(a,o),t=!0)}r.strokeStyle=e.color,r.lineWidth=1,r.stroke()}r.globalAlpha=1}a.strokeStyle=m,a.lineWidth=1.5;for(let e=0;e<O;e++)a.beginPath(),a.moveTo(k[e],s),a.lineTo(k[e],s+D),a.stroke();a.fillStyle=m,a.font=`9px ${Q.mono}`;for(let e=0;e<O;e++){let t=w.extents[e];for(let n of[0,.25,.5,.75,1]){let r=t.lo+n*(t.hi-t.lo),i=A(r,e);a.beginPath(),a.moveTo(k[e]-3,i),a.lineTo(k[e]+3,i),a.stroke(),a.textAlign=e===O-1?`left`:`right`,a.textBaseline=`middle`,a.fillText(jz(r,(t.hi-t.lo)/4),k[e]+(e===O-1?5:-5),i)}a.font=`10px ${Q.mono}`,a.textAlign=`center`,a.textBaseline=`bottom`,a.fillText(S[e],k[e],s-4)}let M=h.colorLabels??[];if(!C&&M.length>0&&M.length<=10){let e=f,t=s+D+8;a.font=`9px ${Q.mono}`,a.textBaseline=`top`,M.forEach((n,r)=>{a.fillStyle=CJ[r%CJ.length],a.fillRect(e,t,10,8),a.fillStyle=m,a.textAlign=`left`,a.fillText(n,e+13,t),e+=a.measureText(n).width+26,e>f+E-40&&(e=f,t+=12)})}}function C(){let e=l.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=f.current;if(i===null)return;let{top:a,right:o,bottom:s,left:c}=SJ,{axes:u}=g.current;if(u.length<2)return;let d=t-c-o,p=c+i/(u.length-1)*d;r.strokeStyle=`rgba(255,255,255,0.6)`,r.lineWidth=2,r.beginPath(),r.moveTo(p,a-4),r.lineTo(p,a+(n-a-s)+4),r.stroke()}let w=K(S);w.current=S;let T=K(null);T.current??=DH(()=>w.current(),()=>u.current);let E=()=>T.current.schedule(),D=()=>{xH(p.current),p.current=bH(C)};return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{d.current=null,E()},[i]),G(()=>{let e=u.current;if(!e)return;let t=new EH(()=>{d.current=null,E(),D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=l.current;if(!e)return;let t=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{axes:r}=g.current;if(r.length<2)return;let i=n.width-SJ.left-SJ.right,a=r.length,o=t.clientX-n.left-SJ.left,s=Math.round(o/i*(a-1));f.current=Math.abs(o-s/(a-1)*i)<20&&s>=0&&s<a?s:null,D()},r=()=>{f.current=null,D()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:u,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Parallel coordinates`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:l,className:`chart-canvas chart-overlay`})]})}function OJ(e,t,n,r,i,a){let o=Math.max(1,Math.ceil(t/r)),s=Math.max(1,Math.ceil(n/r)),c=e=>{let s=i(e),c=a(e);return s>=0&&s<t&&c>=0&&c<n?Math.floor(c/r)*o+Math.floor(s/r):-1},l=new Uint32Array(o*s+1);for(let t=0;t<e;t++){let e=c(t);e>=0&&l[e+1]++}for(let e=0;e<o*s;e++)l[e+1]+=l[e];let u=l.slice(0,o*s),d=new Uint32Array(l[o*s]);for(let t=0;t<e;t++){let e=c(t);e>=0&&(d[u[e]++]=t)}return{cell:r,nx:o,ny:s,start:l,ix:d}}function kJ(e,t,n,r,i,a,o){let s=Math.floor(t/e.cell),c=Math.floor(n/e.cell),l=-1,u=r*r;for(let r=c-1;r<=c+1;r++)if(!(r<0||r>=e.ny))for(let c=s-1;c<=s+1;c++){if(c<0||c>=e.nx)continue;let s=r*e.nx+c;for(let r=e.start[s];r<e.start[s+1];r++){let s=e.ix[r],c=(i(s)-t)**2+(a(s)-n)**2;c<u&&(!o||c<o(s)**2)&&(u=c,l=s)}}return l<0?null:l}var AJ={top:16,right:16,bottom:16,left:16},jJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function MJ(e){return[Math.round(255*Math.min(1,Math.max(0,3.5*e-.5))),Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e))),Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))]}function NJ(e){let[t,n,r]=MJ(e);return`rgb(${t},${n},${r})`}var PJ=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...MJ(t/255),255],t*4);return e})(),FJ=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=XG(jJ[t%jJ.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e});function IJ(e,t){let n=1/0,r=-1/0,i=1/0,a=-1/0;for(let t=0;t<e.length;t++){let o=e.x[t],s=e.y[t];o<n&&(n=o),o>r&&(r=o),s<i&&(i=s),s>a&&(a=s)}let o=!Number.isFinite(n)||!Number.isFinite(i)?{xLo:-1,xHi:1,yLo:-1,yHi:1}:(()=>{let e=(r-n)*.05||.5,t=(a-i)*.05||.5;return{xLo:n-e,xHi:r+e,yLo:i-t,yHi:a+t}})(),s={lo:0,hi:1},c=null,l=`single`;if(t&&e.colorValue){let t=e.colorValue,n=1/0,r=-1/0;for(let i=0;i<e.length;i++){let e=t[i];e<n&&(n=e),e>r&&(r=e)}Number.isFinite(n)&&(s={lo:n,hi:r}),c=new Float32Array(e.length);let i=s.hi-s.lo;for(let n=0;n<e.length;n++)c[n]=t[n]===t[n]?Math.max(0,Math.min(1,i>0?(t[n]-s.lo)/i:.5)):0;l=`colormap`}else !t&&e.colorIndex&&(c=Float32Array.from(e.colorIndex,e=>e>=0?e%256:0),l=`dataset`);return{ext:o,colorExt:s,key:c,mode:l}}function LJ({points:e,color:t=`#64748b`,colorByNumeric:n=!1,pointSize:r=4,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(0),p=K(a);G(()=>{p.current=a},[a]);let m=dt(()=>IJ(e,n),[e,n]),h=K({points:e,color:t,colorByNumeric:n,pointSize:r,model:m});G(()=>{h.current={points:e,color:t,colorByNumeric:n,pointSize:r,model:m}},[e,t,n,r,m]);let g=K({r:null,failed:!1,size:``,model:null,style:``});W(()=>()=>{g.current.r?.dispose(),g.current.r=null},[]);function _(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function v(){let e=l.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function y(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function b(e,t){let{top:n,right:r,bottom:i,left:a}=AJ,o=e-a-r,s=t-n-i,c=h.current.model.ext;return{xToPx:e=>a+(e-c.xLo)/(c.xHi-c.xLo)*o,yToPx:e=>n+(1-(e-c.yLo)/(c.yHi-c.yLo))*s,plotW:o,plotH:s,ext:c}}function x(e,t){let n=g.current;!n.r&&!n.failed&&s.current&&(n.r=uH(s.current,qW),n.failed=!n.r);let r=n.r;if(!r||!s.current)return null;let i=Math.min(2,window.devicePixelRatio||1),a=`${e}x${t}@${i}`;n.size!==a&&(r.resize(e,t,i),s.current.style.width=`${e}px`,s.current.style.height=`${t}px`,n.size=a);let{points:o,model:c,color:u,pointSize:d}=h.current;n.model!==c&&(r.setData(o.x,o.y,c.key??void 0),n.model=c,CH(l.current));let f=`${c.mode}|${u}|${d}`;return n.style!==f&&(r.setStyle(c.mode===`single`?{kind:`single`,rgba:XG(u,1)}:{kind:c.mode,palette:c.mode===`colormap`?PJ:FJ()},d,.8),r.setDraw(!0,!1,0),n.style=f),r}function S(){let e=o.current;if(!e)return;let{w:t,h:n}=v(),r=y(e,t,n);if(!r)return;let{bg:i,muted:a}=_(),{points:s,color:c,colorByNumeric:l,pointSize:u,model:d}=h.current;r.fillStyle=i,r.fillRect(0,0,t,n);let f=x(t,n);if(s.length===0){f?.setData([],[]),g.current.model=null,f?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,AJ.left+8,AJ.top+8);return}let p=d.colorExt,{xToPx:m,yToPx:S,plotW:C,plotH:w,ext:T}=b(t,n);if(f)f.setView(T.xLo,T.xHi,T.yLo,T.yHi,{left:AJ.left,top:AJ.top,width:C,height:w}),f.render();else{for(let e=0;e<s.length;e++){let t=s.x[e],n=s.y[e];if(t!==t||n!==n)continue;let i=d.key?.[e]??0;r.beginPath(),r.arc(m(t),S(n),u,0,Math.PI*2),r.fillStyle=d.mode===`colormap`?NJ(i):d.mode===`dataset`?jJ[i%jJ.length]:c,r.globalAlpha=.8,r.fill()}r.globalAlpha=1}if(l){let e=Math.min(120,Math.floor((n-AJ.top-AJ.bottom)*.4)),i=t-AJ.right-12,o=AJ.top+8;for(let t=0;t<e;t++)r.fillStyle=NJ(1-t/(e-1)),r.fillRect(i,o+t,8,1);r.fillStyle=a,r.font=`9px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`;let s=e=>Math.abs(e)>=1e4||Math.abs(e)<.001&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(3)));r.fillText(s(p.hi),i+10,o),r.fillText(s(p.lo),i+10,o+e)}let E=s.colorLabels??[];if(!l&&E.length>0&&E.length<=10){let e=AJ.left,i=n-AJ.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`,E.forEach((n,o)=>{e>t-AJ.right-60&&(e=AJ.left,i-=14),r.fillStyle=jJ[o%jJ.length],r.beginPath(),r.arc(e+4,i+4,4,0,Math.PI*2),r.fill(),r.fillStyle=a,r.textAlign=`left`,r.fillText(n,e+10,i),e+=r.measureText(n).width+20})}}function C(){let e=c.current;if(!e)return;let{w:t,h:n}=v(),r=y(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=d.current;if(i===null)return;let{points:a,pointSize:o}=h.current;if(i<0||i>=a.length)return;let{xToPx:s,yToPx:l}=b(t,n),u=a.x[i],f=a.y[i],p=s(u),m=l(f);r.beginPath(),r.arc(p,m,o+3,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let g=[],_=a.label?.(i);_&&g.push(_);let x=a.colorIndex?.[i];x!==void 0&&x>=0&&a.colorLabels?g.push(a.colorLabels[x]):a.colorValue&&g.push(a.colorValue[i].toFixed(3)),g.push(`(${u.toFixed(3)}, ${f.toFixed(3)})`);let S=g.join(` · `);r.font=`11px ${Q.mono}`;let C=r.measureText(S).width,w=Math.max(4,Math.min(t-C-8,p+10)),T=m-20<AJ.top?m+10:m-20;r.fillStyle=`rgba(0,0,0,0.75)`,r.fillRect(w-3,T-3,C+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(S,w,T)}let w=K(S);w.current=S;let T=K(null);T.current??=DH(()=>w.current(),()=>l.current);let E=()=>T.current.schedule(),D=()=>{xH(f.current),f.current=bH(C)};return W(()=>{T.current.now()}),W(()=>()=>T.current?.cancel(),[]),W(()=>{u.current=null,E()},[i]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,E(),D()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=c.current;if(!e)return;let t=null,n=e=>{e.preventDefault(),p.current?.({clientX:e.clientX,clientY:e.clientY})},r=n=>{let r=e.getBoundingClientRect(),{points:i,pointSize:a,model:o}=h.current,{w:s,h:c}=v(),{xToPx:l,yToPx:u,plotW:f,plotH:p}=b(s,c),m=e=>l(i.x[e])-AJ.left,g=e=>u(i.y[e])-AJ.top,_=a+8,y=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==y)&&(t={model:o,key:y,g:OJ(i.length,f,p,_,m,g)}),d.current=kJ(t.g,n.clientX-r.left-AJ.left,n.clientY-r.top-AJ.top,_,m,g),D()},i=()=>{d.current=null,D()};return e.addEventListener(`contextmenu`,n),e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,i),()=>{e.removeEventListener(`contextmenu`,n),e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,i)}},[]),_t(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Embedding / scatter`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`})]})}var RJ={top:8,right:8,bottom:8,left:8},zJ=20,BJ=[`#f97316`,`#fb923c`,`#fdba74`,`#fbbf24`,`#fcd34d`,`#4ade80`,`#34d399`,`#38bdf8`,`#818cf8`,`#a78bfa`];function VJ(e){let t=new Map;for(let n of e){let e=n.parent??``;t.has(e)||t.set(e,[]),t.get(e).push(n)}function n(r,i){let a=(t.get(r)??[]).map(e=>n(e.name,i+1)),o=e.find(e=>e.name===r),s=a.reduce((e,t)=>e+t.value,0);return{name:r,value:o?Math.max(o.value,s):s,children:a,depth:i,x0:0,x1:1}}let r=new Set(e.map(e=>e.name)),i=e.filter(e=>!e.parent||!r.has(e.parent)).map(e=>n(e.name,0)),a=i.reduce((e,t)=>e+t.value,0)||1;function o(e,t,n){e.x0=t,e.x1=n;let r=n-t,i=t;for(let t of e.children){let n=t.value/e.value*r;o(t,i,i+n),i+=n}}let s=0;for(let e of i){let t=e.value/a;o(e,s,s+t),s+=t}return i}function HJ(e){let t=[];function n(e){t.push(e);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function UJ(e){let t=0;function n(e){e.depth>t&&(t=e.depth);for(let t of e.children)n(t)}for(let t of e)n(t);return t}function WJ(e){return BJ[e%BJ.length]}function GJ({nodes:e,direction:t=`bottomup`,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(r);G(()=>{u.current=r},[r]);let d=K({nodes:e,direction:t});G(()=>{d.current={nodes:e,direction:t}},[e,t]);let f=dt(()=>{let t=VJ(e);return{roots:t,flat:HJ(t),numRows:UJ(t)+1}},[e]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function h(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||400)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(e,t,n,r,i){let a=RJ.left+e.x0*t,o=(e.x1-e.x0)*t;return{x:a,y:i===`topdown`?RJ.top+e.depth*zJ:RJ.top+n-(e.depth+1)*zJ,w:o,h:zJ-1}}function v(){let e=i.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;let{bg:a,muted:o}=m(),{nodes:s,direction:c}=d.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),s.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,RJ.left+8,RJ.top+8);return}let{flat:l,numRows:u}=p.current,f=t-RJ.left-RJ.right,v=u*zJ;for(let e of l){let t=_(e,f,v,u,c);if(!(t.w<1)&&(r.fillStyle=WJ(e.depth),r.fillRect(t.x,t.y,t.w,t.h),t.w>24)){r.fillStyle=`rgba(0,0,0,0.75)`,r.font=`${Math.min(11,zJ-4)}px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`middle`;let n=e.name,i=Math.floor((t.w-4)/7),a=n.length>i?n.slice(0,i-1)+`…`:n;r.fillText(a,t.x+3,t.y+zJ/2)}}}function y(){let e=a.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(!i)return;let{direction:o}=d.current,{roots:s,numRows:l}=p.current;if(s.length===0)return;let u=_(i,t-RJ.left-RJ.right,l*zJ,l,o);r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.strokeRect(u.x+1,u.y+1,u.w-2,u.h-2);let f=`${i.name} (${i.value.toLocaleString()})`;r.font=`11px ${Q.mono}`;let m=r.measureText(f).width,v=Math.max(4,Math.min(t-m-8,u.x+u.w/2-m/2)),y=u.y<30?u.y+zJ+4:u.y-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(v-3,y-3,m+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(f,v,y)}let b=K(v);b.current=v;let x=K(null);x.current??=DH(()=>b.current(),()=>o.current);let S=()=>x.current.schedule(),C=()=>{xH(l.current),l.current=bH(y)};return W(()=>{x.current.now()}),W(()=>()=>x.current?.cancel(),[]),W(()=>{s.current=null,S()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,S(),C()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{direction:r}=d.current,{roots:i,flat:a,numRows:o}=p.current;if(i.length===0){c.current=null,C();return}let s=t.clientX-n.left,l=t.clientY-n.top,u=n.width-RJ.left-RJ.right,f=o*zJ,m=null;for(let e of a){let t=_(e,u,f,o,r);if(s>=t.x&&s<=t.x+t.w&&l>=t.y&&l<=t.y+t.h){m=e;break}}c.current=m,C()},r=()=>{c.current=null,C()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Flame graph`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var KJ={top:24,right:24,bottom:52,left:56},qJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],JJ=.8;function YJ(e,t,n,r){let i,a,o;if(t)a=t.length,i=t.values,o=e=>String(e+1);else{let t=e??[];a=t.length,i=Array.from({length:n},(e,n)=>Float64Array.from(t,e=>e.values[n]??0)),o=e=>t[e].label}let s=0,c=0;if(r===`stacked`)for(let e=0;e<a;e++){let t=0,n=0;for(let r of i){let i=r[e];i>0?t+=i:i<0&&(n+=i)}t>c&&(c=t),n<s&&(s=n)}else for(let e of i)for(let t=0;t<a;t++){let n=e[t];n>c&&(c=n),n<s&&(s=n)}return c===s&&(c=s+1),{n:a,values:i,label:o,lo:s,hi:c}}function XJ(e,t,n){let r=e.values.length,i=[],a=[],o=[],s=[],c=[],l=(e,t,n,r,l)=>{i.push(e),a.push(t),o.push(n),s.push(r),c.push(l)};if(e.n<=n)for(let n=0;n<e.n;n++)if(t===`grouped`){let t=.8/r;for(let i=0;i<r;i++){let r=e.values[i][n];r===r&&l(n-.4+i*t,n-.4+(i+1)*t-t*.05,0,r,i)}}else{let t=0,i=0;for(let a=0;a<r;a++){let r=e.values[a][n];r!==r||r===0||(r>0?(l(n-.4,n+.4,t,t+r,a),t+=r):(l(n-.4,n+.4,i,i+r,a),i+=r))}}else{let i=e.n/n,a=new Float64Array(r),o=new Float64Array(r);for(let s=0;s<n;s++){let n=Math.floor(s*i),c=Math.min(e.n,Math.floor((s+1)*i));if(!(c<=n)){a.fill(0),o.fill(0);for(let i=n;i<c;i++){let n=0,s=0;for(let c=0;c<r;c++){let r=e.values[c][i];r===r&&(t===`stacked`?r>0?(n+=r,n>o[c]&&(o[c]=n)):(s+=r,s<a[c]&&(a[c]=s)):(r>o[c]&&(o[c]=r),r<a[c]&&(a[c]=r)))}}for(let e=t===`stacked`?r-1:0;t===`stacked`?e>=0:e<r;t===`stacked`?e--:e++)(o[e]!==0||a[e]!==0)&&l(n-.5,c-.5,a[e],o[e],e)}}}return{x0:Float64Array.from(i),x1:Float64Array.from(a),y0:Float64Array.from(o),y1:Float64Array.from(s),k:Float64Array.from(c)}}function ZJ({groups:e,columns:t,seriesNames:n,colors:r,mode:i=`grouped`,horizontal:a=!1,valueRange:o,backgroundToken:s=``,onPlotContextMenu:c}){let l=nU(),u=K(null),d=K(null),f=K(null),p=K(null),m=K(null),h=K(null),g=K(0),_=K(c);G(()=>{_.current=c},[c]);let v=K(null),y=dt(()=>{let r=[e,i,n.length,t?.length,...t?.values??[]],a=v.current;if(a&&a.key.length===r.length&&a.key.every((e,t)=>e===r[t]))return a.value;let o=YJ(e,t,n.length,i);return v.current={key:r,value:o},o},[e,t,n.length,i]),b=K({bars:y,seriesNames:n,colors:r,mode:i,horizontal:a,valueRange:o});G(()=>{b.current={bars:y,seriesNames:n,colors:r,mode:i,horizontal:a,valueRange:o}},[y,n,r,i,a,o]);let x=K({plot:null,failed:!1,key:``,data:null,size:``});W(()=>()=>{x.current.plot?.dispose(),x.current.plot=null},[]);let S=K({bars:null,view:``});function C(){if(m.current)return m.current;let e=p.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return m.current=n,n}function w(){let e=p.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function T(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function E(e){let t=b.current.colors??[];return Array.from({length:e},(e,n)=>t[n]??qJ[n%qJ.length])}function D(e,t){let{bars:n,valueRange:r}=b.current,i=n.lo,a=n.hi;r?.min!==void 0&&Number.isFinite(r.min)&&(i=r.min),r?.max!==void 0&&Number.isFinite(r.max)&&(a=r.max);let o=YW(KJ,e,t),{top:s,right:c,bottom:l,left:u}=o;return{lo:i,hi:a,top:s,left:u,plotW:e-u-c,plotH:t-s-l,tiny:o.tiny}}function O(e,t){let n=x.current;if(!n.plot&&!n.failed&&d.current&&(n.plot=uH(d.current,IK),n.failed=!n.plot),!n.plot||!d.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),d.current.style.width=`${e}px`,d.current.style.height=`${t}px`,n.size=i),n.plot}function k(){let e=u.current;if(!e)return;let{w:t,h:n}=w(),r=T(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=C(),{bars:s,seriesNames:c,mode:d,horizontal:f}=b.current;r.fillStyle=i,r.fillRect(0,0,t,n);let m=O(t,n);if(s.n===0||c.length===0){m?.keep([]),m?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,KJ.left+8,KJ.top+8);return}let{lo:h,hi:g,top:_,left:v,plotW:y,plotH:k,tiny:A}=D(t,n),j=E(c.length),M=f?k:y,N=e=>f?v+(e-h)/(g-h)*y:_+k-(e-h)/(g-h)*k,P=e=>(f?_:v)+(e+.5)/s.n*M;l({left:v,top:_,width:y,height:k,...f?{x:{v0:h,v1:g}}:{y:{v0:h,v1:g}}}),r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<=5;e++){let t=h+e/5*(g-h),n=N(t);r.beginPath(),f?(r.moveTo(n,_),r.lineTo(n,_+k)):(r.moveTo(v,n),r.lineTo(v+y,n)),r.stroke(),r.fillStyle=a,r.font=`9px ${Q.mono}`,!A&&(f?(r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(g-h)/5),n,_+k+4)):(r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(t,(g-h)/5),v-4,n)))}let F=`${h}|${g}|${f}`;(S.current.bars!==s||S.current.view!==F)&&(S.current={bars:s,view:F},CH(p.current));let I=Math.min(2,window.devicePixelRatio||1),L=Math.max(1,Math.round(M*I)),R=j.map(e=>{let t=zV(e);return[t[0],t[1],t[2],JJ]}),z={left:v,top:_,width:y,height:k};if(m){let e=`${d}|${f}|${L}|${j.join(`,`)}`;if(x.current.key!==e||x.current.data!==s){let t=XJ(s,d,L);f?m.setRects(`bars`,t.y0,t.y1,t.x0,t.x1,R,t.k):m.setRects(`bars`,t.x0,t.x1,t.y0,t.y1,R,t.k),m.keep([`bars`]),x.current.key=e,x.current.data=s}f?m.setView(h,g,s.n-.5,-.5,z):m.setView(-.5,s.n-.5,h,g,z),m.render()}else{let e=XJ(s,d,L);r.globalAlpha=JJ;for(let t=0;t<e.x0.length;t++){r.fillStyle=j[e.k[t]];let n=P(e.x0[t]-.5),i=P(e.x1[t]-.5),a=N(e.y0[t]),o=N(e.y1[t]);f?r.fillRect(Math.min(a,o),n,Math.max(1,Math.abs(o-a)),Math.max(1,i-n)):r.fillRect(n,Math.min(a,o),Math.max(1,i-n),Math.max(1,Math.abs(o-a)))}r.globalAlpha=1}if(h<0&&g>0){let e=N(0);r.strokeStyle=a,r.lineWidth=1.5,r.beginPath(),f?(r.moveTo(e,_),r.lineTo(e,_+k)):(r.moveTo(v,e),r.lineTo(v+y,e)),r.stroke()}r.fillStyle=a,r.font=`9px ${Q.mono}`;let B=Math.max(1,Math.ceil(s.n/Math.max(1,Math.floor(M/(f?14:48)))));for(let e=0;e<(A?0:s.n);e+=B){let t=P(e),n=s.label(e),i=n.length>14?n.slice(0,13)+`…`:n;f?(r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(i,v-4,t)):(r.textAlign=`center`,r.textBaseline=`top`,r.fillText(i,t,_+k+4))}if(c.length>1&&!A){let e=f?_-14:_+k+32,t=v;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<c.length&&(r.fillStyle=j[n],r.fillRect(t,e,10,8),r.fillStyle=a,r.textAlign=`left`,r.fillText(c[n],t+13,e),t+=r.measureText(c[n]).width+26,!(t>v+y-30));n++);}}function A(){let e=f.current;if(!e)return;let{w:t,h:n}=w(),r=T(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=h.current,{bars:a,seriesNames:o,horizontal:s}=b.current;if(i===null||i>=a.n)return;let{top:c,left:l,plotW:u,plotH:d}=D(t,n),p=s?d:u,m=(s?c:l)+(i+.5)/a.n*p,g=Math.max(1,p/a.n);r.fillStyle=`rgba(255,255,255,0.08)`,s?r.fillRect(l,m-g/2,u,g):r.fillRect(m-g/2,c,g,d);let _=a.values.map((e,t)=>`${o.length>1?o[t]+` `:``}${Mz(e[i])}`).join(` `),v=`${a.label(i)}: ${_}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,x=s?l+u/2:m,S=s?m:c+d/2,C=Math.max(4,Math.min(t-y-8,x-y/2)),E=S-28<c?S+10:S-24;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(C-3,E-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,E)}let j=K(k);j.current=k;let M=K(null);M.current??=DH(()=>j.current(),()=>p.current);let N=()=>{g.current||=bH(()=>{g.current=0,A()})};return W(()=>{M.current.now()},[y,n,r,i,a,o]),W(()=>()=>{M.current?.cancel(),xH(g.current)},[]),W(()=>{m.current=null,M.current.schedule()},[s]),G(()=>{let e=p.current;if(!e)return;let t=new EH(()=>{m.current=null,M.current.schedule(),N()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=f.current;if(!e)return;let t=e=>{e.preventDefault(),_.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{bars:r,horizontal:i}=b.current,{w:a,h:o}=w(),{top:s,left:c,plotW:l,plotH:u}=D(a,o),d=i?t.clientY-n.top-s:t.clientX-n.left-c,f=i?u:l,p=d>=0&&d<f&&r.n>0?Math.min(r.n-1,Math.floor(d/f*r.n)):null;p!==h.current&&(h.current=p,N())},r=()=>{h.current=null,N()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:p,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:u,className:`chart-canvas`,role:`img`,"aria-label":`Bar chart`}),q(`canvas`,{ref:d,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:f,className:`chart-canvas chart-overlay`})]})}var QJ=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function $J(e,t){if(!t)return QJ[e%QJ.length];if(e===0)return t;let n=QJ.filter(e=>e.toLowerCase()!==t.toLowerCase());return n[(e-1)%n.length]}var eY={top:36,right:36,bottom:36,left:36};function tY({axes:e,series:t,fill:n=!0,color:r,backgroundToken:i=``,onPlotContextMenu:a}){let o=K(null),s=K(null),c=K(null),l=K(null),u=K(a);G(()=>{u.current=a},[a]);let d=K({axes:e,series:t,fill:n,color:r});G(()=>{d.current={axes:e,series:t,fill:n,color:r}},[e,t,n,r]);function f(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function p(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=o.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;let{bg:i,muted:a,grid:s}=f(),{axes:c,series:l,fill:u}=d.current;if(r.fillStyle=i,r.fillRect(0,0,t,n),c.length<3||l.length===0){r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`Select ≥ 3 axes`,eY.left+8,eY.top+8);return}let h=c.length,g=t/2,_=n/2,v=Math.min(t-eY.left-eY.right,n-eY.top-eY.bottom)/2,y=c.map((e,t)=>{let n=0;for(let e of l){let r=e.values[t]??0;r>n&&(n=r)}return n||1});function b(e){return Math.PI*2*e/h-Math.PI/2}function x(e,t){let n=b(e);return{x:g+Math.cos(n)*v*t,y:_+Math.sin(n)*v*t}}for(let e=1;e<=4;e++){let t=e/4;r.beginPath();for(let e=0;e<h;e++){let n=x(e,t);e===0?r.moveTo(n.x,n.y):r.lineTo(n.x,n.y)}r.closePath(),r.strokeStyle=s,r.lineWidth=1,r.stroke()}r.strokeStyle=a,r.lineWidth=1;for(let e=0;e<h;e++){let t=x(e,1);r.beginPath(),r.moveTo(g,_),r.lineTo(t.x,t.y),r.stroke(),r.fillStyle=a,r.font=`10px ${Q.mono}`;let n=b(e),i=x(e,1+10/v);r.textAlign=Math.abs(Math.cos(n))<.1?`center`:Math.cos(n)<0?`right`:`left`,r.textBaseline=Math.abs(Math.sin(n))<.1?`middle`:Math.sin(n)<0?`bottom`:`top`;let o=c[e].length>12?c[e].slice(0,11)+`…`:c[e];r.fillText(o,i.x,i.y)}for(let e=0;e<l.length;e++){let t=l[e],n=$J(e,d.current.color);r.beginPath();for(let e=0;e<h;e++){let n=Math.max(0,Math.min(1,(t.values[e]??0)/y[e])),i=x(e,n);e===0?r.moveTo(i.x,i.y):r.lineTo(i.x,i.y)}r.closePath(),u&&(r.fillStyle=n,r.globalAlpha=.15,r.fill()),r.globalAlpha=1,r.strokeStyle=n,r.lineWidth=1,r.stroke();for(let e=0;e<h;e++){let i=Math.max(0,Math.min(1,(t.values[e]??0)/y[e])),a=x(e,i);r.beginPath(),r.arc(a.x,a.y,3,0,Math.PI*2),r.fillStyle=n,r.globalAlpha=.9,r.fill()}r.globalAlpha=1}if(l.length>1){let e=eY.left,i=n-eY.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<l.length&&(r.fillStyle=$J(n,d.current.color),r.fillRect(e,i,10,8),r.fillStyle=a,r.textAlign=`left`,r.fillText(l[n].name,e+13,i),e+=r.measureText(l[n].name).width+26,!(e>t-eY.right-30));n++);}}let g=K(h);g.current=h;let _=K(null);_.current??=DH(()=>g.current(),()=>c.current);let v=()=>_.current.schedule();return W(()=>{_.current.now()}),W(()=>()=>_.current?.cancel(),[]),W(()=>{l.current=null,v()},[i]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,v()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`contextmenu`,t),()=>{e.removeEventListener(`contextmenu`,t)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Radar chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var nY={top:16,right:16,bottom:40,left:52},rY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function iY(e,t){let n=e.length>0&&e.every(t=>t.x===e[0].x||t.x.length===e[0].x.length),r=t&&n,i=e.map(e=>e.x),a=[],o=[],s=null;for(let t of e){if(!r){a.push(t.y),o.push(null);continue}let e=t.x.length,n=new Float64Array(e);for(let r=0;r<e;r++){let e=t.y[r];n[r]=(s?s[r]:0)+(e>0?e:0)}a.push(n),o.push(s??null),s=n}let c=1/0,l=-1/0,u=0,d=0;for(let e of i)for(let t=0;t<e.length;t++){let n=e[t];n<c&&(c=n),n>l&&(l=n)}for(let e of a)for(let t=0;t<e.length;t++){let n=e[t];n<u&&(u=n),n>d&&(d=n)}return Number.isFinite(c)||(c=0,l=1),{x:i,lo:o,hi:a,ascending:i.map(e=>GK(e)),xLo:c,xHi:l,yLo:u,yHi:d}}function aY({series:e,stacked:t=!1,yRange:n,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(0),p=K(i);G(()=>{p.current=i},[i]);let m=K(null),h=dt(()=>{let n=m.current;if(n&&n.stacked===t&&n.series.length===e.length&&n.series.every((t,n)=>t.x===e[n].x&&t.y===e[n].y&&t.name===e[n].name))return n.value;let r=iY(e,t);return m.current={series:e,stacked:t,value:r},r},[e,t]),g=K({series:e,prepared:h,yRange:n});G(()=>{g.current={series:e,prepared:h,yRange:n}},[e,h,n]);let _=K({plot:null,failed:!1,key:``,size:``});W(()=>()=>{_.current.plot?.dispose(),_.current.plot=null},[]);let v=K({prepared:null,view:``});function y(){if(u.current)return u.current;let e=l.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return u.current=n,n}function b(){let e=l.current;return{w:Math.max(1,e?.clientWidth||600),h:Math.max(1,e?.clientHeight||300)}}function x(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function S(e,t){let n=(e.xHi-e.xLo)*.01||.5,r=e.yLo,i=e.yHi;return i===r&&(i=r+1),i+=(i-r)*.05,t?.min!==void 0&&Number.isFinite(t.min)&&(r=t.min),t?.max!==void 0&&Number.isFinite(t.max)&&(i=t.max),{xLo:e.xLo-n,xHi:e.xHi+n,yLo:r,yHi:i}}function C(e,t,n,r,i){let a=e.x[t],o=e.hi[t],s=e.lo[t];if(!e.ascending[t]||a.length<=2*i)return{x:a,hi:o,lo:s??new Float64Array(a.length)};let c=HK(a,o,n,r,i);return{x:WK(a,c),hi:WK(o,c),lo:s?WK(s,c):new Float64Array(c.length)}}function w(){let e=o.current;if(!e)return;let{w:n,h:r}=b(),i=x(e,n,r);if(!i)return;let{bg:s,muted:c,grid:u}=y(),{series:d,prepared:f,yRange:p}=g.current;i.fillStyle=s,i.fillRect(0,0,n,r);let m=_.current.plot;if(d.length===0){m?.keep([]),m?.render(),i.fillStyle=c,i.font=`13px ${Q.sans}`,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(`No data`,nY.left+8,nY.top+8);return}let h=YW(nY,n,r),{top:w,right:D,bottom:O,left:k}=h,A=n-k-D,j=r-w-O,{xLo:M,xHi:N,yLo:P,yHi:F}=S(f,p),I=e=>k+(e-M)/(N-M)*A,L=e=>w+j-(e-P)/(F-P)*j;a({left:k,top:w,width:A,height:j,x:{v0:M,v1:N},y:{v0:P,v1:F}}),i.strokeStyle=u,i.lineWidth=1;for(let e=0;e<=5;e++){let t=P+e/5*(F-P),n=L(t);i.beginPath(),i.moveTo(k,n),i.lineTo(k+A,n),i.stroke(),i.fillStyle=c,i.font=`9px ${Q.mono}`,i.textAlign=`right`,i.textBaseline=`middle`,h.tiny||i.fillText(jz(t,(F-P)/5),k-4,n)}let R=Math.min(8,f.x[0]?.length??5);for(let e=0;e<=R;e++){let t=M+e/R*(N-M),n=I(t);i.beginPath(),i.moveTo(n,w),i.lineTo(n,w+j),i.stroke(),i.fillStyle=c,i.font=`9px ${Q.mono}`,i.textAlign=`center`,i.textBaseline=`top`,h.tiny||i.fillText(jz(t,(N-M)/R),n,w+j+4)}let z=`${M}|${N}|${P}|${F}`;(v.current.prepared!==f||v.current.view!==z)&&(v.current={prepared:f,view:z},CH(l.current));let B=E(n,r),V=Math.min(2,window.devicePixelRatio||1),ee=Math.max(1,Math.round(A*V)),te=d.map((e,t)=>zV(rY[t%rY.length]));if(B){let e=`${M}|${N}|${ee}`;if(_.current.key!==e||T.current!==f){let n=[];for(let e=0;e<d.length;e++){let r=C(f,e,M,N,ee),i=te[e],a=[i[0],i[1],i[2],f.lo[e]||t?.7:.25];B.setBands(`b${e}`,r.x,r.lo,r.hi,a),B.setLine(`l${e}`,r.x,r.hi,i,1),n.push(`b${e}`,`l${e}`)}B.keep(n),_.current.key=e,T.current=f}B.setView(M,N,P,F,{left:k,top:w,width:A,height:j}),B.render()}else for(let e=0;e<d.length;e++){let n=C(f,e,M,N,ee),r=rY[e%rY.length];i.save(),i.beginPath(),i.rect(k,w,A,j),i.clip(),i.beginPath();for(let e=0;e<n.x.length;e++){let t=I(n.x[e]);e===0?i.moveTo(t,L(n.lo[e])):i.lineTo(t,L(n.lo[e]))}for(let e=n.x.length-1;e>=0;e--)i.lineTo(I(n.x[e]),L(n.hi[e]));i.closePath(),i.fillStyle=r,i.globalAlpha=f.lo[e]||t?.7:.25,i.fill(),i.beginPath();for(let e=0;e<n.x.length;e++){let t=I(n.x[e]),r=L(n.hi[e]);e===0?i.moveTo(t,r):i.lineTo(t,r)}i.globalAlpha=1,i.strokeStyle=r,i.lineWidth=1,i.stroke(),i.restore()}if(d.length>1&&!h.tiny){let e=k,t=w+j+24;i.font=`9px ${Q.mono}`,i.textBaseline=`top`;for(let n=0;n<d.length&&(i.fillStyle=rY[n%rY.length],i.fillRect(e,t,10,8),i.fillStyle=c,i.textAlign=`left`,i.fillText(d[n].name,e+13,t),e+=i.measureText(d[n].name).width+26,!(e>k+A-30));n++);}}let T=K(null);function E(e,t){let n=_.current;if(!n.plot&&!n.failed&&s.current&&(n.plot=uH(s.current,IK),n.failed=!n.plot),!n.plot||!s.current)return null;let r=Math.min(2,window.devicePixelRatio||1),i=`${e}x${t}@${r}`;return n.size!==i&&(n.plot.resize(e,t,r),s.current.style.width=`${e}px`,s.current.style.height=`${t}px`,n.size=i),n.plot}function D(){let e=c.current;if(!e)return;let{w:t,h:n}=b(),r=x(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=d.current;if(i===null)return;let{prepared:a,yRange:o}=g.current,{top:s,right:l,left:u,bottom:f}=YW(nY,t,n),p=n-s-f;r.strokeStyle=`rgba(255,255,255,0.4)`,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(i,s),r.lineTo(i,s+p),r.stroke(),r.setLineDash([]);let{xLo:m,xHi:h}=S(a,o),_=t-u-l,v=`x=${Mz(m+(i-u)/_*(h-m))}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,C=Math.max(4,Math.min(t-y-8,i-y/2));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(C-3,s-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,s)}let O=K(w);O.current=w;let k=K(null);k.current??=DH(()=>O.current(),()=>l.current);let A=()=>{f.current||=bH(()=>{f.current=0,D()})};return W(()=>{k.current.now()},[e,h,n]),W(()=>()=>{k.current?.cancel(),xH(f.current)},[]),W(()=>{u.current=null,k.current.schedule()},[r]),G(()=>{let e=l.current;if(!e)return;let t=new EH(()=>{u.current=null,k.current.schedule(),A()});return t.observe(e),()=>t.disconnect()},[]),G(()=>{let e=c.current;if(!e)return;let t=e=>{e.preventDefault(),p.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();d.current=t.clientX-n.left,A()},r=()=>{d.current=null,A()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:l,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`Area chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`})]})}var oY={top:16,right:16,bottom:40,left:52},sY=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function cY({series:e,complement:t=!1,logX:n=!1,backgroundToken:r=``,onPlotContextMenu:i}){let a=nU(),o=K(null),s=K(null),c=K(null),l=K(null),u=K(null),d=K(0),f=K(i);G(()=>{f.current=i},[i]);let p=K({series:e,complement:t,logX:n});G(()=>{p.current={series:e,complement:t,logX:n}},[e,t,n]);let m=dt(()=>{let t=e.map(e=>Float64Array.from(e.values).sort()),n=1/0,r=-1/0;for(let e of t)e.length&&(n=Math.min(n,e[0]),r=Math.max(r,e[e.length-1]));return{all:t,xLo:n,xHi:r}},[e]),h=K(m);G(()=>{h.current=m},[m]);function g(){if(l.current)return l.current;let e=c.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return l.current=n,n}function _(){let e=c.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function v(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function y(){let e=o.current;if(!e)return;let{w:t,h:n}=_(),r=v(e,t,n);if(!r)return;let{bg:i,muted:s,grid:c}=g(),{series:l,complement:u,logX:d}=p.current;if(r.fillStyle=i,r.fillRect(0,0,t,n),l.length===0){r.fillStyle=s,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,oY.left+8,oY.top+8);return}let{top:f,right:m,bottom:y,left:b}=oY,x=t-b-m,S=n-f-y,{xLo:C,xHi:w}=h.current;Number.isFinite(C)||(C=0,w=1);let T=e=>Math.log10(Math.max(1e-10,e)),E=d?T(C):C,D=d?T(w):w,O=e=>b+((d?T(e):e)-E)/(D-E||1)*x,k=e=>f+S-e*S;a({left:b,top:f,width:x,height:S,x:{v0:C,v1:w,log:d}});for(let e=0;e<=5;e++){let t=e/5,n=k(t);r.strokeStyle=c,r.lineWidth=1,r.beginPath(),r.moveTo(b,n),r.lineTo(b+x,n),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(String(t.toFixed(2)),b-4,n)}for(let e=0;e<=6;e++){let t=C+e/6*(w-C),n=O(t);r.strokeStyle=c,r.lineWidth=1,r.beginPath(),r.moveTo(n,f),r.lineTo(n,f+S),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(w-C)/6),n,f+S+4)}for(let e=0;e<l.length;e++){let t=h.current.all[e],n=t?.length??0;if(n===0)continue;let i=e=>k(u?1-(e+1)/n:(e+1)/n),a=O(t[0]),o=k(+!!u);r.beginPath(),r.moveTo(a,o);for(let e=0;e<n;e++){if(e+1<n&&t[e+1]===t[e])continue;let s=O(t[e]),c=i(e);if(Math.abs(s-a)<.5){o=c;continue}r.lineTo(a,o),r.lineTo(s,o),a=s,o=c}r.lineTo(a,o),r.strokeStyle=sY[e%sY.length],r.lineWidth=1,r.stroke()}if(l.length>1){let e=b,t=f+S+24;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<l.length&&(r.fillStyle=sY[n%sY.length],r.fillRect(e,t,16,2),r.fillStyle=s,r.textAlign=`left`,r.fillText(l[n].name,e+20,t-3),e+=r.measureText(l[n].name).width+30,!(e>b+x-30));n++);}r.save(),r.translate(12,f+S/2),r.rotate(-Math.PI/2),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(u?`CCDF`:`CDF`,0,0),r.restore()}function b(){let e=s.current;if(!e)return;let{w:t,h:n}=_(),r=v(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=u.current;if(i===null)return;let{top:a,left:o,right:c}=oY,l=n-a-oY.bottom,d=t-o-c;r.strokeStyle=`rgba(255,255,255,0.4)`,r.lineWidth=1,r.setLineDash([4,4]),r.beginPath(),r.moveTo(i,a),r.lineTo(i,a+l),r.stroke(),r.setLineDash([]);let{xLo:f,xHi:p}=h.current;if(!Number.isFinite(f))return;let m=Mz(f+(i-o)/d*(p-f));r.font=`11px ${Q.mono}`;let g=r.measureText(m).width,y=Math.max(4,Math.min(t-g-8,i-g/2));r.fillStyle=`rgba(0,0,0,0.7)`,r.fillRect(y-3,a+l+2,g+6,16),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(m,y,a+l+4)}let x=K(y);x.current=y;let S=K(null);S.current??=DH(()=>x.current(),()=>c.current);let C=()=>S.current.schedule(),w=()=>{xH(d.current),d.current=bH(b)};return W(()=>{S.current.now()}),W(()=>()=>S.current?.cancel(),[]),W(()=>{l.current=null,C()},[r]),G(()=>{let e=c.current;if(!e)return;let t=new EH(()=>{l.current=null,C(),w()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=s.current;if(!e)return;let t=e=>{e.preventDefault(),f.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect();u.current=t.clientX-n.left,w()},r=()=>{u.current=null,w()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:c,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:o,className:`chart-canvas`,role:`img`,"aria-label":`CDF chart`}),q(`canvas`,{ref:s,className:`chart-canvas chart-overlay`})]})}var lY={top:16,right:40,bottom:40,left:52},uY=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function dY(e){return[Math.round(255*Math.min(1,Math.max(0,3.5*e-.5))),Math.round(255*Math.min(1,Math.max(0,e<.5?2*e:2-2*e))),Math.round(255*Math.min(1,Math.max(0,1.5-3.5*e)))]}function fY(e){let[t,n,r]=dY(e);return`rgb(${t},${n},${r})`}var pY=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...dY(t/255),255],t*4);return e})(),mY=()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=XG(uY[t%uY.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e};function hY(e,t,n){let r=e.length,i=1/0,a=-1/0,o=1/0,s=-1/0,c=1/0,l=-1/0;for(let t=0;t<r;t++){let n=e.x[t],r=e.y[t],u=e.size[t];n<i&&(i=n),n>a&&(a=n),r<o&&(o=r),r>s&&(s=r),u<c&&(c=u),u>l&&(l=u)}let u=Number.isFinite(i)?(()=>{let e=(a-i)*.1||1,t=(s-o)*.1||1;return{xLo:i-e,xHi:a+e,yLo:o-t,yHi:s+t,sLo:c,sHi:l}})():{xLo:-1,xHi:1,yLo:-1,yHi:1,sLo:1,sHi:1},d=u.sHi-u.sLo||1,f=new Float32Array(r);for(let t=0;t<r;t++)f[t]=3+(e.size[t]-u.sLo)/d*(n-3);let p=0,m=1,h=null,g=`single`;if(t&&e.colorValue){let t=e.colorValue,n=1/0,i=-1/0;for(let e=0;e<r;e++)t[e]<n&&(n=t[e]),t[e]>i&&(i=t[e]);Number.isFinite(n)&&(p=n,m=i),h=new Float32Array(r);for(let e=0;e<r;e++)h[e]=t[e]===t[e]?Math.max(0,Math.min(1,(t[e]-p)/(m-p||1))):0;g=`colormap`}else !t&&e.colorIndex&&(h=Float32Array.from(e.colorIndex,e=>e>=0?e%256:0),g=`dataset`);let _=Uint32Array.from({length:r},(e,t)=>t).sort((e,t)=>(f[t]||0)-(f[e]||0)),v=e=>{let t=new Float64Array(r);for(let n=0;n<r;n++)t[n]=e[_[n]];return t};return{ext:u,radius:f,key:h,mode:g,colorLo:p,colorHi:m,drawn:{x:v(e.x),y:v(e.y),r:v(f),k:h?v(h):void 0}}}function gY({points:e,color:t=`#64748b`,colorByNumeric:n=!1,maxRadius:r=24,backgroundToken:i=``,onPlotContextMenu:a}){let o=nU(),s=K(null),c=K(null),l=K(null),u=K(null),d=K(null),f=K(null),p=K(0),m=K(a);G(()=>{m.current=a},[a]);let h=dt(()=>hY(e,n,r),[e,n,r]),g=K({points:e,color:t,colorByNumeric:n,maxRadius:r,model:h});G(()=>{g.current={points:e,color:t,colorByNumeric:n,maxRadius:r,model:h}},[e,t,n,r,h]);let _=K({r:null,failed:!1,size:``,model:null,style:``});W(()=>()=>{_.current.r?.dispose(),_.current.r=null},[]);function v(){if(d.current)return d.current;let e=u.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return d.current=n,n}function y(){let e=u.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function b(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function x(e,t){let{xLo:n,xHi:r,yLo:i,yHi:a}=g.current.model.ext,{top:s,right:c,bottom:l,left:u}=lY,d=e-u-c,f=t-s-l;return o({left:u,top:s,width:d,height:f,x:{v0:n,v1:r},y:{v0:i,v1:a}}),{plotW:d,plotH:f,xToPx:e=>u+(e-n)/(r-n)*d,yToPx:e=>s+(1-(e-i)/(a-i))*f}}function S(e,t){let n=_.current;!n.r&&!n.failed&&c.current&&(n.r=uH(c.current,qW),n.failed=!n.r);let r=n.r;if(!r||!c.current)return null;let i=Math.min(2,window.devicePixelRatio||1),a=`${e}x${t}@${i}`;n.size!==a&&(r.resize(e,t,i),c.current.style.width=`${e}px`,c.current.style.height=`${t}px`,n.size=a);let{model:o,color:s}=g.current;n.model!==o&&(r.setData(o.drawn.x,o.drawn.y,o.drawn.k,!1,o.drawn.r),n.model=o,CH(u.current));let l=`${o.mode}|${s}`;return n.style!==l&&(r.setStyle(o.mode===`single`?{kind:`single`,rgba:XG(s,1)}:{kind:o.mode,palette:o.mode===`colormap`?pY:mY()},3,.65),r.setDraw(!0,!1,0),n.style=l),r}function C(){let e=s.current;if(!e)return;let{w:t,h:n}=y(),r=b(e,t,n);if(!r)return;let{bg:i,muted:a,grid:o}=v(),{points:c,color:l,colorByNumeric:u,model:d}=g.current;r.fillStyle=i,r.fillRect(0,0,t,n);let f=S(t,n);if(c.length===0){f?.setData([],[]),_.current.model=null,f?.render(),r.fillStyle=a,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,lY.left+8,lY.top+8);return}let{xLo:p,xHi:m,yLo:h,yHi:C}=d.ext,{top:w,left:T}=lY,{plotW:E,plotH:D,xToPx:O,yToPx:k}=x(t,n);r.strokeStyle=o,r.lineWidth=1;for(let e=0;e<=5;e++){let t=p+e/5*(m-p),n=O(t);r.beginPath(),r.moveTo(n,w),r.lineTo(n,w+D),r.stroke(),r.fillStyle=a,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(m-p)/5),n,w+D+4);let i=h+e/5*(C-h),o=k(i);r.beginPath(),r.moveTo(T,o),r.lineTo(T+E,o),r.stroke(),r.fillStyle=a,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(i,(C-h)/5),T-4,o)}if(f)f.setView(p,m,h,C,{left:T,top:w,width:E,height:D}),f.render();else{let e=d.drawn;r.globalAlpha=.65;for(let t=0;t<e.x.length;t++){if(e.x[t]!==e.x[t]||e.y[t]!==e.y[t])continue;let n=e.k?.[t]??0;r.fillStyle=d.mode===`colormap`?fY(n):d.mode===`dataset`?uY[n%uY.length]:l,r.beginPath(),r.arc(O(e.x[t]),k(e.y[t]),e.r[t],0,Math.PI*2),r.fill()}r.globalAlpha=1}let A=c.colorLabels??[];if(!u&&A.length>0&&A.length<=10){let e=T,t=n-lY.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<A.length;n++){let i=A[n];if(r.fillStyle=uY[n%uY.length],r.beginPath(),r.arc(e+4,t+4,4,0,Math.PI*2),r.fill(),r.fillStyle=a,r.textAlign=`left`,r.fillText(i,e+10,t),e+=r.measureText(i).width+20,e>T+E-60)break}}}function w(){let e=l.current;if(!e)return;let{w:t,h:n}=y(),r=b(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=f.current;if(i===null)return;let{points:a,model:o}=g.current;if(i<0||i>=a.length)return;let{xToPx:s,yToPx:c}=x(t,n),u=o.radius[i],d=s(a.x[i]),p=c(a.y[i]);r.beginPath(),r.arc(d,p,u+2,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let m=[],h=a.label?.(i);h&&m.push(h),m.push(`(${Mz(a.x[i])}, ${Mz(a.y[i])})`),m.push(`size=${Mz(a.size[i])}`);let _=a.colorIndex?.[i];_!==void 0&&_>=0&&a.colorLabels?m.push(a.colorLabels[_]):a.colorValue&&m.push(Mz(a.colorValue[i]));let v=m.join(` · `);r.font=`11px ${Q.mono}`;let S=r.measureText(v).width,C=Math.max(4,Math.min(t-S-8,d+u+4)),w=p-20<lY.top?p+u+4:p-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(C-3,w-3,S+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,C,w)}let T=K(C);T.current=C;let E=K(null);E.current??=DH(()=>T.current(),()=>u.current);let D=()=>E.current.schedule(),O=()=>{xH(p.current),p.current=bH(w)};return W(()=>{E.current.now()}),W(()=>()=>E.current?.cancel(),[]),W(()=>{d.current=null,D()},[i]),G(()=>{let e=u.current;if(!e)return;let t=new EH(()=>{d.current=null,D(),O()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=l.current;if(!e)return;let t=null,n=e=>{e.preventDefault(),m.current?.({clientX:e.clientX,clientY:e.clientY})},r=n=>{let r=e.getBoundingClientRect(),{points:i,maxRadius:a,model:o}=g.current,{w:s,h:c}=y(),{plotW:l,plotH:u,xToPx:d,yToPx:p}=x(s,c),m=e=>d(i.x[e])-lY.left,h=e=>p(i.y[e])-lY.top,_=a+6,v=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==v)&&(t={model:o,key:v,g:OJ(i.length,l,u,_,m,h)}),f.current=kJ(t.g,n.clientX-r.left-lY.left,n.clientY-r.top-lY.top,_,m,h,e=>o.radius[e]+6),O()},i=()=>{f.current=null,O()};return e.addEventListener(`contextmenu`,n),e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,i),()=>{e.removeEventListener(`contextmenu`,n),e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,i)}},[]),_t(`div`,{ref:u,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:s,className:`chart-canvas`,role:`img`,"aria-label":`Bubble chart`}),q(`canvas`,{ref:c,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:l,className:`chart-canvas chart-overlay`})]})}var _Y={top:8,right:8,bottom:8,left:8},vY=[`#f97316`,`#38bdf8`,`#4ade80`,`#a78bfa`,`#fbbf24`,`#fb7185`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function yY(e){let t=new Map;for(let n of e){let e=n.parent??``;t.has(e)||t.set(e,[]),t.get(e).push(n)}function n(r,i){let a=(t.get(r)??[]).map(e=>n(e.name,i+1)),o=e.find(e=>e.name===r),s=a.reduce((e,t)=>e+t.value,0);return{name:r,value:o?Math.max(o.value,s):s,children:a,depth:i}}let r=new Set(e.map(e=>e.name));return e.filter(e=>!e.parent||!r.has(e.parent)).map(e=>n(e.name,0))}function bY(e,t,n,r,i,a){if(e.length===0||r<=0||i<=0||e.reduce((e,t)=>e+t.value,0)===0)return[];let o=[],s=[...e].sort((e,t)=>t.value-e.value),c=t,l=n,u=r,d=i;for(;s.length>0;){let e=u*d,t=s.reduce((e,t)=>e+t.value,0),n=e/t,r=[],i=1/0;for(let e=1;e<=s.length;e++){let a=s.slice(0,e),o=a.reduce((e,t)=>e+t.value,0)/t*(u<=d?u:d),c=0;for(let e of a){let t=e.value*n/o,r=Math.max(t/o,o/t);r>c&&(c=r)}if(c<i)i=c,r=a;else break}let f=r.reduce((e,t)=>e+t.value,0),p=u<=d,m=f/t*(p?u:d),h=0;for(let e of r){let t=e.value/f,n=p?u:t*u,r=p?t*d:d,i=p?c:c+h,s=p?l+h:l,g=p?m:n,_=p?r:m;if(o.push({node:e,x:i,y:s,w:g,h:_,depth:a}),e.children.length>0&&g>4&&_>4){let t=bY(e.children,i+1,s+1,g-2,_-2,a+1);for(let e of t)o.push(e)}h+=p?r:n}s=s.slice(r.length),p?(c+=m,u-=m):(l+=m,d-=m)}return o}function xY({nodes:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=K(null),i=K(null),a=K(null),o=K(null),s=K([]),c=K(null),l=K(0),u=K(n);G(()=>{u.current=n},[n]);let d=K({nodes:e});G(()=>{d.current={nodes:e}},[e]);let f=dt(()=>yY(e),[e]),p=K(f);G(()=>{p.current=f},[f]);function m(){if(o.current)return o.current;let e=a.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return o.current=n,n}function h(){let e=a.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function g(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function _(){let e=r.current;if(!e)return;let{w:t,h:n}=h(),i=g(e,t,n);if(!i)return;let{bg:a,muted:o}=m(),{nodes:l}=d.current;if(i.fillStyle=a,i.fillRect(0,0,t,n),l.length===0){i.fillStyle=o,i.font=`13px ${Q.sans}`,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(`No data`,_Y.left+8,_Y.top+8);return}let u=p.current,f=t-_Y.left-_Y.right,_=n-_Y.top-_Y.bottom,v=bY(u,_Y.left,_Y.top,f,_,0);s.current=v;for(let e=0;e<v.length;e++){let{node:t,x:n,y:r,w:o,h:s,depth:l}=v[e];if(o<2||s<2)continue;let u=vY[l%vY.length],d=c.current===e;if(i.fillStyle=u,i.globalAlpha=d?.95:.75,i.fillRect(n,r,o,s),i.globalAlpha=1,i.strokeStyle=a,i.lineWidth=1,i.strokeRect(n,r,o,s),o>20&&s>14){i.fillStyle=`rgba(0,0,0,0.75)`,i.font=`${Math.min(11,s-4)}px ${Q.mono}`,i.textAlign=`left`,i.textBaseline=`top`;let e=Math.floor((o-4)/6),a=t.name.length>e?t.name.slice(0,e-1)+`…`:t.name;i.fillText(a,n+3,r+3)}}i.globalAlpha=1}function v(){let e=i.current;if(!e)return;let{w:t,h:n}=h(),r=g(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let a=c.current;if(a===null)return;let o=s.current;if(a<0||a>=o.length)return;let{node:l,x:u,y:d,w:f,h:p}=o[a];r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.strokeRect(u+1,d+1,f-2,p-2);let m=`${l.name}: ${l.value.toLocaleString()}`;r.font=`11px ${Q.mono}`;let _=r.measureText(m).width,v=Math.max(4,Math.min(t-_-8,u+f/2-_/2)),y=d<30?d+p+4:d-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(v-3,y-3,_+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(m,v,y)}let y=K(_);y.current=_;let b=K(null);b.current??=DH(()=>y.current(),()=>a.current);let x=()=>b.current.schedule(),S=()=>{xH(l.current),l.current=bH(v)};return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{o.current=null,x()},[t]),G(()=>{let e=a.current;if(!e)return;let t=new EH(()=>{o.current=null,x(),S()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=i.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=s.current,o=null;for(let e=0;e<a.length;e++){let t=a[e];r>=t.x&&r<=t.x+t.w&&i>=t.y&&i<=t.y+t.h&&(o=e)}c.current=o,S()},r=()=>{c.current=null,S()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:a,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:r,className:`chart-canvas`,role:`img`,"aria-label":`Treemap`}),q(`canvas`,{ref:i,className:`chart-canvas chart-overlay`})]})}var SY={top:8,right:8,bottom:8,left:8},CY=14,wY=8,TY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function EY(e,t,n,r){if(e.length===0||t.length===0)return{nodes:[],links:[]};let i=n-SY.left-SY.right,a=r-SY.top-SY.bottom,o=new Map;for(let t of e)o.set(t,0);let s=!0;for(;s;){s=!1;for(let e of t){let t=o.get(e.source)??0;(o.get(e.target)??0)<=t&&(o.set(e.target,t+1),s=!0)}}let c=Math.max(0,...Array.from(o.values())),l=e=>SY.left+e/Math.max(1,c)*(i-CY),u=new Map;for(let[e,t]of o)u.has(t)||u.set(t,[]),u.get(t).push(e);let d=new Map;for(let t of e)d.set(t,0);for(let e of t)d.set(e.source,(d.get(e.source)??0)+e.value),d.set(e.target,(d.get(e.target)??0)+e.value);let f=Math.max(1,...Array.from(d.values())),p=new Map;for(let[t,n]of u){let r=a-(n.length-1)*wY,i=0;for(let e of n)i+=Math.max(8,(d.get(e)??0)/f*r*.8);let o=SY.top+(a-i-(n.length-1)*wY)/2;for(let i=0;i<n.length;i++){let a=n[i],s=Math.max(8,(d.get(a)??0)/f*r*.8);p.set(a,{name:a,x:l(t),y:o,h:s,color:TY[e.indexOf(a)%TY.length]}),o+=s+wY}}let m=new Map,h=new Map;for(let[e,t]of p)m.set(e,t.y),h.set(e,t.y);let g=[];for(let e of t){let t=p.get(e.source),n=p.get(e.target);if(!t||!n)continue;let r=Math.max(1,e.value/f*t.h),i=m.get(e.source)??t.y,a=h.get(e.target)??n.y;m.set(e.source,i+r),h.set(e.target,a+r),g.push({sx:t.x+CY,sy:i+r/2,tx:n.x,ty:a+r/2,h:r,color:t.color,label:`${e.source} → ${e.target}: ${e.value.toLocaleString()}`})}return{nodes:Array.from(p.values()),links:g}}function DY({nodeNames:e,links:t,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K({nodes:[],links:[]}),l=K(null),u=K(0),d=K(r);G(()=>{d.current=r},[r]);let f=K({nodeNames:e,links:t});G(()=>{f.current={nodeNames:e,links:t}},[e,t]);function p(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function m(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function g(){let e=i.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{bg:a,muted:o}=p(),{nodeNames:s,links:u}=f.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),s.length===0||u.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data — set source/target/value columns`,SY.left+8,SY.top+8);return}let d=EY(s,u,t,n);c.current=d;for(let e=0;e<d.links.length;e++){let t=d.links[e],n=l.current===e,i=(t.tx-t.sx)/2;r.beginPath(),r.moveTo(t.sx,t.sy-t.h/2),r.bezierCurveTo(t.sx+i,t.sy-t.h/2,t.tx-i,t.ty-t.h/2,t.tx,t.ty-t.h/2),r.lineTo(t.tx,t.ty+t.h/2),r.bezierCurveTo(t.tx-i,t.ty+t.h/2,t.sx+i,t.sy+t.h/2,t.sx,t.sy+t.h/2),r.closePath(),r.fillStyle=t.color,r.globalAlpha=n?.55:.3,r.fill()}r.globalAlpha=1;for(let e of d.nodes)r.fillStyle=e.color,r.globalAlpha=.9,r.fillRect(e.x,e.y,CY,e.h),r.globalAlpha=1,r.fillStyle=o,r.font=`9px ${Q.mono}`,r.textBaseline=`middle`,e.x>t/2?(r.textAlign=`right`,r.fillText(e.name,e.x-3,e.y+e.h/2)):(r.textAlign=`left`,r.fillText(e.name,e.x+CY+3,e.y+e.h/2));r.globalAlpha=1}function _(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(i===null)return;let o=c.current;if(i<0||i>=o.links.length)return;let s=o.links[i],u=s.label;r.font=`11px ${Q.mono}`;let d=r.measureText(u).width,f=Math.max(4,Math.min(t-d-8,(s.sx+s.tx)/2-d/2)),p=Math.max(4,(s.sy+s.ty)/2-10);r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(f-3,p-3,d+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(u,f,p)}let v=K(g);v.current=g;let y=K(null);y.current??=DH(()=>v.current(),()=>o.current);let b=()=>y.current.schedule(),x=()=>{xH(u.current),u.current=bH(_)};return W(()=>{y.current.now()}),W(()=>()=>y.current?.cancel(),[]),W(()=>{s.current=null,b()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,b(),x()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,a=c.current,o=null;for(let e=0;e<a.links.length;e++){let t=a.links[e];if(r>=t.sx&&r<=t.tx&&Math.abs(i-(t.sy+t.ty)/2)<t.h/2+6){o=e;break}}l.current=o,x()},r=()=>{l.current=null,x()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Sankey diagram`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var OY={top:24,right:24,bottom:52,left:52};function kY({bins:e,color:t=`#38bdf8`,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(r);G(()=>{u.current=r},[r]);let d=K({bins:e,color:t});G(()=>{d.current={bins:e,color:t}},[e,t]);function f(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function p(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=i.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;let{bg:a,muted:o,grid:s}=f(),{bins:l,color:u}=d.current;if(r.fillStyle=a,r.fillRect(0,0,t,n),l.length===0){r.fillStyle=o,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,OY.left+8,OY.top+8);return}let{top:h,right:g,bottom:_,left:v}=OY,y=t-v-g,b=n-h-_,x=e=>v+e*y,S=e=>h+(1-e)*b;for(let e=0;e<=5;e++){let t=e/5;r.strokeStyle=s,r.lineWidth=1,r.beginPath(),r.moveTo(v,S(t)),r.lineTo(v+y,S(t)),r.stroke(),r.beginPath(),r.moveTo(x(t),h),r.lineTo(x(t),h+b),r.stroke(),r.fillStyle=o,r.font=`9px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(t.toFixed(2),v-4,S(t)),r.textAlign=`center`,r.textBaseline=`top`,r.fillText(t.toFixed(2),x(t),h+b+4)}r.strokeStyle=o,r.lineWidth=1.5,r.setLineDash([6,4]),r.beginPath(),r.moveTo(x(0),S(0)),r.lineTo(x(1),S(1)),r.stroke(),r.setLineDash([]);let C=Math.max(1,...l.map(e=>e.count)),w=b*.15;for(let e of l){let t=Math.max(1,y/l.length*.7),n=x(e.center)-t/2,i=e.count/C*w;r.fillStyle=u,r.globalAlpha=.3,r.fillRect(n,h+b-i,t,i)}r.globalAlpha=1,r.beginPath();for(let e=0;e<l.length;e++){let t=x(l[e].center),n=S(l[e].actual);e===0?r.moveTo(t,n):r.lineTo(t,n)}r.strokeStyle=u,r.lineWidth=1,r.stroke();for(let e=0;e<l.length;e++){let t=c.current===e;r.beginPath(),r.arc(x(l[e].center),S(l[e].actual),t?6:4,0,Math.PI*2),r.fillStyle=u,r.globalAlpha=t?1:.85,r.fill()}r.globalAlpha=1,r.fillStyle=o,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Predicted probability`,v+y/2,n-4),r.save(),r.translate(12,h+b/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Actual rate`,0,0),r.restore()}function g(){let e=a.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(i===null)return;let{bins:o}=d.current;if(i<0||i>=o.length)return;let s=o[i],{top:l,left:u}=OY,f=t-u-OY.right,h=n-l-OY.bottom,g=u+s.center*f,_=l+(1-s.actual)*h,v=`pred=${s.center.toFixed(2)} actual=${s.actual.toFixed(3)} n=${s.count}`;r.font=`11px ${Q.mono}`;let y=r.measureText(v).width,b=Math.max(4,Math.min(t-y-8,g-y/2)),x=_-28<l?_+12:_-24;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(b-3,x-3,y+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(v,b,x)}let _=K(h);_.current=h;let v=K(null);v.current??=DH(()=>_.current(),()=>o.current);let y=()=>v.current.schedule(),b=()=>{xH(l.current),l.current=bH(g)};return W(()=>{v.current.now()}),W(()=>()=>v.current?.cancel(),[]),W(()=>{s.current=null,y()},[n]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,y(),b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{bins:r}=d.current,{w:i}=p(),a=t.clientX-n.left,o=i-OY.left-OY.right,s=-1,l=20;for(let e=0;e<r.length;e++){let t=OY.left+r[e].center*o,n=Math.abs(a-t);n<l&&(l=n,s=e)}c.current=s>=0?s:null,b()},r=()=>{c.current=null,b()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Calibration curve`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var AY={top:24,right:24,bottom:48,left:52};function jY({points:e,color:t=`#a78bfa`,backgroundToken:n=``,onPlotContextMenu:r}){let i=nU(),a=K(null),o=K(null),s=K(null),c=K(null),l=K(null),u=K(0),d=K(r);G(()=>{d.current=r},[r]);let f=K({points:e,color:t});G(()=>{f.current={points:e,color:t}},[e,t]);function p(){if(c.current)return c.current;let e=s.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return c.current=n,n}function m(){let e=s.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function h(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function g(){let{points:e}=f.current,t=1/0,n=-1/0,r=1/0,i=-1/0;if(e.length>0&&(t=e.theoretical[0],n=e.theoretical[e.length-1],r=e.sample[0],i=e.sample[e.length-1]),!Number.isFinite(t))return{xLo:-3,xHi:3,yLo:-3,yHi:3};let a=(n-t)*.05||.5,o=(i-r)*.05||.5;return{xLo:t-a,xHi:n+a,yLo:r-o,yHi:i+o}}function _(){let e=a.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;let{bg:o,muted:s,grid:c}=p(),{points:u,color:d}=f.current;if(r.fillStyle=o,r.fillRect(0,0,t,n),u.length===0){r.fillStyle=s,r.font=`13px ${Q.sans}`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(`No data`,AY.left+8,AY.top+8);return}let{xLo:_,xHi:v,yLo:y,yHi:b}=g(),{top:x,right:S,bottom:C,left:w}=AY,T=t-w-S,E=n-x-C,D=e=>w+(e-_)/(v-_)*T,O=e=>x+(1-(e-y)/(b-y))*E;i({left:w,top:x,width:T,height:E,x:{v0:_,v1:v}}),r.strokeStyle=c,r.lineWidth=1;for(let e=0;e<=5;e++){let t=_+e/5*(v-_),n=D(t);r.beginPath(),r.moveTo(n,x),r.lineTo(n,x+E),r.stroke(),r.fillStyle=s,r.font=`9px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(jz(t,(v-_)/5),n,x+E+4);let i=y+e/5*(b-y),a=O(i);r.beginPath(),r.moveTo(w,a),r.lineTo(w+T,a),r.stroke(),r.fillStyle=s,r.textAlign=`right`,r.textBaseline=`middle`,r.fillText(jz(i,(b-y)/5),w-4,a)}let k=Math.max(_,y),A=Math.min(v,b);k<A&&(r.strokeStyle=s,r.lineWidth=1.5,r.setLineDash([6,4]),r.beginPath(),r.moveTo(D(k),O(k)),r.lineTo(D(A),O(A)),r.stroke(),r.setLineDash([])),r.fillStyle=d,r.globalAlpha=.75;let j=NaN,M=NaN;for(let e=0;e<u.length;e++){let t=Math.round(D(u.theoretical[e])),n=Math.round(O(u.sample[e]));t===j&&n===M||(j=t,M=n,r.beginPath(),r.arc(t,n,3,0,Math.PI*2),r.fill())}let N=l.current;N!==null&&N<u.length&&(r.globalAlpha=1,r.beginPath(),r.arc(D(u.theoretical[N]),O(u.sample[N]),5,0,Math.PI*2),r.fill()),r.globalAlpha=1,r.fillStyle=s,r.font=`10px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(`Theoretical quantiles`,w+T/2,n-4),r.save(),r.translate(12,x+E/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(`Sample quantiles`,0,0),r.restore()}function v(){let e=o.current;if(!e)return;let{w:t,h:n}=m(),r=h(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=l.current;if(i===null)return;let{points:a}=f.current;if(i<0||i>=a.length)return;let s={theoretical:a.theoretical[i],sample:a.sample[i]},{xLo:c,xHi:u,yLo:d,yHi:p}=g(),{top:_,left:v}=AY,y=t-v-AY.right,b=n-_-AY.bottom,x=v+(s.theoretical-c)/(u-c)*y,S=_+(1-(s.sample-d)/(p-d))*b;r.beginPath(),r.arc(x,S,6,0,Math.PI*2),r.strokeStyle=`rgba(255,255,255,0.9)`,r.lineWidth=2,r.stroke();let C=`(${Mz(s.theoretical)}, ${Mz(s.sample)})`;r.font=`11px ${Q.mono}`;let w=r.measureText(C).width,T=Math.max(4,Math.min(t-w-8,x+10)),E=S-20<_?S+10:S-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(T-3,E-3,w+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(C,T,E)}let y=K(_);y.current=_;let b=K(null);b.current??=DH(()=>y.current(),()=>s.current);let x=()=>b.current.schedule(),S=()=>{xH(u.current),u.current=bH(v)};return W(()=>{b.current.now()}),W(()=>()=>b.current?.cancel(),[]),W(()=>{c.current=null,x()},[n]),G(()=>{let e=s.current;if(!e)return;let t=new EH(()=>{c.current=null,x(),S()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=o.current;if(!e)return;let t=e=>{e.preventDefault(),d.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{points:r}=f.current,{w:i}=m(),{xLo:a,xHi:o,yLo:s,yHi:c}=g(),{top:u,left:d}=AY,p=i-d-AY.right,h=n.height-u-AY.bottom,_=t.clientX-n.left,v=t.clientY-n.top,y=e=>a+(e-d)/p*(o-a),b=e=>{let t=0,n=r.length;for(;t<n;){let i=t+n>>>1;r.theoretical[i]<e?t=i+1:n=i}return t},x=b(y(_-10)),C=Math.min(r.length,b(y(_+10))+1),w=-1,T=10**2;for(let e=x;e<C;e++){let t=d+(r.theoretical[e]-a)/(o-a)*p,n=u+(1-(r.sample[e]-s)/(c-s))*h,i=(_-t)**2+(v-n)**2;i<T&&(T=i,w=e)}l.current=w>=0?w:null,S()},r=()=>{l.current=null,S()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:s,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:a,className:`chart-canvas`,role:`img`,"aria-label":`Q-Q plot`}),q(`canvas`,{ref:o,className:`chart-canvas chart-overlay`})]})}var MY={top:8,right:16,bottom:40,left:120},NY=22,PY=3,FY=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function IY({tasks:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=nU(),i=K(null),a=K(null),o=K(null),s=K(null),c=K(null),l=K(0),u=K(n);G(()=>{u.current=n},[n]);let d=K({tasks:e});G(()=>{d.current={tasks:e}},[e]);function f(){if(s.current)return s.current;let e=o.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`};return s.current=n,n}function p(){let e=o.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||300)}}function m(e,t,n){let r=Math.min(2,window.devicePixelRatio||1),i=Math.floor(t*r),a=Math.floor(n*r);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),e.style.width=`${t}px`,e.style.height=`${n}px`;let o=e.getContext(`2d`);return o&&o.setTransform(r,0,0,r,0,0),o}function h(){let e=i.current;if(!e)return;let{w:t,h:n}=p(),a=m(e,t,n);if(!a)return;let{bg:o,muted:s,grid:l}=f(),{tasks:u}=d.current;if(a.fillStyle=o,a.fillRect(0,0,t,n),u.length===0){a.fillStyle=s,a.font=`13px ${Q.sans}`,a.textAlign=`left`,a.textBaseline=`top`,a.fillText(`No data`,MY.left+8,MY.top+8);return}let h=1/0,g=-1/0;for(let e of u)e.start<h&&(h=e.start),e.end>g&&(g=e.end);Number.isFinite(h)||(h=0,g=1);let _=(g-h)*.02||1;h-=_,g+=_;let{top:v,right:y,bottom:b,left:x}=MY,S=t-x-y,C=e=>x+(e-h)/(g-h)*S;r({left:x,top:v,width:S,height:n-v-b,x:{v0:h,v1:g}});let w=new Map;for(let e of u){let t=e.group??e.label;w.has(t)||w.set(t,w.size)}let T=Math.min(8,Math.floor(S/60));a.strokeStyle=l,a.lineWidth=1;for(let e=0;e<=T;e++){let t=h+e/T*(g-h),n=C(t),r=u.length*(NY+PY)+v;a.beginPath(),a.moveTo(n,v),a.lineTo(n,r),a.stroke(),a.fillStyle=s,a.font=`9px ${Q.mono}`,a.textAlign=`center`,a.textBaseline=`top`,a.fillText(jz(t,(g-h)/T),n,r+4)}for(let e=0;e<u.length;e++){let t=u[e],n=v+e*(NY+PY),r=FY[(w.get(t.group??t.label)??0)%FY.length],i=c.current===e,o=C(t.start),l=C(t.end),d=Math.max(2,l-o);a.fillStyle=r,a.globalAlpha=i?.95:.75,a.fillRect(o,n,d,NY-PY),a.globalAlpha=1,a.fillStyle=s,a.font=`9px ${Q.mono}`,a.textAlign=`right`,a.textBaseline=`middle`;let f=t.label.length>16?t.label.slice(0,15)+`…`:t.label;a.fillText(f,x-4,n+(NY-PY)/2)}a.globalAlpha=1}function g(){let e=a.current;if(!e)return;let{w:t,h:n}=p(),r=m(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let i=c.current;if(i===null)return;let{tasks:o}=d.current;if(i<0||i>=o.length)return;let s=o[i],l=s.end-s.start,u=`${s.label}: ${Mz(s.start)} → ${Mz(s.end)} (${Mz(l)})`;r.font=`11px ${Q.mono}`;let f=r.measureText(u).width,h=1/0,g=-1/0;for(let e of o)e.start<h&&(h=e.start),e.end>g&&(g=e.end);let _=(g-h)*.02||1;h-=_,g+=_;let v=t-MY.left-MY.right,y=e=>MY.left+(e-h)/(g-h)*v,b=MY.top+i*(NY+PY),x=(y(s.start)+y(s.end))/2,S=Math.max(4,Math.min(t-f-8,x-f/2)),C=b-22<MY.top?b+NY+4:b-20;r.fillStyle=`rgba(0,0,0,0.8)`,r.fillRect(S-3,C-3,f+6,18),r.fillStyle=`#fff`,r.textAlign=`left`,r.textBaseline=`top`,r.fillText(u,S,C)}let _=K(h);_.current=h;let v=K(null);v.current??=DH(()=>_.current(),()=>o.current);let y=()=>v.current.schedule(),b=()=>{xH(l.current),l.current=bH(g)};return W(()=>{v.current.now()}),W(()=>()=>v.current?.cancel(),[]),W(()=>{s.current=null,y()},[t]),G(()=>{let e=o.current;if(!e)return;let t=new EH(()=>{s.current=null,y(),b()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=a.current;if(!e)return;let t=e=>{e.preventDefault(),u.current?.({clientX:e.clientX,clientY:e.clientY})},n=t=>{let n=e.getBoundingClientRect(),{tasks:r}=d.current,i=t.clientY-n.top,a=Math.floor((i-MY.top)/(NY+PY));c.current=a>=0&&a<r.length?a:null,b()},r=()=>{c.current=null,b()};return e.addEventListener(`contextmenu`,t),e.addEventListener(`mousemove`,n),e.addEventListener(`mouseleave`,r),()=>{e.removeEventListener(`contextmenu`,t),e.removeEventListener(`mousemove`,n),e.removeEventListener(`mouseleave`,r)}},[]),_t(`div`,{ref:o,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Gantt chart`}),q(`canvas`,{ref:a,className:`chart-canvas chart-overlay`})]})}var LY=e=>[...e].filter(e=>Number.isFinite(e.at)).sort((e,t)=>e.at-t.at),RY=e=>{let t=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);return t?[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]:[128,128,128]},zY=e=>`#${e.map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`;function BY(e,t,n,r){let i=t?LY(t):[];if(!e||e===`solid`||i.length===0||!Number.isFinite(r))return n;if(e===`zones`){let e=i[0].color;for(let t of i)r>=t.at&&(e=t.color);return e}if(r<=i[0].at)return i[0].color;if(r>=i[i.length-1].at)return i[i.length-1].color;let a=0;for(;i[a+1].at<r;)a++;let o=i[a],s=i[a+1],c=(r-o.at)/(s.at-o.at||1),l=RY(o.color),u=RY(s.color);return zY([l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c])}function VY(e,t,n,r,i,a=96){let o=i-r||1,s=t?LY(t):[];if(!e||e===`solid`||s.length===0)return[{f0:0,f1:1,color:n}];if(e===`zones`){let e=[0,...s.slice(1).map(e=>(e.at-r)/o).filter(e=>e>0&&e<1),1];return e.slice(0,-1).map((t,i)=>({f0:t,f1:e[i+1],color:BY(`zones`,s,n,r+(t+e[i+1])/2*o)}))}return Array.from({length:a},(e,t)=>({f0:t/a,f1:(t+1)/a,color:BY(`gradient`,s,n,r+(t+.5)/a*o)}))}function HY(e,t,n){let r=e=>+(t+e*(n-t)).toPrecision(6),i=`#22c55e`,a=`#ef4444`;if(e===`traffic`)return{mode:`zones`,stops:[{at:r(0),color:i},{at:r(.7),color:`#f5a524`},{at:r(.9),color:a}]};let o=[{at:r(0),color:i},{at:r(.5),color:`#eab308`},{at:r(1),color:a}];return{mode:`gradient`,stops:e===`green-red`?o:o.map((e,t)=>({...e,color:o[o.length-1-t].color}))}}function UY(e,t,n){let r=t?LY(t):[];if(!e||e===`solid`||r.length===0)return n;let i=r[0].at,a=r[r.length-1].at,o=e=>`${((e-i)/(a-i||1)*100).toFixed(1)}%`;if(e===`gradient`)return`linear-gradient(90deg, ${r.map(e=>`${e.color} ${o(e.at)}`).join(`, `)})`;let s=100/r.length;return`linear-gradient(90deg, ${r.map((e,t)=>`${e.color} ${(t*s).toFixed(1)}% ${((t+1)*s).toFixed(1)}%`).join(`, `)})`}var WY=.75*Math.PI,GY=1.5*Math.PI;function KY({gauges:e,live:t,backgroundToken:n=``,onPlotContextMenu:r}){let i=K(null),a=K(null),o=K(null),s=K(r);G(()=>{s.current=r},[r]);let c=K({gauges:e,live:t});G(()=>{c.current={gauges:e,live:t}},[e,t]);let l=K(RH()),u=K(0);function d(){if(o.current)return o.current;let e=a.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`,ink:`#e4e4e7`};let t=getComputedStyle(e),n={bg:t.getPropertyValue(`--chart-bg`).trim()||`#0f1014`,muted:t.getPropertyValue(`--chart-muted`).trim()||`#71717a`,grid:t.getPropertyValue(`--chart-grid`).trim()||`#27272a`,ink:t.getPropertyValue(`--chart-fg`).trim()||`#e4e4e7`};return o.current=n,n}function f(){let e=i.current,t=a.current;if(!e||!t)return;let n=Math.max(1,t.clientWidth),r=Math.max(1,t.clientHeight),o=Math.min(2,window.devicePixelRatio||1),s=Math.floor(n*o),f=Math.floor(r*o);(e.width!==s||e.height!==f)&&(e.width=s,e.height=f),e.style.width=`${n}px`,e.style.height=`${r}px`;let p=e.getContext(`2d`);if(!p)return;p.setTransform(o,0,0,o,0,0);let h=d(),{gauges:g,live:_}=c.current,v=g;if(_){let e=performance.now(),t=KH(l.current,_.latestT(),e-u.current);u.current=e,v=g.map(e=>{if((e.stat??`last`)!==`last`)return e;let n=_.valueAt(e.name,t);return Number.isFinite(n)?{...e,value:n}:e}),m.current.schedule()}if(p.fillStyle=h.bg,p.fillRect(0,0,n,r),v.length===0){p.fillStyle=h.muted,p.font=`13px ${Q.sans}`,p.textAlign=`left`,p.textBaseline=`top`,p.fillText(`No data`,16,16);return}let{cols:y,rows:b}=qY(v.length,n,r,v.some(e=>e.style===`arc`)?1.15:3.2),x=n/y,S=r/b;v.forEach((e,t)=>{let n=t%y*x,r=Math.floor(t/y)*S;e.style===`arc`?rX(p,e,n,r,x,S,e.color,e.alarm??null,h):iX(p,e,n,r,x,S,e.color,e.alarm??null,h)})}let p=K(f);p.current=f;let m=K(null);return m.current??=DH(()=>p.current(),()=>a.current),W(()=>{m.current.now()}),W(()=>()=>m.current?.cancel(),[]),W(()=>{o.current=null,m.current.schedule()},[n]),G(()=>{let e=a.current;if(!e)return;let t=new EH(()=>{o.current=null,m.current.schedule()});return t.observe(e),()=>t.disconnect()},[]),q(`div`,{ref:a,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:i,className:`chart-canvas`,role:`img`,"aria-label":`Gauges: ${e.map(e=>`${e.name} ${Number.isFinite(e.value)?JY(e.value,e.max-e.min):`no value`}${e.unit?` ${e.unit}`:``}`).join(`, `)}`,onContextMenu:e=>{e.preventDefault(),s.current?.({clientX:e.clientX,clientY:e.clientY})}})})}function qY(e,t,n,r){let i={cols:1,rows:e,size:-1};for(let a=1;a<=e;a++){let o=Math.ceil(e/a),s=t/a,c=n/o,l=Math.min(s,c*r);l>i.size&&(i={cols:a,rows:o,size:l})}return{cols:i.cols,rows:i.rows}}var JY=(e,t)=>jz(e,wz(Math.abs(t),100)),YY=(e,t)=>Math.max(0,Math.min(1,(t-e.min)/(e.max-e.min||1))),XY=(e,t)=>{let n=e.fromZero?YY(e,0):0;return[Math.min(n,t),Math.max(n,t)]},ZY=(e,t)=>!!t&&(t.linked?t.linked===`active`:Number.isFinite(e.value)&&e.value>=t.value),QY=e=>(e.colorMode===`gradient`||e.colorMode===`zones`)&&!!e.stops?.length,$Y=(e,t)=>ZY(e,t)?t.color:BY(e.colorMode,e.stops,e.color,e.value);function eX(e,t,n){for(let r of VY(t.colorMode,t.stops,t.color,t.min,t.max))e.addColorStop(n(r.f0),r.color),e.addColorStop(n(r.f1),r.color);return e}function tX(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}…`).width>n;)r=r.slice(0,-1);return n>0?`${r}…`:``}var nX=Math.SQRT1_2;function rX(e,t,n,r,i,a,o,s,c){let l=Math.max(6,Math.min(i,a)*.06),u=t.max-t.min,d=JY(t.min,u),f=JY(t.max,u),p=e=>Math.max(9,Math.min(22,e*.1)),m=e=>Math.max(4,e*.13),h=Math.max(8,Math.min((i-2*l)/2,(a-2*l)/1.9)),g=0;for(let t=0;t<2;t++){e.font=`${p(h)}px ${Q.mono}`,g=Math.max(e.measureText(d).width,e.measureText(f).width);let t=m(h),n=Math.max(h+t/2,nX*h+g/2),r=h+t/2+nX*h+t/2+6+p(h)*1.2;h=Math.max(8,Math.min(h*(i-2*l)/(2*n),h*(a-2*l)/r))}let _=m(h),v=p(h),y=h+_/2+nX*h+_/2+6+v*1.2,b=n+i/2,x=r+l+h+_/2+Math.max(0,(a-2*l-y)/2),S=e=>WY+e*GY;e.lineCap=`round`,e.lineWidth=_,e.strokeStyle=c.grid,e.beginPath(),e.arc(b,x,h,WY,WY+GY),e.stroke(),s&&s.value<t.max&&(e.globalAlpha=.3,e.strokeStyle=s.color,e.lineCap=`butt`,e.beginPath(),e.arc(b,x,h,S(YY(t,s.value)),WY+GY),e.stroke(),e.globalAlpha=1,e.lineCap=`round`);let[C,w]=XY(t,Number.isFinite(t.value)?YY(t,t.value):0),T=()=>{e.lineCap=t.fromZero?`butt`:`round`,e.beginPath(),e.arc(b,x,h,S(C),Math.max(S(C)+1e-4,S(w))),e.stroke(),e.lineCap=`round`};if(QY(t)){let n=GY/(2*Math.PI),r=eX(e.createConicGradient(WY,b,x),t,e=>e*n);r.addColorStop(1,BY(t.colorMode,t.stops,t.color,t.min)),e.strokeStyle=r,e.globalAlpha=.24,e.beginPath(),e.arc(b,x,h,WY,WY+GY),e.stroke(),e.globalAlpha=1,Number.isFinite(t.value)&&!ZY(t,s)&&T()}if(Number.isFinite(t.value)&&(!QY(t)||ZY(t,s))&&(e.strokeStyle=ZY(t,s)?s.color:o,T()),t.fromZero&&t.min<0&&t.max>0){let n=S(YY(t,0));e.strokeStyle=c.muted,e.lineWidth=1.5,e.lineCap=`butt`,e.beginPath(),e.moveTo(b+Math.cos(n)*(h-_*.75),x+Math.sin(n)*(h-_*.75)),e.lineTo(b+Math.cos(n)*(h+_*.75),x+Math.sin(n)*(h+_*.75)),e.stroke(),e.lineWidth=_,e.lineCap=`round`}if(s&&s.value>=t.min&&s.value<=t.max){let n=S(YY(t,s.value));e.strokeStyle=s.color,e.lineWidth=Math.max(1.5,s.width),e.lineCap=`butt`,e.beginPath(),e.moveTo(b+Math.cos(n)*(h-_*.9),x+Math.sin(n)*(h-_*.9)),e.lineTo(b+Math.cos(n)*(h+_*.9),x+Math.sin(n)*(h+_*.9)),e.stroke();let r=h+_*.9+10*.7;s.linked&&oU(e,b+Math.cos(n)*r-10/2,x+Math.sin(n)*r-10/2,s.color)}let E=Number.isFinite(t.value)?JY(t.value,u):`—`,D=2*(h-_)*.82,O=Math.max(11,h*.42);e.font=`650 ${O}px ${Q.sans}`;let k=e.measureText(E).width;k>D&&(O=Math.max(9,O*D/k),e.font=`650 ${O}px ${Q.sans}`),e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=ZY(t,s)||QY(t)?$Y(t,s):c.ink,e.fillText(E,b,x+O*.32),e.fillStyle=c.muted,t.unit&&(e.font=`600 ${Math.max(9,h*.13)}px ${Q.sans}`,e.fillText(tX(e,t.unit,D),b,x+O*.32+Math.max(11,h*.19)));let A=x+nX*h+_/2+6,j=nX*h;e.textBaseline=`top`,e.font=`${v}px ${Q.mono}`,e.fillText(d,b-j,A),e.fillText(f,b+j,A);let M=2*j-g-16,N=Math.max(10,Math.min(26,h*.13));e.font=`600 ${N}px ${Q.sans}`;let P=e.measureText(t.name).width;P>M&&N>9&&(N=Math.max(9,N*M/P),e.font=`600 ${N}px ${Q.sans}`),e.fillText(tX(e,t.name,M),b,A+(v-N)/2)}function iX(e,t,n,r,i,a,o,s,c){let l=Math.max(14,i*.06),u=n+l,d=n+i-l,f=d-u,p=Math.max(6,Math.min(16,a*.14)),m=Math.max(12,Math.min(34,a*.28)),h=r+a/2+m*.35,g=e=>u+YY(t,e)*f;e.textBaseline=`alphabetic`,e.fillStyle=c.muted,e.font=`600 ${Math.max(10,m*.42)}px ${Q.sans}`,e.textAlign=`left`,e.fillText(tX(e,t.name,f),u,h-p/2-m-4),e.textAlign=`right`,e.fillStyle=ZY(t,s)?s.color:c.ink,e.font=`650 ${m}px ${Q.sans}`;let _=t.unit?(e.font=`600 ${Math.max(9,m*.4)}px ${Q.sans}`,e.measureText(` ${t.unit}`).width):0;t.unit&&(e.fillStyle=c.muted,e.fillText(` ${t.unit}`,d,h-p/2-8)),e.fillStyle=ZY(t,s)||QY(t)?$Y(t,s):c.ink,e.font=`650 ${m}px ${Q.sans}`,e.fillText(Number.isFinite(t.value)?JY(t.value,t.max-t.min):`—`,d-_,h-p/2-8),e.lineCap=`round`,e.lineWidth=p,e.strokeStyle=c.grid,e.beginPath(),e.moveTo(u,h),e.lineTo(d,h),e.stroke(),s&&s.value<t.max&&(e.globalAlpha=.3,e.strokeStyle=s.color,e.lineCap=`butt`,e.beginPath(),e.moveTo(g(s.value),h),e.lineTo(d,h),e.stroke(),e.globalAlpha=1,e.lineCap=`round`);let v=Number.isFinite(t.value)?YY(t,t.value):0,y=e=>u+e*f,[b,x]=XY(t,v),S=()=>{e.lineCap=t.fromZero?`butt`:`round`,e.beginPath(),e.moveTo(y(b),h),e.lineTo(Math.max(y(b)+.5,y(x)),h),e.stroke(),e.lineCap=`round`};QY(t)&&(e.strokeStyle=eX(e.createLinearGradient(u,0,d,0),t,e=>e),e.globalAlpha=.24,e.beginPath(),e.moveTo(u,h),e.lineTo(d,h),e.stroke(),e.globalAlpha=1,Number.isFinite(t.value)&&!ZY(t,s)&&S()),Number.isFinite(t.value)&&(!QY(t)||ZY(t,s))&&(e.strokeStyle=ZY(t,s)?s.color:o,S()),t.fromZero&&t.min<0&&t.max>0&&(e.strokeStyle=c.muted,e.lineWidth=1.5,e.lineCap=`butt`,e.beginPath(),e.moveTo(g(0),h-p*.75),e.lineTo(g(0),h+p*.75),e.stroke(),e.lineWidth=p,e.lineCap=`round`),s&&s.value>=t.min&&s.value<=t.max&&(e.strokeStyle=s.color,e.lineWidth=Math.max(1.5,s.width),e.lineCap=`butt`,e.beginPath(),e.moveTo(g(s.value),h-p),e.lineTo(g(s.value),h+p),e.stroke(),s.linked&&oU(e,g(s.value)-10/2,h-p-10-2,s.color)),e.fillStyle=c.muted,e.font=`${Math.max(9,m*.34)}px ${Q.mono}`,e.textBaseline=`top`,e.textAlign=`left`,e.fillText(JY(t.min,t.max-t.min),u,h+p/2+4),e.textAlign=`right`,e.fillText(JY(t.max,t.max-t.min),d,h+p/2+4)}var aX=720;function oX(e,t){return t?e<aX:e<640}function sX(e){return e<=1?{cols:1,rows:1}:e===2?{cols:2,rows:1}:e<=4?{cols:2,rows:2}:{cols:3,rows:3}}function cX(e,t){return e.flatMap(e=>{let n=e.info?.meta;if(!n?.recordingId)return[];let r=n.wallOrigin?Number(n.wallOrigin):NaN,i=n.wallQuality;return[{recordingId:n.recordingId,wallOrigin:Number.isFinite(r)?r:null,wallQuality:i===`exact`||i===`approx`?i:null,xOffset:t[e.id]??0}]})}var lX={get:()=>null,subscribe:()=>()=>{}};function uX(e){let[t,n]=ft(null);return G(()=>{let t=e.current;if(!t)return;let r=e=>n(t=>oX(e,t??!1));if(r(t.clientWidth),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(e=>{for(let t of e)r(t.contentRect.width)});return i.observe(t),()=>i.disconnect()},[e]),t}function dX(e){let t=Wn(e.settings),[n,r]=ft(null),[i,a]=ft(null),o=K(null);W(()=>{i&&o.current?.querySelector(`[data-camera="${CSS.escape(i)}"]`)?.focus()},[i]);let s=e.recordings??[],c=e=>s.findIndex(t=>t.recordingId===e.recordingId),l=(e.video??[]).filter(e=>e.kind===`recorded`&&c(e)>=0).sort((e,t)=>c(e)-c(t)),u=e.onContextMenu?t=>{t.preventDefault(),e.onContextMenu({clientX:t.clientX,clientY:t.clientY})}:void 0;if(!t.length){let t=[...new Set([...e.live.filter(e=>e.kind===`camera`&&!e.lowOf),...l].map(t=>Vn(t,e.live)))].sort();return q(pX,{onContextMenu:u,title:`Choose a camera in this panel's settings`,detail:t.length?t.join(`, `):void 0})}let d={panel:e,recorded:l,recIndex:c};if(t.length===1)return q(fX,{...d,id:t[0],onMenu:u});let f=n&&t.includes(n)?n:null,p=f?[f]:t,{cols:m,rows:h}=sX(p.length),g=()=>{a(f),r(null)};return _t(`div`,{ref:o,className:`kymo-camera-wall`,style:{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${h}, minmax(0, 1fr))`},onContextMenu:u,onKeyDown:e=>{e.key===`Escape`&&f&&(e.stopPropagation(),g())},children:[p.map(e=>q(fX,{...d,id:e,multi:!0,wall:!f,onPick:f?void 0:()=>{a(null),r(e)}},e)),f?_t(`button`,{type:`button`,className:`kymo-camera__all`,onClick:g,autoFocus:!0,children:[_t(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[q(`rect`,{x:`2`,y:`2`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`9`,y:`2`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`2`,y:`9`,width:`5`,height:`5`,rx:`1`}),q(`rect`,{x:`9`,y:`9`,width:`5`,height:`5`,rx:`1`})]}),`All cameras`]}):null]})}function fX({panel:e,recorded:t,recIndex:n,id:r,multi:i,wall:a,onPick:o,onMenu:s}){let c=e.recordings??[],l={onMenu:s,wall:a,onPick:o},u=t.find(e=>e.id===r);if(u)return q(mX,{...e,...l,source:u,name:i?Vn(u,e.live):u.name,rec:c[n(u)]},`rec:${u.recordingId}:${u.id}`);let d=e.live.find(e=>e.id===r&&e.kind===`camera`);if(!d?.video||d.status===`error`)return q(pX,{onContextMenu:s,title:`Camera offline`,detail:d?Vn(d,e.live):void 0});let f=e.live.find(e=>e.kind===`camera`&&e.lowOf===d.id&&e.video&&e.status!==`error`),p=f?.video?DE({...f,video:f.video}):void 0;return q(mX,{...e,...l,source:DE({...d,video:d.video}),low:p,name:i?Vn(d,e.live):d.name,conn:d},d.id)}function pX({title:e,detail:t,onContextMenu:n}){return q(`div`,{className:`kymo-camera`,onContextMenu:n,children:_t(`div`,{className:`kymo-camera__empty`,children:[_t(`svg`,{className:`kymo-camera__empty-icon`,viewBox:`0 0 24 24`,"aria-hidden":`true`,children:[q(`rect`,{x:`2.5`,y:`6`,width:`13`,height:`12`,rx:`2.5`}),q(`path`,{d:`M15.5 10.5 21.5 7v10l-6-3.5`})]}),q(`p`,{className:`kymo-camera__empty-title`,children:e}),t?q(`p`,{className:`kymo-camera__empty-detail`,children:t}):null]})})}function mX(e){let{settings:t,source:n}=e,r=e.cursor??lX,i=pt(r.subscribe,r.get),a=e=>e.kind===`data`,o=e.rec?void 0:t.syncStreamId?e.live.find(e=>e.id===t.syncStreamId&&a(e)):e.live.find(t=>t.id===e.conn.parentId&&a(t))??e.live.find(t=>a(t)&&e.selection.includes(t.id))??e.live.find(a),s=i??e.viewXRange?.[1]??null,c=null,l=null,u=o?.clock?.quality()??`none`;if(e.rec){let{wallOrigin:r,wallQuality:i,xOffset:a}=e.rec;u=i??`none`;let o=n.range()?.[0]??null;s===null?c=o:r===null?(c=o,l=`This recording has no wall clock`):e.xKey===`Time`?c=r+s-a+t.offsetMs/1e3:e.xKey===`ElapsedTime`&&i===`exact`?c=s-a+t.offsetMs/1e3:(c=o,l=`Sync needs a time X axis`)}else s!==null&&(e.xIsTime?(c=o?.clock?.toWall(s,t.offsetMs)??null,c===null&&(l=`No data stream to sync with`)):l=`Sync needs a time X axis`);let d=K(null),f=K(null),p=uX(d),m=p===null?null:e.low&&(p||e.wall)?e.low:n,h=K(t.fit),g=K(c);G(()=>{h.current=t.fit,g.current=c});let _=K(null),v=K(null),[y,b]=ft(null),x=y??m??n,[S,C]=ft(!1),[w,T]=ft(!0);W(()=>{if(!m||_.current?.source===m)return;let e=!_.current,t=null,n=!1,r=()=>t?_.current===t:e,i=t=gX(m,f.current,()=>h.current,g.current,{unsupported:()=>{r()&&C(!0)},buffered:e=>{r()&&T(e)},frame:()=>{if(_.current===t){n||(n=!0,b(m));return}_.current?.dispose(),_.current=i,v.current=null,i.show(),n=!0,b(m),T(i.buffered())}},e);if(e){_.current=i;return}return v.current=i,()=>{_.current!==i&&(i.dispose(),v.current===i&&(v.current=null))}},[m]),W(()=>()=>{_.current?.dispose(),_.current=null},[]),W(()=>{_.current?.setTarget(c),v.current?.setTarget(c)},[c]);let E=!!x.lowOf,D=x.info().latestT,O=!e.rec&&c!==null&&D!==null?c-D:null,k=e.rec?`No video at this time`:`Not buffered`;return _t(`div`,{ref:d,className:`kymo-camera${e.onPick?` is-tile`:``}`,onContextMenu:e.onMenu,...e.onPick?{role:`button`,tabIndex:0,"data-camera":n.id,"aria-label":`Show ${e.name} alone`,onClick:e.onPick,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e.onPick())}}:{},children:[q(`canvas`,{ref:f,className:`kymo-camera__video`,role:`img`,"aria-label":`Video from ${e.name}`}),S?q(`div`,{className:`kymo-camera__empty`,children:q(`p`,{className:`kymo-camera__empty-title`,children:`This browser can't decode this camera`})}):_t(`div`,{className:`kymo-camera__overlay`,children:[q(`span`,{className:`kymo-camera__name`,children:e.name}),e.rec?q(`span`,{className:`kymo-camera__rec`,children:`Recording`}):c===null?q(`span`,{className:`kymo-camera__live`,children:`LIVE`}):q(`span`,{className:`kymo-camera__ago`,children:O===null?``:hX(O)}),E?q(`span`,{className:`kymo-camera__badge`,title:`Low-quality copy (small panel)`,children:`LQ`}):null,c!==null&&u!==`none`?q(`span`,{className:`kymo-camera__badge${u===`exact`?` is-exact`:``}`,children:u===`exact`?`Exact`:`Approx.`}):null,l??(c!==null&&!w?k:null)?q(`span`,{className:`kymo-camera__note`,children:l??k}):null]})]})}function hX(e){let t=Math.abs(e).toFixed(1);return t===`0.0`?`0.0 s`:`${e<0?`−`:`+`}${t} s`}function gX(e,t,n,r,i,a=!0){let o=e.acquire?.(),s=!1,c=!0,l=e=>{c=e,i.buffered(e)},u=null,d=null,f=r,p=`live`,m=!0,h=!1,g=!1,_=null,v=null,y=null,b=[],x=e=>{if(s){e.close();return}p===`seek`?(_?.close(),_=e):(v?.close(),v=e,i.frame?.())},S=()=>{!d||d.state===`closed`?d=new VideoDecoder({output:x,error:()=>{}}):d.reset(),d.configure(u),m=!0},C=e=>{d?.state===`closed`&&e.key&&S(),!(d?.state!==`configured`||m&&!e.key)&&(m=!1,d.decode(new EncodedVideoChunk({type:e.key?`key`:`delta`,timestamp:Math.round(e.t*1e6),data:e.data})))},w=()=>{p=`live`,l(!0),S();for(let t of e.livePlan?.()??[])C(t)},T=async()=>{if(!h){h=!0;try{for(;!s&&p===`seek`&&g;){g=!1;let t=[];try{t=await e.seekPlan(f)}catch{}if(!(s||p!==`seek`||g)&&(l(t.length>0),t.length)){S();for(let e of t)C(e);try{await d.flush()}catch{}p===`seek`&&_&&(v?.close(),v=_,_=null,i.frame?.())}}}finally{h=!1,_?.close(),_=null}}},E=()=>{f===null?p!==`live`&&w():(p=`seek`,g=!0,T())};e.onUnit&&b.push(e.onUnit(e=>{u&&p===`live`&&C(e)})),(async()=>{if(typeof VideoDecoder>`u`){i.unsupported();return}if(e.info().codec||(e.ready?await e.ready():e.onUnit&&await new Promise(t=>{let n=e.onUnit(()=>{e.info().codec&&(n(),t())});b.push(n)})),s)return;if(!e.info().codec){l(!1);return}let t={codec:e.info().codec,optimizeForLatency:!0,hardwareAcceleration:`no-preference`},n=!1;try{n=(await VideoDecoder.isConfigSupported(t)).supported===!0}catch{}if(!s){if(!n){i.unsupported();return}u=t,f===null?w():E()}})();let D=n(),O=()=>{if(!a)return;let e=window.devicePixelRatio||1,r=Math.max(1,Math.round(t.clientWidth*e)),i=Math.max(1,Math.round(t.clientHeight*e)),o=!1;if((t.width!==r||t.height!==i)&&(t.width=r,t.height=i,o=!0),v&&(y?.close(),y=v,v=null,o=!0),n()!==D&&(D=n(),o=!0),!o||!y)return;let s=t.getContext(`2d`);if(!s)return;let c=y.displayWidth,l=y.displayHeight,u=D===`cover`?Math.max(r/c,i/l):Math.min(r/c,i/l),d=c*u,f=l*u;s.clearRect(0,0,r,i),s.drawImage(y,(r-d)/2,(i-f)/2,d,f)},k=0,A=()=>{k=bH(A),O()};return k=bH(A),{source:e,show(){a=!0},buffered:()=>c,setTarget(e){e!==f&&(f=e,u&&E())},dispose(){s=!0,xH(k),b.forEach(e=>e()),d&&d.state!==`closed`&&d.close();for(let e of[_,v,y])e?.close();_=v=y=null,o?.()}}}function _X(e,t){let n=e.filter(e=>e.x.length>=2&&vX(e.x));if(n.length<2)return null;let r=1/0,i=-1/0;for(let e of n)e.x[0]<r&&(r=e.x[0]),e.x[e.x.length-1]>i&&(i=e.x[e.x.length-1]);if(!(i>r))return null;let a=Math.max(2,t),o=Float64Array.from({length:a},(e,t)=>r+t/(a-1)*(i-r)),s=new Float64Array(a).fill(1/0),c=new Float64Array(a).fill(-1/0),l=new Uint16Array(a);for(let e of n){let t=0;for(let n=0;n<a;n++){let r=o[n];if(r<e.x[0]||r>e.x[e.x.length-1])continue;for(;t<e.x.length-2&&e.x[t+1]<r;)t++;let i=e.x[t],a=e.x[t+1],u=e.y[t],d=e.y[t+1],f=a===i?u:u+(d-u)*(r-i)/(a-i);f-f===0&&(f<s[n]&&(s[n]=f),f>c[n]&&(c[n]=f),l[n]++)}}for(let e=0;e<a;e++)l[e]<2&&(s[e]=NaN,c[e]=NaN);return{x:o,lo:s,hi:c}}function vX(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return!0}function yX(e){if(e.length===0)return null;if(e.length===1)return e[0];let t=new Set,n={};for(let r of e)for(let e=0;e<r.columnNames.length;e++){let i=r.columnNames[e];t.add(i),r.units[e]?.trim()&&(n[i]=r.units[e])}let r=[...t];return{meta:``,columnNames:r,units:r.map(e=>n[e]??``),rows:e.flatMap(e=>e.rows)}}function bX(e,t,n,r,i){return n||e.length===0||(t>0?e.length!==1:e.length<2||r!==`ElapsedTime`)?null:e.map((e,n)=>({conn:e,keySuffix:`__${t+n}`,offset:i[e.id]??0}))}function xX(e,t,n,r,i){if(e.length===1){let a=e[0];return SX(a.conn,t,n,a.keySuffix,a.offset,r,i)}let a=e.map(e=>SX(e.conn,t,n,e.keySuffix,e.offset,[],null)),o=()=>a.reduce((e,t)=>t.latestT()>e.latestT()?t:e);return{pull:(e,t,n,i)=>[...r,...a.flatMap(r=>r.pull(e,t,n,i))],xBounds:()=>{let e=i;for(let t of a){let n=t.xBounds();n&&(e=e?[Math.min(e[0],n[0]),Math.max(e[1],n[1])]:n)}return e},latestX:()=>o().latestX(),version:()=>a.reduce((e,t)=>e+t.version(),0),latestT:()=>o().latestT(),xAtTime:e=>o().xAtTime(e),latestValues:e=>new Map(a.flatMap(t=>[...t.latestValues(e)]))}}function SX(e,t,n,r,i,a,s){let l=null;return{pull:(s,u,d,f)=>{let p=e.source.version();if(!l||l.ver!==p||l.x0!==s||l.x1!==u||l.mp!==d){let a=e.source.getPointsSync(n,{xKey:t,x0:s-i,x1:u-i},d),o=i===0?a.x:a.x.map(e=>e+i);l={ver:p,x0:s,x1:u,mp:d,pts:{...a,x:o,cols:new Map([...a.cols].map(([e,t])=>[e+r,t]))}}}let m=o(l.pts,f);if(t!==`ElapsedTime`)return[...a,m];let h=Math.min(e.source.latestTimeSync(),f===void 0?1/0:f-i),g=c(n,t=>e.source.lastKnownSync(t),s-i,u-i,h);if(!g)return[...a,m];let _=i===0?g.x:g.x.map(e=>e+i);return[...a,m,{...g,x:_,cols:new Map([...g.cols].map(([e,t])=>[e+r,t]))}]},xBounds:()=>{let n=e.source.xBoundsSync(t);return n.x1>n.x0?s?[Math.min(s[0],n.x0+i),Math.max(s[1],n.x1+i)]:[n.x0+i,n.x1+i]:s},latestX:()=>{let n=e.source.latestSync(t);return Number.isFinite(n)?n+i:null},version:()=>e.source.version(),id:e.id,latestT:()=>e.source.latestTimeSync(),xAtTime:n=>e.source.xAtTimeSync(t,n)+i,latestValues:t=>{let n=new Map,i=t.filter(e=>e.endsWith(r)),a=e.source.latestValuesSync(i.map(e=>e.slice(0,-r.length)));for(let e of i){let t=a.get(e.slice(0,-r.length));t!==void 0&&n.set(e,t)}return n}}}function CX(e,t){return e.filter(e=>B(t,e))}var wX=`__ref`,TX=8e3;function EX(e,t){return e.map(e=>({...e,id:`${e.id}${wX}`,column:`${e.column}${wX}`,color:t}))}var DX=new WeakMap;function OX(e,t,r){let i=e.data.rows,a=`${t}\n${r.join(`
|
|
608
608
|
`)}`,o=DX.get(i);o||(o=new Map,DX.set(i,o));let s=o.get(a);if(s)return s;let c=kX(n(i,t,r,TX,wX)),l={points:c,span:c.length>1?[c.x[0],c.x[c.length-1]]:null};return o.set(a,l),l}function kX(e){let t=!0;for(let n=1;n<e.length&&t;n++)t=e.x[n-1]<=e.x[n];if(t)return e;let n=Array.from({length:e.length},(e,t)=>t).sort((t,n)=>e.x[t]-e.x[n]),r=new Map;for(let[t,i]of e.cols)r.set(t,Float64Array.from(n,e=>i[e]));return{length:e.length,x:Float64Array.from(n,t=>e.x[t]),cols:r}}function AX(e,t){return e?t?[Math.min(e[0],t[0]),Math.max(e[1],t[1])]:e:t}function jX(e,t,n,r,i){e.source.trackCycles(t);let a=r.reference===`dataset`&&i?OX(i,t,n):null,s=null;return{pull:(i,c,l,u)=>{let d=e.source.version();if(!s||s.ver!==d||s.x0!==i||s.x1!==c||s.mp!==l){let o=Ye;if(r.reference===`previous`){let r=e.source.cyclePointsSync(t,`previous`,n,{x0:i,x1:c},l);o={...r,cols:new Map([...r.cols].map(([e,t])=>[e+wX,t]))}}else a&&(o=j(a.points,i,c));s={ver:d,x0:i,x1:c,mp:l,live:e.source.cyclePointsSync(t,`current`,n,{x0:i,x1:c},l),ref:o}}return[s.ref,o(s.live,u)]},id:e.id,latestT:()=>e.source.latestTimeSync(),xAtTime:n=>e.source.xAtTimeSync(t,n),xBounds:()=>AX(e.source.cycleSpanSync(t),a?.span??null),latestX:()=>{let n=e.source.latestSync(t);return Number.isFinite(n)?n:null},version:()=>e.source.version(),latestValues:t=>e.source.latestValuesSync(t)}}function MX(e,t){return e.reference===`previous`?e.previousColor:e.reference===`dataset`&&t?e.datasetColor:null}function NX(e,t,n,r,i=0){let a=e.bands;if(!a)return[];let o=n.filter(e=>a[e.column]);if(o.length===0||e.data.rows.length!==a[o[0].column].lo.length)return[];let s=Float64Array.from(e.data.rows,e=>{let n=e[t];return typeof n==`number`?n+i:NaN});return o.map(e=>({seriesId:e.id,color:r??e.color,x:s,lo:a[e.column].lo,hi:a[e.column].hi}))}var PX=class{#e;#t;#n;#r=new Map;constructor(e,t={}){this.#e=e,this.#t=[...e.keys()].map(e=>({name:e,type:`number`,unit:t[e]??``})),this.#n=e.size?e.values().next().value.length:0}get length(){return this.#n}get columnMap(){return this.#e}async getSchema(){return this.#t}async getSeries(e){let t=this.#e.get(e.viewport.xKey),n=this.#e.get(e.column);return!t||!n?$e(new Float64Array,new Float64Array,e.viewport.x0,e.viewport.x1,e.maxPoints):$e(t,n,e.viewport.x0,e.viewport.x1,e.maxPoints)}async getSeriesMulti(e,t,n){return this.getSeriesMultiSync(e,t,n)}getSeriesMultiSync(e,t,n){let r=this.#e.get(t.xKey),i=r?e.filter(e=>this.#e.has(e)):[];return!r||i.length===0?{x0:t.x0,bucket:0,rows:[],columns:i}:a(r,i.map(e=>this.#e.get(e)),i,t.x0,t.x1,n)}getColumnsSync(e,t,n){let r=this.#e.get(t.xKey),i=r?e.filter(e=>this.#e.has(e)):[];return!r||i.length===0?null:R(r,i.map(e=>this.#e.get(e)),i,t.x0,t.x1,n)}async readColumns(e,t,n){let r={};for(let i of e){let e=this.#e.get(i);e&&(r[i]=e.slice(t,t+n))}return r}async xBounds(e){return this.xBoundsSync(e)}xBoundsSync(e){let t=this.#r.get(e);if(!t){let n=this.#e.get(e),r=1/0,i=-1/0;if(n)for(let e=0;e<n.length;e++){let t=n[e];t<r&&(r=t),t>i&&(i=t)}t=r<=i?{x0:r,x1:i}:{x0:0,x1:0},this.#r.set(e,t)}return t}sampleRowsSync(e,t){let n=t?this.#e.get(t.xcol):void 0,r=null;if(t&&n){r=[];for(let e=0;e<n.length;e++)n[e]>=t.x0&&n[e]<=t.x1&&r.push(e)}let i=r?r.length:this.#n,a=Math.max(1,Math.ceil(i/e)),o=[...this.#e.keys()],s=o.map(e=>this.#e.get(e)),c=[];for(let e=0;e<i;e+=a){let t=r?r[e]:e,n={};for(let e=0;e<o.length;e++){let r=s[e][t];n[o[e]]=Number.isNaN(r)?null:r}c.push(n)}return c}async sampleRows(e,t){return this.sampleRowsSync(e,t)}async dispose(){}};function FX(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e4||t<.01&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(4)))}function IX(e,t){let n=Math.max(1,Math.min(50,Math.floor(t.xBins))),r=Math.max(1,Math.min(50,Math.floor(t.yBins))),i=t.xMin,a=t.xMax,o=t.yMin,s=t.yMax;if(i===void 0||a===void 0||o===void 0||s===void 0){let n=1/0,r=-1/0,c=1/0,l=-1/0;for(let i of e){let e=i[t.xCol],a=i[t.yCol];typeof e==`number`&&Number.isFinite(e)&&(e<n&&(n=e),e>r&&(r=e)),typeof a==`number`&&Number.isFinite(a)&&(a<c&&(c=a),a>l&&(l=a))}i===void 0&&(i=n),a===void 0&&(a=r),o===void 0&&(o=c),s===void 0&&(s=l)}let c=a-i,l=s-o;if(!(c>0)||!(l>0))return{cells:[],xLabels:[],yLabels:[]};let u=new Float64Array(n*r),d=new Float64Array(n*r),f=t.valueCol===``;for(let p of e){let e=p[t.xCol],m=p[t.yCol];if(typeof e!=`number`||!Number.isFinite(e)||typeof m!=`number`||!Number.isFinite(m)||e<i||e>a||m<o||m>s)continue;let h=Math.floor((e-i)/c*n);h>=n&&(h=n-1),h<0&&(h=0);let g=Math.floor((m-o)/l*r);g>=r&&(g=r-1),g<0&&(g=0);let _=g*n+h;if(f)d[_]+=1;else{let e=p[t.valueCol];if(typeof e!=`number`||!Number.isFinite(e))continue;u[_]+=e,d[_]+=1}}let p=Array.from({length:n},(e,t)=>FX(i+(t+.5)*(c/n))),m=Array.from({length:r},(e,t)=>FX(o+(r-1-t+.5)*(l/r))),h=[];for(let e=0;e<r;e++){let t=r-1-e;for(let r=0;r<n;r++){let i=e*n+r,a=d[i],o=f?a:a>0?u[i]/a:NaN;h.push({x:p[r],y:m[t],value:o})}}return{cells:h,xLabels:p,yLabels:m}}function LX(e,t){return t.some(t=>t.name===e)}function RX(e,t){return LX(e,t)?`ƒ ${e}`:e}var zX=8e3,BX=3e3,VX=[];function HX(e){return`live`in e?e.live.source.columns():`source`in e&&e.source instanceof PX?e.source.columnMap:void 0}var UX=4e3,WX=new WeakMap;function GX(e,t,n){let r=WX.get(e);r||WX.set(e,r=new Map);let i=JSON.stringify([n,...t]),a=r.get(i);return a||r.set(i,a=new LE({meta:``,columnNames:[n,...t],units:[],rows:e})),a}var KX=new WeakMap;function qX(e,t){if(t!==`parallel`||e.length===0)return e;let n=e.length,r=100/n;return e.map((e,t)=>({...e,bandFromPct:Math.round((n-1-t)*r),bandToPct:Math.round((n-t)*r)}))}function JX(e,t){let n=1/0,r=-1/0;for(let{rows:i,offset:a}of e){let e=KX.get(i);e||(e=new Map,KX.set(i,e));let o=e.get(t);if(o===void 0){let n=1/0,r=-1/0;for(let e of i){let i=e[t];typeof i!=`number`||!Number.isFinite(i)||(i<n&&(n=i),i>r&&(r=i))}o=Number.isFinite(n)?[n,r]:null,e.set(t,o)}o&&(n=Math.min(n,o[0]+a),r=Math.max(r,o[1]+a))}return Number.isFinite(n)&&r>n?[n,r]:null}function YX(e,t){let n={};for(let t=0;t<e.columnNames.length;t++){let r=e.units[t]?.trim();r&&(n[e.columnNames[t]]=r)}let r=Object.entries(n);for(let e=0;e<t;e++)for(let[t,i]of r)n[`${t}__${e}`]=i;return n}function XX(e,t){let n=1/0,r=-1/0;for(let i of e){let e=i[t];typeof e!=`number`||!Number.isFinite(e)||(e<n&&(n=e),e>r&&(r=e))}if(!(r>n))return e;let i=(r-n)/2,a=0,o=NaN;for(let n=0;n<e.length;n++){let r=e[n][t];typeof r!=`number`||!Number.isFinite(r)||(r<o-i&&(a=n),o=r)}return a===0?e:e.slice(a)}var ZX=new Map;function QX(e){let t=ZX.get(e);return t||(t=Float64Array.from({length:e},(e,t)=>t),ZX.clear(),ZX.set(e,t)),t}function $X(e){let{worksheet:t,viewXRange:r,selectedIds:i,selectedDatasets:a,mathChannels:o,datasetOffsets:s,datasetColors:c,datasetPalette:l}=e,u=t.panels,d=t.panelChartSettings,f=t.xKey,p={connections:dt(()=>f===`ElapsedTime`?e.liveConnections:e.liveConnections.map(e=>{let t=XX(e.dataset.rows,f);return t===e.dataset.rows?e:{...e,dataset:{...e.dataset,rows:t}}}),[e.liveConnections,f])},[m,h]=ft({}),g=dt(()=>u.some(e=>e.kind!==`multiband`),[u]),_=dt(()=>p.connections.some(e=>i.includes(e.id)),[p.connections,i]),v=dt(()=>{let e=p.connections.filter(e=>i.includes(e.id));return e.length===1&&a.length===0?e[0]:null},[p.connections,i,a]),y=dt(()=>yX(a.map(e=>{let t=m[e.id];return t?{...e.data,rows:t}:e.data})),[a,m]),b=dt(()=>{let e=p.connections.filter(e=>i.includes(e.id)).map(e=>e.dataset);return e.length===0?y:yX(y?[y,...e]:e)},[y,p.connections,i]),x=dt(()=>SE(o,d,f).map(e=>e.id).join(`
|
|
609
609
|
`),[o,d,f]),S=dt(()=>{let e=new Set(x.split(`
|
|
610
610
|
`));return o.filter(t=>e.has(t.id))},[o,x]),C=dt(()=>{if(!b)return null;let e=[...a.map(e=>{let t=m[e.id];return t?{...e.data,rows:t}:e.data}),...p.connections.filter(e=>i.includes(e.id)).map(e=>e.dataset)];if(S.length===0)return{dataset:b,partRows:e.map(e=>e.rows),parts:e};let t=e.map(e=>xE(e,S,f)),n=new Set(t.flatMap(e=>e.ok.map(e=>e.id))),r=S.filter(e=>n.has(e.id)),o=t.map(e=>e.rows),s=t.map(e=>e.ok.map(e=>e.name));if(r.length===0)return{dataset:b,partRows:o,parts:e};let c=r.filter(e=>!b.columnNames.includes(e.name));return{dataset:{meta:b.meta,columnNames:[...b.columnNames,...c.map(e=>e.name)],units:[...b.units,...c.map(e=>e.units)],rows:o.length===1?o[0]:[].concat(...o)},partRows:o,parts:e,okByPart:s}},[b,a,m,p.connections,i,S,f]),w=C?.dataset??null,T=dt(()=>{let e=p.connections.filter(e=>i.includes(e.id));return e.length===0?a:[...a,...e.map(e=>({id:e.id,name:e.name,data:e.dataset,live:e}))]},[a,p.connections,i]),E=T.length>1,D=dt(()=>T.length===1?HX(T[0]):void 0,[T]),O=C?.partRows??VX;W(()=>{let e=a.filter(e=>e.kind!==`memory`);if(e.length===0)return;if(!r||!g){h(e=>Object.keys(e).length?{}:e);return}let t=!1,n=setTimeout(()=>{(async()=>{let n=await Promise.all(e.map(async e=>{let t={xcol:f,x0:r[0],x1:r[1]};try{let n=e.source,r=await $U(`sampleRows`,()=>n.sampleRows(BX,t));return[e.id,r]}catch{return null}}));if(t)return;let i={};for(let e of n)e&&(i[e[0]]=e[1]);h(i)})()},150);return()=>{t=!0,clearTimeout(n)}},[a,r,f,g]);let k=dt(()=>w?.columnNames.join(`
|