@kymoscope/sdk 0.0.0-stage → 0.1.0

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.
Files changed (223) hide show
  1. package/LICENSE.md +69 -0
  2. package/README.md +138 -2
  3. package/dist/assets/duckdb-browser-eh.worker--3HUwN9R.js +14 -0
  4. package/dist/assets/duckdb-eh-D-nnNw7L.wasm.gz +0 -0
  5. package/dist/assets/h5wasmModule-BCQWU2Gw.js +24295 -0
  6. package/dist/assets/importer.worker-D4is7BLf.js +6 -0
  7. package/dist/assets/offscreenLineWorker-mShhnyXX.js +79 -0
  8. package/dist/assets/parseDataset.worker-PynRsPD8.js +5 -0
  9. package/dist/importers-DivmF3tx.js +5 -0
  10. package/dist/krc-CbE28CjD.js +9 -0
  11. package/dist/kymoscope-embed.js +633 -0
  12. package/dist/kymoscope-sdk.js +616 -0
  13. package/dist/react.js +2 -0
  14. package/dist/styles/charts.css +207 -0
  15. package/dist/styles/fonts/OFL.txt +93 -0
  16. package/dist/styles/fonts/plus-jakarta-sans-italic-latin-ext.woff2 +0 -0
  17. package/dist/styles/fonts/plus-jakarta-sans-italic-latin.woff2 +0 -0
  18. package/dist/styles/fonts/plus-jakarta-sans-latin-ext.woff2 +0 -0
  19. package/dist/styles/fonts/plus-jakarta-sans-latin.woff2 +0 -0
  20. package/dist/styles/tokens.css +218 -0
  21. package/dist/types/charts/AlarmOverlay.d.ts +11 -0
  22. package/dist/types/charts/AnnotationLayer.d.ts +29 -0
  23. package/dist/types/charts/ChartBody.d.ts +52 -0
  24. package/dist/types/charts/PerfHud.d.ts +20 -0
  25. package/dist/types/charts/beacon.d.ts +27 -0
  26. package/dist/types/charts/chartWindow.d.ts +31 -0
  27. package/dist/types/charts/liveOverlay.d.ts +16 -0
  28. package/dist/types/charts/runtime.d.ts +63 -0
  29. package/dist/types/charts/useWorksheetData.d.ts +159 -0
  30. package/dist/types/components/AreaChart.d.ts +21 -0
  31. package/dist/types/components/BarChart.d.ts +30 -0
  32. package/dist/types/components/BoxPlotChart.d.ts +16 -0
  33. package/dist/types/components/BubbleChart.d.ts +24 -0
  34. package/dist/types/components/CalibrationChart.d.ts +15 -0
  35. package/dist/types/components/CdfChart.d.ts +15 -0
  36. package/dist/types/components/ConfusionChart.d.ts +11 -0
  37. package/dist/types/components/ControlChart.d.ts +17 -0
  38. package/dist/types/components/DuckDbMultiBandPanel.d.ts +35 -0
  39. package/dist/types/components/EmbeddingChart.d.ts +25 -0
  40. package/dist/types/components/FlameGraphChart.d.ts +15 -0
  41. package/dist/types/components/GanttChart.d.ts +15 -0
  42. package/dist/types/components/GaugeChart.d.ts +27 -0
  43. package/dist/types/components/HeatmapChart.d.ts +41 -0
  44. package/dist/types/components/HistogramChart.d.ts +15 -0
  45. package/dist/types/components/LossCurveChart.d.ts +17 -0
  46. package/dist/types/components/MultiBandCanvasChart.d.ts +156 -0
  47. package/dist/types/components/ParallelCoordsChart.d.ts +21 -0
  48. package/dist/types/components/PolarChart.d.ts +17 -0
  49. package/dist/types/components/QQPlotChart.d.ts +16 -0
  50. package/dist/types/components/RadarChart.d.ts +17 -0
  51. package/dist/types/components/RocChart.d.ts +12 -0
  52. package/dist/types/components/SankeyChart.d.ts +15 -0
  53. package/dist/types/components/SpectrogramChart.d.ts +16 -0
  54. package/dist/types/components/SpectrogramWaterfall.d.ts +14 -0
  55. package/dist/types/components/SpectrumChart.d.ts +17 -0
  56. package/dist/types/components/TreemapChart.d.ts +14 -0
  57. package/dist/types/components/ViolinChart.d.ts +17 -0
  58. package/dist/types/components/XYScatterChart.d.ts +47 -0
  59. package/dist/types/components/XYZMeshChart.d.ts +68 -0
  60. package/dist/types/components/dashboardGridLayout.d.ts +50 -0
  61. package/dist/types/components/liveFollowEase.d.ts +10 -0
  62. package/dist/types/components/liveWindow.d.ts +63 -0
  63. package/dist/types/components/multiBandHover.d.ts +44 -0
  64. package/dist/types/embed/Attribution.d.ts +5 -0
  65. package/dist/types/embed/license.d.ts +29 -0
  66. package/dist/types/embed/standalone.d.ts +5 -0
  67. package/dist/types/engine/columns.d.ts +44 -0
  68. package/dist/types/engine/createEngine.d.ts +394 -0
  69. package/dist/types/engine/derive.d.ts +27 -0
  70. package/dist/types/engine/emitter.d.ts +6 -0
  71. package/dist/types/engine/errors.d.ts +7 -0
  72. package/dist/types/engine/history.d.ts +29 -0
  73. package/dist/types/engine/kinds.d.ts +9 -0
  74. package/dist/types/engine/liveController.d.ts +27 -0
  75. package/dist/types/engine/store.d.ts +8 -0
  76. package/dist/types/engine/types.d.ts +194 -0
  77. package/dist/types/index.d.ts +69 -0
  78. package/dist/types/lib/annotations.d.ts +37 -0
  79. package/dist/types/lib/beacon.d.ts +62 -0
  80. package/dist/types/lib/colorScheme.d.ts +5 -0
  81. package/dist/types/lib/colormap.d.ts +9 -0
  82. package/dist/types/lib/columnTable.d.ts +37 -0
  83. package/dist/types/lib/data/arrowDecimation.d.ts +11 -0
  84. package/dist/types/lib/data/binnedHeatmap.d.ts +27 -0
  85. package/dist/types/lib/data/columnCaches.d.ts +6 -0
  86. package/dist/types/lib/data/columnarDataSource.d.ts +34 -0
  87. package/dist/types/lib/data/createDataSource.d.ts +23 -0
  88. package/dist/types/lib/data/dataSource.d.ts +75 -0
  89. package/dist/types/lib/data/decimate.d.ts +25 -0
  90. package/dist/types/lib/data/duckDbDataSource.d.ts +42 -0
  91. package/dist/types/lib/data/envelope.d.ts +16 -0
  92. package/dist/types/lib/data/inMemoryDataSource.d.ts +25 -0
  93. package/dist/types/lib/data/liveDataSource.d.ts +77 -0
  94. package/dist/types/lib/data/lruCache.d.ts +11 -0
  95. package/dist/types/lib/data/openDataset.d.ts +24 -0
  96. package/dist/types/lib/data/opfsParquet.d.ts +4 -0
  97. package/dist/types/lib/data/pointColumns.d.ts +59 -0
  98. package/dist/types/lib/data/schemaColumns.d.ts +5 -0
  99. package/dist/types/lib/data/useSeriesPoints.d.ts +48 -0
  100. package/dist/types/lib/data/xyColumns.d.ts +77 -0
  101. package/dist/types/lib/dataBounds.d.ts +10 -0
  102. package/dist/types/lib/datasetColors.d.ts +19 -0
  103. package/dist/types/lib/datasetColumns.d.ts +3 -0
  104. package/dist/types/lib/datasetMerge.d.ts +8 -0
  105. package/dist/types/lib/duckdb/duckdbInstance.d.ts +7 -0
  106. package/dist/types/lib/duckdb/fileIdentity.d.ts +9 -0
  107. package/dist/types/lib/duckdb/sql.d.ts +124 -0
  108. package/dist/types/lib/fft.d.ts +15 -0
  109. package/dist/types/lib/folderTree.d.ts +29 -0
  110. package/dist/types/lib/gaugeColors.d.ts +32 -0
  111. package/dist/types/lib/importers/arrowSink.d.ts +35 -0
  112. package/dist/types/lib/importers/blobReader.d.ts +22 -0
  113. package/dist/types/lib/importers/bytes.d.ts +11 -0
  114. package/dist/types/lib/importers/combine.d.ts +30 -0
  115. package/dist/types/lib/importers/comtrade/format.d.ts +2 -0
  116. package/dist/types/lib/importers/comtrade/importer.d.ts +25 -0
  117. package/dist/types/lib/importers/dbc.d.ts +45 -0
  118. package/dist/types/lib/importers/edf/format.d.ts +2 -0
  119. package/dist/types/lib/importers/edf/importer.d.ts +7 -0
  120. package/dist/types/lib/importers/expr.d.ts +10 -0
  121. package/dist/types/lib/importers/formats.d.ts +23 -0
  122. package/dist/types/lib/importers/hdf5/format.d.ts +4 -0
  123. package/dist/types/lib/importers/hdf5/h5.d.ts +76 -0
  124. package/dist/types/lib/importers/hdf5/h5wasmModule.d.ts +1 -0
  125. package/dist/types/lib/importers/hdf5/importer.d.ts +2 -0
  126. package/dist/types/lib/importers/importer.worker.d.ts +5 -0
  127. package/dist/types/lib/importers/importers.d.ts +4 -0
  128. package/dist/types/lib/importers/limits.d.ts +28 -0
  129. package/dist/types/lib/importers/mat/format.d.ts +2 -0
  130. package/dist/types/lib/importers/mat/group.d.ts +19 -0
  131. package/dist/types/lib/importers/mat/importer.d.ts +2 -0
  132. package/dist/types/lib/importers/mat/v5.d.ts +24 -0
  133. package/dist/types/lib/importers/mat/v73.d.ts +13 -0
  134. package/dist/types/lib/importers/mdf/blocks3.d.ts +3 -0
  135. package/dist/types/lib/importers/mdf/blocks4.d.ts +7 -0
  136. package/dist/types/lib/importers/mdf/bus.d.ts +59 -0
  137. package/dist/types/lib/importers/mdf/conversion.d.ts +48 -0
  138. package/dist/types/lib/importers/mdf/decode.d.ts +15 -0
  139. package/dist/types/lib/importers/mdf/format.d.ts +2 -0
  140. package/dist/types/lib/importers/mdf/importer.d.ts +19 -0
  141. package/dist/types/lib/importers/mdf/model.d.ts +75 -0
  142. package/dist/types/lib/importers/mdf/records.d.ts +31 -0
  143. package/dist/types/lib/importers/mdf/stream.d.ts +42 -0
  144. package/dist/types/lib/importers/memorySink.d.ts +11 -0
  145. package/dist/types/lib/importers/names.d.ts +2 -0
  146. package/dist/types/lib/importers/openImport.d.ts +33 -0
  147. package/dist/types/lib/importers/registry.d.ts +24 -0
  148. package/dist/types/lib/importers/run.d.ts +35 -0
  149. package/dist/types/lib/importers/session.d.ts +28 -0
  150. package/dist/types/lib/importers/tdms/format.d.ts +2 -0
  151. package/dist/types/lib/importers/tdms/importer.d.ts +10 -0
  152. package/dist/types/lib/importers/types.d.ts +172 -0
  153. package/dist/types/lib/importers/workerCore.d.ts +44 -0
  154. package/dist/types/lib/importers/xdf/format.d.ts +2 -0
  155. package/dist/types/lib/importers/xdf/importer.d.ts +2 -0
  156. package/dist/types/lib/importers/zlib.d.ts +13 -0
  157. package/dist/types/lib/kde.d.ts +2 -0
  158. package/dist/types/lib/live/buffer.d.ts +265 -0
  159. package/dist/types/lib/live/columnsWire.d.ts +24 -0
  160. package/dist/types/lib/live/crypto.d.ts +157 -0
  161. package/dist/types/lib/live/liveMathChannels.d.ts +11 -0
  162. package/dist/types/lib/live/recorder.d.ts +32 -0
  163. package/dist/types/lib/live/stream.d.ts +33 -0
  164. package/dist/types/lib/live/timeBuckets.d.ts +71 -0
  165. package/dist/types/lib/live/types.d.ts +72 -0
  166. package/dist/types/lib/live/wire.d.ts +25 -0
  167. package/dist/types/lib/mathChannels/compile.d.ts +22 -0
  168. package/dist/types/lib/mathChannels/evaluator.d.ts +40 -0
  169. package/dist/types/lib/mathChannels/functions/conditional.d.ts +2 -0
  170. package/dist/types/lib/mathChannels/functions/filters.d.ts +7 -0
  171. package/dist/types/lib/mathChannels/functions/index.d.ts +3 -0
  172. package/dist/types/lib/mathChannels/functions/reference.d.ts +7 -0
  173. package/dist/types/lib/mathChannels/functions/windowOps.d.ts +11 -0
  174. package/dist/types/lib/mathChannels/index.d.ts +13 -0
  175. package/dist/types/lib/mathChannels/io.d.ts +18 -0
  176. package/dist/types/lib/mathChannels/mathjsSetup.d.ts +7 -0
  177. package/dist/types/lib/mathChannels/parseMath.d.ts +12 -0
  178. package/dist/types/lib/mathChannels/parser.d.ts +22 -0
  179. package/dist/types/lib/mathChannels/types.d.ts +34 -0
  180. package/dist/types/lib/mathChannels/usedChannels.d.ts +14 -0
  181. package/dist/types/lib/moduleWorker.d.ts +7 -0
  182. package/dist/types/lib/panelChartSettings.d.ts +438 -0
  183. package/dist/types/lib/parseDataset.d.ts +74 -0
  184. package/dist/types/lib/parseDataset.worker.d.ts +1 -0
  185. package/dist/types/lib/parseDatasetWorkerClient.d.ts +32 -0
  186. package/dist/types/lib/perfLog.d.ts +4 -0
  187. package/dist/types/lib/quantiles.d.ts +10 -0
  188. package/dist/types/lib/recordings/csvWriter.d.ts +10 -0
  189. package/dist/types/lib/recordings/export.d.ts +26 -0
  190. package/dist/types/lib/recordings/importer.d.ts +2 -0
  191. package/dist/types/lib/recordings/keys.d.ts +23 -0
  192. package/dist/types/lib/recordings/krc.d.ts +38 -0
  193. package/dist/types/lib/recordings/mf4Writer.d.ts +20 -0
  194. package/dist/types/lib/render/chartFonts.d.ts +10 -0
  195. package/dist/types/lib/render/colorBucket.d.ts +6 -0
  196. package/dist/types/lib/render/contours.d.ts +16 -0
  197. package/dist/types/lib/render/cssColor.d.ts +2 -0
  198. package/dist/types/lib/render/frames.d.ts +46 -0
  199. package/dist/types/lib/render/gl3d.d.ts +63 -0
  200. package/dist/types/lib/render/glLines.d.ts +62 -0
  201. package/dist/types/lib/render/glPlot.d.ts +36 -0
  202. package/dist/types/lib/render/glPoints.d.ts +37 -0
  203. package/dist/types/lib/render/glSeries.d.ts +67 -0
  204. package/dist/types/lib/render/heatGrid.d.ts +9 -0
  205. package/dist/types/lib/render/hitGrid.d.ts +16 -0
  206. package/dist/types/lib/render/liveZoomBus.d.ts +18 -0
  207. package/dist/types/lib/render/margins.d.ts +14 -0
  208. package/dist/types/lib/render/offscreenLineRenderer.d.ts +53 -0
  209. package/dist/types/lib/render/offscreenLineWorker.d.ts +1 -0
  210. package/dist/types/lib/render/plotFrame.d.ts +36 -0
  211. package/dist/types/lib/render/resample.d.ts +18 -0
  212. package/dist/types/lib/render/sharedGl.d.ts +38 -0
  213. package/dist/types/lib/render/useGlPlot.d.ts +7 -0
  214. package/dist/types/lib/savedLayout.d.ts +45 -0
  215. package/dist/types/lib/stft.d.ts +37 -0
  216. package/dist/types/lib/workspaces/encrypted.d.ts +50 -0
  217. package/dist/types/lib/workspaces/io.d.ts +120 -0
  218. package/dist/types/lib/xyFit.d.ts +14 -0
  219. package/dist/types/lib/yAxisTicks.d.ts +28 -0
  220. package/dist/types/react/index.d.ts +32 -0
  221. package/dist/types/types/loadedDataset.d.ts +42 -0
  222. package/dist/types/types/plotSeries.d.ts +27 -0
  223. package/package.json +63 -4
@@ -0,0 +1,616 @@
1
+ /*! @kymoscope/sdk (c) 2026 Kymoscope. Proprietary software: use requires a license. See LICENSE.md. */
2
+ import{$ as e,A as t,At as n,B as r,Bt as i,C as a,D as o,Dt as s,E as c,F as l,Ft as u,G as d,H as f,Ht as p,I as m,It as h,J as g,K as _,L as v,Lt as y,M as b,Mt as x,N as S,Nt as C,O as w,Ot as T,P as E,Pt as D,Q as O,R as k,Rt as A,S as j,T as M,U as N,Ut as P,V as F,Vt as I,W as L,Wt as R,X as z,Y as B,Z as V,_ as ee,_t as te,a as H,at as ne,b as re,c as ie,ct as U,d as ae,dt as oe,et as se,f as ce,g as le,gt as ue,h as de,ht as fe,it as pe,j as me,jt as he,k as ge,kt as _e,l as ve,m as ye,mt as be,n as xe,nt as Se,o as Ce,p as we,pt as Te,q as Ee,r as De,rt as Oe,s as ke,st as Ae,t as je,tt as Me,u as Ne,ut as Pe,v as Fe,vt as Ie,w as Le,x as Re,y as ze,yt as Be,z as Ve,zt as He}from"./krc-CbE28CjD.js";import{createContext as Ue,forwardRef as We,memo as Ge,startTransition as Ke,useCallback as qe,useContext as Je,useEffect as W,useImperativeHandle as Ye,useLayoutEffect as G,useMemo as Xe,useRef as K,useState as Ze,useSyncExternalStore as Qe}from"react";import{createPortal as $e}from"react-dom";import{createRoot as et}from"react-dom/client";import{Fragment as tt,jsx as q,jsxs as nt}from"react/jsx-runtime";var rt=Object.create,it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,ot=Object.getOwnPropertyNames,st=Object.getPrototypeOf,ct=Object.prototype.hasOwnProperty,lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ut=(e,t)=>{let n={};for(var r in e)it(n,r,{get:e[r],enumerable:!0});return t||it(n,Symbol.toStringTag,{value:`Module`}),n},dt=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ot(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ct.call(e,s)&&s!==n&&it(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=at(t,s))||r.enumerable});return e},ft=(e,t,n)=>(n=e==null?{}:rt(st(e)),dt(t||!e||!e.__esModule?it(n,`default`,{value:e,enumerable:!0}):n,e)),pt=[`text`,`brush`,`arrow`,`box`],mt={text:14,brush:3,arrow:2,box:2},ht=/^#[0-9a-fA-F]{6}$/,gt={text:[1,1],arrow:[2,2],box:[2,2],brush:[2,1/0]},_t=e=>typeof e==`number`&&Number.isFinite(e);function vt(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(!pt.includes(n)||typeof t.id!=`string`||!t.id||!Array.isArray(t.points))return null;let r=t.points.filter(e=>Array.isArray(e)&&_t(e[0])&&_t(e[1])).map(([e,t])=>[e,t]),[i,a]=gt[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`&&ht.test(t.color)?t.color:`#f5a524`,width:_t(t.width)&&t.width>0?Math.min(96,t.width):mt[n],...typeof t.text==`string`&&t.text!==``?{text:t.text}:{}}}function yt(e){return Array.isArray(e)?e.map(vt).filter(e=>e!==null):null}var bt=96,xt=96,St=2,Ct={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},wt={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},Tt=Ct,Et=wt;function Dt(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 Ot(e,t,n,r=96){let i=Ct[e],a=wt[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 kt(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`?Ot(e,{...t,x:t.x+c,y:t.y+l},o,s):{...t,w:Math.max(Ct[e],Math.min(t.w+c,o-t.x)),h:Math.max(wt[e],Math.min(t.h+l,s-t.y))}}function At(e,t,n){for(let r of t)if(r.id!==n&&Dt(e,r.rect))return!0;return!1}function jt(e,t,n=96){let r=Ct[e],i=wt[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=Ot(e,{x:s,y:i,w:a,h:o},n);if(!At(r,t,``))return r}return Ot(e,{x:0,y:0,w:r,h:i},n)}function Mt(e,t){return{id:crypto.randomUUID(),kind:e,rect:jt(e,t)}}function Nt(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=Nt(e-4).map(e=>({x:e.x*.5,y:e.y,w:e.w*.5,h:e.h})),n=Nt(4).map(e=>({x:.5+e.x*.5,y:e.y,w:e.w*.5,h:e.h}));return[...t,...n]}function Pt(e,t=96,n=96){let r=Nt(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 Ft(){return{scaleMin:``,scaleMax:``,majorStep:``,minorStep:``,alarm:null}}var It={style:`dashed`,width:1,color:null},Lt={style:`solid`,width:1,color:null},Rt={enabled:!1,reference:`previous`,datasetId:null,datasetColor:`#94a3b8`,previousColor:`#64748b`},zt=/^#[0-9a-f]{6}$/i;function Bt(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`&&zt.test(t.datasetColor)?t.datasetColor:Rt.datasetColor,previousColor:typeof t.previousColor==`string`&&zt.test(t.previousColor)?t.previousColor:Rt.previousColor}}var Vt=[`#f5a524`,`#38bdf8`,`#22c55e`,`#f472b6`,`#a78bfa`,`#fb7185`];function Ht(e,t){return{id:crypto.randomUUID(),column:e,color:Vt[t%Vt.length],value:`last`,style:`arc`,min:``,max:``}}function Ut(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(typeof n.column!=`string`)return null;let r=kn(n.alarm);return{id:typeof n.id==`string`&&n.id?n.id:`g${t}`,column:n.column,color:typeof n.color==`string`?n.color:Vt[t%Vt.length],value:n.value===`mean`||n.value===`min`||n.value===`max`?n.value:`last`,style:n.style===`linear`?`linear`:`arc`,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 Wt(e,t){let n=parseFloat(e),r=parseFloat(t);return Number.isFinite(n)&&Number.isFinite(r)&&n<r?[n,r]:void 0}var Gt=1.8,Kt=4,qt=1;function Jt(){return{kind:`multiband`,series:[],addColumn:``,layout:`overlay`,xAxisLine:{...It},yAxisLine:{...It},gridLine:{...Lt},lineWidth:1}}function Yt(e){return{kind:`xyscatter`,xyXCol:``,xyYCol:``,xyColorCol:null,xyColor:e,xyPointRadius:Gt,xyXAxisLine:{...It},xyYAxisLine:{...It},xyGridLine:{...Lt},xyFit:null,xyXScale:Ft(),xyYScale:Ft()}}function Xt(e=4){return{kind:`xyzmesh`,xyzXCol:``,xyzYCol:``,xyzZCol:``,xyzViewMode:`3d`,xyzXScale:Ft(),xyzYScale:Ft(),xyzZScale:Ft(),xyzPointRadius:e,showMesh:!1,meshStyle:`filled`,meshOpacity:.85}}function Zt(){return{kind:`histogram`,histColumn:``,histBins:0,histColor:`#38bdf8`,histNormal:!1,histLogY:!1}}function Qt(){return{kind:`polar`,polarAngleCol:``,polarRadiusCol:``,polarColor:`#a78bfa`,polarMode:`waveform`,polarRadiusMin:``,polarRadiusMax:``}}function $t(){return{kind:`spectrum`,specSignalCol:``,specTimeCol:``,specSampleRate:`1000`,specXMode:`hz`,specYMode:`amplitude`,specWindow:`hann`,specColor:`#34d399`,specLogX:!1}}function en(){return{kind:`boxplot`,boxValueCol:``,boxGroupCol:``,boxColor:`#fb923c`,boxWhiskers:`1.5iqr`}}function tn(){return{kind:`spectrogram`,sgSignalCol:``,sgTimeCol:``,sgSampleRate:`1000`,sgWindowSize:512,sgOverlap:.5,sgWinFunc:`hann`,sgYMode:`db`,sgLogFreq:!1}}function nn(){return{kind:`heatmap`,hmMode:`binned`,hmColumns:[],hmXCol:``,hmYCol:``,hmValueCol:``,hmXBins:6,hmYBins:6,hmXMin:``,hmXMax:``,hmYMin:``,hmYMax:``,hmShowValues:!0,hmColorScheme:`diverging`}}function rn(){return{kind:`violin`,vlValueCol:``,vlGroupCol:``,vlColor:`#818cf8`,vlShowBox:!0,vlBandwidth:``,vlOrientation:`vertical`}}function an(){return{kind:`confusion`,cfActualCol:``,cfPredictedCol:``,cfNormalize:!1}}function on(){return{kind:`roc`,rocScoreCol:``,rocLabelCol:``,rocMode:`roc`,rocColor:`#f472b6`}}function sn(){return{kind:`losscurve`,lcXCol:``,lcLeftCols:[],lcRightCols:[]}}function cn(){return{kind:`controlchart`,ccValueCol:``,ccSubgroupCol:``,ccSigmaLevel:3,ccColor:`#22d3ee`}}function ln(){return{kind:`parallelcoords`,pcColumns:[],pcColorByCol:``,pcColor:`#64748b`}}function un(){return{kind:`embedding`,emXCol:``,emYCol:``,emColorCol:``,emColorMode:`categorical`,emLabelCol:``,emPointSize:3,emColor:`#a78bfa`}}function dn(){return{kind:`flamegraph`,fgNameCol:``,fgParentCol:``,fgValueCol:``,fgDirection:`topdown`}}function fn(){return{kind:`barchart`,bcCategoryCol:``,bcValueCols:[],bcMode:`grouped`,bcHorizontal:!1}}function pn(){return{kind:`radar`,rdAxesCols:[],rdGroupCol:``,rdColor:`#38bdf8`,rdFill:!0}}function mn(){return{kind:`areachart`,acXCol:``,acYCols:[],acStacked:!1}}function hn(){return{kind:`cdfchart`,cdValueCols:[],cdComplement:!1,cdLogX:!1}}function gn(){return{kind:`bubblechart`,bbXCol:``,bbYCol:``,bbSizeCol:``,bbColorCol:``,bbColorMode:`categorical`,bbColor:`#64748b`,bbMaxRadius:24}}function _n(){return{kind:`treemap`,tmNameCol:``,tmParentCol:``,tmValueCol:``}}function vn(){return{kind:`sankey`,skSourceCol:``,skTargetCol:``,skValueCol:``}}function yn(){return{kind:`gauge`,ggGauges:[]}}function bn(){return{kind:`calibration`,cbScoreCol:``,cbLabelCol:``,cbBins:10,cbColor:`#38bdf8`}}function xn(){return{kind:`qqplot`,qqValueCol:``,qqMode:`normal`,qqRefCol:``,qqColor:`#a78bfa`}}function Sn(){return{kind:`gantt`,gtLabelCol:``,gtStartCol:``,gtEndCol:``,gtGroupCol:``}}function Cn(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 wn(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 Tn(e,t){return wn(e)?e:{...t}}function En(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.kind===`multiband`&&Array.isArray(t.series)&&t.series.every(Cn)&&typeof t.addColumn==`string`}function Dn(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 On(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 kn(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}}var An={histogram:`histAlarm`,spectrum:`specAlarm`,areachart:`acAlarm`,losscurve:`lcAlarm`,cdfchart:`cdAlarm`,bubblechart:`bbAlarm`,boxplot:`boxAlarm`,violin:`vlAlarm`,barchart:`bcAlarm`,gantt:`gtAlarm`};function jn(e){if(!e||!(e.kind in An))return null;let t=e[An[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 Mn(e){let t=Ft();if(!e||typeof e!=`object`)return t;let n=e,r=kn(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 Nn(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(En(n)){let e=n;r[t]={kind:`multiband`,series:e.series,addColumn:e.addColumn,layout:e.layout===`parallel`?`parallel`:`overlay`,xAxisLine:Tn(e.xAxisLine,It),yAxisLine:Tn(e.yAxisLine,It),gridLine:Tn(e.gridLine,Lt),lineWidth:typeof e.lineWidth==`number`&&Number.isFinite(e.lineWidth)?Math.min(6,Math.max(.5,e.lineWidth)):1,...Bt(e.beacon)?{beacon:Bt(e.beacon)}:{},...e.envelope===!0?{envelope:!0}:{}}}else if(Dn(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:Tn(e.xyXAxisLine,It),xyYAxisLine:Tn(e.xyYAxisLine,It),xyGridLine:Tn(e.xyGridLine,Lt),xyFit:a,xyXScale:Mn(e.xyXScale),xyYScale:Mn(e.xyYScale)}}else if(On(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??Mn(n.xyzXScale),xyzYScale:a??Mn(n.xyzYScale),xyzZScale:o??Mn(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=Ut(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:``}}let e=r[t]?yt(n?.annotations):null;e?.length&&(r[t]={...r[t],annotations:e});let i=r[t]?An[r[t].kind]:void 0,a=i?kn(n[i]):null;i&&a&&(r[t]={...r[t],[i]:a})}return r}function Pn(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]=Jt(),a=!0)}else if(t.kind===`xyscatter`){let e=i[t.id];(!e||e.kind!==`xyscatter`)&&(i[t.id]=Yt(n),a=!0)}else if(t.kind===`xyzmesh`){let e=i[t.id];(!e||e.kind!==`xyzmesh`)&&(i[t.id]=Xt(r),a=!0)}else if(t.kind===`histogram`){let e=i[t.id];(!e||e.kind!==`histogram`)&&(i[t.id]=Zt(),a=!0)}else if(t.kind===`polar`){let e=i[t.id];(!e||e.kind!==`polar`)&&(i[t.id]=Qt(),a=!0)}else if(t.kind===`spectrum`){let e=i[t.id];(!e||e.kind!==`spectrum`)&&(i[t.id]=$t(),a=!0)}else if(t.kind===`boxplot`){let e=i[t.id];(!e||e.kind!==`boxplot`)&&(i[t.id]=en(),a=!0)}else t.kind===`spectrogram`?(!i[t.id]||i[t.id].kind!==`spectrogram`)&&(i[t.id]=tn(),a=!0):t.kind===`heatmap`?(!i[t.id]||i[t.id].kind!==`heatmap`)&&(i[t.id]=nn(),a=!0):t.kind===`violin`?(!i[t.id]||i[t.id].kind!==`violin`)&&(i[t.id]=rn(),a=!0):t.kind===`confusion`?(!i[t.id]||i[t.id].kind!==`confusion`)&&(i[t.id]=an(),a=!0):t.kind===`roc`?(!i[t.id]||i[t.id].kind!==`roc`)&&(i[t.id]=on(),a=!0):t.kind===`losscurve`?(!i[t.id]||i[t.id].kind!==`losscurve`)&&(i[t.id]=sn(),a=!0):t.kind===`controlchart`?(!i[t.id]||i[t.id].kind!==`controlchart`)&&(i[t.id]=cn(),a=!0):t.kind===`parallelcoords`?(!i[t.id]||i[t.id].kind!==`parallelcoords`)&&(i[t.id]=ln(),a=!0):t.kind===`embedding`?(!i[t.id]||i[t.id].kind!==`embedding`)&&(i[t.id]=un(),a=!0):t.kind===`flamegraph`?(!i[t.id]||i[t.id].kind!==`flamegraph`)&&(i[t.id]=dn(),a=!0):t.kind===`barchart`?(!i[t.id]||i[t.id].kind!==`barchart`)&&(i[t.id]=fn(),a=!0):t.kind===`radar`?(!i[t.id]||i[t.id].kind!==`radar`)&&(i[t.id]=pn(),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]=hn(),a=!0):t.kind===`bubblechart`?(!i[t.id]||i[t.id].kind!==`bubblechart`)&&(i[t.id]=gn(),a=!0):t.kind===`treemap`?(!i[t.id]||i[t.id].kind!==`treemap`)&&(i[t.id]=_n(),a=!0):t.kind===`sankey`?(!i[t.id]||i[t.id].kind!==`sankey`)&&(i[t.id]=vn(),a=!0):t.kind===`gauge`?(!i[t.id]||i[t.id].kind!==`gauge`)&&(i[t.id]=yn(),a=!0):t.kind===`calibration`?(!i[t.id]||i[t.id].kind!==`calibration`)&&(i[t.id]=bn(),a=!0):t.kind===`qqplot`?(!i[t.id]||i[t.id].kind!==`qqplot`)&&(i[t.id]=xn(),a=!0):t.kind===`gantt`&&(!i[t.id]||i[t.id].kind!==`gantt`)&&(i[t.id]=Sn(),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 Fn(e){return Number.isNaN(e)?0:Math.min(100,Math.max(0,e))}function In(){return crypto.randomUUID()}function Ln(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 Rn(){return Rn=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},Rn.apply(null,arguments)}var zn={relTol:1e-12,absTol:1e-15,matrix:`Matrix`,number:`number`,numberFallback:`number`,precision:64,predictable:!1,randomSeed:null,legacySubset:!1};function Bn(e,t){if(Hn(e,t)||Un(e,t))return e[t];throw Kn(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 Vn(e,t,n){if(Hn(e,t)||Un(e,t))return e[t]=n,n;throw Error(`No access to property "${t}"`)}function Hn(e,t){return qn(e)?!(t in Object.prototype):!1}function Un(e,t){return Array.isArray(e)?typeof t==`number`||typeof t==`string`&&Wn(t)||t===`length`:!1}function Wn(e){return/^\d+$/.test(e)}function Gn(e,t){if(!Kn(e,t))throw Error(`No access to method "`+t+`"`);return e[t]}function Kn(e,t){return e==null||typeof e[t]!=`function`||ei(e,t)&&Object.getPrototypeOf&&t in Object.getPrototypeOf(e)?!1:Jn.has(t)?!0:!(t in Object.prototype||t in Function.prototype)}function qn(e){return typeof e==`object`&&e&&e.constructor===Object}var Jn=new Set([`toString`,`valueOf`,`toLocaleString`]),Yn=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 Bn(this.wrappedObject,e)}set(e,t){return Vn(this.wrappedObject,e,t),this}has(e){return Hn(this.wrappedObject,e)&&e in this.wrappedObject}entries(){return Zn(this.keys(),e=>[e,this.get(e)])}forEach(e){for(var t of this.keys())e(this.get(t),t,this)}delete(e){Hn(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}},Xn=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 Zn(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 Zn(e,t){return{next:()=>{var n=e.next();return n.done?n:{value:t(n.value),done:!1}}}}function Qn(){return new Map}function $n(e){if(!e)return Qn();if(Sr(e))return e;if(xr(e))return new Yn(e);throw Error(`createMap can create maps from objects or Maps`)}function er(e){if(e instanceof Yn)return e.wrappedObject;var t={};for(var n of e.keys())Vn(t,n,e.get(n));return t}function tr(e){return typeof e==`number`}function nr(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 rr(e){return typeof e==`bigint`}function ir(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 or(e){return e&&e.constructor.prototype.isUnit===!0||!1}function sr(e){return typeof e==`string`}var cr=Array.isArray;function lr(e){return e&&e.constructor.prototype.isMatrix===!0||!1}function ur(e){return Array.isArray(e)||lr(e)}function dr(e){return e&&e.isDenseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function fr(e){return e&&e.isSparseMatrix&&e.constructor.prototype.isMatrix===!0||!1}function pr(e){return e&&e.constructor.prototype.isRange===!0||!1}function mr(e){return e&&e.constructor.prototype.isIndex===!0||!1}function hr(e){return typeof e==`boolean`}function gr(e){return e&&e.constructor.prototype.isResultSet===!0||!1}function _r(e){return e&&e.constructor.prototype.isHelp===!0||!1}function vr(e){return typeof e==`function`}function yr(e){return e instanceof Date}function br(e){return e instanceof RegExp}function xr(e){return!!(e&&typeof e==`object`&&e.constructor===Object&&!ir(e)&&!ar(e))}function Sr(e){return e?e instanceof Map||e instanceof Yn||typeof e.set==`function`&&typeof e.get==`function`&&typeof e.keys==`function`&&typeof e.has==`function`:!1}function Cr(e){return Sr(e)&&Sr(e.a)&&Sr(e.b)}function wr(e){return Sr(e)&&xr(e.wrappedObject)}function Tr(e){return e===null}function Er(e){return e===void 0}function Dr(e){return e&&e.isAccessorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Or(e){return e&&e.isArrayNode===!0&&e.constructor.prototype.isNode===!0||!1}function kr(e){return e&&e.isAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ar(e){return e&&e.isBlockNode===!0&&e.constructor.prototype.isNode===!0||!1}function jr(e){return e&&e.isConditionalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Mr(e){return e&&e.isConstantNode===!0&&e.constructor.prototype.isNode===!0||!1}function Nr(e){return Mr(e)||zr(e)&&e.args.length===1&&Mr(e.args[0])&&`-+~`.includes(e.op)}function Pr(e){return e&&e.isFunctionAssignmentNode===!0&&e.constructor.prototype.isNode===!0||!1}function Fr(e){return e&&e.isFunctionNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ir(e){return e&&e.isIndexNode===!0&&e.constructor.prototype.isNode===!0||!1}function Lr(e){return e&&e.isNode===!0&&e.constructor.prototype.isNode===!0||!1}function Rr(e){return e&&e.isObjectNode===!0&&e.constructor.prototype.isNode===!0||!1}function zr(e){return e&&e.isOperatorNode===!0&&e.constructor.prototype.isNode===!0||!1}function Br(e){return e&&e.isParenthesisNode===!0&&e.constructor.prototype.isNode===!0||!1}function Vr(e){return e&&e.isRangeNode===!0&&e.constructor.prototype.isNode===!0||!1}function Hr(e){return e&&e.isRelationalNode===!0&&e.constructor.prototype.isNode===!0||!1}function Ur(e){return e&&e.isSymbolNode===!0&&e.constructor.prototype.isNode===!0||!1}function Wr(e){return e&&e.constructor.prototype.isChain===!0||!1}function Gr(e){var t=typeof e;return t===`object`?e===null?`null`:nr(e)?`BigNumber`:e.constructor&&e.constructor.name?e.constructor.name:`Object`:t}function Kr(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 Kr(e)});if(e instanceof Date)return new Date(e.valueOf());if(nr(e))return e;if(xr(e))return qr(e,Kr);if(t===`function`)return e;throw TypeError(`Cannot clone: unknown type of value (value: ${e})`)}function qr(e,t){var n={};for(var r in e)ei(e,r)&&(n[r]=t(e[r]));return n}function Jr(e,t){for(var n in t)ei(t,n)&&(e[n]=t[n]);return e}function Yr(e,t){if(Array.isArray(t))throw TypeError(`Arrays are not supported by deepExtend`);for(var n in t)if(ei(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?Yr(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 Xr(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(!Xr(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)||!Xr(e[n],t[n]))return!1;for(n in t)if(!(n in e))return!1;return!0}else return e===t}function Zr(e){var t={};return Qr(e,t),t}function Qr(e,t){for(var n in e)if(ei(e,n)){var r=e[n];typeof r==`object`&&r?Qr(r,t):t[n]=r}}function $r(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 ei(e,t){return e&&Object.hasOwnProperty.call(e,t)}function ti(e){return e&&typeof e.factory==`function`}function ni(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 ri=[`Matrix`,`Array`],ii=[`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=Kr(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=Kr(e);oi(r,`matrix`,ri),oi(r,`number`,ii),Yr(e,r);var o=Kr(e);return t(`config`,o,a,Kr(r)),o}else return Kr(e)}return n.MATRIX_OPTIONS=ri,n.NUMBER_OPTIONS=ii,Object.keys(zn).forEach(t=>{Object.defineProperty(n,t,{get:()=>e[t],enumerable:!0,configurable:!0})}),n}function oi(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 si=lt(((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=ni(r,t.map(di));return li(e,t,r),n(i)}return i.isFactory=!0,i.fn=e,i.dependencies=t.slice().sort(),r&&(i.meta=r),i}function ci(e){return typeof e==`function`&&typeof e.fn==`string`&&Array.isArray(e.dependencies)}function li(e,t,n){if(!t.filter(e=>!ui(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 ui(e){return e&&e[0]===`?`}function di(e){return e&&e[0]===`?`?e.slice(1):e}function fi(e){return typeof e==`boolean`?!0:Number.isFinite(e)?e===Math.round(e):!1}function pi(e,t){if(t.number===`bigint`)try{BigInt(e)}catch{return t.numberFallback}return t.number}var mi=Math.sign||function(e){return e>0?1:e<0?-1:0},hi=Math.log2||function(e){return Math.log(e)/Math.LN2},gi=Math.log10||function(e){return Math.log(e)/Math.LN10},_i=Math.log1p||function(e){return Math.log(e+1)},vi=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},yi=Math.expm1||function(e){return e>=2e-4||e<=-2e-4?Math.exp(e)-1:e+e*e/2+e*e*e/6};function bi(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(!fi(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(!fi(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 xi(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}=Si(t);switch(n){case`fixed`:return Ti(e,r);case`exponential`:return Ei(e,r);case`engineering`:return wi(e,r);case`bin`:return bi(e,2,i);case`oct`:return bi(e,8,i);case`hex`:return bi(e,16,i);case`auto`:return Di(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 Si(e){var t=`auto`,n,r;if(e!==void 0)if(tr(e))n=e;else if(nr(e))n=e.toNumber();else if(xr(e))e.precision!==void 0&&(n=zi(e.precision,()=>{throw Error(`Option "precision" must be a number or BigNumber`)})),e.wordSize!==void 0&&(r=zi(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 Ci(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 wi(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Oi(Ci(e),t),r=n.exponent,i=n.coefficients,a=r%3==0?r:r<0?r-3-r%3:r-r%3;if(tr(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=tr(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 Ti(e,t){if(isNaN(e)||!Number.isFinite(e))return String(e);var n=Ci(e),r=typeof t==`number`?Oi(n,n.exponent+1+t):n,i=r.coefficients,a=r.exponent+1,o=a+(t||0);return i.length<o&&(i=i.concat(ki(o-i.length))),a<0&&(i=ki(-a+1).concat(i),a=1),a<i.length&&i.splice(a,0,a===0?`0.`:`.`),r.sign+i.join(``)}function Ei(e,t){if(isNaN(e)||!Number.isFinite(Number(e)))return String(e);var n=Ci(e),r=t?Oi(n,t):n,i=r.coefficients,a=r.exponent;i.length<t&&(i=i.concat(ki(t-i.length)));var o=i.shift();return r.sign+o+(i.length>0?`.`+i.join(``):``)+`e`+(a>=0?`+`:``)+a}function Di(e,t,n){if(isNaN(e)||!Number.isFinite(e))return String(e);var r=Bi(n?.lowerExp,-3),i=Bi(n?.upperExp,5),a=Ci(e),o=t?Oi(a,t):a;if(o.exponent<r||o.exponent>=i)return Ei(e,t);var s=o.coefficients,c=o.exponent;s.length<t&&(s=s.concat(ki(t-s.length))),s=s.concat(ki(c-s.length+1+(s.length<t?t-s.length:0))),s=ki(-c).concat(s);var l=c>0?c:0;return l<s.length-1&&s.splice(l+1,0,`.`),o.sign+s.join(``)}function Oi(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 ki(e){for(var t=[],n=0;n<e;n++)t.push(0);return t}function Ai(e){return e.toExponential().replace(/e.*$/,``).replace(/^0\.?0*|\./,``).length}function ji(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 Mi=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)},Ni=Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Pi=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2},Fi=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2},Ii=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2},Li=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};function Ri(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 zi(e,t){if(tr(e))return e;if(nr(e))return e.toNumber();t()}function Bi(e,t){return tr(e)?e:nr(e)?e.toNumber():t}var Vi=ft(si(),1),Hi=function(){return Hi=Vi.default.create,Vi.default},Ui=J(`typed`,[`?BigNumber`,`?Complex`,`?DenseMatrix`,`?Fraction`],function(e){var{BigNumber:t,Complex:n,DenseMatrix:r,Fraction:i}=e,a=Hi();return a.clear(),a.addTypes([{name:`number`,test:tr},{name:`Complex`,test:ir},{name:`BigNumber`,test:nr},{name:`bigint`,test:rr},{name:`Fraction`,test:ar},{name:`Unit`,test:or},{name:`identifier`,test:e=>sr&&/^(?:[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:sr},{name:`Chain`,test:Wr},{name:`Array`,test:cr},{name:`Matrix`,test:lr},{name:`DenseMatrix`,test:dr},{name:`SparseMatrix`,test:fr},{name:`Range`,test:pr},{name:`Index`,test:mr},{name:`boolean`,test:hr},{name:`ResultSet`,test:gr},{name:`Help`,test:_r},{name:`function`,test:vr},{name:`Date`,test:yr},{name:`RegExp`,test:br},{name:`null`,test:Tr},{name:`undefined`,test:Er},{name:`AccessorNode`,test:Dr},{name:`ArrayNode`,test:Or},{name:`AssignmentNode`,test:kr},{name:`BlockNode`,test:Ar},{name:`ConditionalNode`,test:jr},{name:`ConstantNode`,test:Mr},{name:`FunctionNode`,test:Fr},{name:`FunctionAssignmentNode`,test:Pr},{name:`IndexNode`,test:Ir},{name:`Node`,test:Lr},{name:`ObjectNode`,test:Rr},{name:`OperatorNode`,test:zr},{name:`ParenthesisNode`,test:Br},{name:`RangeNode`,test:Vr},{name:`RelationalNode`,test:Hr},{name:`SymbolNode`,test:Ur},{name:`Map`,test:Sr},{name:`Object`,test:xr}]),a.addConversions([{from:`number`,to:`BigNumber`,convert:function(e){if(t||Wi(e),Ai(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||Gi(e),new n(e,0)}},{from:`BigNumber`,to:`Complex`,convert:function(e){return n||Gi(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||Wi(e),new t(e.toString())}},{from:`bigint`,to:`Fraction`,convert:function(e){return i||qi(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||Gi(e),new n(e.valueOf(),0)}},{from:`number`,to:`Fraction`,convert:function(e){i||qi(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||Wi(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||qi(e);try{return new i(e)}catch{throw Error(`Cannot convert "`+e+`" to Fraction`)}}},{from:`string`,to:`Complex`,convert:function(e){n||Gi(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||Wi(e),new t(+e)}},{from:`boolean`,to:`bigint`,convert:function(e){return BigInt(+e)}},{from:`boolean`,to:`Fraction`,convert:function(e){return i||qi(e),new i(+e)}},{from:`boolean`,to:`string`,convert:function(e){return String(e)}},{from:`Array`,to:`Matrix`,convert:function(e){return r||Ki(),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&&ur(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&&ur(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 Wi(e){throw Error(`Cannot convert value ${e} into a BigNumber: no class 'BigNumber' provided`)}function Gi(e){throw Error(`Cannot convert value ${e} into a Complex number: no class 'Complex' provided`)}function Ki(){throw Error(`Cannot convert array into a Matrix: no class 'DenseMatrix' provided`)}function qi(e){throw Error(`Cannot convert value ${e} into a Fraction, no class 'Fraction' provided.`)}var Ji=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}),Yi=9e15,Xi=1e9,Zi=`0123456789abcdef`,Qi=`2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058`,$i=`3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789`,ea={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Yi,maxE:Yi,crypto:!1},ta,na,ra=!0,ia=`[DecimalError] `,aa=ia+`Invalid argument: `,oa=ia+`Precision limit exceeded`,sa=ia+`crypto unavailable`,ca=`[object Decimal]`,la=Math.floor,ua=Math.pow,da=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,fa=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,pa=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ma=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ha=1e7,ga=7,_a=9007199254740991,va=Qi.length-1,ya=$i.length-1,Y={toStringTag:ca};Y.absoluteValue=Y.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),Ea(e)},Y.ceil=function(){return Ea(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())+ga,r.rounding=1,n=wa(r,Wa(r,n)),r.precision=e,r.rounding=t,Ea(na==2||na==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(ra=!1,a=u.s*ua(u.s*u,1/3),!a||Math.abs(a)==1/0?(n=ba(u.d),e=u.e,(a=(e-n.length+1)%3)&&(n+=a==1||a==-2?`0`:`00`),a=ua(n,1/3),e=la((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=Ta(l.plus(u).times(s),l.plus(c),o+2,1),ba(s.d).slice(0,o)===(n=ba(r.d)).slice(0,o))if(n=n.slice(o-3,o+1),n==`9999`||!i&&n==`4999`){if(!i&&(Ea(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`)&&(Ea(r,e+1,1),t=!r.times(r).times(r).eq(u));break}return ra=!0,Ea(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-la(this.e/ga))*ga,e=t[e],e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},Y.dividedBy=Y.div=function(e){return Ta(this,new this.constructor(e))},Y.dividedToIntegerBy=Y.divToInt=function(e){var t=this,n=t.constructor;return Ea(Ta(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 Ea(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/Ua(4,e)).toString()):(e=16,t=`2.3283064365386962890625e-10`),a=Ha(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 Ea(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=Ha(a,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(1/Ua(5,e)),i=Ha(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,Ea(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,Ta(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()?Aa(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()?Aa(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,ra=!1,n=n.times(n).minus(1).sqrt().plus(n),ra=!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,ra=!1,n=n.times(n).plus(1).sqrt().plus(n),ra=!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?Ea(new a(i),e,t,!0):(a.precision=n=r-i.e,i=Ta(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=Aa(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<=ya)return o=Aa(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<=ya)return o=Aa(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/ga+2|0),e=n;e;--e)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(ra=!1,t=Math.ceil(s/ga),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)),ra=!0,Ea(o,u.precision=d,u.rounding=f,!0)},Y.isFinite=function(){return!!this.d},Y.isInteger=Y.isInt=function(){return!!this.d&&la(this.e/ga)>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(ra=!1,s=d+p,o=La(l,s),r=t?ka(u,s+10):La(e,s),c=Ta(o,r,s,1),Sa(c.d,i=d,f))do if(s+=10,o=La(l,s),r=t?ka(u,s+10):La(e,s),c=Ta(o,r,s,1),!a){+ba(c.d).slice(i+1,i+15)+1==0x5af3107a4000&&(c=Ea(c,d+1,0));break}while(Sa(c.d,i+=10,f));return ra=!0,Ea(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 ra?Ea(e,s,c):e}if(n=la(e.e/ga),u=la(p.e/ga),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/ga),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]=ha-1;--l[i],l[r]+=ha}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=Oa(l,n),ra?Ea(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]?Ea(new r(n),r.precision,r.rounding):(ra=!1,r.modulo==9?(t=Ta(n,e.abs(),0,3,1),t.s*=e.s):t=Ta(n,e,0,r.modulo,1),t=t.times(e),ra=!0,n.minus(t))},Y.naturalExponential=Y.exp=function(){return Ia(this)},Y.naturalLogarithm=Y.ln=function(){return La(this)},Y.negated=Y.neg=function(){var e=new this.constructor(this);return e.s=-e.s,Ea(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)),ra?Ea(e,s,c):e;if(a=la(d.e/ga),r=la(e.e/ga),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/ga),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)/ha|0,l[i]%=ha;for(t&&(l.unshift(t),++r),o=l.length;l[--o]==0;)l.pop();return e.d=l,e.e=Oa(l,r),ra?Ea(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=ja(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},Y.round=function(){var e=this,t=e.constructor;return Ea(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())+ga,r.rounding=1,n=Va(r,Wa(r,n)),r.precision=e,r.rounding=t,Ea(na>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(ra=!1,l=Math.sqrt(+o),l==0||l==1/0?(t=ba(s),(t.length+c)%2==0&&(t+=`0`),l=Math.sqrt(t),c=la((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(Ta(o,a,n+2,1)).times(.5),ba(a.d).slice(0,n)===(t=ba(r.d)).slice(0,n))if(t=t.slice(n-3,n+1),t==`9999`||!i&&t==`4999`){if(!i&&(Ea(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`)&&(Ea(r,c+1,1),e=!r.times(r).eq(o));break}return ra=!0,Ea(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=Ta(n,new r(1).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,Ea(na==2||na==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=la(u.e/ga)+la(e.e/ga),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%ha|0,t=s/ha|0;a[i]=(a[i]+t)%ha|0}for(;!a[--o];)a.pop();return t?++n:a.shift(),e.d=a,e.e=Oa(a,n),ra?Ea(e,d.precision,d.rounding):e},Y.toBinary=function(e,t){return Ga(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:(xa(e,0,Xi),t===void 0?t=r.rounding:xa(t,0,8),Ea(n,e+n.e+1,t))},Y.toExponential=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Da(r,!0):(xa(e,0,Xi),t===void 0?t=i.rounding:xa(t,0,8),r=Ea(new i(r),e+1,t),n=Da(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=Da(i):(xa(e,0,Xi),t===void 0?t=a.rounding:xa(t,0,8),r=Ea(new a(i),e+i.e+1,t),n=Da(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=ja(m)-p.e-1,o=a%ga,t.d[0]=ua(10,o<0?ga+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(ra=!1,s=new h(ba(m)),u=h.precision,h.precision=a=m.length*ga*2;d=Ta(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=Ta(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=Ta(l,r,a,1).minus(p).abs().cmp(Ta(c,n,a,1).minus(p).abs())<1?[l,r]:[c,n],h.precision=u,ra=!0,f},Y.toHexadecimal=Y.toHex=function(e,t){return Ga(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:xa(t,0,8),!n.d)return e.s?n:e;if(!e.d)return e.s&&=n.s,e}return e.d[0]?(ra=!1,n=Ta(n,e,0,t,1).times(e),ra=!0,Ea(n)):(e.s=n.s,n=e),n},Y.toNumber=function(){return+this},Y.toOctal=function(e,t){return Ga(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(ua(+s,l));if(s=new c(s),s.eq(1))return s;if(r=c.precision,a=c.rounding,e.eq(1))return Ea(s,r,a);if(t=la(e.e/ga),t>=e.d.length-1&&(n=l<0?-l:l)<=_a)return i=Na(c,s,n,r),e.s<0?new c(1).div(i):Ea(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=ua(+s,l),t=n==0||!isFinite(n)?la(l*(Math.log(`0.`+ba(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):(ra=!1,c.rounding=s.s=1,n=Math.min(12,(t+``).length),i=Ia(e.times(La(s,r+n)),r),i.d&&(i=Ea(i,r+5,1),Sa(i.d,r,a)&&(t=r+10,i=Ea(Ia(e.times(La(s,t+n)),t),t+5,1),+ba(i.d).slice(r+1,r+15)+1==0x5af3107a4000&&(i=Ea(i,r+1,0)))),i.s=o,ra=!0,c.rounding=a,Ea(i,r,a))},Y.toPrecision=function(e,t){var n,r=this,i=r.constructor;return e===void 0?n=Da(r,r.e<=i.toExpNeg||r.e>=i.toExpPos):(xa(e,1,Xi),t===void 0?t=i.rounding:xa(t,0,8),r=Ea(new i(r),e,t),n=Da(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):(xa(e,1,Xi),t===void 0?t=r.rounding:xa(t,0,8)),Ea(new r(n),e,t)},Y.toString=function(){var e=this,t=e.constructor,n=Da(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?`-`+n:n},Y.truncated=Y.trunc=function(){return Ea(new this.constructor(this),this.e+1,1)},Y.valueOf=Y.toJSON=function(){var e=this,t=e.constructor,n=Da(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?`-`+n:n};function ba(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=ga-r.length,n&&(a+=Ma(n)),a+=r;o=e[t],r=o+``,n=ga-r.length,n&&(a+=Ma(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}function xa(e,t,n){if(e!==~~e||e<t||e>n)throw Error(aa+e)}function Sa(e,t,n,r){var i,a,o,s;for(a=e[0];a>=10;a/=10)--t;return--t<0?(t+=ga,i=0):(i=Math.ceil((t+1)/ga),t%=ga),a=ua(10,ga-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)==ua(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)==ua(10,t-3)-1,o}function Ca(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]+=Zi.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 wa(e,t){var n,r,i;if(t.isZero())return t;r=t.d.length,r<32?(n=Math.ceil(r/3),i=(1/Ua(4,n)).toString()):(n=16,i=`2.3283064365386962890625e-10`),e.precision+=n,t=Ha(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 Ta=(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=ha,p=ga,u=la(r.e/p)-la(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,ta=m;else{for(d=1,f=v[0];f>=10;f/=10)d++;_.e=d+u*p-1,Ea(_,s?a+_.e+1:a,o,m)}return _}})();function Ea(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+=ga,o=t,u=d[f=0],c=u/ua(10,i-o-1)%10|0;else if(f=Math.ceil((a+1)/ga),s=d.length,f>=s)if(r){for(;s++<=f;)d.push(0);u=c=0,i=1,a%=ga,o=a-ga+1}else break out;else{for(u=s=d[f],i=1;s>=10;s/=10)i++;a%=ga,o=a-ga+i,c=o<0?0:u/ua(10,i-o-1)%10|0}if(r=r||t<0||d[f+1]!==void 0||(o<0?u:u%ua(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/ua(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]=ua(10,(ga-t%ga)%ga),e.e=-t||0):d[0]=e.e=0,e;if(a==0?(d.length=f,s=1,f--):(d.length=f+1,s=ua(10,ga-a),d[f]=o>0?(u/ua(10,i-o)%ua(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]==ha&&(d[0]=1));break}else{if(d[f]+=s,d[f]!=ha)break;d[f--]=0,s=1}for(a=d.length;d[--a]===0;)d.pop()}return ra&&(e.e>p.maxE?(e.d=null,e.e=NaN):e.e<p.minE&&(e.e=0,e.d=[0])),e}function Da(e,t,n){if(!e.isFinite())return Ra(e);var r,i=e.e,a=ba(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+Ma(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(e.e<0?`e`:`e+`)+e.e):i<0?(a=`0.`+Ma(-i-1)+a,n&&(r=n-o)>0&&(a+=Ma(r))):i>=o?(a+=Ma(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+Ma(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=Ma(r))),a}function Oa(e,t){var n=e[0];for(t*=ga;n>=10;n/=10)t++;return t}function ka(e,t,n){if(t>va)throw ra=!0,n&&(e.precision=n),Error(oa);return Ea(new e(Qi),t,1,!0)}function Aa(e,t,n){if(t>ya)throw Error(oa);return Ea(new e($i),t,n,!0)}function ja(e){var t=e.length-1,n=t*ga+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 Ma(e){for(var t=``;e--;)t+=`0`;return t}function Na(e,t,n,r){var i,a=new e(1),o=Math.ceil(r/ga+4);for(ra=!1;;){if(n%2&&(a=a.times(t),Ka(a.d,o)&&(i=!0)),n=la(n/2),n===0){n=a.d.length-1,i&&a.d[n]===0&&++a.d[n];break}t=t.times(t),Ka(t.d,o)}return ra=!0,a}function Pa(e){return e.d[e.d.length-1]&1}function Fa(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 Ia(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?(ra=!1,c=m):c=t,s=new f(.03125);e.e>-2;)e=e.times(s),d+=5;for(r=Math.log(ua(2,d))/Math.LN10*2+5|0,c+=r,n=a=o=new f(1),f.precision=c;;){if(a=Ea(a.times(e),c,1),n=n.times(++u),s=o.plus(Ta(a,n,c,1)),ba(s.d).slice(0,c)===ba(o.d).slice(0,c)){for(i=d;i--;)o=Ea(o.times(o),c,1);if(t==null)if(l<3&&Sa(o.d,c-r,p,l))f.precision=c+=10,n=a=s=new f(1),u=0,l++;else return Ea(o,f.precision=m,p,ra=!0);else return f.precision=m,o}o=s}}function La(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?(ra=!1,u=y):u=t,_.precision=u+=m,n=ba(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=ba(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=ka(_,u+2,y).times(a+``),h=La(new _(r+`.`+n.slice(1)),u-m).plus(l),_.precision=y,t==null?Ea(h,y,v,ra=!0):h;for(d=h,c=o=h=Ta(h.minus(1),h.plus(1),u,1),f=Ea(h.times(h),u,1),i=3;;){if(o=Ea(o.times(f),u,1),l=c.plus(Ta(o,new _(i),u,1)),ba(l.d).slice(0,u)===ba(c.d).slice(0,u))if(c=c.times(2),a!==0&&(c=c.plus(ka(_,u+2,y).times(a+``))),c=Ta(c,new _(p),u,1),t==null)if(Sa(c.d,u-m,v,s))_.precision=u+=m,l=o=h=Ta(d.minus(1),d.plus(1),u,1),f=Ea(h.times(h),u,1),i=s=1;else return Ea(c,_.precision=y,v,ra=!0);else return _.precision=y,c;c=l,i+=2}}function Ra(e){return String(e.s*e.s/0)}function za(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)%ga,n<0&&(r+=ga),r<i){for(r&&e.d.push(+t.slice(0,r)),i-=ga;r<i;)e.d.push(+t.slice(r,r+=ga));t=t.slice(r),r=ga-t.length}else r-=i;for(;r--;)t+=`0`;e.d.push(+t),ra&&(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 Ba(e,t){var n,r,i,a,o,s,c,l,u;if(t.indexOf(`_`)>-1){if(t=t.replace(/(\d)_(?=\d)/g,`$1`),ma.test(t))return za(e,t)}else if(t===`Infinity`||t===`NaN`)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(fa.test(t))n=16,t=t.toLowerCase();else if(da.test(t))n=2;else if(pa.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=Na(r,new r(n),a,a*2)),l=Ca(t,n,ha),u=l.length-1,a=u;l[a]===0;--a)l.pop();return a<0?new r(e.s*0):(e.e=Oa(l,u),e.d=l,ra=!1,o&&(e=Ta(e,i,s*4)),c&&(e=e.times(Math.abs(c)<54?ua(2,c):Fo.pow(2,c))),ra=!0,e)}function Va(e,t){var n,r=t.d.length;if(r<3)return t.isZero()?t:Ha(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(1/Ua(5,n)),t=Ha(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 Ha(e,t,n,r,i){var a,o,s,c,l=1,u=e.precision,d=Math.ceil(u/ga);for(ra=!1,c=n.times(n),s=new e(r);;){if(o=Ta(s.times(c),new e(t++*t++),u,1),s=i?r.plus(o):r.minus(o),r=Ta(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 ra=!0,o.d.length=d+1,o}function Ua(e,t){for(var n=e;--t;)n*=e;return n}function Wa(e,t){var n,r=t.s<0,i=Aa(e,e.precision,1),a=i.times(.5);if(t=t.abs(),t.lte(a))return na=r?4:1,t;if(n=t.divToInt(i),n.isZero())na=r?3:2;else{if(t=t.minus(n.times(i)),t.lte(a))return na=Pa(n)?r?2:3:r?4:1,t;na=Pa(n)?r?1:4:r?3:2}return t.minus(i).abs()}function Ga(e,t,n,r){var i,a,o,s,c,l,u,d,f,p=e.constructor,m=n!==void 0;if(m?(xa(n,1,Xi),r===void 0?r=p.rounding:xa(r,0,8)):(n=p.precision,r=p.rounding),!e.isFinite())u=Ra(e);else{for(u=Da(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=Ca(Da(f),10,i),f.e=f.d.length),d=Ca(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=Ta(e,f,n,r,0,i),d=e.d,a=e.e,l=ta),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+=Zi.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=Ca(u,i,t),c=d.length;!d[c-1];--c);for(o=1,u=`1.`;o<c;o++)u+=Zi.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 Ka(e,t){if(e.length>t)return e.length=t,!0}function qa(e){return new this(e).abs()}function Ja(e){return new this(e).acos()}function Ya(e){return new this(e).acosh()}function Xa(e,t){return new this(e).plus(t)}function Za(e){return new this(e).asin()}function Qa(e){return new this(e).asinh()}function $a(e){return new this(e).atan()}function eo(e){return new this(e).atanh()}function to(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=Aa(this,a,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?Aa(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=Aa(this,a,1).times(.5),n.s=e.s):t.s<0?(this.precision=a,this.rounding=1,n=this.atan(Ta(e,t,a,1)),t=Aa(this,a,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(Ta(e,t,a,1)),n}function no(e){return new this(e).cbrt()}function ro(e){return Ea(e=new this(e),e.e+1,2)}function io(e,t,n){return new this(e).clamp(t,n)}function ao(e){if(!e||typeof e!=`object`)throw Error(ia+`Object expected`);var t,n,r,i=e.defaults===!0,a=[`precision`,1,Xi,`rounding`,0,8,`toExpNeg`,-Yi,0,`toExpPos`,0,Yi,`maxE`,0,Yi,`minE`,-Yi,0,`modulo`,0,9];for(t=0;t<a.length;t+=3)if(n=a[t],i&&(this[n]=ea[n]),(r=e[n])!==void 0)if(la(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]=ea[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(sa);else this[n]=!1;else throw Error(aa+n+`: `+r);return this}function oo(e){return new this(e).cos()}function so(e){return new this(e).cosh()}function co(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,mo(e)){a.s=e.s,ra?!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++;ra?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 za(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),ma.test(e)?za(a,e):Ba(a,e);if(r===`bigint`)return e<0?(e=-e,a.s=-1):a.s=1,za(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=ao,i.clone=co,i.isDecimal=mo,i.abs=qa,i.acos=Ja,i.acosh=Ya,i.add=Xa,i.asin=Za,i.asinh=Qa,i.atan=$a,i.atanh=eo,i.atan2=to,i.cbrt=no,i.ceil=ro,i.clamp=io,i.cos=oo,i.cosh=so,i.div=lo,i.exp=uo,i.floor=fo,i.hypot=po,i.ln=ho,i.log=go,i.log10=vo,i.log2=_o,i.max=yo,i.min=bo,i.mod=xo,i.mul=So,i.pow=Co,i.random=wo,i.round=To,i.sign=Eo,i.sin=Do,i.sinh=Oo,i.sqrt=ko,i.sub=Ao,i.sum=jo,i.tan=Mo,i.tanh=No,i.trunc=Po,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 lo(e,t){return new this(e).div(t)}function uo(e){return new this(e).exp()}function fo(e){return Ea(e=new this(e),e.e+1,3)}function po(){var e,t,n=new this(0);for(ra=!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 ra=!0,new this(1/0);n=t}return ra=!0,n.sqrt()}function mo(e){return e instanceof Fo||e&&e.toStringTag===ca||!1}function ho(e){return new this(e).ln()}function go(e,t){return new this(e).log(t)}function _o(e){return new this(e).log(2)}function vo(e){return new this(e).log(10)}function yo(){return Fa(this,arguments,-1)}function bo(){return Fa(this,arguments,1)}function xo(e,t){return new this(e).mod(t)}function So(e,t){return new this(e).mul(t)}function Co(e,t){return new this(e).pow(t)}function wo(e){var t,n,r,i,a=0,o=new this(1),s=[];if(e===void 0?e=this.precision:xa(e,1,Xi),r=Math.ceil(e/ga),!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(sa);for(r=s[--a],e%=ga,r&&e&&(i=ua(10,ga-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-=ga)s.shift();for(r=1,i=s[0];i>=10;i/=10)r++;r<ga&&(n-=ga-r)}return o.e=n,o.d=s,o}function To(e){return Ea(e=new this(e),e.e+1,this.rounding)}function Eo(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Do(e){return new this(e).sin()}function Oo(e){return new this(e).sinh()}function ko(e){return new this(e).sqrt()}function Ao(e,t){return new this(e).sub(t)}function jo(){var e=0,t=arguments,n=new this(t[e]);for(ra=!1;n.s&&++e<t.length;)n=n.plus(t[e]);return ra=!0,Ea(n,this.precision,this.rounding)}function Mo(e){return new this(e).tan()}function No(e){return new this(e).tanh()}function Po(e){return Ea(e=new this(e),e.e+1,1)}Y[Symbol.for(`nodejs.util.inspect.custom`)]=Y.toString,Y[Symbol.toStringTag]=`Decimal`;var Fo=Y.constructor=co(ea);Qi=new Fo(Qi),$i=new Fo($i);var Io=J(`BigNumber`,[`?on`,`config`],e=>{var{on:t,config:n}=e,r=Fo.clone({precision:n.precision,modulo:Fo.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}),Lo=Math.cosh||function(e){return Math.abs(e)<1e-9?1-e:(Math.exp(e)+Math.exp(-e))*.5},Ro=Math.sinh||function(e){return Math.abs(e)<1e-9?e:(Math.exp(e)-Math.exp(-e))*.5},zo=e=>{let t=Math.sin(.5*e);return-2*t*t},Bo=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))},Vo=function(){throw SyntaxError(`Invalid Param`)};function Ho(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 Uo={re:0,im:0},Wo=function(e,t){let n=Uo;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]):Vo();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&&Vo();for(let e=0;e<t.length;e++){let a=t[e];a===` `||a===` `||a===`
3
+ `||(a===`+`?r++:a===`-`?i++:a===`i`||a===`I`?(r+i===0&&Vo(),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))&&Vo(),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&&Vo();break;case`number`:n.im=0,n.re=e;break;default:Vo()}return isNaN(n.re)||isNaN(n.im),n};function X(e,t){if(!(this instanceof X))return new X(e,t);let n=Wo(e,t);this.re=n.re,this.im=n.im}X.prototype={re:0,im:0,sign:function(){let e=Bo(this.re,this.im);return new X(this.re/e,this.im/e)},add:function(e,t){let n=Wo(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=Wo(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=Wo(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=Wo(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=Wo(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=Ho(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=Bo(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)+zo(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(Ho(e,t),Math.atan2(t,e))},abs:function(){return Bo(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)*Lo(t),Math.cos(e)*Ro(t))},cos:function(){let e=this.re,t=this.im;return new X(Math.cos(e)*Lo(t),-Math.sin(e)*Ro(t))},tan:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)+Lo(t);return new X(Math.sin(e)/n,Ro(t)/n)},cot:function(){let e=2*this.re,t=2*this.im,n=Math.cos(e)-Lo(t);return new X(-Math.sin(e)/n,Ro(t)/n)},sec:function(){let e=this.re,t=this.im,n=.5*Lo(2*t)+.5*Math.cos(2*e);return new X(Math.cos(e)*Lo(t)/n,Math.sin(e)*Ro(t)/n)},csc:function(){let e=this.re,t=this.im,n=.5*Lo(2*t)-.5*Math.cos(2*e);return new X(Math.sin(e)*Lo(t)/n,-Math.cos(e)*Ro(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(Ro(e)*Math.cos(t),Lo(e)*Math.sin(t))},cosh:function(){let e=this.re,t=this.im;return new X(Lo(e)*Math.cos(t),Ro(e)*Math.sin(t))},tanh:function(){let e=2*this.re,t=2*this.im,n=Lo(e)+Math.cos(t);return new X(Ro(e)/n,Math.sin(t)/n)},coth:function(){let e=2*this.re,t=2*this.im,n=Lo(e)-Math.cos(t);return new X(Ro(e)/n,-Math.sin(t)/n)},csch:function(){let e=this.re,t=this.im,n=Math.cos(2*t)-Lo(2*e);return new X(-2*Ro(e)*Math.cos(t)/n,2*Lo(e)*Math.sin(t)/n)},sech:function(){let e=this.re,t=this.im,n=Math.cos(2*t)+Lo(2*e);return new X(2*Lo(e)*Math.cos(t)/n,-2*Ro(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(Ho(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=Wo(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 Go=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=xi(this.re,e),a=xi(this.im,e),o=tr(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(tr(n)){if(or(r)&&r.hasBase(`ANGLE`)&&(r=r.toNumber(`rad`)),tr(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 Ko=BigInt(0),qo=BigInt(1),Jo=BigInt(2),Yo=BigInt(3),Xo=BigInt(5),Zo=BigInt(10);BigInt(2**53-1);var Qo=2e3,$o={s:qo,n:Ko,d:qo};function es(e,t){try{e=BigInt(e)}catch{throw fs()}return e*t}function ts(e){return typeof e==`bigint`?e:Math.floor(e)}function ns(e,t){if(t===Ko)throw ds();let n=Object.create(us.prototype);n.s=e<Ko?-qo:qo,e=e<Ko?-e:e;let r=ls(e,t);return n.n=e/r,n.d=t/r,n}var rs=[Jo*Jo,Jo,Jo*Jo,Jo,Jo*Jo,Jo*Yo,Jo,Jo*Yo];function is(e){let t=Object.create(null);if(e<=qo)return t[e]=qo,t;let n=e=>{t[e]=(t[e]||Ko)+qo};for(;e%Jo===Ko;)n(Jo),e/=Jo;for(;e%Yo===Ko;)n(Yo),e/=Yo;for(;e%Xo===Ko;)n(Xo),e/=Xo;for(let t=0,r=Jo+Xo;r*r<=e;){for(;e%r===Ko;)n(r),e/=r;r+=rs[t],t=t+1&7}return e>qo&&n(e),t}var as=function(e,t){let n=Ko,r=qo,i=qo;if(e!=null)if(t!==void 0){if(typeof e==`bigint`)n=e;else if(isNaN(e))throw fs();else if(e%1!=0)throw ps();else n=BigInt(e);if(typeof t==`bigint`)r=t;else if(isNaN(t))throw fs();else if(t%1!=0)throw ps();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 fs();i=n*r}else if(typeof e==`number`){if(isNaN(e))throw fs();if(e<0&&(i=-qo,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=Ko,o=Ko,s=Ko,c=qo,l=qo,u=e.replace(/_/g,``).match(/\d+|./g);if(u===null)throw fs();if(u[t]===`-`?(i=-qo,t++):u[t]===`+`&&t++,u.length===t+1?o=es(u[t++],i):u[t+1]===`.`||u[t]===`.`?(u[t]!==`.`&&(a=es(u[t++],i)),t++,(t+1===u.length||u[t+1]===`(`&&u[t+3]===`)`||u[t+1]===`'`&&u[t+3]===`'`)&&(o=es(u[t],i),c=Zo**BigInt(u[t].length),t++),(u[t]===`(`&&u[t+2]===`)`||u[t]===`'`&&u[t+2]===`'`)&&(s=es(u[t+1],i),l=Zo**BigInt(u[t+1].length)-qo,t+=3)):u[t+1]===`/`||u[t+1]===`:`?(o=es(u[t],i),c=es(u[t+2],qo),t+=3):u[t+3]===`/`&&u[t+1]===` `&&(a=es(u[t],i),o=es(u[t+2],i),c=es(u[t+4],qo),t+=5),u.length<=t)r=c*l,i=n=s+r*a+l*o;else throw fs()}else if(typeof e==`bigint`)n=e,i=e,r=qo;else throw fs();if(r===Ko)throw ds();$o.s=i<Ko?-qo:qo,$o.n=n<Ko?-n:n,$o.d=r<Ko?-r:r};function os(e,t,n){let r=qo;for(;t>Ko;e=e*e%n,t>>=qo)t&qo&&(r=r*e%n);return r}function ss(e,t){for(;t%Jo===Ko;t/=Jo);for(;t%Xo===Ko;t/=Xo);if(t===qo)return Ko;let n=Zo%t,r=1;for(;n!==qo;r++)if(n=n*Zo%t,r>Qo)return Ko;return BigInt(r)}function cs(e,t,n){let r=qo,i=os(Zo,n,t);for(let e=0;e<300;e++){if(r===i)return BigInt(e);r=r*Zo%t,i=i*Zo%t}return 0}function ls(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}}function us(e,t){if(as(e,t),this instanceof us)e=ls($o.d,$o.n),this.s=$o.s,this.n=$o.n/e,this.d=$o.d/e;else return ns($o.s*$o.n,$o.d)}var ds=function(){return Error(`Division by Zero`)},fs=function(){return Error(`Invalid argument`)},ps=function(){return Error(`Parameters must be integer`)};us.prototype={s:qo,n:Ko,d:qo,abs:function(){return ns(this.n,this.d)},neg:function(){return ns(-this.s*this.n,this.d)},add:function(e,t){return as(e,t),ns(this.s*this.n*$o.d+$o.s*this.d*$o.n,this.d*$o.d)},sub:function(e,t){return as(e,t),ns(this.s*this.n*$o.d-$o.s*this.d*$o.n,this.d*$o.d)},mul:function(e,t){return as(e,t),ns(this.s*$o.s*this.n*$o.n,this.d*$o.d)},div:function(e,t){return as(e,t),ns(this.s*$o.s*this.n*$o.d,this.d*$o.n)},clone:function(){return ns(this.s*this.n,this.d)},mod:function(e,t){if(e===void 0)return ns(this.s*this.n%this.d,qo);if(as(e,t),Ko===$o.n*this.d)throw ds();return ns(this.s*($o.d*this.n)%($o.n*this.d),$o.d*this.d)},gcd:function(e,t){return as(e,t),ns(ls($o.n,this.n)*ls($o.d,this.d),$o.d*this.d)},lcm:function(e,t){return as(e,t),$o.n===Ko&&this.n===Ko?ns(Ko,qo):ns($o.n*this.n,ls($o.n,this.n)*ls($o.d,this.d))},inverse:function(){return ns(this.s*this.d,this.n)},pow:function(e,t){if(as(e,t),$o.d===qo)return $o.s<Ko?ns((this.s*this.d)**$o.n,this.n**$o.n):ns((this.s*this.n)**$o.n,this.d**$o.n);if(this.s<Ko)return null;let n=is(this.n),r=is(this.d),i=qo,a=qo;for(let e in n)if(e!==`1`){if(e===`0`){i=Ko;break}if(n[e]*=$o.n,n[e]%$o.d===Ko)n[e]/=$o.d;else return null;i*=BigInt(e)**n[e]}for(let e in r)if(e!==`1`){if(r[e]*=$o.n,r[e]%$o.d===Ko)r[e]/=$o.d;else return null;a*=BigInt(e)**r[e]}return $o.s<Ko?ns(a,i):ns(i,a)},log:function(e,t){if(as(e,t),this.s<=Ko||$o.s<=Ko)return null;let n=Object.create(null),r=is($o.n),i=is($o.d),a=is(this.n),o=is(this.d);for(let e in i)r[e]=(r[e]||Ko)-i[e];for(let e in o)a[e]=(a[e]||Ko)-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]||Ko,n=a[e]||Ko;if(t===Ko){if(n!==Ko)return null;continue}let i=n,o=t,l=ls(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?ns(s,c):null},equals:function(e,t){return as(e,t),this.s*this.n*$o.d===$o.s*$o.n*this.d},lt:function(e,t){return as(e,t),this.s*this.n*$o.d<$o.s*$o.n*this.d},lte:function(e,t){return as(e,t),this.s*this.n*$o.d<=$o.s*$o.n*this.d},gt:function(e,t){return as(e,t),this.s*this.n*$o.d>$o.s*$o.n*this.d},gte:function(e,t){return as(e,t),this.s*this.n*$o.d>=$o.s*$o.n*this.d},compare:function(e,t){as(e,t);let n=this.s*this.n*$o.d-$o.s*$o.n*this.d;return(Ko<n)-(n<Ko)},ceil:function(e){return e=Zo**BigInt(e||0),ns(ts(this.s*e*this.n/this.d)+(e*this.n%this.d>Ko&&this.s>=Ko?qo:Ko),e)},floor:function(e){return e=Zo**BigInt(e||0),ns(ts(this.s*e*this.n/this.d)-(e*this.n%this.d>Ko&&this.s<Ko?qo:Ko),e)},round:function(e){return e=Zo**BigInt(e||0),ns(ts(this.s*e*this.n/this.d)+this.s*((this.s>=Ko?qo:Ko)+Jo*(e*this.n%this.d)>this.d?qo:Ko),e)},roundTo:function(e,t){as(e,t);let n=this.n*$o.d,r=this.d*$o.n,i=n%r,a=ts(n/r);return i+i>=r&&a++,ns(this.s*a*$o.n,$o.d)},divisible:function(e,t){return as(e,t),$o.n===Ko?!1:this.n*$o.d%($o.n*this.d)===Ko},valueOf:function(){return Number(this.s*this.n)/Number(this.d)},toString:function(e=15){let t=this.n,n=this.d,r=ss(t,n),i=cs(t,n,r),a=this.s<Ko?`-`:``;if(a+=ts(t/n),t%=n,t*=Zo,t&&(a+=`.`),r){for(let e=i;e--;)a+=ts(t/n),t%=n,t*=Zo;a+=`(`;for(let e=r;e--;)a+=ts(t/n),t%=n,t*=Zo;a+=`)`}else for(let r=e;t&&r--;)a+=ts(t/n),t%=n,t*=Zo;return a},toFraction:function(e=!1){let t=this.n,n=this.d,r=this.s<Ko?`-`:``;if(n===qo)r+=t;else{let i=ts(t/n);e&&i>Ko&&(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<Ko?`-`:``;if(n===qo)r+=t;else{let i=ts(t/n);e&&i>Ko&&(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(ts(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=ns(r[e-1],qo);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 ms=J(`Fraction`,[],()=>(Object.defineProperty(us,`name`,{value:`Fraction`}),us.prototype.constructor=us,us.prototype.type=`Fraction`,us.prototype.isFraction=!0,us.prototype.toJSON=function(){return{mathjs:`Fraction`,n:String(this.s*this.n),d:String(this.d)}},us.fromJSON=function(e){return new us(e)},us),{isClass:!0}),hs=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(nr(t))t=t.toNumber();else if(typeof t!=`number`&&!rr(t))throw TypeError(`Parameter start must be a number or bigint`)}if(a){if(nr(n))n=n.toNumber();else if(typeof n!=`number`&&!rr(n))throw TypeError(`Parameter end must be a number or bigint`)}if(o){if(nr(r))r=r.toNumber();else if(typeof r!=`number`&&!rr(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&&ji(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 mi(n)===mi(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=xi(this.start,e);return this.step!==1&&(t+=`:`+xi(this.step,e)),t+=`:`+xi(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}),gs=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 _s(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(!fi(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 vs(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}=Si(t);switch(n){case`fixed`:return xs(e,r);case`exponential`:return bs(e,r);case`engineering`:return ys(e,r);case`bin`:return _s(e,2,i);case`oct`:return _s(e,8,i);case`hex`:return _s(e,16,i);case`auto`:var a=Ss(t?.lowerExp,-3),o=Ss(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():bs(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 ys(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 bs(e,t){return t===void 0?e.toExponential():e.toExponential(t-1)}function xs(e,t){return e.toFixed(t)}function Ss(e,t){return tr(e)?e:nr(e)?e.toNumber():t}function Cs(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t}function ws(e,t){var n=Ts(e,t);return t&&typeof t==`object`&&`truncate`in t&&n.length>t.truncate?n.substring(0,t.truncate-3)+`...`:n}function Ts(e,t){return typeof e==`number`?xi(e,t):nr(e)?vs(e,t):As(e)?!t||t.fraction!==`decimal`?`${e.s*e.n}/${e.d}`:e.toString():Array.isArray(e)?ks(e,t):sr(e)?Es(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=>Es(n)+`: `+ws(e[n],t)).join(`, `)+`}`:String(e)}function Es(e){for(var t=String(e),n=``,r=0;r<t.length;){var i=t.charAt(r);n+=i in Ds?Ds[i]:i,r++}return`"`+n+`"`}var Ds={'"':`\\"`,"\\":`\\\\`,"\b":`\\b`,"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`};function Os(e){var t=String(e);return t=t.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),t}function ks(e,t){if(Array.isArray(e)){for(var n=`[`,r=e.length,i=0;i<r;i++)i!==0&&(n+=`, `),n+=ks(e[i],t);return n+=`]`,n}else return ws(e,t)}function As(e){return e&&typeof e==`object`&&typeof e.s==`bigint`&&typeof e.n==`bigint`&&typeof e.d==`bigint`||!1}function js(e,t){if(!sr(e))throw TypeError(`Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: `+Gr(e)+`, index: 0)`);if(!sr(t))throw TypeError(`Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: `+Gr(t)+`, index: 1)`);return e===t?0:e>t?1:-1}function Ms(e,t,n){if(!(this instanceof Ms))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}Ms.prototype=RangeError(),Ms.prototype.constructor=RangeError,Ms.prototype.name=`DimensionError`,Ms.prototype.isDimensionError=!0;function Ns(e,t,n){if(!(this instanceof Ns))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}Ns.prototype=RangeError(),Ns.prototype.constructor=RangeError,Ns.prototype.name=`IndexError`,Ns.prototype.isIndexError=!0;function Ps(e){for(var t=[];Array.isArray(e);)t.push(e.length),e=e[0];return t}function Fs(e,t,n){var r,i=e.length;if(i!==t[n])throw new Ms(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 Ms(t.length-1,t.length,`<`);Fs(e[r],t,a)}}else for(r=0;r<i;r++)if(Array.isArray(e[r]))throw new Ms(t.length+1,t.length,`>`)}function Is(e,t){if(t.length===0){if(Array.isArray(e))throw new Ms(e.length,0)}else Fs(e,t,0)}function Ls(e,t){var n=e.isMatrix?e._size:Ps(e);t._sourceSize.forEach((e,t)=>{if(e!==null&&e!==n[t])throw new Ms(e,n[t])})}function Rs(e,t){if(e!==void 0){if(!tr(e)||!fi(e))throw TypeError(`Index must be an integer (value: `+e+`)`);if(e<0||typeof t==`number`&&e>=t)throw new Ns(e,t)}}function zs(e){for(var t=0;t<e._dimensions.length;++t){var n=e._dimensions[t];if(n._data&&cr(n._data)){if(n._size[0]===0)return!0}else if(n.isRange){if(n.start===n.end)return!0}else if(sr(n)&&n.length===0)return!0}return!1}function Bs(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(!tr(e)||!fi(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+ws(t)+`)`)}),(tr(e)||nr(e))&&(e=[e]),Vs(e,t,0,n===void 0?0:n),e}function Vs(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),Vs(a,t,l,r);for(i=c;i<s;i++)a=[],e[i]=a,Vs(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 Hs(e,t){var n=Xs(e,!0),r=n.length;if(!Array.isArray(e)||!Array.isArray(t))throw TypeError(`Array expected`);if(t.length===0)throw new Ms(0,r,`!=`);t=Us(t,r);var i=Ws(t);if(r!==i)throw new Ms(i,r,`!=`);try{return Gs(n,t)}catch(e){throw e instanceof Ms?new Ms(i,r,`!=`):e}}function Us(e,t){var n=Ws(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 Ws(e){return e.reduce((e,t)=>e*t,1)}function Gs(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 Ks(e,t){for(var n=t||Ps(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=qs(e,r,0),n.length=r),e}function qs(e,t,n){var r,i;if(n<t){var a=n+1;for(r=0,i=e.length;r<i;r++)e[r]=qs(e[r],t,a)}else for(;Array.isArray(e);)e=e[0];return e}function Js(e,t,n,r){var i=r||Ps(e);if(n)for(var a=0;a<n;a++)e=[e],i.unshift(1);for(e=Ys(e,t,0);i.length<t;)i.push(1);return e}function Ys(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]=Ys(e[r],t,a)}else for(var o=n;o<t;o++)e=[e];return e}function Xs(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 Zs(e,t){return Array.prototype.map.call(e,t)}function Qs(e,t){Array.prototype.forEach.call(e,t)}function $s(e,t){if(Ps(e).length!==1)throw Error(`Only one dimensional matrices supported`);return Array.prototype.filter.call(e,t)}function ec(e,t){if(Ps(e).length!==1)throw Error(`Only one dimensional matrices supported`);return Array.prototype.filter.call(e,e=>t.test(e))}function tc(e,t){return Array.prototype.join.call(e,t)}function nc(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 rc(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 ic(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?ic(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 Ms(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 oc(){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 sc(){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++)cc(e[l],r);return r}function cc(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 lc(e,t){var n=Ps(e);if(Xr(n,t))return e;cc(n,t);var r=sc(n,t),i=r.length,a=[...Array(i-n.length).fill(1),...n],o=mc(e);n.length<i&&(o=Hs(o,a),n=Ps(o));for(var s=0;s<i;s++)n[s]<r[s]&&(o=uc(o,r[s],s),n=Ps(o));return o}function uc(e,t,n){return oc(...Array(t).fill(e),n)}function dc(e,t){if(!Array.isArray(e))throw Error(`Array expected`);if(!Array.isArray(t))throw Error(`Array expected for index`);var n=Ps(e);if(t.length!==n.length)throw new Ms(t.length,n.length);for(var r=0;r<t.length;r++)Rs(t[r],n[r]);return t.reduce((e,t)=>e[t],e)}function fc(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 pc(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 mc(e){return Rn([],e)}function hc(e,t,n,r){if(Vi.default.isTypedFunction(e)){var i;if(r)i=1;else{var a=t.isMatrix?t.size():Ps(t);if(!a.length||a[a.length-1]===0)return{isUnary:r,fn:e};var o=a.map(()=>0);i=vc(e,t.isMatrix?t.get(o):dc(t,o),o,t)}var s;if(t.isMatrix&&t.dataType!==`mixed`&&t.dataType!==void 0){var c=gc(e,i);s=c===void 0?e:c}else s=e;return i>=1&&i<=3?{isUnary:i===1,fn:function(){return yc(s,[...arguments].slice(0,i),n,e.name)}}:{isUnary:!1,fn:function(){return yc(s,[...arguments],n,e.name)}}}return r===void 0?{isUnary:_c(e),fn:e}:{isUnary:r,fn:e}}function gc(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 _c(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 vc(e,t,n,r){for(var i=[t,n,r],a=3;a>0;a--){var o=i.slice(0,a);if(Vi.default.resolve(e,o)!==null)return a}}function yc(e,t,n,r){try{return e(...t)}catch(e){bc(e,t,n,r)}}function bc(e,t,n,r){if(e instanceof TypeError&&e.data?.category===`wrongType`){var i=[];throw i.push(`value: ${Gr(t[0])}`),t.length>=2&&i.push(`index: ${Gr(t[1])}`),t.length>=3&&i.push(`array: ${Gr(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 xc=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&&!sr(t))throw Error(`Invalid datatype: `+t);if(lr(e))e.type===`DenseMatrix`?(this._data=Kr(e._data),this._size=Kr(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&cr(e.data)&&cr(e.size))this._data=e.data,this._size=e.size,Is(this._data,this._size),this._datatype=t||e.datatype;else if(cr(e))this._data=u(e),this._size=Ps(this._data),Is(this._data,this._size),this._datatype=t;else if(e)throw TypeError(`Unsupported type of data (`+Gr(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 ic(this._data,Gr)},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 dc(this._data,e)},r.prototype.set=function(e,t,n){if(!cr(e))throw TypeError(`Array expected`);if(e.length<this._size.length)throw new Ms(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],Rs(a,s.length),s=s[a];return a=e[e.length-1],Rs(a,s.length),s[a]=t,this};function i(e,t){if(!mr(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 Ms(i.length,e._size.length);for(var o=t.min(),s=t.max(),c=0,l=e._size.length;c<l;c++)Rs(o[c],e._size[c]),Rs(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 tr(e)?t(e):e.map(t).valueOf()}return tr(o)?r[a]=null:r[a]=o.size()[0],a<n?s(o,t=>(Rs(t,e.length),i(e[t],a+1))):s(o,t=>(Rs(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(lr(n)?(o=n.size(),n=n.valueOf()):o=Ps(n),a){if(o.length!==0)throw TypeError(`Scalar expected`);e.set(t.min(),n,r)}else{if(!Xr(o,i)){if(o.length===0)n=lc([n],i);else try{n=lc(n,i)}catch{}o=Ps(n)}if(i.length<e._size.length)throw new Ms(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=Js(n,i.length,u,o)}if(!Xr(i,o))throw new Ms(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)=>{Rs(t,e.length),i(e[t],n[r[0]],a+1)},c=(t,r)=>{Rs(t,e.length),e[t]=n[r[0]]};a<r?tr(o)?s(o,[0]):o.forEach(s):tr(o)?c(o,[0]):o.forEach(c)}}r.prototype.resize=function(e,t,n){if(!ur(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;cr(r);)r=r[0];return r}return e._size=t.slice(0),e._data=Bs(e._data,e._size,n),e}r.prototype.reshape=function(e,t){var n=t?this.clone():this;return n._data=Hs(n._data,e),n._size=Us(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:Kr(this._data),size:Kr(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=hc(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=hc(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 Kr(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return ws(this._data,e)},r.prototype.toString=function(){return ws(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(nr(e)&&(e=e.toNumber()),!tr(e)||!fi(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(!cr(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(nr(e)&&(e=e.toNumber()),!tr(e)||!fi(e)||e<1)throw Error(`Size values must be positive integers`);return e}),n){if(nr(n)&&(n=n.toNumber()),!tr(n)||!fi(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(cr(t)){if(t.length!==l)throw Error(`Invalid value array length`);u=function(e){return t[e]}}else if(lr(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||=nr(u(0))?u(0).mul(0):0;var f=[];if(e.length>0){f=Bs(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(!tr(e)||!fi(e)||!tr(t)||!fi(t))throw Error(`Row index must be positive integers`);if(this._size.length!==2)throw Error(`Only two dimensional matrix is supported`);return Rs(e,this._size[0]),Rs(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 lr(e)?u(e.valueOf()):cr(e)?e.map(u):e}return r},{isClass:!0}),Sc=`clone`,Cc=J(Sc,[`typed`],e=>{var{typed:t}=e;return t(Sc,{any:Kr})});function wc(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 Tc(e){for(var t=0;t<e.length;t++)if(ur(e[t]))return!0;return!1}function Ec(e,t){lr(e)?e.forEach(e=>t(e),!1,!0):pc(e,t,!0)}function Dc(e,t,n){if(!n)return lr(e)?e.map(e=>t(e),!1,!0):fc(e,t,!0);var r=e=>e===0?e:t(e);return lr(e)?e.map(e=>r(e),!1,!0):fc(e,r,!0)}function Oc(e,t,n){var r=Array.isArray(e)?Ps(e):e.size();if(t<0||t>=r.length)throw new Ns(t,r.length);return lr(e)?e.create(kc(e.valueOf(),t,n),e.datatype()):kc(e,t,n)}function kc(e,t,n){var r,i,a,o;if(t<=0)if(Array.isArray(e[0])){for(o=wc(e),i=[],r=0;r<o.length;r++)i[r]=kc(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]=kc(e[r],t-1,n);return i}}function Ac(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 jc=`isInteger`,Mc=J(jc,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(jc,{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=>Dc(t,e))})}),Nc=`number`,Pc=`number, number`;function Fc(e){return Math.abs(e)}Fc.signature=Nc;function Ic(e,t){return e+t}Ic.signature=Pc;function Lc(e,t){return e-t}Lc.signature=Pc;function Rc(e,t){return e*t}Rc.signature=Pc;function zc(e,t){return e/t}zc.signature=Pc;function Bc(e){return-e}Bc.signature=Nc;function Vc(e){return e}Vc.signature=Nc;function Hc(e){return vi(e)}Hc.signature=Nc;function Uc(e){return e*e*e}Uc.signature=Nc;function Wc(e){return Math.exp(e)}Wc.signature=Nc;function Gc(e){return yi(e)}Gc.signature=Nc;function Kc(e,t){if(!fi(e)||!fi(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}Kc.signature=Pc;function qc(e,t){if(!fi(e)||!fi(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)}qc.signature=Pc;function Jc(e,t){return t?Math.log(e)/Math.log(t):Math.log(e)}function Yc(e){return gi(e)}Yc.signature=Nc;function Xc(e){return hi(e)}Xc.signature=Nc;function Zc(e){return _i(e)}Zc.signature=Nc;function Qc(e,t){return t===0?e:e-t*Math.floor(e/t)}Qc.signature=Pc;function $c(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 el(e){return mi(e)}el.signature=Nc;function tl(e){return Math.sqrt(e)}tl.signature=Nc;function nl(e){return e*e}nl.signature=Nc;function rl(e,t){var n,r,i,a=0,o=1,s=1,c=0;if(!fi(e)||!fi(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]}rl.signature=Pc;function il(e,t){return e*e<1&&t===1/0||e*e>1&&t===-1/0?0:e**+t}il.signature=Pc;function al(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!fi(t)||t<0||t>15)throw Error(`Number of decimals in function round must be an integer from 0 to 15 inclusive`);return parseFloat(Ti(e,t))}function ol(e){return Math.abs(e)}ol.signature=Nc;var sl=`number`,cl=`number, number`;function ll(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function bitAnd`);return e&t}ll.signature=cl;function ul(e){if(!fi(e))throw Error(`Integer expected in function bitNot`);return~e}ul.signature=sl;function dl(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function bitOr`);return e|t}dl.signature=cl;function fl(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function bitXor`);return e^t}fl.signature=cl;function pl(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function leftShift`);return e<<t}pl.signature=cl;function ml(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function rightArithShift`);return e>>t}ml.signature=cl;function hl(e,t){if(!fi(e)||!fi(t))throw Error(`Integers expected in function rightLogShift`);return e>>>t}hl.signature=cl;function gl(e,t){if(t<e)return 1;if(t===e)return t;var n=t+e>>1;return gl(e,n)*gl(n+1,t)}function _l(e,t){if(!fi(e)||e<0||!fi(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/=gl(a,o)),r}_l.signature=`number, number`;var vl=Math.PI,yl=2*Math.PI,bl=Math.E,xl=1.618033988749895,Sl=`number`,Cl=`number, number`;function wl(e){return!e}wl.signature=Sl;function Tl(e,t){return!!(e||t)}Tl.signature=Cl;function El(e,t){return!!e!=!!t}El.signature=Cl;function Dl(e,t){return!!(e&&t)}Dl.signature=Cl;function Ol(e){var t;if(fi(e))return e<=0?Number.isFinite(e)?1/0:NaN:e>171?1/0:gl(1,e-1);if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Ol(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=Al[0];for(var o=1;o<Al.length;++o)t+=Al[o]/(e+o);var s=e+kl+.5;return Math.sqrt(2*Math.PI)*s**+(e+.5)*Math.exp(-s)*t}Ol.signature=`number`;var kl=4.7421875,Al=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],jl=.9189385332046728,Ml=[1.000000000190015,76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18];function Nl(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))-Nl(1-e);--e;for(var t=e+5+.5,n=Ml[0],r=6;r>=1;r--)n+=Ml[r]/(e+r);return jl+(e+.5)*Math.log(t)-t+Math.log(n)}Nl.signature=`number`;var Pl=`number`,Fl=`number, number`;function Il(e){return Math.acos(e)}Il.signature=Pl;function Ll(e){return Mi(e)}Ll.signature=Pl;function Rl(e){return Math.atan(1/e)}Rl.signature=Pl;function zl(e){return Number.isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0}zl.signature=Pl;function Bl(e){return Math.asin(1/e)}Bl.signature=Pl;function Vl(e){var t=1/e;return Math.log(t+Math.sqrt(t*t+1))}Vl.signature=Pl;function Hl(e){return Math.acos(1/e)}Hl.signature=Pl;function Ul(e){var t=1/e,n=Math.sqrt(t*t-1);return Math.log(n+t)}Ul.signature=Pl;function Wl(e){return Math.asin(e)}Wl.signature=Pl;function Gl(e){return Ni(e)}Gl.signature=Pl;function Kl(e){return Math.atan(e)}Kl.signature=Pl;function ql(e,t){return Math.atan2(e,t)}ql.signature=Fl;function Jl(e){return Pi(e)}Jl.signature=Pl;function Yl(e){return Math.cos(e)}Yl.signature=Pl;function Xl(e){return Fi(e)}Xl.signature=Pl;function Zl(e){return 1/Math.tan(e)}Zl.signature=Pl;function Ql(e){var t=Math.exp(2*e);return(t+1)/(t-1)}Ql.signature=Pl;function $l(e){return 1/Math.sin(e)}$l.signature=Pl;function eu(e){return e===0?1/0:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*mi(e)}eu.signature=Pl;function tu(e){return 1/Math.cos(e)}tu.signature=Pl;function nu(e){return 2/(Math.exp(e)+Math.exp(-e))}nu.signature=Pl;function ru(e){return Math.sin(e)}ru.signature=Pl;function iu(e){return Ii(e)}iu.signature=Pl;function au(e){return Math.tan(e)}au.signature=Pl;function ou(e){return Li(e)}ou.signature=Pl;var su=`number`;function cu(e){return fi(e)}cu.signature=su;function lu(e){return e<0}lu.signature=su;function uu(e){return e>0}uu.signature=su;function du(e){return e===0}du.signature=su;function fu(e){return Number.isNaN(e)}fu.signature=su;function pu(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 mu=`isNegative`,hu=J(mu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(mu,{number:e=>ji(e,0,n.relTol,n.absTol)?!1:lu(e),BigNumber:e=>pu(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=>Dc(t,e))})}),gu=`isNumeric`,_u=J(gu,[`typed`],e=>{var{typed:t}=e;return t(gu,{"number | BigNumber | bigint | Fraction | boolean":()=>!0,"Complex | Unit | string | null | undefined | Node":()=>!1,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),vu=`hasNumericValue`,yu=J(vu,[`typed`,`isNumeric`],e=>{var{typed:t,isNumeric:n}=e;return t(vu,{boolean:()=>!0,string:function(e){return e.trim().length>0&&!isNaN(Number(e))},any:function(e){return n(e)}})}),bu=`isPositive`,xu=J(bu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(bu,{number:e=>ji(e,0,n.relTol,n.absTol)?!1:uu(e),BigNumber:e=>pu(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=>Dc(t,e))})}),Su=`isZero`,Cu=J(Su,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(Su,{"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=>Dc(t,e))})}),wu=`isNaN`,Tu=J(wu,[`typed`],e=>{var{typed:t}=e;return t(wu,{number:fu,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=>Dc(t,e))})}),Eu=`isBounded`,Du=J(Eu,[`typed`],e=>{var{typed:t}=e;return t(Eu,{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))))})}),Ou=`isFinite`,ku=J(Ou,[`typed`,`isBounded`,`map`],e=>{var{typed:t,isBounded:n,map:r}=e;return t(Ou,{"Array | Matrix":e=>r(e,n),any:e=>n(e)})}),Au=`typeOf`,ju=J(Au,[`typed`],e=>{var{typed:t}=e;return t(Au,{any:Gr})});function Mu(e,t,n,r){return ji(e.re,t.re,n,r)&&ji(e.im,t.im,n,r)}var Nu=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)})}}),Pu=`equalScalar`,Fu=J(Pu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Pu,{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,t){return ji(e,t,n.relTol,n.absTol)},"BigNumber, BigNumber":function(e,t){return e.eq(t)||pu(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 Mu(e,t,n.relTol,n.absTol)}},Nu({typed:t}))});J(Pu,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Pu,{"number, number":function(e,t){return ji(e,t,n.relTol,n.absTol)}})});var Iu=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&&!sr(t))throw Error(`Invalid datatype: `+t);if(lr(e))a(this,e,t);else if(e&&cr(e.index)&&cr(e.ptr)&&cr(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(cr(e))o(this,e,t);else if(e)throw TypeError(`Unsupported type of data (`+Gr(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?Kr(t._values):void 0,e._index=Kr(t._index),e._ptr=Kr(t._ptr),e._size=Kr(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(sr(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(cr(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 ic(this._values,Gr)},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(!mr(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 Ms(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++)Rs(c[r],e._size[r]),Rs(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(lr(n)?(o=n.size(),n=n.toArray()):o=Ps(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 Ms(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=Js(n,i.length,c,o)}if(!Xr(i,o))throw new Ms(i,o,`>`);if(i.length===1)d(t.dimension(0),(t,i)=>{Rs(t),e.set([t,0],n[i[0]],r)});else{var l=t.dimension(0),u=t.dimension(1);d(l,(t,i)=>{Rs(t),d(u,(a,o)=>{Rs(a),e.set([t,a],n[i[0]][o[0]],r)})})}}return e;function d(e,t){tr(e)?t(e,[0]):e.forEach(t)}}i.prototype.get=function(e){if(!cr(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new Ms(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];Rs(t,this._size[0]),Rs(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(!cr(e))throw TypeError(`Array expected`);if(e.length!==this._size.length)throw new Ms(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;sr(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]),Rs(a,s),Rs(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(!ur(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(!tr(e)||!fi(e)||e<0)throw TypeError(`Invalid size, must contain positive integers (size: `+ws(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;sr(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(!cr(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(!tr(t)||!fi(t)||t<=-2||t===0)throw TypeError(`Invalid size, must contain positive integers or -1 (size: `+ws(e)+`)`)});var n=this._size[0]*this._size[1];if(e=Us(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?Kr(this._values):void 0,index:Kr(this._index),ptr:Kr(this._ptr),size:Kr(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=hc(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;sr(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=hc(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?Kr(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 [`+ws(t,e)+` x `+ws(n,e)+`] density: `+ws(r,e)+`
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
+ (`+ws(l,e)+`, `+ws(a,e)+`) ==> `+(this._values?ws(this._values[c],e):`X`)}return i},i.prototype.toString=function(){return ws(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(nr(e)&&(e=e.toNumber()),!tr(e)||!fi(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(!cr(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(nr(e)&&(e=e.toNumber()),!tr(e)||!fi(e)||e<1)throw Error(`Size values must be positive integers`);return e}),a){if(nr(a)&&(a=a.toNumber()),!tr(a)||!fi(a))throw TypeError(`The parameter k must be an integer number`)}else a=0;var c=n,l=0;sr(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(cr(r)){if(r.length!==m)throw Error(`Invalid value array length`);h=function(e){return r[e]}}else if(lr(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(!tr(e)||!fi(e)||!tr(t)||!fi(t))throw Error(`Row index must be positive integers`);if(this._size.length!==2)throw Error(`Only two dimensional matrix is supported`);return Rs(e,this._size[0]),Rs(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}),Lu=`number`,Ru=[`typed`];function zu(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 Bu(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 Vu=J(Lu,Ru,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=zu(e);if(t)return Bu(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=>Dc(t,e))});return n.fromJSON=function(e){return parseFloat(e.value)},n}),Hu=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=>Dc(t,e))});return n.fromJSON=function(e){return BigInt(e.value)},n}),Uu=`string`,Wu=J(Uu,[`typed`],e=>{var{typed:t}=e;return t(Uu,{"":function(){return``},number:xi,null:function(e){return`null`},boolean:function(e){return e+``},string:function(e){return e},"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e)),any:function(e){return String(e)}})}),Gu=`boolean`,Ku=J(Gu,[`typed`],e=>{var{typed:t}=e;return t(Gu,{"":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=>Dc(t,e))})}),qu=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=>Dc(t,e))})}),Ju=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=>Dc(t,e))})}),Yu=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=>Dc(t,e))})}),Xu=`matrix`,Zu=J(Xu,[`typed`,`Matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,Matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(Xu,{"":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)+`.`)}}),Qu=`matrixFromFunction`,$u=J(Qu,[`typed`,`matrix`,`isZero`],e=>{var{typed:t,matrix:n,isZero:r}=e;return t(Qu,{"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}}),ed=`matrixFromRows`,td=J(ed,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(ed,{"...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.`)}}),nd=`matrixFromColumns`,rd=J(nd,[`typed`,`matrix`,`flatten`,`size`],e=>{var{typed:t,matrix:n,flatten:r,size:i}=e;return t(nd,{"...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.`)}}),id=`splitUnit`,ad=J(id,[`typed`],e=>{var{typed:t}=e;return t(id,{"Unit, Array":function(e,t){return e.splitUnit(t)}})}),od=`unaryMinus`,sd=J(od,[`typed`],e=>{var{typed:t}=e;return t(od,{number:Bc,"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=>Dc(t,e,!0))})}),cd=`unaryPlus`,ld=J(cd,[`typed`,`config`,`numeric`],e=>{var{typed:t,config:n,numeric:r}=e;return t(cd,{number:Vc,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=>Dc(t,e,!0)),boolean:function(e){return r(+!!e,n.number)},string:function(e){return r(e,pi(e,n))}})}),ud=`abs`,dd=J(ud,[`typed`],e=>{var{typed:t}=e;return t(ud,{number:Fc,"Complex | BigNumber | Fraction | Unit":e=>e.abs(),bigint:e=>e<0n?-e:e,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e,!0))})}),fd=`mapSlices`,pd=J(fd,[`typed`,`isInteger`],e=>{var{typed:t,isInteger:n}=e;return t(fd,{"Array | Matrix, number | BigNumber, function":function(e,t,r){if(!n(t))throw TypeError(`Integer number expected for dimension`);var i=Array.isArray(e)?Ps(e):e.size();if(t<0||t>=i.length)throw new Ns(t,i.length);return lr(e)?e.create(md(e.valueOf(),t,r),e.datatype()):md(e,t,r)}})},{formerly:`apply`});function md(e,t,n){var r,i,a;if(t<=0)if(Array.isArray(e[0])){for(a=hd(e),i=[],r=0;r<a.length;r++)i[r]=md(a[r],t-1,n);return i}else return n(e);else{for(i=[],r=0;r<e.length;r++)i[r]=md(e[r],t-1,n);return i}}function hd(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 gd=`addScalar`,_d=J(gd,[`typed`],e=>{var{typed:t}=e;return t(gd,{"number, number":Ic,"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})})}),vd=`subtractScalar`,yd=J(vd,[`typed`],e=>{var{typed:t}=e;return t(vd,{"number, number":Lc,"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})})}),bd=`cbrt`,xd=J(bd,[`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(bd,{number:Hc,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(Hc(i),0).mul(new o(0,r).exp());if(n){var c=[s,new o(Hc(i),0).mul(new o(0,r+Math.PI*2/3).exp()),new o(Hc(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&&ir(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=nr(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}}}),Sd=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})}}),Cd=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})}}),wd=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:Kr(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}}),Td=`ceil`,Ed=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],Dd=new Fo(10),Od=J(Td,[`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:ji(e,i,n.relTol,n.absTol)&&!ji(e,t,n.relTol,n.absTol)?i:t}return t(Td,{number:i,"number, number":function(e,t){if(!fi(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}})}),kd=J(Td,Ed,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=Sd({typed:t,equalScalar:a}),l=Cd({typed:t,DenseMatrix:s}),u=wd({typed:t}),d=Od({typed:t,config:n,round:r});function f(e){var t=(e,t)=>pu(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=Dd.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)=>Dc(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=>Dc(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>Dc(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))})}),Ad=`cube`,jd=J(Ad,[`typed`],e=>{var{typed:t}=e;return t(Ad,{number:Uc,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)}})}),Md=`exp`,Nd=J(Md,[`typed`],e=>{var{typed:t}=e;return t(Md,{number:Wc,Complex:function(e){return e.exp()},BigNumber:function(e){return e.exp()}})}),Pd=`expm1`,Fd=J(Pd,[`typed`,`Complex`],e=>{var{typed:t,Complex:n}=e;return t(Pd,{number:Gc,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)}})}),Id=`fix`,Ld=[`typed`,`Complex`,`matrix`,`ceil`,`floor`,`equalScalar`,`zeros`,`DenseMatrix`],Rd=J(Id,[`typed`,`ceil`,`floor`],e=>{var{typed:t,ceil:n,floor:r}=e;return t(Id,{number:function(e){return e>0?r(e):n(e)},"number, number":function(e,t){return e>0?r(e,t):n(e,t)}})}),zd=J(Id,Ld,e=>{var{typed:t,Complex:n,matrix:r,ceil:i,floor:a,equalScalar:o,zeros:s,DenseMatrix:c}=e,l=Cd({typed:t,DenseMatrix:c}),u=wd({typed:t}),d=Rd({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)=>Dc(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=>Dc(t,e,!0)),"Array | Matrix, number | BigNumber":t.referToSelf(e=>(t,n)=>Dc(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))})}),Bd=`floor`,Vd=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`DenseMatrix`],Hd=new Fo(10),Ud=J(Bd,[`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:ji(e,i,n.relTol,n.absTol)&&!ji(e,t,n.relTol,n.absTol)?i:t}return t(Bd,{number:i,"number, number":function(e,t){if(!fi(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}})}),Wd=J(Bd,Vd,e=>{var{typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}=e,c=Sd({typed:t,equalScalar:a}),l=Cd({typed:t,DenseMatrix:s}),u=wd({typed:t}),d=Ud({typed:t,config:n,round:r});function f(e){var t=(e,t)=>pu(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=Hd.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)=>Dc(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=>Dc(t,e,!0)),"Array, number | BigNumber":t.referToSelf(e=>(t,n)=>Dc(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))})}),Gd=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 Ms(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})}}),Kd=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 Ms(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})}}),qd=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 Ms(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})}}),Jd=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 Ms(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 Yd(e,t){if(Xr(e.size(),t.size()))return[e,t];var n=sc(e.size(),t.size());return[e,t].map(e=>Xd(e,n))}function Xd(e,t){return Xr(e.size(),t)?e:e.create(lc(e.valueOf(),t),e.datatype())}var Zd=J(`matrixAlgorithmSuite`,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e,r=Jd({typed:t}),i=wd({typed:t});return function(e){var a=e.elop,o=e.SD||e.DS,s;a?(s={"DenseMatrix, DenseMatrix":(e,t)=>r(...Yd(e,t),a),"Array, Array":(e,t)=>r(...Yd(n(e),n(t)),a).valueOf(),"Array, DenseMatrix":(e,t)=>r(...Yd(n(e),t),a),"DenseMatrix, Array":(e,t)=>r(...Yd(e,n(t)),a)},e.SS&&(s[`SparseMatrix, SparseMatrix`]=(t,n)=>e.SS(...Yd(t,n),a,!1)),e.DS&&(s[`DenseMatrix, SparseMatrix`]=(t,n)=>e.DS(...Yd(t,n),a,!1),s[`Array, SparseMatrix`]=(t,r)=>e.DS(...Yd(n(t),r),a,!1)),o&&(s[`SparseMatrix, DenseMatrix`]=(e,t)=>o(...Yd(t,e),a,!0),s[`SparseMatrix, Array`]=(e,t)=>o(...Yd(n(t),e),a,!0))):(s={"DenseMatrix, DenseMatrix":t.referToSelf(e=>(t,n)=>r(...Yd(t,n),e)),"Array, Array":t.referToSelf(e=>(t,i)=>r(...Yd(n(t),n(i)),e).valueOf()),"Array, DenseMatrix":t.referToSelf(e=>(t,i)=>r(...Yd(n(t),i),e)),"DenseMatrix, Array":t.referToSelf(e=>(t,i)=>r(...Yd(t,n(i)),e))},e.SS&&(s[`SparseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.SS(...Yd(n,r),t,!1))),e.DS&&(s[`DenseMatrix, SparseMatrix`]=t.referToSelf(t=>(n,r)=>e.DS(...Yd(n,r),t,!1)),s[`Array, SparseMatrix`]=t.referToSelf(t=>(r,i)=>e.DS(...Yd(n(r),i),t,!1))),o&&(s[`SparseMatrix, DenseMatrix`]=t.referToSelf(e=>(t,n)=>o(...Yd(n,t),e,!0)),s[`SparseMatrix, Array`]=t.referToSelf(e=>(t,r)=>o(...Yd(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&&Jr(s,a.signatures),s}}),Qd=`mod`,$d=J(Qd,[`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=Wd({typed:t,config:n,round:r,matrix:i,equalScalar:a,zeros:o,DenseMatrix:s}),u=Gd({typed:t,equalScalar:a}),d=Kd({typed:t}),f=qd({typed:t,equalScalar:a}),p=Sd({typed:t,equalScalar:a}),m=Cd({typed:t,DenseMatrix:s}),h=Zd({typed:t,matrix:i,concat:c});return t(Qd,{"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 Ms(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})}}),tf=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 Ms(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})}}),nf=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 rf(e,t,n,r){if(!(this instanceof rf))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}rf.prototype=Error(),rf.prototype.constructor=Error,rf.prototype.name=`ArgumentsError`,rf.prototype.isArgumentsError=!0;var af=`gcd`,of=[`typed`,`config`,`round`,`matrix`,`equalScalar`,`zeros`,`BigNumber`,`DenseMatrix`,`concat`],sf=`number | BigNumber | Fraction | Matrix | Array`,cf=`${sf}, ${sf}, ...${sf}`;function lf(e){return!e.some(e=>Array.isArray(e))}var uf=J(af,of,e=>{var{typed:t,matrix:n,config:r,round:i,equalScalar:a,zeros:o,BigNumber:s,DenseMatrix:c,concat:l}=e,u=$d({typed:t,config:r,round:i,matrix:n,equalScalar:a,zeros:o,DenseMatrix:c,concat:l}),d=ef({typed:t}),f=tf({typed:t,equalScalar:a}),p=nf({typed:t,DenseMatrix:c}),m=Zd({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}),{[cf]: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])&&lf(t[0]))return e(...t[0]);if(lf(t))return e(...t);throw new rf(`gcd() supports only 1d matrices!`)}),Matrix:t.referToSelf(e=>t=>e(t.toArray()))});function h(e,t){if(!fi(e)||!fi(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}}),df=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 Ms(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(Ac(e,C,x,b,S,w,v,g),Ac(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})}}),ff=`lcm`,pf=J(ff,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=Gd({typed:t,equalScalar:r}),o=df({typed:t,equalScalar:r}),s=Sd({typed:t,equalScalar:r}),c=Zd({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(ff,{"number, number":qc,"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 mf(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 hf=`log10`,gf=[`typed`,`config`,`Complex`],_f=Yc(16),vf=J(hf,gf,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(hf,{number:function(e){return e>=0||n.predictable?Yc(e):a(e)},bigint:mf(_f,Yc,n,a),Complex:i,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log():a(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),yf=`log2`,bf=J(yf,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;function i(e){return a(new r(e,0))}return t(yf,{number:function(e){return e>=0||n.predictable?Xc(e):i(e)},bigint:mf(4,Xc,n,i),Complex:a,BigNumber:function(e){return!e.isNegative()||n.predictable?e.log(2):i(e.toNumber())},"Array | Matrix":t.referToSelf(e=>t=>Dc(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)}}),xf=J(`multiplyScalar`,[`typed`],e=>{var{typed:t}=e;return t(`multiplyScalar`,{"number, number":Rc,"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)})}),Sf=`multiply`,Cf=J(Sf,[`typed`,`matrix`,`addScalar`,`multiplyScalar`,`equalScalar`,`dot`],e=>{var{typed:t,matrix:n,addScalar:r,multiplyScalar:i,equalScalar:a,dot:o}=e,s=Sd({typed:t,equalScalar:a}),c=wd({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(Sf,i,{"Array, Array":t.referTo(`Matrix, Matrix`,e=>(t,r)=>{l(Ps(t),Ps(r));var i=e(n(t),n(r));return lr(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})})}),wf=`nthRoot`,Tf=J(wf,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,concat:a}=e,o=ef({typed:t}),s=Gd({typed:t,equalScalar:r}),c=df({typed:t,equalScalar:r}),l=Sd({typed:t,equalScalar:r}),u=Zd({typed:t,matrix:n,concat:a});function d(){throw Error(`Complex number not supported in function nthRoot. Use nthRoots instead.`)}return t(wf,{number:$c,"number, number":$c,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))}}),Ef=`sign`,Df=J(Ef,[`typed`,`BigNumber`,`Fraction`,`complex`],e=>{var{typed:t,BigNumber:n,complex:r,Fraction:i}=e;return t(Ef,{number:el,Complex:function(e){return e.im===0?r(el(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=>Dc(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)})})}),Of=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()}}),kf=`square`,Af=J(kf,[`typed`],e=>{var{typed:t}=e;return t(kf,{number:nl,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)}})}),jf=`subtract`,Mf=J(jf,[`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=Kd({typed:t}),u=qd({typed:t,equalScalar:r}),d=nf({typed:t,DenseMatrix:o}),f=Cd({typed:t,DenseMatrix:o}),p=Zd({typed:t,matrix:n,concat:s});return t(jf,{"any, any":i},p({elop:i,SS:u,DS:c,SD:l,Ss:f,sS:d}))}),Nf=`xgcd`,Pf=J(Nf,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(Nf,{"number, number":function(e,t){var i=rl(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)}}),Ff=`invmod`,If=J(Ff,[`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(Ff,{"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}}),Lf=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 Ms(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})}}),Rf=`dotMultiply`,zf=J(Rf,[`typed`,`matrix`,`equalScalar`,`multiplyScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,multiplyScalar:i,concat:a}=e,o=Gd({typed:t,equalScalar:r}),s=Lf({typed:t,equalScalar:r}),c=Sd({typed:t,equalScalar:r});return t(Rf,Zd({typed:t,matrix:n,concat:a})({elop:i,SS:s,DS:o,Ss:c}))});function Bf(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 Uf(e,t,function(e,t){return e&t})}function Vf(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 Hf(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:Uf(e,t,function(e,t){return e|t})}function Uf(e,t,n){var r=e.constructor,i,a,o=+(e.s<0),s=+(t.s<0);if(o){i=Wf(Vf(e));for(var c=0;c<i.length;++c)i[c]^=1}else i=Wf(e);if(s){a=Wf(Vf(t));for(var l=0;l<a.length;++l)a[l]^=1}else a=Wf(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 Wf(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 Gf(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)?Vf(t):t.eq(r)?Vf(e):!e.isFinite()||!t.isFinite()?!e.isFinite()&&!t.isFinite()?r:new n(e.isNegative()===t.isNegative()?1/0:-1/0):Uf(e,t,function(e,t){return e^t})}function Kf(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 qf(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 Jf=`bitAnd`,Yf=J(Jf,[`typed`,`matrix`,`equalScalar`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,concat:i}=e,a=Gd({typed:t,equalScalar:r}),o=df({typed:t,equalScalar:r}),s=Sd({typed:t,equalScalar:r}),c=Zd({typed:t,matrix:n,concat:i});return t(Jf,{"number, number":ll,"BigNumber, BigNumber":Bf,"bigint, bigint":(e,t)=>e&t},c({SS:o,DS:a,Ss:s}))}),Xf=`bitNot`,Zf=J(Xf,[`typed`],e=>{var{typed:t}=e;return t(Xf,{number:ul,BigNumber:Vf,bigint:e=>~e,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),Qf=`bitOr`,$f=J(Qf,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=ef({typed:t}),s=tf({typed:t,equalScalar:r}),c=nf({typed:t,DenseMatrix:i}),l=Zd({typed:t,matrix:n,concat:a});return t(Qf,{"number, number":dl,"BigNumber, BigNumber":Hf,"bigint, bigint":(e,t)=>e|t},l({SS:s,DS:o,Ss:c}))}),ep=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 Ms(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]}}}),tp=`bitXor`,np=J(tp,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=Kd({typed:t}),s=ep({typed:t,SparseMatrix:a}),c=Cd({typed:t,DenseMatrix:r}),l=Zd({typed:t,matrix:n,concat:i});return t(tp,{"number, number":fl,"BigNumber, BigNumber":Gf,"bigint, bigint":(e,t)=>e^t},l({SS:s,DS:o,Ss:c}))}),rp=`arg`,ip=J(rp,[`typed`],e=>{var{typed:t}=e;return t(rp,{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=>Dc(t,e))})}),ap=`conj`,op=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=>Dc(t,e))})}),sp=`im`,cp=J(sp,[`typed`],e=>{var{typed:t}=e;return t(sp,{number:()=>0,"BigNumber | Fraction":e=>e.mul(0),Complex:e=>e.im,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),lp=`re`,up=J(lp,[`typed`],e=>{var{typed:t}=e;return t(lp,{"number | BigNumber | Fraction":e=>e,Complex:e=>e.re,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),dp=`not`,fp=J(dp,[`typed`],e=>{var{typed:t}=e;return t(dp,{"null | undefined":()=>!0,number:wl,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=>Dc(t,e))})}),pp=`nullish`,mp=J(pp,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=Kd({typed:t}),s=wd({typed:t}),c=Jd({typed:t});return t(pp,{"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 Ms(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())})}),hp=`or`,gp=J(hp,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=Kd({typed:t}),s=qd({typed:t,equalScalar:r}),c=Cd({typed:t,DenseMatrix:i}),l=Zd({typed:t,matrix:n,concat:a});return t(hp,{"number, number":Tl,"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":Tl,"Unit, Unit":t.referToSelf(e=>(t,n)=>e(t.value||0,n.value||0))},l({SS:s,DS:o,Ss:c}))}),_p=`xor`,vp=J(_p,[`typed`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,concat:i,SparseMatrix:a}=e,o=Kd({typed:t}),s=ep({typed:t,SparseMatrix:a}),c=Cd({typed:t,DenseMatrix:r}),l=Zd({typed:t,matrix:n,concat:i});return t(_p,{"number, number":El,"Complex, Complex":function(e,t){return(e.re!==0||e.im!==0)!=(t.re!==0||t.im!==0)},"bigint, bigint":El,"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}))}),yp=`concat`,bp=J(yp,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e;return t(yp,{"...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(lr(l)&&(s=!0),tr(l)||nr(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 Ns(a,o+1)}else{var u=Kr(l).valueOf(),d=Ps(u);if(c[t]=u,o=a,a=d.length-1,t>0&&a!==o)throw new Ms(o+1,a+1)}}if(c.length===0)throw SyntaxError(`At least one matrix expected`);for(var f=c.shift();c.length;)f=oc(f,c.shift(),a);return s?n(f):f},"...string":function(e){return e.join(``)}})}),xp=`column`,Sp=J(xp,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e;return t(xp,{"Matrix, number":a,"Array, number":function(e,t){return a(r(Kr(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);Rs(t,e.size()[1]);var a=new n(i(0,e.size()[0]),[t]),o=e.subset(a);return lr(o)?o:r([[o]])}}),Cp=`count`,wp=J(Cp,[`typed`,`size`,`prod`],e=>{var{typed:t,size:n,prod:r}=e;return t(Cp,{string:function(e){return e.length},"Matrix | Array":function(e){return r(n(e))}})}),Tp=`cross`,Ep=J(Tp,[`typed`,`matrix`,`subtract`,`multiply`],e=>{var{typed:t,matrix:n,subtract:r,multiply:i}=e;return t(Tp,{"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(Ps(e).length,Ps(t).length);e=Ks(e),t=Ks(t);var a=Ps(e),o=Ps(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}}),Dp=`diag`,Op=J(Dp,[`typed`,`matrix`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,DenseMatrix:r,SparseMatrix:i}=e;return t(Dp,{Array:function(e){return a(e,0,Ps(e),null)},"Array, number":function(e,t){return a(e,t,Ps(e),null)},"Array, BigNumber":function(e,t){return a(e,t.toNumber(),Ps(e),null)},"Array, string":function(e,t){return a(e,0,Ps(e),t)},"Array, number, string":function(e,t,n){return a(e,t,Ps(e),n)},"Array, BigNumber, string":function(e,t,n){return a(e,t.toNumber(),Ps(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(!fi(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(lr(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)}}),kp=J(`filter`,[`typed`],e=>{var{typed:t}=e;return t(`filter`,{"Array, function":Ap,"Matrix, function":function(e,t){return e.create(Ap(e.valueOf(),t),e.datatype())},"Array, RegExp":ec,"Matrix, RegExp":function(e,t){return e.create(ec(e.valueOf(),t),e.datatype())}})});function Ap(e,t){var n=hc(t,e,`filter`);return n.isUnary?$s(e,n.fn):$s(e,function(e,t,r){return n.fn(e,[t],r)})}var jp=`flatten`,Mp=J(jp,[`typed`],e=>{var{typed:t}=e;return t(jp,{Array:function(e){return Xs(e)},DenseMatrix:function(e){return e.create(Xs(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())`)}})}),Np=`forEach`,Pp=J(Np,[`typed`],e=>{var{typed:t}=e;return t(Np,{"Array, function":Fp,"Matrix, function":function(e,t){e.forEach(t)}})});function Fp(e,t){var n=hc(t,e,Np);pc(e,n.fn,n.isUnary)}var Ip=`getMatrixDataType`,Lp=J(Ip,[`typed`],e=>{var{typed:t}=e;return t(Ip,{Array:function(e){return ic(e,Gr)},Matrix:function(e){return e.getDataType()}})}),Rp=`identity`,zp=J(Rp,[`typed`,`config`,`matrix`,`BigNumber`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i,DenseMatrix:a,SparseMatrix:o}=e;return t(Rp,{"":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=nr(e)||nr(t)?i:null;if(nr(e)&&(e=e.toNumber()),nr(t)&&(t=t.toNumber()),!fi(e)||e<1||!fi(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=Bs([],l,c),d=e<t?e:t,f=0;f<d;f++)u[f][f]=s;return u}}),Bp=`kron`,Vp=J(Bp,[`typed`,`matrix`,`multiplyScalar`],e=>{var{typed:t,matrix:n,multiplyScalar:r}=e;return t(Bp,{"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=Ps(e).length,o=Ps(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)))}}),Hp=`map`,Up=J(Hp,[`typed`],e=>{var{typed:t}=e;return t(Hp,{"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():Ps(e)),u=sc(...l),d=e.length,f=c?(e,t)=>e.get(t):dc,p=e.map((e,t)=>{var n=l[t].map(()=>0);return e.isMatrix?e.get(n):dc(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(lc(t.toArray(),u),t.datatype()):e[0].create(lc(t.valueOf(),u))):e.map(e=>e.isMatrix?lc(e.toArray(),u):lc(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():Ps(e)),a=sc(...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=hc(t,e,Hp);return fc(e,n.fn,n.isUnary)}}),Wp=`diff`,Gp=J(Wp,[`typed`,`matrix`,`subtract`,`number`],e=>{var{typed:t,matrix:n,subtract:r,number:i}=e;return t(Wp,{"Array | Matrix":function(e){return lr(e)?n(o(e.toArray())):o(e)},"Array | Matrix, number":function(e,t){if(!fi(t))throw RangeError(`Dimension must be a whole number`);return lr(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(lr(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){lr(e)&&(e=e.toArray()),lr(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}}),Kp=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?Bs(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){nr(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!fi(e)||e<0)throw Error(`Parameters in function ones must be positive integers`)})}});function qp(){throw Error(`No "bignumber" implementation available`)}function Jp(){throw Error(`No "fraction" implementation available`)}function Yp(){throw Error(`No "matrix" implementation available`)}var Xp=`range`,Zp=J(Xp,[`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(Xp,{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):Yp():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&&qp(),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}}}),Qp=`reshape`,$p=J(Qp,[`typed`,`isInteger`,`matrix`],e=>{var{typed:t,isInteger:n}=e;return t(Qp,{"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)}),Hs(e,t)}})}),em=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 rf(`resize`,arguments.length,2,3);if(lr(i)&&(i=i.valueOf()),nr(i[0])&&(i=i.map(function(e){return nr(e)?e.toNumber():e})),lr(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 Kr(e)}else{Array.isArray(e)||(e=[e]),e=Kr(e);var s=Bs(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 Ms(t.length,1);var r=t[0];if(typeof r!=`number`||!fi(r))throw TypeError(`Invalid size, must contain positive integers (size: `+ws(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}}),tm=`rotate`,nm=J(tm,[`typed`,`multiply`,`rotationMatrix`],e=>{var{typed:t,multiply:n,rotationMatrix:r}=e;return t(tm,{"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)?Ps(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}`)}}),rm=`rotationMatrix`,im=J(rm,[`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(rm,{"":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=nr(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=nr(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`,om=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(Kr(e)),t).valueOf()}});function a(e,t){if(e.size().length!==2)throw Error(`Only two dimensional matrix is supported`);Rs(t,e.size()[0]);var a=i(0,e.size()[1]),o=new n([t],a),s=e.subset(o);return lr(s)?s:r([[s]])}}),sm=`size`,cm=J(sm,[`typed`],e=>{var{typed:t}=e;return t(sm,{Matrix:e=>e.size(),Array:Ps,string:e=>[e.length],"number | Complex | BigNumber | Unit | boolean | null":e=>[]})}),lm=`squeeze`,um=J(lm,[`typed`],e=>{var{typed:t}=e;return t(lm,{Array:function(e){return Ks(Kr(e))},Matrix:function(e){var t=Ks(e.toArray());return Array.isArray(t)?e.create(t,e.datatype()):t},any:function(e){return Kr(e)}})}),dm=`subset`,fm=J(dm,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e;return t(dm,{"Matrix, Index":function(e,t){return zs(t)?n():(Ls(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":hm,"string, Index":pm,"Matrix, Index, any, any":function(e,t,n,r){return zs(t)?e:(Ls(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":mm,"string, Index, string, string":mm,"Object, Index, any":gm});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 pm(e,t){if(!mr(t))throw TypeError(`Index expected`);if(zs(t))return``;if(Ls(Array.from(e),t),t.size().length!==1)throw new Ms(t.size().length,1);var n=e.length;Rs(t.min()[0],n),Rs(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 mm(e,t,n,r){if(!t||t.isIndex!==!0)throw TypeError(`Index expected`);if(zs(t))return e;if(Ls(Array.from(e),t),t.size().length!==1)throw new Ms(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 Ms(i.size()[0],n.length);var a=e.length;Rs(t.min()[0]),Rs(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 hm(e,t){if(!zs(t)){if(t.size().length!==1)throw new Ms(t.size(),1);var n=t.dimension(0);if(typeof n!=`string`)throw TypeError(`String expected as index to retrieve an object property`);return Bn(e,n)}}function gm(e,t,n){if(zs(t))return e;if(t.size().length!==1)throw new Ms(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=Kr(e);return Vn(i,r,n),i}var _m=`transpose`,vm=J(_m,[`typed`,`matrix`],e=>{var{typed:t,matrix:n}=e;return t(_m,{Array:e=>r(n(e)).valueOf(),Matrix:r,any:Kr});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: `+ws(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: `+ws(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]=Kr(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]=Kr(r[v]))}return e.createSparseMatrix({values:o,index:s,ptr:c,size:[n,t],datatype:e._datatype})}}),ym=`ctranspose`,bm=J(ym,[`typed`,`transpose`,`conj`],e=>{var{typed:t,transpose:n,conj:r}=e;return t(ym,{any:function(e){return r(n(e))}})}),xm=`zeros`,Sm=J(xm,[`typed`,`config`,`matrix`,`BigNumber`],e=>{var{typed:t,config:n,matrix:r,BigNumber:i}=e;return t(xm,{"":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?Bs(c,e,n):c}}function o(e){var t=!1;return e.forEach(function(e,n,r){nr(e)&&(t=!0,r[n]=e.toNumber())}),t}function s(e){e.forEach(function(e){if(typeof e!=`number`||!fi(e)||e<0)throw Error(`Parameters in function zeros must be positive integers`)})}}),Cm=`fft`,wm=J(Cm,[`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(Cm,{Array:m,Matrix:function(e){return e.create(m(e.valueOf()),e.datatype())}});function m(e){var t=Ps(e);return t.length===1?_(e,t[0]):h(e.map(e=>m(e,t.slice(1))),0)}function h(e,t){var n=Ps(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=Ps(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)}}),Tm=`ifft`,Em=J(Tm,[`typed`,`fft`,`dotDivide`,`conj`],e=>{var{typed:t,fft:n,dotDivide:r,conj:i}=e;return t(Tm,{"Array | Matrix":function(e){var t=lr(e)?e.size():Ps(e);return r(i(n(i(e))),t.reduce((e,t)=>e*t,1))}})});function Dm(e){"@babel/helpers - typeof";return Dm=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},Dm(e)}function Om(e,t){if(Dm(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Dm(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function km(e){var t=Om(e,`string`);return Dm(t)==`symbol`?t:t+``}function Am(e,t,n){return(t=km(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function jm(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 Mm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?jm(Object(n),!0).forEach(function(t){Am(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Nm=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(or))))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(or)))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(nr),[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=>or(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=Mm({},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 nr(e)||tr(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]))}}})}),Pm=J(`erf`,[`typed`],e=>{var{typed:t}=e;return t(`name`,{number:function(e){var t=Math.abs(e);return t>=zm?mi(e):t<=Fm?mi(e)*n(t):t<=4?mi(e)*(1-r(t)):mi(e)*(1-i(t))},"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))});function n(e){var t=e*e,n=Lm[0][4]*t,r=t,i;for(i=0;i<3;i+=1)n=(n+Lm[0][i])*t,r=(r+Rm[0][i])*t;return e*(n+Lm[0][3])/(r+Rm[0][3])}function r(e){var t=Lm[1][8]*e,n=e,r;for(r=0;r<7;r+=1)t=(t+Lm[1][r])*e,n=(n+Rm[1][r])*e;var i=(t+Lm[1][7])/(n+Rm[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=Lm[2][5]*t,r=t,i;for(i=0;i<4;i+=1)n=(n+Lm[2][i])*t,r=(r+Rm[2][i])*t;var a=t*(n+Lm[2][4])/(r+Rm[2][4]);a=(Im-a)/e,t=parseInt(e*16)/16;var o=(e-t)*(e+t);return Math.exp(-t*t)*Math.exp(-o)*a}}),Fm=.46875,Im=.5641895835477563,Lm=[[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]],Rm=[[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]],zm=2**53,Bm=`zeta`,Vm=J(Bm,[`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(Bm,{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)}}),Hm=`mode`,Um=J(Hm,[`typed`,`isNaN`,`isNumeric`],e=>{var{typed:t,isNaN:n,isNumeric:r}=e;return t(Hm,{"Array | Matrix":i,"...":function(e){return i(e)}});function i(e){if(e=Xs(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 Wm(e,t,n){var r;return String(e).includes(`Unexpected type`)?(r=arguments.length>2?` (type: `+Gr(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: `+Gr(n)+`, value: `+JSON.stringify(n)+`)`:``,TypeError(`Cannot calculate `+t+`, no ordering relation is defined for complex numbers`+r)):e}var Gm=`prod`,Km=J(Gm,[`typed`,`config`,`multiplyScalar`,`numeric`],e=>{var{typed:t,config:n,multiplyScalar:r,numeric:i}=e;return t(Gm,{"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(Ec(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw Wm(t,`prod`,e)}}),typeof t==`string`&&(t=i(t,pi(t,n))),t===void 0)throw Error(`Cannot calculate prod of an empty array`);return t}}),qm=`format`,Jm=J(qm,[`typed`],e=>{var{typed:t}=e;return t(qm,{any:ws,"any, Object | function | number | BigNumber":ws})}),Ym=`bin`,Xm=J(Ym,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(Ym,{"number | BigNumber":function(e){return n(e,{notation:`bin`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`bin`,wordSize:t})}})}),Zm=`oct`,Qm=J(Zm,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t(Zm,{"number | BigNumber":function(e){return n(e,{notation:`oct`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`oct`,wordSize:t})}})}),$m=`hex`,eh=J($m,[`typed`,`format`],e=>{var{typed:t,format:n}=e;return t($m,{"number | BigNumber":function(e){return n(e,{notation:`hex`})},"number | BigNumber, number | BigNumber":function(e,t){return n(e,{notation:`hex`,wordSize:t})}})}),th=/\$([\w.]+)/g,nh=`print`,rh=J(nh,[`typed`],e=>{var{typed:t}=e;return t(nh,{"string, Object | Array":ih,"string, Object | Array, number | Object":ih})});function ih(e,t,n){return e.replace(th,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:sr(a)?a:ws(a,n)})}var ah=`to`,oh=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)},Zd({typed:t,matrix:n,concat:r})({Ds:!0}))}),sh=`toBest`,ch=J(sh,[`typed`],e=>{var{typed:t}=e;return t(sh,{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)})}),lh=`isPrime`,uh=J(lh,[`typed`],e=>{var{typed:t}=e;return t(lh,{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=>Dc(t,e))})}),dh=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):qp,bigint:e=>BigInt(e),Fraction:r?e=>r(e):Jp};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=Gr(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)}}),fh=`divideScalar`,ph=J(fh,[`typed`,`numeric`],e=>{var{typed:t,numeric:n}=e;return t(fh,{"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)})}),mh=`pow`,hh=J(mh,[`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(mh,{"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&&!fi(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:fi(t)||e>=0||n.predictable?il(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(!fi(t))throw TypeError(`For A^b, b must be an integer (value is `+t+`)`);var n=Ps(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))}}),gh=`Number of decimals in function round must be an integer`,_h=`round`,vh=J(_h,[`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=Sd({typed:t,equalScalar:i}),l=Cd({typed:t,DenseMatrix:s}),u=wd({typed:t});function d(e){return Math.abs(Ci(e).exponent)}return t(_h,{number:function(e){var t=al(e,d(n.relTol));return al(ji(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(ji(e,i,n.relTol,n.absTol)?i:e,t)},"number, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(gh);return new o(e).toDecimalPlaces(t.toNumber())},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw TypeError(gh);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(gh);var n=t.toNumber();return e.round(n)},BigNumber:function(e){var t=new o(e).toDecimalPlaces(d(n.relTol));return(pu(e,t,n.relTol,n.absTol)?t:e).toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(gh);var r=d(n.relTol);if(t>=r)return e.toDecimalPlaces(t.toNumber());var i=e.toDecimalPlaces(r);return(pu(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(gh);return e.round(t)},"Fraction, BigNumber":function(e,t){if(!t.isInteger())throw TypeError(gh);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)=>Dc(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=>Dc(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())})}),yh=`log`,bh=[`config`,`typed`,`typeOf`,`divideScalar`,`Complex`],xh=Math.log(16),Sh=J(yh,bh,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(yh,{number:function(e){return e>=0||r.predictable?Jc(e):s(e)},bigint:mf(xh,Jc,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))})})}),Ch=`log1p`,wh=J(Ch,[`typed`,`config`,`divideScalar`,`log`,`Complex`],e=>{var{typed:t,config:n,divideScalar:r,log:i,Complex:a}=e;return t(Ch,{number:function(e){return e>=-1||n.predictable?_i(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=>Dc(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))}}),Th=`nthRoots`,Eh=J(Th,[`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(Th,{Complex:function(e){return o(e,2)},"Complex, number":o})}),Dh=`dotPow`,Oh=J(Dh,[`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=Kd({typed:t}),l=ep({typed:t,SparseMatrix:s}),u=Sd({typed:t,equalScalar:n}),d=Cd({typed:t,DenseMatrix:a}),f=Zd({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(Dh,f({elop:t(p),SS:l,DS:c,Ss:u,sS:d}))}),kh=`dotDivide`,Ah=J(kh,[`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=Gd({typed:t,equalScalar:r}),l=Kd({typed:t}),u=ep({typed:t,SparseMatrix:s}),d=Sd({typed:t,equalScalar:r}),f=Cd({typed:t,DenseMatrix:a});return t(kh,Zd({typed:t,matrix:n,concat:o})({elop:i,SS:u,DS:l,SD:c,Ss:d,sS:f}))});function jh(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: `+ws(i)+`)`);var a=i[0];if(a!==i[1])throw RangeError(`Matrix must be square (size: `+ws(i)+`)`);var o=[];if(lr(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(dr(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(fr(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(cr(n)){var v=Ps(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 Mh=`lsolve`,Nh=J(Mh,[`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=jh({DenseMatrix:s});return t(Mh,{"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]})}}),Ph=`usolve`,Fh=J(Ph,[`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=jh({DenseMatrix:s});return t(Ph,{"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]})}}),Ih=`lsolveAll`,Lh=J(Ih,[`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=jh({DenseMatrix:s});return t(Ih,{"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]}))}}),Rh=`usolveAll`,zh=J(Rh,[`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=jh({DenseMatrix:s});return t(Rh,{"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]}))}}),Bh=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 Ms(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})}}),Vh=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())}}),Hh=`leftShift`,Uh=J(Hh,[`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=Gd({typed:t,equalScalar:r}),l=Bh({typed:t,equalScalar:r}),u=nf({typed:t,DenseMatrix:a}),d=Sd({typed:t,equalScalar:r}),f=wd({typed:t}),p=Zd({typed:t,matrix:n,concat:o}),m=Vh({typed:t,matrix:n});return t(Hh,{"number, number":pl,"BigNumber, BigNumber":Kf,"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}))}),Wh=`rightArithShift`,Gh=J(Wh,[`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=Gd({typed:t,equalScalar:r}),l=Bh({typed:t,equalScalar:r}),u=nf({typed:t,DenseMatrix:a}),d=Sd({typed:t,equalScalar:r}),f=wd({typed:t}),p=Zd({typed:t,matrix:n,concat:o}),m=Vh({typed:t,matrix:n});return t(Wh,{"number, number":ml,"BigNumber, BigNumber":qf,"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}))}),Kh=`rightLogShift`,qh=J(Kh,[`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=Gd({typed:t,equalScalar:r}),l=Bh({typed:t,equalScalar:r}),u=nf({typed:t,DenseMatrix:a}),d=Sd({typed:t,equalScalar:r}),f=wd({typed:t}),p=Zd({typed:t,matrix:n,concat:o}),m=Vh({typed:t,matrix:n});return t(Kh,{"number, number":hl,"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}))}),Jh=`and`,Yh=J(Jh,[`typed`,`matrix`,`equalScalar`,`zeros`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=Gd({typed:t,equalScalar:r}),c=df({typed:t,equalScalar:r}),l=Sd({typed:t,equalScalar:r}),u=wd({typed:t}),d=Zd({typed:t,matrix:n,concat:o});return t(Jh,{"number, number":Dl,"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":Dl,"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}))}),Xh=`compare`,Zh=J(Xh,[`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=Kd({typed:t}),u=qd({typed:t,equalScalar:r}),d=Cd({typed:t,DenseMatrix:s}),f=Zd({typed:t,matrix:i,concat:c}),p=Nu({typed:t});return t(Xh,Qh({typed:t,config:n}),{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"BigNumber, BigNumber":function(e,t){return pu(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}))}),Qh=J(Xh,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(Xh,{"number, number":function(e,t){return ji(e,t,n.relTol,n.absTol)?0:e>t?1:-1}})}),$h=ft(lt(((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),eg=`compareNatural`,tg=J(eg,[`typed`,`compare`],e=>{var{typed:t,compare:n}=e,r=n.signatures[`boolean,boolean`];return t(eg,{"any, any":i});function i(e,t){var c=Gr(e),l=Gr(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,$h.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,$h.default)(c,l):u;if(c!==l)return(0,$h.default)(c,l);if(c===`Complex`)return ng(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,$h.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 fr(t)&&fr(n)?o(e,t.toJSON().values,n.toJSON().values):fr(t)?a(e,t.toArray(),n):fr(n)?a(e,t,n.toArray()):dr(t)?a(e,t.toJSON().data,n):dr(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($h.default),i.sort($h.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 ng(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 rg=`compareText`,ig=[`typed`,`matrix`,`concat`];js.signature=`any, any`;var ag=J(rg,ig,e=>{var{typed:t,matrix:n,concat:r}=e;return t(rg,js,Zd({typed:t,matrix:n,concat:r})({elop:js,Ds:!0}))}),og=`equal`,sg=J(og,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`SparseMatrix`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=Kd({typed:t}),c=ep({typed:t,SparseMatrix:o}),l=Cd({typed:t,DenseMatrix:i}),u=Zd({typed:t,matrix:n});return t(og,cg({typed:t,equalScalar:r}),u({elop:r,SS:c,DS:s,Ss:l}))}),cg=J(og,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(og,{"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)}})}),lg=`equalText`,ug=J(lg,[`typed`,`compareText`,`isZero`],e=>{var{typed:t,compareText:n,isZero:r}=e;return t(lg,{"any, any":function(e,t){return r(n(e,t))}})}),dg=`smaller`,fg=J(dg,[`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=Kd({typed:t}),l=ep({typed:t,SparseMatrix:s}),u=Cd({typed:t,DenseMatrix:a}),d=Zd({typed:t,matrix:i,concat:o}),f=Nu({typed:t});function p(e,t){return e.lt(t)&&!pu(e,t,n.relTol,n.absTol)}return t(dg,pg({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}))}),pg=J(dg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(dg,{"number, number":function(e,t){return e<t&&!ji(e,t,n.relTol,n.absTol)}})}),mg=`smallerEq`,hg=J(mg,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=Kd({typed:t}),c=ep({typed:t,SparseMatrix:o}),l=Cd({typed:t,DenseMatrix:i}),u=Zd({typed:t,matrix:r,concat:a}),d=Nu({typed:t});return t(mg,gg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e<=t,"BigNumber, BigNumber":function(e,t){return e.lte(t)||pu(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}))}),gg=J(mg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(mg,{"number, number":function(e,t){return e<=t||ji(e,t,n.relTol,n.absTol)}})}),_g=`larger`,vg=J(_g,[`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=Kd({typed:t}),l=ep({typed:t,SparseMatrix:s}),u=Cd({typed:t,DenseMatrix:a}),d=Zd({typed:t,matrix:i,concat:o}),f=Nu({typed:t});function p(e,t){return e.gt(t)&&!pu(e,t,n.relTol,n.absTol)}return t(_g,yg({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}))}),yg=J(_g,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(_g,{"number, number":function(e,t){return e>t&&!ji(e,t,n.relTol,n.absTol)}})}),bg=`largerEq`,xg=J(bg,[`typed`,`config`,`matrix`,`DenseMatrix`,`concat`,`SparseMatrix`],e=>{var{typed:t,config:n,matrix:r,DenseMatrix:i,concat:a,SparseMatrix:o}=e,s=Kd({typed:t}),c=ep({typed:t,SparseMatrix:o}),l=Cd({typed:t,DenseMatrix:i}),u=Zd({typed:t,matrix:r,concat:a}),d=Nu({typed:t});return t(bg,Sg({typed:t,config:n}),{"boolean, boolean":(e,t)=>e>=t,"BigNumber, BigNumber":function(e,t){return e.gte(t)||pu(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}))}),Sg=J(bg,[`typed`,`config`],e=>{var{typed:t,config:n}=e;return t(bg,{"number, number":function(e,t){return e>=t||ji(e,t,n.relTol,n.absTol)}})}),Cg=`deepEqual`,wg=J(Cg,[`typed`,`equal`],e=>{var{typed:t,equal:n}=e;return t(Cg,{"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)}}),Tg=`unequal`,Eg=J(Tg,[`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=Kd({typed:t}),l=ep({typed:t,SparseMatrix:s}),u=Cd({typed:t,DenseMatrix:a}),d=Zd({typed:t,matrix:i,concat:o});return t(Tg,Dg({typed:t,equalScalar:r}),d({elop:f,SS:l,DS:c,Ss:u}));function f(e,t){return!r(e,t)}}),Dg=J(Tg,[`typed`,`equalScalar`],e=>{var{typed:t,equalScalar:n}=e;return t(Tg,{"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)}})}),Og=`partitionSelect`,kg=J(Og,[`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(Og,{"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(!fi(t)||t<0)throw Error(`k must be a non-negative integer`);if(lr(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]}}),Ag=`sort`,jg=J(Ag,[`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(Ag,{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(Ps(e).length!==1)throw Error(`One dimensional array expected`)}function l(e){if(e.size().length!==1)throw Error(`One dimensional matrix expected`)}}),Mg=`max`,Ng=J(Mg,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e;return t(Mg,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Oc(e,t.valueOf(),o)},"...":function(e){if(Tc(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 Wm(e,`max`,t)}}function s(e){var t;if(Ec(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw Wm(t,`max`,e)}}),t===void 0)throw Error(`Cannot calculate max of an empty array`);return typeof t==`string`&&(t=r(t,pi(t,n))),t}}),Pg=`min`,Fg=J(Pg,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e;return t(Pg,{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){return Oc(e,t.valueOf(),o)},"...":function(e){if(Tc(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 Wm(e,`min`,t)}}function s(e){var t;if(Ec(e,function(e){try{(a(e)||t===void 0||i(e,t))&&(t=e)}catch(t){throw Wm(t,`min`,e)}}),t===void 0)throw Error(`Cannot calculate min of an empty array`);return typeof t==`string`&&(t=r(t,pi(t,n))),t}}),Ig=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&&!sr(t))throw Error(`Invalid datatype: `+t);if(lr(e)||cr(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&&cr(e.data)&&cr(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 (`+Gr(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 lr(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:Kr(this._data),size:Kr(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}),Lg=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=cr(a),s=lr(a),c=typeof a,l=null;if(pr(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(Rg(a).valueOf())),s&&(u=i(Rg(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(!tr(e[n])||!fi(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=Kr(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]=sr(r)||tr(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]=sr(r)||tr(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]=sr(r)||tr(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 tr(e)?this._dimensions[e]??null:null},r.prototype.isObjectProperty=function(){return this._dimensions.length===1&&sr(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(sr(r)||tr(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];sr(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 Rg(e){var t=[];return e.forEach((e,n)=>{e&&t.push(n)}),t}var zg=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}),Bg=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 Vg(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 Hg(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:Vg(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 Ug=Hg(function(e){return new e(1).exp()},{hasher:qg}),Wg=Hg(function(e){return new e(1).plus(new e(5).sqrt()).div(2)},{hasher:qg}),Gg=Hg(function(e){return e.acos(-1)},{hasher:qg}),Kg=Hg(function(e){return Gg(e).times(2)},{hasher:qg});function qg(e){return e[0].precision}function Jg(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 Yg(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Jg(Object(n),!0).forEach(function(t){Am(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jg(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Xg=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)||ir(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(or(t)&&t.value===null)this.fixPrefix=t.fixPrefix,this.skipAutomaticSimplification=t.skipAutomaticSimplification,this.dimensions=t.dimensions.slice(0),this.units=t.units.map(e=>Rn({},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=Kr(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])ei(this.units[t],n)&&(e.units[t][n]=this.units[t][n]);return e},x.prototype.valueType=function(){return Gr(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(Gr(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(Gr(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=Hg(e=>{if(ei(H,e)){var t=H[e];return{unit:t,prefix:t.prefixes[``]}}for(var n in H)if(ei(H,n)&&Cs(e,n)){var r=H[n],i=e.length-n.length,a=e.substring(0,i),o=ei(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=or(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=Yg({},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,or(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=or(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=Yg(Yg({},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,or(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(Gr(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(or(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=Kr(t);else{var o=x._getNumberConverter(Gr(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(ei(U,r)&&e.hasBase(V[r])){n=r;break}if(n===`NONE`)e.units=[];else{var i;if(n&&ei(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&&(ei(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(ei(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(!or(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&&ir(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&&ir(e.value)&&(t=Math.abs(e.value.re)<1e-14),e.units)ei(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(ei(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=Rn({},z.SHORT,z.LONG),z.BINARY_SHORT=Rn({},z.BINARY_SHORT_SI,z.BINARY_SHORT_IEC),z.BINARY_LONG=Rn({},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)ei(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=Gg(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(ei(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(ei(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(ei(H,ae)){var oe=H[ae];oe.dimensions=oe.base.dimensions}for(var se in ne)if(ei(ne,se)){var ce=H[ne[se]],le={};for(var ue in ce)ei(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(ei(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)ei(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(ei(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(ei(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(ei(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)ei(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)ei(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}),Zg=`unit`,Qg=J(Zg,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(Zg,{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=>Dc(t,e))})}),$g=`sparse`,e_=J($g,[`typed`,`SparseMatrix`],e=>{var{typed:t,SparseMatrix:n}=e;return t($g,{"":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)}})}),t_=`createUnit`,n_=J(t_,[`typed`,`Unit`],e=>{var{typed:t,Unit:n}=e;return t(t_,{"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,{})}})}),r_=`acos`,i_=J(r_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(r_,{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`,o_=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?Ll(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()}})}),s_=`acot`,c_=J(s_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(s_,{number:Rl,Complex:function(e){return e.acot()},BigNumber:function(e){return new n(1).div(e).atan()}})}),l_=`acoth`,u_=J(l_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(l_,{number:function(e){return e>=1||e<=-1||n.predictable?zl(e):new r(e,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(e){return new i(1).div(e).atanh()}})}),d_=`acsc`,f_=J(d_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(d_,{number:function(e){return e<=-1||e>=1||n.predictable?Bl(e):new r(e,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(e){return new i(1).div(e).asin()}})}),p_=`acsch`,m_=J(p_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(p_,{number:Vl,Complex:function(e){return e.acsch()},BigNumber:function(e){return new n(1).div(e).asinh()}})}),h_=`asec`,g_=J(h_,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(h_,{number:function(e){return e<=-1||e>=1||n.predictable?Hl(e):new r(e,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(e){return new i(1).div(e).acos()}})}),__=`asech`,v_=J(__,[`typed`,`config`,`Complex`,`BigNumber`],e=>{var{typed:t,config:n,Complex:r,BigNumber:i}=e;return t(__,{number:function(e){if(e<=1&&e>=-1||n.predictable){var t=1/e;if(t>0||n.predictable)return Ul(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()}})}),y_=`asin`,b_=J(y_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(y_,{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()}})}),x_=J(`asinh`,[`typed`],e=>{var{typed:t}=e;return t(`asinh`,{number:Gl,Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()}})}),S_=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()}})}),C_=`atan2`,w_=J(C_,[`typed`,`matrix`,`equalScalar`,`BigNumber`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,BigNumber:i,DenseMatrix:a,concat:o}=e,s=Gd({typed:t,equalScalar:r}),c=Kd({typed:t}),l=Lf({typed:t,equalScalar:r}),u=Sd({typed:t,equalScalar:r}),d=Cd({typed:t,DenseMatrix:a}),f=Zd({typed:t,matrix:n,concat:o});return t(C_,{"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}))}),T_=`atanh`,E_=J(T_,[`typed`,`config`,`Complex`],e=>{var{typed:t,config:n,Complex:r}=e;return t(T_,{number:function(e){return e<=1&&e>=-1||n.predictable?Jl(e):new r(e,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()}})}),D_=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)})}}),O_=`cos`,k_=J(O_,[`typed`],e=>{var{typed:t}=e,n=D_({typed:t});return t(O_,{number:Math.cos,"Complex | BigNumber":e=>e.cos()},n)}),A_=`cosh`,j_=J(A_,[`typed`],e=>{var{typed:t}=e;return t(A_,{number:Fi,"Complex | BigNumber":e=>e.cosh()})}),M_=`cot`,N_=J(M_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=D_({typed:t});return t(M_,{number:Zl,Complex:e=>e.cot(),BigNumber:e=>new n(1).div(e.tan())},r)}),P_=`coth`,F_=J(P_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(P_,{number:Ql,Complex:e=>e.coth(),BigNumber:e=>new n(1).div(e.tanh())})}),I_=`csc`,L_=J(I_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=D_({typed:t});return t(I_,{number:$l,Complex:e=>e.csc(),BigNumber:e=>new n(1).div(e.sin())},r)}),R_=`csch`,z_=J(R_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(R_,{number:eu,Complex:e=>e.csch(),BigNumber:e=>new n(1).div(e.sinh())})}),B_=`sec`,V_=J(B_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e,r=D_({typed:t});return t(B_,{number:tu,Complex:e=>e.sec(),BigNumber:e=>new n(1).div(e.cos())},r)}),H_=`sech`,U_=J(H_,[`typed`,`BigNumber`],e=>{var{typed:t,BigNumber:n}=e;return t(H_,{number:nu,Complex:e=>e.sech(),BigNumber:e=>new n(1).div(e.cosh())})}),W_=`sin`,G_=J(W_,[`typed`],e=>{var{typed:t}=e,n=D_({typed:t});return t(W_,{number:Math.sin,"Complex | BigNumber":e=>e.sin()},n)}),K_=`sinh`,q_=J(K_,[`typed`],e=>{var{typed:t}=e;return t(K_,{number:iu,"Complex | BigNumber":e=>e.sinh()})}),J_=`tan`,Y_=J(J_,[`typed`],e=>{var{typed:t}=e,n=D_({typed:t});return t(J_,{number:Math.tan,"Complex | BigNumber":e=>e.tan()},n)}),X_=J(`tanh`,[`typed`],e=>{var{typed:t}=e;return t(`tanh`,{number:Li,"Complex | BigNumber":e=>e.tanh()})}),Z_=`setCartesian`,Q_=J(Z_,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(Z_,{"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=Xs(Array.isArray(e)?e:e.toArray()).sort(i),l=Xs(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)}})}),$_=`setDifference`,ev=J($_,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t($_,{"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 Xs(e.toArray());else{var c=nc(Xs(Array.isArray(e)?e:e.toArray()).sort(i)),l=nc(Xs(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)?rc(s):new o(rc(s))}})}),tv=`setDistinct`,nv=J(tv,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(tv,{"Array | Matrix":function(e){var t;if(r(n(e),new a(0))===0)t=[];else{var s=Xs(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)}})}),rv=`setIntersect`,iv=J(rv,[`typed`,`size`,`subset`,`compareNatural`,`Index`,`DenseMatrix`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a,DenseMatrix:o}=e;return t(rv,{"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=nc(Xs(Array.isArray(e)?e:e.toArray()).sort(i)),l=nc(Xs(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)?rc(s):new o(rc(s))}})}),av=`setIsSubset`,ov=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=nc(Xs(Array.isArray(e)?e:e.toArray()).sort(i)),s=nc(Xs(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}})}),sv=`setMultiplicity`,cv=J(sv,[`typed`,`size`,`subset`,`compareNatural`,`Index`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(sv,{"number | BigNumber | Fraction | Complex, Array | Matrix":function(e,t){if(r(n(t),new a(0))===0)return 0;for(var o=Xs(Array.isArray(t)?t:t.toArray()),s=0,c=0;c<o.length;c++)i(o[c],e)===0&&s++;return s}})}),lv=`setPowerset`,uv=J(lv,[`typed`,`size`,`subset`,`compareNatural`,`Index`],e=>{var{typed:t,size:n,subset:r,compareNatural:i,Index:a}=e;return t(lv,{"Array | Matrix":function(e){if(r(n(e),new a(0))===0)return[];for(var t=Xs(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}}),dv=`setSize`,fv=J(dv,[`typed`,`compareNatural`],e=>{var{typed:t,compareNatural:n}=e;return t(dv,{"Array | Matrix":function(e){return Array.isArray(e)?Xs(e).length:Xs(e.toArray()).length},"Array | Matrix, boolean":function(e,t){if(t===!1||e.length===0)return Array.isArray(e)?Xs(e).length:Xs(e.toArray()).length;for(var r=Xs(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}})}),pv=`setSymDifference`,mv=J(pv,[`typed`,`size`,`concat`,`subset`,`setDifference`,`Index`],e=>{var{typed:t,size:n,concat:r,subset:i,setDifference:a,Index:o}=e;return t(pv,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new o(0))===0)return Xs(t);if(i(n(t),new o(0))===0)return Xs(e);var s=Xs(e),c=Xs(t);return r(a(s,c),a(c,s))}})}),hv=`setUnion`,gv=J(hv,[`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(hv,{"Array | Matrix, Array | Matrix":function(e,t){if(i(n(e),new s(0))===0)return Xs(t);if(i(n(t),new s(0))===0)return Xs(e);var c=Xs(e),l=Xs(t);return r(o(c,l),a(c,l))}})}),_v=`add`,vv=J(_v,[`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=tf({typed:t,equalScalar:i}),u=nf({typed:t,DenseMatrix:a}),d=Zd({typed:t,matrix:n,concat:s});return t(_v,{"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}))}),yv=`hypot`,bv=J(yv,[`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(yv,{"... number | BigNumber":l,Array:l,Matrix:e=>l(Xs(e.toArray(),!0))});function l(e){for(var t=0,l=0,u=0;u<e.length;u++){if(ir(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))}}),xv=`norm`,Sv=J(xv,[`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(xv,{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`)}}}),Cv=`dot`,wv=J(Cv,[`typed`,`addScalar`,`multiplyScalar`,`conj`,`size`],e=>{var{typed:t,addScalar:n,multiplyScalar:r,conj:i,size:a}=e;return t(Cv,{"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=lr(e)?e._data:e,u=lr(e)?e._datatype||e.getDataType():void 0,d=lr(s)?s._data:s,f=lr(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}}),Tv=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:Kr});function i(e){var t=e._size,n=e._data;switch(t.length){case 1:if(t[0]===1)return Kr(n[0]);throw RangeError(`Matrix must be square (size: `+ws(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: `+ws(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+ws(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: `+ws(a)+`)`)}}),Ev=`index`,Dv=J(Ev,[`typed`,`Index`],e=>{var{typed:t,Index:n}=e;return t(Ev,{"...number | string | BigNumber | Range | Array | Matrix":function(e){var t=e.map(function(e){return nr(e)?e.toNumber():cr(e)||lr(e)?e.map(function(e){return nr(e)?e.toNumber():e}):e}),r=new n;return n.apply(r,t),r}})}),Ov=new Set([`end`]),kv=J(`Node`,[`mathWithTransform`],e=>{var{mathWithTransform:t}=e;function n(e){for(var t of[...Ov])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=$n(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(!Lr(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&&Xr(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 Av(e){return e&&e.isIndexError?new Ns(e.index+1,e.min+1,e.max===void 0?void 0:e.max+1):e}function jv(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 Bn(e,n.getObjectProperty())}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Av(e)}}}var Mv=`AccessorNode`,Nv=J(Mv,[`subset`,`Node`],e=>{var{subset:t,Node:n}=e,r=jv({subset:t});function i(e){return!(Dr(e)||Or(e)||Mr(e)||Fr(e)||Rr(e)||Br(e)||Ur(e))}class a extends n{constructor(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(super(),!Lr(e))throw TypeError(`Node expected for parameter "object"`);if(!Ir(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 Mv}get isAccessorNode(){return!0}_compile(e,t){var n=this.object._compile(e,t),i=this.index._compile(e,t),a=this.optionalChaining,o=Dr(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 Bn(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:Mv,object:this.object,index:this.index,optionalChaining:this.optionalChaining}}static fromJSON(e){return new a(e.object,e.index,e.optionalChaining)}}return Am(a,`name`,Mv),a},{isClass:!0,isNode:!0}),Pv=`ArrayNode`,Fv=J(Pv,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.items=e||[],!Array.isArray(this.items)||!this.items.every(Lr))throw TypeError(`Array containing Nodes expected`)}get type(){return Pv}get isArrayNode(){return!0}_compile(e,t){var n=Zs(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(Zs(n,function(n){return n(e,t,i)}))}}else return function(e,t,r){return Zs(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:Pv,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(Or)&&!n.every(Or),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 Am(n,`name`,Pv),n},{isClass:!0,isNode:!0});function Iv(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 Vn(e,r.getObjectProperty(),i),e}else throw TypeError(`Cannot apply index: unsupported type of object`)}catch(e){throw Av(e)}}}var Lv=[{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 Rv(e,t){if(!t||t!==`auto`)return e;for(var n=e;Br(n);)n=n.content;return n}function zv(e,t,n,r){var i=e;t!==`keep`&&(i=e.getContent());for(var a=i.getIdentifier(),o=null,s=0;s<Lv.length;s++)if(a in Lv[s]){o=s;break}if(a===`OperatorNode:multiply`&&i.implicit&&n!==`show`){var c=Rv(i.args[0],t);!(Mr(c)&&r&&r.getIdentifier()===`OperatorNode:divide`&&Nr(Rv(r.args[0],t)))&&!(c.getIdentifier()===`OperatorNode:divide`&&Nr(Rv(c.args[0],t))&&Mr(Rv(c.args[1])))&&(o+=1)}return o}function Bv(e,t){var n=e;t!==`keep`&&(n=e.getContent());var r=n.getIdentifier(),i=zv(n,t);if(i===null)return null;var a=Lv[i][r];if(ei(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 Vv(e,t,n){var r=n===`keep`?e:e.getContent(),i=n===`keep`?t:e.getContent(),a=r.getIdentifier(),o=i.getIdentifier(),s=zv(r,n);if(s===null)return null;var c=Lv[s][a];if(ei(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 Hv(e){var t=`OperatorNode:`+e;for(var n of Lv)if(t in n)return n[t].op;return null}var Uv=`AssignmentNode`,Wv=J(Uv,[`subset`,`?matrix`,`Node`],e=>{var{subset:t,matrix:n,Node:r}=e,i=jv({subset:t}),a=Iv({subset:t,matrix:n});function o(e,t,n){t||=`keep`;var r=zv(e,t,n),i=zv(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,!Ur(e)&&!Dr(e))throw TypeError(`SymbolNode or AccessorNode expected as "object"`);if(Ur(e)&&e.name===`end`)throw Error(`Cannot assign to symbol "end"`);if(this.index&&!Ir(this.index))throw TypeError(`IndexNode expected as "index"`);if(!Lr(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 Uv}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(!Ur(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 Vn(i,c,a),a}}else if(Ur(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=Bn(i,u),c=r(e,t,s),d=o(e,t,n);return Vn(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:Uv,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 Am(s,`name`,Uv),s},{isClass:!0,isNode:!0}),Gv=`BlockNode`,Kv=J(Gv,[`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(!Lr(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 Gv}get isBlockNode(){return!0}_compile(e,n){var r=Zs(this.blocks,function(t){return{evaluate:t.node._compile(e,n),visible:t.visible}});return function(e,n,i){var a=[];return Qs(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(`
6
+ `)}toJSON(){return{mathjs:Gv,blocks:this.blocks}}static fromJSON(e){return new r(e.blocks)}_toHTML(e){return this.blocks.map(function(t){return t.node.toHTML(e)+(t.visible?``:`<span class="math-separator">;</span>`)}).join(`<span class="math-separator"><br /></span>`)}_toTex(e){return this.blocks.map(function(t){return t.node.toTex(e)+(t.visible?``:`;`)}).join(`\\;\\;
7
+ `)}}return Am(r,`name`,Gv),r},{isClass:!0,isNode:!0}),qv=`ConditionalNode`,Jv=J(qv,[`Node`],e=>{var{Node:t}=e;function n(e){if(typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return!!e;if(e){if(nr(e))return!e.isZero();if(ir(e))return!!(e.re||e.im);if(or(e))return!!e.value}if(e==null)return!1;throw TypeError(`Unsupported type of condition "`+Gr(e)+`"`)}class r extends t{constructor(e,t,n){if(super(),!Lr(e))throw TypeError(`Parameter condition must be a Node`);if(!Lr(t))throw TypeError(`Parameter trueExpr must be a Node`);if(!Lr(n))throw TypeError(`Parameter falseExpr must be a Node`);this.condition=e,this.trueExpr=t,this.falseExpr=n}get type(){return qv}get isConditionalNode(){return!0}_compile(e,t){var r=this.condition._compile(e,t),i=this.trueExpr._compile(e,t),a=this.falseExpr._compile(e,t);return function(e,t,o){return n(r(e,t,o))?i(e,t,o):a(e,t,o)}}forEach(e){e(this.condition,`condition`,this),e(this.trueExpr,`trueExpr`,this),e(this.falseExpr,`falseExpr`,this)}map(e){return new r(this._ifNode(e(this.condition,`condition`,this)),this._ifNode(e(this.trueExpr,`trueExpr`,this)),this._ifNode(e(this.falseExpr,`falseExpr`,this)))}clone(){return new r(this.condition,this.trueExpr,this.falseExpr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=zv(this,t,e&&e.implicit),r=this.condition.toString(e),i=zv(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`(`+r+`)`);var a=this.trueExpr.toString(e),o=zv(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`(`+a+`)`);var s=this.falseExpr.toString(e),c=zv(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`(`+s+`)`),r+` ? `+a+` : `+s}toJSON(){return{mathjs:qv,condition:this.condition,trueExpr:this.trueExpr,falseExpr:this.falseExpr}}static fromJSON(e){return new r(e.condition,e.trueExpr,e.falseExpr)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=zv(this,t,e&&e.implicit),r=this.condition.toHTML(e),i=zv(this.condition,t,e&&e.implicit);(t===`all`||this.condition.type===`OperatorNode`||i!==null&&i<=n)&&(r=`<span class="math-parenthesis math-round-parenthesis">(</span>`+r+`<span class="math-parenthesis math-round-parenthesis">)</span>`);var a=this.trueExpr.toHTML(e),o=zv(this.trueExpr,t,e&&e.implicit);(t===`all`||this.trueExpr.type===`OperatorNode`||o!==null&&o<=n)&&(a=`<span class="math-parenthesis math-round-parenthesis">(</span>`+a+`<span class="math-parenthesis math-round-parenthesis">)</span>`);var s=this.falseExpr.toHTML(e),c=zv(this.falseExpr,t,e&&e.implicit);return(t===`all`||this.falseExpr.type===`OperatorNode`||c!==null&&c<=n)&&(s=`<span class="math-parenthesis math-round-parenthesis">(</span>`+s+`<span class="math-parenthesis math-round-parenthesis">)</span>`),r+`<span class="math-operator math-conditional-operator">?</span>`+a+`<span class="math-operator math-conditional-operator">:</span>`+s}_toTex(e){return`\\begin{cases} {`+this.trueExpr.toTex(e)+`}, &\\quad{\\text{if }\\;`+this.condition.toTex(e)+`}\\\\{`+this.falseExpr.toTex(e)+`}, &\\quad{\\text{otherwise}}\\end{cases}`}}return Am(r,`name`,qv),r},{isClass:!0,isNode:!0}),Yv=ft(lt(((e,t)=>{var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},r={"{":`\\{`,"}":`\\}`,"\\":`\\textbackslash{}`,"#":`\\#`,$:`\\$`,"%":`\\%`,"&":`\\&`,"^":`\\textasciicircum{}`,_:`\\_`,"~":`\\textasciitilde{}`},i={"–":`\\--`,"—":`\\---`," ":`~`," ":`\\qquad{}`,"\r\n":`\\newline{}`,"\n":`\\newline{}`},a=function(e,t){return n({},e,t)};t.exports=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=t.preserveFormatting,s=o===void 0?!1:o,c=t.escapeMapFn,l=c===void 0?a:c,u=String(e),d=``,f=l(n({},r),s?n({},i):{}),p=Object.keys(f),m=function(){var e=!1;p.forEach(function(t,n){e||u.length>=t.length&&u.slice(0,t.length)===t&&(d+=f[p[n]],u=u.slice(t.length,u.length),e=!0)}),e||(d+=u.slice(0,1),u=u.slice(1,u.length))};u;)m();return d}}))(),1),Xv={Alpha:`A`,alpha:`\\alpha`,Beta:`B`,beta:`\\beta`,Gamma:`\\Gamma`,gamma:`\\gamma`,Delta:`\\Delta`,delta:`\\delta`,Epsilon:`E`,epsilon:`\\epsilon`,varepsilon:`\\varepsilon`,Zeta:`Z`,zeta:`\\zeta`,Eta:`H`,eta:`\\eta`,Theta:`\\Theta`,theta:`\\theta`,vartheta:`\\vartheta`,Iota:`I`,iota:`\\iota`,Kappa:`K`,kappa:`\\kappa`,varkappa:`\\varkappa`,Lambda:`\\Lambda`,lambda:`\\lambda`,Mu:`M`,mu:`\\mu`,Nu:`N`,nu:`\\nu`,Xi:`\\Xi`,xi:`\\xi`,Omicron:`O`,omicron:`o`,Pi:`\\Pi`,pi:`\\pi`,varpi:`\\varpi`,Rho:`P`,rho:`\\rho`,varrho:`\\varrho`,Sigma:`\\Sigma`,sigma:`\\sigma`,varsigma:`\\varsigma`,Tau:`T`,tau:`\\tau`,Upsilon:`\\Upsilon`,upsilon:`\\upsilon`,Phi:`\\Phi`,phi:`\\phi`,varphi:`\\varphi`,Chi:`X`,chi:`\\chi`,Psi:`\\Psi`,psi:`\\psi`,Omega:`\\Omega`,omega:`\\omega`,true:`\\mathrm{True}`,false:`\\mathrm{False}`,i:`i`,inf:`\\infty`,Inf:`\\infty`,infinity:`\\infty`,Infinity:`\\infty`,oo:`\\infty`,lim:`\\lim`,undefined:`\\mathbf{?}`},Zv={transpose:`^\\top`,ctranspose:`^H`,factorial:`!`,pow:`^`,dotPow:`.^\\wedge`,unaryPlus:`+`,unaryMinus:`-`,bitNot:`\\~`,not:`\\neg`,multiply:`\\cdot`,divide:`\\frac`,dotMultiply:`.\\cdot`,dotDivide:`.:`,mod:`\\mod`,add:`+`,subtract:`-`,to:`\\rightarrow`,leftShift:`<<`,rightArithShift:`>>`,rightLogShift:`>>>`,equal:`=`,unequal:`\\neq`,smaller:`<`,larger:`>`,smallerEq:`\\leq`,largerEq:`\\geq`,bitAnd:`\\&`,bitXor:`\\underline{|}`,bitOr:`|`,and:`\\wedge`,xor:`\\veebar`,or:`\\vee`},Qv={abs:{1:"\\left|${args[0]}\\right|"},add:{2:`\\left(\${args[0]}${Zv.add}\${args[1]}\\right)`},cbrt:{1:"\\sqrt[3]{${args[0]}}"},ceil:{1:"\\left\\lceil${args[0]}\\right\\rceil"},cube:{1:"\\left(${args[0]}\\right)^3"},divide:{2:"\\frac{${args[0]}}{${args[1]}}"},dotDivide:{2:`\\left(\${args[0]}${Zv.dotDivide}\${args[1]}\\right)`},dotMultiply:{2:`\\left(\${args[0]}${Zv.dotMultiply}\${args[1]}\\right)`},dotPow:{2:`\\left(\${args[0]}${Zv.dotPow}\${args[1]}\\right)`},exp:{1:"\\exp\\left(${args[0]}\\right)"},expm1:`\\left(e${Zv.pow}{\${args[0]}}-1\\right)`,fix:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},floor:{1:"\\left\\lfloor${args[0]}\\right\\rfloor"},fraction:{2:"\\frac{${args[0]}}{${args[1]}}"},gcd:"\\gcd\\left(${args}\\right)",hypot:"\\hypot\\left(${args}\\right)",log:{1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},log10:{1:"\\log_{10}\\left(${args[0]}\\right)"},log1p:{1:"\\ln\\left(${args[0]}+1\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}+1\\right)"},log2:"\\log_{2}\\left(${args[0]}\\right)",mod:{2:`\\left(\${args[0]}${Zv.mod}\${args[1]}\\right)`},multiply:{2:`\\left(\${args[0]}${Zv.multiply}\${args[1]}\\right)`},norm:{1:"\\left\\|${args[0]}\\right\\|",2:void 0},nthRoot:{2:"\\sqrt[${args[1]}]{${args[0]}}"},nthRoots:{2:"\\{y : y^${args[1]} = {${args[0]}}\\}"},pow:{2:`\\left(\${args[0]}\\right)${Zv.pow}{\${args[1]}}`},round:{1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},sign:{1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},sqrt:{1:"\\sqrt{${args[0]}}"},square:{1:"\\left(${args[0]}\\right)^2"},subtract:{2:`\\left(\${args[0]}${Zv.subtract}\${args[1]}\\right)`},unaryMinus:{1:`${Zv.unaryMinus}\\left(\${args[0]}\\right)`},unaryPlus:{1:`${Zv.unaryPlus}\\left(\${args[0]}\\right)`},bitAnd:{2:`\\left(\${args[0]}${Zv.bitAnd}\${args[1]}\\right)`},bitNot:{1:Zv.bitNot+"\\left(${args[0]}\\right)"},bitOr:{2:`\\left(\${args[0]}${Zv.bitOr}\${args[1]}\\right)`},bitXor:{2:`\\left(\${args[0]}${Zv.bitXor}\${args[1]}\\right)`},leftShift:{2:`\\left(\${args[0]}${Zv.leftShift}\${args[1]}\\right)`},rightArithShift:{2:`\\left(\${args[0]}${Zv.rightArithShift}\${args[1]}\\right)`},rightLogShift:{2:`\\left(\${args[0]}${Zv.rightLogShift}\${args[1]}\\right)`},bellNumbers:{1:"\\mathrm{B}_{${args[0]}}"},catalan:{1:"\\mathrm{C}_{${args[0]}}"},stirlingS2:{2:"\\mathrm{S}\\left(${args}\\right)"},arg:{1:"\\arg\\left(${args[0]}\\right)"},conj:{1:"\\left(${args[0]}\\right)^*"},im:{1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},re:{1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},and:{2:`\\left(\${args[0]}${Zv.and}\${args[1]}\\right)`},not:{1:Zv.not+"\\left(${args[0]}\\right)"},or:{2:`\\left(\${args[0]}${Zv.or}\${args[1]}\\right)`},xor:{2:`\\left(\${args[0]}${Zv.xor}\${args[1]}\\right)`},cross:{2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},ctranspose:{1:`\\left(\${args[0]}\\right)${Zv.ctranspose}`},det:{1:"\\det\\left(${args[0]}\\right)"},dot:{2:"\\left(${args[0]}\\cdot${args[1]}\\right)"},expm:{1:"\\exp\\left(${args[0]}\\right)"},inv:{1:"\\left(${args[0]}\\right)^{-1}"},pinv:{1:"\\left(${args[0]}\\right)^{+}"},sqrtm:{1:`{\${args[0]}}${Zv.pow}{\\frac{1}{2}}`},trace:{1:"\\mathrm{tr}\\left(${args[0]}\\right)"},transpose:{1:`\\left(\${args[0]}\\right)${Zv.transpose}`},combinations:{2:"\\binom{${args[0]}}{${args[1]}}"},combinationsWithRep:{2:"\\left(\\!\\!{\\binom{${args[0]}}{${args[1]}}}\\!\\!\\right)"},factorial:{1:`\\left(\${args[0]}\\right)${Zv.factorial}`},gamma:{1:"\\Gamma\\left(${args[0]}\\right)"},lgamma:{1:"\\ln\\Gamma\\left(${args[0]}\\right)"},equal:{2:`\\left(\${args[0]}${Zv.equal}\${args[1]}\\right)`},larger:{2:`\\left(\${args[0]}${Zv.larger}\${args[1]}\\right)`},largerEq:{2:`\\left(\${args[0]}${Zv.largerEq}\${args[1]}\\right)`},smaller:{2:`\\left(\${args[0]}${Zv.smaller}\${args[1]}\\right)`},smallerEq:{2:`\\left(\${args[0]}${Zv.smallerEq}\${args[1]}\\right)`},unequal:{2:`\\left(\${args[0]}${Zv.unequal}\${args[1]}\\right)`},erf:{1:"erf\\left(${args[0]}\\right)"},max:"\\max\\left(${args}\\right)",min:"\\min\\left(${args}\\right)",variance:"\\mathrm{Var}\\left(${args}\\right)",acos:{1:"\\cos^{-1}\\left(${args[0]}\\right)"},acosh:{1:"\\cosh^{-1}\\left(${args[0]}\\right)"},acot:{1:"\\cot^{-1}\\left(${args[0]}\\right)"},acoth:{1:"\\coth^{-1}\\left(${args[0]}\\right)"},acsc:{1:"\\csc^{-1}\\left(${args[0]}\\right)"},acsch:{1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},asec:{1:"\\sec^{-1}\\left(${args[0]}\\right)"},asech:{1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},asin:{1:"\\sin^{-1}\\left(${args[0]}\\right)"},asinh:{1:"\\sinh^{-1}\\left(${args[0]}\\right)"},atan:{1:"\\tan^{-1}\\left(${args[0]}\\right)"},atan2:{2:"\\mathrm{atan2}\\left(${args}\\right)"},atanh:{1:"\\tanh^{-1}\\left(${args[0]}\\right)"},cos:{1:"\\cos\\left(${args[0]}\\right)"},cosh:{1:"\\cosh\\left(${args[0]}\\right)"},cot:{1:"\\cot\\left(${args[0]}\\right)"},coth:{1:"\\coth\\left(${args[0]}\\right)"},csc:{1:"\\csc\\left(${args[0]}\\right)"},csch:{1:"\\mathrm{csch}\\left(${args[0]}\\right)"},sec:{1:"\\sec\\left(${args[0]}\\right)"},sech:{1:"\\mathrm{sech}\\left(${args[0]}\\right)"},sin:{1:"\\sin\\left(${args[0]}\\right)"},sinh:{1:"\\sinh\\left(${args[0]}\\right)"},tan:{1:"\\tan\\left(${args[0]}\\right)"},tanh:{1:"\\tanh\\left(${args[0]}\\right)"},to:{2:`\\left(\${args[0]}${Zv.to}\${args[1]}\\right)`},numeric:function(e,t){return e.args[0].toTex()},number:{0:`0`,1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},string:{0:`\\mathtt{""}`,1:"\\mathrm{string}\\left(${args[0]}\\right)"},bignumber:{0:`0`,1:"\\left(${args[0]}\\right)"},bigint:{0:`0`,1:"\\left(${args[0]}\\right)"},complex:{0:`0`,1:"\\left(${args[0]}\\right)",2:`\\left(\\left(\${args[0]}\\right)+${Xv.i}\\cdot\\left(\${args[1]}\\right)\\right)`},matrix:{0:`\\begin{bmatrix}\\end{bmatrix}`,1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},sparse:{0:`\\begin{bsparse}\\end{bsparse}`,1:"\\left(${args[0]}\\right)"},unit:{1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"}},$v="\\mathrm{${name}}\\left(${args}\\right)",ey={deg:`^\\circ`};function ty(e){return(0,Yv.default)(e,{preserveFormatting:!0})}function ny(e,t){return t=t===void 0?!1:t,t?ei(ey,e)?ey[e]:`\\mathrm{`+ty(e)+`}`:ei(Xv,e)?Xv[e]:ty(e)}var ry=`ConstantNode`,iy=J(ry,[`Node`,`isBounded`],e=>{var{Node:t,isBounded:n}=e;class r extends t{constructor(e){super(),this.value=e}get type(){return ry}get isConstantNode(){return!0}_compile(e,t){var n=this.value;return function(){return n}}forEach(e){}map(e){return this.clone()}clone(){return new r(this.value)}_toString(e){return ws(this.value,e)}_toHTML(e){var t=this._toString(e);switch(Gr(this.value)){case`number`:case`bigint`:case`BigNumber`:case`Fraction`:return`<span class="math-number">`+t+`</span>`;case`string`:return`<span class="math-string">`+t+`</span>`;case`boolean`:return`<span class="math-boolean">`+t+`</span>`;case`null`:return`<span class="math-null-symbol">`+t+`</span>`;case`undefined`:return`<span class="math-undefined">`+t+`</span>`;default:return`<span class="math-symbol">`+t+`</span>`}}toJSON(){return{mathjs:ry,value:this.value}}static fromJSON(e){return new r(e.value)}_toTex(e){var t=this._toString(e);switch(Gr(this.value)){case`string`:return`\\mathtt{`+ty(t)+`}`;case`number`:case`BigNumber`:if(!n(this.value))return this.value.valueOf()<0?`-\\infty`:`\\infty`;var r=t.toLowerCase().indexOf(`e`);return r===-1?t:t.substring(0,r)+`\\cdot10^{`+t.substring(r+1)+`}`;case`bigint`:return t.toString();case`Fraction`:return this.value.toLatex();default:return t}}}return Am(r,`name`,ry),r},{isClass:!0,isNode:!0}),ay=`FunctionAssignmentNode`,oy=J(ay,[`typed`,`Node`],e=>{var{typed:t,Node:n}=e;function r(e,t,n){var r=zv(e,t,n),i=zv(e.expr,t,n);return t===`all`||i!==null&&i<=r}class i extends n{constructor(e,t,n){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);if(!Array.isArray(t))throw TypeError(`Array containing strings or objects expected for parameter "params"`);if(!Lr(n))throw TypeError(`Node expected for parameter "expr"`);if(Ov.has(e))throw Error(`Illegal function name, "`+e+`" is a reserved keyword`);var r=new Set;for(var i of t){var a=typeof i==`string`?i:i.name;if(r.has(a))throw Error(`Duplicate parameter name "${a}"`);r.add(a)}this.name=e,this.params=t.map(function(e){return e&&e.name||e}),this.types=t.map(function(e){return e&&e.type||`any`}),this.expr=n}get type(){return ay}get isFunctionAssignmentNode(){return!0}_compile(e,n){var r=Object.create(n);Qs(this.params,function(e){r[e]=!0});var i=this.expr,a=i._compile(e,r),o=this.name,s=this.params,c=tc(this.types,`,`),l=o+`(`+tc(this.params,`, `)+`)`;return function(e,n,r){var u={};u[c]=function(){for(var t=Object.create(n),i=0;i<s.length;i++)t[s[i]]=arguments[i];return a(e,t,r)};var d=t(o,u);return d.syntax=l,d.expr=i.toString(),e.set(o,d),d}}forEach(e){e(this.expr,`expr`,this)}map(e){var t=this._ifNode(e(this.expr,`expr`,this));return new i(this.name,this.params.slice(0),t)}clone(){return new i(this.name,this.params.slice(0),this.expr)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toString(e);return r(this,t,e&&e.implicit)&&(n=`(`+n+`)`),this.name+`(`+this.params.join(`, `)+`) = `+n}toJSON(){var e=this.types;return{mathjs:ay,name:this.name,params:this.params.map(function(t,n){return{name:t,type:e[n]}}),expr:this.expr}}static fromJSON(e){return new i(e.name,e.params,e.expr)}_toHTML(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=[],i=0;i<this.params.length;i++)n.push(`<span class="math-symbol math-parameter">`+Os(this.params[i])+`</span>`);var a=this.expr.toHTML(e);return r(this,t,e&&e.implicit)&&(a=`<span class="math-parenthesis math-round-parenthesis">(</span>`+a+`<span class="math-parenthesis math-round-parenthesis">)</span>`),`<span class="math-function">`+Os(this.name)+`</span><span class="math-parenthesis math-round-parenthesis">(</span>`+n.join(`<span class="math-separator">,</span>`)+`<span class="math-parenthesis math-round-parenthesis">)</span><span class="math-operator math-assignment-operator math-variable-assignment-operator math-binary-operator">=</span>`+a}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=this.expr.toTex(e);return r(this,t,e&&e.implicit)&&(n=`\\left(${n}\\right)`),`\\mathrm{`+this.name+`}\\left(`+this.params.map(ny).join(`,`)+`\\right)=`+n}}return Am(i,`name`,ay),i},{isClass:!0,isNode:!0}),sy=`IndexNode`,cy=J(sy,[`Node`,`size`],e=>{var{Node:t,size:n}=e;class r extends t{constructor(e,t){if(super(),this.dimensions=e,this.dotNotation=t||!1,!Array.isArray(e)||!e.every(Lr))throw TypeError(`Array containing Nodes expected for parameter "dimensions"`);if(this.dotNotation&&!this.isObjectProperty())throw Error(`dotNotation only applicable for object properties`)}get type(){return sy}get isIndexNode(){return!0}_compile(e,t){var r=Zs(this.dimensions,function(r,i){if(r.filter(e=>e.isSymbolNode&&e.name===`end`).length>0){var a=Object.create(t);a.end=!0;var o=r._compile(e,a);return function(e,t,r){if(!lr(r)&&!cr(r)&&!sr(r))throw TypeError(`Cannot resolve "end": context must be a Matrix, Array, or string but is `+Gr(r));var a=n(r),s=Object.create(t);return s.end=a[i],o(e,s,r)}}else return r._compile(e,t)}),i=Bn(e,`index`);return function(e,t,n){return i(...Zs(r,function(r){return r(e,t,n)}))}}forEach(e){for(var t=0;t<this.dimensions.length;t++)e(this.dimensions[t],`dimensions[`+t+`]`,this)}map(e){for(var t=[],n=0;n<this.dimensions.length;n++)t[n]=this._ifNode(e(this.dimensions[n],`dimensions[`+n+`]`,this));return new r(t,this.dotNotation)}clone(){return new r(this.dimensions.slice(0),this.dotNotation)}isObjectProperty(){return this.dimensions.length===1&&Mr(this.dimensions[0])&&typeof this.dimensions[0].value==`string`}getObjectProperty(){return this.isObjectProperty()?this.dimensions[0].value:null}_toString(e){return this.dotNotation?`.`+this.getObjectProperty():`[`+this.dimensions.join(`, `)+`]`}toJSON(){return{mathjs:sy,dimensions:this.dimensions,dotNotation:this.dotNotation}}static fromJSON(e){return new r(e.dimensions,e.dotNotation)}_toHTML(e){for(var t=[],n=0;n<this.dimensions.length;n++)t[n]=this.dimensions[n].toHTML();return this.dotNotation?`<span class="math-operator math-accessor-operator">.</span><span class="math-symbol math-property">`+Os(this.getObjectProperty())+`</span>`:`<span class="math-parenthesis math-square-parenthesis">[</span>`+t.join(`<span class="math-separator">,</span>`)+`<span class="math-parenthesis math-square-parenthesis">]</span>`}_toTex(e){var t=this.dimensions.map(function(t){return t.toTex(e)});return this.dotNotation?`.`+this.getObjectProperty():`_{`+t.join(`,`)+`}`}}return Am(r,`name`,sy),r},{isClass:!0,isNode:!0}),ly=`ObjectNode`,uy=J(ly,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),this.properties=e||{},e&&(typeof e!=`object`||!Object.keys(e).every(function(t){return Lr(e[t])})))throw TypeError(`Object containing Nodes expected`)}get type(){return ly}get isObjectNode(){return!0}_compile(e,t){var n={};for(var r in this.properties)if(ei(this.properties,r)){var i=Es(r),a=JSON.parse(i);n[a]=Bn(this.properties,r)._compile(e,t)}return function(e,t,r){var i={};for(var a in n)ei(n,a)&&(i[a]=n[a](e,t,r));return i}}forEach(e){for(var t in this.properties)ei(this.properties,t)&&e(this.properties[t],`properties[`+Es(t)+`]`,this)}map(e){var t={};for(var r in this.properties)ei(this.properties,r)&&(t[r]=this._ifNode(e(this.properties[r],`properties[`+Es(r)+`]`,this)));return new n(t)}clone(){var e={};for(var t in this.properties)ei(this.properties,t)&&(e[t]=this.properties[t]);return new n(e)}_toString(e){var t=[];for(var n in this.properties)ei(this.properties,n)&&t.push(Es(n)+`: `+this.properties[n].toString(e));return`{`+t.join(`, `)+`}`}toJSON(){return{mathjs:ly,properties:this.properties}}static fromJSON(e){return new n(e.properties)}_toHTML(e){var t=[];for(var n in this.properties)ei(this.properties,n)&&t.push(`<span class="math-symbol math-property">`+Os(n)+`</span><span class="math-operator math-assignment-operator math-property-assignment-operator math-binary-operator">:</span>`+this.properties[n].toHTML(e));return`<span class="math-parenthesis math-curly-parenthesis">{</span>`+t.join(`<span class="math-separator">,</span>`)+`<span class="math-parenthesis math-curly-parenthesis">}</span>`}_toTex(e){var t=[];for(var n in this.properties)ei(this.properties,n)&&t.push(`\\mathbf{`+n+`:} & `+this.properties[n].toTex(e)+`\\\\`);return`\\left\\{\\begin{array}{ll}`+t.join(`
8
+ `)+`\\end{array}\\right\\}`}}return Am(n,`name`,ly),n},{isClass:!0,isNode:!0});function dy(e,t){return new Xn(e,new Yn(t),new Set(Object.keys(t)))}var fy=`OperatorNode`,py=J(fy,[`Node`],e=>{var{Node:t}=e;function n(e,t){var r=e;if(t===`auto`)for(;Br(r);)r=r.content;return Mr(r)?!0:zr(r)?n(r.args[0],t):!1}function r(e,t,r,i,a){var o=zv(e,t,r),s=Bv(e,t);if(t===`all`||i.length>2&&e.getIdentifier()!==`OperatorNode:add`&&e.getIdentifier()!==`OperatorNode:multiply`)return i.map(function(e){switch(e.getContent().type){case`ArrayNode`:case`ConstantNode`:case`SymbolNode`:case`ParenthesisNode`:return!1;default:return!0}});var c;switch(i.length){case 0:c=[];break;case 1:var l=zv(i[0],t,r,e);if(a&&l!==null){var u,d;if(t===`keep`?(u=i[0].getIdentifier(),d=e.getIdentifier()):(u=i[0].getContent().getIdentifier(),d=e.getContent().getIdentifier()),Lv[o][d].latexLeftParens===!1){c=[!1];break}if(Lv[l][u].latexParens===!1){c=[!1];break}}if(l===null){c=[!1];break}if(l<=o){c=[!0];break}c=[!1];break;case 2:var f,p=zv(i[0],t,r,e),m=Vv(e,i[0],t);f=p===null?!1:p===o&&s===`right`&&!m?!0:p<o;var h,g=zv(i[1],t,r,e),_=Vv(e,i[1],t);if(h=g===null?!1:g===o&&s===`left`&&!_?!0:g<o,a){var v,y,b;t===`keep`?(v=e.getIdentifier(),y=e.args[0].getIdentifier(),b=e.args[1].getIdentifier()):(v=e.getContent().getIdentifier(),y=e.args[0].getContent().getIdentifier(),b=e.args[1].getContent().getIdentifier()),p!==null&&(Lv[o][v].latexLeftParens===!1&&(f=!1),Lv[p][y].latexParens===!1&&(f=!1)),g!==null&&(Lv[o][v].latexRightParens===!1&&(h=!1),Lv[g][b].latexParens===!1&&(h=!1))}c=[f,h];break;default:(e.getIdentifier()===`OperatorNode:add`||e.getIdentifier()===`OperatorNode:multiply`)&&(c=i.map(function(n){var i=zv(n,t,r,e),a=Vv(e,n,t),c=Bv(n,t);return i===null?!1:o===i&&s===c&&!a?!0:i<o}));break}if(i.length>=2&&e.getIdentifier()===`OperatorNode:multiply`&&e.implicit&&t!==`all`&&r===`hide`)for(var x=1;x<c.length;++x)n(i[x],t)&&!c[x-1]&&(t!==`keep`||!Br(i[x-1]))&&(c[x]=!0);return c}class i extends t{constructor(e,t,n,r,i){if(super(),typeof e!=`string`)throw TypeError(`string expected for parameter "op"`);if(typeof t!=`string`)throw TypeError(`string expected for parameter "fn"`);if(!Array.isArray(n)||!n.every(Lr))throw TypeError(`Array containing Nodes expected for parameter "args"`);this.implicit=r===!0,this.isPercentage=i===!0,this.op=e,this.fn=t,this.args=n||[]}get type(){return fy}get isOperatorNode(){return!0}_compile(e,t){if(typeof this.fn!=`string`||!Kn(e,this.fn))throw e[this.fn]?Error(`No access to function "`+this.fn+`"`):Error(`Function `+this.fn+` missing in provided namespace "math"`);var n=Bn(e,this.fn),r=Zs(this.args,function(n){return n._compile(e,t)});if(typeof n==`function`&&n.rawArgs===!0){var i=this.args;return function(t,r,a){return n(i,e,dy(t,r))}}else if(r.length===1){var a=r[0];return function(e,t,r){return n(a(e,t,r))}}else if(r.length===2){var o=r[0],s=r[1];return function(e,t,r){return n(o(e,t,r),s(e,t,r))}}else return function(e,t,i){return n.apply(null,Zs(r,function(n){return n(e,t,i)}))}}forEach(e){for(var t=0;t<this.args.length;t++)e(this.args[t],`args[`+t+`]`,this)}map(e){for(var t=[],n=0;n<this.args.length;n++)t[n]=this._ifNode(e(this.args[n],`args[`+n+`]`,this));return new i(this.op,this.fn,t,this.implicit,this.isPercentage)}clone(){return new i(this.op,this.fn,this.args.slice(0),this.implicit,this.isPercentage)}isUnary(){return this.args.length===1}isBinary(){return this.args.length===2}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=Bv(this,t),s=i[0].toString(e);a[0]&&(s=`(`+s+`)`);var c=/[a-zA-Z]+/.test(this.op);return o===`right`?this.op+(c?` `:``)+s:o===`left`?s+(c?` `:``)+this.op:s+this.op}else if(i.length===2){var l=i[0].toString(e),u=i[1].toString(e);return a[0]&&(l=`(`+l+`)`),a[1]&&(u=`(`+u+`)`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?l+` `+u:l+` `+this.op+` `+u}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var d=i.map(function(t,n){return t=t.toString(e),a[n]&&(t=`(`+t+`)`),t});return this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?d.join(` `):d.join(` `+this.op+` `)}else return this.fn+`(`+this.args.join(`, `)+`)`}toJSON(){return{mathjs:fy,op:this.op,fn:this.fn,args:this.args,implicit:this.implicit,isPercentage:this.isPercentage}}static fromJSON(e){return new i(e.op,e.fn,e.args,e.implicit,e.isPercentage)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!1);if(i.length===1){var o=Bv(this,t),s=i[0].toHTML(e);return a[0]&&(s=`<span class="math-parenthesis math-round-parenthesis">(</span>`+s+`<span class="math-parenthesis math-round-parenthesis">)</span>`),o===`right`?`<span class="math-operator math-unary-operator math-lefthand-unary-operator">`+Os(this.op)+`</span>`+s:s+`<span class="math-operator math-unary-operator math-righthand-unary-operator">`+Os(this.op)+`</span>`}else if(i.length===2){var c=i[0].toHTML(e),l=i[1].toHTML(e);return a[0]&&(c=`<span class="math-parenthesis math-round-parenthesis">(</span>`+c+`<span class="math-parenthesis math-round-parenthesis">)</span>`),a[1]&&(l=`<span class="math-parenthesis math-round-parenthesis">(</span>`+l+`<span class="math-parenthesis math-round-parenthesis">)</span>`),this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?c+`<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>`+l:c+`<span class="math-operator math-binary-operator math-explicit-binary-operator">`+Os(this.op)+`</span>`+l}else{var u=i.map(function(t,n){return t=t.toHTML(e),a[n]&&(t=`<span class="math-parenthesis math-round-parenthesis">(</span>`+t+`<span class="math-parenthesis math-round-parenthesis">)</span>`),t});return i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)?this.implicit&&this.getIdentifier()===`OperatorNode:multiply`&&n===`hide`?u.join(`<span class="math-operator math-binary-operator math-implicit-binary-operator"></span>`):u.join(`<span class="math-operator math-binary-operator math-explicit-binary-operator">`+Os(this.op)+`</span>`):`<span class="math-function">`+Os(this.fn)+`</span><span class="math-paranthesis math-round-parenthesis">(</span>`+u.join(`<span class="math-separator">,</span>`)+`<span class="math-paranthesis math-round-parenthesis">)</span>`}}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,n=e&&e.implicit?e.implicit:`hide`,i=this.args,a=r(this,t,n,i,!0),o=Zv[this.fn];if(o=o===void 0?this.op:o,i.length===1){var s=Bv(this,t),c=i[0].toTex(e);return a[0]&&(c=`\\left(${c}\\right)`),s===`right`?o+c:c+o}else if(i.length===2){var l=i[0],u=l.toTex(e);a[0]&&(u=`\\left(${u}\\right)`);var d=i[1].toTex(e);a[1]&&(d=`\\left(${d}\\right)`);var f=t===`keep`?l.getIdentifier():l.getContent().getIdentifier();switch(this.getIdentifier()){case`OperatorNode:divide`:return o+`{`+u+`}{`+d+`}`;case`OperatorNode:pow`:switch(u=`{`+u+`}`,d=`{`+d+`}`,f){case`ConditionalNode`:case`OperatorNode:divide`:u=`\\left(${u}\\right)`}break;case`OperatorNode:multiply`:if(this.implicit&&n===`hide`)return u+`~`+d}return u+o+d}else if(i.length>2&&(this.getIdentifier()===`OperatorNode:add`||this.getIdentifier()===`OperatorNode:multiply`)){var p=i.map(function(t,n){return t=t.toTex(e),a[n]&&(t=`\\left(${t}\\right)`),t});return this.getIdentifier()===`OperatorNode:multiply`&&this.implicit&&n===`hide`?p.join(`~`):p.join(o)}else return`\\mathrm{`+this.fn+`}\\left(`+i.map(function(t){return t.toTex(e)}).join(`,`)+`\\right)`}getIdentifier(){return this.type+`:`+this.fn}}return Am(i,`name`,fy),i},{isClass:!0,isNode:!0}),my=`ParenthesisNode`,hy=J(my,[`Node`],e=>{var{Node:t}=e;class n extends t{constructor(e){if(super(),!Lr(e))throw TypeError(`Node expected for parameter "content"`);this.content=e}get type(){return my}get isParenthesisNode(){return!0}_compile(e,t){return this.content._compile(e,t)}getContent(){return this.content.getContent()}forEach(e){e(this.content,`content`,this)}map(e){return new n(e(this.content,`content`,this))}clone(){return new n(this.content)}_toString(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`(`+this.content.toString(e)+`)`:this.content.toString(e)}toJSON(){return{mathjs:my,content:this.content}}static fromJSON(e){return new n(e.content)}_toHTML(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`<span class="math-parenthesis math-round-parenthesis">(</span>`+this.content.toHTML(e)+`<span class="math-parenthesis math-round-parenthesis">)</span>`:this.content.toHTML(e)}_toTex(e){return!e||e&&!e.parenthesis||e&&e.parenthesis===`keep`?`\\left(${this.content.toTex(e)}\\right)`:this.content.toTex(e)}}return Am(n,`name`,my),n},{isClass:!0,isNode:!0}),gy=`RangeNode`,_y=J(gy,[`Node`],e=>{var{Node:t}=e;function n(e,t,n){var r=zv(e,t,n),i={},a=zv(e.start,t,n);if(i.start=a!==null&&a<=r||t===`all`,e.step){var o=zv(e.step,t,n);i.step=o!==null&&o<=r||t===`all`}var s=zv(e.end,t,n);return i.end=s!==null&&s<=r||t===`all`,i}class r extends t{constructor(e,t,n){if(super(),!Lr(e)||!Lr(t)||n&&!Lr(n))throw TypeError(`Node expected`);if(arguments.length>3)throw Error(`Too many arguments`);this.start=e,this.end=t,this.step=n||null}get type(){return gy}get isRangeNode(){return!0}needsEnd(){return this.filter(function(e){return Ur(e)&&e.name===`end`}).length>0}_compile(e,t){var n=e.range,r=this.start._compile(e,t),i=this.end._compile(e,t);if(this.step){var a=this.step._compile(e,t);return function(e,t,o){return n(r(e,t,o),i(e,t,o),a(e,t,o))}}else return function(e,t,a){return n(r(e,t,a),i(e,t,a))}}forEach(e){e(this.start,`start`,this),e(this.end,`end`,this),this.step&&e(this.step,`step`,this)}map(e){return new r(this._ifNode(e(this.start,`start`,this)),this._ifNode(e(this.end,`end`,this)),this.step&&this._ifNode(e(this.step,`step`,this)))}clone(){return new r(this.start,this.end,this.step&&this.step)}_toString(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toString(e);if(r.start&&(a=`(`+a+`)`),i=a,this.step){var o=this.step.toString(e);r.step&&(o=`(`+o+`)`),i+=`:`+o}var s=this.end.toString(e);return r.end&&(s=`(`+s+`)`),i+=`:`+s,i}toJSON(){return{mathjs:gy,start:this.start,end:this.end,step:this.step}}static fromJSON(e){return new r(e.start,e.end,e.step)}_toHTML(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i,a=this.start.toHTML(e);if(r.start&&(a=`<span class="math-parenthesis math-round-parenthesis">(</span>`+a+`<span class="math-parenthesis math-round-parenthesis">)</span>`),i=a,this.step){var o=this.step.toHTML(e);r.step&&(o=`<span class="math-parenthesis math-round-parenthesis">(</span>`+o+`<span class="math-parenthesis math-round-parenthesis">)</span>`),i+=`<span class="math-operator math-range-operator">:</span>`+o}var s=this.end.toHTML(e);return r.end&&(s=`<span class="math-parenthesis math-round-parenthesis">(</span>`+s+`<span class="math-parenthesis math-round-parenthesis">)</span>`),i+=`<span class="math-operator math-range-operator">:</span>`+s,i}_toTex(e){var t=e&&e.parenthesis?e.parenthesis:`keep`,r=n(this,t,e&&e.implicit),i=this.start.toTex(e);if(r.start&&(i=`\\left(${i}\\right)`),this.step){var a=this.step.toTex(e);r.step&&(a=`\\left(${a}\\right)`),i+=`:`+a}var o=this.end.toTex(e);return r.end&&(o=`\\left(${o}\\right)`),i+=`:`+o,i}}return Am(r,`name`,gy),r},{isClass:!0,isNode:!0}),vy=`RelationalNode`,yy=J(vy,[`Node`],e=>{var{Node:t}=e,n={equal:`==`,unequal:`!=`,smaller:`<`,larger:`>`,smallerEq:`<=`,largerEq:`>=`};class r extends t{constructor(e,t){if(super(),!Array.isArray(e))throw TypeError(`Parameter conditionals must be an array`);if(!Array.isArray(t))throw TypeError(`Parameter params must be an array`);if(e.length!==t.length-1)throw TypeError(`Parameter params must contain exactly one more element than parameter conditionals`);this.conditionals=e,this.params=t}get type(){return vy}get isRelationalNode(){return!0}_compile(e,t){var n=this,r=this.params.map(n=>n._compile(e,t));return function(t,i,a){for(var o,s=r[0](t,i,a),c=0;c<n.conditionals.length;c++)if(o=s,s=r[c+1](t,i,a),!Bn(e,n.conditionals[c])(o,s))return!1;return!0}}forEach(e){this.params.forEach((t,n)=>e(t,`params[`+n+`]`,this),this)}map(e){return new r(this.conditionals.slice(),this.params.map((t,n)=>this._ifNode(e(t,`params[`+n+`]`,this)),this))}clone(){return new r(this.conditionals,this.params)}_toString(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=zv(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=zv(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`(`+n.toString(e)+`)`:n.toString(e)}),a=i[0],o=0;o<this.conditionals.length;o++)a+=` `+n[this.conditionals[o]],a+=` `+i[o+1];return a}toJSON(){return{mathjs:vy,conditionals:this.conditionals,params:this.params}}static fromJSON(e){return new r(e.conditionals,e.params)}_toHTML(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,r=zv(this,t,e&&e.implicit),i=this.params.map(function(n,i){var a=zv(n,t,e&&e.implicit);return t===`all`||a!==null&&a<=r?`<span class="math-parenthesis math-round-parenthesis">(</span>`+n.toHTML(e)+`<span class="math-parenthesis math-round-parenthesis">)</span>`:n.toHTML(e)}),a=i[0],o=0;o<this.conditionals.length;o++)a+=`<span class="math-operator math-binary-operator math-explicit-binary-operator">`+Os(n[this.conditionals[o]])+`</span>`+i[o+1];return a}_toTex(e){for(var t=e&&e.parenthesis?e.parenthesis:`keep`,n=zv(this,t,e&&e.implicit),r=this.params.map(function(r,i){var a=zv(r,t,e&&e.implicit);return t===`all`||a!==null&&a<=n?`\\left(`+r.toTex(e)+`\right)`:r.toTex(e)}),i=r[0],a=0;a<this.conditionals.length;a++)i+=Zv[this.conditionals[a]]+r[a+1];return i}}return Am(r,`name`,vy),r},{isClass:!0,isNode:!0}),by=J(`SymbolNode`,[`math`,`?Unit`,`Node`],e=>{var{math:t,Unit:n,Node:r}=e;function i(e){return n?n.isValuelessUnit(e):!1}class a extends r{constructor(e){if(super(),typeof e!=`string`)throw TypeError(`String expected for parameter "name"`);this.name=e}get type(){return`SymbolNode`}get isSymbolNode(){return!0}_compile(e,t){var r=this.name;if(t[r]===!0)return function(e,t,n){return Bn(t,r)};if(r in e)return function(t,n,i){return t.has(r)?t.get(r):Bn(e,r)};var o=i(r);return function(e,t,i){return e.has(r)?e.get(r):o?new n(null,r):a.onUndefinedSymbol(r)}}forEach(e){}map(e){return this.clone()}static onUndefinedSymbol(e){throw Error(`Undefined symbol `+e)}clone(){return new a(this.name)}_toString(e){return this.name}_toHTML(e){var t=Os(this.name);return t===`true`||t===`false`?`<span class="math-symbol math-boolean">`+t+`</span>`:t===`i`?`<span class="math-symbol math-imaginary-symbol">`+t+`</span>`:t===`Infinity`?`<span class="math-symbol math-infinity-symbol">`+t+`</span>`:t===`NaN`?`<span class="math-symbol math-nan-symbol">`+t+`</span>`:t===`null`?`<span class="math-symbol math-null-symbol">`+t+`</span>`:t===`undefined`?`<span class="math-symbol math-undefined-symbol">`+t+`</span>`:`<span class="math-symbol">`+t+`</span>`}toJSON(){return{mathjs:`SymbolNode`,name:this.name}}static fromJSON(e){return new a(e.name)}_toTex(e){var n=!1;t[this.name]===void 0&&i(this.name)&&(n=!0);var r=ny(this.name,n);return r[0]===`\\`?r:` `+r}}return a},{isClass:!0,isNode:!0}),xy=`FunctionNode`,Sy=J(xy,[`math`,`Node`,`SymbolNode`],e=>{var t,{math:n,Node:r,SymbolNode:i}=e,a=e=>ws(e,{truncate:78});function o(e,t,n){for(var r=``,i=/\$(?:\{([a-z_][a-z_0-9]*)(?:\[([0-9]+)\])?\}|\$)/gi,a=0,o;(o=i.exec(e))!==null;)if(r+=e.substring(a,o.index),a=o.index,o[0]===`$$`)r+=`$`,a++;else{a+=o[0].length;var s=t[o[1]];if(!s)throw ReferenceError(`Template: Property `+o[1]+` does not exist.`);if(o[2]===void 0)switch(typeof s){case`string`:r+=s;break;case`object`:if(Lr(s))r+=s.toTex(n);else if(Array.isArray(s))r+=s.map(function(e,t){if(Lr(e))return e.toTex(n);throw TypeError(`Template: `+o[1]+`[`+t+`] is not a Node.`)}).join(`,`);else throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`);break;default:throw TypeError(`Template: `+o[1]+` has to be a Node, String or array of Nodes`)}else if(Lr(s[o[2]]&&s[o[2]]))r+=s[o[2]].toTex(n);else throw TypeError(`Template: `+o[1]+`[`+o[2]+`] is not a Node.`)}return r+=e.slice(a),r}class s extends r{constructor(e,t,n){if(super(),typeof e==`string`&&(e=new i(e)),!Lr(e))throw TypeError(`Node expected as parameter "fn"`);if(!Array.isArray(t)||!t.every(Lr))throw TypeError(`Array containing Nodes expected for parameter "args"`);var r=typeof n;if(!(r===`undefined`||r===`boolean`))throw TypeError(`optional flag, if specified, must be boolean`);this.fn=e,this.args=t||[],this.optional=!!n}get name(){return this.fn.name||``}get type(){return xy}get isFunctionNode(){return!0}_compile(e,t){var n=this.args.map(n=>n._compile(e,t)),r=this.optional||Dr(this.fn)&&this.fn.optionalChaining;if(Ur(this.fn)){var i=this.fn.name;if(t[i]){var o=this.args;return function(t,s,c){var l=Bn(s,i);if(!(r&&l===void 0)){if(typeof l!=`function`)throw TypeError(`Argument '${i}' was not a function; received: ${a(l)}`);if(l.rawArgs)return l(o,e,dy(t,s));var u=n.map(e=>e(t,s,c));return l.apply(l,u)}}}else{var c=i in e?Bn(e,i):void 0,l=typeof c==`function`&&c.rawArgs===!0,u=t=>{var n;if(t.has(i))n=t.get(i);else if(i in e)n=Bn(e,i);else if(r)n=void 0;else return s.onUndefinedFunction(i);if(typeof n==`function`||r&&n===void 0)return n;throw TypeError(`'${i}' is not a function; its value is:
9
+ ${a(n)}`)};if(l){var d=this.args;return function(t,r,i){var a=u(t);return a.rawArgs===!0?a(d,e,dy(t,r)):a(...n.map(e=>e(t,r,i)))}}else switch(n.length){case 0:return function(e,t,n){var i=u(e);if(!(r&&i===void 0))return i()};case 1:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0];return a(o(e,t,i))}};case 2:return function(e,t,i){var a=u(e);if(!(r&&a===void 0)){var o=n[0],s=n[1];return a(o(e,t,i),s(e,t,i))}};default:return function(e,t,i){var a=u(e);if(!(r&&a===void 0))return a(...n.map(n=>n(e,t,i)))}}}}else if(Dr(this.fn)&&Ir(this.fn.index)&&this.fn.index.isObjectProperty()){var f=this.fn.object._compile(e,t),p=this.fn.index.getObjectProperty(),m=this.args;return function(t,i,a){var o=f(t,i,a);if(!(r&&(o==null||o[p]===void 0))){var s=Gn(o,p);if(s!=null&&s.rawArgs)return s(m,e,dy(t,i));var c=n.map(e=>e(t,i,a));return s.apply(o,c)}}}else{var h=this.fn.toString(),g=this.fn._compile(e,t),_=this.args;return function(t,i,o){var s=g(t,i,o);if(!(r&&s===void 0)){if(typeof s!=`function`)throw TypeError(`Expression '${h}' did not evaluate to a function; value is:
10
+ ${a(s)}`);if(s.rawArgs)return s(_,e,dy(t,i));var c=n.map(e=>e(t,i,o));return s.apply(s,c)}}}}forEach(e){e(this.fn,`fn`,this);for(var t=0;t<this.args.length;t++)e(this.args[t],`args[`+t+`]`,this)}map(e){for(var t=this._ifNode(e(this.fn,`fn`,this)),n=[],r=0;r<this.args.length;r++)n[r]=this._ifNode(e(this.args[r],`args[`+r+`]`,this));return new s(t,n)}clone(){return new s(this.fn,this.args.slice(0))}toString(e){var t,n=this.fn.toString(e);return e&&typeof e.handler==`object`&&ei(e.handler,n)&&(t=e.handler[n](this,e)),t===void 0?super.toString(e):t}_toString(e){var t=this.args.map(function(t){return t.toString(e)});return(Pr(this.fn)?`(`+this.fn.toString(e)+`)`:this.fn.toString(e))+`(`+t.join(`, `)+`)`}toJSON(){return{mathjs:xy,fn:this.fn,args:this.args}}_toHTML(e){var t=this.args.map(function(t){return t.toHTML(e)});return`<span class="math-function">`+Os(this.fn)+`</span><span class="math-paranthesis math-round-parenthesis">(</span>`+t.join(`<span class="math-separator">,</span>`)+`<span class="math-paranthesis math-round-parenthesis">)</span>`}toTex(e){var t;return e&&typeof e.handler==`object`&&ei(e.handler,this.name)&&(t=e.handler[this.name](this,e)),t===void 0?super.toTex(e):t}_toTex(e){var t=this.args.map(function(t){return t.toTex(e)}),r;Qv[this.name]&&(r=Qv[this.name]),n[this.name]&&(typeof n[this.name].toTex==`function`||typeof n[this.name].toTex==`object`||typeof n[this.name].toTex==`string`)&&(r=n[this.name].toTex);var i;switch(typeof r){case`function`:i=r(this,e);break;case`string`:i=o(r,this,e);break;case`object`:switch(typeof r[t.length]){case`function`:i=r[t.length](this,e);break;case`string`:i=o(r[t.length],this,e);break}}return i===void 0?o($v,this,e):i}getIdentifier(){return this.type+`:`+this.name}}return t=s,Am(s,`name`,xy),Am(s,`onUndefinedFunction`,function(e){throw Error(`Undefined function `+e)}),Am(s,`fromJSON`,function(e){return new t(e.fn,e.args)}),s},{isClass:!0,isNode:!0}),Cy=`parse`,wy=J(Cy,[`typed`,`numeric`,`config`,`AccessorNode`,`ArrayNode`,`AssignmentNode`,`BlockNode`,`ConditionalNode`,`ConstantNode`,`FunctionAssignmentNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`RangeNode`,`RelationalNode`,`SymbolNode`],e=>{var{typed:t,numeric:n,config:r,AccessorNode:i,ArrayNode:a,AssignmentNode:o,BlockNode:s,ConditionalNode:c,ConstantNode:l,FunctionAssignmentNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,ParenthesisNode:h,RangeNode:g,RelationalNode:_,SymbolNode:v}=e,y=t(Cy,{string:function(e){return L(e,{})},"Array | Matrix":function(e){return b(e,{})},"string, Object":function(e,t){return L(e,t.nodes===void 0?{}:t.nodes)},"Array | Matrix, Object":b});function b(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.nodes===void 0?{}:t.nodes;return Dc(e,function(e){if(typeof e!=`string`)throw TypeError(`String expected`);return L(e,n)})}var x={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},S={",":!0,"(":!0,")":!0,"[":!0,"]":!0,"{":!0,"}":!0,'"':!0,"'":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"=":!0,":":!0,"?":!0,"?.":!0,"??":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},C={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},w={true:!0,false:!1,null:null,undefined:void 0},T=[`NaN`,`Infinity`],E={'"':`"`,"'":`'`,"\\":`\\`,"/":`/`,b:`\b`,f:`\f`,n:`
11
+ `,r:`\r`,t:` `};function D(){return{extraNodes:{},expression:``,comment:``,index:0,token:``,tokenType:x.NULL,nestingLevel:0,conditionalLevel:null}}function O(e,t){return e.expression.substr(e.index,t)}function k(e){return O(e,1)}function A(e){e.index++}function j(e){return e.expression.charAt(e.index-1)}function M(e){return e.expression.charAt(e.index+1)}function N(e){for(e.tokenType=x.NULL,e.token=``,e.comment=``;;){if(k(e)===`#`)for(;k(e)!==`
12
+ `&&k(e)!==``;)e.comment+=k(e),A(e);if(y.isWhitespace(k(e),e.nestingLevel))A(e);else break}if(k(e)===``){e.tokenType=x.DELIMITER;return}if(k(e)===`
13
+ `&&!e.nestingLevel){e.tokenType=x.DELIMITER,e.token=k(e),A(e);return}var t=k(e),n=O(e,2),r=O(e,3);if(r.length===3&&S[r]){e.tokenType=x.DELIMITER,e.token=r,A(e),A(e),A(e);return}if(n.length===2&&S[n]&&(n!==`?.`||!y.isDigit(e.expression.charAt(e.index+2)))){e.tokenType=x.DELIMITER,e.token=n,A(e),A(e);return}if(S[t]){e.tokenType=x.DELIMITER,e.token=t,A(e);return}if(y.isDigitDot(t)){e.tokenType=x.NUMBER;var i=O(e,2);if(i===`0b`||i===`0o`||i===`0x`){for(e.token+=k(e),A(e),e.token+=k(e),A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`.`)for(e.token+=`.`,A(e);y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);else if(k(e)===`i`)for(e.token+=`i`,A(e);y.isDigit(k(e));)e.token+=k(e),A(e);return}if(k(e)===`.`){if(e.token+=k(e),A(e),!y.isDigit(k(e))){e.tokenType=x.DELIMITER;return}}else{for(;y.isDigit(k(e));)e.token+=k(e),A(e);y.isDecimalMark(k(e),M(e))&&(e.token+=k(e),A(e))}for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(k(e)===`E`||k(e)===`e`){if(y.isDigit(M(e))||M(e)===`-`||M(e)===`+`){if(e.token+=k(e),A(e),(k(e)===`+`||k(e)===`-`)&&(e.token+=k(e),A(e)),!y.isDigit(k(e)))throw Oe(e,`Digit expected, got "`+k(e)+`"`);for(;y.isDigit(k(e));)e.token+=k(e),A(e);if(y.isDecimalMark(k(e),M(e)))throw Oe(e,`Digit expected, got "`+k(e)+`"`)}else if(y.isDecimalMark(M(e),e.expression.charAt(e.index+2)))throw A(e),Oe(e,`Digit expected, got "`+k(e)+`"`)}return}if(y.isAlpha(k(e),j(e),M(e))){for(;y.isAlpha(k(e),j(e),M(e))||y.isDigit(k(e));)e.token+=k(e),A(e);ei(C,e.token)?e.tokenType=x.DELIMITER:e.tokenType=x.SYMBOL;return}for(e.tokenType=x.UNKNOWN;k(e)!==``;)e.token+=k(e),A(e);throw Oe(e,`Syntax error in part "`+e.token+`"`)}function P(e){do N(e);while(e.token===`
14
+ `)}function F(e){e.nestingLevel++}function I(e){e.nestingLevel--}y.isAlpha=function(e,t,n){return y.isValidLatinOrGreek(e)||y.isValidMathSymbol(e,n)||y.isValidMathSymbol(t,e)},y.isValidLatinOrGreek=function(e){return/^[a-zA-Z_$\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},y.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDFCC\uDFCD]$/.test(t)},y.isWhitespace=function(e,t){return e===` `||e===` `||e===`\xA0`||e===`
15
+ `&&t>0},y.isDecimalMark=function(e,t){return e===`.`&&t!==`/`&&t!==`*`&&t!==`^`},y.isDigitDot=function(e){return e>=`0`&&e<=`9`||e===`.`},y.isDigit=function(e){return e>=`0`&&e<=`9`};function L(e,t){var n=D();Rn(n,{expression:e,extraNodes:t}),N(n);var r=R(n);if(n.token!==``)throw n.tokenType===x.DELIMITER?ke(n,`Unexpected operator `+n.token):Oe(n,`Unexpected part "`+n.token+`"`);return r}function R(e){var t,n=[],r;for(e.token!==``&&e.token!==`
16
+ `&&e.token!==`;`&&(t=z(e),e.comment&&(t.comment=e.comment));e.token===`
17
+ `||e.token===`;`;)n.length===0&&t&&(r=e.token!==`;`,n.push({node:t,visible:r})),N(e),e.token!==`
18
+ `&&e.token!==`;`&&e.token!==``&&(t=z(e),e.comment&&(t.comment=e.comment),r=e.token!==`;`,n.push({node:t,visible:r}));return n.length>0?new s(n):(t||(t=new l(void 0),e.comment&&(t.comment=e.comment)),t)}function z(e){var t,n,r,i,a=B(e);if(e.token===`=`){if(Ur(a))return t=a.name,P(e),r=z(e),new o(new v(t),r);if(Dr(a)){if(a.optionalChaining)throw Oe(e,`Cannot assign to optional chain`);return P(e),r=z(e),new o(a.object,a.index,r)}else if(Fr(a)&&Ur(a.fn)&&(i=!0,n=[],t=a.name,a.args.forEach(function(e,t){Ur(e)?n[t]=e.name:i=!1}),i))return P(e),r=z(e),new u(t,n,r);throw Oe(e,`Invalid left hand side of assignment operator =`)}return a}function B(e){for(var t=V(e);e.token===`?`;){var n=e.conditionalLevel;e.conditionalLevel=e.nestingLevel,P(e);var r=t,i=z(e);if(e.token!==`:`)throw Oe(e,`False part of conditional expression expected`);e.conditionalLevel=null,P(e),t=new c(r,i,z(e)),e.conditionalLevel=n}return t}function V(e){for(var t=ee(e);e.token===`or`;)P(e),t=new m(`or`,`or`,[t,ee(e)]);return t}function ee(e){for(var t=te(e);e.token===`xor`;)P(e),t=new m(`xor`,`xor`,[t,te(e)]);return t}function te(e){for(var t=H(e);e.token===`and`;)P(e),t=new m(`and`,`and`,[t,H(e)]);return t}function H(e){for(var t=ne(e);e.token===`|`;)P(e),t=new m(`|`,`bitOr`,[t,ne(e)]);return t}function ne(e){for(var t=re(e);e.token===`^|`;)P(e),t=new m(`^|`,`bitXor`,[t,re(e)]);return t}function re(e){for(var t=ie(e);e.token===`&`;)P(e),t=new m(`&`,`bitAnd`,[t,ie(e)]);return t}function ie(e){for(var t=[U(e)],n=[],r={"==":`equal`,"!=":`unequal`,"<":`smaller`,">":`larger`,"<=":`smallerEq`,">=":`largerEq`};ei(r,e.token);){var i={name:e.token,fn:r[e.token]};n.push(i),P(e),t.push(U(e))}return t.length===1?t[0]:t.length===2?new m(n[0].name,n[0].fn,t):new _(n.map(e=>e.fn),t)}function U(e){for(var t=ae(e),n,r,i,a={"<<":`leftShift`,">>":`rightArithShift`,">>>":`rightLogShift`};ei(a,e.token);)n=e.token,r=a[n],P(e),i=[t,ae(e)],t=new m(n,r,i);return t}function ae(e){for(var t=oe(e),n,r,i,a={to:`to`,in:`to`};ei(a,e.token);)n=e.token,r=a[n],P(e),n===`in`&&`])},;`.includes(e.token)?t=new m(`*`,`multiply`,[t,new v(`in`)],!0):(i=[t,oe(e)],t=new m(n,r,i));return t}function oe(e){var t,n=[];if(e.token===`:`){if(e.conditionalLevel===e.nestingLevel)throw Oe(e,`The true-expression of a conditional operator may not be empty`);t=new l(1)}else t=se(e);if(e.token===`:`&&e.conditionalLevel!==e.nestingLevel){for(n.push(t);e.token===`:`&&n.length<3;)P(e),e.token===`)`||e.token===`]`||e.token===`,`||e.token===``?n.push(new v(`end`)):n.push(se(e));t=n.length===3?new g(n[0],n[2],n[1]):new g(n[0],n[1])}return t}function se(e){for(var t=ce(e),n,r,i,a={"+":`add`,"-":`subtract`};ei(a,e.token);){n=e.token,r=a[n],P(e);var o=ce(e);i=o.isPercentage?[t,new m(`*`,`multiply`,[t,o])]:[t,o],t=new m(n,r,i)}return t}function ce(e){for(var t=le(e),n=t,r,i,a={"*":`multiply`,".*":`dotMultiply`,"/":`divide`,"./":`dotDivide`,"%":`mod`,mod:`mod`};ei(a,e.token);)r=e.token,i=a[r],P(e),n=le(e),t=new m(r,i,[t,n]);return t}function le(e){for(var t=ue(e),n=t;e.tokenType===x.SYMBOL||e.token===`in`&&Mr(t)||e.token===`in`&&zr(t)&&t.fn===`unaryMinus`&&Mr(t.args[0])||e.tokenType===x.NUMBER&&!Mr(n)&&(!zr(n)||n.op===`!`)||e.token===`(`;)n=ue(e),t=new m(`*`,`multiply`,[t,n],!0);return t}function ue(e){for(var t=de(e),n=t,r=[];e.token===`/`&&Nr(n);)if(r.push(Rn({},e)),P(e),e.tokenType===x.NUMBER)if(r.push(Rn({},e)),P(e),e.tokenType===x.SYMBOL||e.token===`(`||e.token===`in`)Rn(e,r.pop()),r.pop(),n=de(e),t=new m(`/`,`divide`,[t,n]);else{r.pop(),Rn(e,r.pop());break}else{Rn(e,r.pop());break}return t}function de(e){var t=fe(e);if(e.token===`%`){var n=Rn({},e);P(e);try{fe(e),Rn(e,n)}catch{t=new m(`/`,`divide`,[t,new l(100)],!1,!0)}}return t}function fe(e){var t,n,r,i={"-":`unaryMinus`,"+":`unaryPlus`,"~":`bitNot`,not:`not`};return ei(i,e.token)?(r=i[e.token],t=e.token,P(e),n=[fe(e)],new m(t,r,n)):pe(e)}function pe(e){var t=me(e),n,r,i;return(e.token===`^`||e.token===`.^`)&&(n=e.token,r=n===`^`?`pow`:`dotPow`,P(e),i=[t,fe(e)],t=new m(n,r,i)),t}function me(e){for(var t=he(e);e.token===`??`;)P(e),t=new m(`??`,`nullish`,[t,he(e)]);return t}function he(e){for(var t=ge(e),n,r,i,a={"!":`factorial`,"'":`ctranspose`};ei(a,e.token);)n=e.token,r=a[n],N(e),i=[t],t=new m(n,r,i),t=ve(e,t);return t}function ge(e){var t=[];if(e.tokenType===x.SYMBOL&&ei(e.extraNodes,e.token)){var n=e.extraNodes[e.token];if(N(e),e.token===`(`){if(t=[],F(e),N(e),e.token!==`)`)for(t.push(z(e));e.token===`,`;)N(e),t.push(z(e));if(e.token!==`)`)throw Oe(e,`Parenthesis ) expected`);I(e),N(e)}return new n(t)}return _e(e)}function _e(e){var t,r;return e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C?(r=e.token,N(e),t=ei(w,r)?new l(w[r]):T.includes(r)?new l(n(r,`number`)):new v(r),t=ve(e,t),t):ye(e)}function ve(e,t,n){for(var r;;){var a=!1;e.token===`?.`&&(a=!0,N(e));var o=(e.token===`(`||e.token===`[`||e.token===`.`)&&(!n||n.includes(e.token));if(!(a||o))break;if(r=[],e.token===`(`)if(a||Ur(t)||Dr(t)){if(F(e),N(e),e.token!==`)`)for(r.push(z(e));e.token===`,`;)N(e),r.push(z(e));if(e.token!==`)`)throw Oe(e,`Parenthesis ) expected`);I(e),N(e),t=new d(t,r,a)}else return t;else if(e.token===`[`){if(F(e),N(e),e.token!==`]`)for(r.push(z(e));e.token===`,`;)N(e),r.push(z(e));if(e.token!==`]`)throw Oe(e,`Parenthesis ] expected`);I(e),N(e),t=new i(t,new f(r),a)}else{if(a||N(e),!(e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C)){var s=`Property name expected after `;throw s+=a?`optional chain`:`dot`,Oe(e,s)}r.push(new l(e.token)),N(e),t=new i(t,new f(r,!0),a)}}return t}function ye(e){var t,n;return e.token===`"`||e.token===`'`?(n=be(e,e.token),t=new l(n),t=ve(e,t),t):xe(e)}function be(e,t){for(var n=``;k(e)!==``&&k(e)!==t;)if(k(e)===`\\`){A(e);var r=k(e),i=E[r];if(i!==void 0)n+=i,e.index+=1;else if(r===`u`){var a=e.expression.slice(e.index+1,e.index+5);if(/^[0-9A-Fa-f]{4}$/.test(a))n+=String.fromCharCode(parseInt(a,16)),e.index+=5;else throw Oe(e,`Invalid unicode character \\u${a}`)}else throw Oe(e,`Bad escape character \\${r}`)}else n+=k(e),A(e);if(N(e),e.token!==t)throw Oe(e,`End of string ${t} expected`);return N(e),n}function xe(e){var t,n,r,i;if(e.token===`[`){if(F(e),N(e),e.token!==`]`){var o=Se(e);if(e.token===`;`){for(r=1,n=[o];e.token===`;`;)N(e),e.token!==`]`&&(n[r]=Se(e),r++);if(e.token!==`]`)throw Oe(e,`End of matrix ] expected`);I(e),N(e),i=n[0].items.length;for(var s=1;s<r;s++)if(n[s].items.length!==i)throw ke(e,`Column dimensions mismatch (`+n[s].items.length+` !== `+i+`)`);t=new a(n)}else{if(e.token!==`]`)throw Oe(e,`End of matrix ] expected`);I(e),N(e),t=o}}else I(e),N(e),t=new a([]);return ve(e,t)}return Ce(e)}function Se(e){for(var t=[z(e)],n=1;e.token===`,`;)N(e),e.token!==`]`&&e.token!==`;`&&(t[n]=z(e),n++);return new a(t)}function Ce(e){if(e.token===`{`){F(e);var t,n={};do if(N(e),e.token!==`}`){if(e.token===`"`||e.token===`'`)t=be(e,e.token);else if(e.tokenType===x.SYMBOL||e.tokenType===x.DELIMITER&&e.token in C)t=e.token,N(e);else throw Oe(e,`Symbol or string expected as object key`);if(e.token!==`:`)throw Oe(e,`Colon : expected after object key`);N(e),n[t]=z(e)}while(e.token===`,`);if(e.token!==`}`)throw Oe(e,`Comma , or bracket } expected after object value`);I(e),N(e);var r=new p(n);return r=ve(e,r),r}return we(e)}function we(e){var t;if(e.tokenType===x.NUMBER){t=e.token,N(e);var i=pi(t,r);return new l(n(t,i))}return Te(e)}function Te(e){var t;if(e.token===`(`){if(F(e),N(e),t=z(e),e.token!==`)`)throw Oe(e,`Parenthesis ) expected`);return I(e),N(e),t=new h(t),t=ve(e,t),t}return Ee(e)}function Ee(e){throw e.token===``?Oe(e,`Unexpected end of expression`):Oe(e,`Value expected`)}function De(e){return e.index-e.token.length+1}function Oe(e,t){var n=De(e),r=SyntaxError(t+` (char `+n+`)`);return r.char=n,r}function ke(e,t){var n=De(e),r=SyntaxError(t+` (char `+n+`)`);return r.char=n,r}return t.addConversion({from:`string`,to:`Node`,convert:y}),y}),Ty=`compile`,Ey=J(Ty,[`typed`,`parse`],e=>{var{typed:t,parse:n}=e;return t(Ty,{string:function(e){return n(e).compile()},"Array | Matrix":function(e){return Dc(e,function(e){return n(e).compile()})}})}),Dy=`evaluate`,Oy=J(Dy,[`typed`,`parse`],e=>{var{typed:t,parse:n}=e;return t(Dy,{string:function(e){var t=Qn();return n(e).compile().evaluate(t)},"string, Map | Object":function(e,t){return n(e).compile().evaluate(t)},"Array | Matrix":function(e){var t=Qn();return Dc(e,function(e){return n(e).compile().evaluate(t)})},"Array | Matrix, Map | Object":function(e,t){return Dc(e,function(e){return n(e).compile().evaluate(t)})}})}),ky=J(`Parser`,[`evaluate`,`parse`],e=>{var{evaluate:t,parse:n}=e;function r(){if(!(this instanceof r))throw SyntaxError(`Constructor must be called with the new operator`);Object.defineProperty(this,`scope`,{value:Qn(),writable:!1})}r.prototype.type=`Parser`,r.prototype.isParser=!0,r.prototype.evaluate=function(e){return t(e,this.scope)},r.prototype.get=function(e){if(this.scope.has(e))return this.scope.get(e)},r.prototype.getAll=function(){return er(this.scope)},r.prototype.getAllAsMap=function(){return this.scope};function i(e){if(e.length===0)return!1;for(var t=0;t<e.length;t++){var r=e.charAt(t-1),i=e.charAt(t),a=e.charAt(t+1);if(!(n.isAlpha(i,r,a)||t>0&&n.isDigit(i)))return!1}return!0}return r.prototype.set=function(e,t){if(!i(e))throw Error(`Invalid variable name: '${e}'. Variable names must follow the specified rules.`);return this.scope.set(e,t),t},r.prototype.remove=function(e){this.scope.delete(e)},r.prototype.clear=function(){this.scope.clear()},r.prototype.toJSON=function(){var e={mathjs:`Parser`,variables:{},functions:{}};for(var[t,n]of this.scope)if(vr(n)){if(!Ay(n))throw Error(`Cannot serialize external function ${t}`);e.functions[t]=`${n.syntax} = ${n.expr}`}else e.variables[t]=n;return e},r.fromJSON=function(e){var t=new r;return Object.entries(e.variables).forEach(e=>{var[n,r]=e;return t.set(n,r)}),Object.entries(e.functions).forEach(e=>{var[n,r]=e;return t.evaluate(r)}),t},r},{isClass:!0});function Ay(e){return typeof e==`function`&&typeof e.syntax==`string`&&typeof e.expr==`string`}var jy=`parser`,My=J(jy,[`typed`,`Parser`],e=>{var{typed:t,Parser:n}=e;return t(jy,{"":function(){return new n}})}),Ny=`lup`,Py=J(Ny,[`typed`,`matrix`,`abs`,`addScalar`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`larger`,`equalScalar`,`unaryMinus`,`DenseMatrix`,`SparseMatrix`,`Spa`],e=>{var{typed:t,matrix:n,abs:r,addScalar:i,divideScalar:a,multiplyScalar:o,subtractScalar:s,larger:c,equalScalar:l,unaryMinus:u,DenseMatrix:d,SparseMatrix:f,Spa:p}=e;return t(Ny,{DenseMatrix:function(e){return m(e)},SparseMatrix:function(e){return h(e)},Array:function(e){var t=m(n(e));return{L:t.L.valueOf(),U:t.U.valueOf(),p:t.p}}});function m(e){var t=e._size[0],n=e._size[1],u=Math.min(t,n),f=Kr(e._data),p=[],m=[t,u],h=[],g=[u,n],_,v,y,b=[];for(_=0;_<t;_++)b[_]=_;for(v=0;v<n;v++){if(v>0)for(_=0;_<t;_++){var x=Math.min(_,v),S=0;for(y=0;y<x;y++)S=i(S,o(f[_][y],f[y][v]));f[_][v]=s(f[_][v],S)}var C=v,w=0,T=0;for(_=v;_<t;_++){var E=f[_][v],D=r(E);c(D,w)&&(C=_,w=D,T=E)}if(v!==C&&(b[v]=[b[C],b[C]=b[v]][0],d._swapRows(v,C,f)),v<t)for(_=v+1;_<t;_++){var O=f[_][v];l(O,0)||(f[_][v]=a(f[_][v],T))}}for(v=0;v<n;v++)for(_=0;_<t;_++){if(v===0&&(_<n&&(h[_]=[]),p[_]=[]),_<v){_<n&&(h[_][v]=f[_][v]),v<t&&(p[_][v]=0);continue}if(_===v){_<n&&(h[_][v]=f[_][v]),v<t&&(p[_][v]=1);continue}_<n&&(h[_][v]=0),v<t&&(p[_][v]=f[_][v])}var k=new d({data:p,size:m}),A=new d({data:h,size:g}),j=[];for(_=0,u=b.length;_<u;_++)j[b[_]]=_;return{L:k,U:A,p:j,toString:function(){return`L: `+this.L.toString()+`
19
+ U: `+this.U.toString()+`
20
+ P: `+this.p}}}function h(e){var t=e._size[0],n=e._size[1],i=Math.min(t,n),s=e._values,d=e._index,m=e._ptr,h=[],g=[],_=[],v=[t,i],y=[],b=[],x=[],S=[i,n],C,w,T,E=[],D=[];for(C=0;C<t;C++)E[C]=C,D[C]=C;var O=function(e,t){var n=D[e],r=D[t];E[n]=t,E[r]=e,D[e]=r,D[t]=n},k=function(){var e=new p;w<t&&(_.push(h.length),h.push(1),g.push(w)),x.push(y.length);var n=m[w],i=m[w+1];for(T=n;T<i;T++)C=d[T],e.set(E[C],s[T]);w>0&&e.forEach(0,w-1,function(t,n){f._forEachRow(t,h,g,_,function(r,i){r>t&&e.accumulate(r,u(o(i,n)))})});var D=w,k=e.get(w),A=r(k);e.forEach(w+1,t-1,function(e,t){var n=r(t);c(n,A)&&(D=e,A=n,k=t)}),w!==D&&(f._swapRows(w,D,v[1],h,g,_),f._swapRows(w,D,S[1],y,b,x),e.swap(w,D),O(w,D)),e.forEach(0,t-1,function(e,t){e<=w?(y.push(t),b.push(e)):(t=a(t,k),l(t,0)||(h.push(t),g.push(e)))})};for(w=0;w<n;w++)k();return x.push(y.length),_.push(h.length),{L:new f({values:h,index:g,ptr:_,size:v}),U:new f({values:y,index:b,ptr:x,size:S}),p:E,toString:function(){return`L: `+this.L.toString()+`
21
+ U: `+this.U.toString()+`
22
+ P: `+this.p}}}}),Fy=`qr`,Iy=J(Fy,[`typed`,`matrix`,`zeros`,`identity`,`isZero`,`equal`,`sign`,`sqrt`,`conj`,`unaryMinus`,`addScalar`,`divideScalar`,`multiplyScalar`,`subtractScalar`,`complex`],e=>{var{typed:t,matrix:n,zeros:r,identity:i,isZero:a,equal:o,sign:s,sqrt:c,conj:l,unaryMinus:u,addScalar:d,divideScalar:f,multiplyScalar:p,subtractScalar:m,complex:h}=e;return Rn(t(Fy,{DenseMatrix:function(e){return _(e)},SparseMatrix:function(e){return v(e)},Array:function(e){var t=_(n(e));return{Q:t.Q.valueOf(),R:t.R.valueOf()}}}),{_denseQRimpl:g});function g(e){var t=e._size[0],n=e._size[1],h=i([t],`dense`),g=h._data,_=e.clone(),v=_._data,y,b,x,S=r([t],``);for(x=0;x<Math.min(n,t);++x){var C=v[x][x],w=u(o(C,0)?1:s(C)),T=l(w),E=0;for(y=x;y<t;y++)E=d(E,p(v[y][x],l(v[y][x])));var D=p(w,c(E));if(!a(D)){var O=m(C,D);for(S[x]=1,y=x+1;y<t;y++)S[y]=f(v[y][x],O);var k=u(l(f(O,D))),A=void 0;for(b=x;b<n;b++){for(A=0,y=x;y<t;y++)A=d(A,p(l(S[y]),v[y][b]));for(A=p(A,k),y=x;y<t;y++)v[y][b]=p(m(v[y][b],p(S[y],A)),T)}for(y=0;y<t;y++){for(A=0,b=x;b<t;b++)A=d(A,p(g[y][b],S[b]));for(A=p(A,k),b=x;b<t;++b)g[y][b]=f(m(g[y][b],p(A,l(S[b]))),T)}}}return{Q:h,R:_,toString:function(){return`Q: `+this.Q.toString()+`
23
+ R: `+this.R.toString()}}}function _(e){var t=g(e),n=t.R._data;if(e._data.length>0)for(var r=n[0][0].type===`Complex`?h(0):0,i=0;i<n.length;++i)for(var a=0;a<i&&a<(n[0]||[]).length;++a)n[i][a]=r;return t}function v(e){throw Error(`qr not implemented for sparse matrices yet`)}});function Ly(e,t,n,r){for(var i=e._values,a=e._index,o=e._ptr,s=e._size,c=e._datatype,l=s[0],u=s[1],d=r&&e._values?[]:null,f=[],p=[],m=0,h=0;h<u;h++){p[h]=m;for(var g=n?n[h]:h,_=o[g],v=o[g+1],y=_;y<v;y++)f[m]=t?t[a[y]]:a[y],d&&(d[m]=i[y]),m++}return p[u]=m,e.createSparseMatrix({values:d,index:f,ptr:p,size:[l,u],datatype:c})}function Ry(e,t,n,r,i,a,o){var s=0;for(n[o]=e;s>=0;){var c=n[o+s],l=n[r+c];l===-1?(s--,a[t++]=c):(n[r+c]=n[i+l],++s,n[o+s]=l)}return t}function zy(e,t){if(!e)return null;var n=0,r,i=[],a=[],o=0,s=t,c=2*t;for(r=0;r<t;r++)a[o+r]=-1;for(r=t-1;r>=0;r--)e[r]!==-1&&(a[s+r]=a[o+e[r]],a[o+e[r]]=r);for(r=0;r<t;r++)e[r]===-1&&(n=Ry(r,n,a,o,s,i,c));return i}function By(e,t){if(!e)return null;var n=e._index,r=e._ptr,i=e._size,a=i[0],o=i[1],s=[],c=[],l=0,u=o,d,f;if(t)for(d=0;d<a;d++)c[u+d]=-1;for(var p=0;p<o;p++){s[p]=-1,c[l+p]=-1;for(var m=r[p],h=r[p+1],g=m;g<h;g++){var _=n[g];for(d=t?c[u+_]:_;d!==-1&&d<p;d=f)f=c[l+d],c[l+d]=p,f===-1&&(s[d]=p);t&&(c[u+_]=p)}}return s}function Vy(e,t,n){for(var r=e._values,i=e._index,a=e._ptr,o=e._size[1],s=0,c=0;c<o;c++){var l=a[c];for(a[c]=s;l<a[c+1];l++)t(i[l],c,r?r[l]:1,n)&&(i[s]=i[l],r&&(r[s]=r[l]),s++)}return a[o]=s,i.splice(s,i.length-s),r&&r.splice(s,r.length-s),s}function Hy(e){return-e-2}var Uy=J(`csAmd`,[`add`,`multiply`,`transpose`],e=>{var{add:t,multiply:n,transpose:r}=e;return function(e,t){if(!t||e<=0||e>3)return null;var n=t._size,r=n[0],l=n[1],u=0,d=Math.max(16,10*Math.sqrt(l));d=Math.min(l-2,d);var f=i(e,t,r,l,d);Vy(f,c,null);for(var p=f._index,m=f._ptr,h=m[l],g=[],_=[],v=0,y=l+1,b=2*(l+1),x=3*(l+1),S=4*(l+1),C=5*(l+1),w=6*(l+1),T=7*(l+1),E=g,D=a(l,m,_,v,x,E,b,T,y,w,S,C),O=o(l,m,_,C,S,w,d,y,x,E,b),k=0,A,j,M,N,P,F,I,L,R,z,B,V,ee,te,H,ne;O<l;){for(M=-1;k<l&&(M=_[x+k])===-1;k++);_[b+M]!==-1&&(E[_[b+M]]=-1),_[x+k]=_[b+M];var re=_[S+M],ie=_[y+M];O+=ie;var U=0;_[y+M]=-ie;var ae=m[M],oe=re===0?ae:h,se=oe;for(N=1;N<=re+1;N++){for(N>re?(F=M,I=ae,L=_[v+M]-re):(F=p[ae++],I=m[F],L=_[v+F]),P=1;P<=L;P++)A=p[I++],!((R=_[y+A])<=0)&&(U+=R,_[y+A]=-R,p[se++]=A,_[b+A]!==-1&&(E[_[b+A]]=E[A]),E[A]===-1?_[x+_[C+A]]=_[b+A]:_[b+E[A]]=_[b+A]);F!==M&&(m[F]=Hy(M),_[w+F]=0)}for(re!==0&&(h=se),_[C+M]=U,m[M]=oe,_[v+M]=se-oe,_[S+M]=-2,D=s(D,u,_,w,l),z=oe;z<se;z++)if(A=p[z],!((B=_[S+A])<=0)){R=-_[y+A];var ce=D-R;for(ae=m[A],V=m[A]+B-1;ae<=V;ae++)F=p[ae],_[w+F]>=D?_[w+F]-=R:_[w+F]!==0&&(_[w+F]=_[C+F]+ce)}for(z=oe;z<se;z++){for(A=p[z],V=m[A],ee=V+_[S+A]-1,te=V,H=0,ne=0,ae=V;ae<=ee;ae++)if(F=p[ae],_[w+F]!==0){var le=_[w+F]-D;le>0?(ne+=le,p[te++]=F,H+=F):(m[F]=Hy(M),_[w+F]=0)}_[S+A]=te-V+1;var ue=te,de=V+_[v+A];for(ae=ee+1;ae<de;ae++){j=p[ae];var fe=_[y+j];fe<=0||(ne+=fe,p[te++]=j,H+=j)}ne===0?(m[A]=Hy(M),R=-_[y+A],U-=R,ie+=R,O+=R,_[y+A]=0,_[S+A]=-1):(_[C+A]=Math.min(_[C+A],ne),p[te]=p[ue],p[ue]=p[V],p[V]=M,_[v+A]=te-V+1,H=(H<0?-H:H)%l,_[b+A]=_[T+H],_[T+H]=A,E[A]=H)}for(_[C+M]=U,u=Math.max(u,U),D=s(D+u,u,_,w,l),z=oe;z<se;z++)if(A=p[z],!(_[y+A]>=0))for(H=E[A],A=_[T+H],_[T+H]=-1;A!==-1&&_[b+A]!==-1;A=_[b+A],D++){for(L=_[v+A],B=_[S+A],ae=m[A]+1;ae<=m[A]+L-1;ae++)_[w+p[ae]]=D;var pe=A;for(j=_[b+A];j!==-1;){var me=_[v+j]===L&&_[S+j]===B;for(ae=m[j]+1;me&&ae<=m[j]+L-1;ae++)_[w+p[ae]]!==D&&(me=0);me?(m[j]=Hy(A),_[y+A]+=_[y+j],_[y+j]=0,_[S+j]=-1,j=_[b+j],_[b+pe]=j):(pe=j,j=_[b+j])}}for(ae=oe,z=oe;z<se;z++)A=p[z],!((R=-_[y+A])<=0)&&(_[y+A]=R,ne=_[C+A]+U-R,ne=Math.min(ne,l-O-R),_[x+ne]!==-1&&(E[_[x+ne]]=A),_[b+A]=_[x+ne],E[A]=-1,_[x+ne]=A,k=Math.min(k,ne),_[C+A]=ne,p[ae++]=A);_[y+M]=ie,(_[v+M]=ae-oe)===0&&(m[M]=-1,_[w+M]=0),re!==0&&(h=ae)}for(A=0;A<l;A++)m[A]=Hy(m[A]);for(j=0;j<=l;j++)_[x+j]=-1;for(j=l;j>=0;j--)_[y+j]>0||(_[b+j]=_[x+m[j]],_[x+m[j]]=j);for(F=l;F>=0;F--)_[y+F]<=0||m[F]!==-1&&(_[b+F]=_[x+m[F]],_[x+m[F]]=F);for(M=0,A=0;A<=l;A++)m[A]===-1&&(M=Ry(A,M,_,x,b,g,w));return g.splice(g.length-1,1),g};function i(e,i,a,o,s){var c=r(i);if(e===1&&o===a)return t(i,c);if(e===2){for(var l=c._index,u=c._ptr,d=0,f=0;f<a;f++){var p=u[f];if(u[f]=d,!(u[f+1]-p>s))for(var m=u[f+1];p<m;p++)l[d++]=l[p]}return u[a]=d,i=r(c),n(c,i)}return n(c,i)}function a(e,t,n,r,i,a,o,c,l,u,d,f){for(var p=0;p<e;p++)n[r+p]=t[p+1]-t[p];n[r+e]=0;for(var m=0;m<=e;m++)n[i+m]=-1,a[m]=-1,n[o+m]=-1,n[c+m]=-1,n[l+m]=1,n[u+m]=1,n[d+m]=0,n[f+m]=n[r+m];var h=s(0,0,n,u,e);return n[d+e]=-2,t[e]=-1,n[u+e]=0,h}function o(e,t,n,r,i,a,o,s,c,l,u){for(var d=0,f=0;f<e;f++){var p=n[r+f];if(p===0)n[i+f]=-2,d++,t[f]=-1,n[a+f]=0;else if(p>o)n[s+f]=0,n[i+f]=-1,d++,t[f]=Hy(e),n[s+e]++;else{var m=n[c+p];m!==-1&&(l[m]=f),n[u+f]=n[c+p],n[c+p]=f}}return d}function s(e,t,n,r,i){if(e<2||e+t<0){for(var a=0;a<i;a++)n[r+a]!==0&&(n[r+a]=1);e=2}return e}function c(e,t){return e!==t}});function Wy(e,t,n,r,i,a,o){var s,c,l=0,u;if(e<=t||n[r+t]<=n[i+e])return-1;n[i+e]=n[r+t];var d=n[a+e];if(n[a+e]=t,d===-1)l=1,u=e;else{for(l=2,u=d;u!==n[o+u];u=n[o+u]);for(s=d;s!==u;s=c)c=n[o+s],n[o+s]=u}return{jleaf:l,q:u}}var Gy=J(`csCounts`,[`transpose`],e=>{var{transpose:t}=e;return function(e,n,r,i){if(!e||!n||!r)return null;var a=e._size,o=a[0],s=a[1],c,l,u,d,f,p,m,h=4*s+(i?s+o+1:0),g=[],_=0,v=s,y=2*s,b=3*s,x=4*s,S=5*s+1;for(u=0;u<h;u++)g[u]=-1;var C=[],w=t(e),T=w._index,E=w._ptr;for(u=0;u<s;u++)for(l=r[u],C[l]=+(g[b+l]===-1);l!==-1&&g[b+l]===-1;l=n[l])g[b+l]=u;if(i){for(u=0;u<s;u++)g[r[u]]=u;for(c=0;c<o;c++){for(u=s,p=E[c],m=E[c+1],f=p;f<m;f++)u=Math.min(u,g[T[f]]);g[S+c]=g[x+u],g[x+u]=c}}for(c=0;c<s;c++)g[_+c]=c;for(u=0;u<s;u++){for(l=r[u],n[l]!==-1&&C[n[l]]--,d=i?g[x+u]:l;d!==-1;d=i?g[S+d]:-1)for(f=E[d];f<E[d+1];f++){c=T[f];var D=Wy(c,l,g,b,v,y,_);D.jleaf>=1&&C[l]++,D.jleaf===2&&C[D.q]--}n[l]!==-1&&(g[_+l]=n[l])}for(l=0;l<s;l++)n[l]!==-1&&(C[n[l]]+=C[l]);return C}}),Ky=J(`csSqr`,[`add`,`multiply`,`transpose`],e=>{var{add:t,multiply:n,transpose:r}=e,i=Uy({add:t,multiply:n,transpose:r}),a=Gy({transpose:r});return function(e,t,n){var r=t._ptr,s=t._size[1],c,l={};if(l.q=i(e,t),e&&!l.q)return null;if(n){var u=e?Ly(t,null,l.q,0):t;l.parent=By(u,1);var d=zy(l.parent,s);if(l.cp=a(u,l.parent,d,1),u&&l.parent&&l.cp&&o(u,l))for(l.unz=0,c=0;c<s;c++)l.unz+=l.cp[c]}else l.unz=4*r[s]+s,l.lnz=l.unz;return l};function o(e,t){var n=e._ptr,r=e._index,i=e._size,a=i[0],o=i[1];t.pinv=[],t.leftmost=[];var s=t.parent,c=t.pinv,l=t.leftmost,u=[],d=0,f=a,p=a+o,m=a+2*o,h,g,_,v,y;for(g=0;g<o;g++)u[f+g]=-1,u[p+g]=-1,u[m+g]=0;for(h=0;h<a;h++)l[h]=-1;for(g=o-1;g>=0;g--)for(v=n[g],y=n[g+1],_=v;_<y;_++)l[r[_]]=g;for(h=a-1;h>=0;h--)c[h]=-1,g=l[h],g!==-1&&(u[m+g]++===0&&(u[p+g]=h),u[d+h]=u[f+g],u[f+g]=h);for(t.lnz=0,t.m2=a,g=0;g<o;g++)if(h=u[f+g],t.lnz++,h<0&&(h=t.m2++),c[h]=g,!(--m[g]<=0)){t.lnz+=u[m+g];var b=s[g];b!==-1&&(u[m+b]===0&&(u[p+b]=u[p+g]),u[d+u[p+g]]=u[f+b],u[f+b]=u[d+h],u[m+b]+=u[m+g])}for(h=0;h<a;h++)c[h]<0&&(c[h]=g++);return!0}});function qy(e,t){return e[t]<0}function Jy(e,t){e[t]=Hy(e[t])}function Yy(e){return e<0?Hy(e):e}function Xy(e,t,n,r,i){var a=t._index,o=t._ptr,s=t._size[1],c,l,u,d=0;for(r[0]=e;d>=0;){e=r[d];var f=i?i[e]:e;qy(o,e)||(Jy(o,e),r[s+d]=f<0?0:Yy(o[f]));var p=1;for(l=r[s+d],u=f<0?0:Yy(o[f+1]);l<u;l++)if(c=a[l],!qy(o,c)){r[s+d]=l,r[++d]=c,p=0;break}p&&(d--,r[--n]=e)}return n}function Zy(e,t,n,r,i){var a=e._ptr,o=e._size,s=t._index,c=t._ptr,l=o[1],u,d,f,p=l;for(d=c[n],f=c[n+1],u=d;u<f;u++){var m=s[u];qy(a,m)||(p=Xy(m,e,p,r,i))}for(u=p;u<l;u++)Jy(a,r[u]);return p}var Qy=J(`csSpsolve`,[`divideScalar`,`multiply`,`subtract`],e=>{var{divideScalar:t,multiply:n,subtract:r}=e;return function(e,i,a,o,s,c,l){var u=e._values,d=e._index,f=e._ptr,p=e._size[1],m=i._values,h=i._index,g=i._ptr,_,v,y,b,x=Zy(e,i,a,o,c);for(_=x;_<p;_++)s[o[_]]=0;for(v=g[a],y=g[a+1],_=v;_<y;_++)s[h[_]]=m[_];for(var S=x;S<p;S++){var C=o[S],w=c?c[C]:C;if(!(w<0))for(v=f[w],y=f[w+1],s[C]=t(s[C],u[l?v:y-1]),_=l?v+1:v,b=l?y:y-1;_<b;_++){var T=d[_];s[T]=r(s[T],n(u[_],s[C]))}}return x}}),$y=J(`csLu`,[`abs`,`divideScalar`,`multiply`,`subtract`,`larger`,`largerEq`,`SparseMatrix`],e=>{var{abs:t,divideScalar:n,multiply:r,subtract:i,larger:a,largerEq:o,SparseMatrix:s}=e,c=Qy({divideScalar:n,multiply:r,subtract:i});return function(e,i,l){if(!e)return null;var u=e._size[1],d,f=100,p=100;i&&(d=i.q,f=i.lnz||f,p=i.unz||p);var m=[],h=[],g=[],_=new s({values:m,index:h,ptr:g,size:[u,u]}),v=[],y=[],b=[],x=new s({values:v,index:y,ptr:b,size:[u,u]}),S=[],C,w,T=[],E=[];for(C=0;C<u;C++)T[C]=0,S[C]=-1,g[C+1]=0;f=0,p=0;for(var D=0;D<u;D++){g[D]=f,b[D]=p;var O=d?d[D]:D,k=c(_,e,O,E,T,S,1),A=-1,j=-1;for(w=k;w<u;w++)if(C=E[w],S[C]<0){var M=t(T[C]);a(M,j)&&(j=M,A=C)}else y[p]=S[C],v[p++]=T[C];if(A===-1||j<=0)return null;S[O]<0&&o(t(T[O]),r(j,l))&&(A=O);var N=T[A];for(y[p]=D,v[p++]=N,S[A]=D,h[f]=A,m[f++]=1,w=k;w<u;w++)C=E[w],S[C]<0&&(h[f]=C,m[f++]=n(T[C],N)),T[C]=0}for(g[u]=f,b[u]=p,w=0;w<f;w++)h[w]=S[h[w]];return m.splice(f,m.length-f),h.splice(f,h.length-f),v.splice(p,v.length-p),y.splice(p,y.length-p),{L:_,U:x,pinv:S}}}),eb=`slu`,tb=J(eb,[`typed`,`abs`,`add`,`multiply`,`transpose`,`divideScalar`,`subtract`,`larger`,`largerEq`,`SparseMatrix`],e=>{var{typed:t,abs:n,add:r,multiply:i,transpose:a,divideScalar:o,subtract:s,larger:c,largerEq:l,SparseMatrix:u}=e,d=Ky({add:r,multiply:i,transpose:a}),f=$y({abs:n,divideScalar:o,multiply:i,subtract:s,larger:c,largerEq:l,SparseMatrix:u});return t(eb,{"SparseMatrix, number, number":function(e,t,n){if(!fi(t)||t<0||t>3)throw Error(`Symbolic Ordering and Analysis order must be an integer number in the interval [0, 3]`);if(n<0||n>1)throw Error(`Partial pivoting threshold must be a number from 0 to 1`);var r=d(t,e,!1),i=f(e,r,n);return{L:i.L,U:i.U,p:i.pinv,q:r.q,toString:function(){return`L: `+this.L.toString()+`
24
+ U: `+this.U.toString()+`
25
+ p: `+this.p.toString()+(this.q?`
26
+ q: `+this.q.toString():``)+`
27
+ `}}}})});function nb(e,t){var n,r=t.length,i=[];if(e)for(n=0;n<r;n++)i[e[n]]=t[n];else for(n=0;n<r;n++)i[n]=t[n];return i}var rb=`lusolve`,ib=J(rb,[`typed`,`matrix`,`lup`,`slu`,`usolve`,`lsolve`,`DenseMatrix`],e=>{var{typed:t,matrix:n,lup:r,slu:i,usolve:a,lsolve:o,DenseMatrix:s}=e,c=jh({DenseMatrix:s});return t(rb,{"Array, Array | Matrix":function(e,t){e=n(e);var i=r(e);return u(i.L,i.U,i.p,null,t).valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var n=r(e);return u(n.L,n.U,n.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,n,r){var a=i(e,n,r);return u(a.L,a.U,a.p,a.q,t)},"Object, Array | Matrix":function(e,t){return u(e.L,e.U,e.p,e.q,t)}});function l(e){if(lr(e))return e;if(cr(e))return n(e);throw TypeError(`Invalid Matrix LU decomposition`)}function u(e,t,n,r,i){e=l(e),t=l(t),n&&(i=c(e,i,!0),i._data=nb(n,i._data));var s=o(e,i),u=a(t,s);return r&&(u._data=nb(r,u._data)),u}}),ab=`polynomialRoot`,ob=J(ab,[`typed`,`isZero`,`equalScalar`,`add`,`subtract`,`multiply`,`divide`,`sqrt`,`unaryMinus`,`cbrt`,`typeOf`,`im`,`re`],e=>{var{typed:t,isZero:n,equalScalar:r,add:i,subtract:a,multiply:o,divide:s,sqrt:c,unaryMinus:l,cbrt:u,typeOf:d,im:f,re:p}=e;return t(ab,{"number|Complex, ...number|Complex":(e,t)=>{for(var m=[e,...t];m.length>0&&n(m[m.length-1]);)m.pop();if(m.length<2)throw RangeError(`Polynomial [${e}, ${t}] must have a non-zero non-constant coefficient`);switch(m.length){case 2:return[l(s(m[0],m[1]))];case 3:var[h,g,_]=m,v=o(2,_),y=o(g,g),b=o(4,_,h);if(r(y,b))return[s(l(g),v)];var x=c(a(y,b));return[s(a(x,g),v),s(a(l(x),g),v)];case 4:var[S,C,w,T]=m,E=l(o(3,T)),D=o(w,w),O=o(3,T,C),k=i(o(2,w,w,w),o(27,T,T,S)),A=o(9,T,w,C);if(r(D,O)&&r(k,A))return[s(w,E)];var j=a(D,O),M=a(k,A);return r(i(o(18,T,w,C,S),o(w,w,C,C)),i(o(4,w,w,w,S),o(4,T,C,C,C),o(27,T,T,S,S)))?[s(a(o(4,T,w,C),i(o(9,T,T,S),o(w,w,w))),o(T,j)),s(a(o(9,T,S),o(w,C)),o(2,j))]:u(r(D,O)?M:s(i(M,c(a(o(M,M),o(4,j,j,j)))),2),!0).toArray().map(e=>s(i(w,e,s(j,e)),E)).map(e=>d(e)===`Complex`&&r(p(e),p(e)+f(e))?p(e):e);default:throw RangeError(`only implemented for cubic or lower-order polynomials, not ${m}`)}}})}),sb=J(`Help`,[`evaluate`],e=>{var{evaluate:t}=e;function n(e){if(!(this instanceof n))throw SyntaxError(`Constructor must be called with the new operator`);if(!e)throw Error(`Argument "doc" missing`);this.doc=e}return n.prototype.type=`Help`,n.prototype.isHelp=!0,n.prototype.toString=function(){var e=this.doc||{},n=`
28
+ `;if(e.name&&(n+=`Name: `+e.name+`
29
+
30
+ `),e.category&&(n+=`Category: `+e.category+`
31
+
32
+ `),e.description&&(n+=`Description:
33
+ `+e.description+`
34
+
35
+ `),e.syntax&&(n+=`Syntax:
36
+ `+e.syntax.join(`
37
+ `)+`
38
+
39
+ `),e.examples){n+=`Examples:
40
+ `;for(var r=!1,i=t(`config()`),a={config:e=>(r=!0,t(`config(newConfig)`,{newConfig:e}))},o=0;o<e.examples.length;o++){var s=e.examples[o];n+=` `+s+`
41
+ `;var c=void 0;try{c=t(s,a)}catch(e){c=e}c!==void 0&&!_r(c)&&(n+=` `+ws(c,{precision:14})+`
42
+ `)}n+=`
43
+ `,r&&t(`config(originalConfig)`,{originalConfig:i})}return e.mayThrow&&e.mayThrow.length&&(n+=`Throws: `+e.mayThrow.join(`, `)+`
44
+
45
+ `),e.seealso&&e.seealso.length&&(n+=`See also: `+e.seealso.join(`, `)+`
46
+ `),n},n.prototype.toJSON=function(){var e=Kr(this.doc);return e.mathjs=`Help`,e},n.fromJSON=function(e){var t={};return Object.keys(e).filter(e=>e!==`mathjs`).forEach(n=>{t[n]=e[n]}),new n(t)},n.prototype.valueOf=n.prototype.toString,n},{isClass:!0}),cb=J(`Chain`,[`?on`,`math`,`typed`],e=>{var{on:t,math:n,typed:r}=e;function i(e){if(!(this instanceof i))throw SyntaxError(`Constructor must be called with the new operator`);Wr(e)?this.value=e.value:this.value=e}i.prototype.type=`Chain`,i.prototype.isChain=!0,i.prototype.done=function(){return this.value},i.prototype.valueOf=function(){return this.value},i.prototype.toString=function(){return ws(this.value)},i.prototype.toJSON=function(){return{mathjs:`Chain`,value:this.value}},i.fromJSON=function(e){return new i(e.value)};function a(e,t){typeof t==`function`&&(i.prototype[e]=s(t))}function o(e,t){$r(i.prototype,e,function(){var e=t();if(typeof e==`function`)return s(e)})}function s(e){return function(){if(arguments.length===0)return new i(e(this.value));for(var t=[this.value],n=0;n<arguments.length;n++)t[n+1]=arguments[n];if(r.isTypedFunction(e)){var a=r.resolve(e,t);if(a.params.length===1)throw Error(`chain function `+e.name+` cannot match rest parameter between chain value and additional arguments.`);return new i(a.implementation.apply(e,t))}return new i(e.apply(e,t))}}i.createProxy=function(e,t){if(typeof e==`string`)a(e,t);else{var n=function(t){ei(e,t)&&c[t]===void 0&&o(t,()=>e[t])};for(var r in e)n(r)}};var c={expression:!0,docs:!0,type:!0,classes:!0,json:!0,error:!0,isChain:!0};return i.createProxy(n),t&&t(`import`,function(e,t,n){n||o(e,t)}),i},{isClass:!0}),lb={name:`e`,category:`Constants`,syntax:[`e`],description:`Euler's number, the base of the natural logarithm. Approximately equal to 2.71828`,examples:[`e`,`e ^ 2`,`exp(2)`,`log(e)`],seealso:[`exp`]},ub={name:`false`,category:`Constants`,syntax:[`false`],description:`Boolean value false`,examples:[`false`],seealso:[`true`]},db={name:`i`,category:`Constants`,syntax:[`i`],description:`Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.`,examples:[`i`,`i * i`,`sqrt(-1)`],seealso:[]},fb={name:`Infinity`,category:`Constants`,syntax:[`Infinity`],description:`Infinity, a number which is larger than the maximum number that can be handled by a floating point number.`,examples:[`Infinity`,`1 / 0`],seealso:[]},pb={name:`LN10`,category:`Constants`,syntax:[`LN10`],description:`Returns the natural logarithm of 10, approximately equal to 2.302`,examples:[`LN10`,`log(10)`],seealso:[]},mb={name:`LN2`,category:`Constants`,syntax:[`LN2`],description:`Returns the natural logarithm of 2, approximately equal to 0.693`,examples:[`LN2`,`log(2)`],seealso:[]},hb={name:`LOG10E`,category:`Constants`,syntax:[`LOG10E`],description:`Returns the base-10 logarithm of E, approximately equal to 0.434`,examples:[`LOG10E`,`log(e, 10)`],seealso:[]},gb={name:`LOG2E`,category:`Constants`,syntax:[`LOG2E`],description:`Returns the base-2 logarithm of E, approximately equal to 1.442`,examples:[`LOG2E`,`log(e, 2)`],seealso:[]},_b={name:`NaN`,category:`Constants`,syntax:[`NaN`],description:`Not a number`,examples:[`NaN`,`0 / 0`],seealso:[]},vb={name:`null`,category:`Constants`,syntax:[`null`],description:`Value null`,examples:[`null`],seealso:[`true`,`false`]},yb={name:`phi`,category:`Constants`,syntax:[`phi`],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:[`phi`],seealso:[]},bb={name:`pi`,category:`Constants`,syntax:[`pi`],description:`The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159`,examples:[`pi`,`sin(pi/2)`],seealso:[`tau`]},xb={bignumber:{name:`bignumber`,category:`Construction`,syntax:[`bignumber(x)`],description:`Create a big number from a number or string.`,examples:[`0.1 + 0.2`,`bignumber(0.1) + bignumber(0.2)`,`bignumber("7.2")`,`bignumber("7.2e500")`,`bignumber([0.1, 0.2, 0.3])`],seealso:[`boolean`,`bigint`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},bigint:{name:`bigint`,category:`Construction`,syntax:[`bigint(x)`],description:`Create a bigint, an integer with an arbitrary number of digits, from a number or string.`,examples:[`123123123123123123 # a large number will lose digits`,`bigint("123123123123123123")`,`bignumber(["1", "3", "5"])`],seealso:[`boolean`,`bignumber`,`number`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},boolean:{name:`boolean`,category:`Construction`,syntax:[`x`,`boolean(x)`],description:`Convert a string or number into a boolean.`,examples:[`boolean(0)`,`boolean(1)`,`boolean(3)`,`boolean("true")`,`boolean("false")`,`boolean([1, 0, 1, 1])`],seealso:[`bignumber`,`complex`,`index`,`matrix`,`number`,`string`,`unit`]},complex:{name:`complex`,category:`Construction`,syntax:[`complex()`,`complex(re, im)`,`complex(string)`],description:`Create a complex number.`,examples:[`complex()`,`complex(2, 3)`,`complex("7 - 2i")`],seealso:[`bignumber`,`boolean`,`index`,`matrix`,`number`,`string`,`unit`]},createUnit:{name:`createUnit`,category:`Construction`,syntax:[`createUnit(definitions)`,`createUnit(name, definition)`],description:`Create a user-defined unit and register it with the Unit type.`,examples:[`createUnit("foo")`,`createUnit("knot", {definition: "0.514444444 m/s", aliases: ["knots", "kt", "kts"]})`,`createUnit("mph", "1 mile/hour")`],seealso:[`unit`,`splitUnit`]},fraction:{name:`fraction`,category:`Construction`,syntax:[`fraction(num)`,`fraction(matrix)`,`fraction(num,den)`,`fraction({n: num, d: den})`],description:`Create a fraction from a number or from integer numerator and denominator.`,examples:[`fraction(0.125)`,`fraction(1, 3) + fraction(2, 5)`,`fraction({n: 333, d: 53})`,`fraction([sqrt(9), sqrt(10), sqrt(11)])`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`string`,`unit`]},index:{name:`index`,category:`Construction`,syntax:[`[start]`,`[start:end]`,`[start:step:end]`,`[start1, start 2, ...]`,`[start1:end1, start2:end2, ...]`,`[start1:step1:end1, start2:step2:end2, ...]`],description:`Create an index to get or replace a subset of a matrix`,examples:[`A = [1, 2, 3; 4, 5, 6]`,`A[1, :]`,`A[1, 2] = 50`,`A[1:2, 1:2] = 1`,`B = [1, 2, 3]`,`B[B>1 and B<3]`],seealso:[`bignumber`,`boolean`,`complex`,`matrix`,`number`,`range`,`string`,`unit`]},matrix:{name:`matrix`,category:`Construction`,syntax:[`[]`,`[a1, b1, ...; a2, b2, ...]`,`matrix()`,`matrix("dense")`,`matrix([...])`],description:`Create a matrix.`,examples:[`[]`,`[1, 2, 3]`,`[1, 2, 3; 4, 5, 6]`,`matrix()`,`matrix([3, 4])`,`matrix([3, 4; 5, 6], "sparse")`,`matrix([3, 4; 5, 6], "sparse", "number")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`number`,`string`,`unit`,`sparse`]},number:{name:`number`,category:`Construction`,syntax:[`x`,`number(x)`,`number(unit, valuelessUnit)`],description:`Create a number or convert a string or boolean into a number.`,examples:[`2`,`2e3`,`4.05`,`number(2)`,`number("7.2")`,`number(true)`,`number([true, false, true, true])`,`number(unit("52cm"), "m")`],seealso:[`bignumber`,`bigint`,`boolean`,`complex`,`fraction`,`index`,`matrix`,`string`,`unit`]},sparse:{name:`sparse`,category:`Construction`,syntax:[`sparse()`,`sparse([a1, b1, ...; a1, b2, ...])`,`sparse([a1, b1, ...; a1, b2, ...], "number")`],description:`Create a sparse matrix.`,examples:[`sparse()`,`sparse([3, 4; 5, 6])`,`sparse([3, 0; 5, 0], "number")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`number`,`string`,`unit`,`matrix`]},splitUnit:{name:`splitUnit`,category:`Construction`,syntax:[`splitUnit(unit: Unit, parts: Unit[])`],description:`Split a unit in an array of units whose sum is equal to the original unit.`,examples:[`splitUnit(1 m, ["feet", "inch"])`],seealso:[`unit`,`createUnit`]},string:{name:`string`,category:`Construction`,syntax:[`"text"`,`string(x)`],description:`Create a string or convert a value to a string`,examples:[`"Hello World!"`,`string(4.2)`,`string(3 + 2i)`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`number`,`unit`]},unit:{name:`unit`,category:`Construction`,syntax:[`value unit`,`unit(value, unit)`,`unit(string)`],description:`Create a unit.`,examples:[`5.5 mm`,`3 inch`,`unit(7.1, "kilogram")`,`unit("23 deg")`],seealso:[`bignumber`,`boolean`,`complex`,`index`,`matrix`,`number`,`string`]},e:lb,E:lb,false:ub,i:db,Infinity:fb,LN2:mb,LN10:pb,LOG2E:gb,LOG10E:hb,NaN:_b,null:vb,pi:bb,PI:bb,phi:yb,SQRT1_2:{name:`SQRT1_2`,category:`Constants`,syntax:[`SQRT1_2`],description:`Returns the square root of 1/2, approximately equal to 0.707`,examples:[`SQRT1_2`,`sqrt(1/2)`],seealso:[]},SQRT2:{name:`SQRT2`,category:`Constants`,syntax:[`SQRT2`],description:`Returns the square root of 2, approximately equal to 1.414`,examples:[`SQRT2`,`sqrt(2)`],seealso:[]},tau:{name:`tau`,category:`Constants`,syntax:[`tau`],description:`Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.`,examples:[`tau`,`2 * pi`],seealso:[`pi`]},true:{name:`true`,category:`Constants`,syntax:[`true`],description:`Boolean value true`,examples:[`true`],seealso:[`false`]},version:{name:`version`,category:`Constants`,syntax:[`version`],description:`A string with the version number of math.js`,examples:[`version`],seealso:[]},speedOfLight:{description:`Speed of light in vacuum`,examples:[`speedOfLight`]},gravitationConstant:{description:`Newtonian constant of gravitation`,examples:[`gravitationConstant`]},planckConstant:{description:`Planck constant`,examples:[`planckConstant`]},reducedPlanckConstant:{description:`Reduced Planck constant`,examples:[`reducedPlanckConstant`]},magneticConstant:{description:`Magnetic constant (vacuum permeability)`,examples:[`magneticConstant`]},electricConstant:{description:`Electric constant (vacuum permeability)`,examples:[`electricConstant`]},vacuumImpedance:{description:`Characteristic impedance of vacuum`,examples:[`vacuumImpedance`]},coulomb:{description:`Coulomb's constant. Deprecated in favor of coulombConstant`,examples:[`coulombConstant`]},coulombConstant:{description:`Coulomb's constant`,examples:[`coulombConstant`]},elementaryCharge:{description:`Elementary charge`,examples:[`elementaryCharge`]},bohrMagneton:{description:`Bohr magneton`,examples:[`bohrMagneton`]},conductanceQuantum:{description:`Conductance quantum`,examples:[`conductanceQuantum`]},inverseConductanceQuantum:{description:`Inverse conductance quantum`,examples:[`inverseConductanceQuantum`]},magneticFluxQuantum:{description:`Magnetic flux quantum`,examples:[`magneticFluxQuantum`]},nuclearMagneton:{description:`Nuclear magneton`,examples:[`nuclearMagneton`]},klitzing:{description:`Von Klitzing constant`,examples:[`klitzing`]},bohrRadius:{description:`Bohr radius`,examples:[`bohrRadius`]},classicalElectronRadius:{description:`Classical electron radius`,examples:[`classicalElectronRadius`]},electronMass:{description:`Electron mass`,examples:[`electronMass`]},fermiCoupling:{description:`Fermi coupling constant`,examples:[`fermiCoupling`]},fineStructure:{description:`Fine-structure constant`,examples:[`fineStructure`]},hartreeEnergy:{description:`Hartree energy`,examples:[`hartreeEnergy`]},protonMass:{description:`Proton mass`,examples:[`protonMass`]},deuteronMass:{description:`Deuteron Mass`,examples:[`deuteronMass`]},neutronMass:{description:`Neutron mass`,examples:[`neutronMass`]},quantumOfCirculation:{description:`Quantum of circulation`,examples:[`quantumOfCirculation`]},rydberg:{description:`Rydberg constant`,examples:[`rydberg`]},thomsonCrossSection:{description:`Thomson cross section`,examples:[`thomsonCrossSection`]},weakMixingAngle:{description:`Weak mixing angle`,examples:[`weakMixingAngle`]},efimovFactor:{description:`Efimov factor`,examples:[`efimovFactor`]},atomicMass:{description:`Atomic mass constant`,examples:[`atomicMass`]},avogadro:{description:`Avogadro's number`,examples:[`avogadro`]},boltzmann:{description:`Boltzmann constant`,examples:[`boltzmann`]},faraday:{description:`Faraday constant`,examples:[`faraday`]},firstRadiation:{description:`First radiation constant`,examples:[`firstRadiation`]},loschmidt:{description:`Loschmidt constant at T=273.15 K and p=101.325 kPa`,examples:[`loschmidt`]},gasConstant:{description:`Gas constant`,examples:[`gasConstant`]},molarPlanckConstant:{description:`Molar Planck constant`,examples:[`molarPlanckConstant`]},molarVolume:{description:`Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa`,examples:[`molarVolume`]},sackurTetrode:{description:`Sackur-Tetrode constant at T=1 K and p=101.325 kPa`,examples:[`sackurTetrode`]},secondRadiation:{description:`Second radiation constant`,examples:[`secondRadiation`]},stefanBoltzmann:{description:`Stefan-Boltzmann constant`,examples:[`stefanBoltzmann`]},wienDisplacement:{description:`Wien displacement law constant`,examples:[`wienDisplacement`]},molarMass:{description:`Molar mass constant`,examples:[`molarMass`]},molarMassC12:{description:`Molar mass constant of carbon-12`,examples:[`molarMassC12`]},gravity:{description:`Standard acceleration of gravity (standard acceleration of free-fall on Earth)`,examples:[`gravity`]},planckLength:{description:`Planck length`,examples:[`planckLength`]},planckMass:{description:`Planck mass`,examples:[`planckMass`]},planckTime:{description:`Planck time`,examples:[`planckTime`]},planckCharge:{description:`Planck charge`,examples:[`planckCharge`]},planckTemperature:{description:`Planck temperature`,examples:[`planckTemperature`]},derivative:{name:`derivative`,category:`Algebra`,syntax:[`derivative(expr, variable)`,`derivative(expr, variable, {simplify: boolean})`],description:`Takes the derivative of an expression expressed in parser Nodes. The derivative will be taken over the supplied variable in the second parameter. If there are multiple variables in the expression, it will return a partial derivative.`,examples:[`derivative("2x^3", "x")`,`derivative("2x^3", "x", {simplify: false})`,`derivative("2x^2 + 3x + 4", "x")`,`derivative("sin(2x)", "x")`,`f = parse("x^2 + x")`,`x = parse("x")`,`df = derivative(f, x)`,`df.evaluate({x: 3})`],seealso:[`simplify`,`parse`,`evaluate`]},lsolve:{name:`lsolve`,category:`Algebra`,syntax:[`x=lsolve(L, b)`],description:`Finds one solution of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lsolve(a, b)`],seealso:[`lsolveAll`,`lup`,`lusolve`,`usolve`,`matrix`,`sparse`]},lsolveAll:{name:`lsolveAll`,category:`Algebra`,syntax:[`x=lsolveAll(L, b)`],description:`Finds all solutions of the linear system L * x = b where L is an [n x n] lower triangular matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lsolve(a, b)`],seealso:[`lsolve`,`lup`,`lusolve`,`usolve`,`matrix`,`sparse`]},lup:{name:`lup`,category:`Algebra`,syntax:[`lup(m)`],description:`Calculate the Matrix LU decomposition with partial pivoting. Matrix A is decomposed in three matrices (L, U, P) where P * A = L * U`,examples:[`lup([[2, 1], [1, 4]])`,`lup(matrix([[2, 1], [1, 4]]))`,`lup(sparse([[2, 1], [1, 4]]))`],seealso:[`lusolve`,`lsolve`,`usolve`,`matrix`,`sparse`,`slu`,`qr`]},lusolve:{name:`lusolve`,category:`Algebra`,syntax:[`x=lusolve(A, b)`,`x=lusolve(lu, b)`],description:`Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector.`,examples:[`a = [-2, 3; 2, 1]`,`b = [11, 9]`,`x = lusolve(a, b)`],seealso:[`lup`,`slu`,`lsolve`,`usolve`,`matrix`,`sparse`]},leafCount:{name:`leafCount`,category:`Algebra`,syntax:[`leafCount(expr)`],description:`Computes the number of leaves in the parse tree of the given expression`,examples:[`leafCount("e^(i*pi)-1")`,`leafCount(parse("{a: 22/7, b: 10^(1/2)}"))`],seealso:[`simplify`]},polynomialRoot:{name:`polynomialRoot`,category:`Algebra`,syntax:[`x=polynomialRoot(-6, 3)`,`x=polynomialRoot(4, -4, 1)`,`x=polynomialRoot(-8, 12, -6, 1)`],description:`Finds the roots of a univariate polynomial given by its coefficients starting from constant, linear, and so on, increasing in degree.`,examples:[`a = polynomialRoot(-6, 11, -6, 1)`],seealso:[`cbrt`,`sqrt`]},resolve:{name:`resolve`,category:`Algebra`,syntax:[`resolve(node, scope)`],description:`Recursively substitute variables in an expression tree.`,examples:[`resolve(parse("1 + x"), { x: 7 })`,`resolve(parse("size(text)"), { text: "Hello World" })`,`resolve(parse("x + y"), { x: parse("3z") })`,`resolve(parse("3x"), { x: parse("y+z"), z: parse("w^y") })`],seealso:[`simplify`,`evaluate`],mayThrow:[`ReferenceError`]},simplify:{name:`simplify`,category:`Algebra`,syntax:[`simplify(expr)`,`simplify(expr, rules)`],description:`Simplify an expression tree.`,examples:[`simplify("3 + 2 / 4")`,`simplify("2x + x")`,`f = parse("x * (x + 2 + x)")`,`simplified = simplify(f)`,`simplified.evaluate({x: 2})`],seealso:[`simplifyCore`,`derivative`,`evaluate`,`parse`,`rationalize`,`resolve`]},simplifyConstant:{name:`simplifyConstant`,category:`Algebra`,syntax:[`simplifyConstant(expr)`,`simplifyConstant(expr, options)`],description:`Replace constant subexpressions of node with their values.`,examples:[`simplifyConstant("(3-3)*x")`,`simplifyConstant(parse("z-cos(tau/8)"))`],seealso:[`simplify`,`simplifyCore`,`evaluate`]},simplifyCore:{name:`simplifyCore`,category:`Algebra`,syntax:[`simplifyCore(node)`],description:`Perform simple one-pass simplifications on an expression tree.`,examples:[`simplifyCore(parse("0*x"))`,`simplifyCore(parse("(x+0)*2"))`],seealso:[`simplify`,`simplifyConstant`,`evaluate`]},symbolicEqual:{name:`symbolicEqual`,category:`Algebra`,syntax:[`symbolicEqual(expr1, expr2)`,`symbolicEqual(expr1, expr2, options)`],description:`Returns true if the difference of the expressions simplifies to 0`,examples:[`symbolicEqual("x*y","y*x")`,`symbolicEqual("abs(x^2)", "x^2")`,`symbolicEqual("abs(x)", "x", {context: {abs: {trivial: true}}})`],seealso:[`simplify`,`evaluate`]},rationalize:{name:`rationalize`,category:`Algebra`,syntax:[`rationalize(expr)`,`rationalize(expr, scope)`,`rationalize(expr, scope, detailed)`],description:`Transform a rationalizable expression in a rational fraction. If rational fraction is one variable polynomial then converts the numerator and denominator in canonical form, with decreasing exponents, returning the coefficients of numerator.`,examples:[`rationalize("2x/y - y/(x+1)")`,`rationalize("2x/y - y/(x+1)", true)`],seealso:[`simplify`]},slu:{name:`slu`,category:`Algebra`,syntax:[`slu(A, order, threshold)`],description:`Calculate the Matrix LU decomposition with full pivoting. Matrix A is decomposed in two matrices (L, U) and two permutation vectors (pinv, q) where P * A * Q = L * U`,examples:[`slu(sparse([4.5, 0, 3.2, 0; 3.1, 2.9, 0, 0.9; 0, 1.7, 3, 0; 3.5, 0.4, 0, 1]), 1, 0.001)`],seealso:[`lusolve`,`lsolve`,`usolve`,`matrix`,`sparse`,`lup`,`qr`]},usolve:{name:`usolve`,category:`Algebra`,syntax:[`x=usolve(U, b)`],description:`Finds one solution of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.`,examples:[`x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])`],seealso:[`usolveAll`,`lup`,`lusolve`,`lsolve`,`matrix`,`sparse`]},usolveAll:{name:`usolveAll`,category:`Algebra`,syntax:[`x=usolve(U, b)`],description:`Finds all solutions of the linear system U * x = b where U is an [n x n] upper triangular matrix and b is a [n] column vector.`,examples:[`x=usolve(sparse([1, 1, 1, 1; 0, 1, 1, 1; 0, 0, 1, 1; 0, 0, 0, 1]), [1; 2; 3; 4])`],seealso:[`usolve`,`lup`,`lusolve`,`lsolve`,`matrix`,`sparse`]},qr:{name:`qr`,category:`Algebra`,syntax:[`qr(A)`],description:"Calculates the Matrix QR decomposition. Matrix `A` is decomposed in two matrices (`Q`, `R`) where `Q` is an orthogonal matrix and `R` is an upper triangular matrix.",examples:[`qr([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])`],seealso:[`lup`,`slu`,`matrix`]},abs:{name:`abs`,category:`Arithmetic`,syntax:[`abs(x)`],description:`Compute the absolute value.`,examples:[`abs(3.5)`,`abs(-4.2)`],seealso:[`sign`]},add:{name:`add`,category:`Operators`,syntax:[`x + y`,`add(x, y)`],description:`Add two values.`,examples:[`a = 2.1 + 3.6`,`a - 3.6`,`3 + 2i`,`3 cm + 2 inch`,`"2.3" + "4"`],seealso:[`subtract`]},cbrt:{name:`cbrt`,category:`Arithmetic`,syntax:[`cbrt(x)`,`cbrt(x, allRoots)`],description:"Compute the cubic root value. If x = y * y * y, then y is the cubic root of x. When `x` is a number or complex number, an optional second argument `allRoots` can be provided to return all three cubic roots. If not provided, the principal root is returned",examples:[`cbrt(64)`,`cube(4)`,`cbrt(-8)`,`cbrt(2 + 3i)`,`cbrt(8i)`,`cbrt(8i, true)`,`cbrt(27 m^3)`],seealso:[`square`,`sqrt`,`cube`,`multiply`]},ceil:{name:`ceil`,category:`Arithmetic`,syntax:[`ceil(x)`,`ceil(x, n)`,`ceil(unit, valuelessUnit)`,`ceil(unit, n, valuelessUnit)`],description:`Round a value towards plus infinity. If x is complex, both real and imaginary part are rounded towards plus infinity.`,examples:[`ceil(3.2)`,`ceil(3.8)`,`ceil(-4.2)`,`ceil(3.241cm, cm)`,`ceil(3.241cm, 2, cm)`],seealso:[`floor`,`fix`,`round`]},cube:{name:`cube`,category:`Arithmetic`,syntax:[`cube(x)`],description:`Compute the cube of a value. The cube of x is x * x * x.`,examples:[`cube(2)`,`2^3`,`2 * 2 * 2`],seealso:[`multiply`,`square`,`pow`]},divide:{name:`divide`,category:`Operators`,syntax:[`x / y`,`divide(x, y)`],description:`Divide two values.`,examples:[`a = 2 / 3`,`a * 3`,`4.5 / 2`,`3 + 4 / 2`,`(3 + 4) / 2`,`18 km / 4.5`],seealso:[`multiply`]},dotDivide:{name:`dotDivide`,category:`Operators`,syntax:[`x ./ y`,`dotDivide(x, y)`],description:`Divide two values element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`b = [2, 1, 1; 3, 2, 5]`,`a ./ b`],seealso:[`multiply`,`dotMultiply`,`divide`]},dotMultiply:{name:`dotMultiply`,category:`Operators`,syntax:[`x .* y`,`dotMultiply(x, y)`],description:`Multiply two values element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`b = [2, 1, 1; 3, 2, 5]`,`a .* b`],seealso:[`multiply`,`divide`,`dotDivide`]},dotPow:{name:`dotPow`,category:`Operators`,syntax:[`x .^ y`,`dotPow(x, y)`],description:`Calculates the power of x to y element wise.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a .^ 2`],seealso:[`pow`]},exp:{name:`exp`,category:`Arithmetic`,syntax:[`exp(x)`],description:`Calculate the exponent of a value.`,examples:[`exp(1.3)`,`e ^ 1.3`,`log(exp(1.3))`,`x = 2.4`,`(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula`],seealso:[`expm`,`expm1`,`pow`,`log`]},expm:{name:`expm`,category:`Arithmetic`,syntax:[`exp(x)`],description:`Compute the matrix exponential, expm(A) = e^A. The matrix must be square. Not to be confused with exp(a), which performs element-wise exponentiation.`,examples:[`expm([[0,2],[0,0]])`],seealso:[`exp`]},expm1:{name:`expm1`,category:`Arithmetic`,syntax:[`expm1(x)`],description:`Calculate the value of subtracting 1 from the exponential value.`,examples:[`expm1(2)`,`pow(e, 2) - 1`,`log(expm1(2) + 1)`],seealso:[`exp`,`pow`,`log`]},fix:{name:`fix`,category:`Arithmetic`,syntax:[`fix(x)`,`fix(x, n)`,`fix(unit, valuelessUnit)`,`fix(unit, n, valuelessUnit)`],description:`Round a value towards zero. If x is complex, both real and imaginary part are rounded towards zero.`,examples:[`fix(3.2)`,`fix(3.8)`,`fix(-4.2)`,`fix(-4.8)`,`fix(3.241cm, cm)`,`fix(3.241cm, 2, cm)`],seealso:[`ceil`,`floor`,`round`]},floor:{name:`floor`,category:`Arithmetic`,syntax:[`floor(x)`,`floor(x, n)`,`floor(unit, valuelessUnit)`,`floor(unit, n, valuelessUnit)`],description:`Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.`,examples:[`floor(3.2)`,`floor(3.8)`,`floor(-4.2)`,`floor(3.241cm, cm)`,`floor(3.241cm, 2, cm)`],seealso:[`ceil`,`fix`,`round`]},gcd:{name:`gcd`,category:`Arithmetic`,syntax:[`gcd(a, b)`,`gcd(a, b, c, ...)`],description:`Compute the greatest common divisor.`,examples:[`gcd(8, 12)`,`gcd(-4, 6)`,`gcd(25, 15, -10)`],seealso:[`lcm`,`xgcd`]},hypot:{name:`hypot`,category:`Arithmetic`,syntax:[`hypot(a, b, c, ...)`,`hypot([a, b, c, ...])`],description:`Calculate the hypotenuse of a list with values.`,examples:[`hypot(3, 4)`,`sqrt(3^2 + 4^2)`,`hypot(-2)`,`hypot([3, 4, 5])`],seealso:[`abs`,`norm`]},lcm:{name:`lcm`,category:`Arithmetic`,syntax:[`lcm(x, y)`],description:`Compute the least common multiple.`,examples:[`lcm(4, 6)`,`lcm(6, 21)`,`lcm(6, 21, 5)`],seealso:[`gcd`]},log:{name:`log`,category:`Arithmetic`,syntax:[`log(x)`,`log(x, base)`],description:`Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).`,examples:[`log(3.5)`,`a = log(2.4)`,`exp(a)`,`10 ^ 4`,`log(10000, 10)`,`log(10000) / log(10)`,`b = log(1024, 2)`,`2 ^ b`],seealso:[`exp`,`log1p`,`log2`,`log10`]},log2:{name:`log2`,category:`Arithmetic`,syntax:[`log2(x)`],description:"Calculate the 2-base of a value. This is the same as calculating `log(x, 2)`.",examples:[`log2(0.03125)`,`log2(16)`,`log2(16) / log2(2)`,`pow(2, 4)`],seealso:[`exp`,`log1p`,`log`,`log10`]},log1p:{name:`log1p`,category:`Arithmetic`,syntax:[`log1p(x)`,`log1p(x, base)`],description:"Calculate the logarithm of a `value+1`",examples:[`log1p(2.5)`,`exp(log1p(1.4))`,`pow(10, 4)`,`log1p(9999, 10)`,`log1p(9999) / log(10)`],seealso:[`exp`,`log`,`log2`,`log10`]},log10:{name:`log10`,category:`Arithmetic`,syntax:[`log10(x)`],description:`Compute the 10-base logarithm of a value.`,examples:[`log10(0.00001)`,`log10(10000)`,`10 ^ 4`,`log(10000) / log(10)`,`log(10000, 10)`],seealso:[`exp`,`log`]},mod:{name:`mod`,category:`Operators`,syntax:[`x % y`,`x mod y`,`mod(x, y)`],description:`Calculates the modulus, the remainder of an integer division.`,examples:[`7 % 3`,`11 % 2`,`10 mod 4`,`isOdd(x) = x % 2`,`isOdd(2)`,`isOdd(3)`],seealso:[`divide`]},multiply:{name:`multiply`,category:`Operators`,syntax:[`x * y`,`multiply(x, y)`],description:`multiply two values.`,examples:[`a = 2.1 * 3.4`,`a / 3.4`,`2 * 3 + 4`,`2 * (3 + 4)`,`3 * 2.1 km`],seealso:[`divide`]},norm:{name:`norm`,category:`Arithmetic`,syntax:[`norm(x)`,`norm(x, p)`],description:`Calculate the norm of a number, vector or matrix.`,examples:[`abs(-3.5)`,`norm(-3.5)`,`norm(3 - 4i)`,`norm([1, 2, -3], Infinity)`,`norm([1, 2, -3], -Infinity)`,`norm([3, 4], 2)`,`norm([[1, 2], [3, 4]], 1)`,`norm([[1, 2], [3, 4]], "inf")`,`norm([[1, 2], [3, 4]], "fro")`]},nthRoot:{name:`nthRoot`,category:`Arithmetic`,syntax:[`nthRoot(a)`,`nthRoot(a, root)`],description:`Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".`,examples:[`4 ^ 3`,`nthRoot(64, 3)`,`nthRoot(9, 2)`,`sqrt(9)`],seealso:[`nthRoots`,`pow`,`sqrt`]},nthRoots:{name:`nthRoots`,category:`Arithmetic`,syntax:[`nthRoots(A)`,`nthRoots(A, root)`],description:`Calculate the nth roots of a value. An nth root of a positive real number A, is a positive real solution of the equation "x^root = A". This function returns an array of complex values.`,examples:[`nthRoots(1)`,`nthRoots(1, 3)`],seealso:[`sqrt`,`pow`,`nthRoot`]},pow:{name:`pow`,category:`Operators`,syntax:[`x ^ y`,`pow(x, y)`],description:`Calculates the power of x to y, x^y.`,examples:[`2^3`,`2*2*2`,`1 + e ^ (pi * i)`,`pow([[1, 2], [4, 3]], 2)`,`pow([[1, 2], [4, 3]], -1)`],seealso:[`multiply`,`nthRoot`,`nthRoots`,`sqrt`]},round:{name:`round`,category:`Arithmetic`,syntax:[`round(x)`,`round(x, n)`,`round(unit, valuelessUnit)`,`round(unit, n, valuelessUnit)`],description:`round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.`,examples:[`round(3.2)`,`round(3.8)`,`round(-4.2)`,`round(-4.8)`,`round(pi, 3)`,`round(123.45678, 2)`,`round(3.241cm, 2, cm)`,`round([3.2, 3.8, -4.7])`],seealso:[`ceil`,`floor`,`fix`]},sign:{name:`sign`,category:`Arithmetic`,syntax:[`sign(x)`],description:`Compute the sign of a value. The sign of a value x is 1 when x>0, -1 when x<0, and 0 when x=0.`,examples:[`sign(3.5)`,`sign(-4.2)`,`sign(0)`],seealso:[`abs`]},sqrt:{name:`sqrt`,category:`Arithmetic`,syntax:[`sqrt(x)`],description:`Compute the square root value. If x = y * y, then y is the square root of x.`,examples:[`sqrt(25)`,`5 * 5`,`sqrt(-1)`],seealso:[`square`,`sqrtm`,`multiply`,`nthRoot`,`nthRoots`,`pow`]},sqrtm:{name:`sqrtm`,category:`Arithmetic`,syntax:[`sqrtm(x)`],description:"Calculate the principal square root of a square matrix. The principal square root matrix `X` of another matrix `A` is such that `X * X = A`.",examples:[`sqrtm([[33, 24], [48, 57]])`],seealso:[`sqrt`,`abs`,`square`,`multiply`]},square:{name:`square`,category:`Arithmetic`,syntax:[`square(x)`],description:`Compute the square of a value. The square of x is x * x.`,examples:[`square(3)`,`sqrt(9)`,`3^2`,`3 * 3`],seealso:[`multiply`,`pow`,`sqrt`,`cube`]},subtract:{name:`subtract`,category:`Operators`,syntax:[`x - y`,`subtract(x, y)`],description:`subtract two values.`,examples:[`a = 5.3 - 2`,`a + 2`,`2/3 - 1/6`,`2 * 3 - 3`,`2.1 km - 500m`],seealso:[`add`]},unaryMinus:{name:`unaryMinus`,category:`Operators`,syntax:[`-x`,`unaryMinus(x)`],description:`Inverse the sign of a value. Converts booleans and strings to numbers.`,examples:[`-4.5`,`-(-5.6)`,`-"22"`],seealso:[`add`,`subtract`,`unaryPlus`]},unaryPlus:{name:`unaryPlus`,category:`Operators`,syntax:[`+x`,`unaryPlus(x)`],description:`Converts booleans and strings to numbers.`,examples:[`+true`,`+"2"`],seealso:[`add`,`subtract`,`unaryMinus`]},xgcd:{name:`xgcd`,category:`Arithmetic`,syntax:[`xgcd(a, b)`],description:`Calculate the extended greatest common divisor for two values. The result is an array [d, x, y] with 3 entries, where d is the greatest common divisor, and d = x * a + y * b.`,examples:[`xgcd(8, 12)`,`gcd(8, 12)`,`xgcd(36163, 21199)`],seealso:[`gcd`,`lcm`]},invmod:{name:`invmod`,category:`Arithmetic`,syntax:[`invmod(a, b)`],description:`Calculate the (modular) multiplicative inverse of a modulo b. Solution to the equation ax ≣ 1 (mod b)`,examples:[`invmod(8, 12)`,`invmod(7, 13)`,`invmod(15151, 15122)`],seealso:[`gcd`,`xgcd`]},num:{name:`num`,category:`Fraction`,syntax:[`num(x)`],description:`Get the numerator of a fraction.`,examples:[`num(fraction(2, 3))`,`num(fraction(5, 8))`],seealso:[`den`,`fraction`]},den:{name:`den`,category:`Fraction`,syntax:[`den(x)`],description:`Get the denominator of a fraction.`,examples:[`den(fraction(2, 3))`,`den(fraction(5, 8))`],seealso:[`num`,`fraction`]},bitAnd:{name:`bitAnd`,category:`Bitwise`,syntax:[`x & y`,`bitAnd(x, y)`],description:`Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0`,examples:[`5 & 3`,`bitAnd(53, 131)`,`[1, 12, 31] & 42`],seealso:[`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitNot:{name:`bitNot`,category:`Bitwise`,syntax:[`~x`,`bitNot(x)`],description:`Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.`,examples:[`~1`,`~2`,`bitNot([2, -3, 4])`],seealso:[`bitAnd`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitOr:{name:`bitOr`,category:`Bitwise`,syntax:[`x | y`,`bitOr(x, y)`],description:`Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.`,examples:[`5 | 3`,`bitOr([1, 2, 3], 4)`],seealso:[`bitAnd`,`bitNot`,`bitXor`,`leftShift`,`rightArithShift`,`rightLogShift`]},bitXor:{name:`bitXor`,category:`Bitwise`,syntax:[`bitXor(x, y)`],description:`Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.`,examples:[`bitOr(1, 2)`,`bitXor([2, 3, 4], 4)`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`leftShift`,`rightArithShift`,`rightLogShift`]},leftShift:{name:`leftShift`,category:`Bitwise`,syntax:[`x << y`,`leftShift(x, y)`],description:`Bitwise left logical shift of a value x by y number of bits.`,examples:[`4 << 1`,`8 >> 1`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`rightArithShift`,`rightLogShift`]},rightArithShift:{name:`rightArithShift`,category:`Bitwise`,syntax:[`x >> y`,`rightArithShift(x, y)`],description:`Bitwise right arithmetic shift of a value x by y number of bits.`,examples:[`8 >> 1`,`4 << 1`,`-12 >> 2`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightLogShift`]},rightLogShift:{name:`rightLogShift`,category:`Bitwise`,syntax:[`x >>> y`,`rightLogShift(x, y)`],description:`Bitwise right logical shift of a value x by y number of bits.`,examples:[`8 >>> 1`,`4 << 1`,`-12 >>> 2`],seealso:[`bitAnd`,`bitNot`,`bitOr`,`bitXor`,`leftShift`,`rightArithShift`]},bellNumbers:{name:`bellNumbers`,category:`Combinatorics`,syntax:[`bellNumbers(n)`],description:"The Bell Numbers count the number of partitions of a set. A partition is a pairwise disjoint subset of S whose union is S. `bellNumbers` only takes integer arguments. The following condition must be enforced: n >= 0.",examples:[`bellNumbers(3)`,`bellNumbers(8)`],seealso:[`stirlingS2`]},catalan:{name:`catalan`,category:`Combinatorics`,syntax:[`catalan(n)`],description:`The Catalan Numbers enumerate combinatorial structures of many different types. catalan only takes integer arguments. The following condition must be enforced: n >= 0.`,examples:[`catalan(3)`,`catalan(8)`],seealso:[`bellNumbers`]},composition:{name:`composition`,category:`Combinatorics`,syntax:[`composition(n, k)`],description:`The composition counts of n into k parts. composition only takes integer arguments. The following condition must be enforced: k <= n.`,examples:[`composition(5, 3)`],seealso:[`combinations`]},stirlingS2:{name:`stirlingS2`,category:`Combinatorics`,syntax:[`stirlingS2(n, k)`],description:"The Stirling numbers of the second kind, counts the number of ways to partition a set of n labelled objects into k nonempty unlabelled subsets. `stirlingS2` only takes integer arguments. The following condition must be enforced: k <= n. If n = k or k = 1, then s(n,k) = 1.",examples:[`stirlingS2(5, 3)`],seealso:[`bellNumbers`,`bernoulli`]},config:{name:`config`,category:`Core`,syntax:[`config()`,`config(options)`],description:`Get configuration or change configuration.`,examples:[`config()`,`1/3 + 1/4`,`config({number: "Fraction"})`,`1/3 + 1/4`],seealso:[]},import:{name:`import`,category:`Core`,syntax:[`import(functions)`,`import(functions, options)`],description:`Import functions or constants from an object.`,examples:[`import({myFn: f(x)=x^2, myConstant: 32 })`,`myFn(2)`,`myConstant`],seealso:[]},typed:{name:`typed`,category:`Core`,syntax:[`typed(signatures)`,`typed(name, signatures)`],description:`Create a typed function.`,examples:[`double = typed({ "number": f(x)=x+x, "string": f(x)=concat(x,x) })`,`double(2)`,`double("hello")`],seealso:[]},arg:{name:`arg`,category:`Complex`,syntax:[`arg(x)`],description:`Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).`,examples:[`arg(2 + 2i)`,`atan2(3, 2)`,`arg(2 + 3i)`],seealso:[`re`,`im`,`conj`,`abs`]},conj:{name:`conj`,category:`Complex`,syntax:[`conj(x)`],description:`Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.`,examples:[`conj(2 + 3i)`,`conj(2 - 3i)`,`conj(-5.2i)`],seealso:[`re`,`im`,`abs`,`arg`]},re:{name:`re`,category:`Complex`,syntax:[`re(x)`],description:`Get the real part of a complex number.`,examples:[`re(2 + 3i)`,`im(2 + 3i)`,`re(-5.2i)`,`re(2.4)`],seealso:[`im`,`conj`,`abs`,`arg`]},im:{name:`im`,category:`Complex`,syntax:[`im(x)`],description:`Get the imaginary part of a complex number.`,examples:[`im(2 + 3i)`,`re(2 + 3i)`,`im(-5.2i)`,`im(2.4)`],seealso:[`re`,`conj`,`abs`,`arg`]},evaluate:{name:`evaluate`,category:`Expression`,syntax:[`evaluate(expression)`,`evaluate(expression, scope)`,`evaluate([expr1, expr2, expr3, ...])`,`evaluate([expr1, expr2, expr3, ...], scope)`],description:`Evaluate an expression or an array with expressions.`,examples:[`evaluate("2 + 3")`,`evaluate("sqrt(16)")`,`evaluate("2 inch to cm")`,`evaluate("sin(x * pi)", { "x": 1/2 })`,`evaluate(["width=2", "height=4","width*height"])`],seealso:[`parser`,`parse`,`compile`]},help:{name:`help`,category:`Expression`,syntax:[`help(object)`,`help(string)`],description:`Display documentation on a function or data type.`,examples:[`help(sqrt)`,`help("complex")`],seealso:[]},parse:{name:`parse`,category:`Expression`,syntax:[`parse(expr)`,`parse(expr, options)`,`parse([expr1, expr2, expr3, ...])`,`parse([expr1, expr2, expr3, ...], options)`],description:`Parse an expression. Returns a node tree, which can be evaluated by invoking node.evaluate() or transformed into a functional object via node.compile().`,examples:[`node1 = parse("sqrt(3^2 + 4^2)")`,`node1.evaluate()`,`code1 = node1.compile()`,`code1.evaluate()`,`scope = {a: 3, b: 4}`,`node2 = parse("a * b")`,`node2.evaluate(scope)`,`code2 = node2.compile()`,`code2.evaluate(scope)`],seealso:[`parser`,`evaluate`,`compile`]},parser:{name:`parser`,category:`Expression`,syntax:[`parser()`],description:`Create a parser object that keeps a context of variables and their values, allowing the evaluation of expressions in that context.`,examples:[`myParser = parser()`,`myParser.evaluate("sqrt(3^2 + 4^2)")`,`myParser.set("x", 3)`,`myParser.evaluate("y = x + 3")`,`myParser.evaluate(["y = x + 3", "y = y + 1"])`,`myParser.get("y")`],seealso:[`evaluate`,`parse`,`compile`]},compile:{name:`compile`,category:`Expression`,syntax:[`compile(expr) `,`compile([expr1, expr2, expr3, ...])`],description:`Parse and compile an expression. Returns a an object with a function evaluate([scope]) to evaluate the compiled expression.`,examples:[`code1 = compile("sqrt(3^2 + 4^2)")`,`code1.evaluate() `,`code2 = compile("a * b")`,`code2.evaluate({a: 3, b: 4})`],seealso:[`parser`,`parse`,`evaluate`]},distance:{name:`distance`,category:`Geometry`,syntax:[`distance([x1, y1], [x2, y2])`,`distance([[x1, y1], [x2, y2]])`],description:`Calculates the Euclidean distance between two points.`,examples:[`distance([0,0], [4,4])`,`distance([[0,0], [4,4]])`],seealso:[]},intersect:{name:`intersect`,category:`Geometry`,syntax:[`intersect(expr1, expr2, expr3, expr4)`,`intersect(expr1, expr2, expr3)`],description:`Computes the intersection point of lines and/or planes.`,examples:[`intersect([0, 0], [10, 10], [10, 0], [0, 10])`,`intersect([1, 0, 1], [4, -2, 2], [1, 1, 1, 6])`],seealso:[]},and:{name:`and`,category:`Logical`,syntax:[`x and y`,`and(x, y)`],description:`Logical and. Test whether two values are both defined with a nonzero/nonempty value.`,examples:[`true and false`,`true and true`,`2 and 4`],seealso:[`not`,`or`,`xor`]},not:{name:`not`,category:`Logical`,syntax:[`not x`,`not(x)`],description:`Logical not. Flips the boolean value of given argument.`,examples:[`not true`,`not false`,`not 2`,`not 0`],seealso:[`and`,`or`,`xor`]},nullish:{name:`nullish`,category:`Logical`,syntax:[`x ?? y`,`nullish(x, y)`],description:`Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.`,examples:[`null ?? 42`,`undefined ?? 42`,`0 ?? 42`,`false ?? 42`,`null ?? undefined ?? 42`],seealso:[`and`,`or`,`not`]},or:{name:`or`,category:`Logical`,syntax:[`x or y`,`or(x, y)`],description:`Logical or. Test if at least one value is defined with a nonzero/nonempty value.`,examples:[`true or false`,`false or false`,`0 or 4`],seealso:[`not`,`and`,`xor`]},xor:{name:`xor`,category:`Logical`,syntax:[`x xor y`,`xor(x, y)`],description:`Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.`,examples:[`true xor false`,`false xor false`,`true xor true`,`0 xor 4`],seealso:[`not`,`and`,`or`]},mapSlices:{name:`mapSlices`,category:`Matrix`,syntax:[`mapSlices(A, dim, callback)`],description:`Generate a matrix one dimension less than A by applying callback to each slice of A along dimension dim.`,examples:[`A = [[1, 2], [3, 4]]`,`mapSlices(A, 1, sum)`,`mapSlices(A, 2, prod)`],seealso:[`map`,`forEach`]},concat:{name:`concat`,category:`Matrix`,syntax:[`concat(A, B, C, ...)`,`concat(A, B, C, ..., dim)`],description:`Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.`,examples:[`A = [1, 2; 5, 6]`,`B = [3, 4; 7, 8]`,`concat(A, B)`,`concat(A, B, 1)`,`concat(A, B, 2)`],seealso:[`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},count:{name:`count`,category:`Matrix`,syntax:[`count(x)`],description:`Count the number of elements of a matrix, array or string.`,examples:[`a = [1, 2; 3, 4; 5, 6]`,`count(a)`,`size(a)`,`count("hello world")`],seealso:[`size`]},cross:{name:`cross`,category:`Matrix`,syntax:[`cross(A, B)`],description:`Calculate the cross product for two vectors in three dimensional space.`,examples:[`cross([1, 1, 0], [0, 1, 1])`,`cross([3, -3, 1], [4, 9, 2])`,`cross([2, 3, 4], [5, 6, 7])`],seealso:[`multiply`,`dot`]},column:{name:`column`,category:`Matrix`,syntax:[`column(x, index)`],description:`Return a column from a matrix or array.`,examples:[`A = [[1, 2], [3, 4]]`,`column(A, 1)`,`column(A, 2)`],seealso:[`row`,`matrixFromColumns`]},ctranspose:{name:`ctranspose`,category:`Matrix`,syntax:[`x'`,`ctranspose(x)`],description:`Complex Conjugate and Transpose a matrix`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a'`,`ctranspose(a)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`zeros`]},det:{name:`det`,category:`Matrix`,syntax:[`det(x)`],description:`Calculate the determinant of a matrix`,examples:[`det([1, 2; 3, 4])`,`det([-2, 2, 3; -1, 1, 3; 2, 0, -1])`],seealso:[`concat`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},diag:{name:`diag`,category:`Matrix`,syntax:[`diag(x)`,`diag(x, k)`],description:`Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.`,examples:[`diag(1:3)`,`diag(1:3, 1)`,`a = [1, 2, 3; 4, 5, 6; 7, 8, 9]`,`diag(a)`],seealso:[`concat`,`det`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},diff:{name:`diff`,category:`Matrix`,syntax:[`diff(arr)`,`diff(arr, dim)`],description:[`Create a new matrix or array with the difference of the passed matrix or array.`,`Dim parameter is optional and used to indicate the dimension of the array/matrix to apply the difference`,`If no dimension parameter is passed it is assumed as dimension 0`,`Dimension is zero-based in javascript and one-based in the parser`,`Arrays must be 'rectangular' meaning arrays like [1, 2]`,`If something is passed as a matrix it will be returned as a matrix but other than that all matrices are converted to arrays`],examples:[`A = [1, 2, 4, 7, 0]`,`diff(A)`,`diff(A, 1)`,`B = [[1, 2], [3, 4]]`,`diff(B)`,`diff(B, 1)`,`diff(B, 2)`,`diff(B, bignumber(2))`,`diff([[1, 2], matrix([3, 4])], 2)`],seealso:[`subtract`,`partitionSelect`]},dot:{name:`dot`,category:`Matrix`,syntax:[`dot(A, B)`,`A * B`],description:`Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn`,examples:[`dot([2, 4, 1], [2, 2, 3])`,`[2, 4, 1] * [2, 2, 3]`],seealso:[`multiply`,`cross`]},getMatrixDataType:{name:`getMatrixDataType`,category:`Matrix`,syntax:[`getMatrixDataType(x)`],description:`Find the data type of all elements in a matrix or array, for example "number" if all items are a number and "Complex" if all values are complex numbers. If a matrix contains more than one data type, it will return "mixed".`,examples:[`getMatrixDataType([1, 2, 3])`,`getMatrixDataType([[5 cm], [2 inch]])`,`getMatrixDataType([1, "text"])`,`getMatrixDataType([1, bignumber(4)])`],seealso:[`matrix`,`sparse`,`typeOf`]},identity:{name:`identity`,category:`Matrix`,syntax:[`identity(n)`,`identity(m, n)`,`identity([m, n])`],description:`Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.`,examples:[`identity(3)`,`identity(3, 5)`,`a = [1, 2, 3; 4, 5, 6]`,`identity(size(a))`],seealso:[`concat`,`det`,`diag`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},filter:{name:`filter`,category:`Matrix`,syntax:[`filter(x, test)`],description:`Filter items in a matrix.`,examples:[`isPositive(x) = x > 0`,`filter([6, -2, -1, 4, 3], isPositive)`,`filter([6, -2, 0, 1, 0], x != 0)`],seealso:[`sort`,`map`,`forEach`]},flatten:{name:`flatten`,category:`Matrix`,syntax:[`flatten(x)`],description:`Flatten a multi dimensional matrix into a single dimensional matrix.`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`size(a)`,`b = flatten(a)`,`size(b)`],seealso:[`concat`,`resize`,`size`,`squeeze`]},forEach:{name:`forEach`,category:`Matrix`,syntax:[`forEach(x, callback)`],description:`Iterates over all elements of a matrix/array, and executes the given callback function.`,examples:[`numberOfPets = {}`,`addPet(n) = numberOfPets[n] = (numberOfPets[n] ? numberOfPets[n]:0 ) + 1;`,`forEach(["Dog","Cat","Cat"], addPet)`,`numberOfPets`],seealso:[`map`,`sort`,`filter`]},inv:{name:`inv`,category:`Matrix`,syntax:[`inv(x)`],description:`Calculate the inverse of a matrix`,examples:[`inv([1, 2; 3, 4])`,`inv(4)`,`1 / 4`],seealso:[`concat`,`det`,`diag`,`identity`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},pinv:{name:`pinv`,category:`Matrix`,syntax:[`pinv(x)`],description:`Calculate the Moore–Penrose inverse of a matrix`,examples:[`pinv([1, 2; 3, 4])`,`pinv([[1, 0], [0, 1], [0, 1]])`,`pinv(4)`],seealso:[`inv`]},eigs:{name:`eigs`,category:`Matrix`,syntax:[`eigs(x)`],description:`Calculate the eigenvalues and optionally eigenvectors of a square matrix`,examples:[`eigs([[5, 2.3], [2.3, 1]])`,`eigs([[1, 2, 3], [4, 5, 6], [7, 8, 9]], { precision: 1e-6, eigenvectors: false })`],seealso:[`inv`]},kron:{name:`kron`,category:`Matrix`,syntax:[`kron(x, y)`],description:`Calculates the Kronecker product of 2 matrices or vectors.`,examples:[`kron([[1, 0], [0, 1]], [[1, 2], [3, 4]])`,`kron([1,1], [2,3,4])`],seealso:[`multiply`,`dot`,`cross`]},matrixFromFunction:{name:`matrixFromFunction`,category:`Matrix`,syntax:[`matrixFromFunction(size, fn)`,`matrixFromFunction(size, fn, format)`,`matrixFromFunction(size, fn, format, datatype)`,`matrixFromFunction(size, format, fn)`,`matrixFromFunction(size, format, datatype, fn)`],description:`Create a matrix by evaluating a generating function at each index.`,examples:[`f(I) = I[1] - I[2]`,`matrixFromFunction([3,3], f)`,`g(I) = I[1] - I[2] == 1 ? 4 : 0`,`matrixFromFunction([100, 100], "sparse", g)`,`matrixFromFunction([5], random)`],seealso:[`matrix`,`matrixFromRows`,`matrixFromColumns`,`zeros`]},matrixFromRows:{name:`matrixFromRows`,category:`Matrix`,syntax:[`matrixFromRows(...arr)`,`matrixFromRows(row1, row2)`,`matrixFromRows(row1, row2, row3)`],description:`Create a dense matrix from vectors as individual rows.`,examples:[`matrixFromRows([1, 2, 3], [[4],[5],[6]])`],seealso:[`matrix`,`matrixFromColumns`,`matrixFromFunction`,`zeros`]},matrixFromColumns:{name:`matrixFromColumns`,category:`Matrix`,syntax:[`matrixFromColumns(...arr)`,`matrixFromColumns(row1, row2)`,`matrixFromColumns(row1, row2, row3)`],description:`Create a dense matrix from vectors as individual columns.`,examples:[`matrixFromColumns([1, 2, 3], [[4],[5],[6]])`],seealso:[`matrix`,`matrixFromRows`,`matrixFromFunction`,`zeros`]},map:{name:`map`,category:`Matrix`,syntax:[`map(x, callback)`,`map(x, y, ..., callback)`],description:`Create a new matrix or array with the results of the callback function executed on each entry of the matrix/array or the matrices/arrays.`,examples:[`map([1, 2, 3], square)`,`map([1, 2], [3, 4], f(a,b) = a + b)`],seealso:[`filter`,`forEach`]},ones:{name:`ones`,category:`Matrix`,syntax:[`ones(m)`,`ones(m, n)`,`ones(m, n, p, ...)`,`ones([m])`,`ones([m, n])`,`ones([m, n, p, ...])`],description:`Create a matrix containing ones.`,examples:[`ones(3)`,`ones(3, 5)`,`ones([2,3]) * 4.5`,`a = [1, 2, 3; 4, 5, 6]`,`ones(size(a))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},partitionSelect:{name:`partitionSelect`,category:`Matrix`,syntax:[`partitionSelect(x, k)`,`partitionSelect(x, k, compare)`],description:`Partition-based selection of an array or 1D matrix. Will find the kth smallest value, and mutates the input array. Uses Quickselect.`,examples:[`partitionSelect([5, 10, 1], 2)`,`partitionSelect(["C", "B", "A", "D"], 1, compareText)`,`arr = [5, 2, 1]`,`partitionSelect(arr, 0) # returns 1, arr is now: [1, 2, 5]`,`arr`,`partitionSelect(arr, 1, 'desc') # returns 2, arr is now: [5, 2, 1]`,`arr`],seealso:[`sort`]},range:{name:`range`,category:`Type`,syntax:[`start:end`,`start:step:end`,`range(start, end)`,`range(start, end, step)`,`range(string)`],description:`Create a range. Lower bound of the range is included, upper bound is excluded.`,examples:[`1:5`,`3:-1:-3`,`range(3, 7)`,`range(0, 12, 2)`,`range("4:10")`,`range(1m, 1m, 3m)`,`a = [1, 2, 3, 4; 5, 6, 7, 8]`,`a[1:2, 1:2]`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`size`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},resize:{name:`resize`,category:`Matrix`,syntax:[`resize(x, size)`,`resize(x, size, defaultValue)`],description:`Resize a matrix.`,examples:[`resize([1,2,3,4,5], [3])`,`resize([1,2,3], [5])`,`resize([1,2,3], [5], -1)`,`resize(2, [2, 3])`,`resize("hello", [8], "!")`],seealso:[`size`,`subset`,`squeeze`,`reshape`]},reshape:{name:`reshape`,category:`Matrix`,syntax:[`reshape(x, sizes)`],description:`Reshape a multi dimensional array to fit the specified dimensions.`,examples:[`reshape([1, 2, 3, 4, 5, 6], [2, 3])`,`reshape([[1, 2], [3, 4]], [1, 4])`,`reshape([[1, 2], [3, 4]], [4])`,`reshape([1, 2, 3, 4], [-1, 2])`],seealso:[`size`,`squeeze`,`resize`]},rotate:{name:`rotate`,category:`Matrix`,syntax:[`rotate(w, theta)`,`rotate(w, theta, v)`],description:`Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.`,examples:[`rotate([1, 0], pi / 2)`,`rotate(matrix([1, 0]), unit("35deg"))`,`rotate([1, 0, 0], unit("90deg"), [0, 0, 1])`,`rotate(matrix([1, 0, 0]), unit("90deg"), matrix([0, 0, 1]))`],seealso:[`matrix`,`rotationMatrix`]},rotationMatrix:{name:`rotationMatrix`,category:`Matrix`,syntax:[`rotationMatrix(theta)`,`rotationMatrix(theta, v)`,`rotationMatrix(theta, v, format)`],description:`Returns a 2-D rotation matrix (2x2) for a given angle (in radians). Returns a 2-D rotation matrix (3x3) of a given angle (in radians) around given axis.`,examples:[`rotationMatrix(pi / 2)`,`rotationMatrix(unit("45deg"), [0, 0, 1])`,`rotationMatrix(1, matrix([0, 0, 1]), "sparse")`],seealso:[`cos`,`sin`]},row:{name:`row`,category:`Matrix`,syntax:[`row(x, index)`],description:`Return a row from a matrix or array.`,examples:[`A = [[1, 2], [3, 4]]`,`row(A, 1)`,`row(A, 2)`],seealso:[`column`,`matrixFromRows`]},size:{name:`size`,category:`Matrix`,syntax:[`size(x)`],description:`Calculate the size of a matrix.`,examples:[`size(2.3)`,`size("hello world")`,`a = [1, 2; 3, 4; 5, 6]`,`size(a)`,`size(1:6)`],seealso:[`concat`,`count`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`squeeze`,`subset`,`trace`,`transpose`,`zeros`]},sort:{name:`sort`,category:`Matrix`,syntax:[`sort(x)`,`sort(x, compare)`],description:`Sort the items in a matrix. Compare can be a string "asc", "desc", "natural", or a custom sort function.`,examples:[`sort([5, 10, 1])`,`sort(["C", "B", "A", "D"], "natural")`,`sortByLength(a, b) = size(a)[1] - size(b)[1]`,`sort(["Langdon", "Tom", "Sara"], sortByLength)`,`sort(["10", "1", "2"], "natural")`],seealso:[`map`,`filter`,`forEach`]},squeeze:{name:`squeeze`,category:`Matrix`,syntax:[`squeeze(x)`],description:`Remove inner and outer singleton dimensions from a matrix.`,examples:[`a = zeros(3,2,1)`,`size(squeeze(a))`,`b = zeros(1,1,3)`,`size(squeeze(b))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`subset`,`trace`,`transpose`,`zeros`]},subset:{name:`subset`,category:`Matrix`,syntax:[`value(index)`,`value(index) = replacement`,`subset(value, [index])`,`subset(value, [index], replacement)`],description:"Get or set a subset of the entries of a matrix or characters of a string. Indexes are one-based. There should be one index specification for each dimension of the target. Each specification can be a single index, a list of indices, or a range in colon notation `l:u`. In a range, both the lower bound l and upper bound u are included; and if a bound is omitted it defaults to the most extreme valid value. The cartesian product of the indices specified in each dimension determines the target of the operation.",examples:[`d = [1, 2; 3, 4]`,`e = []`,`e[1, 1:2] = [5, 6]`,`e[2, :] = [7, 8]`,`f = d * e`,`f[2, 1]`,`f[:, 1]`,`f[[1,2], [1,3]] = [9, 10; 11, 12]`,`f`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`trace`,`transpose`,`zeros`]},trace:{name:`trace`,category:`Matrix`,syntax:[`trace(A)`],description:`Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.`,examples:[`A = [1, 2, 3; -1, 2, 3; 2, 0, 3]`,`trace(A)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`transpose`,`zeros`]},transpose:{name:`transpose`,category:`Matrix`,syntax:[`x'`,`transpose(x)`],description:`Transpose a matrix`,examples:[`a = [1, 2, 3; 4, 5, 6]`,`a'`,`transpose(a)`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`zeros`]},zeros:{name:`zeros`,category:`Matrix`,syntax:[`zeros(m)`,`zeros(m, n)`,`zeros(m, n, p, ...)`,`zeros([m])`,`zeros([m, n])`,`zeros([m, n, p, ...])`],description:`Create a matrix containing zeros.`,examples:[`zeros(3)`,`zeros(3, 5)`,`a = [1, 2, 3; 4, 5, 6]`,`zeros(size(a))`],seealso:[`concat`,`det`,`diag`,`identity`,`inv`,`ones`,`range`,`size`,`squeeze`,`subset`,`trace`,`transpose`]},fft:{name:`fft`,category:`Matrix`,syntax:[`fft(x)`],description:`Calculate N-dimensional Fourier transform`,examples:[`fft([[1, 0], [1, 0]])`],seealso:[`ifft`]},ifft:{name:`ifft`,category:`Matrix`,syntax:[`ifft(x)`],description:`Calculate N-dimensional inverse Fourier transform`,examples:[`ifft([[2, 2], [0, 0]])`],seealso:[`fft`]},sylvester:{name:`sylvester`,category:`Algebra`,syntax:[`sylvester(A,B,C)`],description:`Solves the real-valued Sylvester equation AX+XB=C for X`,examples:[`sylvester([[-1, -2], [1, 1]], [[-2, 1], [-1, 2]], [[-3, 2], [3, 0]])`,`A = [[-1, -2], [1, 1]]; B = [[2, -1], [1, -2]]; C = [[-3, 2], [3, 0]]`,`sylvester(A, B, C)`],seealso:[`schur`,`lyap`]},schur:{name:`schur`,category:`Algebra`,syntax:[`schur(A)`],description:`Performs a real Schur decomposition of the real matrix A = UTU'`,examples:[`schur([[1, 0], [-4, 3]])`,`A = [[1, 0], [-4, 3]]`,`schur(A)`],seealso:[`lyap`,`sylvester`]},lyap:{name:`lyap`,category:`Algebra`,syntax:[`lyap(A,Q)`],description:`Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P`,examples:[`lyap([[-2, 0], [1, -4]], [[3, 1], [1, 3]])`,`A = [[-2, 0], [1, -4]]`,`Q = [[3, 1], [1, 3]]`,`lyap(A,Q)`],seealso:[`schur`,`sylvester`]},solveODE:{name:`solveODE`,category:`Numeric`,syntax:[`solveODE(func, tspan, y0)`,`solveODE(func, tspan, y0, options)`],description:`Numerical Integration of Ordinary Differential Equations.`,examples:[`f(t,y) = y`,`tspan = [0, 4]`,`solveODE(f, tspan, 1)`,`solveODE(f, tspan, [1, 2])`,`solveODE(f, tspan, 1, { method:"RK23", maxStep:0.1 })`],seealso:[`derivative`,`simplifyCore`]},bernoulli:{name:`bernoulli`,category:`Probability`,syntax:[`bernoulli(n)`],description:`The nth Bernoulli number`,examples:[`bernoulli(4)`,`bernoulli(fraction(12))`],seealso:[`combinations`,`gamma`,`stirlingS2`]},combinations:{name:`combinations`,category:`Probability`,syntax:[`combinations(n, k)`],description:`Compute the number of combinations of n items taken k at a time`,examples:[`combinations(7, 5)`],seealso:[`combinationsWithRep`,`permutations`,`factorial`]},combinationsWithRep:{name:`combinationsWithRep`,category:`Probability`,syntax:[`combinationsWithRep(n, k)`],description:`Compute the number of combinations of n items taken k at a time with replacements.`,examples:[`combinationsWithRep(7, 5)`],seealso:[`combinations`,`permutations`,`factorial`]},factorial:{name:`factorial`,category:`Probability`,syntax:[`n!`,`factorial(n)`],description:`Compute the factorial of a value`,examples:[`5!`,`5 * 4 * 3 * 2 * 1`,`3!`],seealso:[`combinations`,`combinationsWithRep`,`permutations`,`gamma`]},gamma:{name:`gamma`,category:`Probability`,syntax:[`gamma(n)`],description:`Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.`,examples:[`gamma(4)`,`3!`,`gamma(1/2)`,`sqrt(pi)`],seealso:[`factorial`]},kldivergence:{name:`kldivergence`,category:`Probability`,syntax:[`kldivergence(x, y)`],description:`Calculate the Kullback-Leibler (KL) divergence between two distributions.`,examples:[`kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])`],seealso:[]},lgamma:{name:`lgamma`,category:`Probability`,syntax:[`lgamma(n)`],description:`Logarithm of the gamma function for real, positive numbers and complex numbers, using Lanczos approximation for numbers and Stirling series for complex numbers.`,examples:[`lgamma(4)`,`lgamma(1/2)`,`lgamma(i)`,`lgamma(complex(1.1, 2))`],seealso:[`gamma`]},multinomial:{name:`multinomial`,category:`Probability`,syntax:[`multinomial(A)`],description:"Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities. multinomial takes one array of integers as an argument. The following condition must be enforced: every ai > 0.",examples:[`multinomial([1, 2, 1])`],seealso:[`combinations`,`factorial`]},permutations:{name:`permutations`,category:`Probability`,syntax:[`permutations(n)`,`permutations(n, k)`],description:`Compute the number of permutations of n items taken k at a time`,examples:[`permutations(5)`,`permutations(5, 3)`],seealso:[`combinations`,`combinationsWithRep`,`factorial`]},pickRandom:{name:`pickRandom`,category:`Probability`,syntax:[`pickRandom(array)`,`pickRandom(array, number)`,`pickRandom(array, weights)`,`pickRandom(array, number, weights)`,`pickRandom(array, weights, number)`],description:`Pick a random entry from a given array.`,examples:[`pickRandom(0:10)`,`pickRandom([1, 3, 1, 6])`,`pickRandom([1, 3, 1, 6], 2)`,`pickRandom([1, 3, 1, 6], [2, 3, 2, 1])`,`pickRandom([1, 3, 1, 6], 2, [2, 3, 2, 1])`,`pickRandom([1, 3, 1, 6], [2, 3, 2, 1], 2)`],seealso:[`random`,`randomInt`]},random:{name:`random`,category:`Probability`,syntax:[`random()`,`random(max)`,`random(min, max)`,`random(size)`,`random(size, max)`,`random(size, min, max)`],description:`Return a random number.`,examples:[`random()`,`random(10, 20)`,`random([2, 3])`],seealso:[`pickRandom`,`randomInt`]},randomInt:{name:`randomInt`,category:`Probability`,syntax:[`randomInt(max)`,`randomInt(min, max)`,`randomInt(size)`,`randomInt(size, max)`,`randomInt(size, min, max)`],description:`Return a random integer number`,examples:[`randomInt(10, 20)`,`randomInt([2, 3], 10)`],seealso:[`pickRandom`,`random`]},compare:{name:`compare`,category:`Relational`,syntax:[`compare(x, y)`],description:`Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compare(2, 3)`,`compare(3, 2)`,`compare(2, 2)`,`compare(5cm, 40mm)`,`compare(2, [1, 2, 3])`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compareNatural`,`compareText`]},compareNatural:{name:`compareNatural`,category:`Relational`,syntax:[`compareNatural(x, y)`],description:`Compare two values of any type in a deterministic, natural way. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compareNatural(2, 3)`,`compareNatural(3, 2)`,`compareNatural(2, 2)`,`compareNatural(5cm, 40mm)`,`compareNatural("2", "10")`,`compareNatural(2 + 3i, 2 + 4i)`,`compareNatural([1, 2, 4], [1, 2, 3])`,`compareNatural([1, 5], [1, 2, 3])`,`compareNatural([1, 2], [1, 2])`,`compareNatural({a: 2}, {a: 4})`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compare`,`compareText`]},compareText:{name:`compareText`,category:`Relational`,syntax:[`compareText(x, y)`],description:`Compare two strings lexically. Comparison is case sensitive. Returns 1 when x > y, -1 when x < y, and 0 when x == y.`,examples:[`compareText("B", "A")`,`compareText("A", "B")`,`compareText("A", "A")`,`compareText("2", "10")`,`compare("2", "10")`,`compare(2, 10)`,`compareNatural("2", "10")`,`compareText("B", ["A", "B", "C"])`],seealso:[`compare`,`compareNatural`]},deepEqual:{name:`deepEqual`,category:`Relational`,syntax:[`deepEqual(x, y)`],description:`Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.`,examples:[`deepEqual([1,3,4], [1,3,4])`,`deepEqual([1,3,4], [1,3])`],seealso:[`equal`,`unequal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`]},equal:{name:`equal`,category:`Relational`,syntax:[`x == y`,`equal(x, y)`],description:`Check equality of two values. Returns true if the values are equal, and false if not.`,examples:[`2+2 == 3`,`2+2 == 4`,`a = 3.2`,`b = 6-2.8`,`a == b`,`50cm == 0.5m`],seealso:[`unequal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`,`deepEqual`,`equalText`]},equalText:{name:`equalText`,category:`Relational`,syntax:[`equalText(x, y)`],description:`Check equality of two strings. Comparison is case sensitive. Returns true if the values are equal, and false if not.`,examples:[`equalText("Hello", "Hello")`,`equalText("a", "A")`,`equal("2e3", "2000")`,`equalText("2e3", "2000")`,`equalText("B", ["A", "B", "C"])`],seealso:[`compare`,`compareNatural`,`compareText`,`equal`]},larger:{name:`larger`,category:`Relational`,syntax:[`x > y`,`larger(x, y)`],description:`Check if value x is larger than y. Returns true if x is larger than y, and false if not. Comparing a value with NaN returns false.`,examples:[`2 > 3`,`5 > 2*2`,`a = 3.3`,`b = 6-2.8`,`(a > b)`,`(b < a)`,`5 cm > 2 inch`],seealso:[`equal`,`unequal`,`smaller`,`smallerEq`,`largerEq`,`compare`]},largerEq:{name:`largerEq`,category:`Relational`,syntax:[`x >= y`,`largerEq(x, y)`],description:`Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.`,examples:[`2 >= 1+1`,`2 > 1+1`,`a = 3.2`,`b = 6-2.8`,`(a >= b)`],seealso:[`equal`,`unequal`,`smallerEq`,`smaller`,`compare`]},smaller:{name:`smaller`,category:`Relational`,syntax:[`x < y`,`smaller(x, y)`],description:`Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not. Comparing a value with NaN returns false.`,examples:[`2 < 3`,`5 < 2*2`,`a = 3.3`,`b = 6-2.8`,`(a < b)`,`5 cm < 2 inch`],seealso:[`equal`,`unequal`,`larger`,`smallerEq`,`largerEq`,`compare`]},smallerEq:{name:`smallerEq`,category:`Relational`,syntax:[`x <= y`,`smallerEq(x, y)`],description:`Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.`,examples:[`2 <= 1+1`,`2 < 1+1`,`a = 3.2`,`b = 6-2.8`,`(a <= b)`],seealso:[`equal`,`unequal`,`larger`,`smaller`,`largerEq`,`compare`]},unequal:{name:`unequal`,category:`Relational`,syntax:[`x != y`,`unequal(x, y)`],description:`Check unequality of two values. Returns true if the values are unequal, and false if they are equal.`,examples:[`2+2 != 3`,`2+2 != 4`,`a = 3.2`,`b = 6-2.8`,`a != b`,`50cm != 0.5m`,`5 cm != 2 inch`],seealso:[`equal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`compare`,`deepEqual`]},setCartesian:{name:`setCartesian`,category:`Set`,syntax:[`setCartesian(set1, set2)`],description:`Create the cartesian product of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays and the values will be sorted in ascending order before the operation.`,examples:[`setCartesian([1, 2], [3, 4])`],seealso:[`setUnion`,`setIntersect`,`setDifference`,`setPowerset`]},setDifference:{name:`setDifference`,category:`Set`,syntax:[`setDifference(set1, set2)`],description:`Create the difference of two (multi)sets: every element of set1, that is not the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setDifference([1, 2, 3, 4], [3, 4, 5, 6])`,`setDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setIntersect`,`setSymDifference`]},setDistinct:{name:`setDistinct`,category:`Set`,syntax:[`setDistinct(set)`],description:`Collect the distinct elements of a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setDistinct([1, 1, 1, 2, 2, 3])`],seealso:[`setMultiplicity`]},setIntersect:{name:`setIntersect`,category:`Set`,syntax:[`setIntersect(set1, set2)`],description:`Create the intersection of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setIntersect([1, 2, 3, 4], [3, 4, 5, 6])`,`setIntersect([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setDifference`]},setIsSubset:{name:`setIsSubset`,category:`Set`,syntax:[`setIsSubset(set1, set2)`],description:`Check whether a (multi)set is a subset of another (multi)set: every element of set1 is the element of set2. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setIsSubset([1, 2], [3, 4, 5, 6])`,`setIsSubset([3, 4], [3, 4, 5, 6])`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setMultiplicity:{name:`setMultiplicity`,category:`Set`,syntax:[`setMultiplicity(element, set)`],description:`Count the multiplicity of an element in a multiset. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setMultiplicity(1, [1, 2, 2, 4])`,`setMultiplicity(2, [1, 2, 2, 4])`],seealso:[`setDistinct`,`setSize`]},setPowerset:{name:`setPowerset`,category:`Set`,syntax:[`setPowerset(set)`],description:`Create the powerset of a (multi)set: the powerset contains very possible subsets of a (multi)set. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setPowerset([1, 2, 3])`],seealso:[`setCartesian`]},setSize:{name:`setSize`,category:`Set`,syntax:[`setSize(set)`,`setSize(set, unique)`],description:`Count the number of elements of a (multi)set. When the second parameter "unique" is true, count only the unique values. A multi-dimension array will be converted to a single-dimension array before the operation.`,examples:[`setSize([1, 2, 2, 4])`,`setSize([1, 2, 2, 4], true)`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setSymDifference:{name:`setSymDifference`,category:`Set`,syntax:[`setSymDifference(set1, set2)`],description:`Create the symmetric difference of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setSymDifference([1, 2, 3, 4], [3, 4, 5, 6])`,`setSymDifference([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setUnion`,`setIntersect`,`setDifference`]},setUnion:{name:`setUnion`,category:`Set`,syntax:[`setUnion(set1, set2)`],description:`Create the union of two (multi)sets. Multi-dimension arrays will be converted to single-dimension arrays before the operation.`,examples:[`setUnion([1, 2, 3, 4], [3, 4, 5, 6])`,`setUnion([[1, 2], [3, 4]], [[3, 4], [5, 6]])`],seealso:[`setIntersect`,`setDifference`]},zpk2tf:{name:`zpk2tf`,category:`Signal`,syntax:[`zpk2tf(z, p, k)`],description:`Compute the transfer function of a zero-pole-gain model.`,examples:[`zpk2tf([1, 2], [-1, -2], 1)`,`zpk2tf([1, 2], [-1, -2])`,`zpk2tf([1 - 3i, 2 + 2i], [-1, -2])`],seealso:[]},freqz:{name:`freqz`,category:`Signal`,syntax:[`freqz(b, a)`,`freqz(b, a, w)`],description:`Calculates the frequency response of a filter given its numerator and denominator coefficients.`,examples:[`freqz([1, 2], [1, 2, 3])`,`freqz([1, 2], [1, 2, 3], [0, 1])`,`freqz([1, 2], [1, 2, 3], 512)`],seealso:[]},erf:{name:`erf`,category:`Special`,syntax:[`erf(x)`],description:`Compute the erf function of a value using a rational Chebyshev approximations for different intervals of x`,examples:[`erf(0.2)`,`erf(-0.5)`,`erf(4)`],seealso:[]},zeta:{name:`zeta`,category:`Special`,syntax:[`zeta(s)`],description:`Compute the Riemann Zeta Function using an infinite series and Riemann's Functional Equation for the entire complex plane`,examples:[`zeta(0.2)`,`zeta(-0.5)`,`zeta(4)`],seealso:[]},cumsum:{name:`cumsum`,category:`Statistics`,syntax:[`cumsum(a, b, c, ...)`,`cumsum(A)`],description:`Compute the cumulative sum of all values.`,examples:[`cumsum(2, 3, 4, 1)`,`cumsum([2, 3, 4, 1])`,`cumsum([1, 2; 3, 4])`,`cumsum([1, 2; 3, 4], 1)`,`cumsum([1, 2; 3, 4], 2)`],seealso:[`max`,`mean`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},mad:{name:`mad`,category:`Statistics`,syntax:[`mad(a, b, c, ...)`,`mad(A)`],description:`Compute the median absolute deviation of a matrix or a list with values. The median absolute deviation is defined as the median of the absolute deviations from the median.`,examples:[`mad(10, 20, 30)`,`mad([1, 2, 3])`],seealso:[`mean`,`median`,`std`,`abs`]},max:{name:`max`,category:`Statistics`,syntax:[`max(a, b, c, ...)`,`max(A)`,`max(A, dimension)`],description:`Compute the maximum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.`,examples:[`max(2, 3, 4, 1)`,`max([2, 3, 4, 1])`,`max([2, 5; 4, 3])`,`max([2, 5; 4, 3], 1)`,`max([2, 5; 4, 3], 2)`,`max(2.7, 7.1, -4.5, 2.0, 4.1)`,`min(2.7, 7.1, -4.5, 2.0, 4.1)`],seealso:[`mean`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},mean:{name:`mean`,category:`Statistics`,syntax:[`mean(a, b, c, ...)`,`mean(A)`,`mean(A, dimension)`],description:`Compute the arithmetic mean of a list of values.`,examples:[`mean(2, 3, 4, 1)`,`mean([2, 3, 4, 1])`,`mean([2, 5; 4, 3])`,`mean([2, 5; 4, 3], 1)`,`mean([2, 5; 4, 3], 2)`,`mean([1.0, 2.7, 3.2, 4.0])`],seealso:[`max`,`median`,`min`,`prod`,`std`,`sum`,`variance`]},median:{name:`median`,category:`Statistics`,syntax:[`median(a, b, c, ...)`,`median(A)`],description:`Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.`,examples:[`median(5, 2, 7)`,`median([3, -1, 5, 7])`],seealso:[`max`,`mean`,`min`,`prod`,`std`,`sum`,`variance`,`quantileSeq`]},min:{name:`min`,category:`Statistics`,syntax:[`min(a, b, c, ...)`,`min(A)`,`min(A, dimension)`],description:`Compute the minimum value of a list of values. If any NaN values are found, the function yields the last NaN in the input.`,examples:[`min(2, 3, 4, 1)`,`min([2, 3, 4, 1])`,`min([2, 5; 4, 3])`,`min([2, 5; 4, 3], 1)`,`min([2, 5; 4, 3], 2)`,`min(2.7, 7.1, -4.5, 2.0, 4.1)`,`max(2.7, 7.1, -4.5, 2.0, 4.1)`],seealso:[`max`,`mean`,`median`,`prod`,`std`,`sum`,`variance`]},mode:{name:`mode`,category:`Statistics`,syntax:[`mode(a, b, c, ...)`,`mode(A)`,`mode(A, a, b, B, c, ...)`],description:`Computes the mode of all values as an array. In case mode being more than one, multiple values are returned in an array.`,examples:[`mode(2, 1, 4, 3, 1)`,`mode([1, 2.7, 3.2, 4, 2.7])`,`mode(1, 4, 6, 1, 6)`],seealso:[`max`,`mean`,`min`,`median`,`prod`,`std`,`sum`,`variance`]},prod:{name:`prod`,category:`Statistics`,syntax:[`prod(a, b, c, ...)`,`prod(A)`],description:`Compute the product of all values.`,examples:[`prod(2, 3, 4)`,`prod([2, 3, 4])`,`prod([2, 5; 4, 3])`],seealso:[`max`,`mean`,`min`,`median`,`min`,`std`,`sum`,`variance`]},quantileSeq:{name:`quantileSeq`,category:`Statistics`,syntax:[`quantileSeq(A, prob[, sorted])`,`quantileSeq(A, [prob1, prob2, ...][, sorted])`,`quantileSeq(A, N[, sorted])`],description:`Compute the prob order quantile of a matrix or a list with values. The sequence is sorted and the middle value is returned. Supported types of sequence values are: Number, BigNumber, Unit Supported types of probability are: Number, BigNumber.
47
+
48
+ In case of a (multi dimensional) array or matrix, the prob order quantile of all elements will be calculated.`,examples:[`quantileSeq([3, -1, 5, 7], 0.5)`,`quantileSeq([3, -1, 5, 7], [1/3, 2/3])`,`quantileSeq([3, -1, 5, 7], 2)`,`quantileSeq([-1, 3, 5, 7], 0.5, true)`],seealso:[`mean`,`median`,`min`,`max`,`prod`,`std`,`sum`,`variance`]},std:{name:`std`,category:`Statistics`,syntax:[`std(a, b, c, ...)`,`std(A)`,`std(A, dimension)`,`std(A, normalization)`,`std(A, dimension, normalization)`],description:`Compute the standard deviation of all values, defined as std(A) = sqrt(variance(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".`,examples:[`std(2, 4, 6)`,`std([2, 4, 6, 8])`,`std([2, 4, 6, 8], "uncorrected")`,`std([2, 4, 6, 8], "biased")`,`std([1, 2, 3; 4, 5, 6])`],seealso:[`max`,`mean`,`min`,`median`,`prod`,`sum`,`variance`]},sum:{name:`sum`,category:`Statistics`,syntax:[`sum(a, b, c, ...)`,`sum(A)`,`sum(A, dimension)`],description:`Compute the sum of all values.`,examples:[`sum(2, 3, 4, 1)`,`sum([2, 3, 4, 1])`,`sum([2, 5; 4, 3])`],seealso:[`max`,`mean`,`median`,`min`,`prod`,`std`,`variance`]},variance:{name:`variance`,category:`Statistics`,syntax:[`variance(a, b, c, ...)`,`variance(A)`,`variance(A, dimension)`,`variance(A, normalization)`,`variance(A, dimension, normalization)`],description:`Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".`,examples:[`variance(2, 4, 6)`,`variance([2, 4, 6, 8])`,`variance([2, 4, 6, 8], "uncorrected")`,`variance([2, 4, 6, 8], "biased")`,`variance([1, 2, 3; 4, 5, 6])`],seealso:[`max`,`mean`,`min`,`median`,`min`,`prod`,`std`,`sum`]},corr:{name:`corr`,category:`Statistics`,syntax:[`corr(A,B)`],description:`Compute the correlation coefficient of a two list with values, For matrices, the matrix correlation coefficient is calculated.`,examples:[`corr([2, 4, 6, 8],[1, 2, 3, 6])`,`corr(matrix([[1, 2.2, 3, 4.8, 5], [1, 2, 3, 4, 5]]), matrix([[4, 5.3, 6.6, 7, 8], [1, 2, 3, 4, 5]]))`],seealso:[`max`,`mean`,`min`,`median`,`min`,`prod`,`std`,`sum`]},acos:{name:`acos`,category:`Trigonometry`,syntax:[`acos(x)`],description:`Compute the inverse cosine of a value in radians.`,examples:[`acos(0.5)`,`acos(cos(2.3))`],seealso:[`cos`,`atan`,`asin`]},acosh:{name:`acosh`,category:`Trigonometry`,syntax:[`acosh(x)`],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:[`acosh(1.5)`],seealso:[`cosh`,`asinh`,`atanh`]},acot:{name:`acot`,category:`Trigonometry`,syntax:[`acot(x)`],description:`Calculate the inverse cotangent of a value.`,examples:[`acot(0.5)`,`acot(cot(0.5))`,`acot(2)`],seealso:[`cot`,`atan`]},acoth:{name:`acoth`,category:`Trigonometry`,syntax:[`acoth(x)`],description:"Calculate the inverse hyperbolic tangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:[`acoth(2)`,`acoth(0.5)`],seealso:[`acsch`,`asech`]},acsc:{name:`acsc`,category:`Trigonometry`,syntax:[`acsc(x)`],description:`Calculate the inverse cotangent of a value.`,examples:[`acsc(2)`,`acsc(csc(0.5))`,`acsc(0.5)`],seealso:[`csc`,`asin`,`asec`]},acsch:{name:`acsch`,category:`Trigonometry`,syntax:[`acsch(x)`],description:"Calculate the inverse hyperbolic cosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:[`acsch(0.5)`],seealso:[`asech`,`acoth`]},asec:{name:`asec`,category:`Trigonometry`,syntax:[`asec(x)`],description:`Calculate the inverse secant of a value.`,examples:[`asec(0.5)`,`asec(sec(0.5))`,`asec(2)`],seealso:[`acos`,`acot`,`acsc`]},asech:{name:`asech`,category:`Trigonometry`,syntax:[`asech(x)`],description:`Calculate the inverse secant of a value.`,examples:[`asech(0.5)`],seealso:[`acsch`,`acoth`]},asin:{name:`asin`,category:`Trigonometry`,syntax:[`asin(x)`],description:`Compute the inverse sine of a value in radians.`,examples:[`asin(0.5)`,`asin(sin(0.5))`],seealso:[`sin`,`acos`,`atan`]},asinh:{name:`asinh`,category:`Trigonometry`,syntax:[`asinh(x)`],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:[`asinh(0.5)`],seealso:[`acosh`,`atanh`]},atan:{name:`atan`,category:`Trigonometry`,syntax:[`atan(x)`],description:`Compute the inverse tangent of a value in radians.`,examples:[`atan(0.5)`,`atan(tan(0.5))`],seealso:[`tan`,`acos`,`asin`]},atanh:{name:`atanh`,category:`Trigonometry`,syntax:[`atanh(x)`],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:[`atanh(0.5)`],seealso:[`acosh`,`asinh`]},atan2:{name:`atan2`,category:`Trigonometry`,syntax:[`atan2(y, x)`],description:`Computes the principal value of the arc tangent of y/x in radians.`,examples:[`atan2(2, 2) / pi`,`angle = 60 deg in rad`,`x = cos(angle)`,`y = sin(angle)`,`atan2(y, x)`],seealso:[`sin`,`cos`,`tan`]},cos:{name:`cos`,category:`Trigonometry`,syntax:[`cos(x)`],description:`Compute the cosine of x in radians.`,examples:[`cos(2)`,`cos(pi / 4) ^ 2`,`cos(180 deg)`,`cos(60 deg)`,`sin(0.2)^2 + cos(0.2)^2`],seealso:[`acos`,`sin`,`tan`]},cosh:{name:`cosh`,category:`Trigonometry`,syntax:[`cosh(x)`],description:`Compute the hyperbolic cosine of x in radians.`,examples:[`cosh(0.5)`],seealso:[`sinh`,`tanh`,`coth`]},cot:{name:`cot`,category:`Trigonometry`,syntax:[`cot(x)`],description:`Compute the cotangent of x in radians. Defined as 1/tan(x)`,examples:[`cot(2)`,`1 / tan(2)`],seealso:[`sec`,`csc`,`tan`]},coth:{name:`coth`,category:`Trigonometry`,syntax:[`coth(x)`],description:`Compute the hyperbolic cotangent of x in radians.`,examples:[`coth(2)`,`1 / tanh(2)`],seealso:[`sech`,`csch`,`tanh`]},csc:{name:`csc`,category:`Trigonometry`,syntax:[`csc(x)`],description:`Compute the cosecant of x in radians. Defined as 1/sin(x)`,examples:[`csc(2)`,`1 / sin(2)`],seealso:[`sec`,`cot`,`sin`]},csch:{name:`csch`,category:`Trigonometry`,syntax:[`csch(x)`],description:`Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)`,examples:[`csch(2)`,`1 / sinh(2)`],seealso:[`sech`,`coth`,`sinh`]},sec:{name:`sec`,category:`Trigonometry`,syntax:[`sec(x)`],description:`Compute the secant of x in radians. Defined as 1/cos(x)`,examples:[`sec(2)`,`1 / cos(2)`],seealso:[`cot`,`csc`,`cos`]},sech:{name:`sech`,category:`Trigonometry`,syntax:[`sech(x)`],description:`Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)`,examples:[`sech(2)`,`1 / cosh(2)`],seealso:[`coth`,`csch`,`cosh`]},sin:{name:`sin`,category:`Trigonometry`,syntax:[`sin(x)`],description:`Compute the sine of x in radians.`,examples:[`sin(2)`,`sin(pi / 4) ^ 2`,`sin(90 deg)`,`sin(30 deg)`,`sin(0.2)^2 + cos(0.2)^2`],seealso:[`asin`,`cos`,`tan`]},sinh:{name:`sinh`,category:`Trigonometry`,syntax:[`sinh(x)`],description:`Compute the hyperbolic sine of x in radians.`,examples:[`sinh(0.5)`],seealso:[`cosh`,`tanh`]},tan:{name:`tan`,category:`Trigonometry`,syntax:[`tan(x)`],description:`Compute the tangent of x in radians.`,examples:[`tan(0.5)`,`sin(0.5) / cos(0.5)`,`tan(pi / 4)`,`tan(45 deg)`],seealso:[`atan`,`sin`,`cos`]},tanh:{name:`tanh`,category:`Trigonometry`,syntax:[`tanh(x)`],description:`Compute the hyperbolic tangent of x in radians.`,examples:[`tanh(0.5)`,`sinh(0.5) / cosh(0.5)`],seealso:[`sinh`,`cosh`]},to:{name:`to`,category:`Units`,syntax:[`x to unit`,`to(x, unit)`],description:`Change the unit of a value.`,examples:[`5 inch to cm`,`3.2kg to g`,`16 bytes in bits`],seealso:[]},toBest:{name:`toBest`,category:`Units`,syntax:[`toBest(x)`,`toBest(x, unitList)`,`toBest(x, unitList, options)`],description:`Converts to the most appropriate display unit.`,examples:[`toBest(unit(5000, "m"))`,`toBest(unit(3500000, "W"))`,`toBest(unit(0.000000123, "A"))`,`toBest(unit(10, "m"), "cm")`,`toBest(unit(10, "m"), "mm,km", {offset: 1.5})`],seealso:[]},clone:{name:`clone`,category:`Utils`,syntax:[`clone(x)`],description:`Clone a variable. Creates a copy of primitive variables, and a deep copy of matrices`,examples:[`clone(3.5)`,`clone(2 - 4i)`,`clone(45 deg)`,`clone([1, 2; 3, 4])`,`clone("hello world")`],seealso:[]},format:{name:`format`,category:`Utils`,syntax:[`format(value)`,`format(value, precision)`],description:`Format a value of any type as string.`,examples:[`format(2.3)`,`format(3 - 4i)`,`format([])`,`format(pi, 3)`],seealso:[`print`]},bin:{name:`bin`,category:`Utils`,syntax:[`bin(value)`],description:`Format a number as binary`,examples:[`bin(2)`],seealso:[`oct`,`hex`]},oct:{name:`oct`,category:`Utils`,syntax:[`oct(value)`],description:`Format a number as octal`,examples:[`oct(56)`],seealso:[`bin`,`hex`]},hex:{name:`hex`,category:`Utils`,syntax:[`hex(value)`],description:`Format a number as hexadecimal`,examples:[`hex(240)`],seealso:[`bin`,`oct`]},isNaN:{name:`isNaN`,category:`Utils`,syntax:[`isNaN(x)`],description:`Test whether a value is NaN (not a number)`,examples:[`isNaN(2)`,`isNaN(0 / 0)`,`isNaN(NaN)`,`isNaN(Infinity)`],seealso:[`isNegative`,`isNumeric`,`isPositive`,`isZero`,`isFinite`,`isBounded`]},isBounded:{name:`isBounded`,category:`Utils`,syntax:[`isBounded(x)`],description:`Test whether a value or its entries are bounded.`,examples:[`isBounded(Infinity)`,`isBounded(bigint(3))`,`isBounded([3, -Infinity, -3])`],seealso:[`isFinite`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},isFinite:{name:`isFinite`,category:`Utils`,syntax:[`isFinite(x)`],description:`Test whether a value is finite, elementwise on collections.`,examples:[`isFinite(Infinity)`,`isFinite(bigint(3))`,`isFinite([3, -Infinity, -3])`],seealso:[`isBounded`,`isNumeric`,`isNaN`,`isNegative`,`isPositive`]},isInteger:{name:`isInteger`,category:`Utils`,syntax:[`isInteger(x)`],description:`Test whether a value is an integer number.`,examples:[`isInteger(2)`,`isInteger(3.5)`,`isInteger([3, 0.5, -2])`],seealso:[`isNegative`,`isNumeric`,`isPositive`,`isZero`]},isNegative:{name:`isNegative`,category:`Utils`,syntax:[`isNegative(x)`],description:`Test whether a value is negative: smaller than zero.`,examples:[`isNegative(2)`,`isNegative(0)`,`isNegative(-4)`,`isNegative([3, 0.5, -2])`],seealso:[`isInteger`,`isNumeric`,`isPositive`,`isZero`]},isNumeric:{name:`isNumeric`,category:`Utils`,syntax:[`isNumeric(x)`],description:`Test whether a value is a numeric value. Returns true when the input is a number, BigNumber, Fraction, or boolean.`,examples:[`isNumeric(2)`,`isNumeric("2")`,`hasNumericValue("2")`,`isNumeric(0)`,`isNumeric(bignumber(500))`,`isNumeric(fraction(0.125))`,`isNumeric(2 + 3i)`,`isNumeric([2.3, "foo", false])`],seealso:[`isInteger`,`isZero`,`isNegative`,`isPositive`,`isNaN`,`hasNumericValue`,`isFinite`,`isBounded`]},hasNumericValue:{name:`hasNumericValue`,category:`Utils`,syntax:[`hasNumericValue(x)`],description:`Test whether a value is an numeric value. In case of a string, true is returned if the string contains a numeric value.`,examples:[`hasNumericValue(2)`,`hasNumericValue("2")`,`isNumeric("2")`,`hasNumericValue(0)`,`hasNumericValue(bignumber(500))`,`hasNumericValue(fraction(0.125))`,`hasNumericValue(2 + 3i)`,`hasNumericValue([2.3, "foo", false])`],seealso:[`isInteger`,`isZero`,`isNegative`,`isPositive`,`isNaN`,`isNumeric`]},isPositive:{name:`isPositive`,category:`Utils`,syntax:[`isPositive(x)`],description:`Test whether a value is positive: larger than zero.`,examples:[`isPositive(2)`,`isPositive(0)`,`isPositive(-4)`,`isPositive([3, 0.5, -2])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isZero`]},isPrime:{name:`isPrime`,category:`Utils`,syntax:[`isPrime(x)`],description:`Test whether a value is prime: has no divisors other than itself and one.`,examples:[`isPrime(3)`,`isPrime(-2)`,`isPrime([2, 17, 100])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isZero`]},isZero:{name:`isZero`,category:`Utils`,syntax:[`isZero(x)`],description:`Test whether a value is zero.`,examples:[`isZero(2)`,`isZero(0)`,`isZero(-4)`,`isZero([3, 0, -2, 0])`],seealso:[`isInteger`,`isNumeric`,`isNegative`,`isPositive`]},print:{name:`print`,category:`Utils`,syntax:[`print(template, values)`,`print(template, values, precision)`],description:`Interpolate values into a string template.`,examples:[`print("Lucy is $age years old", {age: 5})`,`print("The value of pi is $pi", {pi: pi}, 3)`,`print("Hello, $user.name!", {user: {name: "John"}})`,`print("Values: $1, $2, $3", [6, 9, 4])`],seealso:[`format`]},typeOf:{name:`typeOf`,category:`Utils`,syntax:[`typeOf(x)`],description:`Get the type of a variable.`,examples:[`typeOf(3.5)`,`typeOf(2 - 4i)`,`typeOf(45 deg)`,`typeOf("hello world")`],seealso:[`getMatrixDataType`]},numeric:{name:`numeric`,category:`Utils`,syntax:[`numeric(x)`],description:`Convert a numeric input to a specific numeric type: number, BigNumber, bigint, or Fraction.`,examples:[`numeric("4")`,`numeric("4", "number")`,`numeric("4", "bigint")`,`numeric("4", "BigNumber")`,`numeric("4", "Fraction")`,`numeric(4, "Fraction")`,`numeric(fraction(2, 5), "number")`],seealso:[`number`,`bigint`,`fraction`,`bignumber`,`string`,`format`]}},Sb=`help`,Cb=J(Sb,[`typed`,`mathWithTransform`,`Help`],e=>{var{typed:t,mathWithTransform:n,Help:r}=e;return t(Sb,{any:function(e){var t,i=e;if(typeof e!=`string`){for(t in n)if(ei(n,t)&&e===n[t]){i=t;break}}var a=Bn(xb,i);if(!a){var o=typeof i==`function`?i.name:i;throw Error(`No documentation found on "`+o+`"`)}return new r(a)}})}),wb=`chain`,Tb=J(wb,[`typed`,`Chain`],e=>{var{typed:t,Chain:n}=e;return t(wb,{"":function(){return new n},any:function(e){return new n(e)}})}),Eb=`det`,Db=J(Eb,[`typed`,`matrix`,`subtractScalar`,`multiply`,`divideScalar`,`isZero`,`unaryMinus`],e=>{var{typed:t,matrix:n,subtractScalar:r,multiply:i,divideScalar:a,isZero:o,unaryMinus:s}=e;return t(Eb,{any:function(e){return Kr(e)},"Array | Matrix":function(e){var t;switch(lr(e)?t=e.size():Array.isArray(e)?(e=n(e),t=e.size()):t=[],t.length){case 0:return Kr(e);case 1:if(t[0]===1)return Kr(e.valueOf()[0]);if(t[0]===0)return 1;throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);case 2:var r=t[0],i=t[1];if(r===i)return c(e.clone().valueOf(),r,i);if(i===0)return 1;throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+ws(t)+`)`)}}});function c(e,t,n){if(t===1)return Kr(e[0][0]);if(t===2)return r(i(e[0][0],e[1][1]),i(e[1][0],e[0][1]));for(var c=!1,l=Array(t).fill(0).map((e,t)=>t),u=0;u<t;u++){var d=l[u];if(o(e[d][u])){var f=void 0;for(f=u+1;f<t;f++)if(!o(e[l[f]][u])){d=l[f],l[f]=l[u],l[u]=d,c=!c;break}if(f===t)return e[d][u]}for(var p=e[d][u],m=u===0?1:e[l[u-1]][u-1],h=u+1;h<t;h++)for(var g=l[h],_=u+1;_<t;_++)e[g][_]=a(r(i(e[g][_],p),i(e[g][u],e[d][_])),m)}var v=e[l[t-1]][t-1];return c?s(v):v}}),Ob=`inv`,kb=J(Ob,[`typed`,`matrix`,`divideScalar`,`addScalar`,`multiply`,`unaryMinus`,`det`,`identity`,`abs`],e=>{var{typed:t,matrix:n,divideScalar:r,addScalar:i,multiply:a,unaryMinus:o,det:s,identity:c,abs:l}=e;return t(Ob,{"Array | Matrix":function(e){var t=lr(e)?e.size():Ps(e);switch(t.length){case 1:if(t[0]===1)return lr(e)?n([r(1,e.valueOf()[0])]):[r(1,e[0])];throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);case 2:var i=t[0],a=t[1];if(i===a)return lr(e)?n(u(e.valueOf(),i,a),e.storage()):u(e,i,a);throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);default:throw RangeError(`Matrix must be two dimensional (size: `+ws(t)+`)`)}},any:function(e){return r(1,e)}});function u(e,t,n){var u,d,f,p,m;if(t===1){if(p=e[0][0],p===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(1,p)]]}else if(t===2){var h=s(e);if(h===0)throw Error(`Cannot calculate inverse, determinant is zero`);return[[r(e[1][1],h),r(o(e[0][1]),h)],[r(o(e[1][0]),h),r(e[0][0],h)]]}else{var g=e.concat();for(u=0;u<t;u++)g[u]=g[u].concat();for(var _=c(t).valueOf(),v=0;v<n;v++){var y=l(g[v][v]),b=v;for(u=v+1;u<t;)l(g[u][v])>y&&(y=l(g[u][v]),b=u),u++;if(y===0)throw Error(`Cannot calculate inverse, determinant is zero`);u=b,u!==v&&(m=g[v],g[v]=g[u],g[u]=m,m=_[v],_[v]=_[u],_[u]=m);var x=g[v],S=_[v];for(u=0;u<t;u++){var C=g[u],w=_[u];if(u!==v){if(C[v]!==0){for(f=r(o(C[v]),x[v]),d=v;d<n;d++)C[d]=i(C[d],a(f,x[d]));for(d=0;d<n;d++)w[d]=i(w[d],a(f,S[d]))}}else{for(f=x[v],d=v;d<n;d++)C[d]=r(C[d],f);for(d=0;d<n;d++)w[d]=r(w[d],f)}}}return _}}}),Ab=`pinv`,jb=J(Ab,[`typed`,`matrix`,`inv`,`deepEqual`,`equal`,`dotDivide`,`dot`,`ctranspose`,`divideScalar`,`multiply`,`add`,`Complex`],e=>{var{typed:t,matrix:n,inv:r,deepEqual:i,equal:a,dotDivide:o,dot:s,ctranspose:c,divideScalar:l,multiply:u,add:d,Complex:f}=e;return t(Ab,{"Array | Matrix":function(e){var t=lr(e)?e.size():Ps(e);switch(t.length){case 1:return _(e)?c(e):t[0]===1?r(e):o(c(e),s(e,e));case 2:if(_(e))return c(e);var i=t[0],a=t[1];if(i===a)try{return r(e)}catch(e){if(!(e instanceof Error&&e.message.match(/Cannot calculate inverse, determinant is zero/)))throw e}return lr(e)?n(p(e.valueOf(),i,a),e.storage()):p(e,i,a);default:throw RangeError(`Matrix must be two dimensional (size: `+ws(t)+`)`)}},any:function(e){return a(e,0)?Kr(e):l(1,e)}});function p(e,t,n){var{C:i,F:a}=h(e,t,n),o=u(r(u(c(i),i)),c(i));return u(u(c(a),r(u(a,c(a)))),o)}function m(e,t,n){for(var r=Kr(e),i=0,a=0;a<t;a++){if(n<=i)return r;for(var s=a;g(r[s][i]);)if(s++,t===s&&(s=a,i++,n===i))return r;[r[s],r[a]]=[r[a],r[s]];for(var c=r[a][i],l=0;l<n;l++)r[a][l]=o(r[a][l],c);for(var f=0;f<t;f++)if(f!==a){c=r[f][i];for(var p=0;p<n;p++)r[f][p]=d(r[f][p],u(-1,u(c,r[a][p])))}i++}return r}function h(e,t,n){var r=m(e,t,n);return{C:e.map((e,n)=>e.filter((e,n)=>n<t&&!g(s(r[n],r[n])))),F:r.filter((e,t)=>!g(s(r[t],r[t])))}}function g(e){return a(d(e,f(1,1)),d(0,f(1,1)))}function _(e){return i(d(e,f(1,1)),d(u(e,0),f(1,1)))}});function Mb(e){var{addScalar:t,subtract:n,flatten:r,multiply:i,multiplyScalar:a,divideScalar:o,sqrt:s,abs:c,bignumber:l,diag:u,size:d,reshape:f,inv:p,qr:m,usolve:h,usolveAll:g,equal:_,complex:v,larger:y,smaller:b,matrixFromColumns:x,dot:S}=e;function C(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=w(e,t,n,r,i);T(e,t,n,r,i,a);var{values:o,C:s}=E(e,t,n,r,i);return i?{values:o,eigenvectors:D(e,t,s,a,o,n,r)}:{values:o}}function w(e,n,r,i,s){var d=i===`BigNumber`,f=i===`Complex`,p=d?l(0):0,m=d?l(1):f?v(1):1,h=d?l(1):1,g=d?l(10):2,x=a(g,g),S;s&&(S=Array(n).fill(m));for(var C=!1;!C;){C=!0;for(var w=0;w<n;w++){for(var T=p,E=p,D=0;D<n;D++)w!==D&&(T=t(T,c(e[D][w])),E=t(E,c(e[w][D])));if(!_(T,0)&&!_(E,0)){for(var O=h,k=T,A=o(E,g),j=a(E,g);b(k,A);)k=a(k,x),O=a(O,g);for(;y(k,j);)k=o(k,x),O=o(O,g);if(b(o(t(k,E),O),a(t(T,E),.95))){C=!1;for(var M=o(1,O),N=0;N<n;N++)w!==N&&(e[w][N]=a(e[w][N],M),e[N][w]=a(e[N][w],O));s&&(S[w]=a(S[w],M))}}}}return s?u(S):null}function T(e,r,i,s,u,d){var f=s===`BigNumber`,p=f?l(0):s===`Complex`?v(0):0;f&&(i=l(i));for(var m=0;m<r-2;m++){for(var h=0,g=p,_=m+1;_<r;_++){var y=e[_][m];b(c(g),c(y))&&(g=y,h=_)}if(!b(c(g),i)){if(h!==m+1){var x=e[h];e[h]=e[m+1],e[m+1]=x;for(var S=0;S<r;S++){var C=e[S][h];e[S][h]=e[S][m+1],e[S][m+1]=C}if(u){var w=d[h];d[h]=d[m+1],d[m+1]=w}}for(var T=m+2;T<r;T++){var E=o(e[T][m],g);if(E!==0){for(var D=0;D<r;D++)e[T][D]=n(e[T][D],a(E,e[m+1][D]));for(var O=0;O<r;O++)e[O][m+1]=t(e[O][m+1],a(E,e[O][T]));if(u)for(var k=0;k<r;k++)d[T][k]=n(d[T][k],a(E,d[m+1][k]))}}}}return d}function E(e,r,a,o,s){var d=o===`BigNumber`,f=d?l(1):o===`Complex`?v(1):1;d&&(a=l(a));for(var p=Kr(e),h=[],g=r,_=[],y=s?u(Array(r).fill(f)):void 0,x=s?u(Array(g).fill(f)):void 0,S=0;S<=100;){S+=1;for(var C=p[g-1][g-1],w=0;w<g;w++)p[w][w]=n(p[w][w],C);var{Q:T,R:E}=m(p);p=i(E,T);for(var D=0;D<g;D++)p[D][D]=t(p[D][D],C);if(s&&(x=i(x,T)),g===1||b(c(p[g-1][g-2]),a)){S=0,h.push(p[g-1][g-1]),s&&(_.unshift([[1]]),A(x,r),y=i(y,x),g>1&&(x=u(Array(g-1).fill(f)))),--g,p.pop();for(var M=0;M<g;M++)p[M].pop()}else if(g===2||b(c(p[g-2][g-3]),a)){S=0;var N=O(p[g-2][g-2],p[g-2][g-1],p[g-1][g-2],p[g-1][g-1]);h.push(...N),s&&(_.unshift(k(p[g-2][g-2],p[g-2][g-1],p[g-1][g-2],p[g-1][g-1],N[0],N[1],a,o)),A(x,r),y=i(y,x),g>2&&(x=u(Array(g-2).fill(f)))),g-=2,p.pop(),p.pop();for(var P=0;P<g;P++)p[P].pop(),p[P].pop()}if(g===0)break}if(h.sort((e,t)=>+n(c(e),c(t))),S>100){var F=Error(`The eigenvalues failed to converge. Only found these eigenvalues: `+h.join(`, `));throw F.values=h,F.vectors=[],F}return{values:h,C:s?i(y,j(_,r)):void 0}}function D(e,t,a,o,s,c,d){var f=i(p(a),e,a),m=d===`BigNumber`,h=d===`Complex`,y=m?l(0):h?v(0):0,b=m?l(1):h?v(1):1,x=[],S=[];for(var C of s){var w=M(x,C,_);w===-1?(x.push(C),S.push(1)):S[w]+=1}for(var T=[],E=x.length,D=Array(t).fill(y),O=u(Array(t).fill(b)),k=function(){var e=x[A],s=n(f,i(e,O)),l=g(s,D);for(l.shift();l.length<S[A];){var u=N(s,t,l,c,d);if(u===null)break;l.push(u)}var m=i(p(o),a);l=l.map(e=>i(m,e)),T.push(...l.map(t=>({value:e,vector:r(t)})))},A=0;A<E;A++)k();return T}function O(e,r,i,o){var c=t(e,o),l=n(a(e,o),a(r,i)),u=a(c,.5),d=a(s(n(a(c,c),a(4,l))),.5);return[t(u,d),n(u,d)]}function k(e,t,r,i,a,o,s,u){var d=u===`BigNumber`,f=u===`Complex`,p=d?l(0):f?v(0):0,m=d?l(1):f?v(1):1;if(b(c(r),s))return[[m,p],[p,m]];if(y(c(n(a,o)),s))return[[n(a,i),n(o,i)],[r,r]];var h=n(e,a),g=n(i,a);return b(c(t),s)&&b(c(g),s)?[[h,m],[r,p]]:[[t,p],[g,m]]}function A(e,t){for(var n=0;n<e.length;n++)e[n].push(...Array(t-e[n].length).fill(0));for(var r=e.length;r<t;r++)e.push(Array(t).fill(0)),e[r][r]=1;return e}function j(e,t){for(var n=[],r=0;r<t;r++)n[r]=Array(t).fill(0);var i=0;for(var a of e){for(var o=a.length,s=0;s<o;s++)for(var c=0;c<o;c++)n[i+s][i+c]=a[s][c];i+=o}return n}function M(e,t,n){for(var r=0;r<e.length;r++)if(n(e[r],t))return r;return-1}function N(e,t,n,r,i){for(var a=i===`BigNumber`?l(1e3):1e3,o,s=0;s<5;++s){o=P(t,n,i);try{o=h(e,o)}catch{continue}if(y(I(o),a))break}if(s>=5)return null;for(s=0;;){var c=h(e,o);if(b(I(F(o,[c])),r))break;if(++s>=10)return null;o=L(c)}return o}function P(e,t,n){var r=n===`BigNumber`,i=n===`Complex`,a=Array(e).fill(0).map(e=>2*Math.random()-1);return r&&(a=a.map(e=>l(e))),i&&(a=a.map(e=>v(e))),a=F(a,t),L(a,n)}function F(e,t){var r=d(e);for(var a of t)a=f(a,r),e=n(e,i(o(S(a,e),S(a,a)),a));return e}function I(e){return c(s(S(e,e)))}function L(e,t){return i(o(t===`BigNumber`?l(1):t===`Complex`?v(1):1,I(e)),e)}return C}function Nb(e){var{config:t,addScalar:n,subtract:r,abs:i,atan:a,cos:o,sin:s,multiplyScalar:c,inv:l,bignumber:u,multiply:d,add:f}=e;function p(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.relTol,i=arguments.length>3?arguments[3]:void 0,a=arguments.length>4?arguments[4]:void 0;if(i===`number`)return m(e,r,a);if(i===`BigNumber`)return h(e,r,a);throw TypeError(`Unsupported data type: `+i)}function m(e,t,n){var r=e.length,i=Math.abs(t/r),a,o;if(n){o=Array(r);for(var s=0;s<r;s++)o[s]=Array(r).fill(0),o[s][s]=1}for(var c=S(e);Math.abs(c[1])>=Math.abs(i);){var l=c[0][0],u=c[0][1];a=g(e[l][l],e[u][u],e[l][u]),e=x(e,a,l,u),n&&(o=v(o,a,l,u)),c=S(e)}for(var d=Array(r).fill(0),f=0;f<r;f++)d[f]=e[f][f];return w(Kr(d),o,n)}function h(e,t,n){var r=e.length,a=i(t/r),o,s;if(n){s=Array(r);for(var c=0;c<r;c++)s[c]=Array(r).fill(0),s[c][c]=1}for(var l=C(e);i(l[1])>=i(a);){var u=l[0][0],d=l[0][1];o=_(e[u][u],e[d][d],e[u][d]),e=b(e,o,u,d),n&&(s=y(s,o,u,d)),l=C(e)}for(var f=Array(r).fill(0),p=0;p<r;p++)f[p]=e[p][p];return w(Kr(f),s,n)}function g(e,n,r){var i=n-e;return Math.abs(i)<=t.relTol?Math.PI/4:.5*Math.atan(2*r/(n-e))}function _(e,n,o){var s=r(n,e);return i(s)<=t.relTol?u(-1).acos().div(4):c(.5,a(d(2,o,l(s))))}function v(e,t,n,r){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=Array(i).fill(0),c=Array(i).fill(0),l=0;l<i;l++)s[l]=a*e[l][n]-o*e[l][r],c[l]=o*e[l][n]+a*e[l][r];for(var u=0;u<i;u++)e[u][n]=s[u],e[u][r]=c[u];return e}function y(e,t,i,a){for(var l=e.length,d=o(t),f=s(t),p=Array(l).fill(u(0)),m=Array(l).fill(u(0)),h=0;h<l;h++)p[h]=r(c(d,e[h][i]),c(f,e[h][a])),m[h]=n(c(f,e[h][i]),c(d,e[h][a]));for(var g=0;g<l;g++)e[g][i]=p[g],e[g][a]=m[g];return e}function b(e,t,i,a){for(var l=e.length,p=u(o(t)),m=u(s(t)),h=c(p,p),g=c(m,m),_=Array(l).fill(u(0)),v=Array(l).fill(u(0)),y=d(u(2),p,m,e[i][a]),b=n(r(c(h,e[i][i]),y),c(g,e[a][a])),x=f(c(g,e[i][i]),y,c(h,e[a][a])),S=0;S<l;S++)_[S]=r(c(p,e[i][S]),c(m,e[a][S])),v[S]=n(c(m,e[i][S]),c(p,e[a][S]));e[i][i]=b,e[a][a]=x,e[i][a]=u(0),e[a][i]=u(0);for(var C=0;C<l;C++)C!==i&&C!==a&&(e[i][C]=_[C],e[C][i]=_[C],e[a][C]=v[C],e[C][a]=v[C]);return e}function x(e,t,n,r){for(var i=e.length,a=Math.cos(t),o=Math.sin(t),s=a*a,c=o*o,l=Array(i).fill(0),u=Array(i).fill(0),d=s*e[n][n]-2*a*o*e[n][r]+c*e[r][r],f=c*e[n][n]+2*a*o*e[n][r]+s*e[r][r],p=0;p<i;p++)l[p]=a*e[n][p]-o*e[r][p],u[p]=o*e[n][p]+a*e[r][p];e[n][n]=d,e[r][r]=f,e[n][r]=0,e[r][n]=0;for(var m=0;m<i;m++)m!==n&&m!==r&&(e[n][m]=l[m],e[m][n]=l[m],e[r][m]=u[m],e[m][r]=u[m]);return e}function S(e){for(var t=e.length,n=0,r=[0,1],i=0;i<t;i++)for(var a=i+1;a<t;a++)Math.abs(n)<Math.abs(e[i][a])&&(n=Math.abs(e[i][a]),r=[i,a]);return[r,n]}function C(e){for(var t=e.length,n=0,r=[0,1],a=0;a<t;a++)for(var o=a+1;o<t;o++)i(n)<i(e[a][o])&&(n=i(e[a][o]),r=[a,o]);return[r,n]}function w(e,t,n){var r=e.length,a=Array(r),o;if(n){o=Array(r);for(var s=0;s<r;s++)o[s]=Array(r)}for(var c=0;c<r;c++){for(var l=0,u=e[0],d=0;d<e.length;d++)i(e[d])<i(u)&&(l=d,u=e[l]);if(a[c]=e.splice(l,1)[0],n)for(var f=0;f<r;f++)o[c][f]=t[f][l],t[f].splice(l,1)}return n?{values:a,eigenvectors:o.map((e,t)=>({value:a[t],vector:e}))}:{values:a}}return p}var Pb=J(`eigs`,`config.typed.matrix.addScalar.equal.subtract.abs.atan.cos.sin.multiplyScalar.divideScalar.inv.bignumber.multiply.add.larger.column.flatten.number.complex.sqrt.diag.size.reshape.qr.usolve.usolveAll.im.re.smaller.matrixFromColumns.dot`.split(`.`),e=>{var{config:t,typed:n,matrix:r,addScalar:i,subtract:a,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,divideScalar:f,inv:p,bignumber:m,multiply:h,add:g,larger:_,column:v,flatten:y,number:b,complex:x,sqrt:S,diag:C,size:w,reshape:T,qr:E,usolve:D,usolveAll:O,im:k,re:A,smaller:j,matrixFromColumns:M,dot:N}=e,P=Nb({config:t,addScalar:i,subtract:a,column:v,flatten:y,equal:o,abs:s,atan:c,cos:l,sin:u,multiplyScalar:d,inv:p,bignumber:m,complex:x,multiply:h,add:g}),F=Mb({config:t,addScalar:i,subtract:a,multiply:h,multiplyScalar:d,flatten:y,divideScalar:f,sqrt:S,abs:s,bignumber:m,diag:C,size:w,reshape:T,qr:E,inv:p,usolve:D,usolveAll:O,equal:o,complex:x,larger:_,smaller:j,matrixFromColumns:M,dot:N});return n(`eigs`,{Array:function(e){return I(r(e))},"Array, number|BigNumber":function(e,t){return I(r(e),{precision:t})},"Array, Object"(e,t){return I(r(e),t)},Matrix:function(e){return I(e,{matricize:!0})},"Matrix, number|BigNumber":function(e,t){return I(e,{precision:t,matricize:!0})},"Matrix, Object":function(e,t){var n={matricize:!0};return Rn(n,t),I(e,n)}});function I(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=`eigenvectors`in n?n.eigenvectors:!0,a=L(e,n.precision??t.relTol,i);return n.matricize&&(a.values=r(a.values),i&&(a.eigenvectors=a.eigenvectors.map(e=>{var{value:t,vector:n}=e;return{value:t,vector:r(n)}}))),i&&Object.defineProperty(a,`vectors`,{enumerable:!1,get:()=>{throw Error(`eigs(M).vectors replaced with eigs(M).eigenvectors`)}}),a}function L(e,t,n){var r=e.toArray(),i=e.size();if(i.length!==2||i[0]!==i[1])throw RangeError(`Matrix must be square (size: ${ws(i)})`);var a=i[0];return z(r,a,t)&&(B(r,a),R(r,a,t))?P(r,a,t,V(e,r,a),n):F(r,a,t,V(e,r,a),n)}function R(e,t,n){for(var r=0;r<t;r++)for(var i=r;i<t;i++)if(_(m(s(a(e[r][i],e[i][r]))),n))return!1;return!0}function z(e,t,n){for(var r=0;r<t;r++)for(var i=0;i<t;i++)if(_(m(s(k(e[r][i]))),n))return!1;return!0}function B(e,t){for(var n=0;n<t;n++)for(var r=0;r<t;r++)e[n][r]=A(e[n][r])}function V(e,t,n){var r=e.datatype();if(r===`number`||r===`BigNumber`||r===`Complex`)return r;for(var i=!1,a=!1,o=!1,s=0;s<n;s++)for(var c=0;c<n;c++){var l=t[s][c];if(tr(l)||ar(l))i=!0;else if(nr(l))a=!0;else if(ir(l))o=!0;else throw TypeError(`Unsupported type in Matrix: `+Gr(l))}if(a&&o&&console.warn(`Complex BigNumbers not supported, this operation will lose precission.`),o){for(var u=0;u<n;u++)for(var d=0;d<n;d++)t[u][d]=x(t[u][d]);return`Complex`}if(a){for(var f=0;f<n;f++)for(var p=0;p<n;p++)t[f][p]=m(t[f][p]);return`BigNumber`}if(i){for(var h=0;h<n;h++)for(var g=0;g<n;g++)t[h][g]=b(t[h][g]);return`number`}else throw TypeError(`Matrix contains unsupported types only.`)}}),Fb=`expm`,Ib=J(Fb,[`typed`,`abs`,`add`,`identity`,`inv`,`multiply`],e=>{var{typed:t,abs:n,add:r,identity:i,inv:a,multiply:o}=e;return t(Fb,{Matrix:function(e){var t=e.size();if(t.length!==2||t[0]!==t[1])throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);for(var n=t[0],l=c(s(e),1e-15),u=l.q,d=l.j,f=o(e,2**-d),p=i(n),m=i(n),h=1,g=f,_=-1,v=1;v<=u;v++)v>1&&(g=o(g,f),_=-_),h=h*(u-v+1)/((2*u-v+1)*v),p=r(p,o(h,g)),m=r(m,o(h*_,g));for(var y=o(a(m),p),b=0;b<d;b++)y=o(y,y);return fr(e)?e.createSparseMatrix(y):y}});function s(e){for(var t=e.size()[0],r=0,i=0;i<t;i++){for(var a=0,o=0;o<t;o++)a+=n(e.get([i,o]));r=Math.max(a,r)}return r}function c(e,t){for(var n=30,r=0;r<n;r++)for(var i=0;i<=r;i++){var a=r-i;if(l(e,i,a)<t)return{q:i,j:a}}throw Error(`Could not find acceptable parameters to compute the matrix exponential (try increasing maxSearchSize in expm.js)`)}function l(e,t,n){for(var r=1,i=2;i<=t;i++)r*=i;for(var a=r,o=t+1;o<=2*t;o++)a*=o;var s=a*(2*t+1);return 8*(e/2**n)**(2*t)*r*r/(a*s)}}),Lb=`sqrtm`,Rb=J(Lb,[`typed`,`abs`,`add`,`multiply`,`map`,`sqrt`,`subtract`,`inv`,`size`,`max`,`identity`],e=>{var{typed:t,abs:n,add:r,multiply:i,map:a,sqrt:o,subtract:s,inv:c,size:l,max:u,identity:d}=e,f=1e3,p=1e-6;function m(e){var t,a=0,o=e,m=d(l(e));do{var h=o;if(o=i(.5,r(h,c(m))),m=i(.5,r(m,c(h))),t=u(n(s(o,h))),t>p&&++a>f)throw Error(`computing square root of matrix: iterative method could not converge`)}while(t>p);return o}return t(Lb,{"Array | Matrix":function(e){var t=lr(e)?e.size():Ps(e);switch(t.length){case 1:if(t[0]===1)return a(e,o);throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);case 2:if(t[0]===t[1])return m(e);throw RangeError(`Matrix must be square (size: `+ws(t)+`)`);default:throw RangeError(`Matrix must be at most two dimensional (size: `+ws(t)+`)`)}}})}),zb=`sylvester`,Bb=J(zb,[`typed`,`schur`,`matrixFromColumns`,`matrix`,`multiply`,`range`,`concat`,`transpose`,`index`,`subset`,`add`,`subtract`,`identity`,`lusolve`,`abs`],e=>{var{typed:t,schur:n,matrixFromColumns:r,matrix:i,multiply:a,range:o,concat:s,transpose:c,index:l,subset:u,add:d,subtract:f,identity:p,lusolve:m,abs:h,config:g}=e;return t(zb,{"Matrix, Matrix, Matrix":_,"Array, Matrix, Matrix":function(e,t,n){return _(i(e),t,n)},"Array, Array, Matrix":function(e,t,n){return _(i(e),i(t),n)},"Array, Matrix, Array":function(e,t,n){return _(i(e),t,i(n))},"Matrix, Array, Matrix":function(e,t,n){return _(e,i(t),n)},"Matrix, Array, Array":function(e,t,n){return _(e,i(t),i(n))},"Matrix, Matrix, Array":function(e,t,n){return _(e,t,i(n))},"Array, Array, Array":function(e,t,n){return _(i(e),i(t),i(n)).toArray()}});function _(e,t,g){for(var _=t.size()[0],v=e.size()[0],y=n(e),b=y.T,x=y.U,S=n(a(-1,t)),C=S.T,w=S.U,T=a(a(c(x),g),w),E=o(0,v),D=[],O=(e,t)=>s(e,t,1),k=(e,t)=>s(e,t,0),A=0;A<_;A++)if(A<_-1&&h(u(C,l(A+1,A)))>1e-5){for(var j=k(u(T,l(E,[A])),u(T,l(E,[A+1]))),M=0;M<A;M++)j=d(j,k(a(D[M],u(C,l(M,A))),a(D[M],u(C,l(M,A+1)))));var N=a(p(v),a(-1,u(C,l(A,A)))),P=a(p(v),a(-1,u(C,l(A+1,A)))),F=a(p(v),a(-1,u(C,l(A,A+1)))),I=a(p(v),a(-1,u(C,l(A+1,A+1)))),L=m(k(O(d(b,N),P),O(F,d(b,I))),j);D[A]=L.subset(l(o(0,v),[0])),D[A+1]=L.subset(l(o(v,2*v),[0])),A++}else{for(var R=u(T,l(E,[A])),z=0;z<A;z++)R=d(R,a(D[z],u(C,l(z,A))));D[A]=m(f(b,a(u(C,l(A,A)),p(v))),R)}return a(x,a(i(r(...D)),c(w)))}}),Vb=`schur`,Hb=J(Vb,[`typed`,`matrix`,`identity`,`multiply`,`qr`,`norm`,`subtract`],e=>{var{typed:t,matrix:n,identity:r,multiply:i,qr:a,norm:o,subtract:s}=e;return t(Vb,{Array:function(e){var t=c(n(e));return{U:t.U.valueOf(),T:t.T.valueOf()}},Matrix:function(e){return c(e)}});function c(e){var t=e.size()[0],n=e,c=r(t),l=0,u;do{u=n;var d=a(n),f=d.Q,p=d.R;if(n=i(p,f),c=i(c,f),l++>100)break}while(o(s(n,u))>1e-4);return{U:c,T:n}}}),Ub=`lyap`,Wb=J(Ub,[`typed`,`matrix`,`sylvester`,`multiply`,`transpose`],e=>{var{typed:t,matrix:n,sylvester:r,multiply:i,transpose:a}=e;return t(Ub,{"Matrix, Matrix":function(e,t){return r(e,a(e),i(-1,t))},"Array, Matrix":function(e,t){return r(n(e),a(n(e)),i(-1,t))},"Matrix, Array":function(e,t){return r(e,a(n(e)),n(i(-1,t)))},"Array, Array":function(e,t){return r(n(e),a(n(e)),n(i(-1,t))).toArray()}})}),Gb=J(`divide`,[`typed`,`matrix`,`multiply`,`equalScalar`,`divideScalar`,`inv`],e=>{var{typed:t,matrix:n,multiply:r,equalScalar:i,divideScalar:a,inv:o}=e,s=Sd({typed:t,equalScalar:i}),c=wd({typed:t});return t(`divide`,Jr({"Array | Matrix, Array | Matrix":function(e,t){return r(e,o(t))},"DenseMatrix, any":function(e,t){return c(e,t,a,!1)},"SparseMatrix, any":function(e,t){return s(e,t,a,!1)},"Array, any":function(e,t){return c(n(e),t,a,!1).valueOf()},"any, Array | Matrix":function(e,t){return r(e,o(t))}},a.signatures))}),Kb=`distance`,qb=J(Kb,[`typed`,`addScalar`,`subtractScalar`,`divideScalar`,`multiplyScalar`,`deepEqual`,`sqrt`,`abs`],e=>{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,deepEqual:o,sqrt:s,abs:c}=e;return t(Kb,{"Array, Array, Array":function(e,t,n){if(e.length===2&&t.length===2&&n.length===2){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!u(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!u(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(o(t,n))throw TypeError(`LinePoint1 should not be same with LinePoint2`);var a=r(n[1],t[1]),s=r(t[0],n[0]),c=r(i(n[0],t[1]),i(t[0],n[1]));return g(e[0],e[1],a,s,c)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object, Object":function(e,t,n){if(Object.keys(e).length===2&&Object.keys(t).length===2&&Object.keys(n).length===2){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!u(t))throw TypeError(`Values of lineOnePtX and lineOnePtY should be numbers or BigNumbers`);if(!u(n))throw TypeError(`Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers`);if(o(m(t),m(n)))throw TypeError(`LinePoint1 should not be same with LinePoint2`);if(`pointX`in e&&`pointY`in e&&`lineOnePtX`in t&&`lineOnePtY`in t&&`lineTwoPtX`in n&&`lineTwoPtY`in n){var a=r(n.lineTwoPtY,t.lineOnePtY),s=r(t.lineOnePtX,n.lineTwoPtX),c=r(i(n.lineTwoPtX,t.lineOnePtY),i(t.lineOnePtX,n.lineTwoPtY));return g(e.pointX,e.pointY,a,s,c)}else throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},"Array, Array":function(e,t){if(e.length===2&&t.length===3){if(!u(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!d(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);return g(e[0],e[1],t[0],t[1],t[2])}else if(e.length===3&&t.length===6){if(!d(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!p(t))throw TypeError(`Array with 6 numbers or BigNumbers expected for second argument`);return _(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}else if(e.length===t.length&&e.length>0){if(!f(e)||!f(t))throw TypeError(`All values of an array should be numbers or BigNumbers`);return v(e,t)}else throw TypeError(`Invalid Arguments: Try again`)},"Object, Object":function(e,t){if(Object.keys(e).length===2&&Object.keys(t).length===3){if(!u(e))throw TypeError(`Values of pointX and pointY should be numbers or BigNumbers`);if(!d(t))throw TypeError(`Values of xCoeffLine, yCoeffLine and constant should be numbers or BigNumbers`);if(`pointX`in e&&`pointY`in e&&`xCoeffLine`in t&&`yCoeffLine`in t&&`constant`in t)return g(e.pointX,e.pointY,t.xCoeffLine,t.yCoeffLine,t.constant);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===6){if(!d(e))throw TypeError(`Values of pointX, pointY and pointZ should be numbers or BigNumbers`);if(!p(t))throw TypeError(`Values of x0, y0, z0, a, b and c should be numbers or BigNumbers`);if(`pointX`in e&&`pointY`in e&&`x0`in t&&`y0`in t&&`z0`in t&&`a`in t&&`b`in t&&`c`in t)return _(e.pointX,e.pointY,e.pointZ,t.x0,t.y0,t.z0,t.a,t.b,t.c);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===2&&Object.keys(t).length===2){if(!u(e))throw TypeError(`Values of pointOneX and pointOneY should be numbers or BigNumbers`);if(!u(t))throw TypeError(`Values of pointTwoX and pointTwoY should be numbers or BigNumbers`);if(`pointOneX`in e&&`pointOneY`in e&&`pointTwoX`in t&&`pointTwoY`in t)return v([e.pointOneX,e.pointOneY],[t.pointTwoX,t.pointTwoY]);throw TypeError(`Key names do not match`)}else if(Object.keys(e).length===3&&Object.keys(t).length===3){if(!d(e))throw TypeError(`Values of pointOneX, pointOneY and pointOneZ should be numbers or BigNumbers`);if(!d(t))throw TypeError(`Values of pointTwoX, pointTwoY and pointTwoZ should be numbers or BigNumbers`);if(`pointOneX`in e&&`pointOneY`in e&&`pointOneZ`in e&&`pointTwoX`in t&&`pointTwoY`in t&&`pointTwoZ`in t)return v([e.pointOneX,e.pointOneY,e.pointOneZ],[t.pointTwoX,t.pointTwoY,t.pointTwoZ]);throw TypeError(`Key names do not match`)}else throw TypeError(`Invalid Arguments: Try again`)},Array:function(e){if(!h(e))throw TypeError(`Incorrect array format entered for pairwise distance calculation`);return y(e)}});function l(e){return typeof e==`number`||nr(e)}function u(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])}function d(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])}function f(e){return Array.isArray(e)||(e=m(e)),e.every(l)}function p(e){return e.constructor!==Array&&(e=m(e)),l(e[0])&&l(e[1])&&l(e[2])&&l(e[3])&&l(e[4])&&l(e[5])}function m(e){for(var t=Object.keys(e),n=[],r=0;r<t.length;r++)n.push(e[t[r]]);return n}function h(e){if(e[0].length===2&&l(e[0][0])&&l(e[0][1])){if(e.some(e=>e.length!==2||!l(e[0])||!l(e[1])))return!1}else if(e[0].length===3&&l(e[0][0])&&l(e[0][1])&&l(e[0][2])){if(e.some(e=>e.length!==3||!l(e[0])||!l(e[1])||!l(e[2])))return!1}else return!1;return!0}function g(e,t,r,o,l){return a(c(n(n(i(r,e),i(o,t)),l)),s(n(i(r,r),i(o,o))))}function _(e,t,o,c,l,u,d,f,p){var m=[r(i(r(l,t),p),i(r(u,o),f)),r(i(r(u,o),d),i(r(c,e),p)),r(i(r(c,e),f),i(r(l,t),d))];m=s(n(n(i(m[0],m[0]),i(m[1],m[1])),i(m[2],m[2])));var h=s(n(n(i(d,d),i(f,f)),i(p,p)));return a(m,h)}function v(e,t){for(var a=e.length,o=0,c=0,l=0;l<a;l++)c=r(e[l],t[l]),o=n(i(c,c),o);return s(o)}function y(e){for(var t=[],n=[],r=[],i=0;i<e.length-1;i++)for(var a=i+1;a<e.length;a++)e[0].length===2?(n=[e[i][0],e[i][1]],r=[e[a][0],e[a][1]]):e[0].length===3&&(n=[e[i][0],e[i][1],e[i][2]],r=[e[a][0],e[a][1],e[a][2]]),t.push(v(n,r));return t}}),Jb=J(`intersect`,[`typed`,`config`,`abs`,`add`,`addScalar`,`matrix`,`multiply`,`multiplyScalar`,`divideScalar`,`subtract`,`smaller`,`equalScalar`,`flatten`,`isZero`,`isNumeric`],e=>{var{typed:t,config:n,abs:r,add:i,addScalar:a,matrix:o,multiply:s,multiplyScalar:c,divideScalar:l,subtract:u,smaller:d,equalScalar:f,flatten:p,isZero:m,isNumeric:h}=e;return t(`intersect`,{"Array, Array, Array":g,"Array, Array, Array, Array":_,"Matrix, Matrix, Matrix":function(e,t,n){var r=g(e.valueOf(),t.valueOf(),n.valueOf());return r===null?null:o(r)},"Matrix, Matrix, Matrix, Matrix":function(e,t,n,r){var i=_(e.valueOf(),t.valueOf(),n.valueOf(),r.valueOf());return i===null?null:o(i)}});function g(e,t,n){if(e=v(e),t=v(t),n=v(n),!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!x(n))throw TypeError(`Array with 4 numbers expected as third argument`);return T(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],n[3])}function _(e,t,n,r){if(e=v(e),t=v(t),n=v(n),r=v(r),e.length===2){if(!y(e))throw TypeError(`Array with 2 numbers or BigNumbers expected for first argument`);if(!y(t))throw TypeError(`Array with 2 numbers or BigNumbers expected for second argument`);if(!y(n))throw TypeError(`Array with 2 numbers or BigNumbers expected for third argument`);if(!y(r))throw TypeError(`Array with 2 numbers or BigNumbers expected for fourth argument`);return S(e,t,n,r)}else if(e.length===3){if(!b(e))throw TypeError(`Array with 3 numbers or BigNumbers expected for first argument`);if(!b(t))throw TypeError(`Array with 3 numbers or BigNumbers expected for second argument`);if(!b(n))throw TypeError(`Array with 3 numbers or BigNumbers expected for third argument`);if(!b(r))throw TypeError(`Array with 3 numbers or BigNumbers expected for fourth argument`);return w(e[0],e[1],e[2],t[0],t[1],t[2],n[0],n[1],n[2],r[0],r[1],r[2])}else throw TypeError(`Arrays with two or thee dimensional points expected`)}function v(e){return e.length===1?e[0]:e.length>1&&Array.isArray(e[0])&&e.every(e=>Array.isArray(e)&&e.length===1)?p(e):e}function y(e){return e.length===2&&h(e[0])&&h(e[1])}function b(e){return e.length===3&&h(e[0])&&h(e[1])&&h(e[2])}function x(e){return e.length===4&&h(e[0])&&h(e[1])&&h(e[2])&&h(e[3])}function S(e,t,o,f){var p=e,h=o,g=u(p,t),_=u(h,f),v=u(c(g[0],_[1]),c(_[0],g[1]));if(m(v)||d(r(v),n.relTol))return null;var y=c(_[0],p[1]),b=c(_[1],p[0]),x=c(_[0],h[1]),S=c(_[1],h[0]);return i(s(g,l(a(u(u(y,b),x),S),v)),p)}function C(e,t,n,r,i,o,s,l,d,f,p,m){var h=c(u(e,t),u(n,r)),g=c(u(i,o),u(s,l)),_=c(u(d,f),u(p,m));return a(a(h,g),_)}function w(e,t,n,r,i,o,s,d,p,h,g,_){var v=C(e,s,h,s,t,d,g,d,n,p,_,p),y=C(h,s,r,e,g,d,i,t,_,p,o,n),b=C(e,s,r,e,t,d,i,t,n,p,o,n),x=C(h,s,h,s,g,d,g,d,_,p,_,p),S=C(r,e,r,e,i,t,i,t,o,n,o,n),w=u(c(v,y),c(b,x)),T=u(c(S,x),c(y,y));if(m(T))return null;var E=l(w,T),D=l(a(v,c(E,y)),x),O=a(e,c(E,u(r,e))),k=a(t,c(E,u(i,t))),A=a(n,c(E,u(o,n))),j=a(s,c(D,u(h,s))),M=a(d,c(D,u(g,d))),N=a(p,c(D,u(_,p)));return f(O,j)&&f(k,M)&&f(A,N)?[O,k,A]:null}function T(e,t,n,r,i,o,s,d,f,p){var m=c(e,s),h=c(r,s),g=c(t,d),_=c(i,d),v=c(n,f),y=c(o,f),b=l(u(u(u(p,m),g),v),u(u(u(a(a(h,_),y),m),g),v));return[a(e,c(b,u(r,e))),a(t,c(b,u(i,t))),a(n,c(b,u(o,n)))]}}),Yb=`sum`,Xb=J(Yb,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e;return t(Yb,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":o,"...":function(e){if(Tc(e))throw TypeError(`Scalar values expected in function sum`);return a(e)}});function a(e){var t;return Ec(e,function(e){try{t=t===void 0?e:r(t,e)}catch(t){throw Wm(t,`sum`,e)}}),t===void 0&&(t=i(0,n.number)),typeof t==`string`&&(t=i(t,pi(t,n))),t}function o(e,t){try{return Oc(e,t,r)}catch(e){throw Wm(e,`sum`)}}}),Zb=`cumsum`,Qb=J(Zb,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e;return t(Zb,{Array:i,Matrix:function(e){return e.create(i(e.valueOf(),e.datatype()))},"Array, number | BigNumber":o,"Matrix, number | BigNumber":function(e,t){return e.create(o(e.valueOf(),t),e.datatype())},"...":function(e){if(Tc(e))throw TypeError(`All values expected to be scalar in function cumsum`);return i(e)}});function i(e){try{return a(e)}catch(e){throw Wm(e,Zb)}}function a(e){if(e.length===0)return[];for(var t=[r(e[0])],i=1;i<e.length;++i)t.push(n(t[i-1],e[i]));return t}function o(e,t){var n=Ps(e);if(t<0||t>=n.length)throw new Ns(t,n.length);try{return s(e,t)}catch(e){throw Wm(e,Zb)}}function s(e,t){var n,r,i;if(t<=0){var o=e[0][0];if(Array.isArray(o)){for(i=wc(e),r=[],n=0;n<i.length;n++)r[n]=s(i[n],t-1);return r}else return a(e)}else{for(r=[],n=0;n<e.length;n++)r[n]=s(e[n],t-1);return r}}}),$b=`mean`,ex=J($b,[`typed`,`add`,`divide`],e=>{var{typed:t,add:n,divide:r}=e;return t($b,{"Array | Matrix":a,"Array | Matrix, number | BigNumber":i,"...":function(e){if(Tc(e))throw TypeError(`Scalar values expected in function mean`);return a(e)}});function i(e,t){try{return r(Oc(e,t,n),(Array.isArray(e)?Ps(e):e.size())[t])}catch(e){throw Wm(e,`mean`)}}function a(e){var t,i=0;if(Ec(e,function(e){try{t=t===void 0?e:n(t,e),i++}catch(t){throw Wm(t,`mean`,e)}}),i===0)throw Error(`Cannot calculate the mean of an empty array`);return r(t,i)}}),tx=`median`,nx=J(tx,[`typed`,`add`,`divide`,`compare`,`partitionSelect`],e=>{var{typed:t,add:n,divide:r,compare:i,partitionSelect:a}=e;function o(e){try{e=Xs(e.valueOf());var t=e.length;if(t===0)throw Error(`Cannot calculate median of an empty array`);if(t%2==0){for(var n=t/2-1,r=a(e,n+1),o=e[n],l=0;l<n;++l)i(e[l],o)>0&&(o=e[l]);return c(o,r)}else return s(a(e,(t-1)/2))}catch(e){throw Wm(e,`median`)}}var s=t({"number | BigNumber | Complex | Unit":function(e){return e}}),c=t({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(e,t){return r(n(e,t),2)}});return t(tx,{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw Error(`median(A, dim) is not yet supported`)},"...":function(e){if(Tc(e))throw TypeError(`Scalar values expected in function median`);return o(e)}})}),rx=`mad`,ix=J(rx,[`typed`,`abs`,`map`,`median`,`subtract`],e=>{var{typed:t,abs:n,map:r,median:i,subtract:a}=e;return t(rx,{"Array | Matrix":o,"...":function(e){return o(e)}});function o(e){if(e=Xs(e.valueOf()),e.length===0)throw Error(`Cannot calculate median absolute deviation (mad) of an empty array`);try{var t=i(e);return i(r(e,function(e){return n(a(e,t))}))}catch(e){throw e instanceof TypeError&&e.message.includes(`median`)?TypeError(e.message.replace(`median`,`mad`)):Wm(e,`mad`)}}}),ax=`unbiased`,ox=`variance`,sx=J(ox,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e;return t(ox,{"Array | Matrix":function(e){return c(e,ax)},"Array | Matrix, string":c,"Array | Matrix, number | BigNumber":function(e,t){return l(e,t,ax)},"Array | Matrix, number | BigNumber, string":l,"...":function(e){return c(e,ax)}});function c(e,t){var o,c=0;if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);if(Ec(e,function(e){try{o=o===void 0?e:n(o,e),c++}catch(t){throw Wm(t,`variance`,e)}}),c===0)throw Error(`Cannot calculate variance of an empty array`);var l=a(o,c);if(o=void 0,Ec(e,function(e){var t=r(e,l);o=o===void 0?i(t,t):n(o,i(t,t))}),s(o))return o;switch(t){case`uncorrected`:return a(o,c);case`biased`:return a(o,c+1);case`unbiased`:var u=nr(o)?o.mul(0):0;return c===1?u:a(o,c-1);default:throw Error(`Unknown normalization "`+t+`". Choose "unbiased" (default), "uncorrected", or "biased".`)}}function l(e,t,n){try{if(e.length===0)throw SyntaxError(`Function variance requires one or more parameters (0 provided)`);return o(e,t,e=>c(e,n))}catch(e){throw Wm(e,`variance`)}}}),cx=`quantileSeq`,lx=J(cx,[`typed`,`?bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e;return t(cx,{"Array | Matrix, number | BigNumber":(e,t)=>h(e,t,!1),"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,!1,n,h),"Array | Matrix, number | BigNumber, boolean":h,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,r,h),"Array | Matrix, Array | Matrix":(e,t)=>g(e,t,!1),"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,!1,n,g),"Array | Matrix, Array | Matrix, boolean":g,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,r,g)});function m(e,t,n,r,i){return p(e,r,e=>i(e,t,n))}function h(e,t,i){var o,s=e.valueOf();if(u(t,0))throw Error(`N/prob must be non-negative`);if(d(t,1))return tr(t)?_(s,t,i):n(_(s,t,i));if(f(t,1)){if(!l(t))throw Error(`N must be a positive integer`);if(f(t,4294967295))throw Error(`N must be less than or equal to 2^32-1, as that is the maximum length of an Array`);var c=r(t,1);o=[];for(var p=0;u(p,t);p++){var m=a(p+1,c);o.push(_(s,m,i))}return tr(t)?o:n(o)}}function g(e,t,n){for(var r=e.valueOf(),i=t.valueOf(),a=[],o=0;o<i.length;++o)a.push(_(r,i[o],n));return a}function _(e,t,n){var a=Xs(e),u=a.length;if(u===0)throw Error(`Cannot calculate quantile of an empty sequence`);var d=tr(t)?t*(u-1):t.times(u-1),f=tr(t)?Math.floor(d):d.floor().toNumber(),p=tr(t)?d%1:d.minus(f);if(l(d))return n?a[d]:s(a,tr(t)?d:d.valueOf());var m,h;if(n)m=a[f],h=a[f+1];else{h=s(a,f+1),m=a[f];for(var g=0;g<f;++g)c(a[g],m)>0&&(m=a[g])}return r(o(m,i(1,p)),o(h,p))}}),ux=`std`,dx=J(ux,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e;return t(ux,{"Array | Matrix":a,"Array | Matrix, string":a,"Array | Matrix, number | BigNumber":a,"Array | Matrix, number | BigNumber, string":a,"...":function(e){return a(e)}});function a(e,t){if(e.length===0)throw SyntaxError(`Function std requires one or more parameters (0 provided)`);try{var a=i.apply(null,arguments);return ur(a)?n(a,r):r(a)}catch(e){throw e instanceof TypeError&&e.message.includes(` variance`)?TypeError(e.message.replace(` variance`,` std`)):e}}}),fx=`corr`,px=J(fx,[`typed`,`matrix`,`mean`,`sqrt`,`sum`,`add`,`subtract`,`multiply`,`pow`,`divide`],e=>{var{typed:t,matrix:n,sqrt:r,sum:i,add:a,subtract:o,multiply:s,pow:c,divide:l}=e;return t(fx,{"Array, Array":function(e,t){return u(e,t)},"Matrix, Matrix":function(e,t){var r=u(e.toArray(),t.toArray());return Array.isArray(r)?n(r):r}});function u(e,t){var n=[];if(Array.isArray(e[0])&&Array.isArray(t[0])){if(e.length!==t.length)throw SyntaxError(`Dimension mismatch. Array A and B must have the same length.`);for(var r=0;r<e.length;r++){if(e[r].length!==t[r].length)throw SyntaxError(`Dimension mismatch. Array A and B must have the same number of elements.`);n.push(d(e[r],t[r]))}return n}else{if(e.length!==t.length)throw SyntaxError(`Dimension mismatch. Array A and B must have the same number of elements.`);return d(e,t)}}function d(e,t){var n=e.length,u=i(e),d=i(t),f=e.reduce((e,n,r)=>a(e,s(n,t[r])),0),p=i(e.map(e=>c(e,2))),m=i(t.map(e=>c(e,2)));return l(o(s(n,f),s(u,d)),r(s(o(s(n,p),c(u,2)),o(s(n,m),c(d,2)))))}}),mx=`bernoulli`,hx=J(mx,[`typed`,`config`,`isInteger`,`number`,`?BigNumber`,`?Fraction`],e=>{var{typed:t,config:n,number:r,BigNumber:i,Fraction:a}=e,o=[void 0],s=[void 0],c=[void 0],l=50;return t(mx,{number:e=>gx(e,e=>e,o,(e,t)=>e+t,(e,t)=>e*t,(e,t)=>e/t),"bigint | Fraction":e=>gx(r(e),e=>new a(e),s,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)),BigNumber:e=>(n.precision!==l&&(c=[void 0],l=n.precision),gx(r(e),e=>new i(e),c,(e,t)=>e.add(t),(e,t)=>e.mul(t),(e,t)=>e.div(t)))})});function gx(e,t,n,r,i,a){if(e<0||!fi(e))throw RangeError(`Bernoulli index must be nonnegative integer`);if(e===0)return t(1);if(e===1)return a(t(-1),t(2));if(e%2==1)return t(0);var o=t(1);n.length===1&&n.push([a(o,t(-3)),a(o,t(-2)),a(o,t(6))]);for(var s=e/2,c=t(0),l=t(2);n.length<=s;){for(var u=n.length,d=Math.floor((u+1)/2),f=c,p=1;p<d;++p)f=r(f,i(n[p][0],n[u-p][0]));f=i(f,l),u%2==0&&(f=r(f,i(n[d][0],n[d][0]))),f=a(f,t(-(2*u+1)));var m=a(i(n[u-1][1],t(-u*(2*u-1))),l);n.push([f,m,i(m,f)])}return n[s][2]}var _x=`combinations`,vx=J(_x,[`typed`],e=>{var{typed:t}=e;return t(_x,{"number, number":_l,"BigNumber, BigNumber":function(e,t){var n=e.constructor,r,i,a=e.minus(t),o=new n(1);if(!yx(e)||!yx(t))throw TypeError(`Positive integer value expected in function combinations`);if(t.gt(e))throw TypeError(`k must be less than n in function combinations`);if(r=o,t.lt(a))for(i=o;i.lte(a);i=i.plus(o))r=r.times(t.plus(i)).dividedBy(i);else for(i=o;i.lte(t);i=i.plus(o))r=r.times(a.plus(i)).dividedBy(i);return r}})});function yx(e){return e.isInteger()&&e.gte(0)}var bx=`combinationsWithRep`,xx=J(bx,[`typed`],e=>{var{typed:t}=e;return t(bx,{"number, number":function(e,t){if(!fi(e)||e<0||!fi(t)||t<0)throw TypeError(`Positive integer value expected in function combinationsWithRep`);if(e<1)throw TypeError(`k must be less than or equal to n + k - 1`);return t<e-1?gl(e,e+t-1)/gl(1,t):gl(t+1,e+t-1)/gl(1,e-1)},"BigNumber, BigNumber":function(e,t){var n=e.constructor,r,i,a=new n(1),o=e.minus(a);if(!Sx(e)||!Sx(t))throw TypeError(`Positive integer value expected in function combinationsWithRep`);if(e.lt(a))throw TypeError(`k must be less than or equal to n + k - 1 in function combinationsWithRep`);if(r=a,t.lt(o))for(i=a;i.lte(o);i=i.plus(a))r=r.times(t.plus(i)).dividedBy(i);else for(i=a;i.lte(t);i=i.plus(a))r=r.times(o.plus(i)).dividedBy(i);return r}})});function Sx(e){return e.isInteger()&&e.gte(0)}var Cx=`gamma`,wx=J(Cx,[`typed`,`config`,`multiplyScalar`,`pow`,`BigNumber`,`Complex`],e=>{var{typed:t,config:n,multiplyScalar:r,pow:i,BigNumber:a,Complex:o}=e;function s(e){if(e.im===0)return Ol(e.re);if(e.re<.5){var t=new o(1-e.re,-e.im),n=new o(Math.PI*e.re,Math.PI*e.im);return new o(Math.PI).div(n.sin()).div(s(t))}e=new o(e.re-1,e.im);for(var r=new o(Al[0],0),i=1;i<Al.length;++i){var a=new o(Al[i],0);r=r.add(a.div(e.add(i)))}var c=new o(e.re+kl+.5,e.im),l=Math.sqrt(2*Math.PI),u=c.pow(e.add(.5)),d=c.neg().exp();return r.mul(l).mul(u).mul(d)}return t(Cx,{number:Ol,Complex:s,BigNumber:function(e){if(e.isInteger())return e.isNegative()||e.isZero()?new a(1/0):c(e.minus(1));if(!e.isFinite())return new a(e.isNegative()?NaN:1/0);throw Error(`Integer BigNumber expected`)}});function c(e){if(e<8)return new a([1,1,2,6,24,120,720,5040][e]);var t=n.precision+(Math.log(e.toNumber())|0),r=a.clone({precision:t});if(e%2==1)return e.times(c(new a(e-1)));for(var i=e,o=new r(e),s=e.toNumber();i>2;)i-=2,s+=i,o=o.times(s);return new a(o.toPrecision(a.precision))}}),Tx=`lgamma`,Ex=J(Tx,[`Complex`,`typed`],e=>{var{Complex:t,typed:n}=e,r=7,i=7,a=[-.029550653594771242,.00641025641025641,-.0019175269175269176,.0008417508417508417,-.0005952380952380953,.0007936507936507937,-.002777777777777778,.08333333333333333];return n(Tx,{number:Nl,Complex:o,BigNumber:function(){throw Error(`mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber`)}});function o(e){var n=6.283185307179586,a=1.1447298858494002,l=.1;if(e.isNaN())return new t(NaN,NaN);if(e.im===0)return new t(Nl(e.re),0);if(e.re>=r||Math.abs(e.im)>=i)return s(e);if(e.re<=l){var u=Ri(n,e.im)*Math.floor(.5*e.re+.25),d=e.mul(Math.PI).sin().log(),f=o(new t(1-e.re,-e.im));return new t(a,u).sub(d).sub(f)}else if(e.im>=0)return c(e);else return c(e.conjugate()).conjugate()}function s(e){for(var n=e.sub(.5).mul(e.log()).sub(e).add(jl),r=new t(1,0).div(e),i=r.div(e),o=a[0],s=a[1],c=2*i.re,l=i.re*i.re+i.im*i.im,u=2;u<8;u++){var d=s;s=-l*o+a[u],o=c*o+d}var f=r.mul(i.mul(o).add(s));return n.add(f)}function c(e){var n=0,i=0,a=e;for(e=e.add(1);e.re<=r;){a=a.mul(e);var o=+(a.im<0);o!==0&&i===0&&n++,i=o,e=e.add(1)}return s(e).sub(a.log()).sub(new t(0,n*2*Math.PI*1))}}),Dx=`factorial`,Ox=J(Dx,[`typed`,`gamma`],e=>{var{typed:t,gamma:n}=e;return t(Dx,{number:function(e){if(e<0)throw Error(`Value must be non-negative`);return n(e+1)},BigNumber:function(e){if(e.isNegative())throw Error(`Value must be non-negative`);return n(e.plus(1))},"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),kx=`kldivergence`,Ax=J(kx,[`typed`,`matrix`,`divide`,`sum`,`multiply`,`map`,`dotDivide`,`log`,`isNumeric`],e=>{var{typed:t,matrix:n,divide:r,sum:i,multiply:a,map:o,dotDivide:s,log:c,isNumeric:l}=e;return t(kx,{"Array, Array":function(e,t){return u(n(e),n(t))},"Matrix, Array":function(e,t){return u(e,n(t))},"Array, Matrix":function(e,t){return u(n(e),t)},"Matrix, Matrix":function(e,t){return u(e,t)}});function u(e,t){var n=t.size().length,u=e.size().length;if(n>1)throw Error(`first object must be one dimensional`);if(u>1)throw Error(`second object must be one dimensional`);if(n!==u)throw Error(`Length of two vectors must be equal`);if(i(e)===0)throw Error(`Sum of elements in first object must be non zero`);if(i(t)===0)throw Error(`Sum of elements in second object must be non zero`);var d=r(e,i(e)),f=i(a(d,o(s(d,r(t,i(t))),e=>c(e))));return l(f)?f:NaN}}),jx=`multinomial`,Mx=J(jx,[`typed`,`add`,`divide`,`multiply`,`factorial`,`isInteger`,`isPositive`],e=>{var{typed:t,add:n,divide:r,multiply:i,factorial:a,isInteger:o,isPositive:s}=e;return t(jx,{"Array | Matrix":function(e){var t=0,c=1;return Ec(e,function(e){if(!o(e)||!s(e))throw TypeError(`Positive integer value expected in function multinomial`);t=n(t,e),c=i(c,a(e))}),r(a(t),c)}})}),Nx=`permutations`,Px=J(Nx,[`typed`,`factorial`],e=>{var{typed:t,factorial:n}=e;return t(Nx,{"number | BigNumber":n,"number, number":function(e,t){if(!fi(e)||e<0||!fi(t)||t<0)throw TypeError(`Positive integer value expected in function permutations`);if(t>e)throw TypeError(`second argument k must be less than or equal to first argument n`);return gl(e-t+1,e)},"BigNumber, BigNumber":function(e,t){var n,r;if(!Fx(e)||!Fx(t))throw TypeError(`Positive integer value expected in function permutations`);if(t.gt(e))throw TypeError(`second argument k must be less than or equal to first argument n`);for(n=e.mul(0).add(1),r=e.minus(t).plus(1);r.lte(e);r=r.plus(1))n=n.times(r);return n}})});function Fx(e){return e.isInteger()&&e.gte(0)}var Ix=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=o();t.next=function(){var e=2091639*t.s0+t.c*23283064365386963e-26;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=e|0)},t.c=1,t.s0=n(` `),t.s1=n(` `),t.s2=n(` `),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function i(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function a(e,t){var n=new r(e),a=t&&t.state,o=n.next;return o.int32=function(){return n.next()*4294967296|0},o.double=function(){return o()+(o()*2097152|0)*11102230246251565e-32},o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}function o(){var e=4022871197;return function(t){t=String(t);for(var n=0;n<t.length;n++){e+=t.charCodeAt(n);var r=.02519603282416938*e;e=r>>>0,r-=e,r*=e,e=r>>>0,r-=e,e+=r*4294967296}return(e>>>0)*23283064365386963e-26}}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.alea=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),Lx=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(e|0)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=n.charCodeAt(r)|0,t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor128=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),Rx=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^(e^e<<1))|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(e|0)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=n.charCodeAt(r)|0,r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function i(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorwow=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),zx=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.x,n=t.i,r=e[n],i;return r^=r>>>7,i=r^r<<24,r=e[n+1&7],i^=r^r>>>10,r=e[n+3&7],i^=r^r>>>3,r=e[n+4&7],i^=r^r<<7,r=e[n+7&7],r^=r<<13,i^=r^r<<9,e[n]=i,t.i=n+1&7,i};function n(e,t){var n,r=[];if(t===(t|0))r[0]=t;else for(t=``+t,n=0;n<t.length;++n)r[n&7]=r[n&7]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&r[n]===0;++n);for(n==8?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}n(t,e)}function i(e,t){return t.x=e.x.slice(),t.i=e.i,t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.x&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xorshift7=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),Bx=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this;t.next=function(){var e=t.w,n=t.X,r=t.i,i,a;return t.w=e=e+1640531527|0,a=n[r+34&127],i=n[r=r+1&127],a^=a<<13,i^=i<<17,a^=a>>>15,i^=i>>>12,a=n[r]=a^i,t.i=r,a+(e^e>>>16)|0};function n(e,t){var n,r,i,a,o,s=[],c=128;for(t===(t|0)?(r=t,t=null):(t+=`\0`,r=0,c=Math.max(c,t.length)),i=0,a=-32;a<c;++a)t&&(r^=t.charCodeAt((a+32)%t.length)),a===0&&(o=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,a>=0&&(o=o+1640531527|0,n=s[a&127]^=r+o,i=n==0?i+1:0);for(i>=128&&(s[(t&&t.length||0)&127]=-1),i=127,a=512;a>0;--a)r=s[i+34&127],n=s[i=i+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,s[i]=r^n;e.w=o,e.X=s,e.i=i}n(t,e)}function i(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function a(e,t){e??=+new Date;var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(a.X&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.xor4096=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),Vx=lt(((e,t)=>{(function(e,t,n){function r(e){var t=this,n=``;t.next=function(){var e=t.b,n=t.c,r=t.d,i=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^i,i=i-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^i,t.a=i-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=e|0):n+=e;for(var r=0;r<n.length+20;r++)t.b^=n.charCodeAt(r)|0,t.next()}function i(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function a(e,t){var n=new r(e),a=t&&t.state,o=function(){return(n.next()>>>0)/4294967296};return o.double=function(){do var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21);while(e===0);return e},o.int32=n.next,o.quick=o,a&&(typeof a==`object`&&i(a,n),o.state=function(){return i(n,{})}),o}t&&t.exports?t.exports=a:n&&n.amd?n(function(){return a}):this.tychei=a})(e,typeof t==`object`&&t,typeof define==`function`&&define)})),Hx=lt(((e,t)=>{t.exports={}})),Ux=lt(((e,t)=>{(function(e,n,r){var i=256,a=6,o=52,s=`random`,c=r.pow(i,a),l=r.pow(2,o),u=l*2,d=i-1,f;function p(e,t,o){var d=[];t=t==1?{entropy:!0}:t||{};var f=_(g(t.entropy?[e,y(n)]:e??v(),3),d),p=new m(d),b=function(){for(var e=p.g(a),t=c,n=0;e<l;)e=(e+n)*i,t*=i,n=p.g(1);for(;e>=u;)e/=2,t/=2,n>>>=1;return(e+n)/t};return b.int32=function(){return p.g(4)|0},b.quick=function(){return p.g(4)/4294967296},b.double=b,_(y(p.S),n),(t.pass||o||function(e,t,n,i){return i&&(i.S&&h(i,p),e.state=function(){return h(p,{})}),n?(r[s]=e,t):e})(b,f,`global`in t?t.global:this==r,t.state)}function m(e){var t,n=e.length,r=this,a=0,o=r.i=r.j=0,s=r.S=[];for(n||(e=[n++]);a<i;)s[a]=a++;for(a=0;a<i;a++)s[a]=s[o=d&o+e[a%n]+(t=s[a])],s[o]=t;(r.g=function(e){for(var t,n=0,a=r.i,o=r.j,s=r.S;e--;)t=s[a=d&a+1],n=n*i+s[d&(s[a]=s[o=d&o+t])+(s[o]=t)];return r.i=a,r.j=o,n})(i)}function h(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function g(e,t){var n=[],r=typeof e,i;if(t&&r==`object`)for(i in e)try{n.push(g(e[i],t-1))}catch{}return n.length?n:r==`string`?e:e+`\0`}function _(e,t){for(var n=e+``,r,i=0;i<n.length;)t[d&i]=d&(r^=t[d&i]*19)+n.charCodeAt(i++);return y(t)}function v(){try{var t;return f&&(t=f.randomBytes)?t=t(i):(t=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(t)),y(t)}catch{var r=e.navigator,a=r&&r.plugins;return[+new Date,e,a,e.screen,y(n)]}}function y(e){return String.fromCharCode.apply(0,e)}if(_(r.random(),n),typeof t==`object`&&t.exports){t.exports=p;try{f=Hx()}catch{}}else typeof define==`function`&&define.amd?define(function(){return p}):r[`seed`+s]=p})(typeof self<`u`?self:e,[],Math)})),Wx=ft(lt(((e,t)=>{var n=Ix(),r=Lx(),i=Rx(),a=zx(),o=Bx(),s=Vx(),c=Ux();c.alea=n,c.xor128=r,c.xorwow=i,c.xorshift7=a,c.xor4096=o,c.tychei=s,t.exports=c}))(),1),Gx=(0,Wx.default)(Date.now());function Kx(e){var t;function n(e){t=e===null?Gx:(0,Wx.default)(String(e))}n(e);function r(){return t()}return r}var qx=`pickRandom`,Jx=J(qx,[`typed`,`config`,`?on`],e=>{var{typed:t,config:n,on:r}=e,i=Kx(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=Kx(e.randomSeed))}),t(qx,{"Array | Matrix":function(e){return a(e,{})},"Array | Matrix, Object":function(e,t){return a(e,t)},"Array | Matrix, number":function(e,t){return a(e,{number:t})},"Array | Matrix, Array | Matrix":function(e,t){return a(e,{weights:t})},"Array | Matrix, Array | Matrix, number":function(e,t,n){return a(e,{number:n,weights:t})},"Array | Matrix, number, Array | Matrix":function(e,t,n){return a(e,{number:t,weights:n})}});function a(e,t){var{number:n,weights:r,elementWise:a=!0}=t,o=n===void 0;o&&(n=1);var s=lr(e)?e.create:lr(r)?r.create:null;e=e.valueOf(),r&&=r.valueOf(),a===!0&&(e=Xs(e),r=Xs(r));var c=0;if(r!==void 0){if(r.length!==e.length)throw Error(`Weights must have the same length as possibles`);for(var l=0,u=r.length;l<u;l++){if(!tr(r[l])||r[l]<0)throw Error(`Weights must be an array of positive numbers`);c+=r[l]}}for(var d=e.length,f=[],p;f.length<n;){if(r===void 0)p=e[Math.floor(i()*d)];else for(var m=i()*c,h=0,g=e.length;h<g;h++)if(m-=r[h],m<0){p=e[h];break}f.push(p)}return o?f[0]:s?s(f):f}});function Yx(e,t){var n=[];if(e=e.slice(0),e.length>1)for(var r=0,i=e.shift();r<i;r++)n.push(Yx(e,t));else for(var a=0,o=e.shift();a<o;a++)n.push(t());return n}var Xx=`random`,Zx=J(Xx,[`typed`,`config`,`?on`],e=>{var{typed:t,config:n,on:r}=e,i=Kx(n.randomSeed);return r&&r(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(i=Kx(e.randomSeed))}),t(Xx,{"":()=>o(0,1),number:e=>o(0,e),"number, number":(e,t)=>o(e,t),"Array | Matrix":e=>a(e,0,1),"Array | Matrix, number":(e,t)=>a(e,0,t),"Array | Matrix, number, number":(e,t,n)=>a(e,t,n)});function a(e,t,n){var r=Yx(e.valueOf(),()=>o(t,n));return lr(e)?e.create(r,`number`):r}function o(e,t){return e+i()*(t-e)}}),Qx=`randomInt`,$x=J(Qx,[`typed`,`config`,`log2`,`?on`],e=>{var{typed:t,config:n,log2:r,on:i}=e,a=Kx(n.randomSeed);return i&&i(`config`,function(e,t){e.randomSeed!==t.randomSeed&&(a=Kx(e.randomSeed))}),t(Qx,{"":()=>s(0,2),number:e=>s(0,e),"number, number":(e,t)=>s(e,t),bigint:e=>c(0n,e),"bigint, bigint":c,"Array | Matrix":e=>o(e,0,1),"Array | Matrix, number":(e,t)=>o(e,0,t),"Array | Matrix, number, number":(e,t,n)=>o(e,t,n)});function o(e,t,n){var r=Yx(e.valueOf(),()=>s(t,n));return lr(e)?e.create(r,`number`):r}function s(e,t){return Math.floor(e+a()*(t-e))}function c(e,t){var n=2n**30n,i=t-e;if(i<=n)return e+BigInt(s(0,Number(i)));for(var o=r(i),c=i;c>=i;){c=0n;for(var l=0;l<o;++l)c=2n*c+(a()<.5?0n:1n)}return e+c}}),eS=`stirlingS2`,tS=J(eS,[`typed`,`addScalar`,`subtractScalar`,`multiplyScalar`,`divideScalar`,`pow`,`factorial`,`combinations`,`isNegative`,`isInteger`,`number`,`?bignumber`,`larger`],e=>{var{typed:t,addScalar:n,subtractScalar:r,multiplyScalar:i,divideScalar:a,pow:o,factorial:s,combinations:c,isNegative:l,isInteger:u,number:d,bignumber:f,larger:p}=e,m=[],h=[];return t(eS,{"number | BigNumber, number | BigNumber":function(e,t){if(!u(e)||l(e)||!u(t)||l(t))throw TypeError(`Non-negative integer value expected in function stirlingS2`);if(p(t,e))throw TypeError(`k must be less than or equal to n in function stirlingS2`);var r=!(tr(e)&&tr(t)),a=r?h:m,o=r?f:d,s=d(e),c=d(t);if(a[s]&&a[s].length>c)return a[s][c];for(var g=0;g<=s;++g)if(a[g]||(a[g]=[o(+(g===0))]),g!==0)for(var _=a[g],v=a[g-1],y=_.length;y<=g&&y<=c;++y)y===g?_[y]=1:_[y]=n(i(o(y),v[y]),v[y-1]);return a[s][c]}})}),nS=`bellNumbers`,rS=J(nS,[`typed`,`addScalar`,`isNegative`,`isInteger`,`stirlingS2`],e=>{var{typed:t,addScalar:n,isNegative:r,isInteger:i,stirlingS2:a}=e;return t(nS,{"number | BigNumber":function(e){if(!i(e)||r(e))throw TypeError(`Non-negative integer value expected in function bellNumbers`);for(var t=0,o=0;o<=e;o++)t=n(t,a(e,o));return t}})}),iS=`catalan`,aS=J(iS,[`typed`,`addScalar`,`divideScalar`,`multiplyScalar`,`combinations`,`isNegative`,`isInteger`],e=>{var{typed:t,addScalar:n,divideScalar:r,multiplyScalar:i,combinations:a,isNegative:o,isInteger:s}=e;return t(iS,{"number | BigNumber":function(e){if(!s(e)||o(e))throw TypeError(`Non-negative integer value expected in function catalan`);return r(a(i(e,2),e),n(e,1))}})}),oS=`composition`,sS=J(oS,[`typed`,`addScalar`,`combinations`,`isNegative`,`isPositive`,`isInteger`,`larger`],e=>{var{typed:t,addScalar:n,combinations:r,isPositive:i,isNegative:a,isInteger:o,larger:s}=e;return t(oS,{"number | BigNumber, number | BigNumber":function(e,t){if(!o(e)||!i(e)||!o(t)||!i(t))throw TypeError(`Positive integer value expected in function composition`);if(s(t,e))throw TypeError(`k must be less than or equal to n in function composition`);return r(n(e,-1),n(t,-1))}})}),cS=`leafCount`,lS=J(cS,[`parse`,`typed`],e=>{var{parse:t,typed:n}=e;function r(e){var t=0;return e.forEach(e=>{t+=r(e)}),t||1}return n(cS,{Node:function(e){return r(e)}})});function uS(e){return Mr(e)||zr(e)&&e.isUnary()&&Mr(e.args[0])}function dS(e){return!!(Mr(e)||(Fr(e)||zr(e))&&e.args.every(dS)||Br(e)&&dS(e.content))}function fS(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 pS(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?fS(Object(n),!0).forEach(function(t){Am(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fS(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var mS=J(`simplifyUtil`,[`FunctionNode`,`OperatorNode`,`SymbolNode`],e=>{var{FunctionNode:t,OperatorNode:n,SymbolNode:r}=e,i=!0,a=!1,o=`defaultF`,s={add:{trivial:i,total:i,commutative:i,associative:i},unaryPlus:{trivial:i,total:i,commutative:i,associative:i},subtract:{trivial:a,total:i,commutative:a,associative:a},multiply:{trivial:i,total:i,commutative:i,associative:i},divide:{trivial:a,total:i,commutative:a,associative:a},paren:{trivial:i,total:i,commutative:i,associative:a},defaultF:{trivial:a,total:i,commutative:a,associative:a}},c={divide:{total:a},log:{total:a}},l={subtract:{total:a},abs:{trivial:i},log:{total:i}};function u(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:s,r=o;if(typeof e==`string`?r=e:zr(e)?r=e.fn.toString():Fr(e)?r=e.name:Br(e)&&(r=`paren`),ei(n,r)){var i=n[r];if(ei(i,t))return i[t];if(ei(s,r))return s[r][t]}if(ei(n,o)){var a=n[o];return ei(a,t)?a[t]:s[o][t]}if(ei(s,r)){var c=s[r];if(ei(c,t))return c[t]}return s[o][t]}function d(e){return u(e,`commutative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function f(e){return u(e,`associative`,arguments.length>1&&arguments[1]!==void 0?arguments[1]:s)}function p(e,t){var n=pS({},e);for(var r in t)ei(e,r)?n[r]=pS(pS({},t[r]),e[r]):n[r]=t[r];return n}function m(e,t){if(!e.args||e.args.length===0)return e;e.args=h(e,t);for(var n=0;n<e.args.length;n++)m(e.args[n],t)}function h(e,t){var n,r=[],i=function(e){for(var t=0;t<e.args.length;t++){var a=e.args[t];zr(a)&&n===a.op?i(a):r.push(a)}};return f(e,t)?(n=e.op,i(e),r):e.args}function g(e,t){if(!(!e.args||e.args.length===0)){for(var n=v(e),r=e.args.length,i=0;i<r;i++)g(e.args[i],t);if(r>2&&f(e,t)){for(var a=e.args.pop();e.args.length>0;)a=n([e.args.pop(),a]);e.args=a.args}}}function _(e,t){if(!(!e.args||e.args.length===0)){for(var n=v(e),r=e.args.length,i=0;i<r;i++)_(e.args[i],t);if(r>2&&f(e,t)){for(var a=e.args.shift();e.args.length>0;)a=n([a,e.args.shift()]);e.args=a.args}}}function v(e){return zr(e)?function(t){try{return new n(e.op,e.fn,t,e.implicit)}catch(e){return console.error(e),[]}}:function(n){return new t(new r(e.name),n)}}return{createMakeNodeFunction:v,hasProperty:u,isCommutative:d,isAssociative:f,mergeContext:p,flatten:m,allChildren:h,unflattenr:g,unflattenl:_,defaultContext:s,realContext:c,positiveContext:l}}),hS=J(`simplify`,[`typed`,`parse`,`equal`,`resolve`,`simplifyConstant`,`simplifyCore`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`,`replacer`],e=>{var{typed:t,parse:n,equal:r,resolve:i,simplifyConstant:a,simplifyCore:o,AccessorNode:s,ArrayNode:c,ConstantNode:l,FunctionNode:u,IndexNode:d,ObjectNode:f,OperatorNode:p,ParenthesisNode:m,SymbolNode:h,replacer:g}=e,{hasProperty:_,isCommutative:v,isAssociative:y,mergeContext:b,flatten:x,unflattenr:S,unflattenl:C,createMakeNodeFunction:w,defaultContext:T,realContext:E,positiveContext:D}=mS({FunctionNode:u,OperatorNode:p,SymbolNode:h});t.addConversion({from:`Object`,to:`Map`,convert:$n});var O=t(`simplify`,{Node:F,"Node, Map":(e,t)=>F(e,!1,t),"Node, Map, Object":(e,t,n)=>F(e,!1,t,n),"Node, Array":F,"Node, Array, Map":F,"Node, Array, Map, Object":F});t.removeConversion({from:`Object`,to:`Map`,convert:$n}),O.defaultContext=T,O.realContext=E,O.positiveContext=D;function k(e){return e.transform(function(e){return Br(e)?k(e.content):e})}var A={true:!0,false:!0,e:!0,i:!0,Infinity:!0,LN2:!0,LN10:!0,LOG2E:!0,LOG10E:!0,NaN:!0,phi:!0,pi:!0,SQRT1_2:!0,SQRT2:!0,tau:!0};O.rules=[o,{l:`log(e)`,r:`1`},{s:`n-n1 -> n+-n1`,assuming:{subtract:{total:!0}}},{s:`n-n -> 0`,assuming:{subtract:{total:!1}}},{s:`-(cl*v) -> v * (-cl)`,assuming:{multiply:{commutative:!0},subtract:{total:!0}}},{s:`-(cl*v) -> (-cl) * v`,assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{s:`-(v*cl) -> v * (-cl)`,assuming:{multiply:{commutative:!1},subtract:{total:!0}}},{l:`-(n1/n2)`,r:`-n1/n2`},{l:`-v`,r:`v * (-1)`},{l:`(n1 + n2)*(-1)`,r:`n1*(-1) + n2*(-1)`,repeat:!0},{l:`n/n1^n2`,r:`n*n1^-n2`},{l:`n/n1`,r:`n*n1^-1`},{s:`(n1*n2)^n3 -> n1^n3 * n2^n3`,assuming:{multiply:{commutative:!0}}},{s:`(n1*n2)^(-1) -> n2^(-1) * n1^(-1)`,assuming:{multiply:{commutative:!1}}},{s:`(n ^ n1) ^ n2 -> n ^ (n1 * n2)`,assuming:{divide:{total:!0}}},{l:` vd * ( vd * n1 + n2)`,r:`vd^2 * n1 + vd * n2`},{s:` vd * (vd^n4 * n1 + n2) -> vd^(1+n4) * n1 + vd * n2`,assuming:{divide:{total:!0}}},{s:`vd^n3 * ( vd * n1 + n2) -> vd^(n3+1) * n1 + vd^n3 * n2`,assuming:{divide:{total:!0}}},{s:`vd^n3 * (vd^n4 * n1 + n2) -> vd^(n3+n4) * n1 + vd^n3 * n2`,assuming:{divide:{total:!0}}},{l:`n*n`,r:`n^2`},{s:`n * n^n1 -> n^(n1+1)`,assuming:{divide:{total:!0}}},{s:`n^n1 * n^n2 -> n^(n1+n2)`,assuming:{divide:{total:!0}}},a,{s:`n+n -> 2*n`,assuming:{add:{total:!0}}},{l:`n+-n`,r:`0`},{l:`vd*n + vd`,r:`vd*(n+1)`},{l:`n3*n1 + n3*n2`,r:`n3*(n1+n2)`},{l:`n3^(-n4)*n1 + n3 * n2`,r:`n3^(-n4)*(n1 + n3^(n4+1) *n2)`},{l:`n3^(-n4)*n1 + n3^n5 * n2`,r:`n3^(-n4)*(n1 + n3^(n4+n5)*n2)`},{s:`n*vd + vd -> (n+1)*vd`,assuming:{multiply:{commutative:!1}}},{s:`vd + n*vd -> (1+n)*vd`,assuming:{multiply:{commutative:!1}}},{s:`n1*n3 + n2*n3 -> (n1+n2)*n3`,assuming:{multiply:{commutative:!1}}},{s:`n^n1 * n -> n^(n1+1)`,assuming:{divide:{total:!0},multiply:{commutative:!1}}},{s:`n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)`,assuming:{multiply:{commutative:!1}}},{s:`n1*n3^(-n4) + n2 * n3^n5 -> (n1 + n2*n3^(n4 + n5))*n3^(-n4)`,assuming:{multiply:{commutative:!1}}},{l:`n*cd + cd`,r:`(n+1)*cd`},{s:`cd*n + cd -> cd*(n+1)`,assuming:{multiply:{commutative:!1}}},{s:`cd + cd*n -> cd*(1+n)`,assuming:{multiply:{commutative:!1}}},a,{s:`(-n)*n1 -> -(n*n1)`,assuming:{subtract:{total:!0}}},{s:`n1*(-n) -> -(n1*n)`,assuming:{subtract:{total:!0},multiply:{commutative:!1}}},{s:`ce+ve -> ve+ce`,assuming:{add:{commutative:!0}},imposeContext:{add:{commutative:!1}}},{s:`vd*cd -> cd*vd`,assuming:{multiply:{commutative:!0}},imposeContext:{multiply:{commutative:!1}}},{l:`n+-n1`,r:`n-n1`},{l:`n+-(n1)`,r:`n-(n1)`},{s:`n*(n1^-1) -> n/n1`,assuming:{multiply:{commutative:!0}}},{s:`n*n1^-n2 -> n/n1^n2`,assuming:{multiply:{commutative:!0}}},{s:`n^-1 -> 1/n`,assuming:{multiply:{commutative:!0}}},{l:`n^1`,r:`n`},{s:`n*(n1/n2) -> (n*n1)/n2`,assuming:{multiply:{associative:!0}}},{s:`n-(n1+n2) -> n-n1-n2`,assuming:{addition:{associative:!0,commutative:!0}}},{l:`1*n`,r:`n`,imposeContext:{multiply:{commutative:!0}}},{s:`n1/(n2/n3) -> (n1*n3)/n2`,assuming:{multiply:{associative:!0}}},{l:`n1/(-n2)`,r:`-n1/n2`}];function j(e,t){var r={};if(e.s){var i=e.s.split(`->`);if(i.length===2)r.l=i[0],r.r=i[1];else throw SyntaxError(`Could not parse rule: `+e.s)}else r.l=e.l,r.r=e.r;r.l=k(n(r.l)),r.r=k(n(r.r));for(var a of[`imposeContext`,`repeat`,`assuming`])a in e&&(r[a]=e[a]);if(e.evaluate&&(r.evaluate=n(e.evaluate)),y(r.l,t)){var o=!v(r.l,t),s;o&&(s=P());var c=w(r.l),l=P();r.expanded={},r.expanded.l=c([r.l,l]),x(r.expanded.l,t),S(r.expanded.l,t),r.expanded.r=c([r.r,l]),o&&(r.expandedNC1={},r.expandedNC1.l=c([s,r.l]),r.expandedNC1.r=c([s,r.r]),r.expandedNC2={},r.expandedNC2.l=c([s,r.expanded.l]),r.expandedNC2.r=c([s,r.expanded.r]))}return r}function M(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r],a=void 0,o=typeof i;switch(o){case`string`:i={s:i};case`object`:a=j(i,t);break;case`function`:a=i;break;default:throw TypeError(`Unsupported type of rule: `+o)}n.push(a)}return n}var N=0;function P(){return new h(`_p`+ N++)}function F(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qn(),r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=r.consoleDebug;t=M(t||O.rules,r.context);var o=i(e,n);o=k(o);for(var s={},c=o.toString({parenthesis:`all`});!s[c];){s[c]=!0,N=0;var l=c;a&&console.log(`Working on: `,c);for(var u=0;u<t.length;u++){var d=``;if(typeof t[u]==`function`?(o=t[u](o,r),a&&(d=t[u].name)):(x(o,r.context),o=L(o,t[u],r.context),a&&(d=`${t[u].l.toString()} -> ${t[u].r.toString()}`)),a){var f=o.toString({parenthesis:`all`});f!==l&&(console.log(`Applying`,d,`produced`,f),l=f)}C(o,r.context)}c=o.toString({parenthesis:`all`})}return o}function I(e,t,n){var r=e;if(e)for(var i=0;i<e.length;++i){var a=L(e[i],t,n);a!==e[i]&&(r===e&&(r=e.slice()),r[i]=a)}return r}function L(e,t,n){if(t.assuming){for(var r in t.assuming)for(var i in t.assuming[r])if(_(r,i,n)!==t.assuming[r][i])return e}var a=b(t.imposeContext,n),o=e;if(o instanceof p||o instanceof u){var l=I(o.args,t,n);l!==o.args&&(o=o.clone(),o.args=l)}else if(o instanceof m){if(o.content){var h=L(o.content,t,n);h!==o.content&&(o=new m(h))}}else if(o instanceof c){var g=I(o.items,t,n);g!==o.items&&(o=new c(g))}else if(o instanceof s){var v=o.object;o.object&&(v=L(o.object,t,n));var y=o.index;o.index&&(y=L(o.index,t,n)),(v!==o.object||y!==o.index)&&(o=new s(v,y))}else if(o instanceof d){var x=I(o.dimensions,t,n);x!==o.dimensions&&(o=new d(x))}else if(o instanceof f){var S=!1,C={};for(var w in o.properties)C[w]=L(o.properties[w],t,n),C[w]!==o.properties[w]&&(S=!0);S&&(o=new f(C))}var T=t.r,E=ee(t.l,o,a)[0];if(!E&&t.expanded&&(T=t.expanded.r,E=ee(t.expanded.l,o,a)[0]),!E&&t.expandedNC1&&(T=t.expandedNC1.r,E=ee(t.expandedNC1.l,o,a)[0],E||=(T=t.expandedNC2.r,ee(t.expandedNC2.l,o,a)[0])),E){var D=o.implicit;o=T.clone(),D&&`implicit`in T&&(o.implicit=!0),o=o.transform(function(e){return e.isSymbolNode&&ei(E.placeholders,e.name)?E.placeholders[e.name].clone():e})}return t.repeat&&o!==e&&(o=L(o,t,n)),o}function R(e,t){var n=[],r,i,a=w(e);if(v(e,t))for(var o=0;o<e.args.length;o++)i=e.args.slice(0),i.splice(o,1),r=i.length===1?i[0]:a(i),n.push(a([e.args[o],r]));else for(var s=1;s<e.args.length;s++){var c=e.args[0];s>1&&(c=a(e.args.slice(0,s))),i=e.args.slice(s),r=i.length===1?i[0]:a(i),n.push(a([c,r]))}return n}function z(e,t){var n={placeholders:{}};if(!e.placeholders&&!t.placeholders)return n;if(!e.placeholders)return t;if(!t.placeholders)return e;for(var r in e.placeholders)if(ei(e.placeholders,r)&&(n.placeholders[r]=e.placeholders[r],ei(t.placeholders,r)&&!te(e.placeholders[r],t.placeholders[r])))return null;for(var i in t.placeholders)ei(t.placeholders,i)&&(n.placeholders[i]=t.placeholders[i]);return n}function B(e,t){var n=[];if(e.length===0||t.length===0)return n;for(var r,i=0;i<e.length;i++)for(var a=0;a<t.length;a++)r=z(e[i],t[a]),r&&n.push(r);return n}function V(e){if(e.length===0)return e;for(var t=e.reduce(B),n=[],r={},i=0;i<t.length;i++){var a=JSON.stringify(t[i],g);r[a]||(r[a]=!0,n.push(t[i]))}return n}function ee(e,t,n,i){var a=[{placeholders:{}}];if(e instanceof p&&t instanceof p||e instanceof u&&t instanceof u){if(e instanceof p){if(e.op!==t.op||e.fn!==t.fn)return[]}else if(e instanceof u&&e.name!==t.name)return[];if(t.args.length===1&&e.args.length===1||!y(t,n)&&t.args.length===e.args.length||i){for(var o=[],s=0;s<e.args.length;s++){var c=ee(e.args[s],t.args[s],n);if(c.length===0)break;o.push(c)}if(o.length!==e.args.length){if(!v(t,n)||e.args.length===1)return[];if(e.args.length>2)throw Error(`permuting >2 commutative non-associative rule arguments not yet implemented`);var d=ee(e.args[0],t.args[1],n);if(d.length===0)return[];var f=ee(e.args[1],t.args[0],n);if(f.length===0)return[];o=[d,f]}a=V(o)}else if(t.args.length>=2&&e.args.length===2){for(var m=R(t,n),g=[],_=0;_<m.length;_++){var b=ee(e,m[_],n,!0);g=g.concat(b)}return g}else if(e.args.length>2)throw Error(`Unexpected non-binary associative function: `+e.toString());else return[]}else if(e instanceof h){if(e.name.length===0)throw Error(`Symbol in rule has 0 length...!?`);if(A[e.name]){if(e.name!==t.name)return[]}else switch(e.name[1]>=`a`&&e.name[1]<=`z`?e.name.substring(0,2):e.name[0]){case`n`:case`_p`:a[0].placeholders[e.name]=t;break;case`c`:case`cl`:if(Mr(t))a[0].placeholders[e.name]=t;else return[];break;case`v`:if(!Mr(t))a[0].placeholders[e.name]=t;else return[];break;case`vl`:if(Ur(t))a[0].placeholders[e.name]=t;else return[];break;case`cd`:if(uS(t))a[0].placeholders[e.name]=t;else return[];break;case`vd`:if(!uS(t))a[0].placeholders[e.name]=t;else return[];break;case`ce`:if(dS(t))a[0].placeholders[e.name]=t;else return[];break;case`ve`:if(!dS(t))a[0].placeholders[e.name]=t;else return[];break;default:throw Error(`Invalid symbol in rule: `+e.name)}}else if(e instanceof l){if(!r(e.value,t.value))return[]}else return[];return a}function te(e,t){if(e instanceof l&&t instanceof l){if(!r(e.value,t.value))return!1}else if(e instanceof h&&t instanceof h){if(e.name!==t.name)return!1}else if(e instanceof p&&t instanceof p||e instanceof u&&t instanceof u){if(e instanceof p){if(e.op!==t.op||e.fn!==t.fn)return!1}else if(e instanceof u&&e.name!==t.name)return!1;if(e.args.length!==t.args.length)return!1;for(var n=0;n<e.args.length;n++)if(!te(e.args[n],t.args[n]))return!1}else return!1;return!0}return O}),gS=J(`simplifyConstant`,[`typed`,`config`,`mathWithTransform`,`matrix`,`isBounded`,`?fraction`,`?bignumber`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`SymbolNode`],e=>{var{typed:t,config:n,mathWithTransform:r,matrix:i,isBounded:a,fraction:o,bignumber:s,AccessorNode:c,ArrayNode:l,ConstantNode:u,FunctionNode:d,IndexNode:f,ObjectNode:p,OperatorNode:m,SymbolNode:h}=e,{isCommutative:g,isAssociative:_,allChildren:v,createMakeNodeFunction:y}=mS({FunctionNode:d,OperatorNode:m,SymbolNode:h}),b=t(`simplifyConstant`,{Node:e=>w(j(e,{})),"Node, Object":function(e,t){return w(j(e,t))}});function x(e){return ar(e)?e.valueOf():e instanceof Array?e.map(x):lr(e)?i(x(e.valueOf())):e}function S(e,t,n){try{return r[e].apply(null,t)}catch{return t=t.map(x),E(r[e].apply(null,t),n)}}var C=t({Fraction:O,number:function(e){return e<0?D(new u(-e)):new u(e)},BigNumber:function(e){return e<0?D(new u(-e)):new u(e)},bigint:function(e){return e<0n?D(new u(-e)):new u(e)},Complex:function(e){throw Error(`Cannot convert Complex number to Node`)},string:function(e){return new u(e)},Matrix:function(e){return new l(e.valueOf().map(e=>C(e)))}});function w(e){return Lr(e)?e:C(e)}function T(e,t){if(t&&t.exactFractions!==!1&&a(e)&&o){var n=o(e),r=t&&typeof t.fractionsLimit==`number`?t.fractionsLimit:1/0;if(n.valueOf()===e&&n.n<r&&n.d<r)return n}return e}var E=t({"string, Object":function(e,t){var r=pi(e,n);return r===`BigNumber`?(s===void 0&&qp(),s(e)):r===`bigint`?BigInt(e):r===`Fraction`?(o===void 0&&Jp(),o(e)):T(parseFloat(e),t)},"Fraction, Object":function(e,t){return e},"BigNumber, Object":function(e,t){return e},"number, Object":function(e,t){return T(e,t)},"bigint, Object":function(e,t){return e},"Complex, Object":function(e,t){return e.im===0?T(e.re,t):e},"Matrix, Object":function(e,t){return i(T(e.valueOf()))},"Array, Object":function(e,t){return e.map(T)}});function D(e){return new m(`-`,`unaryMinus`,[e])}function O(e){var t=e=>n.number===`BigNumber`&&s?s(e):Number(e),r=e.s*e.n,i=r<0n?new m(`-`,`unaryMinus`,[new u(-t(r))]):new u(t(r));return e.d===1n?i:new m(`/`,`divide`,[i,new u(t(e.d))])}function k(e,t,n){if(!Ir(t))return new c(w(e),w(t));if(Or(e)||lr(e)){for(var r=Array.from(t.dimensions);r.length>0;)if(Mr(r[0])&&typeof r[0].value!=`string`){var a=E(r.shift().value,n);Or(e)?e=e.items[a-1]:(e=e.valueOf()[a-1],e instanceof Array&&(e=i(e)))}else if(r.length>1&&Mr(r[1])&&typeof r[1].value!=`string`){var o=E(r[1].value,n),s=[],d=Or(e)?e.items:e.valueOf();for(var p of d)if(Or(p))s.push(p.items[o-1]);else if(lr(e))s.push(p[o-1]);else break;if(s.length===d.length)e=Or(e)?new l(s):i(s),r.splice(1,1);else break}else break;return r.length===t.dimensions.length?new c(w(e),t):r.length>0?(t=new f(r),new c(w(e),t)):e}if(Rr(e)&&t.dimensions.length===1&&Mr(t.dimensions[0])){var m=t.dimensions[0].value;return m in e.properties?e.properties[m]:new u}return new c(w(e),t)}function A(e,t,n,r){var i=t.shift(),a=t.reduce((t,i)=>{if(!Lr(i)){var a=t.pop();if(Lr(a))return[a,i];try{return t.push(S(e,[a,i],r)),t}catch{t.push(a)}}return t.push(w(t.pop())),[n([t.length===1?t[0]:n(t),w(i)])]},[i]);return a.length===1?a[0]:n([a[0],C(a[1])])}function j(e,t){switch(e.type){case`SymbolNode`:return e;case`ConstantNode`:switch(typeof e.value){case`number`:return E(e.value,t);case`bigint`:return E(e.value,t);case`string`:return e.value;default:if(!isNaN(e.value))return E(e.value,t)}return e;case`FunctionNode`:if(r[e.name]&&r[e.name].rawArgs)return e;if(![`add`,`multiply`].includes(e.name)){var n=e.args.map(e=>j(e,t));if(!n.some(Lr))try{return S(e.name,n,t)}catch{}if(e.name===`size`&&n.length===1&&Or(n[0])){for(var a=[],o=n[0];Or(o);)a.push(o.items.length),o=o.items[0];return i(a)}return new d(e.name,n.map(w))}case`OperatorNode`:var s=e.fn.toString(),c,u,m=y(e);if(zr(e)&&e.isUnary())c=[j(e.args[0],t)],u=Lr(c[0])?m(c):S(s,c,t);else if(_(e,t.context))if(c=v(e,t.context),c=c.map(e=>j(e,t)),g(s,t.context)){for(var h=[],x=[],C=0;C<c.length;C++)Lr(c[C])?x.push(c[C]):h.push(c[C]);h.length>1?(u=A(s,h,m,t),x.unshift(u),u=A(s,x,m,t)):u=A(s,c,m,t)}else u=A(s,c,m,t);else c=e.args.map(e=>j(e,t)),u=A(s,c,m,t);return u;case`ParenthesisNode`:return j(e.content,t);case`AccessorNode`:return k(j(e.object,t),j(e.index,t),t);case`ArrayNode`:var T=e.items.map(e=>j(e,t));return T.some(Lr)?new l(T.map(w)):i(T);case`IndexNode`:return new f(e.dimensions.map(e=>b(e,t)));case`ObjectNode`:var D={};for(var O in e.properties)D[O]=b(e.properties[O],t);return new p(D);default:throw Error(`Unimplemented node type in simplifyConstant: ${e.type}`)}}return b}),_S=`simplifyCore`,vS=J(_S,[`typed`,`parse`,`equal`,`isZero`,`add`,`subtract`,`multiply`,`divide`,`pow`,`AccessorNode`,`ArrayNode`,`ConstantNode`,`FunctionNode`,`IndexNode`,`ObjectNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,parse:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,AccessorNode:u,ArrayNode:d,ConstantNode:f,FunctionNode:p,IndexNode:m,ObjectNode:h,OperatorNode:g,ParenthesisNode:_,SymbolNode:v}=e,y=new f(0),b=new f(1),x=new f(!0),S=new f(!1);function C(e){return zr(e)&&[`and`,`not`,`or`].includes(e.op)}var{hasProperty:w,isCommutative:T}=mS({FunctionNode:p,OperatorNode:g,SymbolNode:v});function E(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t?t.context:void 0;if(w(e,`trivial`,n)){if(Fr(e)&&e.args.length===1)return E(e.args[0],t);var a=!1,o=0;if(e.forEach(e=>{++o,o===1&&(a=E(e,t))}),o===1)return a}var s=e;if(Fr(s)){var c=Hv(s.name);if(c){if(s.args.length>2&&w(s,`associative`,n))for(;s.args.length>2;){var l=s.args.pop(),f=s.args.pop();s.args.push(new g(c,s.name,[l,f]))}s=new g(c,s.name,s.args)}else return new p(E(s.fn),s.args.map(e=>E(e,t)))}if(zr(s)&&s.isUnary()){var _=E(s.args[0],t);if(s.op===`~`&&zr(_)&&_.isUnary()&&_.op===`~`||s.op===`not`&&zr(_)&&_.isUnary()&&_.op===`not`&&C(_.args[0]))return _.args[0];var v=!0;if(s.op===`-`&&zr(_)&&(_.isBinary()&&_.fn===`subtract`&&(s=new g(`-`,`subtract`,[_.args[1],_.args[0]]),v=!1),_.isUnary()&&_.op===`-`))return _.args[0];if(v)return new g(s.op,s.fn,[_])}if(zr(s)&&s.isBinary()){var D=E(s.args[0],t),O=E(s.args[1],t);if(s.op===`+`){if(Mr(D)&&i(D.value))return O;if(Mr(O)&&i(O.value))return D;zr(O)&&O.isUnary()&&O.op===`-`&&(O=O.args[0],s=new g(`-`,`subtract`,[D,O]))}if(s.op===`-`)return zr(O)&&O.isUnary()&&O.op===`-`?E(new g(`+`,`add`,[D,O.args[0]]),t):Mr(D)&&i(D.value)?E(new g(`-`,`unaryMinus`,[O])):Mr(O)&&i(O.value)?D:new g(s.op,s.fn,[D,O]);if(s.op===`*`){if(Mr(D)){if(i(D.value))return y;if(r(D.value,1))return O}if(Mr(O)){if(i(O.value))return y;if(r(O.value,1))return D;if(T(s,n))return new g(s.op,s.fn,[O,D],s.implicit)}return new g(s.op,s.fn,[D,O],s.implicit)}if(s.op===`/`)return Mr(D)&&i(D.value)?y:Mr(O)&&r(O.value,1)?D:new g(s.op,s.fn,[D,O]);if(s.op===`^`&&Mr(O)){if(i(O.value))return b;if(r(O.value,1))return D}if(s.op===`and`){if(Mr(D))if(D.value){if(C(O))return O;if(Mr(O))return O.value?x:S}else return S;if(Mr(O))if(O.value){if(C(D))return D}else return S}if(s.op===`or`){if(Mr(D)){if(D.value)return x;if(C(O))return O}if(Mr(O)){if(O.value)return x;if(C(D))return D}}return new g(s.op,s.fn,[D,O])}if(zr(s))return new g(s.op,s.fn,s.args.map(e=>E(e,t)));if(Or(s))return new d(s.items.map(e=>E(e,t)));if(Dr(s))return new u(E(s.object,t),E(s.index,t));if(Ir(s))return new m(s.dimensions.map(e=>E(e,t)));if(Rr(s)){var k={};for(var A in s.properties)k[A]=E(s.properties[A],t);return new h(k)}return s}return t(_S,{Node:E,"Node,Object":E})}),yS=J(`resolve`,[`typed`,`parse`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`],e=>{var{typed:t,parse:n,ConstantNode:r,FunctionNode:i,OperatorNode:a,ParenthesisNode:o}=e;function s(e,t){var c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;if(!t)return e;if(Ur(e)){if(c.has(e.name)){var l=Array.from(c).join(`, `);throw ReferenceError(`recursive loop of variable definitions among {${l}}`)}var u=t.get(e.name);if(Lr(u)){var d=new Set(c);return d.add(e.name),s(u,t,d)}else if(typeof u==`number`)return n(String(u));else if(u!==void 0)return new r(u);else return e}else if(zr(e)){var f=e.args.map(function(e){return s(e,t,c)});return new a(e.op,e.fn,f,e.implicit)}else if(Br(e))return new o(s(e.content,t,c));else if(Fr(e)){var p=e.args.map(function(e){return s(e,t,c)});return new i(e.name,p)}return e.map(e=>s(e,t,c))}return t(`resolve`,{Node:s,"Node, Map | null | undefined":s,"Node, Object":(e,t)=>s(e,$n(t)),"Array | Matrix":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array | Matrix, null | undefined":t.referToSelf(e=>t=>t.map(t=>e(t))),"Array, Object":t.referTo(`Array,Map`,e=>(t,n)=>e(t,$n(n))),"Matrix, Object":t.referTo(`Matrix,Map`,e=>(t,n)=>e(t,$n(n))),"Array | Matrix, Map":t.referToSelf(e=>(t,n)=>t.map(t=>e(t,n)))})}),bS=`symbolicEqual`,xS=J(bS,[`parse`,`simplify`,`typed`,`OperatorNode`],e=>{var{parse:t,simplify:n,typed:r,OperatorNode:i}=e;function a(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=n(new i(`-`,`subtract`,[e,t]),{},r);return Mr(a)&&!a.value}return r(bS,{"Node, Node":a,"Node, Node, Object":a})}),SS=`derivative`,CS=J(SS,[`typed`,`config`,`parse`,`simplify`,`equal`,`isZero`,`numeric`,`ConstantNode`,`FunctionNode`,`OperatorNode`,`ParenthesisNode`,`SymbolNode`],e=>{var{typed:t,config:n,parse:r,simplify:i,equal:a,isZero:o,numeric:s,ConstantNode:c,FunctionNode:l,OperatorNode:u,ParenthesisNode:d,SymbolNode:f}=e;function p(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{simplify:!0},r=new Map,a=t.name;function o(e){var t=r.get(e);if(t!==void 0)return t;var n=_(o,e,a);return r.set(e,n),n}var s=v(e,o);return n.simplify?i(s):s}function m(e){var t=r(e);if(!t.isSymbolNode)throw TypeError(`Invalid variable. Cannot parse ${JSON.stringify(e)} into a variable in function derivative`);return t}var h=t(SS,{"Node, SymbolNode":p,"Node, SymbolNode, Object":p,"Node, string":(e,t)=>p(e,m(t)),"Node, string, Object":(e,t,n)=>p(e,m(t),n)});h._simplify=!0,h.toTex=function(e){return g.apply(null,e.args)};var g=t(`_derivTex`,{"Node, SymbolNode":function(e,t){return Mr(e)&&Gr(e.value)===`string`?g(r(e.value).toString(),t.toString(),1):g(e.toTex(),t.toString(),1)},"Node, ConstantNode":function(e,t){if(Gr(t.value)===`string`)return g(e,r(t.value));throw Error(`The second parameter to 'derivative' is a non-string constant`)},"Node, SymbolNode, ConstantNode":function(e,t,n){return g(e.toString(),t.name,n.value)},"string, string, number":function(e,t,n){return(n===1?`{d\\over d`+t+`}`:`{d^{`+n+`}\\over d`+t+`^{`+n+`}}`)+`\\left[${e}\\right]`}}),_=t(`_isConst`,{"function, ConstantNode, string":function(){return!0},"function, SymbolNode, string":function(e,t,n){return t.name!==n},"function, ParenthesisNode, string":function(e,t,n){return e(t.content,n)},"function, FunctionAssignmentNode, string":function(e,t,n){return t.params.includes(n)?e(t.expr,n):!0},"function, FunctionNode | OperatorNode, string":function(e,t,n){return t.args.every(t=>e(t,n))}}),v=t(`_derivative`,{"ConstantNode, function":function(){return y(0)},"SymbolNode, function":function(e,t){return t(e)?y(0):y(1)},"ParenthesisNode, function":function(e,t){return new d(v(e.content,t))},"FunctionAssignmentNode, function":function(e,t){return t(e)?y(0):v(e.expr,t)},"FunctionNode, function":function(e,t){if(t(e))return y(0);var n=e.args[0],r,i=!1,a=!1,o;switch(e.name){case`cbrt`:i=!0,o=new u(`*`,`multiply`,[y(3),new u(`^`,`pow`,[n,new u(`/`,`divide`,[y(2),y(3)])])]);break;case`sqrt`:case`nthRoot`:if(e.args.length===1)i=!0,o=new u(`*`,`multiply`,[y(2),new l(`sqrt`,[n])]);else if(e.args.length===2)return r=new u(`/`,`divide`,[y(1),e.args[1]]),v(new u(`^`,`pow`,[n,r]),t);break;case`log10`:r=y(10);case`log`:if(!r&&e.args.length===1)o=n.clone(),i=!0;else if(e.args.length===1&&r||e.args.length===2&&t(e.args[1]))o=new u(`*`,`multiply`,[n.clone(),new l(`log`,[r||e.args[1]])]),i=!0;else if(e.args.length===2)return v(new u(`/`,`divide`,[new l(`log`,[n]),new l(`log`,[e.args[1]])]),t);break;case`pow`:if(e.args.length===2)return v(new u(`^`,`pow`,[n,e.args[1]]),t);break;case`exp`:o=new l(`exp`,[n.clone()]);break;case`sin`:o=new l(`cos`,[n.clone()]);break;case`cos`:o=new u(`-`,`unaryMinus`,[new l(`sin`,[n.clone()])]);break;case`tan`:o=new u(`^`,`pow`,[new l(`sec`,[n.clone()]),y(2)]);break;case`sec`:o=new u(`*`,`multiply`,[e,new l(`tan`,[n.clone()])]);break;case`csc`:a=!0,o=new u(`*`,`multiply`,[e,new l(`cot`,[n.clone()])]);break;case`cot`:a=!0,o=new u(`^`,`pow`,[new l(`csc`,[n.clone()]),y(2)]);break;case`asin`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`acos`:i=!0,a=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])]);break;case`atan`:i=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`asec`:i=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acsc`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acot`:i=!0,a=!0,o=new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)]);break;case`sinh`:o=new l(`cosh`,[n.clone()]);break;case`cosh`:o=new l(`sinh`,[n.clone()]);break;case`tanh`:o=new u(`^`,`pow`,[new l(`sech`,[n.clone()]),y(2)]);break;case`sech`:a=!0,o=new u(`*`,`multiply`,[e,new l(`tanh`,[n.clone()])]);break;case`csch`:a=!0,o=new u(`*`,`multiply`,[e,new l(`coth`,[n.clone()])]);break;case`coth`:a=!0,o=new u(`^`,`pow`,[new l(`csch`,[n.clone()]),y(2)]);break;case`asinh`:i=!0,o=new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`acosh`:i=!0,o=new l(`sqrt`,[new u(`-`,`subtract`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])]);break;case`atanh`:i=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`asech`:i=!0,a=!0,o=new u(`*`,`multiply`,[n.clone(),new l(`sqrt`,[new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])])])]);break;case`acsch`:i=!0,a=!0,o=new u(`*`,`multiply`,[new l(`abs`,[n.clone()]),new l(`sqrt`,[new u(`+`,`add`,[new u(`^`,`pow`,[n.clone(),y(2)]),y(1)])])]);break;case`acoth`:i=!0,a=!0,o=new u(`-`,`subtract`,[y(1),new u(`^`,`pow`,[n.clone(),y(2)])]);break;case`abs`:o=new u(`/`,`divide`,[new l(new f(`abs`),[n.clone()]),n.clone()]);break;default:throw Error(`Cannot process function "`+e.name+`" in derivative: the function is not supported, undefined, or the number of arguments passed to it are not supported`)}var s,c;i?(s=`/`,c=`divide`):(s=`*`,c=`multiply`);var d=v(n,t);return a&&(d=new u(`-`,`unaryMinus`,[d])),new u(s,c,[d,o])},"OperatorNode, function":function(e,t){if(t(e))return y(0);if(e.op===`+`)return new u(e.op,e.fn,e.args.map(function(e){return v(e,t)}));if(e.op===`-`){if(e.isUnary())return new u(e.op,e.fn,[v(e.args[0],t)]);if(e.isBinary())return new u(e.op,e.fn,[v(e.args[0],t),v(e.args[1],t)])}if(e.op===`*`){var n=e.args.filter(function(e){return t(e)});if(n.length>0){var r=e.args.filter(function(e){return!t(e)}),i=r.length===1?r[0]:new u(`*`,`multiply`,r);return new u(`*`,`multiply`,n.concat(v(i,t)))}return new u(`+`,`add`,e.args.map(function(n){return new u(`*`,`multiply`,e.args.map(function(e){return e===n?v(e,t):e.clone()}))}))}if(e.op===`/`&&e.isBinary()){var s=e.args[0],c=e.args[1];return t(c)?new u(`/`,`divide`,[v(s,t),c]):t(s)?new u(`*`,`multiply`,[new u(`-`,`unaryMinus`,[s]),new u(`/`,`divide`,[v(c,t),new u(`^`,`pow`,[c.clone(),y(2)])])]):new u(`/`,`divide`,[new u(`-`,`subtract`,[new u(`*`,`multiply`,[v(s,t),c.clone()]),new u(`*`,`multiply`,[s.clone(),v(c,t)])]),new u(`^`,`pow`,[c.clone(),y(2)])])}if(e.op===`^`&&e.isBinary()){var d=e.args[0],f=e.args[1];if(t(d))return Mr(d)&&(o(d.value)||a(d.value,1))?y(0):new u(`*`,`multiply`,[e,new u(`*`,`multiply`,[new l(`log`,[d.clone()]),v(f.clone(),t)])]);if(t(f)){if(Mr(f)){if(o(f.value))return y(0);if(a(f.value,1))return v(d,t)}var p=new u(`^`,`pow`,[d.clone(),new u(`-`,`subtract`,[f,y(1)])]);return new u(`*`,`multiply`,[f.clone(),new u(`*`,`multiply`,[v(d,t),p])])}return new u(`*`,`multiply`,[new u(`^`,`pow`,[d.clone(),f.clone()]),new u(`+`,`add`,[new u(`*`,`multiply`,[v(d,t),new u(`/`,`divide`,[f.clone(),d.clone()])]),new u(`*`,`multiply`,[v(f,t),new l(`log`,[d.clone()])])])])}throw Error(`Cannot process operator "`+e.op+`" in derivative: the operator is not supported, undefined, or the number of arguments passed to it are not supported`)}});function y(e,t){return new c(s(e,t||pi(String(e),n)))}return h}),wS=`rationalize`,TS=J(wS,`config.typed.equal.isZero.add.subtract.multiply.divide.pow.parse.simplifyConstant.simplifyCore.simplify.?bignumber.?fraction.mathWithTransform.matrix.AccessorNode.ArrayNode.ConstantNode.FunctionNode.IndexNode.ObjectNode.OperatorNode.SymbolNode.ParenthesisNode`.split(`.`),e=>{var{config:t,typed:n,equal:r,isZero:i,add:a,subtract:o,multiply:s,divide:c,pow:l,parse:u,simplifyConstant:d,simplifyCore:f,simplify:p,fraction:m,bignumber:h,mathWithTransform:g,matrix:_,AccessorNode:v,ArrayNode:y,ConstantNode:b,FunctionNode:x,IndexNode:S,ObjectNode:C,OperatorNode:w,SymbolNode:T,ParenthesisNode:E}=e;function D(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=k(),i=O(e,t,!0,r.firstRules),a=i.variables.length,o={exactFractions:!1},s={exactFractions:!0};if(e=i.expression,a>=1){e=A(e);var c,l,u=!0,d=!1;e=p(e,r.firstRules,{},o);for(var f;l=u?r.distrDivRules:r.sucDivRules,e=p(e,l,{},s),u=!u,f=e.toString(),f!==c;)d=!0,c=f;d&&(e=p(e,r.firstRulesAgain,{},o)),e=p(e,r.finalRules,{},o)}var m=[],h={};return e.type===`OperatorNode`&&e.isBinary()&&e.op===`/`?(a===1&&(e.args[0]=j(e.args[0],m),e.args[1]=j(e.args[1])),n&&(h.numerator=e.args[0],h.denominator=e.args[1])):(a===1&&(e=j(e,m)),n&&(h.numerator=e,h.denominator=null)),n?(h.coefficients=m,h.variables=i.variables,h.expression=e,h):e}return n(wS,{Node:D,"Node, boolean":(e,t)=>D(e,{},t),"Node, Object":D,"Node, Object, boolean":D});function O(e,t,n,r){var i=[],a=p(e,r,t,{exactFractions:!1});n=!!n;var o=`+-*`+(n?`/`:``);c(a);var s={};return s.expression=a,s.variables=i,s;function c(e){var t=e.type;if(t===`FunctionNode`)throw Error(`There is an unsolved function call`);if(t===`OperatorNode`)if(e.op===`^`){if(e.args[1].type!==`ConstantNode`||!fi(parseFloat(e.args[1].value)))throw Error(`There is a non-integer exponent`);c(e.args[0])}else{if(!o.includes(e.op))throw Error(`Operator `+e.op+` invalid in polynomial expression`);for(var n=0;n<e.args.length;n++)c(e.args[n])}else if(t===`SymbolNode`){var r=e.name;i.indexOf(r)===-1&&i.push(r)}else if(t===`ParenthesisNode`)c(e.content);else if(t!==`ConstantNode`)throw Error(`type `+t+` is not allowed in polynomial expression`)}}function k(){var e=[f,{l:`n+n`,r:`2*n`},{l:`n+-n`,r:`0`},d,{l:`n*(n1^-1)`,r:`n/n1`},{l:`n*n1^-n2`,r:`n/n1^n2`},{l:`n1^-1`,r:`1/n1`},{l:`n*(n1/n2)`,r:`(n*n1)/n2`},{l:`1*n`,r:`n`}],t=[{l:`(-n1)/(-n2)`,r:`n1/n2`},{l:`(-n1)*(-n2)`,r:`n1*n2`},{l:`n1--n2`,r:`n1+n2`},{l:`n1-n2`,r:`n1+(-n2)`},{l:`(n1+n2)*n3`,r:`(n1*n3 + n2*n3)`},{l:`n1*(n2+n3)`,r:`(n1*n2+n1*n3)`},{l:`c1*n + c2*n`,r:`(c1+c2)*n`},{l:`c1*n + n`,r:`(c1+1)*n`},{l:`c1*n - c2*n`,r:`(c1-c2)*n`},{l:`c1*n - n`,r:`(c1-1)*n`},{l:`v/c`,r:`(1/c)*v`},{l:`v/-c`,r:`-(1/c)*v`},{l:`-v*-c`,r:`c*v`},{l:`-v*c`,r:`-c*v`},{l:`v*-c`,r:`-c*v`},{l:`v*c`,r:`c*v`},{l:`-(-n1*n2)`,r:`(n1*n2)`},{l:`-(n1*n2)`,r:`(-n1*n2)`},{l:`-(-n1+n2)`,r:`(n1-n2)`},{l:`-(n1+n2)`,r:`(-n1-n2)`},{l:`(n1^n2)^n3`,r:`(n1^(n2*n3))`},{l:`-(-n1/n2)`,r:`(n1/n2)`},{l:`-(n1/n2)`,r:`(-n1/n2)`}],n=[{l:`(n1/n2 + n3/n4)`,r:`((n1*n4 + n3*n2)/(n2*n4))`},{l:`(n1/n2 + n3)`,r:`((n1 + n3*n2)/n2)`},{l:`(n1 + n2/n3)`,r:`((n1*n3 + n2)/n3)`}],r=[{l:`(n1/(n2/n3))`,r:`((n1*n3)/n2)`},{l:`(n1/n2/n3)`,r:`(n1/(n2*n3))`}],i={};return i.firstRules=e.concat(t,r),i.distrDivRules=n,i.sucDivRules=r,i.firstRulesAgain=e.concat(t),i.finalRules=[f,{l:`n*-n`,r:`-n^2`},{l:`n*n`,r:`n^2`},d,{l:`n*-n^n1`,r:`-n^(n1+1)`},{l:`n*n^n1`,r:`n^(n1+1)`},{l:`n^n1*-n^n2`,r:`-n^(n1+n2)`},{l:`n^n1*n^n2`,r:`n^(n1+n2)`},{l:`n^n1*-n`,r:`-n^(n1+1)`},{l:`n^n1*n`,r:`n^(n1+1)`},{l:`n^n1/-n`,r:`-n^(n1-1)`},{l:`n^n1/n`,r:`n^(n1-1)`},{l:`n/-n^n1`,r:`-n^(1-n1)`},{l:`n/n^n1`,r:`n^(1-n1)`},{l:`n^n1/-n^n2`,r:`n^(n1-n2)`},{l:`n^n1/n^n2`,r:`n^(n1-n2)`},{l:`n1+(-n2*n3)`,r:`n1-n2*n3`},{l:`v*(-c)`,r:`-c*v`},{l:`n1+-n2`,r:`n1-n2`},{l:`v*c`,r:`c*v`},{l:`(n1^n2)^n3`,r:`(n1^(n2*n3))`}],i}function A(e,t,n){var r=e.type,i=arguments.length>1;if(r===`OperatorNode`&&e.isBinary()){var a=!1,o;if(e.op===`^`&&(e.args[0].type===`ParenthesisNode`||e.args[0].type===`OperatorNode`)&&e.args[1].type===`ConstantNode`&&(o=parseFloat(e.args[1].value),a=o>=2&&fi(o)),a){if(o>2){var s=e.args[0];e=new w(`*`,`multiply`,[s,new w(`^`,`pow`,[e.args[0].cloneDeep(),new b(o-1)])])}else e=new w(`*`,`multiply`,[e.args[0],e.args[0].cloneDeep()]);i&&(n===`content`?t.content=e:t.args[n]=e)}}if(r===`ParenthesisNode`)A(e.content,e,`content`);else if(r!==`ConstantNode`&&r!==`SymbolNode`)for(var c=0;c<e.args.length;c++)A(e.args[c],e,c);if(!i)return e}function j(e,t){t===void 0&&(t=[]),t[0]=0;var n={};n.cte=1,n.oper=`+`,n.fire=``;var r=0,i=``;f(e,null,n),r=t.length-1;for(var a=!0,o,s=r;s>=0;s--)if(t[s]!==0){var c=new b(a?t[s]:Math.abs(t[s])),l=t[s]<0?`-`:`+`;if(s>0){var u=new T(i);if(s>1){var d=new b(s);u=new w(`^`,`pow`,[u,d])}c=t[s]===-1&&a?new w(`-`,`unaryMinus`,[u]):Math.abs(t[s])===1?u:new w(`*`,`multiply`,[c,u])}o=a?c:l===`+`?new w(`+`,`add`,[o,c]):new w(`-`,`subtract`,[o,c]),a=!1}if(a)return new b(0);return o;function f(e,n,a){var o=e.type;if(o===`FunctionNode`)throw Error(`There is an unsolved function call`);if(o===`OperatorNode`){if(!`+-*^`.includes(e.op))throw Error(`Operator `+e.op+` invalid`);if(n!==null&&((e.fn===`unaryMinus`||e.fn===`pow`)&&n.fn!==`add`&&n.fn!==`subtract`&&n.fn!==`multiply`||(e.fn===`subtract`||e.fn===`add`||e.fn===`multiply`)&&n.fn!==`add`&&n.fn!==`subtract`||(e.fn===`subtract`||e.fn===`add`||e.fn===`unaryMinus`)&&a.noFil!==0))throw Error(`Invalid `+e.op+` placing`);(e.op===`^`||e.op===`*`)&&(a.fire=e.op);for(var s=0;s<e.args.length;s++)e.fn===`unaryMinus`&&(a.oper=`-`),(e.op===`+`||e.fn===`subtract`)&&(a.fire=``,a.cte=1,a.oper=s===0?`+`:e.op),a.noFil=s,f(e.args[s],e,a)}else if(o===`SymbolNode`){if(e.name!==i&&i!==``)throw Error(`There is more than one variable`);if(i=e.name,n===null){t[1]=1;return}if(n.op===`^`&&a.noFil!==0)throw Error(`In power the variable should be the first parameter`);if(n.op===`*`&&a.noFil!==1)throw Error(`In multiply the variable should be the second parameter`);(a.fire===``||a.fire===`*`)&&(r<1&&(t[1]=0),t[1]+=a.cte*(a.oper===`+`?1:-1),r=Math.max(1,r))}else if(o===`ConstantNode`){var c=parseFloat(e.value);if(n===null){t[0]=c;return}if(n.op===`^`){if(a.noFil!==1)throw Error(`Constant cannot be powered`);if(!fi(c)||c<=0)throw Error(`Non-integer exponent is not allowed`);for(var l=r+1;l<c;l++)t[l]=0;c>r&&(t[c]=0),t[c]+=a.cte*(a.oper===`+`?1:-1),r=Math.max(c,r);return}a.cte=c,a.fire===``&&(t[0]+=a.cte*(a.oper===`+`?1:-1))}else throw Error(`Type `+o+` is not allowed`)}}}),ES=`zpk2tf`,DS=J(ES,[`typed`,`add`,`multiply`,`Complex`,`number`],e=>{var{typed:t,add:n,multiply:r,Complex:i,number:a}=e;return t(ES,{"Array,Array,number":function(e,t,n){return o(e,t,n)},"Array,Array":function(e,t){return o(e,t,1)},"Matrix,Matrix,number":function(e,t,n){return o(e.valueOf(),t.valueOf(),n)},"Matrix,Matrix":function(e,t){return o(e.valueOf(),t.valueOf(),1)}});function o(e,t,n){e.some(e=>e.type===`BigNumber`)&&(e=e.map(e=>a(e))),t.some(e=>e.type===`BigNumber`)&&(t=t.map(e=>a(e)));for(var o=[i(1,0)],c=[i(1,0)],l=0;l<e.length;l++){var u=e[l];typeof u==`number`&&(u=i(u,0)),o=s(o,[i(1,0),i(-u.re,-u.im)])}for(var d=0;d<t.length;d++){var f=t[d];typeof f==`number`&&(f=i(f,0)),c=s(c,[i(1,0),i(-f.re,-f.im)])}for(var p=0;p<o.length;p++)o[p]=r(o[p],n);return[o,c]}function s(e,t){for(var a=[],o=0;o<e.length+t.length-1;o++){a[o]=i(0,0);for(var s=0;s<e.length;s++)o-s>=0&&o-s<t.length&&(a[o]=n(a[o],r(e[s],t[o-s])))}return a}}),OS=`freqz`,kS=J(OS,[`typed`,`add`,`multiply`,`Complex`,`divide`,`matrix`],e=>{var{typed:t,add:n,multiply:r,Complex:i,divide:a,matrix:o}=e;return t(OS,{"Array, Array":function(e,t){return s(e,t,c(512))},"Array, Array, Array":function(e,t,n){return s(e,t,n)},"Array, Array, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);return s(e,t,c(n))},"Matrix, Matrix":function(e,t){var n=c(512),{w:r,h:i}=s(e.valueOf(),t.valueOf(),n);return{w:o(r),h:o(i)}},"Matrix, Matrix, Matrix":function(e,t,n){var{h:r}=s(e.valueOf(),t.valueOf(),n.valueOf());return{h:o(r),w:o(n)}},"Matrix, Matrix, number":function(e,t,n){if(n<0)throw Error(`w must be a positive number`);var r=c(n),{h:i}=s(e.valueOf(),t.valueOf(),r);return{h:o(i),w:o(r)}}});function s(e,t,o){for(var s=[],c=[],l=0;l<o.length;l++){for(var u=i(0,0),d=i(0,0),f=0;f<e.length;f++)u=n(u,r(e[f],i(Math.cos(-f*o[l]),Math.sin(-f*o[l]))));for(var p=0;p<t.length;p++)d=n(d,r(t[p],i(Math.cos(-p*o[l]),Math.sin(-p*o[l]))));s.push(u),c.push(d)}for(var m=[],h=0;h<s.length;h++)m.push(a(s[h],c[h]));return{h:m,w:o}}function c(e){for(var t=[],n=0;n<e;n++)t.push(n/e*Math.PI);return t}}),AS=J(`reviver`,[`classes`],e=>{var{classes:t}=e;return function(e,n){var r=t[n&&n.mathjs];return r&&typeof r.fromJSON==`function`?r.fromJSON(n):n}}),jS=J(`replacer`,[],()=>function(e,t){return typeof t==`number`&&(!Number.isFinite(t)||isNaN(t))?{mathjs:`number`,value:String(t)}:typeof t==`bigint`?{mathjs:`bigint`,value:String(t)}:t}),MS=`15.2.0`,NS=J(`true`,[],()=>!0),PS=J(`false`,[],()=>!1),FS=J(`null`,[],()=>null),IS=QS(`Infinity`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1/0):1/0}),LS=QS(`NaN`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(NaN):NaN}),RS=QS(`pi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Gg(n):vl}),zS=QS(`tau`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Kg(n):yl}),BS=QS(`e`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Ug(n):bl}),VS=QS(`phi`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?Wg(n):xl}),HS=QS(`LN2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).ln():Math.LN2}),US=QS(`LN10`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(10).ln():Math.LN10}),WS=QS(`LOG2E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(2).ln()):Math.LOG2E}),GS=QS(`LOG10E`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(1).div(new n(10).ln()):Math.LOG10E}),KS=QS(`SQRT1_2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(`0.5`).sqrt():Math.SQRT1_2}),qS=QS(`SQRT2`,[`config`,`?BigNumber`],e=>{var{config:t,BigNumber:n}=e;return t.number===`BigNumber`?new n(2).sqrt():Math.SQRT2}),JS=QS(`i`,[`Complex`],e=>{var{Complex:t}=e;return t.I}),YS=J(`PI`,[`pi`],e=>{var{pi:t}=e;return t}),XS=J(`E`,[`e`],e=>{var{e:t}=e;return t}),ZS=J(`version`,[],()=>MS);function QS(e,t,n){return J(e,t,n,{recreateOnConfigChange:!0})}var $S=XC(`speedOfLight`,`299792458`,`m s^-1`),eC=XC(`gravitationConstant`,`6.67430e-11`,`m^3 kg^-1 s^-2`),tC=XC(`planckConstant`,`6.62607015e-34`,`J s`),nC=XC(`reducedPlanckConstant`,`1.0545718176461565e-34`,`J s`),rC=XC(`magneticConstant`,`1.25663706212e-6`,`N A^-2`),iC=XC(`electricConstant`,`8.8541878128e-12`,`F m^-1`),aC=XC(`vacuumImpedance`,`376.730313667`,`ohm`),oC=XC(`coulomb`,`8.987551792261171e9`,`N m^2 C^-2`),sC=XC(`coulombConstant`,`8.987551792261171e9`,`N m^2 C^-2`),cC=XC(`elementaryCharge`,`1.602176634e-19`,`C`),lC=XC(`bohrMagneton`,`9.2740100783e-24`,`J T^-1`),uC=XC(`conductanceQuantum`,`7.748091729863649e-5`,`S`),dC=XC(`inverseConductanceQuantum`,`12906.403729652257`,`ohm`),fC=XC(`magneticFluxQuantum`,`2.0678338484619295e-15`,`Wb`),pC=XC(`nuclearMagneton`,`5.0507837461e-27`,`J T^-1`),mC=XC(`klitzing`,`25812.807459304513`,`ohm`),hC=XC(`bohrRadius`,`5.29177210903e-11`,`m`),gC=XC(`classicalElectronRadius`,`2.8179403262e-15`,`m`),_C=XC(`electronMass`,`9.1093837015e-31`,`kg`),vC=XC(`fermiCoupling`,`1.1663787e-5`,`GeV^-2`),yC=ZC(`fineStructure`,.0072973525693),bC=XC(`hartreeEnergy`,`4.3597447222071e-18`,`J`),xC=XC(`protonMass`,`1.67262192369e-27`,`kg`),SC=XC(`deuteronMass`,`3.3435830926e-27`,`kg`),CC=XC(`neutronMass`,`1.6749271613e-27`,`kg`),wC=XC(`quantumOfCirculation`,`3.6369475516e-4`,`m^2 s^-1`),TC=XC(`rydberg`,`10973731.568160`,`m^-1`),EC=XC(`thomsonCrossSection`,`6.6524587321e-29`,`m^2`),DC=ZC(`weakMixingAngle`,.2229),OC=ZC(`efimovFactor`,22.7),kC=XC(`atomicMass`,`1.66053906660e-27`,`kg`),AC=XC(`avogadro`,`6.02214076e23`,`mol^-1`),jC=XC(`boltzmann`,`1.380649e-23`,`J K^-1`),MC=XC(`faraday`,`96485.33212331001`,`C mol^-1`),NC=XC(`firstRadiation`,`3.7417718521927573e-16`,`W m^2`),PC=XC(`loschmidt`,`2.686780111798444e25`,`m^-3`),FC=XC(`gasConstant`,`8.31446261815324`,`J K^-1 mol^-1`),IC=XC(`molarPlanckConstant`,`3.990312712893431e-10`,`J s mol^-1`),LC=XC(`molarVolume`,`0.022413969545014137`,`m^3 mol^-1`),RC=ZC(`sackurTetrode`,-1.16487052358),zC=XC(`secondRadiation`,`0.014387768775039337`,`m K`),BC=XC(`stefanBoltzmann`,`5.67037441918443e-8`,`W m^-2 K^-4`),VC=XC(`wienDisplacement`,`2.897771955e-3`,`m K`),HC=XC(`molarMass`,`0.99999999965e-3`,`kg mol^-1`),UC=XC(`molarMassC12`,`11.9999999958e-3`,`kg mol^-1`),WC=XC(`gravity`,`9.80665`,`m s^-2`),GC=XC(`planckLength`,`1.616255e-35`,`m`),KC=XC(`planckMass`,`2.176435e-8`,`kg`),qC=XC(`planckTime`,`5.391245e-44`,`s`),JC=XC(`planckCharge`,`1.87554603778e-18`,`C`),YC=XC(`planckTemperature`,`1.416785e+32`,`K`);function XC(e,t,n){return J(e,[`config`,`Unit`,`BigNumber`],e=>{var{config:r,Unit:i,BigNumber:a}=e,o=new i(r.number===`BigNumber`?new a(t):parseFloat(t),n);return o.fixPrefix=!0,o})}function ZC(e,t){return J(e,[`config`,`BigNumber`],e=>{var{config:n,BigNumber:r}=e;return n.number===`BigNumber`?new r(t):t})}function QC(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 $C(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?QC(Object(n),!0).forEach(function(t){Am(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):QC(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var ew=J(`mapSlices`,[`typed`,`isInteger`],e=>{var{typed:t,isInteger:n}=e,r=pd({typed:t,isInteger:n});return t(`mapSlices`,{"...any":function(e){var t=e[1];tr(t)?e[1]=t-1:nr(t)&&(e[1]=t.minus(1));try{return r.apply(null,e)}catch(e){throw Av(e)}}})},$C({isTransformFunction:!0},pd.meta)),tw=J(`column`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=Sp({typed:t,Index:n,matrix:r,range:i});return t(`column`,{"...any":function(e){var t=e.length-1,n=e[t];tr(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0});function nw(e,t,n){var r=e.filter(function(e){return Ur(e)&&!(e.name in t)&&!n.has(e.name)})[0];if(!r)throw Error(`No undefined variable found in inline expression "`+e+`"`);var i=r.name,a=new Map,o=new Xn(n,a,new Set([i])),s=e.compile();return function(e){return a.set(i,e),s.evaluate(o)}}var rw=J(`transformCallback`,[`typed`],e=>{var{typed:t}=e;return function(e,r){return t.isTypedFunction(e)?n(e,r):iw(e,e.length,r)};function n(e,r){var i=Object.fromEntries(Object.entries(e.signatures).map(e=>{var[i,a]=e,o=i.split(`,`).length;return t.isTypedFunction(a)?[i,n(a,r)]:[i,iw(a,o,r)]}));return typeof e.name==`string`?t(e.name,i):t(i)}});function iw(e,t,n){return t===n?e:t===n+1?function(){var t=[...arguments],r=t.slice(0,n),i=aw(t[n]);return e(...r,i)}:t>n+1?function(){var t=[...arguments],r=t.slice(0,n),i=aw(t[n]),a=t.slice(n+1);return e(...r,i,...a)}:e}function aw(e){return e.map(e=>e+1)}var ow=J(`filter`,[`typed`],e=>{var{typed:t}=e;function n(e,n,i){var a=kp({typed:t}),o=rw({typed:t});if(e.length===0)return a();var s=e[0];if(e.length===1)return a(s);var c=e.length-1,l=e[c];return s&&=r(s,i),l&&=Ur(l)||Pr(l)?r(l,i):nw(l,n,i),a(s,o(l,c))}n.rawArgs=!0;function r(e,t){return e.compile().evaluate(t)}return n},{isTransformFunction:!0}),sw=J(`forEach`,[`typed`],e=>{var{typed:t}=e,n=Pp({typed:t}),r=rw({typed:t});function i(e,t,i){if(e.length===0)return n();var o=e[0];if(e.length===1)return n(o);var s=e.length-1,c=e[s];return o&&=a(o,i),c&&=Ur(c)||Pr(c)?a(c,i):nw(c,t,i),n(o,r(c,s))}i.rawArgs=!0;function a(e,t){return e.compile().evaluate(t)}return i},{isTransformFunction:!0}),cw=J(`index`,[`Index`,`getMatrixDataType`],e=>{var{Index:t,getMatrixDataType:n}=e;return function(){for(var e=[],r=0,i=arguments.length;r<i;r++){var a=arguments[r];if(pr(a))a.start--,a.end-=a.step>0?0:2;else if(a&&a.isSet===!0)a=a.map(function(e){return e-1});else if(cr(a)||lr(a))n(a)!==`boolean`&&(a=a.map(function(e){return e-1}));else if(tr(a)||rr(a))a--;else if(nr(a))a=a.toNumber()-1;else if(typeof a!=`string`)throw TypeError(`Dimension must be an Array, Matrix, number, bigint, string, or Range`);e[r]=a}var o=new t;return t.apply(o,e),o}},{isTransformFunction:!0}),lw=J(`map`,[`typed`],e=>{var{typed:t}=e,n=Up({typed:t}),r=rw({typed:t});function i(e,t,i){if(e.length===0)return n();if(e.length===1)return n(e[0]);var a=e.length-1,o=e.slice(0,a),s=e[a];return o=o.map(e=>c(e,i)),s&&=Ur(s)||Pr(s)?c(s,i):nw(s,t,i),n(...o,r(s,a));function c(e,t){return e.compile().evaluate(t)}}return i.rawArgs=!0,i},{isTransformFunction:!0});function uw(e){return tr(e)?e-1:nr(e)?e.minus(1):e}function dw(e){return tr(e)||nr(e)}function fw(e){if(e.length===2&&ur(e[0])){e=e.slice();var t=e[1];dw(t)&&(e[1]=uw(t))}return e}var pw=J(`max`,[`typed`,`config`,`numeric`,`larger`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,larger:i,isNaN:a}=e,o=Ng({typed:t,config:n,numeric:r,larger:i,isNaN:a});return t(`max`,{"...any":function(e){e=fw(e);try{return o.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),mw=J(`mean`,[`typed`,`add`,`divide`],e=>{var{typed:t,add:n,divide:r}=e,i=ex({typed:t,add:n,divide:r});return t(`mean`,{"...any":function(e){e=fw(e);try{return i.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),hw=J(`min`,[`typed`,`config`,`numeric`,`smaller`,`isNaN`],e=>{var{typed:t,config:n,numeric:r,smaller:i,isNaN:a}=e,o=Fg({typed:t,config:n,numeric:r,smaller:i,isNaN:a});return t(`min`,{"...any":function(e){e=fw(e);try{return o.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),gw=J(`range`,[`typed`,`config`,`?matrix`,`?bignumber`,`equal`,`smaller`,`smallerEq`,`larger`,`largerEq`,`add`,`isZero`,`isPositive`],e=>{var{typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f}=e,p=Zp({typed:t,config:n,matrix:r,bignumber:i,equal:a,smaller:o,smallerEq:s,larger:c,largerEq:l,add:u,isZero:d,isPositive:f});return t(`range`,{"...any":function(e){return typeof e[e.length-1]!=`boolean`&&e.push(!0),p.apply(null,e)}})},{isTransformFunction:!0}),_w=J(`row`,[`typed`,`Index`,`matrix`,`range`],e=>{var{typed:t,Index:n,matrix:r,range:i}=e,a=om({typed:t,Index:n,matrix:r,range:i});return t(`row`,{"...any":function(e){var t=e.length-1,n=e[t];tr(n)&&(e[t]=n-1);try{return a.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),vw=J(`subset`,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=fm({typed:t,matrix:n,zeros:r,add:i});return t(`subset`,{"...any":function(e){try{return a.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),yw=J(`concat`,[`typed`,`matrix`,`isInteger`],e=>{var{typed:t,matrix:n,isInteger:r}=e,i=bp({typed:t,matrix:n,isInteger:r});return t(`concat`,{"...any":function(e){var t=e.length-1,n=e[t];tr(n)?e[t]=n-1:nr(n)&&(e[t]=n.minus(1));try{return i.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),bw=`diff`,xw=J(bw,[`typed`,`matrix`,`subtract`,`number`,`bignumber`],e=>{var{typed:t,matrix:n,subtract:r,number:i,bignumber:a}=e,o=Gp({typed:t,matrix:n,subtract:r,number:i,bignumber:a});return t(bw,{"...any":function(e){e=fw(e);try{return o.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),Sw=J(`std`,[`typed`,`map`,`sqrt`,`variance`],e=>{var{typed:t,map:n,sqrt:r,variance:i}=e,a=dx({typed:t,map:n,sqrt:r,variance:i});return t(`std`,{"...any":function(e){e=fw(e);try{return a.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),Cw=`sum`,ww=J(Cw,[`typed`,`config`,`add`,`numeric`],e=>{var{typed:t,config:n,add:r,numeric:i}=e,a=Xb({typed:t,config:n,add:r,numeric:i});return t(Cw,{"...any":function(e){e=fw(e);try{return a.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),Tw=J(`quantileSeq`,[`typed`,`bignumber`,`add`,`subtract`,`divide`,`multiply`,`partitionSelect`,`compare`,`isInteger`,`smaller`,`smallerEq`,`larger`,`mapSlices`],e=>{var{typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p}=e,m=lx({typed:t,bignumber:n,add:r,subtract:i,divide:a,multiply:o,partitionSelect:s,compare:c,isInteger:l,smaller:u,smallerEq:d,larger:f,mapSlices:p});return t(`quantileSeq`,{"Array | Matrix, number | BigNumber":m,"Array | Matrix, number | BigNumber, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, number | BigNumber, boolean":m,"Array | Matrix, number | BigNumber, boolean, number":(e,t,n,r)=>m(e,t,n,h(r)),"Array | Matrix, Array | Matrix":m,"Array | Matrix, Array | Matrix, number":(e,t,n)=>m(e,t,h(n)),"Array | Matrix, Array | Matrix, boolean":m,"Array | Matrix, Array | Matrix, boolean, number":(e,t,n,r)=>m(e,t,n,h(r))});function h(e){return fw([[],e])[1]}},{isTransformFunction:!0}),Ew=`cumsum`,Dw=J(Ew,[`typed`,`add`,`unaryPlus`],e=>{var{typed:t,add:n,unaryPlus:r}=e,i=Qb({typed:t,add:n,unaryPlus:r});return t(Ew,{"...any":function(e){if(e.length===2&&ur(e[0])){var t=e[1];tr(t)?e[1]=t-1:nr(t)&&(e[1]=t.minus(1))}try{return i.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),Ow=`variance`,kw=J(Ow,[`typed`,`add`,`subtract`,`multiply`,`divide`,`mapSlices`,`isNaN`],e=>{var{typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s}=e,c=sx({typed:t,add:n,subtract:r,multiply:i,divide:a,mapSlices:o,isNaN:s});return t(Ow,{"...any":function(e){e=fw(e);try{return c.apply(null,e)}catch(e){throw Av(e)}}})},{isTransformFunction:!0}),Aw=`print`,jw=J(Aw,[`typed`,`matrix`,`zeros`,`add`],e=>{var{typed:t,matrix:n,zeros:r,add:i}=e,a=rh({typed:t,matrix:n,zeros:r,add:i});return t(Aw,{"string, Object | Array":function(e,t){return a(o(e),t)},"string, Object | Array, number | Object":function(e,t,n){return a(o(e),t,n)}});function o(e){return e.replace(th,e=>`$`+e.slice(1).split(`.`).map(function(e){return!isNaN(e)&&e.length>0?parseInt(e)-1:e}).join(`.`))}},{isTransformFunction:!0}),Mw=J(`and`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=Yh({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);return!ur(r)&&!s(r,!0)?!1:s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),Nw=J(`or`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=gp({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!ur(r)&&o(r,!1)?!0:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),Pw=J(`nullish`,[`typed`,`matrix`,`size`,`flatten`,`deepEqual`],e=>{var{typed:t,matrix:n,size:r,flatten:i,deepEqual:a}=e,o=mp({typed:t,matrix:n,size:r,flatten:i,deepEqual:a});function s(e,t,n){var r=e[0].compile().evaluate(n);return!ur(r)&&r!=null&&r!==void 0?r:o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),Fw=J(`bitAnd`,[`typed`,`matrix`,`zeros`,`add`,`equalScalar`,`not`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o}=e,s=Yf({typed:t,matrix:n,equalScalar:r,zeros:i,not:a,concat:o});function c(e,t,n){var r=e[0].compile().evaluate(n);if(!ur(r)){if(isNaN(r))return NaN;if(r===0||r===!1)return 0}return s(r,e[1].compile().evaluate(n))}return c.rawArgs=!0,c},{isTransformFunction:!0}),Iw=J(`bitOr`,[`typed`,`matrix`,`equalScalar`,`DenseMatrix`,`concat`],e=>{var{typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a}=e,o=$f({typed:t,matrix:n,equalScalar:r,DenseMatrix:i,concat:a});function s(e,t,n){var r=e[0].compile().evaluate(n);if(!ur(r)){if(isNaN(r))return NaN;if(r===-1)return-1;if(r===!0)return 1}return o(r,e[1].compile().evaluate(n))}return s.rawArgs=!0,s},{isTransformFunction:!0}),Lw=`num`,Rw=J(Lw,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(Lw,{Fraction:e=>e.s*e.n,BigNumber:e=>{var t=n(e);return t.s*t.n},"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),zw=`den`,Bw=J(zw,[`typed`,`fraction`],e=>{var{typed:t,fraction:n}=e;return t(zw,{Fraction:e=>e.d,BigNumber:e=>n(e).d,"Array | Matrix":t.referToSelf(e=>t=>Dc(t,e))})}),Vw=ut({createAbs:()=>dd,createAccessorNode:()=>Nv,createAcos:()=>i_,createAcosh:()=>o_,createAcot:()=>c_,createAcoth:()=>u_,createAcsc:()=>f_,createAcsch:()=>m_,createAdd:()=>vv,createAddScalar:()=>_d,createAnd:()=>Yh,createAndTransform:()=>Mw,createArg:()=>ip,createArrayNode:()=>Fv,createAsec:()=>g_,createAsech:()=>v_,createAsin:()=>b_,createAsinh:()=>x_,createAssignmentNode:()=>Wv,createAtan:()=>S_,createAtan2:()=>w_,createAtanh:()=>E_,createAtomicMass:()=>kC,createAvogadro:()=>AC,createBellNumbers:()=>rS,createBernoulli:()=>hx,createBigNumberClass:()=>Io,createBigint:()=>Hu,createBignumber:()=>qu,createBin:()=>Xm,createBitAnd:()=>Yf,createBitAndTransform:()=>Fw,createBitNot:()=>Zf,createBitOr:()=>$f,createBitOrTransform:()=>Iw,createBitXor:()=>np,createBlockNode:()=>Kv,createBohrMagneton:()=>lC,createBohrRadius:()=>hC,createBoltzmann:()=>jC,createBoolean:()=>Ku,createCatalan:()=>aS,createCbrt:()=>xd,createCeil:()=>kd,createChain:()=>Tb,createChainClass:()=>cb,createClassicalElectronRadius:()=>gC,createClone:()=>Cc,createColumn:()=>Sp,createColumnTransform:()=>tw,createCombinations:()=>vx,createCombinationsWithRep:()=>xx,createCompare:()=>Zh,createCompareNatural:()=>tg,createCompareText:()=>ag,createCompile:()=>Ey,createComplex:()=>Ju,createComplexClass:()=>Go,createComposition:()=>sS,createConcat:()=>bp,createConcatTransform:()=>yw,createConditionalNode:()=>Jv,createConductanceQuantum:()=>uC,createConj:()=>op,createConstantNode:()=>iy,createCorr:()=>px,createCos:()=>k_,createCosh:()=>j_,createCot:()=>N_,createCoth:()=>F_,createCoulomb:()=>oC,createCoulombConstant:()=>sC,createCount:()=>wp,createCreateUnit:()=>n_,createCross:()=>Ep,createCsc:()=>L_,createCsch:()=>z_,createCtranspose:()=>bm,createCube:()=>jd,createCumSum:()=>Qb,createCumSumTransform:()=>Dw,createDeepEqual:()=>wg,createDen:()=>Bw,createDenseMatrixClass:()=>xc,createDerivative:()=>CS,createDet:()=>Db,createDeuteronMass:()=>SC,createDiag:()=>Op,createDiff:()=>Gp,createDiffTransform:()=>xw,createDistance:()=>qb,createDivide:()=>Gb,createDivideScalar:()=>ph,createDot:()=>wv,createDotDivide:()=>Ah,createDotMultiply:()=>zf,createDotPow:()=>Oh,createE:()=>BS,createEfimovFactor:()=>OC,createEigs:()=>Pb,createElectricConstant:()=>iC,createElectronMass:()=>_C,createElementaryCharge:()=>cC,createEqual:()=>sg,createEqualScalar:()=>Fu,createEqualText:()=>ug,createErf:()=>Pm,createEvaluate:()=>Oy,createExp:()=>Nd,createExpm:()=>Ib,createExpm1:()=>Fd,createFactorial:()=>Ox,createFalse:()=>PS,createFaraday:()=>MC,createFermiCoupling:()=>vC,createFft:()=>wm,createFibonacciHeapClass:()=>zg,createFilter:()=>kp,createFilterTransform:()=>ow,createFineStructure:()=>yC,createFirstRadiation:()=>NC,createFix:()=>zd,createFlatten:()=>Mp,createFloor:()=>Wd,createForEach:()=>Pp,createForEachTransform:()=>sw,createFormat:()=>Jm,createFraction:()=>Yu,createFractionClass:()=>ms,createFreqz:()=>kS,createFunctionAssignmentNode:()=>oy,createFunctionNode:()=>Sy,createGamma:()=>wx,createGasConstant:()=>FC,createGcd:()=>uf,createGetMatrixDataType:()=>Lp,createGravitationConstant:()=>eC,createGravity:()=>WC,createHartreeEnergy:()=>bC,createHasNumericValue:()=>yu,createHelp:()=>Cb,createHelpClass:()=>sb,createHex:()=>eh,createHypot:()=>bv,createI:()=>JS,createIdentity:()=>zp,createIfft:()=>Em,createIm:()=>cp,createImmutableDenseMatrixClass:()=>Ig,createIndex:()=>Dv,createIndexClass:()=>Lg,createIndexNode:()=>cy,createIndexTransform:()=>cw,createInfinity:()=>IS,createIntersect:()=>Jb,createInv:()=>kb,createInverseConductanceQuantum:()=>dC,createInvmod:()=>If,createIsBounded:()=>Du,createIsFinite:()=>ku,createIsInteger:()=>Mc,createIsNaN:()=>Tu,createIsNegative:()=>hu,createIsNumeric:()=>_u,createIsPositive:()=>xu,createIsPrime:()=>uh,createIsZero:()=>Cu,createKldivergence:()=>Ax,createKlitzing:()=>mC,createKron:()=>Vp,createLN10:()=>US,createLN2:()=>HS,createLOG10E:()=>GS,createLOG2E:()=>WS,createLarger:()=>vg,createLargerEq:()=>xg,createLcm:()=>pf,createLeafCount:()=>lS,createLeftShift:()=>Uh,createLgamma:()=>Ex,createLog:()=>Sh,createLog10:()=>vf,createLog1p:()=>wh,createLog2:()=>bf,createLoschmidt:()=>PC,createLsolve:()=>Nh,createLsolveAll:()=>Lh,createLup:()=>Py,createLusolve:()=>ib,createLyap:()=>Wb,createMad:()=>ix,createMagneticConstant:()=>rC,createMagneticFluxQuantum:()=>fC,createMap:()=>Up,createMapSlices:()=>pd,createMapSlicesTransform:()=>ew,createMapTransform:()=>lw,createMatrix:()=>Zu,createMatrixClass:()=>gs,createMatrixFromColumns:()=>rd,createMatrixFromFunction:()=>$u,createMatrixFromRows:()=>td,createMax:()=>Ng,createMaxTransform:()=>pw,createMean:()=>ex,createMeanTransform:()=>mw,createMedian:()=>nx,createMin:()=>Fg,createMinTransform:()=>hw,createMod:()=>$d,createMode:()=>Um,createMolarMass:()=>HC,createMolarMassC12:()=>UC,createMolarPlanckConstant:()=>IC,createMolarVolume:()=>LC,createMultinomial:()=>Mx,createMultiply:()=>Cf,createMultiplyScalar:()=>xf,createNaN:()=>LS,createNeutronMass:()=>CC,createNode:()=>kv,createNorm:()=>Sv,createNot:()=>fp,createNthRoot:()=>Tf,createNthRoots:()=>Eh,createNuclearMagneton:()=>pC,createNull:()=>FS,createNullish:()=>mp,createNullishTransform:()=>Pw,createNum:()=>Rw,createNumber:()=>Vu,createNumeric:()=>dh,createObjectNode:()=>uy,createOct:()=>Qm,createOnes:()=>Kp,createOperatorNode:()=>py,createOr:()=>gp,createOrTransform:()=>Nw,createParenthesisNode:()=>hy,createParse:()=>wy,createParser:()=>My,createParserClass:()=>ky,createPartitionSelect:()=>kg,createPermutations:()=>Px,createPhi:()=>VS,createPi:()=>RS,createPickRandom:()=>Jx,createPinv:()=>jb,createPlanckCharge:()=>JC,createPlanckConstant:()=>tC,createPlanckLength:()=>GC,createPlanckMass:()=>KC,createPlanckTemperature:()=>YC,createPlanckTime:()=>qC,createPolynomialRoot:()=>ob,createPow:()=>hh,createPrint:()=>rh,createPrintTransform:()=>jw,createProd:()=>Km,createProtonMass:()=>xC,createQr:()=>Iy,createQuantileSeq:()=>lx,createQuantileSeqTransform:()=>Tw,createQuantumOfCirculation:()=>wC,createRandom:()=>Zx,createRandomInt:()=>$x,createRange:()=>Zp,createRangeClass:()=>hs,createRangeNode:()=>_y,createRangeTransform:()=>gw,createRationalize:()=>TS,createRe:()=>up,createReducedPlanckConstant:()=>nC,createRelationalNode:()=>yy,createReplacer:()=>jS,createReshape:()=>$p,createResize:()=>em,createResolve:()=>yS,createResultSet:()=>Ji,createReviver:()=>AS,createRightArithShift:()=>Gh,createRightLogShift:()=>qh,createRotate:()=>nm,createRotationMatrix:()=>im,createRound:()=>vh,createRow:()=>om,createRowTransform:()=>_w,createRydberg:()=>TC,createSQRT1_2:()=>KS,createSQRT2:()=>qS,createSackurTetrode:()=>RC,createSchur:()=>Hb,createSec:()=>V_,createSech:()=>U_,createSecondRadiation:()=>zC,createSetCartesian:()=>Q_,createSetDifference:()=>ev,createSetDistinct:()=>nv,createSetIntersect:()=>iv,createSetIsSubset:()=>ov,createSetMultiplicity:()=>cv,createSetPowerset:()=>uv,createSetSize:()=>fv,createSetSymDifference:()=>mv,createSetUnion:()=>gv,createSign:()=>Df,createSimplify:()=>hS,createSimplifyConstant:()=>gS,createSimplifyCore:()=>vS,createSin:()=>G_,createSinh:()=>q_,createSize:()=>cm,createSlu:()=>tb,createSmaller:()=>fg,createSmallerEq:()=>hg,createSolveODE:()=>Nm,createSort:()=>jg,createSpaClass:()=>Bg,createSparse:()=>e_,createSparseMatrixClass:()=>Iu,createSpeedOfLight:()=>$S,createSplitUnit:()=>ad,createSqrt:()=>Of,createSqrtm:()=>Rb,createSquare:()=>Af,createSqueeze:()=>um,createStd:()=>dx,createStdTransform:()=>Sw,createStefanBoltzmann:()=>BC,createStirlingS2:()=>tS,createString:()=>Wu,createSubset:()=>fm,createSubsetTransform:()=>vw,createSubtract:()=>Mf,createSubtractScalar:()=>yd,createSum:()=>Xb,createSumTransform:()=>ww,createSylvester:()=>Bb,createSymbolNode:()=>by,createSymbolicEqual:()=>xS,createTan:()=>Y_,createTanh:()=>X_,createTau:()=>zS,createThomsonCrossSection:()=>EC,createTo:()=>oh,createToBest:()=>ch,createTrace:()=>Tv,createTranspose:()=>vm,createTrue:()=>NS,createTypeOf:()=>ju,createTyped:()=>Ui,createUnaryMinus:()=>sd,createUnaryPlus:()=>ld,createUnequal:()=>Eg,createUnitClass:()=>Xg,createUnitFunction:()=>Qg,createUppercaseE:()=>XS,createUppercasePi:()=>YS,createUsolve:()=>Fh,createUsolveAll:()=>zh,createVacuumImpedance:()=>aC,createVariance:()=>sx,createVarianceTransform:()=>kw,createVersion:()=>ZS,createWeakMixingAngle:()=>DC,createWienDisplacement:()=>VC,createXgcd:()=>Pf,createXor:()=>vp,createZeros:()=>Sm,createZeta:()=>Vm,createZpk2tf:()=>DS}),Hw=ft(lt(((e,t)=>{function n(){}n.prototype={on:function(e,t,n){var r=this.e||={};return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){var r=this;function i(){r.off(e,i),t.apply(n,arguments)}return i._=t,this.on(e,i,n)},emit:function(e){for(var t=[].slice.call(arguments,1),n=((this.e||={})[e]||[]).slice(),r=0,i=n.length;r<i;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||={},r=n[e],i=[];if(r&&t)for(var a=0,o=r.length;a<o;a++)r[a].fn!==t&&r[a].fn._!==t&&i.push(r[a]);return i.length?n[e]=i:delete n[e],this}},t.exports=n,t.exports.TinyEmitter=n}))(),1);function Uw(e){var t=new Hw.default;return e.on=t.on.bind(t),e.off=t.off.bind(t),e.once=t.once.bind(t),e.emit=t.emit.bind(t),e}function Ww(e,t,n,r){function i(e,t){var n=arguments.length;if(n!==1&&n!==2)throw new rf(`import`,n,1,2);t||={};function r(e,n,i){if(Array.isArray(n))n.forEach(t=>r(e,t));else if(xr(n)||d(n))for(var a in n)ei(n,a)&&r(e,n[a],a);else if(ci(n)||i!==void 0){var o=ci(n)?h(n)?n.fn+`.transform`:n.fn:i;if(ei(e,o)&&e[o]!==n&&!t.silent)throw Error(`Cannot import "`+o+`" twice`);e[o]=n}else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}var i={};for(var o in r(i,e),i)if(ei(i,o)){var s=i[o];if(ci(s))l(s,t);else if(u(s))a(o,s,t);else if(!t.silent)throw TypeError(`Factory, Object, or Array expected`)}}function a(t,i,a){if(a.wrap&&typeof i==`function`&&(i=c(i)),f(i)&&(i=e(t,{[i.signature]:i})),e.isTypedFunction(n[t])&&e.isTypedFunction(i)){i=a.override?e(t,i.signatures):e(n[t],i),n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}var s=n[t]!==void 0,l=n.Unit?.isValuelessUnit(t);if(!s&&!l||a.override){n[t]=i,delete r[t],o(t,i),n.emit(`import`,t,function(){return i});return}if(!a.silent)throw Error(`Cannot import "`+t+`": already exists`)}function o(e,t){t&&typeof t.transform==`function`?(n.expression.transform[e]=t.transform,p(e)&&(n.expression.mathWithTransform[e]=t.transform)):(delete n.expression.transform[e],p(e)&&(n.expression.mathWithTransform[e]=t))}function s(e){delete n.expression.transform[e],p(e)?n.expression.mathWithTransform[e]=n[e]:delete n.expression.mathWithTransform[e]}function c(e){var t=function(){for(var t=[],r=0,i=arguments.length;r<i;r++){var a=arguments[r];t[r]=a&&a.valueOf()}return e.apply(n,t)};return e.transform&&(t.transform=e.transform),t}function l(t,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:t.fn;if(a.includes(`.`))throw Error(`Factory name should not contain a nested path. Name: `+JSON.stringify(a));var o=h(t)?n.expression.transform:n,c=a in n.expression.transform,l=ei(o,a)?o[a]:void 0,u=function(){var r={};t.dependencies.map(di).forEach(e=>{if(e.includes(`.`))throw Error(`Factory dependency should not contain a nested path. Name: `+JSON.stringify(e));e===`math`?r.math=n:e===`mathWithTransform`?r.mathWithTransform=n.expression.mathWithTransform:e===`classes`?r.classes=n:r[e]=n[e]});var o=t(r);if(o&&typeof o.transform==`function`)throw Error(`Transforms cannot be attached to factory functions. Please create a separate function for it with export const path = "expression.transform"`);if(l===void 0||i.override)return o;if(e.isTypedFunction(l)&&e.isTypedFunction(o))return e(l,o);if(i.silent)return l;throw Error(`Cannot import "`+a+`": already exists`)},d=t.meta?.formerly??``,f=h(t)||m(t),p=n.expression.mathWithTransform;!t.meta||t.meta.lazy!==!1?($r(o,a,u),d&&$r(o,d,u),l&&c?(s(a),d&&s(d)):f&&($r(p,a,()=>o[a]),d&&$r(p,d,()=>o[a]))):(o[a]=u(),d&&(o[d]=o[a]),l&&c?(s(a),d&&s(d)):f&&($r(p,a,()=>o[a]),d&&$r(p,d,()=>o[a]))),r[a]=t,n.emit(`import`,a,u)}function u(e){return typeof e==`function`||typeof e==`number`||typeof e==`string`||typeof e==`boolean`||e===null||or(e)||ir(e)||nr(e)||ar(e)||lr(e)||Array.isArray(e)}function d(e){return typeof e==`object`&&e[Symbol.toStringTag]===`Module`}function f(e){return typeof e==`function`&&typeof e.signature==`string`}function p(e){return!ei(g,e)}function m(e){return!e.fn.includes(`.`)&&!ei(g,e.fn)&&(!e.meta||!e.meta.isClass)}function h(e){return e!==void 0&&e.meta!==void 0&&e.meta.isTransformFunction===!0||!1}var g={expression:!0,type:!0,docs:!0,error:!0,json:!0,chain:!0};return i}function Gw(e,t){var n=Rn({},zn,t);if(typeof Object.create!=`function`)throw Error(`ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.`);var r=Uw({isNumber:tr,isComplex:ir,isBigNumber:nr,isBigInt:rr,isFraction:ar,isUnit:or,isString:sr,isArray:cr,isMatrix:lr,isCollection:ur,isDenseMatrix:dr,isSparseMatrix:fr,isRange:pr,isIndex:mr,isBoolean:hr,isResultSet:gr,isHelp:_r,isFunction:vr,isDate:yr,isRegExp:br,isObject:xr,isMap:Sr,isPartitionedMap:Cr,isObjectWrappingMap:wr,isNull:Tr,isUndefined:Er,isAccessorNode:Dr,isArrayNode:Or,isAssignmentNode:kr,isBlockNode:Ar,isConditionalNode:jr,isConstantNode:Mr,isFunctionAssignmentNode:Pr,isFunctionNode:Fr,isIndexNode:Ir,isNode:Lr,isObjectNode:Rr,isOperatorNode:zr,isParenthesisNode:Br,isRangeNode:Vr,isRelationalNode:Hr,isSymbolNode:Ur,isChain:Wr});r.config=ai(n,r.emit),r.expression={transform:{},mathWithTransform:{config:r.config}};var i=[],a=[];function o(e){if(ci(e))return e(r);var t=e[Object.keys(e)[0]];if(ci(t))return t(r);if(!ti(e))throw console.warn("Factory object with properties `type`, `name`, and `factory` expected",e),Error("Factory object with properties `type`, `name`, and `factory` expected");var s=i.indexOf(e),c;return s===-1?(c=e.math===!0?e.factory(r.type,n,o,r.typed,r):e.factory(r.type,n,o,r.typed),i.push(e),a.push(c)):c=a[s],c}var s={};function c(){var e=[...arguments];return r.typed.apply(r.typed,e)}c.isTypedFunction=Vi.default.isTypedFunction;var l=Ww(c,o,r,s);return r.import=l,r.on(`config`,()=>{Object.values(s).forEach(e=>{e&&e.meta&&e.meta.recreateOnConfigChange&&l(e,{override:!0})})}),r.create=Gw.bind(null,e),r.factory=J,r.import(Object.values(Zr(e))),r.ArgumentsError=rf,r.DimensionError=Ms,r.IndexError=Ns,r}var Kw=[`import`,`createUnit`,`evaluate`,`parse`,`compile`,`simplify`,`derivative`,`resolve`],qw=new WeakMap;function Jw(e){let t=Gw(Vw,{matrix:`Array`,number:`number`});return e&&e(t),qw.set(t,t.parse),t.import(Object.fromEntries(Kw.map(e=>[e,function(){throw Error(`Function ${e} is disabled`)}])),{override:!0}),t}function Yw(e,t){let n=qw.get(e);if(!n)throw Error(`not a createMathInstance instance`);return n(t)}function Xw(e){e.import({if:function(e,t,n){return e?t:n},nullif:function(e,t){return t?null:e},clamp:function(e,t,n){return e<t?t:e>n?n:e}},{override:!0})}var Zw=[{name:`if`,signature:`if(cond, a, b)`,description:`cond ? a : b per row.`,isWindow:!1},{name:`nullif`,signature:`nullif(value, cond)`,description:`Returns null when cond is true, else value.`,isWindow:!1},{name:`clamp`,signature:`clamp(value, lo, hi)`,description:`Saturate value to [lo, hi].`,isWindow:!1},{name:`derivative`,signature:`derivative(y, x?)`,description:`Numeric dy/dx; central diff with edge fallbacks. x defaults to xKey.`,isWindow:!0},{name:`integral`,signature:`integral(y, x?)`,description:`Trapezoidal cumulative integral. Starts at 0.`,isWindow:!0},{name:`movavg`,signature:`movavg(y, n)`,description:`Centered simple moving average, window n.`,isWindow:!0},{name:`lag`,signature:`lag(y, n)`,description:`Shift forward n rows; first n become null.`,isWindow:!0},{name:`lead`,signature:`lead(y, n)`,description:`Shift backward n rows; last n become null.`,isWindow:!0},{name:`lowpass`,signature:`lowpass(y, fc, fs?)`,description:`Butterworth 2nd-order low-pass at cutoff fc Hz. fs inferred from xKey if omitted.`,isWindow:!0},{name:`highpass`,signature:`highpass(y, fc, fs?)`,description:`Butterworth 2nd-order high-pass at cutoff fc Hz.`,isWindow:!0},{name:`sin`,signature:`sin(x)`,description:`Sine, radians.`,isWindow:!1},{name:`cos`,signature:`cos(x)`,description:`Cosine, radians.`,isWindow:!1},{name:`tan`,signature:`tan(x)`,description:`Tangent, radians.`,isWindow:!1},{name:`asin`,signature:`asin(x)`,description:`Inverse sine.`,isWindow:!1},{name:`acos`,signature:`acos(x)`,description:`Inverse cosine.`,isWindow:!1},{name:`atan`,signature:`atan(x)`,description:`Inverse tangent.`,isWindow:!1},{name:`atan2`,signature:`atan2(y, x)`,description:`Two-argument inverse tangent.`,isWindow:!1},{name:`log`,signature:`log(x)`,description:`Natural logarithm.`,isWindow:!1},{name:`log10`,signature:`log10(x)`,description:`Base-10 logarithm.`,isWindow:!1},{name:`log2`,signature:`log2(x)`,description:`Base-2 logarithm.`,isWindow:!1},{name:`exp`,signature:`exp(x)`,description:`Euler's number raised to x.`,isWindow:!1},{name:`sqrt`,signature:`sqrt(x)`,description:`Square root.`,isWindow:!1},{name:`abs`,signature:`abs(x)`,description:`Absolute value.`,isWindow:!1},{name:`floor`,signature:`floor(x)`,description:`Round toward -Infinity.`,isWindow:!1},{name:`ceil`,signature:`ceil(x)`,description:`Round toward +Infinity.`,isWindow:!1},{name:`round`,signature:`round(x)`,description:`Round to nearest integer.`,isWindow:!1},{name:`sign`,signature:`sign(x)`,description:`-1, 0, or 1.`,isWindow:!1},{name:`min`,signature:`min(a, b, ...)`,description:`Minimum.`,isWindow:!1},{name:`max`,signature:`max(a, b, ...)`,description:`Maximum.`,isWindow:!1},{name:`mod`,signature:`mod(a, b)`,description:`a modulo b.`,isWindow:!1}];function Qw(){return Jw(Xw)}var $w=new Set([`add`,`subtract`,`multiply`,`divide`,`pow`,`mod`,`unaryMinus`,`unaryPlus`,`equal`,`unequal`,`smaller`,`larger`,`smallerEq`,`largerEq`,`xor`,`not`]),eT=new Set([`sin`,`cos`,`tan`,`asin`,`acos`,`atan`,`atan2`,`log`,`log10`,`log2`,`exp`,`sqrt`,`abs`,`floor`,`ceil`,`round`,`sign`,`mod`,`min`,`max`]),tT=new Set([`if`,`nullif`,`clamp`]),nT=class extends Error{};function rT(e,t,n){let r=e.expression.mathWithTransform,i=e.typed,a=[],o=e=>{let t=a.indexOf(e);return t<0&&(t=a.push(e)-1),`$${t}`},s=new Map,c=(e,t)=>{let n=s.get(e);return n||s.set(e,n=o(t())),n},l=(e,t)=>{try{return i.find(e,Array(t).fill(`number`).join(`,`),{exact:!0})}catch{return}},u=(t,n,r)=>{let i=n;return`${c(`${t}/${r.length}`,()=>{if(t===`min`||t===`max`){if(r.length!==2)return i;let n=l(e.isNaN,1),a=l(t===`max`?e.larger:e.smaller,2);return(e,t)=>typeof e==`number`&&typeof t==`number`?n(t)||a(t,e)?t:e:i(e,t)}let a=l(n,r.length);return a?r.length===1?e=>typeof e==`number`?a(e):i(e):r.length===2?(e,t)=>typeof e==`number`&&typeof t==`number`?a(e,t):i(e,t):i:i})}(${r.join(`, `)})`},d=new Map;n.forEach((e,t)=>d.set(e,t));let f=0,p=t=>{let n=t;switch(n.type){case`ConstantNode`:{let e=n.value;if(typeof e!=`number`&&typeof e!=`boolean`&&e!=null)throw new nT;return o(e)}case`SymbolNode`:{let e=d.get(n.name);if(e!==void 0)return`x${e}`;if(n.name===`pi`||n.name===`e`)return o(r[n.name]);throw new nT}case`ParenthesisNode`:return p(n.content);case`ConditionalNode`:{let t=`t${f++}`,r=c(`cond`,()=>{let t=Yw(e,`__c ? true : false`).compile();return e=>t.evaluate({__c:e})});return`((${t} = ${p(n.condition)}, typeof ${t} === 'number' || typeof ${t} === 'boolean' || ${t} === null ? ${t} : ${r}(${t})) ? ${p(n.trueExpr)} : ${p(n.falseExpr)})`}case`OperatorNode`:{let t=n.fn,i=n.args.map(p);if((t===`and`||t===`or`)&&i.length===2){let n=`t${f++}`,r=(n,r)=>u(t,e[t],[n,r]);return t===`and`?`(${n} = ${i[0]}, !${r(n,`true`)} ? false : ${r(n,i[1])})`:`(${n} = ${i[0]}, ${r(n,`false`)} ? true : ${r(n,i[1])})`}if(!$w.has(t))throw new nT;return u(t,r[t],i)}case`FunctionNode`:{let e=n.fn;if(n.optional||e.type!==`SymbolNode`)throw new nT;let t=e.name;if(d.has(t))throw new nT;let i=n.args.map(p);if(tT.has(t))return`${o(r[t])}(${i.join(`, `)})`;if(!eT.has(t))throw new nT;return u(t,r[t],i)}default:throw new nT}},m;try{m=p(t)}catch(e){if(e instanceof nT)return null;throw e}let h=n.map((e,t)=>t),g=h.map(e=>`let x${e} = c${e}[i]`).join(`; `),_=h.length?`if (!(${h.map(e=>`x${e} - x${e} === 0`).join(` && `)})) { out[i] = NaN; continue }`:``,v=`
49
+ ${a.map((e,t)=>`const $${t} = env[${t}];`).join(`
50
+ `)}
51
+ return function kernel(out, cols, n) {
52
+ ${h.map(e=>`const c${e} = cols[${e}];`).join(` `)}
53
+ let r${Array.from({length:f},(e,t)=>`, t${t}`).join(``)}
54
+ for (let i = 0; i < n; i++) {
55
+ ${g}
56
+ ${_}
57
+ r = ${m}
58
+ // As the scalar path stores results: null, finite numbers, booleans as 1/0, anything else null.
59
+ out[i] = r === null || r === undefined ? NaN
60
+ : typeof r === 'number' ? (r - r === 0 ? r : NaN)
61
+ : typeof r === 'boolean' ? (r ? 1 : 0) : NaN
62
+ }
63
+ }`;try{return Function(`env`,v)(a)}catch{return null}}function iT(e,t){let n=e.length,r=Array(n);for(let i=0;i<n;i++){if(e[i]===null){r[i]=null;continue}if(i===0){let n=lT(t[1],t[0]),a=lT(e[1],e[0]);r[i]=n===null||a===null||n===0?null:a/n}else if(i===n-1){let n=lT(t[i],t[i-1]),a=lT(e[i],e[i-1]);r[i]=n===null||a===null||n===0?null:a/n}else{let n=lT(t[i+1],t[i-1]),a=lT(e[i+1],e[i-1]);r[i]=n===null||a===null||n===0?null:a/n}}return r}function aT(e,t){let n=e.length,r=Array(n),i=0;r[0]=0;for(let a=1;a<n;a++){let n=e[a-1],o=e[a],s=t[a-1],c=t[a];if(n===null||o===null||s===null||c===null){r[a]=null;continue}i+=(n+o)/2*(c-s),r[a]=i}return r}function oT(e,t){let n=Math.floor(Math.max(1,Math.floor(t))/2),r=Array(e.length);for(let t=0;t<e.length;t++){let i=0,a=0,o=Math.max(0,t-n),s=Math.min(e.length-1,t+n);for(let t=o;t<=s;t++){let n=e[t];n!==null&&Number.isFinite(n)&&(i+=n,a++)}r[t]=a===0?null:i/a}return r}function sT(e,t){let n=Math.max(0,Math.floor(t)),r=Array(e.length);for(let t=0;t<e.length;t++)r[t]=t<n?null:e[t-n];return r}function cT(e,t){let n=Math.max(0,Math.floor(t)),r=Array(e.length);for(let t=0;t<e.length;t++)r[t]=t+n>=e.length?null:e[t+n];return r}function lT(e,t){return e===null||t===null||!Number.isFinite(e)||!Number.isFinite(t)?null:e-t}function uT(e,t){let n=e.length,r=new Float64Array(n);for(let i=0;i<n;i++){if(e[i]!==e[i]){r[i]=NaN;continue}let a=i===n-1?i:i+1,o=i===0?0:i-1,s=t[a]-t[o],c=e[a]-e[o];if(s!==s||c!==c||s===0){r[i]=NaN;continue}let l=c/s;if(l!==l)return null;r[i]=l}return r}function dT(e,t){let n=e.length,r=new Float64Array(n),i=0;for(let a=1;a<n;a++){let n=e[a-1],o=e[a],s=t[a-1],c=t[a];if(n!==n||o!==o||s!==s||c!==c){r[a]=NaN;continue}if(i+=(n+o)/2*(c-s),i!==i)return null;r[a]=i}return r}function fT(e,t){let n=Math.floor(Math.max(1,Math.floor(t))/2),r=new Float64Array(e.length);for(let t=0;t<e.length;t++){let i=0,a=0,o=Math.max(0,t-n),s=Math.min(e.length-1,t+n);for(let t=o;t<=s;t++){let n=e[t];n===n&&(i+=n,a++)}if(a===0){r[t]=NaN;continue}let c=i/a;if(c!==c)return null;r[t]=c}return r}function pT(e,t){let n=Math.max(0,Math.floor(t)),r=new Float64Array(e.length);for(let t=0;t<e.length;t++)r[t]=t<n?NaN:e[t-n];return r}function mT(e,t){let n=Math.max(0,Math.floor(t)),r=new Float64Array(e.length);for(let t=0;t<e.length;t++)r[t]=t+n>=e.length?NaN:e[t+n];return r}function hT(e){let t=[];for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];if(r===null||i===null)continue;let a=i-r;Number.isFinite(a)&&a>0&&t.push(a)}if(t.length===0)return NaN;t.sort((e,t)=>e-t);let n=Math.floor(t.length/2);return 1/(t.length%2?t[n]:(t[n-1]+t[n])/2)}function gT(e,t,n){if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0||e>=t/2)return null;let r=2*Math.PI*e/t,i=Math.cos(r),a=Math.sin(r)/(2*Math.SQRT1_2),o=1+a;return n===`low`?{b0:(1-i)/2/o,b1:(1-i)/o,b2:(1-i)/2/o,a1:-2*i/o,a2:(1-a)/o}:{b0:(1+i)/2/o,b1:-(1+i)/o,b2:(1+i)/2/o,a1:-2*i/o,a2:(1-a)/o}}function _T(e,t){let n=Array(e.length),r=0,i=0,a=0,o=0;for(let s=0;s<e.length;s++){let c=e[s];if(c===null||!Number.isFinite(c)){n[s]=null,r=0,i=0,a=0,o=0;continue}let l=t.b0*c+t.b1*r+t.b2*i-t.a1*a-t.a2*o;n[s]=l,i=r,r=c,o=a,a=l}return n}function vT(e,t,n){return!Number.isFinite(t)||t<=0?`${e}: cutoff frequency must be a positive number, got fc=${t}`:!Number.isFinite(n)||n<=0?`${e}: could not infer a valid sample rate from the time axis (got fs=${n}). Specify it explicitly as a third argument: ${e}(y, fc, fs)`:t>=n/2?`${e}: cutoff fc=${t} Hz must be below Nyquist fs/2=${(n/2).toFixed(3)} Hz. Inferred sample rate fs=${n.toFixed(3)} Hz from the current x-axis — pass an explicit fs as third arg: ${e}(y, fc, fs).`:`${e}: invalid filter parameters (fc=${t}, fs=${n})`}function yT(e,t,n){let r=gT(t,n,`low`);if(!r)throw Error(vT(`lowpass`,t,n));return _T(e,r)}function bT(e,t,n){let r=gT(t,n,`high`);if(!r)throw Error(vT(`highpass`,t,n));return _T(e,r)}function xT(e,t){let n=new Float64Array(e.length),r=0,i=0,a=0,o=0;for(let s=0;s<e.length;s++){let c=e[s];if(c!==c){n[s]=NaN,r=0,i=0,a=0,o=0;continue}let l=t.b0*c+t.b1*r+t.b2*i-t.a1*a-t.a2*o;if(l!==l)return null;n[s]=l,i=r,r=c,o=a,a=l}return n}function ST(e,t,n){let r=gT(t,n,`low`);if(!r)throw Error(vT(`lowpass`,t,n));return xT(e,r)}function CT(e,t,n){let r=gT(t,n,`high`);if(!r)throw Error(vT(`highpass`,t,n));return xT(e,r)}var wT=Qw(),TT=new Map;function ET(e){let t=TT.get(e);if(t)return t;try{let t={ok:!0,node:Yw(wT,e)};return TT.set(e,t),t}catch(t){let n={ok:!1,message:`parse error: ${t instanceof Error?t.message:`unknown error`}`};return TT.set(e,n),n}}var DT=[`derivative`,`integral`,`movavg`,`lag`,`lead`,`lowpass`,`highpass`],OT=new Set([`pi`,`e`,`true`,`false`,`null`]);function kT(e){return ET(e)}function AT(e){let t=e,n=new Set,r=new Set;t.traverse(e=>{if(e.type===`FunctionNode`){let t=e,n=t.fn?.name??t.name;typeof n==`string`&&r.add(n)}else if(e.type===`SymbolNode`){let t=e.name;typeof t==`string`&&!OT.has(t)&&n.add(t)}});for(let e of r)n.delete(e);return{identifiers:[...n],functions:[...r]}}var jT=Qw();function MT(e,t,n,r){let{rows:i}=t,a=new Set(t.columnNames),o=P(i),{values:s,compiled:c,...l}=IT(e,e=>{if(!a.has(e))return;let t=o&&p(o,e);if(t)return t;let n=new Float64Array(i.length);for(let t=0;t<i.length;t++){let r=i[t][e];n[t]=typeof r==`number`?r:NaN}return n},n,i.length,r),u=Array(s.length);for(let e=0;e<s.length;e++)u[e]=s[e]===s[e]?s[e]:null;return{...l,values:u}}var NT=!0,PT=new Map;function FT(e,t,n){if(!NT)return null;let r=PT.get(e);return r===void 0&&PT.set(e,r=rT(jT,t,n)),r}function IT(e,t,n,r,i,a){let o={channelId:e.id},s=new Float64Array;if(!e.enabled)return{...o,status:`disabled`,values:s};let c=ET(e.formula);if(!c.ok)return{...o,status:`parse-error`,values:s,message:c.message};let{identifiers:l,functions:u}=AT(c.node),d=new Set(i.filter(t=>t.id!==e.id).map(e=>e.name));for(let t of l)if(d.has(t))return{...o,status:`references-channel`,values:s,message:`Channel "${e.name}" references another channel "${t}". This is not allowed in V1.`};let f=l.map(t),p=l.filter((e,t)=>!f[t]);if(p.length>0)return{...o,status:`missing-inputs`,values:s,missingCols:p};if(u.some(e=>DT.includes(e))){let i=n?t(n):void 0;return GT(e,c.node,l,f,i,r,a)}let m=new Float64Array(r);try{let t=FT(`s${e.formula}`,c.node,l);if(t)return t(m,f,r),{...o,status:`ok`,values:m,compiled:!0};let n=c.node.compile(),i={};for(let e=0;e<r;e++){let t=!1;for(let n=0;n<l.length;n++){let r=f[n][e];if(r-r===0)i[l[n]]=r;else{t=!0;break}}m[e]=t?NaN:LT(n.evaluate(i))}return{...o,status:`ok`,values:m}}catch(e){return{...o,status:`runtime-error`,values:s,message:e instanceof Error?e.message:`runtime error`}}}function LT(e){return e==null?NaN:typeof e==`number`?Number.isFinite(e)?e:NaN:typeof e==`boolean`?+!!e:NaN}function RT(e){let t=new Float64Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]-e[n]===0?e[n]:NaN;return t}var zT=e=>Array.from(e,e=>e===e?e:null),BT={derivative:iT,integral:aT,movavg:oT,lag:sT,lead:cT,lowpass:yT,highpass:bT},VT={derivative:uT,integral:dT,movavg:fT,lag:pT,lead:mT,lowpass:ST,highpass:CT};function HT(e,t){return Array.isArray(e)?e.map(e=>e===null?null:e+t):e.map(e=>e+t)}function UT(e,t,n,r,i){let a=0,o=0,s=Object.create(null),c=null,l=!1,u=e.transform(e=>{if(c||l||e.type!==`FunctionNode`)return e;let u=e,d=u.fn?.name??u.name;if(typeof d!=`string`||![`derivative`,`integral`,`movavg`,`lag`,`lead`,`lowpass`,`highpass`].includes(d))return e;let f=u.args??[];try{if(f.length===0)throw Error(`${d}(): missing first argument`);let c=f[0];if(c.type!==`SymbolNode`)throw Error(`${d}() expects a column name as its first argument`);let u=c.name,p=t[u];if(!p)throw Error(`${d}(): column "${u}" not available`);let m;if(d===`derivative`||d===`integral`){let e=f[1],a=e?.type===`SymbolNode`?t[e.name]??n:n;if(m=d===`derivative`?r.derivative(p,a):r.integral(p,a),d===`integral`&&m&&i){let e=o++,t=i.start(e);t&&(m=HT(m,t)),i.done(e,m)}}else if(d===`movavg`||d===`lag`||d===`lead`){let e=f[1];if(!e)throw Error(`${d}(y, n) requires a second argument`);let t=e.compile().evaluate({});if(!Number.isFinite(t))throw Error(`${d}(): n must be a finite number`);m=d===`movavg`?r.movavg(p,t):d===`lag`?r.lag(p,t):r.lead(p,t)}else{let e=f[1];if(!e)throw Error(`${d}(y, fc, fs?) requires a cutoff frequency`);let t=e.compile().evaluate({}),i=f[2],a=i?i.compile().evaluate({}):hT(n);m=d===`lowpass`?r.lowpass(p,t,a):r.highpass(p,t,a)}if(!m)return l=!0,e;let h=`__w${a++}`;return s[h]=m,new jT.SymbolNode(h)}catch(t){return c=t instanceof Error?t:Error(String(t)),e}});return c?{error:c.message}:l?null:{node:u,synthetic:s}}function WT(e,t){let n=new Set(AT(e).identifiers);return t.filter(e=>n.has(e))}function GT(e,t,n,r,i,a,o){let s={channelId:e.id},c=e=>({...s,status:`runtime-error`,values:new Float64Array,message:e}),l=Object.create(null);n.forEach((e,t)=>{l[e]=RT(r[t])});let u=i?RT(i):Float64Array.from({length:a},(e,t)=>t),d=new Float64Array(a);if(NT){let r=UT(t,l,u,VT,o);if(r&&`error`in r)return c(r.error);if(r){let t=Object.keys(r.synthetic),i=WT(r.node,n),o=FT(`w${e.formula}`,r.node,[...i,...t]);if(o)try{return o(d,[...i.map(e=>l[e]),...t.map(e=>r.synthetic[e])],a),{...s,status:`ok`,values:d,compiled:!0}}catch(e){return c(e instanceof Error?e.message:`runtime error`)}}}let f=Object.create(null);for(let e of n)f[e]=zT(l[e]);let p=UT(t,f,zT(u),BT,o);if(`error`in p)return c(p.error);let{synthetic:m}=p,h=p.node.compile(),g={};try{let e=[...WT(p.node,n).map(e=>[e,f[e]]),...Object.keys(m).map(e=>[e,m[e]])];rows:for(let t=0;t<a;t++){for(let[n,r]of e){let e=r[t];if(e===null||!Number.isFinite(e)){d[t]=NaN;continue rows}g[n]=e}d[t]=LT(h.evaluate(g))}return{...s,status:`ok`,values:d}}catch(e){return c(e instanceof Error?e.message:`runtime error`)}}function KT(e,t,n){let r={};for(let i of e)r[i.id]=MT(i,t,n,e);return r}var qT=new WeakMap;function JT(e,t,n,r,i){let a=qT.get(e);a||qT.set(e,a=new Map);let o=[i,...t.map(e=>e.id)].join(`
64
+ `),s=a.get(o);s||(a.size>=4&&a.delete(a.keys().next().value),s={rows:e.map(e=>Object.create(e)),written:new Set},a.set(o,s));let c=new Set(n.map(e=>e.name)),l=[...s.written].filter(e=>!c.has(e));for(let t=0;t<e.length;t++){let e=s.rows[t];for(let t of l)delete e[t];for(let i of n)e[i.name]=r[i.id].values[t]}return s.written=c,s.rows.slice()}var YT=new WeakMap;function XT(e,t,n){let r=YT.get(e.rows);if(r&&r.channels===t&&r.xKey===n)return r.result;let i=KT(t,e,n),a=t.filter(e=>i[e.id]?.status===`ok`),o={rows:a.length===0?e.rows:JT(e.rows,t,a,i,n),ok:a};return YT.set(e.rows,{channels:t,xKey:n,result:o}),o}function ZT(e,t,n){if(e.length===0)return[];let r=JSON.stringify(t);return e.filter(e=>e.name===n||r.includes(`"${e.name}"`))}function QT(e){let t=e.filter(e=>e.source===`personal`&&e.projectId===null),n={version:1,exportedAt:new Date().toISOString(),channels:t.map(e=>({name:e.name,units:e.units,formula:e.formula,enabled:e.enabled,...e.description===void 0?{}:{description:e.description}}))};return new Blob([JSON.stringify(n,null,2)],{type:`application/json`})}function $T(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 eE(e){let t=await $T(e),n;try{n=JSON.parse(t)}catch{return{channels:[],errors:[`Not a valid JSON file.`]}}if(!n||typeof n!=`object`||n.version!==1||!Array.isArray(n.channels))return{channels:[],errors:[`Unrecognized format. Is this a Kymoscope export (version 1)?`]};let r=[],i=[];return n.channels.forEach((e,t)=>{let n=e;if(typeof n.name!=`string`||typeof n.units!=`string`||typeof n.formula!=`string`){i.push(`Channel #${t+1} skipped: missing name/units/formula.`);return}r.push(Ln({name:n.name,units:n.units,formula:n.formula,enabled:typeof n.enabled==`boolean`?n.enabled:!0,description:typeof n.description==`string`?n.description:void 0,source:`personal`,sharedWithOrgId:null,ownerUserId:``}))}),{channels:r,errors:i}}var tE=class extends Error{code;detail;constructor(e,t){super(e),this.name=`KymoscopeError`,this.code=e,this.detail=t}};function nE(e){let t=new URL(e,location.href);if(t.origin===location.origin)return new Worker(t,{type:`module`});let n=URL.createObjectURL(new Blob([`import ${JSON.stringify(t.href)};`],{type:`text/javascript`}));try{return new Worker(n,{type:`module`})}finally{URL.revokeObjectURL(n)}}var rE=``+new URL(`assets/parseDataset.worker-PynRsPD8.js`,import.meta.url).href;function iE(){return nE(rE)}function aE(e,t=iE,n){return new Promise((r,i)=>{if(n?.aborted){i(new tE(`cancelled`));return}let a=t(),o=()=>{a.terminate(),i(new tE(`cancelled`))};n?.addEventListener(`abort`,o,{once:!0}),a.onmessage=e=>{if(n?.removeEventListener(`abort`,o),a.terminate(),e.data.ok){let{table:t,...n}=e.data.data;r({...n,rows:R(t)})}else i(Error(e.data.error))},a.onerror=e=>{n?.removeEventListener(`abort`,o),a.terminate(),i(e instanceof Error?e:Error(`Worker failed to parse the dataset.`))},a.postMessage(e)})}async function oE(e,t){if(typeof Worker<`u`)return aE(e,iE,t);let{table:n,...r}=He(`file`in e?await e.file.text():e.rawText,e.config);return{...r,rows:R(n)}}var sE=n(new WeakMap);function cE(e){let t=sE.get(e);if(t===void 0){t=!0;for(let n=0;n<e.length;n++)if(!(e[n]>=(n>0?e[n-1]:-1/0))){t=!1;break}sE.set(e,t)}return t}var lE=class{#e;constructor(e){this.#e=e}async getSchema(){let{columnNames:e,units:t,rows:n}=this.#e;return e.map((e,r)=>({name:e,type:x(n,e)?`number`:`string`,unit:t[r]??``}))}async getSeries(e){let{rows:t}=this.#e,n=P(t);if(n){let r=p(n,e.viewport.xKey),i=p(n,e.column),a=new Float64Array(t.length),o=new Float64Array(t.length),c=0;if(r&&i)for(let e=0;e<r.length;e++)r[e]===r[e]&&i[e]===i[e]&&(a[c]=r[e],o[c]=i[e],c++);return s(a.subarray(0,c),o.subarray(0,c),e.viewport.x0,e.viewport.x1,e.maxPoints)}let r=new Float64Array(t.length),i=new Float64Array(t.length),a=0;for(let n of t){let t=n[e.viewport.xKey],o=n[e.column];typeof t==`number`&&typeof o==`number`&&(r[a]=t,i[a]=o,a++)}return s(r.subarray(0,a),i.subarray(0,a),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.rows,i=new Set(this.#e.columnNames),a=i.has(t.xKey)?e.filter(e=>i.has(e)):[];if(a.length===0)return{x0:t.x0,bucket:0,rows:[],columns:a};let o=P(r),s=o&&p(o,t.xKey),c=o?a.map(e=>p(o,e)):[];if(s&&c.every(e=>e))return T(s,c,a,t.x0,t.x1,n);let l=new Float64Array(r.length),u=a.map(()=>new Float64Array(r.length));for(let e=0;e<r.length;e++){let n=r[e][t.xKey];l[e]=typeof n==`number`?n:NaN;for(let t=0;t<a.length;t++){let n=r[e][a[t]];u[t][e]=typeof n==`number`?n:NaN}}return T(l,u,a,t.x0,t.x1,n)}getColumnsSync(e,t,n){let r=P(this.#e.rows),i=r&&p(r,t.xKey);if(!r||!i)return null;let a=e.filter(e=>p(r,e));return a.length===0?null:_e(i,a.map(e=>p(r,e)),a,t.x0,t.x1,n)}async xBounds(e){return this.xBoundsSync(e)}xBoundsSync(e){let{rows:t}=this.#e,n=P(t),r=n&&p(n,e),i=1/0,a=-1/0;if(r&&r.length>0&&cE(r))i=r[0],a=r[r.length-1];else if(r)for(let e=0;e<r.length;e++){let t=r[e];t<i&&(i=t),t>a&&(a=t)}else for(let n of t){let t=n[e];typeof t==`number`&&(t<i&&(i=t),t>a&&(a=t))}return i<=a?{x0:i,x1:a}:{x0:0,x1:0}}async dispose(){}};function uE(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function dE(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function fE(e){return this instanceof fE?(this.v=e,this):new fE(e)}function pE(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof fE?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function mE(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:fE(e[r](t)),done:!1}:i?i(t):t}:i}}function hE(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof dE==`function`?dE(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}var gE=new TextDecoder(`utf-8`),_E=e=>gE.decode(e),vE=new TextEncoder,yE=e=>vE.encode(e),bE=e=>typeof e==`number`,xE=e=>typeof e==`boolean`,SE=e=>typeof e==`function`,CE=e=>e!=null&&Object(e)===e,wE=e=>CE(e)&&SE(e.then),TE=e=>CE(e)&&SE(e[Symbol.iterator]),EE=e=>CE(e)&&SE(e[Symbol.asyncIterator]),DE=e=>CE(e)&&CE(e.schema),OE=e=>CE(e)&&`done`in e&&`value`in e,kE=e=>CE(e)&&SE(e.stat)&&bE(e.fd),AE=e=>CE(e)&&NE(e.body),jE=e=>`_getDOMStream`in e&&`_getNodeStream`in e,ME=e=>CE(e)&&SE(e.abort)&&SE(e.getWriter)&&!jE(e),NE=e=>CE(e)&&SE(e.cancel)&&SE(e.getReader)&&!jE(e),PE=e=>CE(e)&&SE(e.end)&&SE(e.write)&&xE(e.writable)&&!jE(e),FE=e=>CE(e)&&SE(e.read)&&SE(e.pipe)&&xE(e.readable)&&!jE(e),IE=e=>CE(e)&&SE(e.clear)&&SE(e.bytes)&&SE(e.position)&&SE(e.setPosition)&&SE(e.capacity)&&SE(e.getBufferIdentifier)&&SE(e.createLong),LE=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function RE(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++c<u;){if(o=t[l],s=e[c],!o||!s||o.buffer!==s.buffer||s.byteOffset<o.byteOffset){s&&(t[++l]=s);continue}if({byteOffset:n,byteLength:i}=o,{byteOffset:r,byteLength:a}=s,n+i<r||r+a<n){s&&(t[++l]=s);continue}t[l]=new Uint8Array(o.buffer,n,r-n+a)}return t}function zE(e,t,n=0,r=t.byteLength){let i=e.byteLength,a=new Uint8Array(e.buffer,e.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return a.set(o,n),e}function BE(e,t){let n=RE(e),r=n.reduce((e,t)=>e+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++c<e;){if(i=n[c],a=i.subarray(0,Math.min(i.length,l-s)),l<=s+a.length){a.length<i.length?n[c]=i.subarray(a.length):a.length===i.length&&c++,o?zE(o,a,s):o=a;break}zE(o||=new Uint8Array(l),a,s),s+=a.length}return[o||new Uint8Array,n.slice(c),r-(o?o.byteLength:0)]}function VE(e,t){let n=OE(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n==`string`&&(n=yE(n)),n instanceof ArrayBuffer||n instanceof LE?new e(n):IE(n)?VE(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}var HE=e=>VE(Int32Array,e),UE=e=>VE(BigInt64Array,e),WE=e=>VE(Uint8Array,e),GE=e=>(e.next(),e);function*KE(e,t){let n=function*(e){yield e};return yield*GE((function*(t){let n=null;do n=t.next(yield VE(e,n));while(!n.done)})((typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof LE?n(t):TE(t)?t:n(t))[Symbol.iterator]())),new e}var qE=e=>KE(Uint8Array,e);function JE(e,t){return pE(this,arguments,function*(){if(wE(t))return yield fE(yield fE(yield*mE(hE(JE(e,yield fE(t))))));let n=function(e){return pE(this,arguments,function*(){yield yield fE(yield fE(e))})};return yield fE(yield*mE(hE(GE((function(t){return pE(this,arguments,function*(){let n=null;do n=yield fE(t.next(yield yield fE(VE(e,n))));while(!n.done)})})((typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof LE?n(t):TE(t)?function(e){return pE(this,arguments,function*(){yield fE(yield*mE(hE(GE((function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)})(e[Symbol.iterator]())))))})}(t):EE(t)?t:n(t))[Symbol.asyncIterator]()))))),yield fE(new e)})}var YE=e=>JE(Uint8Array,e);function XE(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t<r;)n[t]+=e}return n.subarray(0,t)}function ZE(e,t){let n=0,r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}var QE={fromIterable(e){return $E(eD(e))},fromAsyncIterable(e){return $E(tD(e))},fromDOMStream(e){return $E(nD(e))},fromNodeStream(e){return $E(aD(e))},toDOMStream(e,t){throw Error(`"toDOMStream" not available in this environment`)},toNodeStream(e,t){throw Error(`"toNodeStream" not available in this environment`)}},$E=e=>(e.next(),e);function*eD(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?BE(r,o)[0]:([i,r,s]=BE(r,o),i)}({cmd:a,size:o}=(yield null)||{cmd:`read`,size:0});let l=qE(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?l.next():l.next(o-s),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield c());while(o<s);while(!t)}catch(e){(n=!0)&&typeof l.throw==`function`&&l.throw(e)}finally{n===!1&&typeof l.return==`function`&&l.return(null)}return null}function tD(e){return pE(this,arguments,function*(){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?BE(r,o)[0]:([i,r,s]=BE(r,o),i)}({cmd:a,size:o}=(yield yield fE(null))||{cmd:`read`,size:0});let l=YE(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?yield fE(l.next()):yield fE(l.next(o-s)),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield fE(c()));while(o<s);while(!t)}catch(e){(n=!0)&&typeof l.throw==`function`&&(yield fE(l.throw(e)))}finally{n===!1&&typeof l.return==`function`&&(yield fE(l.return(new Uint8Array)))}return yield fE(null)})}function nD(e){return pE(this,arguments,function*(){let t=!1,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?BE(r,o)[0]:([i,r,s]=BE(r,o),i)}({cmd:a,size:o}=(yield yield fE(null))||{cmd:`read`,size:0});let l=new rD(e);try{do if({done:t,value:i}=Number.isNaN(o-s)?yield fE(l.read()):yield fE(l.read(o-s)),!t&&i.byteLength>0&&(r.push(WE(i)),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield yield fE(c()));while(o<s);while(!t)}catch(e){(n=!0)&&(yield fE(l.cancel(e)))}finally{n===!1?yield fE(l.cancel()):e.locked&&l.releaseLock()}return yield fE(null)})}var rD=class{constructor(e){this.source=e,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return uE(this,void 0,void 0,function*(){let{reader:t,source:n}=this;t&&(yield t.cancel(e).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(e){return uE(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array};let t=yield this.reader.read();return!t.done&&(t.value=WE(t)),t})}},iD=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function aD(e){return pE(this,arguments,function*(){let t=[],n=`error`,r=!1,i=null,a,o,s=0,c=[],l;function u(){return a===`peek`?BE(c,o)[0]:([l,c,s]=BE(c,o),l)}if({cmd:a,size:o}=(yield yield fE(null))||{cmd:`read`,size:0},e.isTTY)return yield yield fE(new Uint8Array),yield fE(null);try{t[0]=iD(e,`end`),t[1]=iD(e,`error`);do{if(t[2]=iD(e,`readable`),[n,i]=yield fE(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((r=n===`end`)||(Number.isFinite(o-s)?(l=WE(e.read(o-s)),l.byteLength<o-s&&(l=WE(e.read()))):l=WE(e.read()),l.byteLength>0&&(c.push(l),s+=l.byteLength)),r||o<=s)do({cmd:a,size:o}=yield yield fE(u()));while(o<s)}while(!r)}finally{yield fE(d(t,n===`error`?i:null))}return yield fE(null);function d(t,n){return l=c=null,new Promise((r,i)=>{for(let[n,r]of t)e.off(n,r);try{let t=e.destroy;t&&t.call(e,n),n=void 0}catch(e){n=e||n}finally{n==null?r():i(n)}})}})}var oD;(function(e){e[e.V1=0]=`V1`,e[e.V2=1]=`V2`,e[e.V3=2]=`V3`,e[e.V4=3]=`V4`,e[e.V5=4]=`V5`})(oD||={});var sD;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(sD||={});var cD;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(cD||={});var lD;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(lD||={});var uD;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})(uD||={});var dD;(function(e){e[e.YEAR_MONTH=0]=`YEAR_MONTH`,e[e.DAY_TIME=1]=`DAY_TIME`,e[e.MONTH_DAY_NANO=2]=`MONTH_DAY_NANO`})(dD||={});var fD=new Int32Array(2),pD=new Float32Array(fD.buffer),mD=new Float64Array(fD.buffer),hD=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,gD;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(gD||={});var _D=class e{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new e(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readUint64(e){return BigInt.asUintN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readFloat32(e){return fD[0]=this.readInt32(e),pD[0]}readFloat64(e){return fD[+!hD]=this.readInt32(e),fD[+!!hD]=this.readInt32(e+4),mD[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){pD[0]=t,this.writeInt32(e,fD[0])}writeFloat64(e,t){mD[0]=t,this.writeInt32(e,fD[+!hD]),this.writeInt32(e+4,fD[+!!hD])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw Error(`FlatBuffers: ByteBuffer is too short to contain an identifier.`);let e=``;for(let t=0;t<4;t++)e+=String.fromCharCode(this.readInt8(this.position_+4+t));return e}__offset(e,t){let n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);let n=this.readInt32(e);e+=4;let r=this.bytes_.subarray(e,e+n);return t===gD.UTF8_BYTES?r:this.text_decoder_.decode(r)}__union_with_string(e,t){return typeof e==`string`?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+4}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=4)throw Error(`FlatBuffers: file identifier must be length 4`);for(let t=0;t<4;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+4+t))return!1;return!0}createScalarList(e,t){let n=[];for(let r=0;r<t;++r){let t=e(r);t!==null&&n.push(t)}return n}createObjList(e,t){let n=[];for(let r=0;r<t;++r){let t=e(r);t!==null&&n.push(t.unpack())}return n}},vD=class e{constructor(e){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let t;t=e||1024,this.bb=_D.allocate(t),this.space=t}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);let r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){let t=this.bb.capacity();this.bb=e.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(--this.space,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||t!==n)&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw TypeError(`FlatBuffers: struct must be serialized inline.`)}notNested(){if(this.isNested)throw TypeError(`FlatBuffers: object serialization must not be nested.`)}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){let t=e.capacity();if(t&3221225472)throw Error(`FlatBuffers: cannot grow buffer beyond 2 gigabytes.`);let n=t<<1,r=_D.allocate(n);return r.setPosition(n-t),r.bytes().set(e.bytes(),n-t),r}addOffset(e){this.prep(4,0),this.writeInt32(this.offset()-e+4)}startObject(e){this.notNested(),this.vtable??=[],this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw Error(`FlatBuffers: endObject called without startObject`);this.addInt32(0);let e=this.offset(),t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);let n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]==0?0:e-this.vtable[t]);this.addInt16(e-this.object_start);let r=(n+2)*2;this.addInt16(r);let i=0,a=this.space;outer_loop:for(t=0;t<this.vtables.length;t++){let e=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(e)){for(let t=2;t<r;t+=2)if(this.bb.readInt16(a+t)!=this.bb.readInt16(e+t))continue outer_loop;i=this.vtables[t];break}}return i?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,i-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){let r=n?4:0;if(t){let e=t;if(this.prep(this.minalign,8+r),e.length!=4)throw TypeError(`FlatBuffers: file identifier must be length 4`);for(let t=3;t>=0;t--)this.writeInt8(e.charCodeAt(t))}this.prep(this.minalign,4+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){let n=this.bb.capacity()-e,r=n-this.bb.readInt32(n);if(!(t<this.bb.readInt16(r)&&this.bb.readInt16(r+t)!=0))throw TypeError(`FlatBuffers: field `+t+` must be set`)}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(4,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||=new Map,this.string_maps.has(e))return this.string_maps.get(e);let t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(e==null)return 0;let t;return t=e instanceof Uint8Array?e:this.text_encoder.encode(e),this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector()}createByteVector(e){return e==null?0:(this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector())}createObjectOffset(e){return e===null?0:typeof e==`string`?this.createString(e):e.pack(this)}createObjectOffsetList(e){let t=[];for(let n=0;n<e.length;++n){let r=e[n];if(r!==null)t.push(this.createObjectOffset(r));else throw TypeError(`FlatBuffers: Argument for createObjectOffsetList cannot contain null.`)}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e.slice().reverse()),this.endVector()}},yD;(function(e){e[e.BUFFER=0]=`BUFFER`})(yD||={});var bD;(function(e){e[e.LZ4_FRAME=0]=`LZ4_FRAME`,e[e.ZSTD=1]=`ZSTD`})(bD||={});var xD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBodyCompression(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}codec(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):bD.LZ4_FRAME}method(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):yD.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,t){e.addFieldInt8(0,t,bD.LZ4_FRAME)}static addMethod(e,t){e.addFieldInt8(1,t,yD.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(t,n,r){return e.startBodyCompression(t),e.addCodec(t,n),e.addMethod(t,r),e.endBodyCompression(t)}},SD=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)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},CD=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},wD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsRecordBatch(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}length(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}nodes(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new CD).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}nodesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new SD).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}buffersLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){let t=this.bb.__offset(this.bb_pos,10);return t?(e||new xD).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addNodes(e,t){e.addFieldOffset(1,t,0)}static startNodesVector(e,t){e.startVector(16,t,8)}static addBuffers(e,t){e.addFieldOffset(2,t,0)}static startBuffersVector(e,t){e.startVector(16,t,8)}static addCompression(e,t){e.addFieldOffset(3,t,0)}static endRecordBatch(e){return e.endObject()}},TD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryBatch(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}id(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}data(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new wD).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isDelta(){let e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startDictionaryBatch(e){e.startObject(3)}static addId(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addData(e,t){e.addFieldOffset(1,t,0)}static addIsDelta(e,t){e.addFieldInt8(2,+t,0)}static endDictionaryBatch(e){return e.endObject()}},ED;(function(e){e[e.Little=0]=`Little`,e[e.Big=1]=`Big`})(ED||={});var DD;(function(e){e[e.DenseArray=0]=`DenseArray`})(DD||={});var OD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInt(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}isSigned(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startInt(e){e.startObject(2)}static addBitWidth(e,t){e.addFieldInt32(0,t,0)}static addIsSigned(e,t){e.addFieldInt8(1,+t,0)}static endInt(e){return e.endObject()}static createInt(t,n,r){return e.startInt(t),e.addBitWidth(t,n),e.addIsSigned(t,r),e.endInt(t)}},kD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryEncoding(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}id(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}indexType(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new OD).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isOrdered(){let e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}dictionaryKind(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt16(this.bb_pos+e):DD.DenseArray}static startDictionaryEncoding(e){e.startObject(4)}static addId(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addIndexType(e,t){e.addFieldOffset(1,t,0)}static addIsOrdered(e,t){e.addFieldInt8(2,+t,0)}static addDictionaryKind(e,t){e.addFieldInt16(3,t,DD.DenseArray)}static endDictionaryEncoding(e){return e.endObject()}},AD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsKeyValue(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}key(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}value(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startKeyValue(e){e.startObject(2)}static addKey(e,t){e.addFieldOffset(0,t,0)}static addValue(e,t){e.addFieldOffset(1,t,0)}static endKeyValue(e){return e.endObject()}static createKeyValue(t,n,r){return e.startKeyValue(t),e.addKey(t,n),e.addValue(t,r),e.endKeyValue(t)}},jD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(e){e.startObject(0)}static endBinary(e){return e.endObject()}static createBinary(t){return e.startBinary(t),e.endBinary(t)}},MD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBool(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startBool(e){e.startObject(0)}static endBool(e){return e.endObject()}static createBool(t){return e.startBool(t),e.endBool(t)}},ND=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDate(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):lD.MILLISECOND}static startDate(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,lD.MILLISECOND)}static endDate(e){return e.endObject()}static createDate(t,n){return e.startDate(t),e.addUnit(t,n),e.endDate(t)}},PD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDecimal(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}precision(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}scale(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):0}bitWidth(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt32(this.bb_pos+e):128}static startDecimal(e){e.startObject(3)}static addPrecision(e,t){e.addFieldInt32(0,t,0)}static addScale(e,t){e.addFieldInt32(1,t,0)}static addBitWidth(e,t){e.addFieldInt32(2,t,128)}static endDecimal(e){return e.endObject()}static createDecimal(t,n,r,i){return e.startDecimal(t),e.addPrecision(t,n),e.addScale(t,r),e.addBitWidth(t,i),e.endDecimal(t)}},FD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDuration(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):uD.MILLISECOND}static startDuration(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,uD.MILLISECOND)}static endDuration(e){return e.endObject()}static createDuration(t,n){return e.startDuration(t),e.addUnit(t,n),e.endDuration(t)}},ID=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeBinary(e){e.startObject(1)}static addByteWidth(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeBinary(e){return e.endObject()}static createFixedSizeBinary(t,n){return e.startFixedSizeBinary(t),e.addByteWidth(t,n),e.endFixedSizeBinary(t)}},LD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeList(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeList(e){e.startObject(1)}static addListSize(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeList(e){return e.endObject()}static createFixedSizeList(t,n){return e.startFixedSizeList(t),e.addListSize(t,n),e.endFixedSizeList(t)}},RD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFloatingPoint(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}precision(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):cD.HALF}static startFloatingPoint(e){e.startObject(1)}static addPrecision(e,t){e.addFieldInt16(0,t,cD.HALF)}static endFloatingPoint(e){return e.endObject()}static createFloatingPoint(t,n){return e.startFloatingPoint(t),e.addPrecision(t,n),e.endFloatingPoint(t)}},zD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInterval(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):dD.YEAR_MONTH}static startInterval(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,dD.YEAR_MONTH)}static endInterval(e){return e.endObject()}static createInterval(t,n){return e.startInterval(t),e.addUnit(t,n),e.endInterval(t)}},BD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(e){e.startObject(0)}static endLargeBinary(e){return e.endObject()}static createLargeBinary(t){return e.startLargeBinary(t),e.endLargeBinary(t)}},VD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(e){e.startObject(0)}static endLargeUtf8(e){return e.endObject()}static createLargeUtf8(t){return e.startLargeUtf8(t),e.endLargeUtf8(t)}},HD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsList(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startList(e){e.startObject(0)}static endList(e){return e.endObject()}static createList(t){return e.startList(t),e.endList(t)}},UD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMap(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let e=this.bb.__offset(this.bb_pos,4);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startMap(e){e.startObject(1)}static addKeysSorted(e,t){e.addFieldInt8(0,+t,0)}static endMap(e){return e.endObject()}static createMap(t,n){return e.startMap(t),e.addKeysSorted(t,n),e.endMap(t)}},WD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNull(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startNull(e){e.startObject(0)}static endNull(e){return e.endObject()}static createNull(t){return e.startNull(t),e.endNull(t)}},GD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsStruct_(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(e){e.startObject(0)}static endStruct_(e){return e.endObject()}static createStruct_(t){return e.startStruct_(t),e.endStruct_(t)}},KD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTime(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):uD.MILLISECOND}bitWidth(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):32}static startTime(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,uD.MILLISECOND)}static addBitWidth(e,t){e.addFieldInt32(1,t,32)}static endTime(e){return e.endObject()}static createTime(t,n,r){return e.startTime(t),e.addUnit(t,n),e.addBitWidth(t,r),e.endTime(t)}},qD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTimestamp(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):uD.SECOND}timezone(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startTimestamp(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,uD.SECOND)}static addTimezone(e,t){e.addFieldOffset(1,t,0)}static endTimestamp(e){return e.endObject()}static createTimestamp(t,n,r){return e.startTimestamp(t),e.addUnit(t,n),e.addTimezone(t,r),e.endTimestamp(t)}},JD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUnion(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}mode(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):sD.Sparse}typeIds(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+e*4):0}typeIdsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}typeIdsArray(){let e=this.bb.__offset(this.bb_pos,6);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}static startUnion(e){e.startObject(2)}static addMode(e,t){e.addFieldInt16(0,t,sD.Sparse)}static addTypeIds(e,t){e.addFieldOffset(1,t,0)}static createTypeIdsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(t,n,r){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,r),e.endUnion(t)}},YD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(t){return e.startUtf8(t),e.endUtf8(t)}},XD;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.FloatingPoint=3]=`FloatingPoint`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct_=13]=`Struct_`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.LargeList=21]=`LargeList`,e[e.RunEndEncoded=22]=`RunEndEncoded`})(XD||={});var ZD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):XD.NONE}type(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){let t=this.bb.__offset(this.bb_pos,12);return t?(e||new kD).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(t,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new e).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new AD).__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,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,XD.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(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 startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,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 endField(e){return e.endObject()}},QD=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):ED.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new ZD).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new AD).__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,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,ED.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(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 startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,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 addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(t,n,r,i,a){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,r),e.addCustomMetadata(t,i),e.addFeatures(t,a),e.endSchema(t)}},$D;(function(e){e[e.NONE=0]=`NONE`,e[e.Schema=1]=`Schema`,e[e.DictionaryBatch=2]=`DictionaryBatch`,e[e.RecordBatch=3]=`RecordBatch`,e[e.Tensor=4]=`Tensor`,e[e.SparseTensor=5]=`SparseTensor`})($D||={});var Z;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.Float=3]=`Float`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct=13]=`Struct`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.Dictionary=-1]=`Dictionary`,e[e.Int8=-2]=`Int8`,e[e.Int16=-3]=`Int16`,e[e.Int32=-4]=`Int32`,e[e.Int64=-5]=`Int64`,e[e.Uint8=-6]=`Uint8`,e[e.Uint16=-7]=`Uint16`,e[e.Uint32=-8]=`Uint32`,e[e.Uint64=-9]=`Uint64`,e[e.Float16=-10]=`Float16`,e[e.Float32=-11]=`Float32`,e[e.Float64=-12]=`Float64`,e[e.DateDay=-13]=`DateDay`,e[e.DateMillisecond=-14]=`DateMillisecond`,e[e.TimestampSecond=-15]=`TimestampSecond`,e[e.TimestampMillisecond=-16]=`TimestampMillisecond`,e[e.TimestampMicrosecond=-17]=`TimestampMicrosecond`,e[e.TimestampNanosecond=-18]=`TimestampNanosecond`,e[e.TimeSecond=-19]=`TimeSecond`,e[e.TimeMillisecond=-20]=`TimeMillisecond`,e[e.TimeMicrosecond=-21]=`TimeMicrosecond`,e[e.TimeNanosecond=-22]=`TimeNanosecond`,e[e.DenseUnion=-23]=`DenseUnion`,e[e.SparseUnion=-24]=`SparseUnion`,e[e.IntervalDayTime=-25]=`IntervalDayTime`,e[e.IntervalYearMonth=-26]=`IntervalYearMonth`,e[e.DurationSecond=-27]=`DurationSecond`,e[e.DurationMillisecond=-28]=`DurationMillisecond`,e[e.DurationMicrosecond=-29]=`DurationMicrosecond`,e[e.DurationNanosecond=-30]=`DurationNanosecond`})(Z||={});var eO;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(eO||={});var tO=void 0;function nO(e){if(e===null)return`null`;if(e===tO)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>nO(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function rO(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function iO(e,t){return rO(e/t)+rO(e%t)/rO(t)}var aO=Symbol.for(`isArrowBigNum`);function oO(e,...t){return t.length===0?Object.setPrototypeOf(VE(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}oO.prototype[aO]=!0,oO.prototype.toJSON=function(){return`"${fO(this)}"`},oO.prototype.valueOf=function(e){return dO(this,e)},oO.prototype.toString=function(){return fO(this)},oO.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return dO(this);case`string`:return fO(this);case`default`:return pO(this)}return fO(this)};function sO(...e){return oO.apply(this,e)}function cO(...e){return oO.apply(this,e)}function lO(...e){return oO.apply(this,e)}Object.setPrototypeOf(sO.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(cO.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(lO.prototype,Object.create(Uint32Array.prototype)),Object.assign(sO.prototype,oO.prototype,{constructor:sO,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(cO.prototype,oO.prototype,{constructor:cO,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(lO.prototype,oO.prototype,{constructor:lO,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var uO=BigInt(4294967296)*BigInt(4294967296)-BigInt(1);function dO(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(s){for(let e of o)c|=(e^uO)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let e of o)c|=e*(BigInt(1)<<BigInt(64*l++));if(typeof t==`number`){let e=BigInt(10**t),n=c/e,r=c%e;return rO(n)+rO(r)/rO(e)}return rO(c)}function fO(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return mO(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return mO(e);t=t.slice();let n=1;for(let e=0;e<t.length;e++){let r=t[e],i=~r+n;t[e]=i,n&=+(r===0)}return`-${mO(t)}`}function pO(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:fO(e)}function mO(e){let t=``,n=new Uint32Array(2),r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer),a=-1,o=r.length-1;do{for(n[0]=r[a=0];a<o;)r[a++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[a];r[a]=n[1]=n[0]/10,n[0]-=n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??`0`}var hO=class e{static new(e,t){switch(t){case!0:return new sO(e);case!1:return new cO(e)}switch(e.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new sO(e)}return e.byteLength===16?new lO(e):new cO(e)}static signed(e){return new sO(e)}static unsigned(e){return new cO(e)}static decimal(e){return new lO(e)}constructor(t,n){return e.new(t,n)}},gO,_O,vO,yO,bO,xO,SO,CO,wO,TO,EO,DO,OO,kO,AO,jO,MO,NO,PO,FO,IO,LO,RO=class e{static isNull(e){return e?.typeId===Z.Null}static isInt(e){return e?.typeId===Z.Int}static isFloat(e){return e?.typeId===Z.Float}static isBinary(e){return e?.typeId===Z.Binary}static isLargeBinary(e){return e?.typeId===Z.LargeBinary}static isUtf8(e){return e?.typeId===Z.Utf8}static isLargeUtf8(e){return e?.typeId===Z.LargeUtf8}static isBool(e){return e?.typeId===Z.Bool}static isDecimal(e){return e?.typeId===Z.Decimal}static isDate(e){return e?.typeId===Z.Date}static isTime(e){return e?.typeId===Z.Time}static isTimestamp(e){return e?.typeId===Z.Timestamp}static isInterval(e){return e?.typeId===Z.Interval}static isDuration(e){return e?.typeId===Z.Duration}static isList(e){return e?.typeId===Z.List}static isStruct(e){return e?.typeId===Z.Struct}static isUnion(e){return e?.typeId===Z.Union}static isFixedSizeBinary(e){return e?.typeId===Z.FixedSizeBinary}static isFixedSizeList(e){return e?.typeId===Z.FixedSizeList}static isMap(e){return e?.typeId===Z.Map}static isDictionary(e){return e?.typeId===Z.Dictionary}static isDenseUnion(t){return e.isUnion(t)&&t.mode===sD.Dense}static isSparseUnion(t){return e.isUnion(t)&&t.mode===sD.Sparse}constructor(e){this.typeId=e}};gO=Symbol.toStringTag,RO[gO]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(RO.prototype);var zO=class extends RO{constructor(){super(Z.Null)}toString(){return`Null`}};_O=Symbol.toStringTag,zO[_O]=(e=>e[Symbol.toStringTag]=`Null`)(zO.prototype);var BO=class extends RO{constructor(e,t){super(Z.Int),this.isSigned=e,this.bitWidth=t}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};vO=Symbol.toStringTag,BO[vO]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(BO.prototype);var VO=class extends BO{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},HO=class extends BO{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},UO=class extends BO{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},WO=class extends BO{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},GO=class extends BO{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},KO=class extends BO{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},qO=class extends BO{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},JO=class extends BO{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(VO.prototype,`ArrayType`,{value:Int8Array}),Object.defineProperty(HO.prototype,`ArrayType`,{value:Int16Array}),Object.defineProperty(UO.prototype,`ArrayType`,{value:Int32Array}),Object.defineProperty(WO.prototype,`ArrayType`,{value:BigInt64Array}),Object.defineProperty(GO.prototype,`ArrayType`,{value:Uint8Array}),Object.defineProperty(KO.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(qO.prototype,`ArrayType`,{value:Uint32Array}),Object.defineProperty(JO.prototype,`ArrayType`,{value:BigUint64Array});var YO=class extends RO{constructor(e){super(Z.Float),this.precision=e}get ArrayType(){switch(this.precision){case cD.HALF:return Uint16Array;case cD.SINGLE:return Float32Array;case cD.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};yO=Symbol.toStringTag,YO[yO]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(YO.prototype);var XO=class extends YO{constructor(){super(cD.HALF)}},ZO=class extends YO{constructor(){super(cD.SINGLE)}},QO=class extends YO{constructor(){super(cD.DOUBLE)}};Object.defineProperty(XO.prototype,`ArrayType`,{value:Uint16Array}),Object.defineProperty(ZO.prototype,`ArrayType`,{value:Float32Array}),Object.defineProperty(QO.prototype,`ArrayType`,{value:Float64Array});var $O=class extends RO{constructor(){super(Z.Binary)}toString(){return`Binary`}};bO=Symbol.toStringTag,$O[bO]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))($O.prototype);var ek=class extends RO{constructor(){super(Z.LargeBinary)}toString(){return`LargeBinary`}};xO=Symbol.toStringTag,ek[xO]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(ek.prototype);var tk=class extends RO{constructor(){super(Z.Utf8)}toString(){return`Utf8`}};SO=Symbol.toStringTag,tk[SO]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(tk.prototype);var nk=class extends RO{constructor(){super(Z.LargeUtf8)}toString(){return`LargeUtf8`}};CO=Symbol.toStringTag,nk[CO]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(nk.prototype);var rk=class extends RO{constructor(){super(Z.Bool)}toString(){return`Bool`}};wO=Symbol.toStringTag,rk[wO]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(rk.prototype);var ik=class extends RO{constructor(e,t,n=128){super(Z.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};TO=Symbol.toStringTag,ik[TO]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(ik.prototype);var ak=class extends RO{constructor(e){super(Z.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${lD[this.unit]}>`}get ArrayType(){return this.unit===lD.DAY?Int32Array:BigInt64Array}};EO=Symbol.toStringTag,ak[EO]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(ak.prototype);var ok=class extends RO{constructor(e,t){super(Z.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${uD[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};DO=Symbol.toStringTag,ok[DO]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(ok.prototype);var sk=class extends RO{constructor(e,t){super(Z.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${uD[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};OO=Symbol.toStringTag,sk[OO]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(sk.prototype);var ck=class extends sk{constructor(e){super(uD.MILLISECOND,e)}},lk=class extends RO{constructor(e){super(Z.Interval),this.unit=e}toString(){return`Interval<${dD[this.unit]}>`}};kO=Symbol.toStringTag,lk[kO]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(lk.prototype);var uk=class extends RO{constructor(e){super(Z.Duration),this.unit=e}toString(){return`Duration<${uD[this.unit]}>`}};AO=Symbol.toStringTag,uk[AO]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(uk.prototype);var dk=class extends RO{constructor(e){super(Z.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};jO=Symbol.toStringTag,dk[jO]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(dk.prototype);var fk=class extends RO{constructor(e){super(Z.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};MO=Symbol.toStringTag,fk[MO]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(fk.prototype);var pk=class extends RO{constructor(e,t,n){super(Z.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};NO=Symbol.toStringTag,pk[NO]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(pk.prototype);var mk=class extends RO{constructor(e){super(Z.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};PO=Symbol.toStringTag,mk[PO]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(mk.prototype);var hk=class extends RO{constructor(e,t){super(Z.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};FO=Symbol.toStringTag,hk[FO]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(hk.prototype);var gk=class extends RO{constructor(e,t=!1){if(super(Z.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,e?.type?.children)){let t=(e?.type)?.children[0];t&&(t.name=`key`);let n=(e?.type)?.children[1];n&&(n.name=`value`)}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};IO=Symbol.toStringTag,gk[IO]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(gk.prototype);var _k=(e=>()=>++e)(-1),vk=class extends RO{constructor(e,t,n,r){super(Z.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?_k():rO(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};LO=Symbol.toStringTag,vk[LO]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(vk.prototype);function yk(e){let t=e;switch(e.typeId){case Z.Decimal:return e.bitWidth/32;case Z.Interval:return 1+t.unit;case Z.FixedSizeList:return t.listSize;case Z.FixedSizeBinary:return t.byteWidth;default:return 1}}var bk=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return xk(this,e,t)}getVisitFnByTypeId(e,t=!0){return Sk(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function xk(e,t,n=!0){return typeof t==`number`?Sk(e,t,n):typeof t==`string`&&t in Z?Sk(e,Z[t],n):t&&t instanceof RO?Sk(e,Ck(t),n):t?.type&&t.type instanceof RO?Sk(e,Ck(t.type),n):Sk(e,Z.NONE,n)}function Sk(e,t,n=!0){let r=null;switch(t){case Z.Null:r=e.visitNull;break;case Z.Bool:r=e.visitBool;break;case Z.Int:r=e.visitInt;break;case Z.Int8:r=e.visitInt8||e.visitInt;break;case Z.Int16:r=e.visitInt16||e.visitInt;break;case Z.Int32:r=e.visitInt32||e.visitInt;break;case Z.Int64:r=e.visitInt64||e.visitInt;break;case Z.Uint8:r=e.visitUint8||e.visitInt;break;case Z.Uint16:r=e.visitUint16||e.visitInt;break;case Z.Uint32:r=e.visitUint32||e.visitInt;break;case Z.Uint64:r=e.visitUint64||e.visitInt;break;case Z.Float:r=e.visitFloat;break;case Z.Float16:r=e.visitFloat16||e.visitFloat;break;case Z.Float32:r=e.visitFloat32||e.visitFloat;break;case Z.Float64:r=e.visitFloat64||e.visitFloat;break;case Z.Utf8:r=e.visitUtf8;break;case Z.LargeUtf8:r=e.visitLargeUtf8;break;case Z.Binary:r=e.visitBinary;break;case Z.LargeBinary:r=e.visitLargeBinary;break;case Z.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case Z.Date:r=e.visitDate;break;case Z.DateDay:r=e.visitDateDay||e.visitDate;break;case Z.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case Z.Timestamp:r=e.visitTimestamp;break;case Z.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case Z.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case Z.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case Z.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case Z.Time:r=e.visitTime;break;case Z.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case Z.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case Z.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case Z.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case Z.Decimal:r=e.visitDecimal;break;case Z.List:r=e.visitList;break;case Z.Struct:r=e.visitStruct;break;case Z.Union:r=e.visitUnion;break;case Z.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case Z.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case Z.Dictionary:r=e.visitDictionary;break;case Z.Interval:r=e.visitInterval;break;case Z.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case Z.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case Z.Duration:r=e.visitDuration;break;case Z.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case Z.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case Z.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case Z.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case Z.FixedSizeList:r=e.visitFixedSizeList;break;case Z.Map:r=e.visitMap;break}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${Z[t]}'`)}function Ck(e){switch(e.typeId){case Z.Null:return Z.Null;case Z.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?Z.Int8:Z.Uint8;case 16:return n?Z.Int16:Z.Uint16;case 32:return n?Z.Int32:Z.Uint32;case 64:return n?Z.Int64:Z.Uint64}return Z.Int}case Z.Float:switch(e.precision){case cD.HALF:return Z.Float16;case cD.SINGLE:return Z.Float32;case cD.DOUBLE:return Z.Float64}return Z.Float;case Z.Binary:return Z.Binary;case Z.LargeBinary:return Z.LargeBinary;case Z.Utf8:return Z.Utf8;case Z.LargeUtf8:return Z.LargeUtf8;case Z.Bool:return Z.Bool;case Z.Decimal:return Z.Decimal;case Z.Time:switch(e.unit){case uD.SECOND:return Z.TimeSecond;case uD.MILLISECOND:return Z.TimeMillisecond;case uD.MICROSECOND:return Z.TimeMicrosecond;case uD.NANOSECOND:return Z.TimeNanosecond}return Z.Time;case Z.Timestamp:switch(e.unit){case uD.SECOND:return Z.TimestampSecond;case uD.MILLISECOND:return Z.TimestampMillisecond;case uD.MICROSECOND:return Z.TimestampMicrosecond;case uD.NANOSECOND:return Z.TimestampNanosecond}return Z.Timestamp;case Z.Date:switch(e.unit){case lD.DAY:return Z.DateDay;case lD.MILLISECOND:return Z.DateMillisecond}return Z.Date;case Z.Interval:switch(e.unit){case dD.DAY_TIME:return Z.IntervalDayTime;case dD.YEAR_MONTH:return Z.IntervalYearMonth}return Z.Interval;case Z.Duration:switch(e.unit){case uD.SECOND:return Z.DurationSecond;case uD.MILLISECOND:return Z.DurationMillisecond;case uD.MICROSECOND:return Z.DurationMicrosecond;case uD.NANOSECOND:return Z.DurationNanosecond}return Z.Duration;case Z.Map:return Z.Map;case Z.List:return Z.List;case Z.Struct:return Z.Struct;case Z.Union:switch(e.mode){case sD.Dense:return Z.DenseUnion;case sD.Sparse:return Z.SparseUnion}return Z.Union;case Z.FixedSizeBinary:return Z.FixedSizeBinary;case Z.FixedSizeList:return Z.FixedSizeList;case Z.Dictionary:return Z.Dictionary}throw Error(`Unrecognized type '${Z[e.typeId]}'`)}bk.prototype.visitInt8=null,bk.prototype.visitInt16=null,bk.prototype.visitInt32=null,bk.prototype.visitInt64=null,bk.prototype.visitUint8=null,bk.prototype.visitUint16=null,bk.prototype.visitUint32=null,bk.prototype.visitUint64=null,bk.prototype.visitFloat16=null,bk.prototype.visitFloat32=null,bk.prototype.visitFloat64=null,bk.prototype.visitDateDay=null,bk.prototype.visitDateMillisecond=null,bk.prototype.visitTimestampSecond=null,bk.prototype.visitTimestampMillisecond=null,bk.prototype.visitTimestampMicrosecond=null,bk.prototype.visitTimestampNanosecond=null,bk.prototype.visitTimeSecond=null,bk.prototype.visitTimeMillisecond=null,bk.prototype.visitTimeMicrosecond=null,bk.prototype.visitTimeNanosecond=null,bk.prototype.visitDenseUnion=null,bk.prototype.visitSparseUnion=null,bk.prototype.visitIntervalDayTime=null,bk.prototype.visitIntervalYearMonth=null,bk.prototype.visitDuration=null,bk.prototype.visitDurationSecond=null,bk.prototype.visitDurationMillisecond=null,bk.prototype.visitDurationMicrosecond=null,bk.prototype.visitDurationNanosecond=null;var wk=new Float64Array(1),Tk=new Uint32Array(wk.buffer);function Ek(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function Dk(e){if(e!==e)return 32256;wk[0]=e;let t=(Tk[1]&2147483648)>>16&65535,n=Tk[1]&2146435072,r=0;return n>=1089470464?Tk[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Tk[1]&1048575)>>10):n<=1056964608?(r=1048576+(Tk[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Tk[1]&1048575)+512>>10),t|n|r&65535}var Ok=class extends bk{};function kk(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}var Ak=(e,t,n)=>{e[t]=Math.floor(n/864e5)},jk=(e,t,n,r)=>{if(n+1<t.length){let i=rO(t[n]),a=rO(t[n+1]);e.set(r.subarray(0,a-i),i)}},Mk=({offset:e,values:t},n,r)=>{let i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Nk=({values:e},t,n)=>{e[t]=n},Pk=({values:e},t,n)=>{e[t]=n},Fk=({values:e},t,n)=>{e[t]=Dk(n)},Ik=(e,t,n)=>{switch(e.type.precision){case cD.HALF:return Fk(e,t,n);case cD.SINGLE:case cD.DOUBLE:return Pk(e,t,n)}},Lk=({values:e},t,n)=>{Ak(e,t,n.valueOf())},Rk=({values:e},t,n)=>{e[t]=BigInt(n)},zk=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Bk=({values:e,valueOffsets:t},n,r)=>jk(e,t,n,r),Vk=({values:e,valueOffsets:t},n,r)=>jk(e,t,n,yE(r)),Hk=(e,t,n)=>{e.type.unit===lD.DAY?Lk(e,t,n):Rk(e,t,n)},Uk=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},Wk=({values:e},t,n)=>{e[t]=BigInt(n)},Gk=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Kk=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},qk=(e,t,n)=>{switch(e.type.unit){case uD.SECOND:return Uk(e,t,n);case uD.MILLISECOND:return Wk(e,t,n);case uD.MICROSECOND:return Gk(e,t,n);case uD.NANOSECOND:return Kk(e,t,n)}},Jk=({values:e},t,n)=>{e[t]=n},Yk=({values:e},t,n)=>{e[t]=n},Xk=({values:e},t,n)=>{e[t]=n},Zk=({values:e},t,n)=>{e[t]=n},Qk=(e,t,n)=>{switch(e.type.unit){case uD.SECOND:return Jk(e,t,n);case uD.MILLISECOND:return Yk(e,t,n);case uD.MICROSECOND:return Xk(e,t,n);case uD.NANOSECOND:return Zk(e,t,n)}},$k=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},eA=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=bA.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o<s;)a(r,o++,n[++e]);else for(let e=-1,o=i[t],s=i[t+1];o<s;)a(r,o++,n.get(++e))},tA=(e,t,n)=>{let r=e.children[0],{valueOffsets:i}=e,a=bA.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},nA=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),rA=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),iA=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),aA=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),oA=(e,t,n)=>{let r=e.type.children.map(e=>bA.getVisitFn(e.type)),i=n instanceof Map?iA(t,n):n instanceof _M?rA(t,n):Array.isArray(n)?nA(t,n):aA(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},sA=(e,t,n)=>{e.type.mode===sD.Dense?cA(e,t,n):lA(e,t,n)},cA=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];bA.visit(i,e.valueOffsets[t],n)},lA=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];bA.visit(i,t,n)},uA=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},dA=(e,t,n)=>{e.type.unit===dD.DAY_TIME?fA(e,t,n):pA(e,t,n)},fA=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},pA=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},mA=({values:e},t,n)=>{e[t]=n},hA=({values:e},t,n)=>{e[t]=n},gA=({values:e},t,n)=>{e[t]=n},_A=({values:e},t,n)=>{e[t]=n},vA=(e,t,n)=>{switch(e.type.unit){case uD.SECOND:return mA(e,t,n);case uD.MILLISECOND:return hA(e,t,n);case uD.MICROSECOND:return gA(e,t,n);case uD.NANOSECOND:return _A(e,t,n)}},yA=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=bA.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e<r;)a(i,o+e,n[e]);else for(let e=-1,o=t*r;++e<r;)a(i,o+e,n.get(e))};Ok.prototype.visitBool=kk(Mk),Ok.prototype.visitInt=kk(Nk),Ok.prototype.visitInt8=kk(Nk),Ok.prototype.visitInt16=kk(Nk),Ok.prototype.visitInt32=kk(Nk),Ok.prototype.visitInt64=kk(Nk),Ok.prototype.visitUint8=kk(Nk),Ok.prototype.visitUint16=kk(Nk),Ok.prototype.visitUint32=kk(Nk),Ok.prototype.visitUint64=kk(Nk),Ok.prototype.visitFloat=kk(Ik),Ok.prototype.visitFloat16=kk(Fk),Ok.prototype.visitFloat32=kk(Pk),Ok.prototype.visitFloat64=kk(Pk),Ok.prototype.visitUtf8=kk(Vk),Ok.prototype.visitLargeUtf8=kk(Vk),Ok.prototype.visitBinary=kk(Bk),Ok.prototype.visitLargeBinary=kk(Bk),Ok.prototype.visitFixedSizeBinary=kk(zk),Ok.prototype.visitDate=kk(Hk),Ok.prototype.visitDateDay=kk(Lk),Ok.prototype.visitDateMillisecond=kk(Rk),Ok.prototype.visitTimestamp=kk(qk),Ok.prototype.visitTimestampSecond=kk(Uk),Ok.prototype.visitTimestampMillisecond=kk(Wk),Ok.prototype.visitTimestampMicrosecond=kk(Gk),Ok.prototype.visitTimestampNanosecond=kk(Kk),Ok.prototype.visitTime=kk(Qk),Ok.prototype.visitTimeSecond=kk(Jk),Ok.prototype.visitTimeMillisecond=kk(Yk),Ok.prototype.visitTimeMicrosecond=kk(Xk),Ok.prototype.visitTimeNanosecond=kk(Zk),Ok.prototype.visitDecimal=kk($k),Ok.prototype.visitList=kk(eA),Ok.prototype.visitStruct=kk(oA),Ok.prototype.visitUnion=kk(sA),Ok.prototype.visitDenseUnion=kk(cA),Ok.prototype.visitSparseUnion=kk(lA),Ok.prototype.visitDictionary=kk(uA),Ok.prototype.visitInterval=kk(dA),Ok.prototype.visitIntervalDayTime=kk(fA),Ok.prototype.visitIntervalYearMonth=kk(pA),Ok.prototype.visitDuration=kk(vA),Ok.prototype.visitDurationSecond=kk(mA),Ok.prototype.visitDurationMillisecond=kk(hA),Ok.prototype.visitDurationMicrosecond=kk(gA),Ok.prototype.visitDurationNanosecond=kk(_A),Ok.prototype.visitFixedSizeList=kk(yA),Ok.prototype.visitMap=kk(tA);var bA=new Ok,xA=Symbol.for(`parent`),SA=Symbol.for(`rowIndex`),CA=class{constructor(e,t){return this[xA]=e,this[SA]=t,new Proxy(this,new TA)}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[SA],t=this[xA],n=t.type.children,r={};for(let i=-1,a=n.length;++i<a;)r[n[i].name]=gj.visit(t.children[i],e);return r}toString(){return`{${[...this].map(([e,t])=>`${nO(e)}: ${nO(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new wA(this[xA],this[SA])}},wA=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return e<this.numChildren?(this.childIndex=e+1,{done:!1,value:[this.childFields[e].name,gj.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(CA.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[xA]:{writable:!0,enumerable:!1,configurable:!1,value:null},[SA]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var TA=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[xA].type.children.map(e=>e.name)}has(e,t){return e[xA].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[xA].type.children.findIndex(e=>e.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[xA].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=gj.visit(e[xA].children[n],e[SA]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[xA].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(bA.visit(e[xA].children[r],e[SA],n),Reflect.set(e,t,n))}},EA=class extends bk{};function DA(e){return(t,n)=>t.getValid(n)?e(t,n):null}var OA=(e,t)=>864e5*e[t],kA=(e,t)=>null,AA=(e,t,n)=>{if(n+1>=t.length)return null;let r=rO(t[n]),i=rO(t[n+1]);return e.subarray(r,i)},jA=({offset:e,values:t},n)=>{let r=e+n;return(t[r>>3]&1<<r%8)!=0},MA=({values:e},t)=>OA(e,t),NA=({values:e},t)=>rO(e[t]),PA=({stride:e,values:t},n)=>t[e*n],FA=({stride:e,values:t},n)=>Ek(t[e*n]),IA=({values:e},t)=>e[t],LA=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),RA=({values:e,valueOffsets:t},n)=>AA(e,t,n),zA=({values:e,valueOffsets:t},n)=>{let r=AA(e,t,n);return r===null?null:_E(r)},BA=({values:e},t)=>e[t],VA=({type:e,values:t},n)=>e.precision===cD.HALF?Ek(t[n]):t[n],HA=(e,t)=>e.type.unit===lD.DAY?MA(e,t):NA(e,t),UA=({values:e},t)=>1e3*rO(e[t]),WA=({values:e},t)=>rO(e[t]),GA=({values:e},t)=>iO(e[t],BigInt(1e3)),KA=({values:e},t)=>iO(e[t],BigInt(1e6)),qA=(e,t)=>{switch(e.type.unit){case uD.SECOND:return UA(e,t);case uD.MILLISECOND:return WA(e,t);case uD.MICROSECOND:return GA(e,t);case uD.NANOSECOND:return KA(e,t)}},JA=({values:e},t)=>e[t],YA=({values:e},t)=>e[t],XA=({values:e},t)=>e[t],ZA=({values:e},t)=>e[t],QA=(e,t)=>{switch(e.type.unit){case uD.SECOND:return JA(e,t);case uD.MILLISECOND:return YA(e,t);case uD.MICROSECOND:return XA(e,t);case uD.NANOSECOND:return ZA(e,t)}},$A=({values:e,stride:t},n)=>hO.decimal(e.subarray(t*n,t*(n+1))),ej=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n;return new _M([i[0].slice(a,o-a)])},tj=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new xj(o.slice(i,a-i))},nj=(e,t)=>new CA(e,t),rj=(e,t)=>e.type.mode===sD.Dense?ij(e,t):aj(e,t),ij=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return gj.visit(r,e.valueOffsets[t])},aj=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return gj.visit(r,t)},oj=(e,t)=>e.dictionary?.get(e.values[t]),sj=(e,t)=>e.type.unit===dD.DAY_TIME?cj(e,t):lj(e,t),cj=({values:e},t)=>e.subarray(2*t,2*(t+1)),lj=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},uj=({values:e},t)=>e[t],dj=({values:e},t)=>e[t],fj=({values:e},t)=>e[t],pj=({values:e},t)=>e[t],mj=(e,t)=>{switch(e.type.unit){case uD.SECOND:return uj(e,t);case uD.MILLISECOND:return dj(e,t);case uD.MICROSECOND:return fj(e,t);case uD.NANOSECOND:return pj(e,t)}},hj=(e,t)=>{let{stride:n,children:r}=e;return new _M([r[0].slice(t*n,n)])};EA.prototype.visitNull=DA(kA),EA.prototype.visitBool=DA(jA),EA.prototype.visitInt=DA(BA),EA.prototype.visitInt8=DA(PA),EA.prototype.visitInt16=DA(PA),EA.prototype.visitInt32=DA(PA),EA.prototype.visitInt64=DA(IA),EA.prototype.visitUint8=DA(PA),EA.prototype.visitUint16=DA(PA),EA.prototype.visitUint32=DA(PA),EA.prototype.visitUint64=DA(IA),EA.prototype.visitFloat=DA(VA),EA.prototype.visitFloat16=DA(FA),EA.prototype.visitFloat32=DA(PA),EA.prototype.visitFloat64=DA(PA),EA.prototype.visitUtf8=DA(zA),EA.prototype.visitLargeUtf8=DA(zA),EA.prototype.visitBinary=DA(RA),EA.prototype.visitLargeBinary=DA(RA),EA.prototype.visitFixedSizeBinary=DA(LA),EA.prototype.visitDate=DA(HA),EA.prototype.visitDateDay=DA(MA),EA.prototype.visitDateMillisecond=DA(NA),EA.prototype.visitTimestamp=DA(qA),EA.prototype.visitTimestampSecond=DA(UA),EA.prototype.visitTimestampMillisecond=DA(WA),EA.prototype.visitTimestampMicrosecond=DA(GA),EA.prototype.visitTimestampNanosecond=DA(KA),EA.prototype.visitTime=DA(QA),EA.prototype.visitTimeSecond=DA(JA),EA.prototype.visitTimeMillisecond=DA(YA),EA.prototype.visitTimeMicrosecond=DA(XA),EA.prototype.visitTimeNanosecond=DA(ZA),EA.prototype.visitDecimal=DA($A),EA.prototype.visitList=DA(ej),EA.prototype.visitStruct=DA(nj),EA.prototype.visitUnion=DA(rj),EA.prototype.visitDenseUnion=DA(ij),EA.prototype.visitSparseUnion=DA(aj),EA.prototype.visitDictionary=DA(oj),EA.prototype.visitInterval=DA(sj),EA.prototype.visitIntervalDayTime=DA(cj),EA.prototype.visitIntervalYearMonth=DA(lj),EA.prototype.visitDuration=DA(mj),EA.prototype.visitDurationSecond=DA(uj),EA.prototype.visitDurationMillisecond=DA(dj),EA.prototype.visitDurationMicrosecond=DA(fj),EA.prototype.visitDurationNanosecond=DA(pj),EA.prototype.visitFixedSizeList=DA(hj),EA.prototype.visitMap=DA(tj);var gj=new EA,_j=Symbol.for(`keys`),vj=Symbol.for(`vals`),yj=Symbol.for(`kKeysAsStrings`),bj=Symbol.for(`_kKeysAsStrings`),xj=class{constructor(e){return this[_j]=new _M([e.children[0]]).memoize(),this[vj]=e.children[1],new Proxy(this,new Cj)}get[yj](){return this[bj]||(this[bj]=Array.from(this[_j].toArray(),String))}[Symbol.iterator](){return new Sj(this[_j],this[vj])}get size(){return this[_j].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[_j],t=this[vj],n={};for(let r=-1,i=e.length;++r<i;)n[e.get(r)]=gj.visit(t,r);return n}toString(){return`{${[...this].map(([e,t])=>`${nO(e)}: ${nO(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},Sj=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),gj.visit(this.vals,e)]})}},Cj=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[yj]}has(e,t){return e[yj].includes(t)}getOwnPropertyDescriptor(e,t){if(e[yj].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[yj].indexOf(t);if(n!==-1){let r=gj.visit(Reflect.get(e,vj),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[yj].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(bA.visit(Reflect.get(e,vj),r,n),Reflect.set(e,t,n))}};Object.defineProperties(xj.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[_j]:{writable:!0,enumerable:!1,configurable:!1,value:null},[vj]:{writable:!0,enumerable:!1,configurable:!1,value:null},[bj]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var wj;function Tj(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),o<a&&(wj=a,a=o,o=wj),o>i&&(o=i),r?r(e,a,o):[a,o]}var Ej=(e,t)=>e<0?t+e:e,Dj=e=>e!==e;function Oj(e){if(typeof e!=`object`||!e)return Dj(e)?Dj:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?ZE(e,t):!1:e instanceof Map?Aj(e):Array.isArray(e)?kj(e):e instanceof _M?jj(e):Mj(e,!0)}function kj(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Oj(e[n]);return Nj(t)}function Aj(e){let t=-1,n=[];for(let r of e.values())n[++t]=Oj(r);return Nj(n)}function jj(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Oj(e.get(n));return Nj(t)}function Mj(e,t=!1){let n=Object.keys(e);if(!t&&n.length===0)return()=>!1;let r=[];for(let t=-1,i=n.length;++t<i;)r[t]=Oj(e[n[t]]);return Nj(r,n)}function Nj(e,t){return n=>{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return Pj(e,n);case Map:return Ij(e,n,n.keys());case xj:case CA:case Object:case void 0:return Ij(e,n,t||Object.keys(n))}return n instanceof _M?Fj(e,n):!1}}function Pj(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function Fj(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Ij(e,t,n){let r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),a=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,s=e.length,c=a.next(),l=r.next(),u=i.next();for(;o<s&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!e[o](c.value));++o,l=r.next(),u=i.next(),c=a.next());return o===s&&l.done&&u.done&&c.done?!0:(r.return&&r.return(),i.return&&i.return(),a.return&&a.return(),!1)}function Lj(e,t,n,r){return(n&1<<r)!=0}function Rj(e,t,n,r){return(n&1<<r)>>r}function zj(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength<r){let i=new Uint8Array(r);return i.set(e%8==0?n.subarray(e>>3):Bj(new Vj(n,e,t,null,Lj)).subarray(0,r)),i}return n}function Bj(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var Vj=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Hj(e,t,n){if(n-t<=0)return 0;if(n-t<8){let r=0;for(let i of new Vj(e,t,n-t,e,Rj))r+=i;return r}let r=n>>3<<3,i=t+(t%8==0?0:8-t%8);return Hj(e,t,i)+Hj(e,r,n)+Uj(e,i>>3,r-i>>3)}function Uj(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=Wj(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=Wj(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=Wj(a.getUint8(i)),i+=1;return r}function Wj(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Gj=class e{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:e}=this;return RO.isSparseUnion(e)||RO.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(RO.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Hj(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=yk(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(RO.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===sD.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e;return(this.nullBitmap[t>>3]&1<<t%8)!=0}return!0}setValid(e,t){let n,{type:r}=this;if(RO.isUnion(r)){let i=r,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],o=i.mode===sD.Dense?this.valueOffsets[e]:e;n=a.getValid(o),a.setValid(o,t)}else{let{nullBitmap:r}=this,{offset:i,length:a}=this,o=i+e,s=1<<o%8,c=o>>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(zj(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===Z.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<<t-(t&-8))-1,n>0&&r.set(zj(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[eO.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[eO.TYPE])&&(a[eO.TYPE]=i.subarray(e,e+t)),(i=a[eO.OFFSET])&&(a[eO.OFFSET]=i.subarray(e,e+t+1))||(i=a[eO.DATA])&&(a[eO.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};Gj.prototype.children=Object.freeze([]);var Kj=new class e extends bk{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new Gj(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=WE(e.data),i=WE(e.nullBitmap),a=HE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Gj(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=WE(e.data),i=WE(e.nullBitmap),a=UE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Gj(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=WE(e.data),i=WE(e.nullBitmap),a=HE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Gj(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=WE(e.data),i=WE(e.nullBitmap),a=UE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Gj(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=WE(e.nullBitmap),a=HE(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new Gj(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=WE(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=VE(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;return RO.isSparseUnion(t)?new Gj(t,n,a,o,[void 0,void 0,void 0,i],r):new Gj(t,n,a,o,[HE(e.valueOffsets),void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=WE(t.nullBitmap),a=VE(n.indices.ArrayType,t.data),{dictionary:o=new _M([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new Gj(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length/yk(t),nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=WE(e.nullBitmap),i=VE(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new Gj(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=WE(t.nullBitmap),{length:o=i.length/yk(n),nullCount:s=t.nullBitmap?-1:0}=t;return new Gj(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=WE(t.nullBitmap),o=HE(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new Gj(n,r,s,c,[o,void 0,a],[i])}};function qj(e){return Kj.visit(e)}var Jj=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let e=this.chunkIterator.next();if(!e.done)return e;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function Yj(e){return e.some(e=>e.nullable)}function Xj(e){return e.reduce((e,t)=>e+t.nullCount,0)}function Zj(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function Qj(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a<o;){let o=e[a],s=t[a],{length:c}=o;if(s>=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function $j(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n<t[o]?r(e,i,n-t[i]):null;a=i+Math.trunc((o-i)*.5),n<t[a]?o=a:i=a}while(i<o)}function eM(e,t){return e.getValid(t)}function tM(e){function t(t,n,r){return e(t[n],r)}return function(e){let n=this.data;return $j(n,this._offsets,e,t)}}function nM(e){let t;function n(n,r,i){return e(n[r],i,t)}return function(e,r){let i=this.data;t=r;let a=$j(i,this._offsets,e,n);return t=void 0,a}}function rM(e){let t;function n(n,r,i){let a=i,o=0,s=0;for(let i=r-1,c=n.length;++i<c;){let r=n[i];if(~(o=e(r,t,a)))return s+o;a=0,s+=r.length}return-1}return function(e,r){t=e;let i=this.data,a=typeof r==`number`?$j(i,this._offsets,r,n):n(i,0,0);return t=void 0,a}}var iM=class extends bk{};function aM(e,t){return t===null&&e.length>0?0:-1}function oM(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new Vj(n,e.offset+(t||0),e.length,n,Lj)){if(!i)return r;++r}return-1}function sM(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case Z.Union:break;case Z.Dictionary:break;default:return oM(e,n)}let r=gj.getVisitFn(e),i=Oj(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}function cM(e,t,n){let r=gj.getVisitFn(e),i=Oj(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}iM.prototype.visitNull=aM,iM.prototype.visitBool=sM,iM.prototype.visitInt=sM,iM.prototype.visitInt8=sM,iM.prototype.visitInt16=sM,iM.prototype.visitInt32=sM,iM.prototype.visitInt64=sM,iM.prototype.visitUint8=sM,iM.prototype.visitUint16=sM,iM.prototype.visitUint32=sM,iM.prototype.visitUint64=sM,iM.prototype.visitFloat=sM,iM.prototype.visitFloat16=sM,iM.prototype.visitFloat32=sM,iM.prototype.visitFloat64=sM,iM.prototype.visitUtf8=sM,iM.prototype.visitLargeUtf8=sM,iM.prototype.visitBinary=sM,iM.prototype.visitLargeBinary=sM,iM.prototype.visitFixedSizeBinary=sM,iM.prototype.visitDate=sM,iM.prototype.visitDateDay=sM,iM.prototype.visitDateMillisecond=sM,iM.prototype.visitTimestamp=sM,iM.prototype.visitTimestampSecond=sM,iM.prototype.visitTimestampMillisecond=sM,iM.prototype.visitTimestampMicrosecond=sM,iM.prototype.visitTimestampNanosecond=sM,iM.prototype.visitTime=sM,iM.prototype.visitTimeSecond=sM,iM.prototype.visitTimeMillisecond=sM,iM.prototype.visitTimeMicrosecond=sM,iM.prototype.visitTimeNanosecond=sM,iM.prototype.visitDecimal=sM,iM.prototype.visitList=sM,iM.prototype.visitStruct=sM,iM.prototype.visitUnion=sM,iM.prototype.visitDenseUnion=cM,iM.prototype.visitSparseUnion=cM,iM.prototype.visitDictionary=sM,iM.prototype.visitInterval=sM,iM.prototype.visitIntervalDayTime=sM,iM.prototype.visitIntervalYearMonth=sM,iM.prototype.visitDuration=sM,iM.prototype.visitDurationSecond=sM,iM.prototype.visitDurationMillisecond=sM,iM.prototype.visitDurationMicrosecond=sM,iM.prototype.visitDurationNanosecond=sM,iM.prototype.visitFixedSizeList=sM,iM.prototype.visitMap=sM;var lM=new iM,uM=class extends bk{};function dM(e){let{type:t}=e;if(e.nullCount===0&&e.stride===1&&(RO.isInt(t)&&t.bitWidth!==64||RO.isTime(t)&&t.bitWidth!==64||RO.isFloat(t)&&t.precision!==cD.HALF))return new Jj(e.data.length,t=>{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new Jj(e.data.length,t=>{let r=e.data[t].length,i=e.slice(n,n+r);return n+=r,new fM(i)})}var fM=class{constructor(e){this.vector=e,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};uM.prototype.visitNull=dM,uM.prototype.visitBool=dM,uM.prototype.visitInt=dM,uM.prototype.visitInt8=dM,uM.prototype.visitInt16=dM,uM.prototype.visitInt32=dM,uM.prototype.visitInt64=dM,uM.prototype.visitUint8=dM,uM.prototype.visitUint16=dM,uM.prototype.visitUint32=dM,uM.prototype.visitUint64=dM,uM.prototype.visitFloat=dM,uM.prototype.visitFloat16=dM,uM.prototype.visitFloat32=dM,uM.prototype.visitFloat64=dM,uM.prototype.visitUtf8=dM,uM.prototype.visitLargeUtf8=dM,uM.prototype.visitBinary=dM,uM.prototype.visitLargeBinary=dM,uM.prototype.visitFixedSizeBinary=dM,uM.prototype.visitDate=dM,uM.prototype.visitDateDay=dM,uM.prototype.visitDateMillisecond=dM,uM.prototype.visitTimestamp=dM,uM.prototype.visitTimestampSecond=dM,uM.prototype.visitTimestampMillisecond=dM,uM.prototype.visitTimestampMicrosecond=dM,uM.prototype.visitTimestampNanosecond=dM,uM.prototype.visitTime=dM,uM.prototype.visitTimeSecond=dM,uM.prototype.visitTimeMillisecond=dM,uM.prototype.visitTimeMicrosecond=dM,uM.prototype.visitTimeNanosecond=dM,uM.prototype.visitDecimal=dM,uM.prototype.visitList=dM,uM.prototype.visitStruct=dM,uM.prototype.visitUnion=dM,uM.prototype.visitDenseUnion=dM,uM.prototype.visitSparseUnion=dM,uM.prototype.visitDictionary=dM,uM.prototype.visitInterval=dM,uM.prototype.visitIntervalDayTime=dM,uM.prototype.visitIntervalYearMonth=dM,uM.prototype.visitDuration=dM,uM.prototype.visitDurationSecond=dM,uM.prototype.visitDurationMillisecond=dM,uM.prototype.visitDurationMicrosecond=dM,uM.prototype.visitDurationNanosecond=dM,uM.prototype.visitFixedSizeList=dM,uM.prototype.visitMap=dM;var pM=new uM,mM,hM={},gM={},_M=class e{constructor(t){let n=t[0]instanceof e?t.flatMap(e=>e.data):t;if(n.length===0||n.some(e=>!(e instanceof Gj)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let r=n[0]?.type;switch(n.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:i}=hM[r.typeId],a=n[0];this.isValid=e=>eM(a,e),this.get=t=>e(a,t),this.set=(e,n)=>t(a,e,n),this.indexOf=e=>i(a,e),this._offsets=[0,a.length];break}default:Object.setPrototypeOf(this,gM[r.typeId]),this._offsets=Zj(n);break}this.data=n,this.type=r,this.stride=yk(r),this.numChildren=r.children?.length??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return Yj(this.data)}get nullCount(){return Xj(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${Z[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Ej(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return pM.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(Tj(this,t,n,({data:e,_offsets:t},n,r)=>Qj(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case Z.Int:case Z.Float:case Z.Decimal:case Z.Time:case Z.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){return this.getChildAt(this.type.children?.findIndex(t=>t.name===e))}getChildAt(t){return t>-1&&t<this.numChildren?new e(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return RO.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(RO.isDictionary(this.type)){let t=new vM(this.data[0].dictionary);return new e(this.data.map(e=>{let n=e.clone();return n.dictionary=t,n}))}return new vM(this)}unmemoize(){if(RO.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize();return new e(this.data.map(e=>{let n=e.clone();return n.dictionary=t,n}))}return this}};mM=Symbol.toStringTag,_M[mM]=(e=>{e.type=RO.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(Z).map(e=>Z[e]).filter(e=>typeof e==`number`&&e!==Z.NONE);for(let n of t)hM[n]={get:gj.getVisitFnByTypeId(n),set:bA.getVisitFnByTypeId(n),indexOf:lM.getVisitFnByTypeId(n)},gM[n]=Object.create(e,{isValid:{value:tM(eM)},get:{value:tM(gj.getVisitFnByTypeId(n))},set:{value:nM(bA.getVisitFnByTypeId(n))},indexOf:{value:rM(lM.getVisitFnByTypeId(n))}});return`Vector`})(_M.prototype);var vM=class e extends _M{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,`get`,{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,`set`,{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,`slice`,{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,`isMemoized`,{value:!0}),Object.defineProperty(this,`unmemoize`,{value:()=>new _M(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}};function yM(e){if(e){if(e instanceof Gj)return new _M([e]);if(e instanceof _M)return new _M(e.data);if(e.type instanceof RO)return new _M([qj(e)]);if(Array.isArray(e))return new _M(e.flatMap(e=>bM(e)));if(ArrayBuffer.isView(e)){e instanceof DataView&&(e=new Uint8Array(e.buffer));let t={offset:0,length:e.length,nullCount:-1,data:e};if(e instanceof Int8Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new VO}))]);if(e instanceof Int16Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new HO}))]);if(e instanceof Int32Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new UO}))]);if(e instanceof BigInt64Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new WO}))]);if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return new _M([qj(Object.assign(Object.assign({},t),{type:new GO}))]);if(e instanceof Uint16Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new KO}))]);if(e instanceof Uint32Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new qO}))]);if(e instanceof BigUint64Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new JO}))]);if(e instanceof Float32Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new ZO}))]);if(e instanceof Float64Array)return new _M([qj(Object.assign(Object.assign({},t),{type:new QO}))]);throw Error(`Unrecognized input`)}}throw Error(`Unrecognized input`)}function bM(e){return e instanceof Gj?[e]:e instanceof _M?e.data:yM(e).data}function xM(e){if(!e||e.length<=0)return function(e){return!0};let t=``,n=e.filter(e=>e===e);return n.length>0&&(t=`
65
+ switch (x) {${n.map(e=>`
66
+ case ${SM(e)}:`).join(``)}
67
+ return false;
68
+ }`),e.length!==n.length&&(t=`if (x !== x) return false;\n${t}`),Function(`x`,`${t}\nreturn true;`)}function SM(e){return typeof e==`bigint`?`${nO(e)}n`:nO(e)}function CM(e,t){let n=Math.ceil(e)*t-1;return(n-n%64+64||64)/t}function wM(e,t=0){return e.length>=t?e.subarray(0,t):zE(new e.constructor(t),e,0)}var TM=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(CM(r===0?n*1:n*2,this.BYTES_PER_ELEMENT))}return this}flush(e=this.length){e=CM(e*this.stride,this.BYTES_PER_ELEMENT);let t=wM(this.buffer,e);return this.clear(),t}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(e){return this.buffer=wM(this.buffer,e)}},EM=class extends TM{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}},DM=class extends EM{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()}},OM=class extends EM{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)}},kM=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=yk(e),this._nulls=new DM,t&&t.length>0&&(this._isValid=xM(t))}toVector(){return new _M([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(),qj({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}};kM.prototype.length=1,kM.prototype.stride=1,kM.prototype.children=null,kM.prototype.finished=!1,kM.prototype.nullValues=null,kM.prototype._isValid=()=>!0;var AM=class extends kM{constructor(e){super(e),this._values=new EM(this.ArrayType,0,this.stride)}setValue(e,t){let n=this._values;return n.reserve(e-n.length+1),super.setValue(e,t)}},jM=class extends kM{constructor(e){super(e),this._pendingLength=0,this._offsets=new OM(e.type)}setValue(e,t){let n=this._pending||=new Map,r=n.get(e);r&&(this._pendingLength-=r.length),this._pendingLength+=t instanceof xj?t[_j].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}},MM=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()}},NM=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):oD.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new QD).__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 MM).__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 MM).__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 AD).__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,oD.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)}},PM=class e{constructor(e=[],t,n,r=oD.V5){this.fields=e||[],this.metadata=t||new Map,n||=LM(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=IM(IM(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:IM(IM(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=LM(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};PM.prototype.fields=null,PM.prototype.metadata=null,PM.prototype.dictionaries=null;var FM=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)}};FM.prototype.type=null,FM.prototype.name=null,FM.prototype.nullable=null,FM.prototype.metadata=null;function IM(e,t){return new Map([...e||new Map,...t||new Map])}function LM(e,t=new Map){for(let n=-1,r=e.length;++n<r;){let r=e[n].type;if(RO.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&&LM(r.children,t)}return t}var RM=vD,zM=_D,BM=class{static decode(e){e=new zM(WE(e));let t=NM.getRootAsFooter(e);return new VM(PM.decode(t.schema(),new Map,t.version()),t)}static encode(e){let t=new RM,n=PM.encode(t,e.schema);NM.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())HM.encode(t,n);let r=t.endVector();NM.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())HM.encode(t,n);let i=t.endVector();return NM.startFooter(t),NM.addSchema(t,n),NM.addVersion(t,oD.V5),NM.addRecordBatches(t,r),NM.addDictionaries(t,i),NM.finishFooterBuffer(t,NM.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=oD.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}},VM=class extends BM{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 HM.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){let t=this._footer.dictionaries(e);if(t)return HM.decode(t)}return null}},HM=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 MM.createBlock(e,r,n,i)}constructor(e,t,n){this.metaDataLength=e,this.offset=rO(n),this.bodyLength=rO(t)}},UM=Object.freeze({done:!0,value:void 0}),WM=class{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},GM=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()}},KM=class extends GM{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return uE(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(UM);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return QE.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return QE.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return uE(this,void 0,void 0,function*(){return yield this.abort(e),UM})}return(e){return uE(this,void 0,void 0,function*(){return yield this.close(),UM})}read(e){return uE(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return uE(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(UM)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},qM=class extends KM{write(e){if((e=WE(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?_E(this.toUint8Array(!0)):this.toUint8Array(!1).then(_E)}toUint8Array(e=!1){return e?BE(this._values)[0]:uE(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var o=!0,s=hE(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 BE(i,a)[0]})}},JM=class{constructor(e){e&&(this.source=new XM(QE.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)}},YM=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof qM?this.source=new ZM(QE.fromAsyncIterable(t)):FE(t)?this.source=new ZM(QE.fromNodeStream(t)):NE(t)?this.source=new ZM(QE.fromDOMStream(t)):AE(t)?this.source=new ZM(QE.fromDOMStream(t.body)):TE(t)?this.source=new ZM(QE.fromIterable(t)):(wE(t)||EE(t))&&(this.source=new ZM(QE.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)}},XM=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)||UM)}return(e){return Object.create(this.source.return&&this.source.return(e)||UM)}},ZM=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return uE(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return uE(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return uE(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return uE(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return uE(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||UM;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return uE(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||UM;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},QM=class extends JM{constructor(e,t){super(),this.position=0,this.buffer=WE(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}}},$M=class extends YM{constructor(e,t){super(),this.position=0,this._handle=e,typeof t==`number`?this.size=t:this._pending=uE(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending})}readInt32(e){return uE(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 uE(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 uE(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 uE(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 uE(this,void 0,void 0,function*(){let e=this._handle;this._handle=null,e&&(yield e.close())})}throw(e){return uE(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}return(e){return uE(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}},eN=65536;function tN(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}var nN=8,rN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],iN=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?eN: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`${tN(this.buffer[1])} ${tN(this.buffer[0])}`}},aN=class e extends iN{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=nN<r-n?nN:r-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+a),10),0])),s=new e(new Uint32Array([rN[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)}},oN=class e extends iN{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=nN<i-n?nN:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0])),s=new e(new Uint32Array([rN[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)}},sN=class e{constructor(e){this.buffer=e}high(){return new oN(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new oN(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 aN(new Uint32Array([this.buffer[3],0])),n=new aN(new Uint32Array([this.buffer[2],0])),r=new aN(new Uint32Array([this.buffer[1],0])),i=new aN(new Uint32Array([this.buffer[0],0])),a=new aN(new Uint32Array([e.buffer[3],0])),o=new aN(new Uint32Array([e.buffer[2],0])),s=new aN(new Uint32Array([e.buffer[1],0])),c=new aN(new Uint32Array([e.buffer[0],0])),l=aN.multiply(i,c);this.buffer[0]=l.low();let u=new aN(new Uint32Array([l.high(),0]));return l=aN.multiply(r,c),u.plus(l),l=aN.multiply(i,s),u.plus(l),this.buffer[1]=u.low(),this.buffer[3]=+!!u.lessThan(l),this.buffer[2]=u.high(),new aN(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(aN.multiply(n,c)).plus(aN.multiply(r,s)).plus(aN.multiply(i,o)),this.buffer[3]+=aN.multiply(t,c).plus(aN.multiply(n,s)).plus(aN.multiply(r,o)).plus(aN.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`${tN(this.buffer[3])} ${tN(this.buffer[2])} ${tN(this.buffer[1])} ${tN(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=nN<i-n?nN:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0,0,0])),s=new e(new Uint32Array([rN[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}},cN=class extends bk{constructor(e,t,n,r,i=oD.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 FM?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return qj({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({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 qj({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 qj({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 qj({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 qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({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 qj({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<oD.V5&&this.readNullBitmap(e,n),e.mode===sD.Sparse?this.visitSparseUnion(e,{length:t,nullCount:n}):this.visitDenseUnion(e,{length:t,nullCount:n})}visitDenseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({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 qj({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({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 qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return qj({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 qj({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 cN{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:Bj(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return VE(Uint8Array,VE(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return VE(Uint8Array,VE(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return RO.isTimestamp(e)||(RO.isInt(e)||RO.isTime(e))&&e.bitWidth===64||RO.isDuration(e)||RO.isDate(e)&&e.unit===lD.MILLISECOND?VE(Uint8Array,oN.convertArray(n[t])):RO.isDecimal(e)?VE(Uint8Array,sN.convertArray(n[t])):RO.isBinary(e)||RO.isLargeBinary(e)||RO.isFixedSizeBinary(e)?uN(n[t]):RO.isBool(e)?Bj(n[t]):RO.isUtf8(e)||RO.isLargeUtf8(e)?yE(n[t].join(``)):VE(Uint8Array,VE(e.ArrayType,n[t].map(e=>+e)))}};function uN(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 dN=class extends jM{constructor(e){super(e),this._values=new TM(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,WE(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}}},fN=class extends jM{constructor(e){super(e),this._values=new TM(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,WE(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}}},pN=class extends kM{constructor(e){super(e),this._values=new DM}setValue(e,t){this._values.set(e,+t)}},mN=class extends AM{};mN.prototype._setValue=Hk;var hN=class extends mN{};hN.prototype._setValue=Lk;var gN=class extends mN{};gN.prototype._setValue=Rk;var _N=class extends AM{};_N.prototype._setValue=$k;var vN=class extends kM{constructor({type:e,nullValues:t,dictionaryHashFunction:n}){super({type:new vk(e.dictionary,e.indices,e.id,e.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=OP({type:this.type.indices,nullValues:t}),this.dictionary=OP({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}`}},yN=class extends AM{};yN.prototype._setValue=zk;var bN=class extends kM{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 hk(this.type.listSize,new FM(t,e.type,!0)),n}},xN=class extends AM{setValue(e,t){this._values.set(e,t)}},SN=class extends xN{setValue(e,t){super.setValue(e,Dk(t))}},CN=class extends xN{},wN=class extends xN{},TN=class extends AM{};TN.prototype._setValue=dA;var EN=class extends TN{};EN.prototype._setValue=fA;var DN=class extends TN{};DN.prototype._setValue=pA;var ON=class extends AM{};ON.prototype._setValue=vA;var kN=class extends ON{};kN.prototype._setValue=mA;var AN=class extends ON{};AN.prototype._setValue=hA;var jN=class extends ON{};jN.prototype._setValue=gA;var MN=class extends ON{};MN.prototype._setValue=_A;var NN=class extends AM{setValue(e,t){this._values.set(e,t)}},PN=class extends NN{},FN=class extends NN{},IN=class extends NN{},LN=class extends NN{},RN=class extends NN{},zN=class extends NN{},BN=class extends NN{},VN=class extends NN{},HN=class extends jM{constructor(e){super(e),this._offsets=new OM(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 dk(new FM(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])}}},UN=class extends jM{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 gk(new FM(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}}},WN=class extends kM{setValue(e,t){}setValid(e,t){return this.length=Math.max(e+1,this.length),t}},GN=class extends kM{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 fk([...this.type.children,new FM(t,e.type,!0)]),n}},KN=class extends AM{};KN.prototype._setValue=qk;var qN=class extends KN{};qN.prototype._setValue=Uk;var JN=class extends KN{};JN.prototype._setValue=Wk;var YN=class extends KN{};YN.prototype._setValue=Gk;var XN=class extends KN{};XN.prototype._setValue=Kk;var ZN=class extends AM{};ZN.prototype._setValue=Qk;var QN=class extends ZN{};QN.prototype._setValue=Jk;var $N=class extends ZN{};$N.prototype._setValue=Yk;var eP=class extends ZN{};eP.prototype._setValue=Xk;var tP=class extends ZN{};tP.prototype._setValue=Zk;var nP=class extends kM{constructor(e){super(e),this._typeIds=new EM(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 FM(t,e.type)];return this.type=new pk(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.")}},rP=class extends nP{},iP=class extends nP{constructor(e){super(e),this._offsets=new EM(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)}},aP=class extends jM{constructor(e){super(e),this._values=new TM(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,yE(t))}_flushPending(e,t){}};aP.prototype._flushPending=dN.prototype._flushPending;var oP=class extends jM{constructor(e){super(e),this._values=new TM(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,yE(t))}_flushPending(e,t){}};oP.prototype._flushPending=fN.prototype._flushPending;var sP=new class extends bk{visitNull(){return WN}visitBool(){return pN}visitInt(){return NN}visitInt8(){return PN}visitInt16(){return FN}visitInt32(){return IN}visitInt64(){return LN}visitUint8(){return RN}visitUint16(){return zN}visitUint32(){return BN}visitUint64(){return VN}visitFloat(){return xN}visitFloat16(){return SN}visitFloat32(){return CN}visitFloat64(){return wN}visitUtf8(){return aP}visitLargeUtf8(){return oP}visitBinary(){return dN}visitLargeBinary(){return fN}visitFixedSizeBinary(){return yN}visitDate(){return mN}visitDateDay(){return hN}visitDateMillisecond(){return gN}visitTimestamp(){return KN}visitTimestampSecond(){return qN}visitTimestampMillisecond(){return JN}visitTimestampMicrosecond(){return YN}visitTimestampNanosecond(){return XN}visitTime(){return ZN}visitTimeSecond(){return QN}visitTimeMillisecond(){return $N}visitTimeMicrosecond(){return eP}visitTimeNanosecond(){return tP}visitDecimal(){return _N}visitList(){return HN}visitStruct(){return GN}visitUnion(){return nP}visitDenseUnion(){return iP}visitSparseUnion(){return rP}visitDictionary(){return vN}visitInterval(){return TN}visitIntervalDayTime(){return EN}visitIntervalYearMonth(){return DN}visitDuration(){return ON}visitDurationSecond(){return kN}visitDurationMillisecond(){return AN}visitDurationMicrosecond(){return jN}visitDurationNanosecond(){return MN}visitFixedSizeList(){return bN}visitMap(){return UN}},cP=class extends bk{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 uP(e,t){return e===t||lP(e,t)}function dP(e,t){return e===t||lP(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function fP(e,t){return e===t||lP(e,t)&&e.precision===t.precision}function pP(e,t){return e===t||lP(e,t)&&e.byteWidth===t.byteWidth}function mP(e,t){return e===t||lP(e,t)&&e.unit===t.unit}function hP(e,t){return e===t||lP(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function gP(e,t){return e===t||lP(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function _P(e,t){return e===t||lP(e,t)&&e.children.length===t.children.length&&TP.compareManyFields(e.children,t.children)}function vP(e,t){return e===t||lP(e,t)&&e.children.length===t.children.length&&TP.compareManyFields(e.children,t.children)}function yP(e,t){return e===t||lP(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&TP.compareManyFields(e.children,t.children)}function bP(e,t){return e===t||lP(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&TP.visit(e.indices,t.indices)&&TP.visit(e.dictionary,t.dictionary)}function xP(e,t){return e===t||lP(e,t)&&e.unit===t.unit}function SP(e,t){return e===t||lP(e,t)&&e.unit===t.unit}function CP(e,t){return e===t||lP(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&TP.compareManyFields(e.children,t.children)}function wP(e,t){return e===t||lP(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&TP.compareManyFields(e.children,t.children)}cP.prototype.visitNull=uP,cP.prototype.visitBool=uP,cP.prototype.visitInt=dP,cP.prototype.visitInt8=dP,cP.prototype.visitInt16=dP,cP.prototype.visitInt32=dP,cP.prototype.visitInt64=dP,cP.prototype.visitUint8=dP,cP.prototype.visitUint16=dP,cP.prototype.visitUint32=dP,cP.prototype.visitUint64=dP,cP.prototype.visitFloat=fP,cP.prototype.visitFloat16=fP,cP.prototype.visitFloat32=fP,cP.prototype.visitFloat64=fP,cP.prototype.visitUtf8=uP,cP.prototype.visitLargeUtf8=uP,cP.prototype.visitBinary=uP,cP.prototype.visitLargeBinary=uP,cP.prototype.visitFixedSizeBinary=pP,cP.prototype.visitDate=mP,cP.prototype.visitDateDay=mP,cP.prototype.visitDateMillisecond=mP,cP.prototype.visitTimestamp=hP,cP.prototype.visitTimestampSecond=hP,cP.prototype.visitTimestampMillisecond=hP,cP.prototype.visitTimestampMicrosecond=hP,cP.prototype.visitTimestampNanosecond=hP,cP.prototype.visitTime=gP,cP.prototype.visitTimeSecond=gP,cP.prototype.visitTimeMillisecond=gP,cP.prototype.visitTimeMicrosecond=gP,cP.prototype.visitTimeNanosecond=gP,cP.prototype.visitDecimal=uP,cP.prototype.visitList=_P,cP.prototype.visitStruct=vP,cP.prototype.visitUnion=yP,cP.prototype.visitDenseUnion=yP,cP.prototype.visitSparseUnion=yP,cP.prototype.visitDictionary=bP,cP.prototype.visitInterval=xP,cP.prototype.visitIntervalDayTime=xP,cP.prototype.visitIntervalYearMonth=xP,cP.prototype.visitDuration=SP,cP.prototype.visitDurationSecond=SP,cP.prototype.visitDurationMillisecond=SP,cP.prototype.visitDurationMicrosecond=SP,cP.prototype.visitDurationNanosecond=SP,cP.prototype.visitFixedSizeList=CP,cP.prototype.visitMap=wP;var TP=new cP;function EP(e,t){return TP.compareSchemas(e,t)}function DP(e,t){return TP.visit(e,t)}function OP(e){let t=e.type,n=new(sP.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(OP(Object.assign(Object.assign({},i),{type:t})))}}return n}function kP(e,t){if(e instanceof Gj||e instanceof _M||e.type instanceof RO||ArrayBuffer.isView(e))return yM(e);let n=[...jP({type:t??AP(e),nullValues:[null]})(e)],r=n.length===1?n[0]:n.reduce((e,t)=>e.concat(t));return RO.isDictionary(r.type)?r.memoize():r}function AP(e){if(e.length===0)return new zO;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 QO;if(a+t===e.length)return new vk(new tk,new UO);if(o+t===e.length)return new WO;if(s+t===e.length)return new rk;if(c+t===e.length)return new ck;if(n+t===e.length){let t=e,n=AP(t[t.findIndex(e=>e!=null)]);if(t.every(e=>e==null||DP(n,AP(e))))return new dk(new FM(``,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 FM(e,AP([n[e]]),!0));return new fk([...t.values()])}throw TypeError(`Unable to infer Vector type from input values, explicit type declaration expected.`)}function jP(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=OP(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 MP(e,t){return NP(e,t.map(e=>e.data.concat()))}function NP(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=PP(n,o,u,t,i),o>0&&(r[a++]=qj({type:new fk(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new RP(e,t))]}function PP(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)??qj({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var FP,IP=class e{constructor(...t){if(t.length===0)return this.batches=[],this.schema=new PM([]),this._offsets=[0],this;let n,r;t[0]instanceof PM&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());let i=t=>{if(t){if(t instanceof RP)return[t];if(t instanceof e)return t.batches;if(t instanceof Gj){if(t.type instanceof fk)return[new RP(new PM(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 _M([t[e]])),[,i]=MP(n??new PM(e.map((e,t)=>new FM(String(e),r[t].type,r[t].nullable))),r);return i.length===0?[new RP(t)]:i}}return[]},a=t.flatMap(e=>i(e));if(n=n??a[0]?.schema??new PM([]),!(n instanceof PM))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of a){if(!(e instanceof RP))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!EP(n,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=n,this.batches=a,this._offsets=r??Zj(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=Xj(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Ej(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?pM.visit(new _M(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`,
69
+ `)}\n]`}concat(...t){let n=this.schema;return new e(n,this.data.concat(t.flatMap(({data:e})=>e)).map(e=>new RP(n,e)))}slice(t,n){let r=this.schema;return[t,n]=Tj({length:this.numRows},t,n),new e(r,Qj(this.data,this._offsets,t,n).map(e=>new RP(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=qj({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new _M(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 _M([qj({type:new zO,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]=MP(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(...MP(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)))}};FP=Symbol.toStringTag,IP[FP]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=tM(eM),e.get=tM(gj.getVisitFn(Z.Struct)),e.set=nM(bA.getVisitFn(Z.Struct)),e.indexOf=rM(lM.getVisitFn(Z.Struct)),`Table`))(IP.prototype);var LP,RP=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof PM)||([,this.data=qj({nullCount:0,type:new fk(this.schema.fields),children:this.schema.fields.map(e=>qj({type:e.type,nullCount:0}))})]=e,!(this.data instanceof Gj)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=zP(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]=FM.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new PM(n),o=qj({type:new fk(n),length:i,children:r,nullCount:0});[this.schema,this.data]=zP(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||=BP(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 gj.visit(this.data,e)}at(e){return this.get(Ej(e,this.numRows))}set(e,t){return bA.visit(this.data,e,t)}indexOf(e,t){return lM.visit(this.data,e,t)}[Symbol.iterator](){return pM.visit(new _M([this.data]))}toArray(){return[...this]}concat(...e){return new IP(this.schema,[this,...e])}slice(t,n){let[r]=new _M([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 _M([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 _M([qj({type:new zO,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 PM(e,new Map(this.schema.metadata)),i=qj({type:new fk(e),children:a})}return new e(r,i)}select(t){let n=this.schema.select(t),r=new fk(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,qj({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,qj({type:new fk(n.fields),length:this.numRows,children:r}))}};LP=Symbol.toStringTag,RP[LP]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(RP.prototype);function zP(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)??qj({type:s.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),qj({type:new fk(r),length:n,children:i})]}function BP(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||[]])BP(i.children,e?.children,n);if(RO.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 VP=class extends RP{constructor(e){let t=e.fields.map(e=>qj({type:e.type})),n=qj({type:new fk(e.fields),nullCount:0,children:t});super(e,n)}},HP=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):oD.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):$D.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 AD).__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,oD.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,$D.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)}},UP=new class extends bk{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return WD.startNull(t),WD.endNull(t)}visitInt(e,t){return OD.startInt(t),OD.addBitWidth(t,e.bitWidth),OD.addIsSigned(t,e.isSigned),OD.endInt(t)}visitFloat(e,t){return RD.startFloatingPoint(t),RD.addPrecision(t,e.precision),RD.endFloatingPoint(t)}visitBinary(e,t){return jD.startBinary(t),jD.endBinary(t)}visitLargeBinary(e,t){return BD.startLargeBinary(t),BD.endLargeBinary(t)}visitBool(e,t){return MD.startBool(t),MD.endBool(t)}visitUtf8(e,t){return YD.startUtf8(t),YD.endUtf8(t)}visitLargeUtf8(e,t){return VD.startLargeUtf8(t),VD.endLargeUtf8(t)}visitDecimal(e,t){return PD.startDecimal(t),PD.addScale(t,e.scale),PD.addPrecision(t,e.precision),PD.addBitWidth(t,e.bitWidth),PD.endDecimal(t)}visitDate(e,t){return ND.startDate(t),ND.addUnit(t,e.unit),ND.endDate(t)}visitTime(e,t){return KD.startTime(t),KD.addUnit(t,e.unit),KD.addBitWidth(t,e.bitWidth),KD.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return qD.startTimestamp(t),qD.addUnit(t,e.unit),n!==void 0&&qD.addTimezone(t,n),qD.endTimestamp(t)}visitInterval(e,t){return zD.startInterval(t),zD.addUnit(t,e.unit),zD.endInterval(t)}visitDuration(e,t){return FD.startDuration(t),FD.addUnit(t,e.unit),FD.endDuration(t)}visitList(e,t){return HD.startList(t),HD.endList(t)}visitStruct(e,t){return GD.startStruct_(t),GD.endStruct_(t)}visitUnion(e,t){JD.startTypeIdsVector(t,e.typeIds.length);let n=JD.createTypeIdsVector(t,e.typeIds);return JD.startUnion(t),JD.addMode(t,e.mode),JD.addTypeIds(t,n),JD.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return kD.startDictionaryEncoding(t),kD.addId(t,BigInt(e.id)),kD.addIsOrdered(t,e.isOrdered),n!==void 0&&kD.addIndexType(t,n),kD.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return ID.startFixedSizeBinary(t),ID.addByteWidth(t,e.byteWidth),ID.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return LD.startFixedSizeList(t),LD.addListSize(t,e.listSize),LD.endFixedSizeList(t)}visitMap(e,t){return UD.startMap(t),UD.addKeysSorted(t,e.keysSorted),UD.endMap(t)}};function WP(e,t=new Map){return new PM(qP(e,t),$P(e.metadata),t)}function GP(e){return new aF(e.count,YP(e.columns),XP(e.columns))}function KP(e){return new oF(GP(e.data),e.id,e.isDelta)}function qP(e,t){return(e.fields||[]).filter(Boolean).map(e=>FM.fromJSON(e,t))}function JP(e,t){return(e.children||[]).filter(Boolean).map(e=>FM.fromJSON(e,t))}function YP(e){return(e||[]).reduce((e,t)=>[...e,new cF(t.count,ZP(t.VALIDITY)),...YP(t.children)],[])}function XP(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){let r=e[n];r.VALIDITY&&t.push(new sF(t.length,r.VALIDITY.length)),r.TYPE_ID&&t.push(new sF(t.length,r.TYPE_ID.length)),r.OFFSET&&t.push(new sF(t.length,r.OFFSET.length)),r.DATA&&t.push(new sF(t.length,r.DATA.length)),t=XP(r.children,t)}return t}function ZP(e){return(e||[]).reduce((e,t)=>e+ +(t===0),0)}function QP(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=tF(e,JP(e,t)),i=new FM(e.name,o,e.nullable,$P(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?eF(r):new UO,s=new vk(t.get(n),r,n,a.isOrdered),i=new FM(e.name,s,e.nullable,$P(e.metadata))):(r=(r=a.indexType)?eF(r):new UO,t.set(n,o=tF(e,JP(e,t))),s=new vk(o,r,n,a.isOrdered),i=new FM(e.name,s,e.nullable,$P(e.metadata))),i||null}function $P(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function eF(e){return new BO(e.isSigned,e.bitWidth)}function tF(e,t){let n=e.type.name;switch(n){case`NONE`:return new zO;case`null`:return new zO;case`binary`:return new $O;case`largebinary`:return new ek;case`utf8`:return new tk;case`largeutf8`:return new nk;case`bool`:return new rk;case`list`:return new dk((t||[])[0]);case`struct`:return new fk(t||[]);case`struct_`:return new fk(t||[])}switch(n){case`int`:{let t=e.type;return new BO(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new YO(cD[t.precision])}case`decimal`:{let t=e.type;return new ik(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new ak(lD[t.unit])}case`time`:{let t=e.type;return new ok(uD[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new sk(uD[t.unit],t.timezone)}case`interval`:{let t=e.type;return new lk(dD[t.unit])}case`duration`:{let t=e.type;return new uk(uD[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase();return new pk(sD[r.toUpperCase()+i.join(``)],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new mk(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new hk(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new gk((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var nF=vD,rF=_D,iF=class e{static fromJSON(t,n){let r=new e(0,oD.V5,n);return r._createHeader=lF(t,n),r}static decode(t){t=new rF(WE(t));let n=HP.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=uF(n,a),o}static encode(e){let t=new nF,n=-1;return e.isSchema()?n=PM.encode(t,e.header()):e.isRecordBatch()?n=aF.encode(t,e.header()):e.isDictionaryBatch()&&(n=oF.encode(t,e.header())),HP.startMessage(t),HP.addVersion(t,oD.V5),HP.addHeader(t,n),HP.addHeaderType(t,e.headerType),HP.addBodyLength(t,BigInt(e.bodyLength)),HP.finishMessageBuffer(t,HP.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof PM)return new e(0,oD.V5,$D.Schema,t);if(t instanceof aF)return new e(n,oD.V5,$D.RecordBatch,t);if(t instanceof oF)return new e(n,oD.V5,$D.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===$D.Schema}isRecordBatch(){return this.headerType===$D.RecordBatch}isDictionaryBatch(){return this.headerType===$D.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=rO(e)}},aF=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=rO(e)}},oF=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=rO(t)}},sF=class{constructor(e,t){this.offset=rO(e),this.length=rO(t)}},cF=class{constructor(e,t){this.length=rO(e),this.nullCount=rO(t)}};function lF(e,t){return(()=>{switch(t){case $D.Schema:return PM.fromJSON(e);case $D.RecordBatch:return aF.fromJSON(e);case $D.DictionaryBatch:return oF.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${$D[t]}, type: ${t} }`)})}function uF(e,t){return(()=>{switch(t){case $D.Schema:return PM.decode(e.header(new QD),new Map,e.version());case $D.RecordBatch:return aF.decode(e.header(new wD),e.version());case $D.DictionaryBatch:return oF.decode(e.header(new TD),e.version())}throw Error(`Unrecognized Message type: { name: ${$D[t]}, type: ${t} }`)})}FM.encode=TF,FM.decode=bF,FM.fromJSON=QP,PM.encode=wF,PM.decode=dF,PM.fromJSON=WP,aF.encode=EF,aF.decode=fF,aF.fromJSON=GP,oF.encode=DF,oF.decode=pF,oF.fromJSON=KP,cF.encode=OF,cF.decode=hF,sF.encode=kF,sF.decode=mF;function dF(e,t=new Map,n=oD.V5){return new PM(vF(e,t),xF(e),t,n)}function fF(e,t=oD.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new aF(e.length(),gF(e),_F(e,t))}function pF(e,t=oD.V5){return new oF(aF.decode(e.data(),t),e.id(),e.isDelta())}function mF(e){return new sF(e.offset(),e.length())}function hF(e){return new cF(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]=cF.decode(n));return t}function _F(e,t){let n=[];for(let r,i=-1,a=-1,o=e.buffersLength();++i<o;)(r=e.buffers(i))&&(t<oD.V4&&(r.bb_pos+=8*(i+1)),n[++a]=sF.decode(r));return n}function vF(e,t){let n=[];for(let r,i=-1,a=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++a]=FM.decode(r,t));return n}function yF(e,t){let n=[];for(let r,i=-1,a=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++a]=FM.decode(r,t));return n}function bF(e,t){let n,r,i,a,o,s;return!t||!(s=e.dictionary())?(i=CF(e,yF(e,t)),r=new FM(e.name(),i,e.nullable(),xF(e))):t.has(n=rO(s.id()))?(a=(a=s.indexType())?SF(a):new UO,o=new vk(t.get(n),a,n,s.isOrdered()),r=new FM(e.name(),o,e.nullable(),xF(e))):(a=(a=s.indexType())?SF(a):new UO,t.set(n,i=CF(e,yF(e,t))),o=new vk(i,a,n,s.isOrdered()),r=new FM(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 SF(e){return new BO(e.isSigned(),e.bitWidth())}function CF(e,t){let n=e.typeType();switch(n){case XD.NONE:return new zO;case XD.Null:return new zO;case XD.Binary:return new $O;case XD.LargeBinary:return new ek;case XD.Utf8:return new tk;case XD.LargeUtf8:return new nk;case XD.Bool:return new rk;case XD.List:return new dk((t||[])[0]);case XD.Struct_:return new fk(t||[])}switch(n){case XD.Int:{let t=e.type(new OD);return new BO(t.isSigned(),t.bitWidth())}case XD.FloatingPoint:return new YO(e.type(new RD).precision());case XD.Decimal:{let t=e.type(new PD);return new ik(t.scale(),t.precision(),t.bitWidth())}case XD.Date:return new ak(e.type(new ND).unit());case XD.Time:{let t=e.type(new KD);return new ok(t.unit(),t.bitWidth())}case XD.Timestamp:{let t=e.type(new qD);return new sk(t.unit(),t.timezone())}case XD.Interval:return new lk(e.type(new zD).unit());case XD.Duration:return new uk(e.type(new FD).unit());case XD.Union:{let n=e.type(new JD);return new pk(n.mode(),n.typeIdsArray()||[],t||[])}case XD.FixedSizeBinary:return new mk(e.type(new ID).byteWidth());case XD.FixedSizeList:return new hk(e.type(new LD).listSize(),(t||[])[0]);case XD.Map:{let n=e.type(new UD);return new gk((t||[])[0],n.keysSorted())}}throw Error(`Unrecognized type: "${XD[n]}" (${n})`)}function wF(e,t){let n=t.fields.map(t=>FM.encode(e,t));QD.startFieldsVector(e,n.length);let r=QD.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?QD.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return AD.startKeyValue(e),AD.addKey(e,r),AD.addValue(e,i),AD.endKeyValue(e)})):-1;return QD.startSchema(e),QD.addFields(e,r),QD.addEndianness(e,AF?ED.Little:ED.Big),i!==-1&&QD.addCustomMetadata(e,i),QD.endSchema(e)}function TF(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;RO.isDictionary(a)?(o=a.dictionary.typeId,i=UP.visit(a,e),r=UP.visit(a.dictionary,e)):r=UP.visit(a,e);let s=(a.children||[]).map(t=>FM.encode(e,t)),c=ZD.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?ZD.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return AD.startKeyValue(e),AD.addKey(e,r),AD.addValue(e,i),AD.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),ZD.startField(e),ZD.addType(e,r),ZD.addTypeType(e,o),ZD.addChildren(e,c),ZD.addNullable(e,!!t.nullable),n!==-1&&ZD.addName(e,n),i!==-1&&ZD.addDictionary(e,i),l!==-1&&ZD.addCustomMetadata(e,l),ZD.endField(e)}function EF(e,t){let n=t.nodes||[],r=t.buffers||[];wD.startNodesVector(e,n.length);for(let t of n.slice().reverse())cF.encode(e,t);let i=e.endVector();wD.startBuffersVector(e,r.length);for(let t of r.slice().reverse())sF.encode(e,t);let a=e.endVector();return wD.startRecordBatch(e),wD.addLength(e,BigInt(t.length)),wD.addNodes(e,i),wD.addBuffers(e,a),wD.endRecordBatch(e)}function DF(e,t){let n=aF.encode(e,t.data);return TD.startDictionaryBatch(e),TD.addId(e,BigInt(t.id)),TD.addIsDelta(e,t.isDelta),TD.addData(e,n),TD.endDictionaryBatch(e)}function OF(e,t){return CD.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function kF(e,t){return SD.createBuffer(e,BigInt(t.offset),BigInt(t.length))}var AF=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),jF=e=>`Expected ${$D[e]} Message in stream, but was null or length 0.`,MF=e=>`Header pointer of flatbuffer-encoded ${$D[e]} Message is null or length 0.`,NF=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,PF=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`,FF=class{constructor(e){this.source=e instanceof JM?e:new JM(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?UM: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(jF(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=WE(this.source.read(e));if(t.byteLength<e)throw Error(PF(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()}readSchema(e=!1){let t=$D.Schema,n=this.readMessage(t)?.header();if(e&&!n)throw Error(MF(t));return n}readMetadataLength(){let e=this.source.read(4),t=(e&&new _D(e))?.readInt32(0)||0;return{done:t===0,value:t}}readMetadata(e){let t=this.source.read(e);if(!t)return UM;if(t.byteLength<e)throw Error(NF(e,t.byteLength));return{done:!1,value:iF.decode(t)}}},IF=class{constructor(e,t){this.source=e instanceof YM?e:kE(e)?new $M(e,t):new YM(e)}[Symbol.asyncIterator](){return this}next(){return uE(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?UM:e})}throw(e){return uE(this,void 0,void 0,function*(){return yield this.source.throw(e)})}return(e){return uE(this,void 0,void 0,function*(){return yield this.source.return(e)})}readMessage(e){return uE(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(jF(e));return t.value})}readMessageBody(e){return uE(this,void 0,void 0,function*(){if(e<=0)return new Uint8Array;let t=WE(yield this.source.read(e));if(t.byteLength<e)throw Error(PF(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()})}readSchema(){return uE(this,arguments,void 0,function*(e=!1){let t=$D.Schema,n=(yield this.readMessage(t))?.header();if(e&&!n)throw Error(MF(t));return n})}readMetadataLength(){return uE(this,void 0,void 0,function*(){let e=yield this.source.read(4),t=(e&&new _D(e))?.readInt32(0)||0;return{done:t===0,value:t}})}readMetadata(e){return uE(this,void 0,void 0,function*(){let t=yield this.source.read(e);if(!t)return UM;if(t.byteLength<e)throw Error(NF(e,t.byteLength));return{done:!1,value:iF.decode(t)}})}},LF=class extends FF{constructor(e){super(new Uint8Array),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof WM?e:new WM(e)}next(){let{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:iF.fromJSON(e.schema,$D.Schema)};if(this._dictionaryIndex<e.dictionaries.length){let t=e.dictionaries[this._dictionaryIndex++];return this._body=t.data.columns,{done:!1,value:iF.fromJSON(t,$D.DictionaryBatch)}}if(this._batchIndex<e.batches.length){let t=e.batches[this._batchIndex++];return this._body=t.columns,{done:!1,value:iF.fromJSON(t,$D.RecordBatch)}}return this._body=[],UM}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(jF(e));return t.value}readSchema(){let e=$D.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(MF(e));return n}},RF=`ARROW1`,zF=new Uint8Array(6);for(let e=0;e<6;e+=1)zF[e]=RF.codePointAt(e);function BF(e,t=0){for(let n=-1,r=zF.length;++n<r;)if(zF[n]!==e[t+n])return!1;return!0}var VF=zF.length,HF=VF+4,UF=VF*2+4,WF=class e extends GM{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 wE(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 QE.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return QE.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:DE(t)?iI(t):kE(t)?sI(t):wE(t)?uE(this,void 0,void 0,function*(){return yield e.from(yield t)}):AE(t)||NE(t)||FE(t)||EE(t)?oI(new YM(t)):aI(new JM(t))}static readAll(t){return t instanceof e?t.isSync()?nI(t):rI(t):DE(t)||ArrayBuffer.isView(t)||TE(t)||OE(t)?nI(t):rI(t)}},GF=class extends WF{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return pE(this,arguments,function*(){yield fE(yield*mE(hE(this[Symbol.iterator]())))})}},KF=class extends WF{constructor(e){super(e),this._impl=e}readAll(){return uE(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,o=hE(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]()}},qF=class extends GF{constructor(e){super(e),this._impl=e}},JF=class extends KF{constructor(e){super(e),this._impl=e}},YF=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=qj({type:new fk(this.schema.fields),length:e.length,children:n});return new RP(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 _M(c)):new _M(c)).memoize()}_loadVectors(e,t,n){return new cN(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},XF=class extends YF{constructor(e,t){super(t),this._reader=DE(e)?new LF(this._handle=e):new FF(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=tI(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):UM}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):UM}next(){if(this.closed)return UM;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 VP(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},ZF=class extends YF{constructor(e,t){super(t),this._reader=new IF(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return uE(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 uE(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=tI(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return uE(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):UM})}return(e){return uE(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):UM})}next(){return uE(this,void 0,void 0,function*(){if(this.closed)return UM;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 VP(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return uE(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},QF=class extends XF{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 QM?e:new QM(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($D.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($D.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-HF,n=e.readInt32(t),r=e.readAt(t-n,n);return BM.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}},$F=class extends ZF{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 $M?e:new $M(e,n),r)}isFile(){return!0}isAsync(){return!0}open(e){let t=Object.create(null,{open:{get:()=>super.open}});return uE(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 uE(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($D.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 uE(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($D.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 uE(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-HF,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return BM.decode(r)})}_readNextMessageAndValidate(e){return uE(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})}},eI=class extends XF{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 tI(e,t){return t&&typeof t.autoDestroy==`boolean`?t.autoDestroy:e.autoDestroy}function*nI(e){let t=WF.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function rI(e){return pE(this,arguments,function*(){let t=yield fE(WF.from(e));try{if(!(yield fE(t.open({autoDestroy:!1}))).closed)do yield yield fE(t);while(!(yield fE(t.reset().open())).closed)}finally{yield fE(t.cancel())}})}function iI(e){return new GF(new eI(e))}function aI(e){let t=e.peek(VF+7&-8);return t&&t.byteLength>=4?BF(t)?new qF(new QF(e.read())):new GF(new XF(e)):new GF(new XF(function*(){}()))}function oI(e){return uE(this,void 0,void 0,function*(){let t=yield e.peek(VF+7&-8);return t&&t.byteLength>=4?BF(t)?new qF(new QF(yield e.read())):new KF(new ZF(e)):new KF(new ZF(function(){return pE(this,arguments,function*(){})}()))})}function sI(e){return uE(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new $M(e,t);return t>=UF&&BF(yield n.readAt(0,VF+7&-8))?new JF(new $F(n)):new KF(new ZF(n))})}var cI=class e extends bk{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof RP?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 _M)return this.visitMany(e.data),this;let{type:t}=e;if(!RO.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(RO.isUnion(t))this.nodes.push(new cF(n,0));else{let{nullCount:r}=e;RO.isNull(t)||lI.call(this,r<=0?new Uint8Array:zj(e.offset,n,e.nullBitmap)),this.nodes.push(new cF(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 lI(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new sF(this._byteLength,t)),this._byteLength+=t,this}function uI(e){let{type:t,length:n,typeIds:r,valueOffsets:i}=e;if(lI.call(this,r),t.mode===sD.Sparse)return hI.call(this,e);if(t.mode===sD.Dense){if(e.offset<=0)return lI.call(this,i),hI.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);lI.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 dI(e){let t;return e.nullCount>=e.length?lI.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?lI.call(this,zj(e.offset,e.length,t)):lI.call(this,Bj(e.values))}function fI(e){return lI.call(this,e.values.subarray(0,e.length*e.stride))}function pI(e){let{length:t,values:n,valueOffsets:r}=e,i=rO(r[0]),a=rO(r[t]),o=Math.min(a-i,n.byteLength-i);return lI.call(this,XE(-i,t+1,r)),lI.call(this,n.subarray(i,i+o)),this}function mI(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return lI.call(this,XE(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function hI(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}cI.prototype.visitBool=dI,cI.prototype.visitInt=fI,cI.prototype.visitFloat=fI,cI.prototype.visitUtf8=pI,cI.prototype.visitLargeUtf8=pI,cI.prototype.visitBinary=pI,cI.prototype.visitLargeBinary=pI,cI.prototype.visitFixedSizeBinary=fI,cI.prototype.visitDate=fI,cI.prototype.visitTimestamp=fI,cI.prototype.visitTime=fI,cI.prototype.visitDecimal=fI,cI.prototype.visitList=mI,cI.prototype.visitStruct=hI,cI.prototype.visitUnion=uI,cI.prototype.visitInterval=fI,cI.prototype.visitDuration=fI,cI.prototype.visitFixedSizeList=mI,cI.prototype.visitMap=mI;var gI=class extends GM{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 qM,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,CE(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 wE(e)?e.then(e=>this.writeAll(e)):EE(e)?bI(this,e):yI(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 qM?this._sink=e:(this._sink=new qM,e&&ME(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&PE(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||!EP(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 IP&&!(t=e.schema)||e instanceof RP&&!(t=e.schema))return this.finish()&&void 0;if(t&&!EP(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof RP?e instanceof VP||this._writeRecordBatch(e):e instanceof IP?this.writeAll(e.batches):TE(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=iF.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===$D.RecordBatch?this._recordBatchBlocks.push(new HM(o,e.bodyLength,this._position)):e.headerType===$D.DictionaryBatch&&this._dictionaryBlocks.push(new HM(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=WE(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(iF.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(zF)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=cI.assemble(e),a=new aF(e.numRows,n,r),o=iF.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}=cI.assemble(new _M([e])),s=new oF(new aF(e.length,i,a),t,n),c=iF.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}},_I=class e extends gI{static writeAll(t,n){let r=new e(n);return wE(t)?t.then(e=>r.writeAll(e)):EE(t)?bI(r,t):yI(r,t)}},vI=class e extends gI{static writeAll(t){let n=new e;return wE(t)?t.then(e=>n.writeAll(e)):EE(t)?bI(n,t):yI(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=BM.encode(new BM(e,oD.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function yI(e,t){let n=t;t instanceof IP&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function bI(e,t){return uE(this,void 0,void 0,function*(){var n,r,i,a,o,s,c;try{for(n=!0,r=hE(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`?_I:vI).writeAll(e).toUint8Array(!0)}var SI=Object.create,CI=Object.defineProperty,wI=Object.getOwnPropertyDescriptor,TI=Object.getOwnPropertyNames,EI=Object.getPrototypeOf,DI=Object.prototype.hasOwnProperty,OI=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kI=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of TI(t))!DI.call(e,i)&&i!==n&&CI(e,i,{get:()=>t[i],enumerable:!(r=wI(t,i))||r.enumerable});return e},AI=(e,t,n)=>(n=e==null?{}:SI(EI(e)),kI(t||!e||!e.__esModule?CI(n,`default`,{value:e,enumerable:!0}):n,e)),jI=OI((e,t)=>{t.exports=Worker}),MI=(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))(MI||{}),NI=(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))(NI||{}),PI=(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))(PI||{}),FI=(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))(FI||{}),II=(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))(II||{}),LI=(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))(LI||{}),RI=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},zI=(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))(zI||{}),BI=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=WF.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new IP(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 VI(this._bindings,this._conn,n),i=await WF.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 HI(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)}},VI=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}},HI=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=WF.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new IP(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new VI(this.bindings,this.connectionId,t),r=await WF.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},UI=(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))(UI||{}),WI=(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))(WI||{}),GI=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 KI(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:KI(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=>qI(e.name,e.type))};case Z.Map:{let t=e;return{sqlType:`map`,keyType:KI(t.keyType),valueType:KI(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 qI(e,t){let n=KI(t);return n.name=e,n}var JI=/'(opfs:\/\/\S*?)'/g,YI=/(opfs:\/\/\S*?)/g;function XI(e){return e.search(YI)>-1}function ZI(e){return[...e.matchAll(JI)].map(e=>e[1])}var QI=new TextEncoder,$I=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 GI(`RESET`,null);return await this.postTask(e)}async ping(){let e=new GI(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new GI(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(e){let t=new GI(`DROP_FILES`,e);return await this.postTask(t)}async flushFiles(){let e=new GI(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new GI(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new GI(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new GI(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){this._config=e;let t=new GI(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new GI(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new GI(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new BI(this,e)}async disconnect(e){let t=new GI(`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 GI(`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 GI(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new GI(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new GI(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new GI(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new GI(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new GI(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new GI(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new GI(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new GI(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new GI(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=QI.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new GI(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new GI(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new GI(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new GI(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new GI(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new GI(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new GI(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new GI(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new GI(`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(qI(t,r))}n.columnsFlat=e,delete n.columns}let r=new GI(`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(qI(t,r))}n.columnsFlat=e,delete n.columns}let r=new GI(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}shouldOPFSFileHandling(){return XI(this.config.path??``)?this.config.opfs?.fileHandling==`auto`:!1}async registerOPFSFileFromSQL(e){let t=ZI(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 eL(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}eL();var tL=(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))(tL||{}),nL={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`}}};nL.name,nL.version;var rL=nL.version.split(`.`);rL[0],rL[1],rL[2],AI(jI());var iL=``+new URL(`assets/duckdb-browser-eh.worker--3HUwN9R.js`,import.meta.url).href,aL=``+new URL(`assets/duckdb-eh-D-nnNw7L.wasm.gz`,import.meta.url).href;async function oL(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 sL=null;function cL(){return sL||(sL=(async()=>{let e=e=>new URL(e,location.href).href,t=URL.createObjectURL(new Blob([`importScripts(${JSON.stringify(e(iL))});`],{type:`text/javascript`})),n=new Worker(t),r=new $I(new RI(PI.WARNING),n),i=await oL(e(aL));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})(),sL)}function lL(e){return`"`+e.replace(/"/g,`""`)+`"`}function uL(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=lL(e.xcol),r=lL(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 ${lL(e.table)} WHERE ${n} BETWEEN ? AND ? GROUP BY 1 ORDER BY 1`,params:[e.x0,t,e.maxPoints,e.x0,e.x1]}}function dL(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=lL(e.xcol),r=lL(e.table);return{sql:`SELECT least(floor((${n} - ?) / ?), ? - 1) AS b, ${e.ycols.map((e,t)=>`min(${lL(e)}) AS y${t}lo, max(${lL(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 fL=`__kym_bin`;function pL(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=lL(e.xcol),n=lL(e.srcTable);return`CREATE OR REPLACE TABLE ${lL(e.dstTable)} AS SELECT ${`CAST(floor((${t} - ${gL(e.x0base)}) / ${gL(e.binWidth)}) AS BIGINT)`} AS ${fL}, ${e.ycols.map(e=>`min(${lL(e)}) AS ${lL(e+`__lo`)}, max(${lL(e)}) AS ${lL(e+`__hi`)}`).join(`, `)} FROM ${n} WHERE ${t} IS NOT NULL GROUP BY 1`}function mL(e){let t=lL(e.srcTable);return`CREATE OR REPLACE TABLE ${lL(e.dstTable)} AS SELECT CAST(floor(${fL} / 2.0) AS BIGINT) AS ${fL}, ${e.ycols.map(e=>`min(${lL(e+`__lo`)}) AS ${lL(e+`__lo`)}, max(${lL(e+`__hi`)}) AS ${lL(e+`__hi`)}`).join(`, `)} FROM ${t} GROUP BY 1`}function hL(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=lL(e.levelTable);return{sql:`SELECT least(greatest(CAST(floor(? + ${fL} * ?) AS BIGINT), 0), ?) AS b, ${e.ycols.map((e,t)=>`min(${lL(e+`__lo`)}) AS y${t}lo, max(${lL(e+`__hi`)}) AS y${t}hi`).join(`, `)} FROM ${o} WHERE ${fL} BETWEEN ? AND ? GROUP BY 1 ORDER BY 1`,params:[r,n,e.maxPoints-1,i,a]}}function gL(e){if(!Number.isFinite(e))throw Error(`num: value must be finite`);return Number.isInteger(e)?String(e):e.toExponential(17)}function _L(e){let t=lL(e.table);return e.range?{sql:`SELECT count(*) AS n FROM ${t} WHERE ${lL(e.range.xcol)} BETWEEN ? AND ?`,params:[e.range.x0,e.range.x1]}:{sql:`SELECT count(*) AS n FROM ${t}`,params:[]}}function vL(e){if(!Number.isInteger(e.stride)||e.stride<1)throw Error(`buildSampleRowsSql: stride must be a positive integer`);let t=lL(e.table),n=e.range?` WHERE ${lL(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 yL(e){return`'`+e.replace(/'/g,`''`)+`'`}function bL(e){let t=e.columnNames.map(yL).join(`, `),n=e.delim===` `?`'\\t'`:yL(e.delim),r=e.decimalComma?`decimal_separator=',', `:``;return`SELECT * FROM read_csv(${yL(e.handle)}, header=false, skip=${e.dataStartRow}, delim=${n}, `+r+`names=[${t}], auto_type_candidates=['DOUBLE', 'VARCHAR'])`}function xL(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 SL=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}},CL=0,wL=()=>`t_${++CL}`,TL=5e4,EL=65536,DL=512,OL=2;function kL(e){return e<1?1:2**Math.floor(Math.log2(e))}var AL=class e{#e;#t;#n;#r;#i=new SL(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 cL(),i=await r.connect(),a=await t.slice(0,256*1024).text(),o=u(a),s=h(a),c=y(o,s.headerRow),l=s.unitsRow===null?``:o[s.unitsRow]??``,d=D(o[s.headerRow]??``),f=C(o.slice(s.dataStartRow,s.dataStartRow+10),d);n?.({phase:`reading`,message:`Reading file…`});let p=new Uint8Array(await t.arrayBuffer());await r.dropFile(`input.csv`).catch(()=>{}),await r.registerFileBuffer(`input.csv`,p),n?.({phase:`parsing`,message:`Parsing CSV…`});let m=wL(),g=bL({handle:`input.csv`,columnNames:c,delim:d,dataStartRow:s.dataStartRow,decimalComma:f});await i.query(`CREATE OR REPLACE TABLE ${lL(m)} AS ${g}`),await r.dropFile(`input.csv`).catch(()=>{});let _=l?l.split(d).map(e=>e.trim()):[],v=new Map;c.forEach((e,t)=>v.set(e,_[t]??``));let b=await e.attach(i,m,v);return n?.({phase:`done`,message:`Ready.`}),b}static async attach(t,n,r){return new e(t,(await t.query(`DESCRIBE ${lL(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}=uL({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 xL((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)??dL({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/OL,a=null;for(let t of e.levels)t.binWidth<=i&&(a=t);return a?hL({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 cL()).connect();try{let n=_L({table:this.#n}),r=await t.query(n.sql),i=Number(r.getChild(`n`)?.get(0)??0);if(i<TL)return null;let a=await t.query(`SELECT min(${lL(e)}) AS lo, max(${lL(e)}) AS hi FROM ${lL(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(EL,kL(i));if(u<DL*2)return null;let d=++this.#c,f=[],p=u,m=0,h=`${this.#n}_p${d}_0`;await t.query(pL({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>=DL;){p/=2,m+=1;let e=`${this.#n}_p${d}_${m}`;await t.query(mL({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=_L({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}=vL({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 xBounds(e){if(!this.#r.has(e))return{x0:0,x1:0};let t=await this.#e.query(`SELECT min(${lL(e)}) AS lo, max(${lL(e)}) AS hi FROM ${lL(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 ${lL(e)}`)}catch{}try{await this.#e.query(`DROP TABLE IF EXISTS ${lL(this.#n)}`)}catch{}await this.#e.close()}},jL=1e8,ML=256*1024;function NL(e,t,n=0,r=jL){return e>314572800||n+t>r?`duckdb`:`memory`}function PL(e,t){let n=u(t);t.length<e&&n.length>1&&(n=n.slice(0,-1));try{let t=h(n.join(`
70
+ `)),r=y(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 FL=12e3;async function IL(e,t,n){let r=h(n),a=typeof Worker>`u`?i(n,r):await aE({rawText:n,config:r}),o=new lE(a);return{id:e,name:t,kind:`memory`,source:o,schema:await o.getSchema(),data:a,rawText:n,parseConfig:r}}async function LL(e,t,n,r,i=e=>e.text(),a){let o=h(r),s=typeof Worker>`u`?await oE({rawText:await i(n),config:o},a):await oE({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 RL(e,t,n){let r=await AL.open(t,n),i=await r.getSchema(),a=await r.sampleRows(FL),o={meta:``,columnNames:i.map(e=>e.name),units:i.map(e=>e.unit),rows:a},s=await t.slice(0,ML).text();return{id:e,name:t.name,kind:`duckdb`,source:r,schema:i,data:o,rawText:s,parseConfig:h(s)}}async function zL(e,t,n,r,i=0,a){let o=await t.slice(0,ML).text();return NL(t.size,PL(t.size,o),i)===`memory`?LL(e,t.name,t,o,e=>n(e),a):RL(e,t,r)}function BL(e,t){return e instanceof File&&e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified}async function VL(e,t,n){let r=n.find(e=>e.kind===`memory`&&e.parseConfig&&BL(e.file,t)&&P(e.data.rows));if(!r)return null;let i=await t.slice(0,ML).text();if(!A(r.parseConfig,h(i)))return null;let a={...r.data,rows:R(P(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 HL(e){let t=new Set,n=0;for(let r of e){if(r.kind!==`memory`)continue;let e=P(r.data.rows)??r.data.rows;t.has(e)||(t.add(e),n+=r.data.rows.length*r.data.columnNames.length)}return n}var UL=4096,WL=[`.dat`,`.txt`,`.csv`,`.tsv`],GL=[Be,Ie,te,ue,fe,be,Te],KL=e=>{let t=e.lastIndexOf(`.`);return t<=0?``:e.slice(t).toLowerCase()},qL=e=>{let t=e.lastIndexOf(`.`);return(t<=0?e:e.slice(0,t)).toLowerCase()};async function JL(e){let t=new Uint8Array(await e.slice(0,UL).arrayBuffer()),n=KL(e.name),r=GL.filter(e=>e.extensions.includes(n));for(let n of[...r,...GL.filter(e=>!r.includes(e))])if(n.sniff(t,e.name))return n;return null}async function YL(e){return new Uint8Array(await e.slice(0,UL).arrayBuffer()).includes(0)}async function XL(e){let t=await Promise.all(e.map(JL)),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]&&KL(e.name)===n.ext),o=a.find(e=>qL(e.name)===qL(i.main.name))??(n.anyName&&a.length===1?a[0]:void 0);o&&(i.companions.push(o),r.add(o))}let i=new Set(GL.flatMap(e=>(e.companions??[]).map(e=>e.ext))),a=[];for(let t of e){if(r.has(t))continue;let e=KL(t.name);e===`.dat`&&await YL(t)?a.push({file:t.name,error:Error(`This COMTRADE .dat needs its .cfg file — drop both together.`)}):WL.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 ZL=[...new Set([...WL,...GL.flatMap(e=>[...e.extensions,...(e.companions??[]).map(e=>e.ext)])])];function QL(e){let t=0;for(let n=0;n<e.length;n++)e[n]!==e[n]&&t++;if(t===0)return yM(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 yM(qj({type:new QO,data:e,nullBitmap:n,length:e.length,nullCount:t}))}var $L=122880,eR=class{#e;#t;#n;#r=!1;#i=[];#a=0;#o;rows=0;constructor(e,t,n,r=$L){this.#e=e,this.#t=t,this.#n=new PM(n.map(e=>new FM(e.name,e.text?new tk:new QO,!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?QL(i.subarray(0,t)):kP(i.slice(0,t),new tk)).data[0]});this.#i.push(new RP(this.#n,qj({type:new fk(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 IP(this.#n,this.#i);this.#i=[],this.#a=0,await this.#e.insertArrowTable(e,{name:this.#t,create:!this.#r}),this.#r=!0}},tR=`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 rR(e){let t=e[Symbol.asyncIterator]();return{pull:async()=>{let e=await t.next();return e.done?null:e.value}}}function iR(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(tR)}};return n.map((e,t)=>({pull:()=>a(t)}))}function aR(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 oR=new Int32Array,sR={t:new Float64Array,cols:[],from:0};function cR(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 lR=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=uR(aR(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(tR)}};function uR(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 dR(e,t){let n=e.length,r=e.map(e=>e.t),i=Int32Array.from(e,e=>e.from),a=Int32Array.from(e,e=>cR(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 fR(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 pR(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];fR(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}fR(e,d,u,p,l-1,c[p]),o=c[l-1],t=d[u+l-1]}e.fill(t,o,e.length)}function mR(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 hR(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):oR}function gR(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=cR(i,e,r.from,i.length),o=new Int32Array(a-r.from);if(c.push(hR(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 mR(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),pR(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 _R(e,t,n,r,i,a=!1){let o=e.map((e,r)=>new lR(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=dR(l.map(e=>e.pending[0]??sR),e),n=[t];for(let e=0;e<o.length;e++)n.push(...gR(o[e],t,c[e],u&&c[e],a));d+=t.length,t.length&&await r({length:t.length,columns:n})}return d}var vR=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 yR(e,t,n){return Pe(await e.plan(t,n))}var bR=(e,t,n)=>Math.max(0,Math.min(e,Math.max(1<<20,n),Math.floor(1e8/t)));function xR(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=Ae(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 SR(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 CR(e,t,n){let r=SR(e,t);return r<0?Math.ceil(n/4):r*(1+t.reduce((e,t)=>e+t.channels.length,0))}async function wR(e,t,n,r,i,a,o={}){let s=xR(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=>rR(d(e.streamGroup({...f,selection:[t]},t.group)))):iR(d(e.stream(f)),new Map(i.map((e,t)=>[e.group,t]))),m=SR(n,i),h=a===`memory`?new vR(s,bR(m,s.length,r.size)):null,g=0,_=await _R(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 TR=``+new URL(`assets/importer.worker-D4is7BLf.js`,import.meta.url).href,ER=``+new URL(`assets/h5wasmModule-BCQWU2Gw.js`,import.meta.url).href,DR=()=>new tE(`cancelled`);function OR(){let e=nE(TR);return e.postMessage({type:`init`,h5Url:new URL(ER,location.href).href}),e}var kR=null,AR=e=>{typeof requestIdleCallback==`function`?requestIdleCallback(e,{timeout:5e3}):setTimeout(e,1e3)};function jR(e,t=OR){t===OR&&typeof Worker>`u`||(kR&&kR.make!==t&&(kR.w.terminate(),kR=null),kR??={w:t(),h5:!1,make:t},e&&!kR.h5&&(kR.h5=!0,kR.w.postMessage({type:`warm`})))}function MR(e){if(kR?.make!==e)return{w:e(),rewarm:null};let{w:t,h5:n}=kR;return kR=null,{w:t,rewarm:n}}function NR(e,t,n,r,i){return!r&&typeof Worker>`u`?PR(e,t,n,i):IR(e,t,n,r??OR)}function PR(e,t,n,r=async e=>(await import(`./importers-DivmF3tx.js`)).importerFor(e)){let i=new ne(t.main),a=null,o=null,s=e=>e.catch(e=>{throw n?.aborted?DR():oe(e)});return{plan:()=>s((async()=>(a=await r(e),o=await yR(a,t,i)))()),read:(e,r,c={})=>(i.bytesRead=0,s(wR(a,t,o,i,e,r,{...c,signal:n}))),close(){}}}var FR=3e4;function IR(e,t,n,r){let{w:i,rewarm:a}=MR(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>FR&&p(Error(U))},1e3),h=()=>p(DR());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(DR());return}if(d){a(Error(U));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&&AR(()=>jR(a,r))}}}var LR=12e3,RR=(e,t)=>t.map(t=>({group:t,channels:e.groups[t].channels.map((e,t)=>t)}));function zR(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 BR(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:zR(e,n)}:null,splitKey:r,channels:n.reduce((e,t)=>e+t.channels.length,0),notes:e.notes,meta:e.meta,events:[]}}async function VR(e,t,n,r,i,a){let o={meta:``,columnNames:n.columns.map(e=>e.name),units:n.columns.map(e=>e.unit),rows:R(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 HR(e,t,n,r,i,a,o,s,c){let l=cL().then(e=>e.connect());l.catch(()=>void 0);let u=wL(),d=xR(r,i),f=new eR({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 AL.attach(p,u,new Map(d.map(e=>[e.name,e.unit]))),h=await m.getSchema(),g=await m.sampleRows(LR);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 ${lL(u)}`).catch(()=>void 0),await t?.close().catch(()=>void 0),e}}async function UR(e,t){let{main:n,companions:r}=e,i=NR(e.format,{main:n,companions:r,keys:e.keys},t.signal,t.createWorker,t.find),a=[];try{t.priorInMemoryValues+n.size/8>1e8&&cL().catch(()=>void 0);let o=await i.plan(),s=t.selection??t.initial??RR(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=>CR(o,e,n.size),budget:jL,used:t.priorInMemoryValues,notes:o.notes});if(!e)throw new tE(`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=CR(o,s,n.size),f=l.length>1?`${n.name} · ${o.groups[s[0].group].name}`:n.name,p=BR(o,e.format,s,u),m=crypto.randomUUID();if(NL(0,c,d)===`memory`){let e=await i.read(s,`memory`,{progress:t.onProgress});a.push(await VR(m,f,e,n,r,p)),d+=c}else a.push(await HR(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 tE(`cancelled`):e}finally{i.close()}}function WR(e){return e.filter(e=>e.type===`number`).map(e=>e.name)}function GR(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 KR(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 qR(e){return Math.max(2,Math.min(6,Math.floor(e/64)))}function JR(e,t,n,r){let i=Math.max(e,t)-Math.min(e,t),a=n!==void 0&&n>0&&Number.isFinite(n)?n:KR(i,6);(a<=0||!Number.isFinite(a))&&(a=KR(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 YR(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 XR(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 ZR={[-12]:`p`,[-9]:`n`,[-6]:`µ`,[-3]:`m`,0:``,3:`k`,6:`M`,9:`G`,12:`T`};function QR(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 $R(e,t){if(!Number.isFinite(e))return`—`;if(!(t>0)||!Number.isFinite(t))return ez(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(QR(t/10**r))+ZR[r]}return e.toFixed(QR(t))}function ez(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)+ZR[n]}var tz=[`#fb923c`,`#60a5fa`,`#4ade80`,`#f87171`,`#facc15`,`#22d3ee`,`#f472b6`,`#2dd4bf`,`#94a3b8`,`#a3e635`];function nz(e,t,n,r=tz){let i=r.length>0?r:tz;return e[t]??i[n%i.length]}function rz(e){return[e===`light`?`#000000`:`#ffffff`,...tz.slice(0,9)]}function iz(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:rz(t)}var az=[`class`,`data-theme`,`data-color-scheme`];function oz(e){return e?.closest(`[data-color-scheme]`)??document.documentElement}function sz(e){return oz(e).getAttribute(`data-color-scheme`)===`light`?`light`:`dark`}function cz(e,t){let n=new MutationObserver(t),r=new Set([document.documentElement,oz(e)]);for(let e of r)n.observe(e,{attributes:!0,attributeFilter:az});return()=>n.disconnect()}function lz(e,t){return!!t&&e.composedPath().includes(t)}var uz=[{value:`span`,label:`Span (max − min)`},{value:`mean`,label:`Mean`},{value:`max`,label:`Max`},{value:`min`,label:`Min`}];function dz(e,t){let n=[],r=-1,i=0,a=0,o=0;for(let s=0;s<e.length;s++){let c=e[s][t];typeof c==`number`&&(r<0?(r=0,i=a=c):c<o&&o-c>(a-i)/2?(n.push({start:r,end:s}),r=s,i=a=c):(c<i&&(i=c),c>a&&(a=c)),o=c)}return r>=0&&n.push({start:r,end:e.length}),n}function fz(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=dz(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 pz(e,t){return fz(e,t)[0]??t[0]??``}function mz(e,t,n){if(n&&t.includes(n.channel)&&dz(e,n.channel).length>1)return{...n,metric:t.includes(n.metric)?n.metric:n.channel};let r=fz(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 hz(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 gz(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 _z(e,t){return t.trim()===`s`||/time/i.test(e)}function vz(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?ez(e):e.toFixed(r>=1e3?0:r>=100?1:3);return t.trim()?`${i} ${t.trim()}`:i}function yz(e,t){return`${e}::lap${t}`}var bz=(e,t,n)=>`kymoscope-workbook-export|3|${e}|${t??``}|${n??``}`,xz=e=>new TextEncoder().encode(e);async function Sz(e,t){return{format:`kymoscope-workbook`,v:2,...await Ee(t,xz(JSON.stringify(e)),a)}}async function Cz(e,t){let n=t.password?JSON.stringify(await Sz(e,t.password)):JSON.stringify(e),r=await _(await S(t.key),xz(n),bz(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 wz(e){return!!e&&typeof e==`object`&&e.format===`kymoscope-workbook`}function Tz(e){return wz(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 Ez=e=>{try{return JSON.parse(new TextDecoder().decode(e))}catch{throw new tE(`bad_file`)}};async function Dz(e,t){let n=Tz(e);if(!n)throw new tE(`bad_file`);let r=e;if(n.v===3){let i=e;if(!t.key)throw new tE(`scope_key_required`,{scope:n.scope,scopeId:n.scopeId});let a;try{a=await m(await S(t.key),i,bz(i.scope,i.scope_id,i.inner))}catch{throw new tE(`bad_file`)}if(r=Ez(a),!n.password)return r;if(r?.v!==2||!wz(r))throw new tE(`bad_file`)}if(!t.password)throw new tE(`password_required`);let i;try{i=await v(t.password,r,a)}catch{throw new tE(`wrong_password`)}return Ez(i)}var Oz=new Set(Object.keys(Tt));function kz(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`||!Oz.has(n)||!r||![r.x,r.y,r.w,r.h].every(e=>typeof e==`number`&&Number.isFinite(e))?[]:[{...e,rect:Ot(n,r,96)}]}):[]}var Az=e=>({name:e.name,xKey:e.xKey,panels:e.panels,panelChartSettings:e.panelChartSettings,panelChartBackgrounds:e.panelChartBackgrounds});function jz(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 Mz(e){return{version:2,worksheets:e.worksheets.map(e=>({...Az(e),panelChartSettings:jz(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}}function Nz(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}}}function Pz(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 Fz(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 Iz(e){let t=await Fz(e),n;try{n=JSON.parse(t)}catch{return{worksheets:[],errors:[`Not a valid JSON file.`]}}return Hz(n)}var Lz=new Set(uz.map(e=>e.value)),Rz=/^(#(?:[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 zz(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):Rz.test(e.trim())}function Bz(e){if(Array.isArray(e))return e.map(Bz);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`&&!zz(r)||(t[n]=r&&typeof r==`object`?Bz(r):r);return t}function Vz(e){return!e||typeof e!=`object`?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>e===null||zz(e)))}function Hz(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};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:kz(n.panels),panelChartSettings:Bz(n.panelChartSettings),panelChartBackgrounds:Vz(n.panelChartBackgrounds)})}),n===1)return{worksheets:r,errors:i,activeIndex:0,mathChannels:[],liveWindowSeconds:void 0,laps:void 0};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`&&Lz.has(s.stat)?{channel:s.channel,metric:s.metric,stat:s.stat}:null,l=typeof t.activeWorksheet==`number`&&Number.isInteger(t.activeWorksheet)?t.activeWorksheet:0;return{worksheets:r,errors:i,mathChannels:a,laps:c,activeIndex:Math.min(Math.max(0,l),Math.max(0,r.length-1)),liveWindowSeconds:o===null||typeof o==`number`&&o>0?o:void 0}}function Uz(e){return e.some(e=>e.panels.length>0)}function Wz(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:kz(t.panels),panelChartSettings:Bz(t.panelChartSettings),panelChartBackgrounds:Vz(t.panelChartBackgrounds)}}function Gz(e){if(!e||typeof e!=`object`)return null;let t=e,n=t.kind;if(typeof n!=`string`||!Oz.has(n))return null;let r=Nn({__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 Kz(e){let t=await Fz(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=Tz(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=Wz(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=Gz(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 Iz(e);return i.worksheets.length===0&&i.errors.length>0?{type:`error`,errors:i.errors}:{type:`workspace`,worksheets:i.worksheets,errors:i.errors}}var qz=ZL;function Jz(e){let t=e.toLowerCase();return!t.startsWith(`.`)&&qz.some(e=>t.endsWith(e))}function Yz(e,t=``){let n={name:t,path:``,dirs:[],files:[],allPaths:[]};for(let t of e){if(!Jz(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 Xz(e){return e.map(e=>({path:e.webkitRelativePath||e.name,file:e}))}async function Zz(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 Qz(){return typeof window.showDirectoryPicker==`function`}async function $z(){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 eB={1:`dohstRIUBeOkkAXOTXhhEkXanWzz-V4M518JBqTehRM`};function tB(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 nB(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 rB(e){try{let t=JSON.parse(new TextDecoder().decode(tB(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 iB(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=rB(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`,tB(s),`Ed25519`,!1,[`verify`]);c=await crypto.subtle.verify(`Ed25519`,e,tB(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=>nB(e,t))?{ok:!0,sub:a.sub,exp:a.exp}:{ok:!1,reason:`domain`}:{ok:!1,reason:`bad_signature`}}function aB(e,t){return iB(e,t,eB,Date.now()/1e3)}var Q={sans:`system-ui, sans-serif`,mono:`ui-monospace, monospace`};function oB(){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 sB(){return nt(`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 cB(){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 lB(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 uB(e){return Math.max(0,(e>>1)-1)}var dB=2.5,fB=`#version 300 es
71
+ in vec2 a_corner; // static quad corner: (±1, ±1)
72
+ in vec2 a_a; // per-instance: segment start (CSS px)
73
+ in vec2 a_b; // per-instance: segment end (CSS px)
74
+ uniform vec2 u_resolution;
75
+ uniform float u_ext; // halfWidth + feather (CSS px)
76
+ flat out vec2 v_a;
77
+ flat out vec2 v_b;
78
+ out vec2 v_pos;
79
+ void main() {
80
+ vec2 ab = a_b - a_a;
81
+ float len = length(ab);
82
+ // Degenerate (repeated point): pick any direction; the capsule SDF still
83
+ // renders it as a correct round dot.
84
+ vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
85
+ vec2 n = vec2(-dir.y, dir.x);
86
+ // corner.x picks the end (A for -1, B for +1) and extends past it along the
87
+ // segment direction so the round cap has room; corner.y spans the width.
88
+ vec2 base = mix(a_a, a_b, step(0.0, a_corner.x));
89
+ vec2 pos = base + dir * (a_corner.x * u_ext) + n * (a_corner.y * u_ext);
90
+ v_a = a_a;
91
+ v_b = a_b;
92
+ v_pos = pos;
93
+ vec2 clip = pos / u_resolution * 2.0 - 1.0; // 0..1 → -1..1
94
+ gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0); // flip y (px down → clip up)
95
+ }`,pB=`#version 300 es
96
+ precision highp float;
97
+ uniform vec4 u_color;
98
+ uniform float u_halfWidth; // visible half-thickness (CSS px)
99
+ flat in vec2 v_a;
100
+ flat in vec2 v_b;
101
+ in vec2 v_pos;
102
+ out vec4 outColor;
103
+ void main() {
104
+ // Capsule SDF: distance from this pixel to the segment AB.
105
+ vec2 ab = v_b - v_a;
106
+ float t = clamp(dot(v_pos - v_a, ab) / max(dot(ab, ab), 1e-12), 0.0, 1.0);
107
+ float d = distance(v_pos, v_a + ab * t);
108
+ // Feather over one pixel (fwidth ≈ 1 device px in CSS units, so this stays a
109
+ // crisp 1px edge at any devicePixelRatio). Coverage varies smoothly with
110
+ // sub-pixel position — the no-shimmer property MSAA lacks.
111
+ float aa = max(fwidth(d), 1e-4);
112
+ // One-pixel smoothstep feather, measured in SUPERSAMPLED pixels (this shader
113
+ // runs on the ×2 target), so after the 2×2 box downsample a 1 CSS px line
114
+ // stays ~1 px on screen. The supersample + box filter is what keeps the edge
115
+ // stable at any sub-pixel phase (no "travelling beam" on near-vertical
116
+ // strokes while scrolling). The earlier 1.75 px feather and cov^(1/2.2) gamma
117
+ // boost (pre-supersampling fixes for the same shimmer) widened a 1 px line to
118
+ // ~2 px once the downsample was done properly — the "bold traces" report.
119
+ float e = clamp((u_halfWidth - d) / aa + 0.5, 0.0, 1.0);
120
+ float cov = e * e * (3.0 - 2.0 * e);
121
+ if (cov <= 0.0) discard;
122
+ // Premultiplied: the 2x2 downsample (see draw) averages texels, which is only
123
+ // correct on premultiplied colour — straight alpha would darken the AA fringe.
124
+ float a = u_color.a * cov;
125
+ outColor = vec4(u_color.rgb * a, a);
126
+ }`;function mB(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`glLines shader compile failed:`,e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}function hB(e,t=1){let n=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!n)return null;let r=mB(n,n.VERTEX_SHADER,fB),i=mB(n,n.FRAGMENT_SHADER,pB);if(!r||!i)return null;let a=n.createProgram();if(!a||(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS)))return null;let o=n.getAttribLocation(a,`a_corner`),s=n.getAttribLocation(a,`a_a`),c=n.getAttribLocation(a,`a_b`),l=n.getUniformLocation(a,`u_resolution`),u=n.getUniformLocation(a,`u_color`),d=n.getUniformLocation(a,`u_ext`),f=n.getUniformLocation(a,`u_halfWidth`),p=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,p),n.bufferData(n.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),n.STATIC_DRAW);let m=n.createBuffer(),h=n.createFramebuffer(),g=n.createRenderbuffer(),_=1,v=1,y=(`clientWidth`in e?e.clientWidth:0)||1,b=(`clientHeight`in e?e.clientHeight:0)||1,x=1;return{resize(t,r,i){y=Math.max(1,t),b=Math.max(1,r),x=i*2,e.width=Math.round(y*i),e.height=Math.round(b*i),_=e.width*2,v=e.height*2,h&&g&&(n.bindRenderbuffer(n.RENDERBUFFER,g),n.renderbufferStorage(n.RENDERBUFFER,n.RGBA8,_,v),n.bindFramebuffer(n.FRAMEBUFFER,h),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,g),n.bindFramebuffer(n.FRAMEBUFFER,null))},draw(r){n.bindFramebuffer(n.FRAMEBUFFER,h),n.viewport(0,0,h?_:e.width,h?v:e.height),n.disable(n.SCISSOR_TEST),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.useProgram(a),n.uniform2f(l,y,b),n.enable(n.BLEND),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),n.bindBuffer(n.ARRAY_BUFFER,p),n.enableVertexAttribArray(o),n.vertexAttribPointer(o,2,n.FLOAT,!1,0,0),n.vertexAttribDivisor(o,0),n.bindBuffer(n.ARRAY_BUFFER,m),n.enableVertexAttribArray(s),n.vertexAttribPointer(s,2,n.FLOAT,!1,8,0),n.vertexAttribDivisor(s,1),n.enableVertexAttribArray(c),n.vertexAttribPointer(c,2,n.FLOAT,!1,8,8),n.vertexAttribDivisor(c,1);for(let e of r){let r=uB(e.points.length);if(r<1)continue;e.clip?(n.enable(n.SCISSOR_TEST),n.scissor(Math.round(e.clip.x*x),Math.round((b-e.clip.y-e.clip.h)*x),Math.round(e.clip.w*x),Math.round(e.clip.h*x))):n.disable(n.SCISSOR_TEST),n.bufferData(n.ARRAY_BUFFER,e.points,n.DYNAMIC_DRAW),n.uniform4fv(u,e.color);let i=e.width??t;n.uniform1f(d,i/2+dB),n.uniform1f(f,i/2),n.drawArraysInstanced(n.TRIANGLE_STRIP,0,4,r)}n.disable(n.SCISSOR_TEST),n.vertexAttribDivisor(s,0),n.vertexAttribDivisor(c,0),h&&(n.bindFramebuffer(n.READ_FRAMEBUFFER,h),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.blitFramebuffer(0,0,_,v,0,0,e.width,e.height,n.COLOR_BUFFER_BIT,n.LINEAR),n.bindFramebuffer(n.FRAMEBUFFER,null))},dispose(){n.deleteBuffer(p),n.deleteBuffer(m),n.deleteFramebuffer(h),n.deleteRenderbuffer(g),n.deleteProgram(a),n.deleteShader(r),n.deleteShader(i),n.getExtension(`WEBGL_lose_context`)?.loseContext()}}}var gB=1024,_B=`#version 300 es
127
+ in vec2 a_corner; // static quad corner: (±1, ±1)
128
+ in float a_ax; // per instance: segment start/end X (relative to the layer origin)
129
+ in float a_bx;
130
+ in float a_ay; // per instance: segment start/end value
131
+ in float a_by;
132
+ in float a_bstart; // 1 where the END point starts a new trace (or a new series)
133
+ in float a_sid; // series of the START point
134
+ uniform highp sampler2D u_styles;
135
+ uniform vec2 u_resolution;
136
+ uniform float u_left; // plot left edge (CSS px)
137
+ uniform float u_plotW;
138
+ uniform float u_xoff; // view xmin - origin
139
+ uniform float u_xscale; // plot width px / view X range
140
+ uniform float u_xR; // view X range
141
+ uniform float u_minGap; // floor of the gap threshold (resampled: buckets apart)
142
+ flat out vec2 v_a;
143
+ flat out vec2 v_b;
144
+ flat out vec4 v_color;
145
+ flat out float v_halfWidth;
146
+ flat out vec4 v_clip; // left, top, right, bottom (CSS px)
147
+ out vec2 v_pos;
148
+ vec4 style(int sid, int k) {
149
+ return texelFetch(u_styles, ivec2((sid % ${gB}) * 3 + k, sid / ${gB}), 0);
150
+ }
151
+ void main() {
152
+ int sid = int(a_sid + 0.5);
153
+ vec4 s0 = style(sid, 0); // scale lo, scale hi, band top, band bottom
154
+ vec4 s1 = style(sid, 1); // colour
155
+ vec4 s2 = style(sid, 2); // gap median, half width, quad extension, visible
156
+ // Same threshold as the on-main path (joinGapThreshold over a median step).
157
+ float gap = max(u_minGap, s2.x > 0.0 ? max(s2.x * 4.0, u_xR * 1e-9) : max(u_xR * 1e-6, 1e-12));
158
+ if (s2.w < 0.5 || a_bstart > 0.5 || abs(a_bx - a_ax) > gap) {
159
+ // Not a segment (a gap, a trace or series start, a hidden series): collapse off-screen.
160
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
161
+ v_a = vec2(0.0); v_b = vec2(0.0); v_pos = vec2(0.0);
162
+ v_color = vec4(0.0); v_halfWidth = 0.0; v_clip = vec4(0.0);
163
+ return;
164
+ }
165
+ float lo = s0.x, hi = s0.y, top = s0.z, bottom = s0.w;
166
+ float ta = hi == lo ? 0.5 : clamp((a_ay - lo) / (hi - lo), 0.0, 1.0);
167
+ float tb = hi == lo ? 0.5 : clamp((a_by - lo) / (hi - lo), 0.0, 1.0);
168
+ vec2 a = vec2(u_left + (a_ax - u_xoff) * u_xscale, top + (1.0 - ta) * (bottom - top));
169
+ vec2 b = vec2(u_left + (a_bx - u_xoff) * u_xscale, top + (1.0 - tb) * (bottom - top));
170
+ vec2 ab = b - a;
171
+ float len = length(ab);
172
+ vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
173
+ vec2 n = vec2(-dir.y, dir.x);
174
+ vec2 base = mix(a, b, step(0.0, a_corner.x));
175
+ vec2 pos = base + dir * (a_corner.x * s2.z) + n * (a_corner.y * s2.z);
176
+ v_a = a;
177
+ v_b = b;
178
+ v_pos = pos;
179
+ v_color = s1;
180
+ v_halfWidth = s2.y;
181
+ v_clip = vec4(u_left, top, u_left + u_plotW, bottom);
182
+ vec2 clip = pos / u_resolution * 2.0 - 1.0;
183
+ gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
184
+ }`,vB=`#version 300 es
185
+ precision highp float;
186
+ flat in vec2 v_a;
187
+ flat in vec2 v_b;
188
+ flat in vec4 v_color;
189
+ flat in float v_halfWidth;
190
+ flat in vec4 v_clip;
191
+ in vec2 v_pos;
192
+ out vec4 outColor;
193
+ void main() {
194
+ if (v_pos.x < v_clip.x || v_pos.x > v_clip.z || v_pos.y < v_clip.y || v_pos.y > v_clip.w) discard;
195
+ vec2 ab = v_b - v_a;
196
+ float t = clamp(dot(v_pos - v_a, ab) / max(dot(ab, ab), 1e-12), 0.0, 1.0);
197
+ float d = distance(v_pos, v_a + ab * t);
198
+ float aa = max(fwidth(d), 1e-4);
199
+ float e = clamp((v_halfWidth - d) / aa + 0.5, 0.0, 1.0);
200
+ float cov = e * e * (3.0 - 2.0 * e);
201
+ if (cov <= 0.0) discard;
202
+ float alpha = v_color.a * cov;
203
+ outColor = vec4(v_color.rgb * alpha, alpha);
204
+ }`;function yB(e,t,n,r){let i=e.length,a=0;for(let t=0;t<i;t++)Number.isFinite(r[t])&&Number.isFinite(e[t])&&a++;if(a===i)return null;let o=new Float32Array(a),s=new Float32Array(a),c=new Uint8Array(a),l=0,u=!1;for(let a=0;a<i;a++)n[a]&&(u=!0),Number.isFinite(r[a])&&Number.isFinite(e[a])&&(o[l]=t[a],s[l]=r[a],u&&=(c[l]=255,!1),l++);return{x:o,y:s,starts:c}}function bB(e,t,n){let r=e.length,i=0;for(let t=0;t<r;t++)if(Number.isFinite(e[t])){i=e[t];break}let a=new Float32Array(r);for(let t=0;t<r;t++)a[t]=e[t]-i;let o=new Uint8Array(r);if(t)for(let e=0;e<r;e++)t[e]&&(o[e]=255);let s=n.map(t=>yB(e,a,o,t)??{x:a,y:t,starts:o}),c=s.map(e=>e.y.length),l=c.reduce((e,t)=>e+t,0),u=new Float32Array(l),d=new Float32Array(l),f=new Uint8Array(l),p=new Float32Array(l),m=0;return s.forEach((e,t)=>{u.set(e.x,m),d.set(e.y,m),f.set(e.starts,m),e.y.length>0&&(f[m]=255),p.fill(t,m,m+e.y.length),m+=e.y.length}),{origin:i,x:u,y:d,starts:f,sid:p,counts:c}}function xB(e,t,n,r,i,a){let o=(i-r)/a,s=(t,n)=>{let r=0,i=e.length;for(;r<i;){let a=r+i>>>1;(n?e[a]<=t:e[a]<t)?r=a+1:i=a}return r},c=s(r,!1),l=s(i,!0),u=t.length*(2*a+2),d=new Float32Array(u),f=new Float32Array(u),p=new Uint8Array(u),m=new Float32Array(u),h=0,g=(e,t,r)=>{d[h]=e-n,f[h]=t,m[h]=r,h++};return t.forEach((t,n)=>{let i=h;for(let r=c-1;r>=Math.max(0,c-64);r--)if(t[r]===t[r]){g(e[r],t[r],n);break}let s=c;for(let i=0;i<a&&s<l;i++){let c=i===a-1?1/0:r+(i+1)*o,u=1/0,d=-1/0,f=-1,p=-1;for(;s<l&&e[s]<c;s++){let e=t[s];e<u&&(u=e,f=s),e>d&&(d=e,p=s)}f<0||(f===p?g(e[f],u,n):f<p?(g(e[f],u,n),g(e[p],d,n)):(g(e[p],d,n),g(e[f],u,n)))}for(let r=l;r<Math.min(e.length,l+64);r++)if(t[r]===t[r]){g(e[r],t[r],n);break}h>i&&(p[i]=255)}),{x:d.subarray(0,h),y:f.subarray(0,h),starts:p.subarray(0,h),sid:m.subarray(0,h),bucket:o}}function SB(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 CB(e,t=1){let n=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!n)return null;let r=mB(n,n.VERTEX_SHADER,_B),i=mB(n,n.FRAGMENT_SHADER,vB);if(!r||!i)return null;let a=n.createProgram();if(!a)return null;if(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),!n.getProgramParameter(a,n.LINK_STATUS))return console.error(`glSeries program link failed:`,n.getProgramInfoLog(a)),null;let o=e=>n.getAttribLocation(a,e),s=o(`a_corner`),c=o(`a_ax`),l=o(`a_bx`),u=o(`a_ay`),d=o(`a_by`),f=o(`a_bstart`),p=o(`a_sid`),m=[c,l,u,d,f,p],h=e=>n.getUniformLocation(a,e),g={res:h(`u_resolution`),styles:h(`u_styles`),left:h(`u_left`),plotW:h(`u_plotW`),xoff:h(`u_xoff`),xscale:h(`u_xscale`),xR:h(`u_xR`),minGap:h(`u_minGap`)},_=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,_),n.bufferData(n.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),n.STATIC_DRAW);let v=n.createFramebuffer(),y=n.createRenderbuffer(),b=1,x=1,S=(`clientWidth`in e?e.clientWidth:0)||1,C=(`clientHeight`in e?e.clientHeight:0)||1,w=[],T=0,E=1,D=e=>{let t=n.createBuffer();return n.bindBuffer(n.ARRAY_BUFFER,t),n.bufferData(n.ARRAY_BUFFER,e,n.STATIC_DRAW),t},O=e=>{if(e)for(let t of[e.x,e.y,e.starts,e.sid])n.deleteBuffer(t)},k=e=>{e&&(O(e.full),O(e.res),n.deleteTexture(e.styles))},A=e=>({x:D(e.x),y:D(e.y),starts:D(e.starts),sid:D(e.sid),total:e.x.length}),j=e=>{let t=e.full;if(t&&t.version===e.version)return t;if(t&&e.valuesOnly&&t.whole&&e.counts.every(t=>t===e.xs.length)){let r=e.xs.length,i=e.columns.length===1?e.columns[0]:new Float32Array(r*e.columns.length);return e.columns.length>1&&e.columns.forEach((e,t)=>i.set(e,t*r)),n.bindBuffer(n.ARRAY_BUFFER,t.y),n.bufferSubData(n.ARRAY_BUFFER,0,i),t.version=e.version,t}O(t);let r=bB(e.xs,e.breaks,e.columns);return e.full={...A(r),version:e.version,whole:r.counts.every(t=>t===e.xs.length)},e.full},M=t=>{let n=Math.max(1,Math.round(t.plotW*(e.width/S)));if(t.resamplable&&E>T){let e=t.xs,r=0,i=e.length;for(;r<i;){let t=r+i>>>1;e[t]<T?r=t+1:i=t}let a=r;for(i=e.length;r<i;){let t=r+i>>>1;e[t]<=E?r=t+1:i=t}if(r-a>n*4){let r=`${t.version}|${T}|${E}|${n}`;if(t.res?.key!==r){O(t.res);let i=xB(e,t.columns,t.origin,T,E,n);t.res={...A(i),key:r,bucket:i.bucket}}return{d:t.res,minGap:t.res.bucket*2.5}}}return{d:j(t),minGap:0}},N=(e,r)=>{let i=e.counts.length,a=Math.max(1,Math.ceil(i/gB)),o=3*Math.min(Math.max(i,1),gB),s=new Float32Array(o*a*4);for(let n=0;n<i;n++){let i=r[n],a=(Math.floor(n/gB)*o+n%gB*3)*4;if(!i)continue;let c=i.width??t;s.set([Math.min(i.scaleMin,i.scaleMax),Math.max(i.scaleMin,i.scaleMax),i.bandTop,i.bandBottom],a),s.set(i.color,a+4),s.set([i.gapMedian,c/2,c/2+dB,+(e.counts[n]>=2)],a+8)}n.bindTexture(n.TEXTURE_2D,e.styles),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,o,a,0,n.RGBA,n.FLOAT,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST)};return{resize(t,r,i){S=Math.max(1,t),C=Math.max(1,r),e.width=Math.round(S*i),e.height=Math.round(C*i),b=e.width*2,x=e.height*2,v&&y&&(n.bindRenderbuffer(n.RENDERBUFFER,y),n.renderbufferStorage(n.RENDERBUFFER,n.RGBA8,b,x),n.bindFramebuffer(n.FRAMEBUFFER,v),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,y),n.bindFramebuffer(n.FRAMEBUFFER,null))},setData(e,t,r,i){let a=w[e],o=!t&&!!a&&i.length===a.columns.length;if(!t){if(!a)return;t=a.xs,r=a.breaks}let s=0;for(let e=0;e<t.length;e++)if(Number.isFinite(t[e])){s=t[e];break}let c=i.map(e=>{let t=0;for(let n=0;n<e.length;n++)e[n]===e[n]&&t++;return t});if(a&&(o||a.xs===t)){a.columns=i,a.counts=c,a.valuesOnly=o,a.version++,o||(O(a.full),a.full=null);return}let l={xs:t,breaks:r,columns:i,origin:s,counts:c,resamplable:!r?.some(e=>e)&&SB(t),version:0,valuesOnly:!1,full:null,res:null,styles:n.createTexture(),left:a?.left??0,plotW:a?.plotW??0};N(l,[]),w[e]=l,k(a)},setStyles(e,t,n,r){let i=w[e];i&&(N(i,t),i.left=n,i.plotW=r)},clearLayer(e){k(w[e]),w[e]=null},setView(e,t){T=e,E=t},render(){n.bindFramebuffer(n.FRAMEBUFFER,v),n.viewport(0,0,v?b:e.width,v?x:e.height),n.disable(n.SCISSOR_TEST),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.useProgram(a),n.uniform2f(g.res,S,C),n.uniform1i(g.styles,0),n.activeTexture(n.TEXTURE0),n.enable(n.BLEND),n.blendFunc(n.ONE,n.ONE_MINUS_SRC_ALPHA),n.bindBuffer(n.ARRAY_BUFFER,_),n.enableVertexAttribArray(s),n.vertexAttribPointer(s,2,n.FLOAT,!1,0,0),n.vertexAttribDivisor(s,0);for(let e of m)n.enableVertexAttribArray(e),n.vertexAttribDivisor(e,1);let t=E-T||1;for(let e of w){if(!e)continue;n.uniform1f(g.left,e.left),n.uniform1f(g.plotW,e.plotW),n.uniform1f(g.xoff,T-e.origin),n.uniform1f(g.xscale,e.plotW/t),n.uniform1f(g.xR,t);let{d:r,minGap:i}=M(e);r.total<2||(n.uniform1f(g.minGap,i),n.bindTexture(n.TEXTURE_2D,e.styles),n.bindBuffer(n.ARRAY_BUFFER,r.x),n.vertexAttribPointer(c,1,n.FLOAT,!1,4,0),n.vertexAttribPointer(l,1,n.FLOAT,!1,4,4),n.bindBuffer(n.ARRAY_BUFFER,r.y),n.vertexAttribPointer(u,1,n.FLOAT,!1,4,0),n.vertexAttribPointer(d,1,n.FLOAT,!1,4,4),n.bindBuffer(n.ARRAY_BUFFER,r.starts),n.vertexAttribPointer(f,1,n.UNSIGNED_BYTE,!0,1,1),n.bindBuffer(n.ARRAY_BUFFER,r.sid),n.vertexAttribPointer(p,1,n.FLOAT,!1,4,0),n.drawArraysInstanced(n.TRIANGLE_STRIP,0,4,r.total-1))}for(let e of m)n.vertexAttribDivisor(e,0);v&&(n.bindFramebuffer(n.READ_FRAMEBUFFER,v),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,null),n.blitFramebuffer(0,0,b,x,0,0,e.width,e.height,n.COLOR_BUFFER_BIT,n.LINEAR),n.bindFramebuffer(n.FRAMEBUFFER,null))},dispose(){for(let e of w)k(e);w.length=0,n.deleteBuffer(_),n.deleteFramebuffer(v),n.deleteRenderbuffer(y),n.deleteProgram(a),n.deleteShader(r),n.deleteShader(i),n.getExtension(`WEBGL_lose_context`)?.loseContext()}}}var wB=12,TB=0,EB=null;function DB(){return TB<wB}function OB(){TB++;let e=!1;return()=>{e||(e=!0,TB--)}}function kB(){if(EB&&!EB.gl.isContextLost())return EB;let e=document.createElement(`canvas`);e.width=1,e.height=1;let t=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1});return EB=t?{canvas:e,gl:t}:null,EB}function AB(e){if(TB<wB)return{canvas:e,shared:!1,present(){},release:OB()};let t=kB();if(!t)return{canvas:e,shared:!1,present(){},release(){}};let n=1,r=1,i={get width(){return n},set width(e){n=Math.max(1,Math.round(e)),t.canvas.width<n&&(t.canvas.width=n)},get height(){return r},set height(e){r=Math.max(1,Math.round(e)),t.canvas.height<r&&(t.canvas.height=r)},getContext(e){return e===`webgl2`?t.gl:null}},a=null;return{canvas:i,shared:!0,present(){e.width!==n&&(e.width=n),e.height!==r&&(e.height=r),a??=e.getContext(`2d`),a&&(a.globalCompositeOperation=`copy`,a.drawImage(t.canvas,0,t.canvas.height-r,n,r,0,0,n,r),a.globalCompositeOperation=`source-over`)},release(){}}}var jB=new WeakMap;function MB(e,t,n){let r=jB.get(e);return r||jB.set(e,r=new Map),r.has(t)||r.set(t,n()),r.get(t)}function NB(e,t){let n=AB(e),r=t(n.canvas);if(!r)return n.release(),null;let i=r.render.bind(r),a=r.dispose.bind(r);return r.render=()=>{i(),n.present()},r.dispose=()=>{a(),n.release()},r}var PB=``+new URL(`assets/offscreenLineWorker-mShhnyXX.js`,import.meta.url).href;function FB(e,t=1){if(typeof e.transferControlToOffscreen!=`function`||typeof Worker>`u`)return null;let n;try{n=nE(PB)}catch{return null}let r;try{r=e.transferControlToOffscreen()}catch{return n.terminate(),null}n.postMessage({type:`init`,canvas:r,lineWidth:t},[r]);let i=OB(),a=-1,o=-1,s=-1;return{resize(e,t,r){e===a&&t===o&&r===s||(a=e,o=t,s=r,n.postMessage({type:`resize`,w:e,h:t,dpr:r}))},setData(e,t){let r=[];t.xs&&r.push(t.xs.buffer),t.breaks&&r.push(t.breaks.buffer);for(let e of t.columns)r.push(e.buffer);n.postMessage({type:`data`,layer:e,...t},r)},setStyle(e,t){n.postMessage({type:`style`,layer:e,...t})},clear(e){n.postMessage({type:`clear`,layer:e})},setView(e,t){n.postMessage({type:`view`,xmin:e,xmax:t})},dispose(){try{n.postMessage({type:`dispose`})}catch{}n.terminate(),i()}}}function IB(e,t=1){let n=NB(e,e=>CB(e,t));if(!n)return null;let r=0,i=1,a=``,o=(e,t)=>{n.setStyles(e,t.styles,t.left,t.plotW),r=t.xmin,i=t.xmax,n.setView(r,i),n.render()};return{resize(e,t,r){let i=`${e}|${t}|${r}`;i!==a&&(a=i,n.resize(e,t,r),n.render())},setData(e,t){n.setData(e,t.xs,t.breaks,t.columns),o(e,t)},setStyle(e,t){o(e,t)},clear(e){n.clearLayer(e),n.render()},setView(e,t){e===r&&t===i||(r=e,i=t,n.setView(e,t),n.render())},dispose(){n.dispose()}}}function LB(e,t,n,r,i){return r+(e-t)/n*(i-r)}function RB(e,t,n,r){let i=new Map,a=n.length;if(a===0)return i;let o=new Float64Array(a),s=new Float64Array(a).fill(1/0);for(let r of e){let e=r.x;for(let i=0;i<a;i++){let a=r.cols.get(n[i]);if(!a)continue;let c=s[i],l=o[i];for(let n=0;n<r.length;n++){let r=e[n],i=r<t?t-r:r-t;if(i>=c)continue;let o=a[n];Number.isFinite(o)&&(c=i,l=o)}s[i]=c,o[i]=l}}for(let e=0;e<a;e++)s[e]!==1/0&&(r&&s[e]>(r.get(n[e])??1/0)||i.set(n[e],o[e]));return i}function zB(e,t,n,r=64){let i=new Map;if(t.length===0||!Number.isFinite(n))return i;let a=new Map;for(let o of e){if(o.length===0)continue;let e=0,s=o.length-1;for(;e<s;){let t=e+s>>1;o.x[t]<n?e=t+1:s=t}for(let s of t){let t=o.cols.get(s);if(t)for(let c=0;c<=r;c++){let r=e-c,l=e+c,u=r>=0&&Number.isFinite(t[r])?r:l<o.length&&Number.isFinite(t[l])?l:-1;if(u<0)continue;let d=Math.abs(o.x[u]-n);d<(a.get(s)??1/0)&&(a.set(s,d),i.set(s,t[u]));break}}}return i}function BB(e,t){let n=new Map;if(t.length===0)return n;for(let r=e.length-1;r>=0&&n.size<t.length;r--){let i=e[r];for(let e of t){if(n.has(e))continue;let t=i.cols.get(e);if(t){for(let r=i.length-1;r>=0;r--)if(Number.isFinite(t[r])){n.set(e,t[r]);break}}}}return n}function VB(e,t){return!(e>0)||!(t>0)?1:1-Math.exp(-e/t)}function HB(e,t,n,r=t){if(!(t>e)||n==null||!(n>0))return[e,t];let i=Number.isFinite(r)?Math.min(t,Math.max(e,r)):t;return i-n<e?[e,Math.min(t,e+n)]:[i-n,i]}function UB(e,t){let n=Math.round(e*t*2);return Math.min(8e3,Math.max(2e3,n))}var WB=.5;function GB(e,t,n,r=WB){if(!(t>0))return e;let i=e!=null&&e>0?Math.min(e,t):t,a=n?i*.88:i/.88;return a>=t*.999?null:Math.max(r,a)}function KB(){return{d:null,lastT:NaN,burst:0}}function qB(e,t,n){if(!Number.isFinite(t))return t;if(t>e.lastT){let n=t-e.lastT;e.burst=e.burst>0?e.burst*.8+n*.2:n}else t!==e.lastT&&(e.d=null,e.burst=0);e.lastT=t;let r=t-Math.min(1,e.burst*1.5);return e.d===null||e.d<t-2?e.d=r:(e.d+=n/1e3,e.d+=(r-e.d)*Math.min(1,n/500)),e.d>t&&(e.d=t),e.d}var JB=new Set;function YB(e){JB.add(e)}function XB(e){JB.delete(e)}function ZB(){let e=typeof window>`u`?[]:[window];for(let t of JB)t.closed||e.push(t);return e}var QB=1,$B=new Map;function eV(e){let t=QB++,n=ZB();if(n.length===1){let r=n[0].requestAnimationFrame(n=>{$B.delete(t),e(n)});return $B.set(t,[{w:n[0],id:r}]),t}let r=[],i=n=>{$B.has(t)&&(tV(t),e(n))};for(let e of n)r.push({w:e,id:e.requestAnimationFrame(i)});return $B.set(t,r),t}function tV(e){if(e==null)return;let t=$B.get(e);if(t){$B.delete(e);for(let{w:e,id:n}of t)e.closed||e.cancelAnimationFrame(n)}}var nV=new WeakMap;function rV(e){e&&nV.set(e,(nV.get(e)??0)+1)}function iV(e){let t=nV.get(e)??0;for(let n of e.querySelectorAll(`*`))t+=nV.get(n)??0;return t}function aV(){return ZB().every(e=>e.document.hidden)}var oV=class{#e;#t=new Map;constructor(e){this.#e=e}observe(e,t){let n=e.ownerDocument.defaultView??window,r=this.#t.get(n);r||(r=new(n.ResizeObserver??ResizeObserver)(e=>this.#e(e,this)),this.#t.set(n,r)),r.observe(e,t)}unobserve(e){for(let t of this.#t.values())t.unobserve(e)}disconnect(){for(let e of this.#t.values())e.disconnect();this.#t.clear()}};function sV(e,t){let n=0,r=null,i=t=>{n=0,r=t,e()};return{schedule(){n||=eV(i)},now(){let a=t()?.timeline?.currentTime;if(typeof a!=`number`||a===r){n||=eV(i);return}n&&=(tV(n),0),r=a,e()},cancel(){n&&tV(n),n=0}}}var cV=(e,t)=>e.log?(Math.log10(Math.max(t,Number.MIN_VALUE))-Math.log10(e.v0))/(Math.log10(e.v1)-Math.log10(e.v0)||1):(t-e.v0)/(e.v1-e.v0||1),lV=(e,t)=>e.log?10**(Math.log10(e.v0)+t*(Math.log10(e.v1)-Math.log10(e.v0))):e.v0+t*(e.v1-e.v0),uV=(e,t)=>e.left+cV(e.x,t)*e.width,dV=(e,t)=>lV(e.x,(t-e.left)/(e.width||1)),fV=(e,t)=>e.top+(1-cV(e.y,t))*e.height,pV=e=>!e||Number.isFinite(e.v0)&&Number.isFinite(e.v1)&&e.v0!==e.v1&&(!e.log||e.v0>0&&e.v1>0),mV=(e,t)=>e===t||!!e&&!!t&&e.v0===t.v0&&e.v1===t.v1&&!!e.log==!!t.log;function hV(){let e=null,t=new Set;return{get:()=>e,set:n=>{if(n&&(n.width>0&&n.height>0?(!pV(n.x)||!pV(n.y))&&(n={...n,x:pV(n.x)?n.x:void 0,y:pV(n.y)?n.y:void 0}):n=null),!(n===e||n&&e&&n.left===e.left&&n.top===e.top&&n.width===e.width&&n.height===e.height&&mV(n.x,e.x)&&mV(n.y,e.y))){e=n;for(let e of[...t])e()}},subscribe:e=>(t.add(e),()=>{t.delete(e)})}}var gV=Ue(()=>{}),_V=()=>Je(gV),vV=(()=>{try{return localStorage.getItem(`glLines`)!==`0`}catch{return!0}})(),yV=(()=>{try{return localStorage.getItem(`offscreenGl`)!==`0`}catch{return!0}})(),bV=70;function xV(e){return e===`dashed`?[5,4]:e===`dotted`?[1,4]:[]}var SV={top:14,right:160,bottom:40,left:110},CV={top:14,right:100,bottom:40,left:70},wV=640,TV={top:3,right:3,bottom:3,left:3},EV=260;function DV(e){return e<EV?TV:e<wV?CV:SV}var OV=220,kV=2e3,AV=4,jV=`11.25px ${Q.mono}`,MV=11*1.125,NV=24*1.125,PV=NV-MV+26,FV=.6,IV=13,LV=10,RV=5,zV=14,BV=4;function VV(e,t,n){return Math.min(n,Math.max(t,e))}function HV(e,t,n,r,i){let a=Math.min(r,i),o=Math.max(r,i);return t+(1-VV(o===a?.5:(e-a)/(o-a),0,1))*(n-t)}function UV(e,t,n,r){let i=e+t;return{bandTop:i-r/100*t,bandBottom:i-n/100*t}}function WV(e){return e.replace(/__(\d+|ref)$/,``)}function GV(e,t,n){let r=Math.floor((n-t-MV)/IV)+1;return Math.max(0,Math.min(e,r))}function KV(e){let t=0;for(let n of e)t+=n.length;return t}function qV(e,t){let n=e.cols.get(t);return n?Float32Array.from(n):new Float32Array(e.length).fill(NaN)}function JV(e){let t=new Map;for(let n of e){let e=WV(n.column),r=t.get(e)??[];r.push(n),t.set(e,r)}let n=new Set,r=[];for(let i of e){let e=WV(i.column);if(n.has(e))continue;n.add(e);let a=t.get(e);r.push({base:e,leader:a[0],members:a})}return r}function YV(e,t,n){let r=new Map,i=e.map((e,r)=>{let{bandTop:i}=UV(t,n,e.leader.bandFromPct,e.leader.bandToPct);return{g:e,i:r,bandTop:i,blockDY:e.members.length>1?MV+(e.members.length+1)*IV:PV}});i.sort((e,t)=>e.bandTop-t.bandTop||e.i-t.i);let a=-1/0;for(let{g:e,bandTop:t,blockDY:n}of i){let i=t+MV,o=Math.max(i,a),s=o-MV;r.set(e.leader.id,s),a=o+n}return r}function XV(e,t){let n=e.cols.get(t);if(!n)return 0;let r=e.x;if(n.length===e.length&&ze.has(n))return ZV(r,e.length);let i=0,a=0,o=null;for(let t=0;t<e.length;t++)Number.isFinite(n[t])&&(a++,o!==null&&r[t]!==o&&i++,o=r[t]);return i===0?0:a===e.length?ZV(r,e.length):$V(r,e.length,e=>Number.isFinite(n[e]),i)}function ZV(e,t){let n=QV.get(e);if(n===void 0){let r=0;for(let n=1;n<t;n++)e[n]!==e[n-1]&&r++;n=r===0?0:$V(e,t,()=>!0,r),QV.set(e,n)}return n}var QV=n(new WeakMap);function $V(e,t,n,r){let i=null,a=Math.max(1,Math.ceil(r/eH)),o=new Float64Array(Math.ceil(r/a)),s=0,c=0;for(let r=0;r<t;r++)n(r)&&(i!==null&&e[r]!==i&&(c%a===0&&s<o.length&&(o[s++]=Math.abs(e[r]-i)),c++),i=e[r]);return o.subarray(0,s).sort()[s-1>>1]}var eH=2048;function tH(e,t){return e>0?Math.max(e*4,t*1e-9):Math.max(t*1e-6,1e-12)}var nH=250;function rH({xLabel:e,series:t,points:n,columnUnits:r={},height:i=440,onPlotContextMenu:a,backgroundToken:o=``,viewXRange:s=null,onViewXRangeChange:c,liveZoom:l,liveZoomId:u,fullXRange:d=null,shiftMode:f,xAxisLine:p,yAxisLine:m,gridLine:h,lineWidth:g=1,envelopes:_,showLatestValues:v=!1,liveSource:y,liveWindowSeconds:b=null,onLiveWindowChange:x,liveZoomMode:S,onPlotWidthCss:C}){let w=_V(),T=K(null),E=K(null),D=K(null),O=K(null),k=K(C);k.current=C;let A=K(-1),j=K(null),M=K(!1),N=K(null),P=K(!1),F=K(!1),I=K(null),L=K(null),R=K({pts:null,layers:[]}),z=K(new Map),B=K([]),V=K(null),ee=K(null),te=K(null),H=K(null),ne=K(0),re=K(0),ie=K(!1),U=K(0),ae=K(kV),oe=K(y),se=K(null),ce=K(KB()),le=K(0);G(()=>{oe.current=y,se.current=null,R.current={pts:null,layers:[]},z.current.clear()},[y]);let ue=K(b);G(()=>{ue.current=b},[b]);let de=K(x);de.current=x;let fe=S??(x?`follow`:`free`),pe=K(fe);pe.current=fe;let me=K(null);G(()=>{me.current=null},[fe,e]);let he=K([]),ge=K(!1),_e=K(0),ve=K(0),ye=K(0),be=K(0),xe=K(`none`),Se=K(0),Ce=K(0),we=K(0),Te=K(null),Ee=K(null),De=K(f),Oe=K(null),ke=K({pts:null,x0:NaN,x1:NaN,ser:null}),Ae=K(0),je=K(0),Me=K(null),Ne=K(null),Pe=K(null),Fe=K(null);G(()=>{De.current=f},[f]),W(()=>(I.current&&=(clearTimeout(I.current),null),()=>{j.current?.dispose(),j.current=null;let e=N.current;e&&(I.current=setTimeout(()=>{e.dispose(),N.current===e&&(N.current=null),I.current=null},0))}),[]);let Ie=K({xLabel:e,series:t,points:n,height:i,columnUnits:r,shiftMode:f,xAxisLine:p,yAxisLine:m,gridLine:h,lineWidth:g,showLatestValues:v,envelopes:_}),Le=K(null),Re=K(null);G(()=>{Ie.current={xLabel:e,series:t,points:n,height:i,columnUnits:r,shiftMode:f,xAxisLine:p,yAxisLine:m,gridLine:h,lineWidth:g,showLatestValues:v,envelopes:_}},[e,t,n,i,r,f,p,m,h,g,v,_]);let ze=K(c);G(()=>{ze.current=c},[c]);let Be=K(l),Ve=K(u);G(()=>{Be.current=l,Ve.current=u},[l,u]),W(()=>{if(!(!l||!u))return l.subscribe((e,t)=>{e!==u&&(V.current=t?.[0]??null,ee.current=t?.[1]??null,ct())})},[l,u]);let He=K(a);G(()=>{He.current=a},[a]);let Ue=Xe(()=>{if(d&&d[1]>d[0])return{xmin:d[0],xmax:d[1]};let e=1/0,t=-1/0;for(let r of n)for(let n=0;n<r.length;n++){let i=r.x[n];i<e&&(e=i),i>t&&(t=i)}return(!Number.isFinite(e)||e===t)&&(--e,t+=1),{xmin:e,xmax:t}},[n,d]),We=K(Ue);G(()=>{We.current=Ue},[Ue]);function Ge(){return oe.current!=null&&V.current===null&&ee.current===null&&!ge.current&&Oe.current===null}function Ke(){let{xmin:e,xmax:t}=We.current,n=V.current,r=ee.current;if(n!==null&&r!==null&&r>n&&Number.isFinite(n)&&Number.isFinite(r))return{xmin:n,xmax:r};let i=te.current,a=H.current;return Ge()&&i!==null&&a!==null&&a>i&&Number.isFinite(i)&&Number.isFinite(a)?{xmin:i,xmax:a}:{xmin:e,xmax:t}}function qe(e,t){let n=oe.current;if(!n?.latestValues)return BB(e,t);let r=n.latestValues(t),i=t.filter(e=>!r.has(e)),a=n.latestX?.();if(i.length>0&&a!=null)for(let[t,n]of zB(e,i,a))r.set(t,n);return r}function Je(){return oe.current?he.current:Ie.current.points}function Ye(e,t,n){let r=new Map;for(let i of t)r.set(i,tH(tt(e,i),n));return r}function Ze(e){if(R.current.pts===e)return R.current.layers;let t=R.current.layers,n=oe.current?.version?.(),r=e.map((e,r)=>({pts:e,key:t[r]?.pts===e?t[r].key:n??e}));return R.current={pts:e,layers:r},r}function Qe(e,t){let n=z.current.get(e),r=performance.now(),i=n&&(n.key===t.key||typeof t.key==`number`&&typeof n.key==`number`&&r-n.at<nH);return(!n||!i)&&(n={key:t.key,at:r,has:new Map,median:new Map},z.current.set(e,n)),n}function $e(e,t,n){let r=Qe(e,t),i=r.has.get(n);if(i===void 0){let e=t.pts.cols.get(n);i=!!e&&e.some(Number.isFinite),r.has.set(n,i)}return i}function et(e,t){return Ze(e).some((e,n)=>$e(n,e,t))}function tt(e,t){let n=Ze(e);for(let e=0;e<n.length;e++){if(!$e(e,n[e],t))continue;let r=Qe(e,n[e]),i=r.median.get(t);return i===void 0&&(i=XV(n[e].pts,t),r.median.set(t,i)),i}return 0}function rt(){if(Fe.current)return Fe.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 Fe.current=n,n}function it(){let e=O.current,t=Math.max(1,e?.clientWidth||200),n=e?.clientHeight??0;return{w:t,h:Math.max(1,n>0?n:Ie.current.height)}}function at(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 ot(){let e=T.current;if(!e)return;let{w:t,h:n}=it(),r=at(e,t,n);if(!r)return;{let e=Je(),t=Ke(),n=Ie.current.series,r=ke.current;(r.pts!==e||r.x0!==t.xmin||r.x1!==t.xmax||r.ser!==n)&&(ke.current={pts:e,x0:t.xmin,x1:t.xmax,ser:n},rV(O.current))}let i=DV(t),a=i===TV,{top:o,right:s,bottom:c}=i,l=i.left,u=t-l-s,d=n-o-c,{bg:f,muted:p,grid:m}=rt(),{xLabel:h,series:g,xAxisLine:_,yAxisLine:v,gridLine:y,lineWidth:b,columnUnits:x,showLatestValues:S}=Ie.current,C=Je();if(r.fillStyle=f,r.fillRect(0,0,t,n),KV(C)<2||u<=0||d<=0){if(r.fillStyle=p,r.font=`13px ${Q.sans}`,r.fillText(`Not enough data to plot`,l,o+24),j.current&&(j.current.resize(t,n,window.devicePixelRatio||1),j.current.draw([])),N.current){N.current.resize(t,n,window.devicePixelRatio||1);for(let e=0;e<B.current.length;e++)N.current.clear(e);B.current=[]}return}let{xmin:D,xmax:k}=Ke(),A=k-D,L=e=>l+(e-D)/A*u;w({left:l,top:o,width:u,height:d,x:{v0:D,v1:k}});let R=g.filter(e=>e.bandToPct>e.bandFromPct&&e.scaleMin!==e.scaleMax&&et(C,e.column)),z=JV(R),V=YV(z,o,d),ee=new Map;for(let e of z){let t=V.get(e.leader.id);t!==void 0&&e.members.forEach(e=>ee.set(e.id,t))}let te=new Set,H=new Set;for(let e of z)e.members.length>1&&e.members.forEach(e=>te.add(e.id)),H.add(e.leader.id);let ne=`11px ${Q.mono}`,re=R.map(e=>{let{bandTop:t,bandBottom:n}=UV(o,d,e.bandFromPct,e.bandToPct),r=Math.min(e.scaleMin,e.scaleMax),i=Math.max(e.scaleMin,e.scaleMax),{majorStep:a,minorStep:s}=JR(e.scaleMin,e.scaleMax,e.yMajorStep??0,e.yMinorStep??0),c=a,l=YR(r,i,c);l.length>120&&(l=YR(r,i,c=JR(e.scaleMin,e.scaleMax,0,0).majorStep));let u=XR(r,i,s,l);return u.length>400&&(u=[]),{s:e,bandTop:t,bandBottom:n,majors:l,minors:u,step:c}}),ie=new Map,U=0;{r.save(),r.font=ne;let e=re.filter(e=>H.has(e.s.id));e.sort((e,t)=>{let n=Math.abs(e.s.bandToPct-e.s.bandFromPct),r=Math.abs(t.s.bandToPct-t.s.bandFromPct);return n===r?re.indexOf(e)-re.indexOf(t):r-n});let n=new Map,a=[];for(let t of e){let r=0;for(;r<e.length;r++){let e=a[r];if(!e||e.length===0||!e.some(e=>t.bandTop<e.bandBottom&&t.bandBottom>e.bandTop))break}n.set(t.s.id,r),a[r]||(a[r]=[]),a[r].push(t)}let o=new Map,c=new Map;for(let t of e){let e=0;for(let n of t.majors){let i=$R(n,t.step),a=c.get(i);a===void 0&&c.set(i,a=r.measureText(i).width),a>e&&(e=a)}o.set(t.s.id,e)}let u=[],d=[],f=0;for(let e=0;e<a.length;e++){u[e]=f;let t=0;for(let n of a[e]??[]){let e=o.get(n.s.id)??0;e>t&&(t=e)}d[e]=t,f+=t+22}for(let e of re){let t=n.get(e.s.id)??0;ie.set(e.s.id,u[t]??0)}let p=i.left;for(let e=0;e<a.length;e++){let t=a[e];if(!t||t.length===0)continue;let n=(u[e]??0)+BV+zV+(d[e]??0)+6;n>p&&(p=n)}let m=Math.max(i.left,t-s-Math.max(120,t*.4)),h=Math.min(Math.ceil(p),m);h>l&&(U=h-l),r.restore()}U>0&&(l+=U,u=Math.max(1,t-l-s)),ae.current=UB(u,window.devicePixelRatio||1);let oe=(e,t)=>1-(1-e)**t,se=new Map,ce=new Map;for(let e of re){let t=`${e.bandTop}|${e.bandBottom}|${e.s.scaleMin}|${e.s.scaleMax}|${e.majors.join(`,`)}`,n=se.get(t);n?n.k++:se.set(t,{c:e,k:1});let r=te.has(e.s.id)?p:e.s.color,i=`${e.bandTop}|${e.bandBottom}|${r}`,a=ce.get(i);a?a.k++:ce.set(i,{c:e,color:r,k:1})}if((v?.style??`dashed`)!==`none`)for(let{c:{s:e,bandTop:t,bandBottom:n,majors:i},k:a}of se.values()){r.save(),r.strokeStyle=v?.color??m,r.globalAlpha=oe(.1,a),r.lineWidth=v?.width??1,r.lineCap=`round`,r.setLineDash(xV(v?.style??`dashed`));for(let a of i){let i=HV(a,t,n,e.scaleMin,e.scaleMax);r.beginPath(),r.moveTo(l,i),r.lineTo(l+u,i),r.stroke()}r.restore()}for(let{c:{bandTop:e,bandBottom:t},color:n,k:i}of ce.values())r.strokeStyle=n,r.lineWidth=1,r.setLineDash([]),r.globalAlpha=oe(.45,i),r.beginPath(),r.moveTo(l,e),r.lineTo(l,t),r.stroke(),r.globalAlpha=1;for(let{s:e,bandTop:t,bandBottom:n,majors:i,minors:o,step:s}of a?[]:re){let a=te.has(e.id)?p:e.color;if(H.has(e.id)){let c=ie.get(e.id)??0,u=l-c-BV;r.strokeStyle=a,r.lineWidth=1;for(let i of o){let a=HV(i,t,n,e.scaleMin,e.scaleMax);r.beginPath(),r.moveTo(u-RV,a),r.lineTo(u,a),r.stroke()}r.font=ne,r.textAlign=`right`,r.textBaseline=`middle`,r.strokeStyle=a,r.fillStyle=a;for(let a of i){let i=HV(a,t,n,e.scaleMin,e.scaleMax);r.beginPath(),r.moveTo(u-LV,i),r.lineTo(u,i),r.stroke(),r.fillText($R(a,s),u-zV,i)}}}if((y?.style??`solid`)!==`none`&&(r.strokeStyle=y?.color??m,r.lineWidth=y?.width??1,r.setLineDash(xV(y?.style??`solid`)),r.strokeRect(l,o,u,d),r.setLineDash([])),(_?.style??`dashed`)!==`none`){r.strokeStyle=_?.color??m,r.lineWidth=_?.width??1,r.setLineDash(xV(_?.style??`dashed`));for(let e=1;e<6;e++){let t=l+e/6*u;r.beginPath(),r.moveTo(t,o),r.lineTo(t,o+d),r.stroke()}r.setLineDash([])}let le=o+d+10;r.fillStyle=p,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`top`;for(let e=0;e<=(a?-1:6);e++){let t=D+e/6*A;r.fillText($R(t,A/6),l+e/6*u,le)}r.textBaseline=`bottom`,a||r.fillText(h,l+u/2,n-5);let{shiftMode:ue}=Ie.current;ue&&(r.globalAlpha=.8,r.font=`10px ${Q.sans}`,r.fillStyle=p,r.textAlign=`center`,r.textBaseline=`top`,r.fillText(`⇄ shifting: ${ue.label}`,l+u/2,o+3),r.globalAlpha=1);let de=Ie.current.envelopes;if(de?.length){r.save(),r.beginPath(),r.rect(l,o,u,d),r.clip();for(let e of de){let t=R.find(t=>t.id===e.seriesId||t.id.startsWith(`${e.seriesId}__`));if(!t)continue;let{bandTop:n,bandBottom:i}=UV(o,d,t.bandFromPct,t.bandToPct),a=e=>HV(e,n,i,t.scaleMin,t.scaleMax);r.fillStyle=e.color,r.globalAlpha=.2;let s=0;for(;s<e.x.length;){for(;s<e.x.length&&e.lo[s]!==e.lo[s];)s++;let t=s;for(;s<e.x.length&&e.lo[s]===e.lo[s];)s++;if(!(s-t<2)){r.beginPath(),r.moveTo(L(e.x[t]),a(e.hi[t]));for(let n=t+1;n<s;n++)r.lineTo(L(e.x[n]),a(e.hi[n]));for(let n=s-1;n>=t;n--)r.lineTo(L(e.x[n]),a(e.lo[n]));r.closePath(),r.fill()}}}r.restore()}I.current&&=(clearTimeout(I.current),null);let fe=yV&&!P.current?N.current:null;if(yV&&!fe&&!P.current&&E.current&&!F.current&&(fe=DB()?FB(E.current):IB(E.current),fe?(N.current=fe,F.current=!0):P.current=!0),fe){fe.resize(t,n,window.devicePixelRatio||1);let e=`${l.toFixed(2)}|${u.toFixed(2)}|${o}|${d}|${b}|`+R.map(e=>`${e.id}:${e.column}:${e.bandFromPct}:${e.bandToPct}:${e.scaleMin}:${e.scaleMax}:${e.color}`).join(`,`),r=Ze(C),i=B.current;for(let t=0;t<Math.max(r.length,i.length);t++){let n=r[t];if(!n){i[t]&&fe.clear(t),i[t]=null;continue}let a=R.filter(e=>$e(t,n,e.column)),s=a.map(e=>e.column).join(`
205
+ `),c=i[t];if(c&&c.pts===n.pts&&c.sig===e&&c.cols===s)continue;i[t]={pts:n.pts,sig:e,cols:s};let f={styles:a.map(e=>{let{bandTop:t,bandBottom:n}=UV(o,d,e.bandFromPct,e.bandToPct);return{color:lB(e.color),bandTop:t,bandBottom:n,scaleMin:e.scaleMin,scaleMax:e.scaleMax,gapMedian:tt(C,e.column),width:b}}),left:l,plotW:u,xmin:D,xmax:k};if(c&&c.pts===n.pts&&c.cols===s){fe.setStyle(t,f);continue}let p=n.pts,m=!!c&&c.pts.x===p.x&&c.pts.brk===p.brk&&c.cols===s;fe.setData(t,{...f,xs:m?null:p.x.slice(),breaks:m?void 0:p.brk?.slice(),columns:a.map(e=>qV(p,e.column))})}i.length=r.length,fe.setView(D,k)}else{let e=j.current;vV&&!e&&!M.current&&E.current&&!F.current&&(e=hB(E.current),e?j.current=e:M.current=!0);let i=!!e;i&&e&&e.resize(t,n,window.devicePixelRatio||1);let a=[],s=Ye(C,R.map(e=>e.column),A);for(let e of R){let{bandTop:t,bandBottom:n}=UV(o,d,e.bandFromPct,e.bandToPct),c=s.get(e.column);if(i){let r={x:l,y:t,w:u,h:n-t},i=lB(e.color),o=[],s=null,d=()=>{o.length>=4&&a.push({points:Float32Array.from(o),color:i,clip:r,width:b}),o=[]};for(let r of C){let i=r.cols.get(e.column);if(i){s=null;for(let a=0;a<r.length;a++){r.brk?.[a]&&d();let l=i[a];if(!Number.isFinite(l))continue;let u=r.x[a];s!==null&&Math.abs(u-s)>c&&d(),o.push(L(u),HV(l,t,n,e.scaleMin,e.scaleMax)),s=u}d()}}d();continue}r.strokeStyle=e.color,r.lineWidth=b,r.lineJoin=`round`,r.lineCap=`round`,r.save(),r.beginPath(),r.rect(l,t,u,n-t),r.clip(),r.beginPath();let f=!1,p=null,m=!1;for(let i of C){let a=i.cols.get(e.column);if(a){m=!0;for(let o=0;o<i.length;o++){i.brk?.[o]&&(m=!0);let s=a[o];if(!Number.isFinite(s))continue;let l=i.x[o],u=L(l),d=HV(s,t,n,e.scaleMin,e.scaleMax);f?m||p!==null&&Math.abs(l-p)>c?(r.stroke(),r.beginPath(),r.moveTo(u,d),p=l,m=!1):(r.lineTo(u,d),p=l):(r.moveTo(u,d),f=!0,p=l,m=!1)}}}f&&r.stroke(),r.restore()}i&&e&&e.draw(a)}for(let e of R){if(!e.alarm)continue;let{bandTop:t,bandBottom:n}=UV(o,d,e.bandFromPct,e.bandToPct),i=HV(e.alarm.value,t,n,e.scaleMin,e.scaleMax);r.save(),r.beginPath(),r.rect(l,t,u,n-t),r.clip(),r.strokeStyle=e.alarm.color,r.lineWidth=e.alarm.width,r.setLineDash(xV(e.alarm.style)),r.beginPath(),r.moveTo(l,i),r.lineTo(l+u,i),r.stroke(),r.setLineDash([]),r.restore()}if(a)return;let pe=S?qe(C,R.map(e=>e.column)):null,me=e=>{let t=pe?.get(e.column);if(typeof t!=`number`)return`-`;let n=x[e.column]?.trim()??``;return`${ez(t)}${n?` ${n}`:``}`},he=l+u+8;r.font=jV,r.textAlign=`left`;for(let e of z){let t=V.get(e.leader.id);if(t===void 0)continue;let i=e.members.length>1;if(r.fillStyle=i?p:e.leader.color,r.globalAlpha=1,r.fillText(e.base,he,t+MV),i){let i=GV(e.members.length,t,n);for(let n=0;n<i;n++)r.fillStyle=e.members[n].color,r.globalAlpha=FV,r.fillText(me(e.members[n]),he,t+MV+(n+1)*IV)}else r.fillStyle=e.leader.color,r.globalAlpha=FV,r.fillText(me(e.leader),he,t+NV);r.globalAlpha=1}}function st(){let e=D.current;if(!e)return;let{w:t,h:n}=it(),r=at(e,t,n);if(!r)return;r.clearRect(0,0,t,n);let{top:i,right:a,bottom:o,left:s}=DV(t),c=t-s-a,l=n-i-o,{series:u,columnUnits:d,xLabel:f}=Ie.current,p=Je();if(ge.current&&c>0&&l>0){let e=_e.current,t=ve.current,n=ye.current,i=be.current,a=Math.min(e,n),o=Math.min(t,i),s=Math.abs(n-e),c=Math.abs(i-t);r.fillStyle=`rgba(59, 130, 246, 0.12)`,r.fillRect(a,o,s,c),r.strokeStyle=`rgba(59, 130, 246, 0.85)`,r.setLineDash([4,3]),r.lineWidth=1,r.strokeRect(a,o,s,c),r.setLineDash([])}let m=L.current;if(m===null||KV(p)<2||c<=0||l<=0)return;let{xmin:h,xmax:g}=Ke(),_=u.filter(e=>e.bandToPct>e.bandFromPct&&e.scaleMin!==e.scaleMax&&et(p,e.column)),v=[...new Set(_.map(e=>e.column))],y=Ye(p,v,g-h),{bg:b,muted:x}=rt();r.strokeStyle=x,r.globalAlpha=.5,r.lineWidth=1,r.beginPath(),r.moveTo(m,i),r.lineTo(m,i+l),r.stroke(),r.globalAlpha=1;let S=JV(_),C=YV(S,i,l),w=s+c+8;r.font=jV,r.textAlign=`left`;let T=LB(m,s,c,h,g),E=RB(p,T,v,y),O=e=>{let t=E.get(e.column);if(typeof t!=`number`)return`-`;let n=d[e.column]?.trim()??``;return`${ez(t)}${n?` ${n}`:``}`};for(let e of S){let t=C.get(e.leader.id)??UV(i,l,e.leader.bandFromPct,e.leader.bandToPct).bandTop;if(e.members.length>1){let i=e.members.length*IV+4;r.fillStyle=b,r.fillRect(s+c+6,t+MV+2,a-8,i);let o=GV(e.members.length,t,n);for(let n=0;n<o;n++){let i=e.members[n];r.fillStyle=i.color,r.globalAlpha=FV,r.fillText(O(i),w,t+MV+(n+1)*IV)}}else{let n=e.leader;r.fillStyle=b,r.fillRect(s+c+6,t+MV+2,a-8,NV-MV+6),r.fillStyle=n.color,r.globalAlpha=FV,r.fillText(O(n),w,t+NV)}r.globalAlpha=1}let k=/^(.*?)\s*\(([^)]*)\)\s*$/.exec(f),A=k?k[1]:f,j=k?k[2].trim():``,M=`${A} ${Math.round(T)}${j}`;r.font=jV,r.textAlign=`left`,r.textBaseline=`alphabetic`;let N=r.measureText(M).width,P=i+l;r.fillStyle=b,r.fillRect(w-2,P-11,N+6,15),r.fillStyle=x,r.globalAlpha=1,r.fillText(M,w,P)}function ct(){if(oe.current){ie.current=!0;return}Me.current=()=>{ot(),st()},!Ae.current&&(Ae.current=eV(e=>{Ae.current=0,Ne.current=e,Me.current?.()}))}function lt(){if(oe.current){ie.current=!0;return}let e=O.current?.ownerDocument.timeline?.currentTime;if(typeof e!=`number`||e===Ne.current){ct();return}Ne.current=e,tV(Ae.current),Ae.current=0,ot(),st()}function ut(){Pe.current=st,!je.current&&(je.current=eV(()=>{je.current=0,Pe.current?.()}))}function dt(e){ne.current=eV(dt);let t=oe.current;if(!t)return;let n=t.xBounds();n&&n[1]>n[0]&&(We.current={xmin:n[0],xmax:n[1]});let r=le.current?Math.min(64,e-le.current):16;le.current=e;let i=t.latestT?.(),a;if(i!==void 0&&t.xAtTime&&Number.isFinite(i)){let e=t.xAtTime(qB(ce.current,i,r));Number.isFinite(e)&&(a=e)}if(Ge()){let n=a??t.latestX?.()??We.current.xmax,r=ue.current,i=r!=null&&t.spanForSeconds?t.spanForSeconds(r):r??me.current,[o,s]=HB(We.current.xmin,We.current.xmax,i,n??void 0);if(Number.isFinite(o)&&Number.isFinite(s)&&s>o){let t=s-o,n=H.current!==null&&s<H.current-t;if(te.current===null||H.current===null||n)te.current=o,H.current=s,re.current=e;else{let n=re.current;re.current=e;let r=VB(n?Math.min(64,e-n):16,OV);te.current+=(o-te.current)*r,H.current+=(s-H.current)*r,Math.abs(o-te.current)<t*1e-6&&(te.current=o),Math.abs(s-H.current)<t*1e-6&&(H.current=s)}}}else te.current=null,H.current=null,re.current=0;let o=Ke(),s=t.version?.(),c=ae.current,l=se.current,u=l!==null&&s!==void 0&&l.ver===s&&l.x0===o.xmin&&l.x1===o.xmax&&l.mp===c&&l.cut===a;(KV(he.current)===0||!u&&e-U.current>=AV)&&(U.current=e,he.current=t.pull(o.xmin,o.xmax,c,a),se.current=s===void 0?null:{ver:s,x0:o.xmin,x1:o.xmax,mp:c,cut:a}),ie.current=!1,ot(),st()}function ft(){ne.current||=(re.current=0,eV(dt))}function pt(){ne.current&&(tV(ne.current),ne.current=0,le.current=0,te.current=null,H.current=null,he.current=[])}W(()=>(y?ft():(pt(),ct()),pt),[!!y]),W(()=>cz(O.current,()=>{Fe.current=null,ct()}),[]),W(()=>{Fe.current=null,ct()},[o]);let mt=!!f;W(()=>{let e=D.current;e&&(e.style.cursor=mt?`ew-resize`:``),ct()},[mt,f?.label??``]);let ht=s?.[0]??null,gt=s?.[1]??null;return G(()=>{V.current===ht&&ee.current===gt||(V.current=ht,ee.current=gt,ct())},[ht,gt]),W(()=>{lt()},[t,n,i,e,p,m,h,g,v]),W(()=>()=>{tV(Ae.current),tV(je.current),Ae.current=0,je.current=0},[]),W(()=>{let e=D.current,t=O.current;if(!e||!t)return;let n=()=>{let e=Math.round(t.clientWidth);e>0&&e!==A.current&&(A.current=e,k.current?.(e))};n();let r=new oV(()=>{Fe.current=null,n(),ct()});r.observe(t);let i=t=>{if(ge.current||Oe.current!==null)return;if(KV(Je())<2){L.current!==null&&(L.current=null,ut());return}let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,{left:a,top:o,right:s,bottom:c}=DV(n.width),l=Math.max(1,n.width-a-s),u=n.height-o-c;if(r<a||r>a+l||i<o||i>o+u){L.current!==null&&(L.current=null,ut());return}L.current!==r&&(L.current=r,ut())},a=()=>{L.current!==null&&(L.current=null,ut())},o=e=>{Le.current&&clearTimeout(Le.current),Le.current=setTimeout(()=>{Le.current=null,ze.current?.(e)},bV)},s=t=>{if(xe.current!==`none`||t.buttons&2||Date.now()-we.current<300||KV(Je())<2)return;let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,{top:a,left:s,right:c,bottom:l}=DV(n.width),u=Math.max(1,n.width-s-c),d=Math.max(1,n.height-a-l);if(r<s||r>s+u||i<a||i>a+d)return;t.preventDefault();let f=We.current,p=f.xmax-f.xmin;if(!(p>0))return;if(pe.current===`follow`&&Ge()&&!de.current){me.current=GB(me.current,p,t.deltaY<0,p*.001);return}if(pe.current===`follow`&&Ge()){let e=GB(ue.current,oe.current?.bufferedSeconds?.()??p,t.deltaY<0);ue.current=e,Re.current&&clearTimeout(Re.current),Re.current=setTimeout(()=>{Re.current=null,de.current?.(e)},bV);return}let m=V.current??f.xmin,h=(ee.current??f.xmax)-m;if(!(h>0))return;let g=Date.now();g-Ce.current>300&&(Te.current=V.current,Ee.current=ee.current),Ce.current=g;let _=m+(r-s)/u*h,v=t.deltaY<0,y=.88,b=v?h*y:h/y,x=Math.max(p*1e-7,1e-12);if(v)b=Math.max(b,x);else{if(b>=p*.999){V.current=null,ee.current=null,o(null),Be.current?.publish(Ve.current??``,null),ct();return}b=Math.min(b,p)}let S=(_-m)/h,C=_-S*b,w=_+(1-S)*b;C<f.xmin&&(w+=f.xmin-C,C=f.xmin),w>f.xmax&&(C-=w-f.xmax,w=f.xmax),w-C<b-1e-12&&(C=Math.max(f.xmin,_-b/2),w=C+b,w>f.xmax&&(w=f.xmax,C=w-b)),w-C>=p*.999?(V.current=null,ee.current=null,o(null),Be.current?.publish(Ve.current??``,null)):(V.current=C,ee.current=w,o([C,w]),Be.current?.publish(Ve.current??``,[C,w])),ct()},c=e=>{if(e.preventDefault(),we.current=Date.now(),Date.now()-Ce.current<300){V.current=Te.current,ee.current=Ee.current;let e=Te.current,t=Ee.current;Le.current&&=(clearTimeout(Le.current),null),ze.current?.(e===null&&t===null?null:[e,t]),Ce.current=0,ct()}},l=t=>{if(t.button===0&&De.current){let n=e.getBoundingClientRect(),{left:r,top:i,right:a,bottom:o}=DV(n.width),s=Math.max(1,n.width-r-a),c=n.height-i-o,l=t.clientX-n.left,u=t.clientY-n.top;if(l>=r&&l<=r+s&&u>=i&&u<=i+c){Oe.current=t.clientX,De.current.onDragStart();try{e.setPointerCapture(t.pointerId)}catch{}}return}if(t.button!==2)return;if(t.preventDefault(),t.buttons===0){He.current?.({clientX:t.clientX,clientY:t.clientY});return}if(xe.current!==`none`){ge.current=!1,xe.current=`none`;try{e.releasePointerCapture(t.pointerId)}catch{}}let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top;Se.current=Date.now(),xe.current=`menuOnly`,ge.current=!1,_e.current=r,ve.current=i,ye.current=r,be.current=i;try{e.setPointerCapture(t.pointerId)}catch{}},u=t=>{if(Oe.current!==null){let n=t.clientX-Oe.current,r=e.getBoundingClientRect(),{left:i,right:a}=DV(r.width),o=Math.max(1,r.width-i-a),{xmin:s,xmax:c}=Ke(),l=c-s;l>0&&o>0&&De.current?.onDragOffset(n/o*l);return}if(xe.current===`none`)return;let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top;if(xe.current===`menuOnly`){if(Date.now()-Se.current<150)return;let e=r-_e.current,t=i-ve.current;if(Math.sqrt(e*e+t*t)<12)return;let a=Je(),{top:o,left:s,right:c,bottom:l}=DV(n.width),u=n.width-s-c,d=n.height-o-l,f=u>0&&d>0&&_e.current>=s&&_e.current<=s+u&&ve.current>=o&&ve.current<=o+d;if(KV(a)<2||!f)return;xe.current=`rubber`,ge.current=!0,L.current=null}xe.current===`rubber`&&(t.preventDefault(),ye.current=r,be.current=i,ut())},d=t=>{if(t.button!==2)return;t.preventDefault();let n=xe.current;xe.current=`none`;try{e.releasePointerCapture(t.pointerId)}catch{}if(n===`menuOnly`){ge.current=!1,ut(),He.current?.({clientX:t.clientX,clientY:t.clientY});return}if(n!==`rubber`||!ge.current){ge.current=!1,ut();return}ge.current=!1;let r=Je(),i=e.getBoundingClientRect(),{left:a,right:o}=DV(i.width),s=Math.max(1,i.width-a-o),c=_e.current,l=ye.current,u=Math.abs(l-c);if(KV(r)<2||u<12){He.current?.({clientX:t.clientX,clientY:t.clientY}),ut();return}let d=VV(Math.min(c,l),a,a+s),f=VV(Math.max(c,l),a,a+s),{xmin:p,xmax:m}=Ke(),h=m-p;if(!(h>0)){He.current?.({clientX:t.clientX,clientY:t.clientY}),ut();return}let g=p+(d-a)/s*h,_=p+(f-a)/s*h;if(g>_){let e=g;g=_,_=e}let v=We.current,y=Math.min(v.xmin,v.xmax),b=Math.max(v.xmin,v.xmax);g=VV(g,y,b),_=VV(_,y,b);let x=_-g;if(x<=(b-y)*1e-12||x<=0){He.current?.({clientX:t.clientX,clientY:t.clientY}),ut();return}He.current?.({clientX:t.clientX,clientY:t.clientY,zoomXRange:[g,_]}),ut()},f=t=>{if(t.button===0&&Oe.current!==null){Oe.current=null;try{e.releasePointerCapture(t.pointerId)}catch{}return}if(t.button===2){d(t);return}if(t.buttons===0&&xe.current!==`none`){xe.current=`none`,ge.current=!1;try{e.releasePointerCapture(t.pointerId)}catch{}He.current?.({clientX:t.clientX,clientY:t.clientY}),ut()}},p=t=>{Oe.current!==null&&(Oe.current=null),xe.current!==`none`&&(ge.current=!1,xe.current=`none`);try{e.releasePointerCapture(t.pointerId)}catch{}ut()},m=t=>{if(t.button!==0||KV(Je())<2)return;let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,{top:a,left:o,right:s,bottom:c}=DV(n.width),l=Math.max(1,n.width-o-s),u=Math.max(1,n.height-a-c);r<o||r>o+l||i<a||i>a+u||V.current===null&&ee.current===null||(V.current=null,ee.current=null,Le.current&&=(clearTimeout(Le.current),null),ze.current?.(null),Be.current?.publish(Ve.current??``,null),ct(),ut())},h=e=>{if(e.key!==`Escape`)return;let t=!1;xe.current!==`none`&&(xe.current=`none`,ge.current=!1,t=!0),Oe.current!==null&&(Oe.current=null,t=!0),t&&ut()};e.addEventListener(`mousemove`,i),e.addEventListener(`mouseleave`,a),e.addEventListener(`wheel`,s,{passive:!1}),e.addEventListener(`contextmenu`,c),e.addEventListener(`pointerdown`,l),e.addEventListener(`pointermove`,u),e.addEventListener(`pointerup`,f),e.addEventListener(`pointercancel`,p),e.addEventListener(`dblclick`,m);let g=e.ownerDocument.defaultView??window;return g.addEventListener(`keydown`,h),()=>{r.disconnect(),e.removeEventListener(`mousemove`,i),e.removeEventListener(`mouseleave`,a),e.removeEventListener(`wheel`,s),e.removeEventListener(`contextmenu`,c),e.removeEventListener(`pointerdown`,l),e.removeEventListener(`pointermove`,u),e.removeEventListener(`pointerup`,f),e.removeEventListener(`pointercancel`,p),e.removeEventListener(`dblclick`,m),g.removeEventListener(`keydown`,h),Le.current&&clearTimeout(Le.current),Re.current&&clearTimeout(Re.current)}},[]),nt(`div`,{ref:O,className:`chart-canvas-wrap`,children:[q(`canvas`,{ref:T,className:`chart-canvas`,role:`img`,"aria-label":`Chart of ${e}`}),q(`canvas`,{ref:E,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:D,className:`chart-canvas chart-overlay`})]})}function iH(){try{if(localStorage.getItem(`perfLog`)===`1`)return!0;if(localStorage.getItem(`perfLog`)===`0`)return!1}catch{}return!1}var aH=!1;function oH(){let e=iH();return e&&!aH&&(aH=!0,console.log(`[perf] logging enabled — zoom an out-of-core chart to see decimate()/sampleRows timings`)),e}oH();var sH=new Map;function cH(e,t){let n=(sH.get(e)??0)+1;sH.set(e,n),console.log(`[perf] ${e} #${n} ${t.toFixed(1)}ms`)}async function lH(e,t){if(!oH())return t();let n=performance.now();try{return await t()}finally{cH(e,performance.now()-n)}}var uH=20;async function dH(e,t,n,r){let{x0:i,bucket:a,rows:o,columns:s}=await lH(`decimate(${t.length}col)`,()=>e.getSeriesMulti(t,n,r));return re(o,s,i,a)}function fH(e,t,n,r,i=0,a=!1,o=0){let[s,c]=Ze({points:ye,fetchedViewport:null}),[l,u]=Ze(!1),d=`${t.join(`,`)}|${n?`${n.xKey}:${n.x0}:${n.x1}`:`none`}|${r}|${i}`,f=Xe(()=>{if(!a||!e?.getSeriesMultiSync||!n||t.length===0)return null;let i=o>0?e.getColumnsSync?.(t,n,o):null;if(i)return{points:i,loading:!1,fetchedViewport:n,full:!0};let s=e.getSeriesMultiSync(t,n,r);return{points:re(s.rows,s.columns,s.x0,s.bucket),loading:!1,fetchedViewport:n}},[a,e,d,o]);return W(()=>{if(a)return;if(!e||!n||t.length===0){c({points:ye,fetchedViewport:null});return}let i=!0;u(!0);let o=setTimeout(()=>{dH(e,t,n,r).then(t=>{i&&(c({points:t,fetchedViewport:n,source:e}),u(!1))}).catch(()=>{i&&u(!1)})},uH);return()=>{i=!1,clearTimeout(o)}},[e,d,a]),f||(s.source!==void 0&&s.source!==e?{points:ye,loading:l,fetchedViewport:null}:{points:s.points,loading:l,fetchedViewport:s.fetchedViewport})}var pH=250,mH=2,hH=6e3,gH=2e6,_H=[];function vH(e,t,n,r,i,a){let o=!!e&&e.columnSet.has(n),s=Xe(()=>e&&o?t.filter(t=>e.columnSet.has(t)):_H,[e,o,t]),c=e&&o&&s.length>0?e.source:null,l=!!c&&!e?.live&&!!c.getSeriesMultiSync&&!!c.xBoundsSync,u=Xe(()=>l&&c?c.xBoundsSync(n):null,[l,c,n]),[d,f]=Ze(null),p=!!e?.live;W(()=>{if(!c||l)return;let e=!0,t=()=>c.xBounds(n).then(t=>{let r=c.version?.()??0;e&&f(e=>e&&e.source===c&&e.xKey===n&&e.ver===r?e:{source:c,xKey:n,b:t,ver:r})}).catch(()=>{});t();let r=p?setInterval(t,pH):void 0;return()=>{e=!1,clearInterval(r)}},[c,n,p,l]);let m=d&&d.source===c&&d.xKey===n?d:null,h=u??m?.b??null,g=m?.ver??0,{points:_,loading:v,full:y}=fH(c,s,c&&h&&h.x1>h.x0?{xKey:n,x0:h.x0,x1:h.x1}:null,Math.min(hH,i*mH),g,l,a),b=e?.xOffset??0,x=r&&r[1]>r[0]?r[0]-b:null,S=r&&r[1]>r[0]?r[1]-b:null,C=y||!!h&&x!==null&&S!==null&&x<=h.x0&&S>=h.x1,{points:w,fetchedViewport:T}=fH(c,s,c&&x!==null&&S!==null&&!C?{xKey:n,x0:x,x1:S}:null,i,g,l,a),E=Xe(()=>!T||w.length===0?_:ee([Fe(_,e=>e<T.x0),w,Fe(_,e=>e>T.x1)]),[_,w,T]),D=!!c&&(h===null||v);return Xe(()=>e?{points:Re(E,e.keySuffix,e.xOffset),bounds:h?{x0:h.x0+e.xOffset,x1:h.x1+e.xOffset}:null,loading:D}:{points:ye,bounds:null,loading:!1},[e,E,h,D])}var yH=new WeakMap,bH=0;function xH(e){if(e.key!==void 0)return e.key;let t=yH.get(e.source);return t===void 0&&yH.set(e.source,t=bH++),`${t}${e.keySuffix}`}function SH(){let[e,t]=Ze(()=>new Map);return[e,qe((e,n)=>t(t=>{if(n?t.get(e)===n:!t.has(e))return t;let r=new Map(t);return n?r.set(e,n):r.delete(e),r}),[])]}var CH=Ge(function({id:e,layer:t,columns:n,xKey:r,view:i,mp:a,rawLimit:o,report:s}){let c=vH(t,n,r,i,a,o);return G(()=>{s(e,c)},[e,c,s]),G(()=>()=>s(e,null),[e,s]),null});function wH({layers:e,xKey:t,columns:n,maxPoints:r,...i}){let a=i.viewXRange??null,[o,s]=Ze(null),c=typeof window<`u`?Math.min(3,Math.max(1,window.devicePixelRatio||1)):1,l=o==null?r:Math.min(r,Math.round(o*c/50)*50),u=Math.max(1e3,Math.round(l/Math.sqrt(Math.max(1,e.length)))),d=Math.floor(gH/Math.max(1,e.length)),[f,p]=SH(),m=Xe(()=>e.map(xH),[e]),h=Xe(()=>m.map(e=>f.get(e)),[m,f]),g=Xe(()=>h.flatMap(e=>e&&e.points.length>0?[e.points]:[]),[h]),_=Xe(()=>{let e=1/0,t=-1/0;for(let n of h){let r=n?.bounds;r&&(e=Math.min(e,r.x0),t=Math.max(t,r.x1))}return Number.isFinite(e)&&t>e?[e,t]:null},[h]),v=h.some(e=>!e||e.loading);return nt(tt,{children:[e.map((e,r)=>q(CH,{id:m[r],layer:e,columns:n,xKey:t,view:a,mp:u,rawLimit:d,report:p},m[r])),g.length===0?nt(`div`,{className:`chart-placeholder chart-placeholder--no-data`,onContextMenu:e=>{e.preventDefault(),i.onPlotContextMenu?.({clientX:e.clientX,clientY:e.clientY})},children:[q(`span`,{className:`content-empty-icon`,"aria-hidden":!0}),q(`h2`,{children:v?`Loading…`:`No data for the selected X axis`}),v?null:q(`p`,{children:`None of the selected datasets has this X column together with a plotted channel.`})]}):q(rH,{points:g,fullXRange:_,...i,onPlotWidthCss:s})]})}function TH(e){return!!e&&!Array.isArray(e)&&typeof e.length==`number`&&`x`in e&&`y`in e}function EH(e){let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=t>0&&e[0].c!==void 0?new Float32Array(t):void 0,a=e.some(e=>e.d!==void 0)?new Uint8Array(t):void 0;for(let o=0;o<t;o++){let t=e[o];n[o]=t.x,r[o]=t.y,i&&(i[o]=t.c??0),a&&(a[o]=t.d??0)}return{length:t,x:n,y:r,c:i,d:a}}function DH(e,t,n){let r=n?.get(t);if(r)return r;let i=P(e);if(i)return p(i,t);if(e.length===0||!(t in e[0]))return;let a=new Float64Array(e.length);for(let n=0;n<e.length;n++){let r=e[n][t];a[n]=typeof r==`number`?r:NaN}return a}function OH(e,t,n){let r=DH(e,t,n);if(!r||ze.has(r))return r;let i=0;for(let e=0;e<r.length;e++)r[e]-r[e]===0&&i++;if(i===r.length)return r;let a=new Float64Array(i);for(let e=0,t=0;e<r.length;e++)r[e]-r[e]===0&&(a[t++]=r[e]);return a}function kH(e,t,n,r){if(!n){let n=OH(e,t,r);return n?[{label:t,values:n}]:[]}let i=DH(e,t,r);if(!i)return[];let a=i.length,o=r?.has(n)||e.length>0&&typeof e[0][n]==`number`?DH(e,n,r):void 0,s=t=>{if(o){let e=o[t];return e===e?String(e):`unknown`}return String(e[t]?.[n]??`unknown`)},c=new Map,l=[],u=new Int32Array(a),d=[];for(let e=0;e<a;e++){if(i[e]-i[e]!==0){u[e]=-1;continue}let t=s(e),n=c.get(t);n===void 0&&(c.set(t,n=l.length),l.push(t),d.push(0)),u[e]=n,d[n]++}let f=l.map((e,t)=>({label:e,values:new Float64Array(d[t])})),p=new Int32Array(l.length);for(let e=0;e<a;e++){let t=u[e];t>=0&&(f[t].values[p[t]++]=i[e])}return f}function AH(e){let t=NaN,n=NaN,r=0;for(let i=0;i<e.length;i++){let a=e[i];a-a===0&&(r===0&&(t=a),n=a,r++)}let i=n-t;return r>1&&i>0?(r-1)/i:null}function jH(e,t,n){let r=0;for(let i=0;i<e.length;i++)e[i]>=t&&e[i]<=n&&r++;let i=new Uint32Array(r),a=0;for(let r=0;r<e.length;r++)e[r]>=t&&e[r]<=n&&(i[a++]=r);return i}function MH(e,t){let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n}function NH(e,t,n,r){let i=DH(e.rows,t,e.full),a=DH(e.rows,n,e.full);if(!i||!a)return null;let o=r.colorCol?DH(e.rows,r.colorCol,e.full):void 0;if(r.viewXRange){let t=DH(e.rows,r.xKey,e.full);if(t){let e=jH(t,r.viewXRange[0],r.viewXRange[1]);i=MH(i,e),a=MH(a,e),o&&=MH(o,e)}}let s=Math.min(i.length,a.length);if(!o)return{cols:{length:s,x:i,y:a}};let c=1/0,l=-1/0;for(let e=0;e<s;e++){let t=o[e];t<c&&(c=t),t>l&&(l=t)}if(!(l>c))return{cols:{length:s,x:i,y:a}};let u=new Float32Array(s),d=l-c;for(let e=0;e<s;e++){let t=o[e];u[e]=t===t?(t-c)/d:0}return{cols:{length:s,x:i,y:a,c:u},color:{label:r.colorCol,min:c,max:l}}}function PH(e,t,n,r){let i=[],a=[];e.forEach((e,o)=>{a.push(nz(r.colorOverrides,e.id,o,r.palette));let s=NH(e,t,n,{xKey:r.xKey,viewXRange:r.viewXRange});i.push(s?.cols??{length:0,x:[],y:[]})});let o=i.reduce((e,t)=>e+t.length,0),s=new Float64Array(o),c=new Float64Array(o),l=new Uint8Array(o),u=0;return i.forEach((e,t)=>{for(let t=0;t<e.length;t++)s[u+t]=e.x[t],c[u+t]=e.y[t];l.fill(Math.min(t,255),u,u+e.length),u+=e.length}),{cols:{length:o,x:s,y:c,d:l},colors:a}}var FH=e=>TH(e)?e:EH(e),IH=(e,t,n)=>t===t&&n===n&&(!e||t>=e.xmin&&t<=e.xmax&&n>=e.ymin&&n<=e.ymax);function LH(e,t,n){let r=t+1,i=Array.from({length:r},()=>Array(r).fill(0)),a=Array(r).fill(0),o=new Float64Array(2*r-1),s=0;for(let t=0;t<e.length;t++){let c=e.x[t],l=e.y[t];if(IH(n,c,l)){s++,o[0]=1;for(let e=1;e<o.length;e++)o[e]=o[e-1]*c;for(let e=0;e<r;e++){for(let t=0;t<r;t++)i[e][t]+=o[e+t];a[e]+=o[e]*l}}}if(s<r)return null;let c=i.map((e,t)=>[...e,a[t]]);for(let e=0;e<r;e++){let t=e;for(let n=e+1;n<r;n++)Math.abs(c[n][e])>Math.abs(c[t][e])&&(t=n);if([c[e],c[t]]=[c[t],c[e]],Math.abs(c[e][e])<1e-10)return null;let n=c[e][e];for(let t=e;t<=r;t++)c[e][t]/=n;for(let t=0;t<r;t++){if(t===e)continue;let n=c[t][e];for(let i=e;i<=r;i++)c[t][i]-=n*c[e][i]}}return c.map(e=>e[r])}function RH(e,t,n){return LH(FH(e),t,n)}function zH(e,t){let n=FH(e),r=0,i=0;for(let e=0;e<n.length;e++)IH(void 0,n.x[e],n.y[e])&&(r++,i+=n.y[e]);if(r===0)return 0;let a=i/r,o=0,s=0;for(let e=0;e<n.length;e++){let r=n.x[e],i=n.y[e];if(!IH(void 0,r,i))continue;let c=0;for(let e=t.length-1;e>=0;e--)c=c*r+t[e];o+=(i-a)**2,s+=(i-c)**2}return o<1e-15?1:Math.max(0,1-s/o)}function BH(e,t=4){if(!Number.isFinite(e))return`?`;let n=Math.abs(e);return n===0?`0`:n>=1e5||n>0&&n<.001?e.toExponential(2):e.toPrecision(t).replace(/\.?0+$/,``)}function VH(e,t,n){let r=[];for(let n=e.length-1;n>=0;n--){let i=e[n];n===0?r.push(BH(i)):n===1?r.push(`${BH(i)}·${t}`):r.push(`${BH(i)}·${t}${n>1?`^${n}`:``}`)}return`${n} = ${r.join(` + `).replace(/\+ -/g,`− `)}`}var HH=[[0,45,80,160],[.25,40,145,175],[.5,60,180,110],[.75,220,175,55],[1,210,75,55]];function UH(e){let t=0;for(let n=1;n<HH.length;n++){if(e<=HH[n][0]){t=n-1;break}n===HH.length-1&&(t=n-1)}let n=t+1,r=(e-HH[t][0])/(HH[n][0]-HH[t][0]);return{r:Math.round(HH[t][1]+r*(HH[n][1]-HH[t][1])),g:Math.round(HH[t][2]+r*(HH[n][2]-HH[t][2])),b:Math.round(HH[t][3]+r*(HH[n][3]-HH[t][3]))}}function WH(e){let{r:t,g:n,b:r}=UH(e);return`rgb(${t},${n},${r})`}function GH(e,t){if(!Number.isFinite(e))return 0;let n=Math.floor(e*t);return n<0?0:n>=t?t-1:n}var KH=`#version 300 es
206
+ in vec2 a_corner;
207
+ in float a_x;
208
+ in float a_y;
209
+ in float a_k;
210
+ in float a_r; // the point's own radius (CSS px), or 0: u_radius
211
+ uniform vec2 u_resolution;
212
+ uniform vec4 u_plot; // left, top, width, height (CSS px)
213
+ uniform vec4 u_view; // xmin, xmax, ymin, ymax (relative to the origin)
214
+ uniform float u_radius;
215
+ uniform float u_kScale; // colour texel per k: 255 for a 0..1 value, 1 for an index
216
+ out vec2 v_local;
217
+ out float v_tex;
218
+ out float v_r;
219
+ void main() {
220
+ v_r = a_r > 0.0 ? a_r : u_radius;
221
+ float quad = v_r + 0.5; // the radius plus the half pixel the antialiased edge reaches
222
+ vec2 p = vec2(
223
+ u_plot.x + (a_x - u_view.x) / (u_view.y - u_view.x) * u_plot.z,
224
+ u_plot.y + (u_view.w - a_y) / (u_view.w - u_view.z) * u_plot.w);
225
+ vec2 pos = p + a_corner * quad;
226
+ v_local = a_corner * quad;
227
+ v_tex = (clamp(floor(a_k * u_kScale + 0.5), 0.0, 255.0) + 0.5) / 256.0;
228
+ vec2 clip = pos / u_resolution * 2.0 - 1.0;
229
+ gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
230
+ }`,qH=`#version 300 es
231
+ precision highp float;
232
+ in vec2 v_local;
233
+ in float v_tex;
234
+ in float v_r; // disc radius (without the feather)
235
+ uniform sampler2D u_palette;
236
+ uniform float u_alpha;
237
+ uniform vec4 u_clip; // left, top, right, bottom (device px from the top)
238
+ uniform float u_dpr;
239
+ uniform float u_height; // canvas height (device px)
240
+ out vec4 outColor;
241
+ void main() {
242
+ vec2 frag = vec2(gl_FragCoord.x, u_height - gl_FragCoord.y) / u_dpr;
243
+ if (frag.x < u_clip.x || frag.x > u_clip.z || frag.y < u_clip.y || frag.y > u_clip.w) discard;
244
+ float d = length(v_local);
245
+ float cov = clamp(v_r - d + 0.5, 0.0, 1.0);
246
+ if (cov <= 0.0) discard;
247
+ vec4 c = texture(u_palette, vec2(v_tex, 0.5));
248
+ float a = c.a * u_alpha * cov;
249
+ outColor = vec4(c.rgb * a, a);
250
+ }`,JH=`#version 300 es
251
+ in float a_x;
252
+ in float a_y;
253
+ in float a_k;
254
+ uniform vec2 u_resolution;
255
+ uniform vec4 u_plot;
256
+ uniform vec4 u_view;
257
+ uniform float u_radius;
258
+ uniform float u_kScale;
259
+ uniform float u_dpr;
260
+ out float v_tex;
261
+ void main() {
262
+ vec2 p = vec2(
263
+ u_plot.x + (a_x - u_view.x) / (u_view.y - u_view.x) * u_plot.z,
264
+ u_plot.y + (u_view.w - a_y) / (u_view.w - u_view.z) * u_plot.w);
265
+ gl_PointSize = 2.0 * (u_radius + 0.5) * u_dpr;
266
+ v_tex = (clamp(floor(a_k * u_kScale + 0.5), 0.0, 255.0) + 0.5) / 256.0;
267
+ vec2 clip = p / u_resolution * 2.0 - 1.0;
268
+ gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
269
+ }`,YH=`#version 300 es
270
+ precision highp float;
271
+ in float v_tex;
272
+ uniform sampler2D u_palette;
273
+ uniform float u_radius;
274
+ uniform float u_alpha;
275
+ uniform vec4 u_clip;
276
+ uniform float u_dpr;
277
+ uniform float u_height;
278
+ out vec4 outColor;
279
+ void main() {
280
+ vec2 frag = vec2(gl_FragCoord.x, u_height - gl_FragCoord.y) / u_dpr;
281
+ if (frag.x < u_clip.x || frag.x > u_clip.z || frag.y < u_clip.y || frag.y > u_clip.w) discard;
282
+ float d = length((gl_PointCoord * 2.0 - 1.0) * (u_radius + 0.5));
283
+ float cov = clamp(u_radius - d + 0.5, 0.0, 1.0);
284
+ if (cov <= 0.0) discard;
285
+ vec4 c = texture(u_palette, vec2(v_tex, 0.5));
286
+ float a = c.a * u_alpha * cov;
287
+ outColor = vec4(c.rgb * a, a);
288
+ }`,XH=`#version 300 es
289
+ in vec2 a_corner;
290
+ in float a_ax;
291
+ in float a_ay;
292
+ in float a_bx;
293
+ in float a_by;
294
+ in float a_bstart; // 1 where the END point starts a new trace: no segment
295
+ in float a_k;
296
+ uniform vec2 u_resolution;
297
+ uniform vec4 u_plot;
298
+ uniform vec4 u_view;
299
+ uniform float u_ext; // half width + antialiasing (CSS px)
300
+ uniform float u_kScale;
301
+ flat out vec2 v_a;
302
+ flat out vec2 v_b;
303
+ out vec2 v_pos;
304
+ out float v_tex;
305
+ vec2 project(float x, float y) {
306
+ return vec2(u_plot.x + (x - u_view.x) / (u_view.y - u_view.x) * u_plot.z,
307
+ u_plot.y + (u_view.w - y) / (u_view.w - u_view.z) * u_plot.w);
308
+ }
309
+ void main() {
310
+ if (a_bstart > 0.5) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); v_a = vec2(0.0); v_b = vec2(0.0); v_pos = vec2(0.0); v_tex = 0.0; return; }
311
+ vec2 a = project(a_ax, a_ay);
312
+ vec2 b = project(a_bx, a_by);
313
+ vec2 ab = b - a;
314
+ float len = length(ab);
315
+ vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
316
+ vec2 n = vec2(-dir.y, dir.x);
317
+ vec2 base = mix(a, b, step(0.0, a_corner.x));
318
+ vec2 pos = base + dir * (a_corner.x * u_ext) + n * (a_corner.y * u_ext);
319
+ v_a = a; v_b = b; v_pos = pos;
320
+ v_tex = (clamp(floor(a_k * u_kScale + 0.5), 0.0, 255.0) + 0.5) / 256.0;
321
+ vec2 clip = pos / u_resolution * 2.0 - 1.0;
322
+ gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
323
+ }`,ZH=`#version 300 es
324
+ precision highp float;
325
+ flat in vec2 v_a;
326
+ flat in vec2 v_b;
327
+ in vec2 v_pos;
328
+ in float v_tex;
329
+ uniform sampler2D u_palette;
330
+ uniform float u_half; // half line width (CSS px)
331
+ uniform vec4 u_clip;
332
+ out vec4 outColor;
333
+ void main() {
334
+ if (v_pos.x < u_clip.x || v_pos.x > u_clip.z || v_pos.y < u_clip.y || v_pos.y > u_clip.w) discard;
335
+ vec2 ab = v_b - v_a;
336
+ float t = clamp(dot(v_pos - v_a, ab) / max(dot(ab, ab), 1e-12), 0.0, 1.0);
337
+ float d = distance(v_pos, v_a + ab * t);
338
+ float aa = max(fwidth(d), 1e-4);
339
+ float cov = clamp((u_half - d) / aa + 0.5, 0.0, 1.0);
340
+ if (cov <= 0.0) discard;
341
+ vec4 c = texture(u_palette, vec2(v_tex, 0.5));
342
+ float a = c.a * cov;
343
+ outColor = vec4(c.rgb * a, a);
344
+ }`,QH=`
345
+ uniform vec2 u_ox;
346
+ uniform vec2 u_oy;
347
+ float dbl(uvec2 b, vec2 o) {
348
+ uint e = (b.y >> 20) & 0x7FFu;
349
+ if (e == 0x7FFu) return uintBitsToFloat(0x7FC00000u);
350
+ int fe = int(e) - 896;
351
+ if (e == 0u || fe <= 0) return -o.x - o.y;
352
+ if (fe >= 255) return uintBitsToFloat(0x7FC00000u);
353
+ uint sgn = b.y & 0x80000000u;
354
+ float h = uintBitsToFloat(sgn | (uint(fe) << 23) | ((b.y & 0xFFFFFu) << 3) | (b.x >> 29));
355
+ float l = float(b.x & 0x1FFFFFFFu) * exp2(float(int(e) - 1075));
356
+ return (h - o.x) + ((sgn != 0u ? -l : l) - o.y);
357
+ }
358
+ `;function $H(e,t,n,r){let i=QH,a=e,o=[];for(let[e,r]of[[t,`u_ox`],[n,`u_oy`]])for(let t of e)a=a.replace(`in float ${t};`,`in uvec2 ${t}_bits;`),o.push(` float ${t} = dbl(${t}_bits, ${r});`);let s=[...t,...n].map(e=>`${e} != ${e}`).join(` || `),c=r?`\n if (${s}) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }`:``;return a.replace(`void main() {`,`${i}void main() {\n${o.join(`
359
+ `)}${c}`)}var eU=`#version 300 es
360
+ in uvec2 a_x_bits;
361
+ in uvec2 a_y_bits;
362
+ out float v_x;
363
+ out float v_y;
364
+ ${QH}
365
+ void main() {
366
+ v_x = dbl(a_x_bits, u_ox);
367
+ v_y = dbl(a_y_bits, u_oy);
368
+ gl_Position = vec4(0.0);
369
+ }`,tU=`#version 300 es
370
+ precision mediump float;
371
+ out vec4 o;
372
+ void main() { o = vec4(0.0); }`;function nU(e,t,n,r){let i=mB(e,e.VERTEX_SHADER,t),a=mB(e,e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),r&&e.transformFeedbackVaryings(o,r,e.SEPARATE_ATTRIBS),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?{prog:o,shaders:[i,a]}:(console.error(`glPoints program link failed:`,e.getProgramInfoLog(o)),null)}function rU(e){let t=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!t)return null;let n=MB(t,`glPoints|points`,()=>nU(t,KH,qH)),r=MB(t,`glPoints|lines`,()=>nU(t,XH,ZH)),i=MB(t,`glPoints|points64`,()=>nU(t,$H(KH,[`a_x`],[`a_y`],!0),qH)),a=MB(t,`glPoints|sprites`,()=>nU(t,JH,YH)),o=MB(t,`glPoints|sprites64`,()=>nU(t,$H(JH,[`a_x`],[`a_y`],!0),YH)),s=t.getParameter(t.ALIASED_POINT_SIZE_RANGE)[1],c=MB(t,`glPoints|decode`,()=>nU(t,eU,tU,[`v_x`,`v_y`])),l=t.createVertexArray();if(!n||!r)return null;let u=(e,n)=>Object.fromEntries(n.map(n=>[n,t.getAttribLocation(e,n)])),d=(e,n)=>Object.fromEntries(n.map(n=>[n,t.getUniformLocation(e,n)])),f=u(n.prog,[`a_corner`,`a_x`,`a_y`,`a_k`,`a_r`]),p=d(n.prog,[`u_resolution`,`u_plot`,`u_view`,`u_radius`,`u_kScale`,`u_palette`,`u_alpha`,`u_clip`,`u_dpr`,`u_height`]),m=u(r.prog,[`a_corner`,`a_ax`,`a_ay`,`a_bx`,`a_by`,`a_bstart`,`a_k`]),h=d(r.prog,[`u_resolution`,`u_plot`,`u_view`,`u_ext`,`u_kScale`,`u_palette`,`u_half`,`u_clip`]),g=i&&u(i.prog,[`a_corner`,`a_x_bits`,`a_y_bits`,`a_k`,`a_r`]),_=i&&d(i.prog,[`u_resolution`,`u_plot`,`u_view`,`u_radius`,`u_kScale`,`u_palette`,`u_alpha`,`u_clip`,`u_dpr`,`u_height`,`u_ox`,`u_oy`]),v=[`u_resolution`,`u_plot`,`u_view`,`u_radius`,`u_kScale`,`u_palette`,`u_alpha`,`u_clip`,`u_dpr`,`u_height`],y=a&&u(a.prog,[`a_x`,`a_y`,`a_k`]),b=a&&d(a.prog,v),x=o&&u(o.prog,[`a_x_bits`,`a_y_bits`,`a_k`]),S=o&&d(o.prog,[...v,`u_ox`,`u_oy`]),C=c&&u(c.prog,[`a_x_bits`,`a_y_bits`]),w=c&&d(c.prog,[`u_ox`,`u_oy`]),T=t.createTransformFeedback(),E=t.createVertexArray(),D=t.createBuffer(),O=t.createBuffer(),k=!1,A=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,A),t.bufferData(t.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),t.STATIC_DRAW);let j=t.createBuffer(),M=t.createBuffer(),N=t.createBuffer(),P=t.createBuffer(),F=t.createBuffer(),I=t.createTexture(),L=0,R=!1,z=!1,B=!1,V=0,ee=0,te=1,H=1,ne=1,re=1.8,ie=.8,U=255,ae=!0,oe=!1,se=1,ce={xmin:0,xmax:1,ymin:0,ymax:1},le={left:0,top:0,width:1,height:1},ue=new Float32Array,de=new Float32Array,fe=new Float32Array,pe=new Uint8Array,me=new Float32Array,he=new Map,ge=(e,n,r)=>{t.bindBuffer(t.ARRAY_BUFFER,e);let i=r*n.BYTES_PER_ELEMENT;i<=(he.get(e)??0)?t.bufferSubData(t.ARRAY_BUFFER,0,n,0,r):(t.bufferData(t.ARRAY_BUFFER,n.subarray(0,r),t.DYNAMIC_DRAW),he.set(e,i))},_e=(e,n,r=0,i=t.FLOAT)=>{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)},ve=(e,n,r=0)=>{t.bindBuffer(t.ARRAY_BUFFER,n),t.enableVertexAttribArray(e),t.vertexAttribIPointer(e,2,t.UNSIGNED_INT,8,r*8),t.vertexAttribDivisor(e,1)},ye=e=>{t.bindBuffer(t.ARRAY_BUFFER,A),t.enableVertexAttribArray(e),t.vertexAttribPointer(e,2,t.FLOAT,!1,0,0),t.vertexAttribDivisor(e,0)};return{resize(t,n,r){te=Math.max(1,t),H=Math.max(1,n),ne=r,e.width=Math.round(te*ne),e.height=Math.round(H*ne)},setData(e,t,n,r=!1,i){let a=Math.min(e.length,t.length);ue.length<a&&(ue=new Float32Array(a),de=new Float32Array(a)),R=!!n,z=!!i,n&&fe.length<a&&(fe=new Float32Array(a)),i&&me.length<a&&(me=new Float32Array(a)),oe&&pe.length<a&&(pe=new Uint8Array(a)),V=0,ee=0;for(let n=0;n<a;n++)if(e[n]-e[n]===0&&t[n]-t[n]===0){V=e[n],ee=t[n];break}let o=ze.has(e)&&ze.has(t);if(B=!!g&&!!c&&e instanceof Float64Array&&t instanceof Float64Array&&(o||!oe),k=!1,B){if(ge(j,e,a),ge(M,t,a),n){for(let e=0;e<a;e++)fe[e]=n[e];ge(N,fe,a)}if(i){for(let e=0;e<a;e++)me[e]=i[e];ge(F,me,a)}if(oe){if(pe.fill(0,0,a),a&&(pe[0]=255),n&&r)for(let e=1;e<a;e++)n[e]!==n[e-1]&&(pe[e]=255);ge(P,pe,a)}L=a;return}let s=0;if(ze.has(e)&&ze.has(t)){for(let t=0;t<a;t++)ue[t]=e[t]-V;for(let e=0;e<a;e++)de[e]=t[e]-ee;if(n)for(let e=0;e<a;e++)fe[e]=n[e];if(i)for(let e=0;e<a;e++)me[e]=i[e];if(oe&&(pe.fill(0,0,a),a&&(pe[0]=255),n&&r))for(let e=1;e<a;e++)n[e]!==n[e-1]&&(pe[e]=255);s=a}else{let o=!0;for(let c=0;c<a;c++){let a=e[c],l=t[c];if(a-a!==0||l-l!==0){o=!0;continue}ue[s]=a-V,de[s]=l-ee,n&&(fe[s]=n[c]),i&&(me[s]=i[c]),oe&&(pe[s]=o||r&&n&&s>0&&n[c]!==fe[s-1]?255:0),o=!1,s++}}L=s,ge(j,ue,s),ge(M,de,s),n&&ge(N,fe,s),i&&ge(F,me,s),oe&&ge(P,pe,s)},setStyle(e,n,r){re=n,ie=r;let i=new Uint8Array(256*4);if(e.kind===`single`){let t=e.rgba.map(e=>Math.round(e*255));for(let e=0;e<256;e++)i.set(t,e*4);U=0}else i.set(e.palette.subarray(0,256*4)),U=e.kind===`colormap`?255:1;t.bindTexture(t.TEXTURE_2D,I),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,i),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)},setDraw(e,t,n){ae=e,oe=t,se=n},setView(e,t,n,r,i){ce={xmin:e,xmax:t,ymin:n,ymax:r},le=i},render(){if(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),L===0)return;t.bindVertexArray(l),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,I);let u=R?U:0,d=[ce.xmin-V,ce.xmax-V,ce.ymin-ee,ce.ymax-ee],v=[le.left,le.top,le.left+le.width,le.top+le.height],A=e=>{let t=Math.fround(e);return[t,e-t]},ue=B,de=j,fe=M;if(B&&oe&&L>1){if(!k){for(let e of[D,O])t.bindBuffer(t.ARRAY_BUFFER,e),(he.get(e)??0)<L*4&&(t.bufferData(t.ARRAY_BUFFER,L*4,t.DYNAMIC_COPY),he.set(e,L*4));t.bindBuffer(t.ARRAY_BUFFER,null),t.bindVertexArray(E),t.useProgram(c.prog),t.uniform2f(w.u_ox,...A(V)),t.uniform2f(w.u_oy,...A(ee)),ve(C.a_x_bits,j),ve(C.a_y_bits,M),t.vertexAttribDivisor(C.a_x_bits,0),t.vertexAttribDivisor(C.a_y_bits,0),t.enable(t.RASTERIZER_DISCARD),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,T),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,D),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,1,O),t.beginTransformFeedback(t.POINTS),t.drawArrays(t.POINTS,0,L),t.endTransformFeedback(),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,0,null),t.bindBufferBase(t.TRANSFORM_FEEDBACK_BUFFER,1,null),t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null),t.disable(t.RASTERIZER_DISCARD),t.bindVertexArray(l),k=!0}ue=!1,de=D,fe=O}if(oe&&L>1){let e=h,n=m;t.useProgram(r.prog),t.uniform2f(e.u_resolution,te,H),t.uniform4f(e.u_plot,le.left,le.top,le.width,le.height),t.uniform4f(e.u_view,...d),t.uniform1f(e.u_half,se/2),t.uniform1f(e.u_ext,se/2+1),t.uniform1f(e.u_kScale,u),t.uniform4f(e.u_clip,...v),t.uniform1i(e.u_palette,0),ye(n.a_corner),_e(n.a_ax,de,0),_e(n.a_bx,de,1),_e(n.a_ay,fe,0),_e(n.a_by,fe,1),_e(n.a_bstart,P,1,t.UNSIGNED_BYTE),R?_e(n.a_k,N,0):(t.disableVertexAttribArray(n.a_k),t.vertexAttrib1f(n.a_k,0)),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,L-1);for(let e of Object.values(n))t.vertexAttribDivisor(e,0)}if(ae&&!z&&2*(re+.5)*ne<=s&&(ue?o:a)){let n=ue?S:b,r=ue?x:y;t.useProgram((ue?o:a).prog),ue&&(t.uniform2f(n.u_ox,...A(V)),t.uniform2f(n.u_oy,...A(ee))),t.uniform2f(n.u_resolution,te,H),t.uniform4f(n.u_plot,le.left,le.top,le.width,le.height),t.uniform4f(n.u_view,...d),t.uniform1f(n.u_radius,re),t.uniform1f(n.u_kScale,u),t.uniform1f(n.u_alpha,ie),t.uniform4f(n.u_clip,...v),t.uniform1f(n.u_dpr,ne),t.uniform1f(n.u_height,e.height),t.uniform1i(n.u_palette,0),ue?(ve(r.a_x_bits,j),ve(r.a_y_bits,M)):(_e(r.a_x,de),_e(r.a_y,fe)),R?_e(r.a_k,N):(t.disableVertexAttribArray(r.a_k),t.vertexAttrib1f(r.a_k,0));for(let e of Object.values(r))t.vertexAttribDivisor(e,0);t.drawArrays(t.POINTS,0,L)}else if(ae){let r=ue?_:p,a=ue?g:f;t.useProgram(ue?i.prog:n.prog),ue&&(t.uniform2f(r.u_ox,...A(V)),t.uniform2f(r.u_oy,...A(ee))),t.uniform2f(r.u_resolution,te,H),t.uniform4f(r.u_plot,le.left,le.top,le.width,le.height),t.uniform4f(r.u_view,...d),t.uniform1f(r.u_radius,re),t.uniform1f(r.u_kScale,u),t.uniform1f(r.u_alpha,ie),t.uniform4f(r.u_clip,...v),t.uniform1f(r.u_dpr,ne),t.uniform1f(r.u_height,e.height),t.uniform1i(r.u_palette,0),ye(a.a_corner),ue?(ve(a.a_x_bits,j),ve(a.a_y_bits,M)):(_e(a.a_x,de),_e(a.a_y,fe)),R?_e(a.a_k,N):(t.disableVertexAttribArray(a.a_k),t.vertexAttrib1f(a.a_k,0)),z?_e(a.a_r,F):(t.disableVertexAttribArray(a.a_r),t.vertexAttrib1f(a.a_r,0)),t.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,L);for(let e of Object.values(a))t.vertexAttribDivisor(e,0)}t.bindVertexArray(null)},dispose(){for(let e of[A,j,M,N,P,F,D,O])t.deleteBuffer(e);t.deleteTransformFeedback(T),t.deleteVertexArray(E),t.deleteTexture(I),t.deleteVertexArray(l)}}}var iU={top:3,right:3,bottom:3,left:3};function aU(e,t,n){return t<200||n<120?{...iU,tiny:!0}:{...e,tiny:!1}}var oU={top:14,right:24,bottom:40,left:78},sU=70,cU=6,lU=8,uU=1.8;function dU(e,t,n){return Math.min(n,Math.max(t,e))}function fU(e,t){let n=e[t],r=1/0,i=-1/0;for(let t=0;t<e.length;t++){let e=n[t];e<r&&(r=e),e>i&&(i=e)}(!Number.isFinite(r)||r===i)&&(--r,i+=1);let a=(i-r)*.04;return{min:r-a,max:i+a}}function pU(e){return e===`dashed`?[5,4]:e===`dotted`?[1,4]:[]}function mU({points:e,xLabel:t,yLabel:n,color:r=`#38bdf8`,datasetColors:i,colorLabel:a,colorRange:o,height:s=400,pointRadius:c=uU,drawMode:l=`points`,lineWidth:u=1,backgroundToken:d=``,onPlotContextMenu:f,xAxisLine:p,yAxisLine:m,gridLine:h,fitSettings:g,xScale:_,yScale:v}){let y=_V(),b=K(null),x=K(null),S=K(null),C=K(f);G(()=>{C.current=f},[f]);let w=K(null),T=K(null),E=K(null),D=K(null),O=K(null),k=K(0),A=K(null),j=Xe(()=>TH(e)?e:EH(e),[e]),M=K({cols:j,xLabel:t,yLabel:n,color:r,datasetColors:i,colorLabel:a,colorRange:o,height:s,pointRadius:c,drawMode:l,lineWidth:u,xAxisLine:p,yAxisLine:m,gridLine:h,fitSettings:g,xScale:_,yScale:v});G(()=>{M.current={cols:j,xLabel:t,yLabel:n,color:r,datasetColors:i,colorLabel:a,colorRange:o,height:s,pointRadius:c,drawMode:l,lineWidth:u,xAxisLine:p,yAxisLine:m,gridLine:h,fitSettings:g,xScale:_,yScale:v}},[j,t,n,r,i,a,o,s,c,l,u,p,m,h,g,_,v]);let N=K({cols:null,value:{x:{min:0,max:1},y:{min:0,max:1}}});function P(){let e=M.current.cols,t=N.current;return t.cols!==e&&(t.value={x:fU(e,`x`),y:fU(e,`y`)},t.cols=e),t.value}W(()=>{T.current=null,E.current=null,D.current=null,O.current=null},[e]);function F(){let e=P(),t=T.current,n=E.current,r=D.current,i=O.current;return{xmin:t!==null&&n!==null&&n>t?t:e.x.min,xmax:t!==null&&n!==null&&n>t?n:e.x.max,ymin:r!==null&&i!==null&&i>r?r:e.y.min,ymax:r!==null&&i!==null&&i>r?i:e.y.max}}function I(){if(T.current!==null||D.current!==null)return F();let{xScale:e,yScale:t}=M.current,n=e=>{if(!e)return null;let t=parseFloat(e.scaleMin),n=parseFloat(e.scaleMax);return Number.isFinite(t)&&Number.isFinite(n)&&t<n?{min:t,max:n}:null},r=n(e)??P().x,i=n(t)??P().y;return{xmin:r.min,xmax:r.max,ymin:i.min,ymax:i.max}}function L(){if(A.current)return A.current;let e=S.current;if(!e)return{bg:`#0f1014`,muted:`#71717a`,grid:`#27272a`,accent:`#f97316`};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`,accent:t.getPropertyValue(`--accent`).trim()||`#f97316`};return A.current=n,n}function R(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 z(){let e=S.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||M.current.height)}}let B=K(null),V=K(null),ee=K({r:null,failed:!1,data:null,mode:``,style:``,size:``});function te(e,t){let n=ee.current;!n.r&&!n.failed&&V.current&&(n.r=NB(V.current,rU),n.failed=!n.r);let r=n.r;if(!r||!V.current)return null;let{cols:i,color:a,datasetColors:o,pointRadius:s,drawMode:c,lineWidth:l}=M.current,u=Math.min(2,window.devicePixelRatio||1),d=`${e}x${t}@${u}`;n.size!==d&&(r.resize(e,t,u),V.current.style.width=`${e}px`,V.current.style.height=`${t}px`,n.size=d);let f=o&&o.length>0&&i.d?`dataset`:i.c?`colormap`:`single`,p=c!==`points`;r.setDraw(c!==`lines`,p,l),(n.data!==i||n.mode!==`${f}|${p}`)&&(r.setData(i.x,i.y,f===`dataset`?i.d:f===`colormap`?i.c:void 0,f===`dataset`),n.data=i,n.mode=`${f}|${p}`);let m=`${f}|${a}|${f===`dataset`?o.join(`,`):``}|${s}`;return n.style!==m&&(r.setStyle(gU(f,a,o),Math.max(.25,s),.8),n.style=m),r}W(()=>()=>{ee.current.r?.dispose(),ee.current.r=null},[]);let H=K({cols:null,key:``,coeffs:null});function ne(e,t,n){let r=`${t}|${n.xmin}|${n.xmax}|${n.ymin}|${n.ymax}`,i=H.current;return(i.cols!==e||i.key!==r)&&(H.current={cols:e,key:r,coeffs:RH(e,t,n)}),H.current.coeffs}let re=K({pts:null,view:``}),ie=K(``);function U(){let e=b.current;if(!e)return;let{w:t,h:n}=z(),r=R(e,t,n);if(!r)return;let{cols:i,xLabel:a,yLabel:o,color:s,datasetColors:c,colorLabel:l,colorRange:u,pointRadius:d,xAxisLine:f,yAxisLine:p,gridLine:m,fitSettings:h,xScale:g,yScale:_}=M.current,v=!!c&&c.length>0&&!!i.d,x=!v&&i.length>0&&!!i.c,C=aU(oU,t,n),w=C.tiny?C.right:x?sU:C.right,{top:T,bottom:E,left:D}=C,O=t-D-w,k=n-T-E,{bg:A,muted:j,grid:N,accent:P}=L(),F=Math.max(.25,d),V=te(t,n),ee=i.length>=1&&O>0&&k>0?I():null,H=[t,n,e.width,ee&&`${ee.xmin}|${ee.xmax}|${ee.ymin}|${ee.ymax}`,a,o,x,v,l,u?.join(),JSON.stringify([f,p,m,g,_]),A,j,N,P].join(`§`);if(V&&ee&&!h&&ie.current===H){let e=re.current;e.pts!==i&&(re.current={pts:i,view:e.view},rV(S.current)),V.setView(ee.xmin,ee.xmax,ee.ymin,ee.ymax,{left:D,top:T,width:O,height:k}),V.render();return}ie.current=H,r.fillStyle=A,r.fillRect(0,0,t,n);let U=B.current?R(B.current,t,n):null;U?.clearRect(0,0,t,n);let ae=V;if(i.length<1||O<=0||k<=0){ae?.render(),r.fillStyle=j,r.font=`13px ${Q.sans}`,r.fillText(`No data`,D,T+24);return}let{xmin:oe,xmax:se,ymin:ce,ymax:le}=I(),ue=se-oe,de=le-ce,fe=e=>D+(e-oe)/ue*O;y({left:D,top:T,width:O,height:k,x:{v0:oe,v1:se}});let pe=e=>T+(le-e)/de*k,me=(()=>{if(_?.majorStep){let e=parseFloat(_.majorStep);if(Number.isFinite(e)&&e>0)return e}return KR(de,6)})(),he=YR(ce,le,me);if((p?.style??`dashed`)!==`none`){r.strokeStyle=p?.color??N,r.lineWidth=p?.width??1,r.setLineDash(pU(p?.style??`dashed`));for(let e of he){let t=pe(e);r.beginPath(),r.moveTo(D,t),r.lineTo(D+O,t),r.stroke()}r.setLineDash([])}r.strokeStyle=j,r.lineWidth=1,r.fillStyle=j,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of C.tiny?[]:he){let t=pe(e);r.beginPath(),r.moveTo(D-cU,t),r.lineTo(D,t),r.stroke(),r.fillText($R(e,me),D-lU,t)}let ge=(()=>{if(g?.majorStep){let e=parseFloat(g.majorStep);if(Number.isFinite(e)&&e>0)return e}return KR(ue,qR(O))})(),_e=YR(oe,se,ge);if((f?.style??`dashed`)!==`none`){r.strokeStyle=f?.color??N,r.lineWidth=f?.width??1,r.setLineDash(pU(f?.style??`dashed`));for(let e of _e){let t=fe(e);r.beginPath(),r.moveTo(t,T),r.lineTo(t,T+k),r.stroke()}r.setLineDash([])}r.strokeStyle=j,r.lineWidth=1,r.fillStyle=j,r.textAlign=`center`,r.textBaseline=`top`;for(let e of C.tiny?[]:_e){let t=fe(e);r.beginPath(),r.moveTo(t,T+k),r.lineTo(t,T+k+cU),r.stroke(),r.fillText($R(e,ge),t,T+k+cU+2)}(m?.style??`solid`)!==`none`&&(r.strokeStyle=m?.color??N,r.lineWidth=m?.width??1,r.setLineDash(pU(m?.style??`solid`)),r.strokeRect(D,T,O,k),r.setLineDash([])),r.fillStyle=j,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,C.tiny||(r.fillText(a,D+O/2,n-4),r.save(),r.translate(14,T+k/2),r.rotate(-Math.PI/2),r.fillText(o,0,0),r.restore());let ve=re.current;if((ve.pts!==i||ve.view!==`${oe}|${se}|${ce}|${le}`)&&(re.current={pts:i,view:`${oe}|${se}|${ce}|${le}`},rV(S.current)),ae)ae.setView(oe,se,ce,le,{left:D,top:T,width:O,height:k}),ae.render();else{let e={xToPx:fe,yToPx:pe,left:D,top:T,plotW:O,plotH:k,dotR:F,col:s,dsColors:v?c:null,hasColormap:x};M.current.drawMode!==`points`&&vU(r,i,e,M.current.lineWidth),M.current.drawMode!==`lines`&&_U(r,i,e)}if(x&&!C.tiny){let e=D+O+10,n=k;for(let t=0;t<64;t++)r.fillStyle=WH(1-t/64),r.fillRect(e,T+t/64*n,10,n/64+1);r.strokeStyle=j,r.lineWidth=.5,r.strokeRect(e,T,10,n),r.fillStyle=j,r.font=`10px ${Q.mono}`,r.textAlign=`left`,r.textBaseline=`top`;let i=u?String(u[1].toPrecision(3)):`1`,a=u?String(u[0].toPrecision(3)):`0`;r.fillText(i,e+10+3,T),r.textBaseline=`bottom`,r.fillText(a,e+10+3,T+n),l&&(r.save(),r.textBaseline=`middle`,r.translate(t-6,T+n/2),r.rotate(Math.PI/2),r.fillText(l,0,0),r.restore())}if(h&&U){let e=ne(i,h.degree,{xmin:oe,xmax:se,ymin:ce,ymax:le});if(e){U.save(),U.beginPath(),U.rect(D,T,O,k),U.clip(),U.strokeStyle=h.color,U.lineWidth=h.width,U.setLineDash(pU(h.lineStyle)),U.beginPath();for(let t=0;t<=300;t++){let n=oe+t/300*ue,r=e.reduce((e,t,r)=>e+t*n**+r,0),i=fe(n),a=pe(r);t===0?U.moveTo(i,a):U.lineTo(i,a)}U.stroke(),U.setLineDash([]);let t=VH(e,`x`,`y`);U.fillStyle=P,U.font=`10px ${Q.mono}`,U.textAlign=`right`,U.textBaseline=`top`,U.fillText(t,D+O-8,T+8),U.restore()}}if((g?.alarm||_?.alarm)&&U){if(U.save(),U.beginPath(),U.rect(D,T,O,k),U.clip(),g?.alarm){let e=g.alarm;U.strokeStyle=e.color,U.lineWidth=e.width,U.setLineDash(pU(e.style));let t=fe(e.value);U.beginPath(),U.moveTo(t,T),U.lineTo(t,T+k),U.stroke(),U.setLineDash([])}if(_?.alarm){let e=_.alarm;U.strokeStyle=e.color,U.lineWidth=e.width,U.setLineDash(pU(e.style));let t=pe(e.value);U.beginPath(),U.moveTo(D,t),U.lineTo(D+O,t),U.stroke(),U.setLineDash([])}U.restore()}}let ae=K(``);function oe(){let e=x.current;if(!e)return;let{w:t,h:n}=z(),r=`${t}x${n}`;if(w.current===null&&ae.current===r)return;let i=R(e,t,n);if(!i)return;i.clearRect(0,0,t,n),ae.current=w.current===null?r:``;let a=w.current,{cols:o,color:s,datasetColors:c,pointRadius:l}=M.current;if(a===null||a>=o.length||o.length<1)return;let u=Math.max(4,l*2),d=o.d?.[a],f=c&&c.length>0&&d!==void 0?c[d]??s:s,{top:p,right:m,bottom:h,left:g}=aU(oU,t,n),_=t-g-m,v=n-p-h;if(_<=0||v<=0)return;let{xmin:y,xmax:b,ymin:S,ymax:C}=I(),T=b-y,E=C-S,D={x:o.x[a],y:o.y[a]},O=g+(D.x-y)/T*_,k=p+(C-D.y)/E*v,{bg:A,muted:j}=L();i.strokeStyle=j,i.globalAlpha=.4,i.lineWidth=1,i.setLineDash([3,3]),i.beginPath(),i.moveTo(O,p),i.lineTo(O,p+v),i.stroke(),i.beginPath(),i.moveTo(g,k),i.lineTo(g+_,k),i.stroke(),i.setLineDash([]),i.globalAlpha=1,i.fillStyle=f,i.beginPath(),i.arc(O,k,u,0,Math.PI*2),i.fill(),i.strokeStyle=A,i.lineWidth=1.5,i.beginPath(),i.arc(O,k,u,0,Math.PI*2),i.stroke();let N=`(${ez(D.x)}, ${ez(D.y)})`;i.font=`11px ${Q.mono}`;let P=i.measureText(N).width+12,F=O+10,B=k-24;F+P>g+_&&(F=O-P-10),B<p&&(B=k+10),i.fillStyle=A,i.globalAlpha=.85,i.beginPath(),hU(i,F,B,P,20,4),i.fill(),i.globalAlpha=1,i.strokeStyle=j,i.lineWidth=.5,i.beginPath(),hU(i,F,B,P,20,4),i.stroke(),i.fillStyle=j,i.textAlign=`left`,i.textBaseline=`middle`,i.fillText(N,F+6,B+20/2)}let se=K(U),ce=K(oe);G(()=>{se.current=U,ce.current=oe});let le=K(null);le.current??=sV(()=>{se.current(),ce.current()},()=>S.current?.ownerDocument);function ue(){le.current.schedule()}function de(){k.current||=eV(()=>{k.current=0,ce.current()})}W(()=>()=>{le.current?.cancel(),tV(k.current),k.current=0},[]);let fe=K(ue),pe=K(de);return G(()=>{fe.current=ue,pe.current=de}),W(()=>cz(S.current,()=>{A.current=null,fe.current()}),[]),W(()=>{A.current=null,fe.current()},[d]),W(()=>{le.current.now()},[e,t,n,r,i,s,c,l,u,p,m,h,g,_,v]),W(()=>{let e=x.current,t=S.current;if(!e||!t)return;let n=new oV(()=>{A.current=null,fe.current()});n.observe(t);let r=null;function i(e,t){let n=M.current.cols;if(n.length===0)return null;let{w:i,h:a}=z(),{top:o,right:s,bottom:c,left:l}=aU(oU,i,a),u=i-l-s,d=a-o-c,{xmin:f,xmax:p,ymin:m,ymax:h}=I(),g=p-f,_=h-m,v=Math.max(12,M.current.pointRadius*10),y=`${i}|${a}|${f}|${p}|${m}|${h}|${v}`;if(!r||r.cols!==n||r.key!==y){let e=Math.max(1,Math.ceil(u/v)),t=Math.max(1,Math.ceil(d/v)),i=t=>{let r=(n.x[t]-f)/g*u,i=(h-n.y[t])/_*d;return r>=0&&r<u&&i>=0&&i<d?Math.floor(i/v)*e+Math.floor(r/v):-1},a=new Uint32Array(e*t+1);for(let e=0;e<n.length;e++){let t=i(e);t>=0&&a[t+1]++}for(let n=0;n<e*t;n++)a[n+1]+=a[n];let o=a.slice(0,e*t),s=new Uint32Array(a[e*t]);for(let e=0;e<n.length;e++){let t=i(e);t>=0&&(s[o[t]++]=e)}r={cols:n,key:y,cell:v,nx:e,start:a,ix:s}}let b=r,x=Math.floor((e-l)/b.cell),S=Math.floor((t-o)/b.cell),C=(b.start.length-1)/b.nx,w=-1,T=v*v;for(let r=S-1;r<=S+1;r++)if(!(r<0||r>=C))for(let i=x-1;i<=x+1;i++){if(i<0||i>=b.nx)continue;let a=r*b.nx+i;for(let r=b.start[a];r<b.start[a+1];r++){let i=b.ix[r],a=l+(n.x[i]-f)/g*u,s=o+(h-n.y[i])/_*d,c=(a-e)**2+(s-t)**2;c<T&&(T=c,w=i)}}return w<0?null:w}let a=t=>{if(M.current.cols.length<1){w.current!==null&&(w.current=null,pe.current());return}let n=e.getBoundingClientRect(),r=t.clientX-n.left,a=t.clientY-n.top,{left:o,top:s,right:c,bottom:l}=aU(oU,n.width,n.height),u=Math.max(1,n.width-o-c),d=n.height-s-l;if(r<o||r>o+u||a<s||a>s+d){w.current!==null&&(w.current=null,pe.current());return}let f=i(r,a);w.current!==f&&(w.current=f,pe.current())},o=()=>{w.current!==null&&(w.current=null,pe.current())},s=t=>{if(M.current.cols.length<1)return;let n=e.getBoundingClientRect(),r=t.clientX-n.left,i=t.clientY-n.top,{top:a,left:o,right:s,bottom:c}=aU(oU,n.width,n.height),l=Math.max(1,n.width-o-s),u=Math.max(1,n.height-a-c);if(r<o||r>o+l||i<a||i>a+u)return;t.preventDefault();let d=P(),f=d.x.max-d.x.min,p=d.y.max-d.y.min,m=I(),h=m.xmin,g=m.xmax,_=m.ymin,v=m.ymax,y=g-h,b=v-_,x=(r-o)/l,S=(i-a)/u,C=h+x*y,w=v-S*b,k=t.deltaY<0,A=.88,j=k?A:1/A,N=y*j,F=b*j;if(!k&&N>=f*.999&&F>=p*.999){T.current=null,E.current=null,D.current=null,O.current=null,fe.current();return}N=dU(N,Math.max(f*1e-7,1e-12),f),F=dU(F,Math.max(p*1e-7,1e-12),p);let L=C-x*N,R=C+(1-x)*N;L<d.x.min&&(R+=d.x.min-L,L=d.x.min),R>d.x.max&&(L-=R-d.x.max,R=d.x.max);let z=w-(1-S)*F,B=w+S*F;z<d.y.min&&(B+=d.y.min-z,z=d.y.min),B>d.y.max&&(z-=B-d.y.max,B=d.y.max),T.current=L,E.current=R,D.current=z,O.current=B,fe.current()},c=e=>{e.button===0&&(T.current===null&&D.current===null||(T.current=null,E.current=null,D.current=null,O.current=null,fe.current(),pe.current()))},l=e=>{e.preventDefault(),C.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`mousemove`,a),e.addEventListener(`mouseleave`,o),e.addEventListener(`wheel`,s,{passive:!1}),e.addEventListener(`contextmenu`,l),e.addEventListener(`dblclick`,c),()=>{n.disconnect(),e.removeEventListener(`mousemove`,a),e.removeEventListener(`mouseleave`,o),e.removeEventListener(`wheel`,s),e.removeEventListener(`contextmenu`,l),e.removeEventListener(`dblclick`,c)}},[]),nt(`div`,{ref:S,className:`chart-canvas-wrap`,children:[q(`canvas`,{ref:b,className:`chart-canvas`,role:`img`,"aria-label":`Scatter ${t} vs ${n}`}),q(`canvas`,{ref:V,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:B,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}}),q(`canvas`,{ref:x,className:`chart-canvas chart-overlay`})]})}function hU(e,t,n,r,i,a){e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.arcTo(t+r,n,t+r,n+a,a),e.lineTo(t+r,n+i-a),e.arcTo(t+r,n+i,t+r-a,n+i,a),e.lineTo(t+a,n+i),e.arcTo(t,n+i,t,n+i-a,a),e.lineTo(t,n+a),e.arcTo(t,n,t+a,n,a)}function gU(e,t,n){if(e===`single`)return{kind:`single`,rgba:lB(t)};let r=new Uint8Array(256*4);for(let t=0;t<256;t++)if(e===`colormap`){let{r:e,g:n,b:i}=UH(t/255);r.set([e,n,i,255],t*4)}else{let e=lB(n[Math.min(t,n.length-1)]);r.set([e[0]*255,e[1]*255,e[2]*255,e[3]*255],t*4)}return{kind:e===`colormap`?`colormap`:`dataset`,palette:r}}function _U(e,t,n){let r=Math.PI*2,i=n.dsColors?n.dsColors.length:n.hasColormap?24:1,a=Array.from({length:i},()=>new Path2D);for(let e=0;e<t.length;e++){let o=n.xToPx(t.x[e]),s=n.yToPx(t.y[e]);if(!(o>=n.left&&o<=n.left+n.plotW&&s>=n.top&&s<=n.top+n.plotH))continue;let c=n.dsColors?Math.min(t.d?.[e]??0,i-1):n.hasColormap?GH(t.c?.[e]??0,24):0;a[c].moveTo(o+n.dotR,s),a[c].arc(o,s,n.dotR,0,r)}e.globalAlpha=.8;for(let t=0;t<i;t++)e.fillStyle=n.dsColors?n.dsColors[t]:n.hasColormap?WH((t+.5)/24):n.col,e.fill(a[t]);e.globalAlpha=1}function vU(e,t,n,r){e.save(),e.beginPath(),e.rect(n.left,n.top,n.plotW,n.plotH),e.clip(),e.lineWidth=r;let i=n.dsColors?n.dsColors.length:1;for(let r=0;r<i;r++){e.beginPath();let i=!1;for(let a=0;a<t.length;a++){if(n.dsColors&&(t.d?.[a]??0)!==r){i=!1;continue}let o=t.x[a],s=t.y[a];if(o-o!==0||s-s!==0){i=!1;continue}i?e.lineTo(n.xToPx(o),n.yToPx(s)):(e.moveTo(n.xToPx(o),n.yToPx(s)),i=!0)}e.strokeStyle=n.dsColors?n.dsColors[r]:n.col,e.stroke()}e.restore()}var yU=11102230246251565e-32,bU=134217729,xU=(3+8*yU)*yU;function SU(e,t,n,r,i){let a,o,s,c,l=t[0],u=r[0],d=0,f=0;u>l==u>-l?(a=l,l=t[++d]):(a=u,u=r[++f]);let p=0;if(d<e&&f<n)for(u>l==u>-l?(o=l+a,s=a-(o-l),l=t[++d]):(o=u+a,s=a-(o-u),u=r[++f]),a=o,s!==0&&(i[p++]=s);d<e&&f<n;)u>l==u>-l?(o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d]):(o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f]),a=o,s!==0&&(i[p++]=s);for(;d<e;)o=a+l,c=o-a,s=a-(o-c)+(l-c),l=t[++d],a=o,s!==0&&(i[p++]=s);for(;f<n;)o=a+u,c=o-a,s=a-(o-c)+(u-c),u=r[++f],a=o,s!==0&&(i[p++]=s);return(a!==0||p===0)&&(i[p++]=a),p}function CU(e,t){let n=t[0];for(let r=1;r<e;r++)n+=t[r];return n}function $(e){return new Float64Array(e)}var wU=(3+16*yU)*yU,TU=(2+12*yU)*yU,EU=(9+64*yU)*yU*yU,DU=$(4),OU=$(8),kU=$(12),AU=$(16),jU=$(4);function MU(e,t,n,r,i,a,o){let s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=e-i,E=n-i,D=t-a,O=r-a;b=T*O,f=bU*T,p=f-(f-T),m=T-p,f=bU*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=D*E,f=bU*D,p=f-(f-D),m=D-p,f=bU*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,DU[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,DU[1]=y-(_+d)+(d-S),w=v+_,d=w-v,DU[2]=v-(w-d)+(_-d),DU[3]=w;let k=CU(4,DU),A=TU*o;if(k>=A||-k>=A||(d=e-T,s=e-(T+d)+(d-i),d=n-E,l=n-(E+d)+(d-i),d=t-D,c=t-(D+d)+(d-a),d=r-O,u=r-(O+d)+(d-a),s===0&&c===0&&l===0&&u===0)||(A=EU*o+xU*Math.abs(k),k+=T*u+O*s-(D*l+E*c),k>=A||-k>=A))return k;b=s*O,f=bU*s,p=f-(f-s),m=s-p,f=bU*O,h=f-(f-O),g=O-h,x=m*g-(b-p*h-m*h-p*g),S=c*E,f=bU*c,p=f-(f-c),m=c-p,f=bU*E,h=f-(f-E),g=E-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,jU[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,jU[1]=y-(_+d)+(d-S),w=v+_,d=w-v,jU[2]=v-(w-d)+(_-d),jU[3]=w;let j=SU(4,DU,4,jU,OU);b=T*u,f=bU*T,p=f-(f-T),m=T-p,f=bU*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=D*l,f=bU*D,p=f-(f-D),m=D-p,f=bU*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,jU[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,jU[1]=y-(_+d)+(d-S),w=v+_,d=w-v,jU[2]=v-(w-d)+(_-d),jU[3]=w;let M=SU(j,OU,4,jU,kU);return b=s*u,f=bU*s,p=f-(f-s),m=s-p,f=bU*u,h=f-(f-u),g=u-h,x=m*g-(b-p*h-m*h-p*g),S=c*l,f=bU*c,p=f-(f-c),m=c-p,f=bU*l,h=f-(f-l),g=l-h,C=m*g-(S-p*h-m*h-p*g),_=x-C,d=x-_,jU[0]=x-(_+d)+(d-C),v=b+_,d=v-b,y=b-(v-d)+(_-d),_=y-S,d=y-_,jU[1]=y-(_+d)+(d-S),w=v+_,d=w-v,jU[2]=v-(w-d)+(_-d),jU[3]=w,AU[SU(M,kU,4,jU,AU)-1]}function NU(e,t,n,r,i,a){let o=(t-a)*(n-i),s=(e-i)*(r-a),c=o-s,l=Math.abs(o+s);return Math.abs(c)>=wU*l?c:-MU(e,t,n,r,i,a,l)}(7+56*yU)*yU,(3+28*yU)*yU,(26+288*yU)*yU*yU,$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(8),$(8),$(8),$(4),$(8),$(8),$(16),$(12),$(192),$(192),(10+96*yU)*yU,(4+48*yU)*yU,(44+576*yU)*yU*yU,$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(8),$(8),$(8),$(8),$(8),$(8),$(8),$(8),$(8),$(4),$(4),$(4),$(8),$(16),$(16),$(16),$(32),$(32),$(48),$(64),$(1152),$(1152),(16+224*yU)*yU,(5+72*yU)*yU,(71+1408*yU)*yU*yU,$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(4),$(24),$(24),$(24),$(24),$(24),$(24),$(24),$(24),$(24),$(24),$(1152),$(1152),$(1152),$(1152),$(1152),$(2304),$(2304),$(3456),$(5760),$(8),$(8),$(8),$(16),$(24),$(48),$(48),$(96),$(192),$(384),$(384),$(384),$(768),$(96),$(96),$(96),$(1152);var PU=2**-52,FU=new Uint32Array(512),IU=class e{static from(t,n=WU,r=GU){let i=t.length,a=new Float64Array(i*2);for(let e=0;e<i;e++){let i=t[e];a[2*e]=n(i),a[2*e+1]=r(i)}return new e(a)}constructor(e){let t=e.length>>1;if(t>0&&typeof e[0]!=`number`)throw Error(`Expected coords to contain numbers.`);this.coords=e;let n=Math.max(2*t-5,0);this._triangles=new Uint32Array(n*3),this._halfedges=new Int32Array(n*3),this._hashSize=Math.ceil(Math.sqrt(t)),this._hullPrev=new Uint32Array(t),this._hullNext=new Uint32Array(t),this._hullTri=new Uint32Array(t),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(t),this._dists=new Float64Array(t),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){let{coords:e,_hullPrev:t,_hullNext:n,_hullTri:r,_hullHash:i}=this,a=e.length>>1,o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t=0;t<a;t++){let n=e[2*t],r=e[2*t+1];n<o&&(o=n),r<s&&(s=r),n>c&&(c=n),r>l&&(l=r),this._ids[t]=t}let u=(o+c)/2,d=(s+l)/2,f=0,p=0,m=0;for(let t=0,n=1/0;t<a;t++){let r=RU(u,d,e[2*t],e[2*t+1]);r<n&&(f=t,n=r)}let h=e[2*f],g=e[2*f+1];for(let t=0,n=1/0;t<a;t++){if(t===f)continue;let r=RU(h,g,e[2*t],e[2*t+1]);r<n&&r>0&&(p=t,n=r)}let _=e[2*p],v=e[2*p+1],y=1/0;for(let t=0;t<a;t++){if(t===f||t===p)continue;let n=BU(h,g,_,v,e[2*t],e[2*t+1]);n<y&&(m=t,y=n)}let b=e[2*m],x=e[2*m+1];if(y===1/0){for(let t=0;t<a;t++)this._dists[t]=e[2*t]-e[0]||e[2*t+1]-e[1];HU(this._ids,this._dists,0,a-1);let t=new Uint32Array(a),n=0;for(let e=0,r=-1/0;e<a;e++){let i=this._ids[e],a=this._dists[i];a>r&&(t[n++]=i,r=a)}this.hull=t.subarray(0,n),this.triangles=new Uint32Array,this.halfedges=new Int32Array;return}if(NU(h,g,_,v,b,x)<0){let e=p,t=_,n=v;p=m,_=b,v=x,m=e,b=t,x=n}let S=VU(h,g,_,v,b,x);this._cx=S.x,this._cy=S.y;for(let t=0;t<a;t++)this._dists[t]=RU(e[2*t],e[2*t+1],S.x,S.y);HU(this._ids,this._dists,0,a-1),this._hullStart=f;let C=3;n[f]=t[m]=p,n[p]=t[f]=m,n[m]=t[p]=f,r[f]=0,r[p]=1,r[m]=2,i.fill(-1),i[this._hashKey(h,g)]=f,i[this._hashKey(_,v)]=p,i[this._hashKey(b,x)]=m,this.trianglesLen=0,this._addTriangle(f,p,m,-1,-1,-1);for(let a=0,o=0,s=0;a<this._ids.length;a++){let c=this._ids[a],l=e[2*c],u=e[2*c+1];if(a>0&&Math.abs(l-o)<=PU&&Math.abs(u-s)<=PU||(o=l,s=u,c===f||c===p||c===m))continue;let d=0;for(let e=0,t=this._hashKey(l,u);e<this._hashSize&&(d=i[(t+e)%this._hashSize],!(d!==-1&&d!==n[d]));e++);d=t[d];let h=d,g;for(;g=n[h],NU(l,u,e[2*h],e[2*h+1],e[2*g],e[2*g+1])>=0;)if(h=g,h===d){h=-1;break}if(h===-1)continue;let _=this._addTriangle(h,c,n[h],-1,-1,r[h]);r[c]=this._legalize(_+2),r[h]=_,C++;let v=n[h];for(;g=n[v],NU(l,u,e[2*v],e[2*v+1],e[2*g],e[2*g+1])<0;)_=this._addTriangle(v,c,g,r[c],-1,r[v]),r[c]=this._legalize(_+2),n[v]=v,C--,v=g;if(h===d)for(;g=t[h],NU(l,u,e[2*g],e[2*g+1],e[2*h],e[2*h+1])<0;)_=this._addTriangle(g,c,h,-1,r[h],r[g]),this._legalize(_+2),r[g]=_,n[h]=h,C--,h=g;this._hullStart=t[c]=h,n[h]=t[v]=c,n[c]=v,i[this._hashKey(l,u)]=c,i[this._hashKey(e[2*h],e[2*h+1])]=h}this.hull=new Uint32Array(C);for(let e=0,t=this._hullStart;e<C;e++)this.hull[e]=t,t=n[t];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(e,t){return Math.floor(LU(e-this._cx,t-this._cy)*this._hashSize)%this._hashSize}_legalize(e){let{_triangles:t,_halfedges:n,coords:r}=this,i=0,a=0;for(;;){let o=n[e],s=e-e%3;if(a=s+(e+2)%3,o===-1){if(i===0)break;e=FU[--i];continue}let c=o-o%3,l=s+(e+1)%3,u=c+(o+2)%3,d=t[a],f=t[e],p=t[l],m=t[u];if(zU(r[2*d],r[2*d+1],r[2*f],r[2*f+1],r[2*p],r[2*p+1],r[2*m],r[2*m+1])){t[e]=m,t[o]=d;let r=n[u];if(r===-1){let t=this._hullStart;do{if(this._hullTri[t]===u){this._hullTri[t]=e;break}t=this._hullPrev[t]}while(t!==this._hullStart)}this._link(e,r),this._link(o,n[a]),this._link(a,u);let s=c+(o+1)%3;i<FU.length&&(FU[i++]=s)}else{if(i===0)break;e=FU[--i]}}return a}_link(e,t){this._halfedges[e]=t,t!==-1&&(this._halfedges[t]=e)}_addTriangle(e,t,n,r,i,a){let o=this.trianglesLen;return this._triangles[o]=e,this._triangles[o+1]=t,this._triangles[o+2]=n,this._link(o,r),this._link(o+1,i),this._link(o+2,a),this.trianglesLen+=3,o}};function LU(e,t){let n=e/(Math.abs(e)+Math.abs(t));return(t>0?3-n:1+n)/4}function RU(e,t,n,r){let i=e-n,a=t-r;return i*i+a*a}function zU(e,t,n,r,i,a,o,s){let c=e-o,l=t-s,u=n-o,d=r-s,f=i-o,p=a-s,m=c*c+l*l,h=u*u+d*d,g=f*f+p*p;return c*(d*g-h*p)-l*(u*g-h*f)+m*(u*p-d*f)<0}function BU(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c),p=(l*u-s*d)*f,m=(o*d-c*u)*f;return p*p+m*m}function VU(e,t,n,r,i,a){let o=n-e,s=r-t,c=i-e,l=a-t,u=o*o+s*s,d=c*c+l*l,f=.5/(o*l-s*c);return{x:e+(l*u-s*d)*f,y:t+(o*d-c*u)*f}}function HU(e,t,n,r){if(r-n<=20)for(let i=n+1;i<=r;i++){let r=e[i],a=t[r],o=i-1;for(;o>=n&&t[e[o]]>a;)e[o+1]=e[o--];e[o+1]=r}else{let i=n+r>>1,a=n+1,o=r;UU(e,i,a),t[e[n]]>t[e[r]]&&UU(e,n,r),t[e[a]]>t[e[r]]&&UU(e,a,r),t[e[n]]>t[e[a]]&&UU(e,n,a);let s=e[a],c=t[s];for(;;){do a++;while(t[e[a]]<c);do o--;while(t[e[o]]>c);if(o<a)break;UU(e,a,o)}e[n+1]=e[o],e[o]=s,r-a+1>=o-n?(HU(e,t,a,r),HU(e,t,n,o-1)):(HU(e,t,n,o-1),HU(e,t,a,r))}}function UU(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function WU(e){return e[0]}function GU(e){return e[1]}var KU=`
373
+ uniform vec3 u_lo; // the box minimum, relative to the data origin
374
+ uniform vec3 u_span; // the box size (0: a flat axis)
375
+ uniform int u_flat; // 0: 3D camera, 1: a 2D view
376
+ uniform vec3 u_eye; uniform vec3 u_right; uniform vec3 u_up; uniform vec3 u_fwd;
377
+ uniform float u_f;
378
+ uniform vec3 u_h; uniform vec3 u_v; uniform vec3 u_c; // 2D across, up; colour axis (one-hot)
379
+ uniform vec4 u_plot; // left, top, width, height (CSS px)
380
+ uniform vec2 u_resolution;
381
+ uniform sampler2D u_palette;
382
+ out vec3 v_n; // -1..1 in the box
383
+ out vec4 v_color;
384
+ vec3 norm(vec3 d) {
385
+ return vec3(u_span.x > 0.0 ? (d.x - u_lo.x) / u_span.x * 2.0 - 1.0 : 0.0,
386
+ u_span.y > 0.0 ? (d.y - u_lo.y) / u_span.y * 2.0 - 1.0 : 0.0,
387
+ u_span.z > 0.0 ? (d.z - u_lo.z) / u_span.z * 2.0 - 1.0 : 0.0);
388
+ }
389
+ vec4 place(vec3 d) {
390
+ vec3 n = norm(d);
391
+ v_n = n;
392
+ float t = clamp(dot(n, u_c) * 0.5 + 0.5, 0.0, 1.0);
393
+ v_color = texture(u_palette, vec2((t * 255.0 + 0.5) / 256.0, 0.5));
394
+ if (u_flat == 1) {
395
+ vec2 s = vec2(u_plot.x + (dot(n, u_h) * 0.5 + 0.5) * u_plot.z, u_plot.y + (0.5 - dot(n, u_v) * 0.5) * u_plot.w);
396
+ vec2 c = s / u_resolution * 2.0 - 1.0;
397
+ return vec4(c.x, -c.y, 0.0, 1.0);
398
+ }
399
+ vec3 w = vec3(n.x, n.z, n.y) - u_eye;
400
+ float cx = dot(w, u_right), cy = dot(w, u_up), cz = dot(w, u_fwd);
401
+ if (cz < 0.02) return vec4(2.0, 2.0, 2.0, 1.0);
402
+ float k = u_f * u_plot.w * 0.5;
403
+ vec2 s = vec2(u_plot.x + u_plot.z * 0.5 + cx / cz * k, u_plot.y + u_plot.w * 0.5 - cy / cz * k);
404
+ vec2 c = s / u_resolution * 2.0 - 1.0;
405
+ float z = clamp(cz / 16.0, 0.0, 1.0) * 2.0 - 1.0;
406
+ return vec4(c.x * cz, -c.y * cz, z * cz, cz);
407
+ }
408
+ `,qU=`bool outside(vec3 n) { return any(greaterThan(abs(n), vec3(1.0001))); }`,JU=`#version 300 es
409
+ in float a_x; in float a_y; in float a_z;
410
+ uniform float u_size;
411
+ ${KU}
412
+ ${qU}
413
+ void main() {
414
+ vec3 d = vec3(a_x, a_y, a_z);
415
+ gl_Position = place(d);
416
+ gl_PointSize = u_size;
417
+ if (a_x != a_x || a_y != a_y || a_z != a_z || outside(v_n)) gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
418
+ }`,YU=`#version 300 es
419
+ precision highp float;
420
+ in vec3 v_n; in vec4 v_color;
421
+ uniform float u_size; // device px
422
+ uniform float u_rim; // device px
423
+ out vec4 o;
424
+ void main() {
425
+ float r = length(gl_PointCoord * 2.0 - 1.0) * u_size * 0.5;
426
+ if (u_size >= 3.0 && r > u_size * 0.5) discard;
427
+ vec4 c = r > u_size * 0.5 - u_rim ? vec4(0.0588, 0.0627, 0.0784, 0.85) : v_color;
428
+ o = vec4(c.rgb * c.a, c.a);
429
+ }`,XU=`#version 300 es
430
+ in float a_x; in float a_y; in float a_z;
431
+ ${KU}
432
+ void main() { gl_Position = place(vec3(a_x, a_y, a_z)); }`,ZU=`#version 300 es
433
+ precision highp int;
434
+ uniform highp sampler2D u_z;
435
+ uniform ivec2 u_n; // grid size
436
+ uniform int u_step; // grid cells per drawn cell
437
+ uniform int u_wstep; // grid cells between wire lines
438
+ uniform int u_wire;
439
+ uniform vec4 u_ext; // x0, x1, y0, y1 (relative to the origin)
440
+ out float v_hole;
441
+ ${KU}
442
+ void main() {
443
+ int cx = (u_n.x - 2) / u_step + 1, cy = (u_n.y - 2) / u_step + 1;
444
+ int id = gl_VertexID, gx, gy;
445
+ if (u_wire == 0) {
446
+ int cell = id / 6, k = id - cell * 6;
447
+ int ox = (k == 1 || k == 4 || k == 5) ? 1 : 0, oy = (k == 2 || k == 3 || k == 5) ? 1 : 0;
448
+ gx = ((cell % cx) + ox) * u_step; gy = ((cell / cx) + oy) * u_step;
449
+ } else {
450
+ int seg = id / 2, end = id - seg * 2;
451
+ int rows = (u_n.y - 1) / u_wstep + 1;
452
+ if (seg < rows * cx) { gy = (seg / cx) * u_wstep; gx = ((seg % cx) + end) * u_step; }
453
+ else { seg -= rows * cx; gx = (seg / cy) * u_wstep; gy = ((seg % cy) + end) * u_step; }
454
+ }
455
+ gx = min(gx, u_n.x - 1); gy = min(gy, u_n.y - 1);
456
+ float z = texelFetch(u_z, ivec2(gx, gy), 0).r;
457
+ v_hole = z != z ? 1.0 : 0.0;
458
+ float fx = u_n.x > 1 ? float(gx) / float(u_n.x - 1) : 0.0, fy = u_n.y > 1 ? float(gy) / float(u_n.y - 1) : 0.0;
459
+ gl_Position = place(vec3(mix(u_ext.x, u_ext.y, fx), mix(u_ext.z, u_ext.w, fy), z == z ? z : 0.0));
460
+ }`,QU=`#version 300 es
461
+ precision highp float;
462
+ in vec3 v_n; in vec4 v_color;
463
+ uniform float u_alpha;
464
+ uniform vec4 u_solid; // a colour of its own (wire) when its alpha is set
465
+ ${qU}
466
+ out vec4 o;
467
+ void main() {
468
+ if (outside(v_n)) discard;
469
+ vec4 c = u_solid.a > 0.0 ? u_solid : vec4(v_color.rgb, u_alpha);
470
+ o = vec4(c.rgb * c.a, c.a);
471
+ }`,$U=`#version 300 es
472
+ precision highp float;
473
+ in vec3 v_n; in vec4 v_color; in float v_hole;
474
+ uniform float u_alpha;
475
+ uniform vec4 u_solid;
476
+ ${qU}
477
+ out vec4 o;
478
+ void main() {
479
+ if (v_hole > 0.0 || outside(v_n)) discard;
480
+ vec4 c = u_solid.a > 0.0 ? u_solid : vec4(v_color.rgb, u_alpha);
481
+ o = vec4(c.rgb * c.a, c.a);
482
+ }`,eW=16e6,tW=128,nW=[`u_lo`,`u_span`,`u_flat`,`u_eye`,`u_right`,`u_up`,`u_fwd`,`u_f`,`u_h`,`u_v`,`u_c`,`u_plot`,`u_resolution`,`u_palette`];function rW(e){for(let t=0;t<e.length;t++)if(e[t]===e[t]&&Math.abs(e[t])!==1/0)return e[t];return 0}function iW(e){let t=e.getContext(`webgl2`,{antialias:!0,alpha:!0,premultipliedAlpha:!0,depth:!0});if(!t)return null;let n=(e,n,r,i)=>MB(t,`gl3d|${e}|${n}`,()=>{let a=mB(t,t.VERTEX_SHADER,e),o=mB(t,t.FRAGMENT_SHADER,n);if(!a||!o)return null;let s=t.createProgram();return t.attachShader(s,a),t.attachShader(s,o),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)?{prog:s,a:Object.fromEntries(r.map(e=>[e,t.getAttribLocation(s,e)])),u:Object.fromEntries([...nW,...i].map(e=>[e,t.getUniformLocation(s,e)]))}:(console.error(`gl3d program link failed:`,t.getProgramInfoLog(s)),null)}),r=[`a_x`,`a_y`,`a_z`],i=n(JU,YU,r,[`u_size`,`u_rim`]),a=n(XU,QU,r,[`u_alpha`,`u_solid`]),o=n(ZU,$U,[],[`u_alpha`,`u_solid`,`u_z`,`u_n`,`u_step`,`u_wstep`,`u_wire`,`u_ext`]);if(!i||!a||!o)return null;let s=t.getParameter(t.MAX_TEXTURE_SIZE),c=t.createVertexArray(),l={x:t.createBuffer(),y:t.createBuffer(),z:t.createBuffer()},u=t.createBuffer(),d=t.createBuffer(),f=new Map,p=t.createTexture(),m=t.createTexture(),h=1,g=1,_=1,v={minX:0,maxX:1,minY:0,maxY:1,minZ:0,maxZ:1},y={kind:`2d`,h:0,v:1},b={left:0,top:0,width:1,height:1},x=null,S=0,C=[0,0,0],w=0,T=0,E=null,D={w:0,h:0},O=new Float32Array,k=(e,n,r)=>{t.bindBuffer(e,n),r.byteLength<=(f.get(n)??0)?t.bufferSubData(e,0,r):(t.bufferData(e,r,t.DYNAMIC_DRAW),f.set(n,r.byteLength))},A=(e,t)=>{let n=e.length;O.length<n&&(O=new Float32Array(n));for(let r=0;r<n;r++)O[r]=e[r]-t;return O.subarray(0,n)},j=(e,n)=>{let r=e.u,i=v;t.uniform3f(r.u_lo,i.minX-n[0],i.minY-n[1],i.minZ-n[2]);let a=(e,t)=>t-e>1e-12*Math.max(1,Math.abs(e))?t-e:0;t.uniform3f(r.u_span,a(i.minX,i.maxX),a(i.minY,i.maxY),a(i.minZ,i.maxZ));let o=e=>[+(e===0),+(e===1),+(e===2)];y.kind===`3d`?(t.uniform1i(r.u_flat,0),t.uniform3f(r.u_eye,...y.eye),t.uniform3f(r.u_right,...y.right),t.uniform3f(r.u_up,...y.up),t.uniform3f(r.u_fwd,...y.fwd),t.uniform1f(r.u_f,y.f)):(t.uniform1i(r.u_flat,1),t.uniform3f(r.u_h,...o(y.h)),t.uniform3f(r.u_v,...o(y.v))),t.uniform3f(r.u_c,...o(x.colorAxis)),t.uniform4f(r.u_plot,b.left,b.top,b.width,b.height),t.uniform2f(r.u_resolution,h,g),t.uniform1i(r.u_palette,0)},M=e=>{for(let n of[`x`,`y`,`z`]){let r=e.a[`a_${n}`];t.bindBuffer(t.ARRAY_BUFFER,l[n]),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,1,t.FLOAT,!1,0,0)}};return{maxTextureSize:s,resize(t,n,r){h=Math.max(1,t),g=Math.max(1,n),_=r,e.width=Math.max(1,Math.round(h*_)),e.height=Math.max(1,Math.round(g*_))},setBounds(e){v=e},setView(e,t){y=e,b=t},setPoints(e,n,r){if(!e||!n||!r){S=0;return}S=Math.min(e.length,n.length,r.length),C=[rW(e),rW(n),rW(r)],k(t.ARRAY_BUFFER,l.x,A(e,C[0]).subarray(0,S)),k(t.ARRAY_BUFFER,l.y,A(n,C[1]).subarray(0,S)),k(t.ARRAY_BUFFER,l.z,A(r,C[2]).subarray(0,S))},setTriangles(e){if(!e||e.length<3){w=T=0;return}w=e.length-e.length%3,k(t.ELEMENT_ARRAY_BUFFER,u,e.subarray(0,w));let n=new Uint32Array(w*2);for(let t=0;t<w;t+=3){let r=e[t],i=e[t+1],a=e[t+2],o=t*2;n[o]=r,n[o+1]=i,n[o+2]=i,n[o+3]=a,n[o+4]=a,n[o+5]=r}T=n.length,k(t.ELEMENT_ARRAY_BUFFER,d,n)},setSurface(e,n=0,r=0,i=[0,1],a=[0,1]){if(!e||n<2||r<2||n>s||r>s){E=null;return}let o=rW(e),c=A(e,o).subarray(0,n*r);t.bindTexture(t.TEXTURE_2D,m),t.pixelStorei(t.UNPACK_ALIGNMENT,4),D.w===n&&D.h===r?t.texSubImage2D(t.TEXTURE_2D,0,0,0,n,r,t.RED,t.FLOAT,c):(t.texImage2D(t.TEXTURE_2D,0,t.R32F,n,r,0,t.RED,t.FLOAT,c),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),D={w:n,h:r}),E={w:n,h:r,origin:o,ext:[i[0],i[1],a[0],a[1]]}},setStyle(e){x?.palette!==e.palette&&(t.bindTexture(t.TEXTURE_2D,p),t.texImage2D(t.TEXTURE_2D,0,t.RGBA8,256,1,0,t.RGBA,t.UNSIGNED_BYTE,e.palette),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)),x=e},render(){t.viewport(0,0,e.width,e.height),t.clearColor(0,0,0,0),t.clearDepth(1),t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT);let n=x;if(!n)return;t.bindVertexArray(c),t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.enable(t.DEPTH_TEST),t.depthFunc(t.LEQUAL),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,p),t.enable(t.POLYGON_OFFSET_FILL),t.polygonOffset(1,1);let r=n.wireColor;if(E){let e=o;t.useProgram(e.prog);let[i,a,s,c]=E.ext;j(e,[i,s,E.origin]),t.uniform4f(e.u.u_ext,0,a-i,0,c-s),t.activeTexture(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,m),t.uniform1i(e.u.u_z,1),t.uniform2i(e.u.u_n,E.w,E.h);let l=(E.w-1)*(E.h-1),u=Math.max(1,Math.ceil(Math.sqrt(l/eW))),d=Math.floor((E.w-2)/u)+1,f=Math.floor((E.h-2)/u)+1;if(t.uniform1i(e.u.u_step,u),t.uniform1f(e.u.u_alpha,n.fillAlpha),n.fill&&(t.uniform1i(e.u.u_wire,0),t.uniform4f(e.u.u_solid,0,0,0,0),t.drawArrays(t.TRIANGLES,0,d*f*6)),n.wire){let n=u*Math.max(1,Math.ceil(Math.max(d,f)/tW)),i=Math.floor((E.h-1)/n)+1,a=Math.floor((E.w-1)/n)+1;t.uniform1i(e.u.u_wire,1),t.uniform1i(e.u.u_wstep,n),t.uniform4f(e.u.u_solid,...r),t.drawArrays(t.LINES,0,(i*d+a*f)*2)}t.activeTexture(t.TEXTURE0)}if(S>0){if(w>0&&(n.fill||n.wire)){let e=a;t.useProgram(e.prog),j(e,C),M(e),t.uniform1f(e.u.u_alpha,n.fillAlpha),n.fill&&(t.uniform4f(e.u.u_solid,0,0,0,0),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,u),t.drawElements(t.TRIANGLES,w,t.UNSIGNED_INT,0)),n.wire&&(t.uniform4f(e.u.u_solid,...r),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,d),t.drawElements(t.LINES,T,t.UNSIGNED_INT,0))}let e=i;t.useProgram(e.prog),j(e,C),M(e);let o=Math.max(1,2*n.pointRadius*_);t.uniform1f(e.u.u_size,o),t.uniform1f(e.u.u_rim,o>=3?Math.max(.9,n.pointRadius*.3)*_:0),t.drawArrays(t.POINTS,0,S)}t.disable(t.POLYGON_OFFSET_FILL),t.disable(t.DEPTH_TEST),t.bindVertexArray(null)},dispose(){for(let e of[l.x,l.y,l.z,u,d])t.deleteBuffer(e);t.deleteTexture(p),t.deleteTexture(m),t.deleteVertexArray(c)}}}var aW=new Map;function oW(e,t){let n=aW.get(e);if(!n){let r=typeof OffscreenCanvas>`u`?null:new OffscreenCanvas(1,1).getContext(`2d`,{willReadFrequently:!0});if(!r)return[0,0,0,t];r.fillStyle=e,r.fillRect(0,0,1,1);let i=r.getImageData(0,0,1,1).data;aW.set(e,n=[i[0]/255,i[1]/255,i[2]/255,i[3]/255])}return[n[0],n[1],n[2],n[3]*t]}function sW(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}function cW(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}function lW(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function uW(e){return Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z)}function dW(e){let t=uW(e);return t>1e-12?{x:e.x/t,y:e.y/t,z:e.z/t}:{x:0,y:0,z:1}}function fW(e,t,n,r){let i=Math.cos(n),a=Math.sin(n),o=Math.cos(r),s=Math.sin(r);return{x:e.x+t*o*a,y:e.y+t*s,z:e.z+t*o*i}}function pW(e,t,n){let r=dW(sW(t,e)),i=dW(cW(r,n));return{right:i,up:cW(i,r),fwd:r,eye:e}}function mW(e,t,n,r,i){let a=sW(e,t.eye),o=lW(a,t.right),s=lW(a,t.up),c=lW(a,t.fwd);if(c<.01)return{sx:-9999,sy:-9999,depth:c};let l=1/Math.tan(n/2);return{sx:r/2+o/c*l*(i/2),sy:i/2-s/c*l*(i/2),depth:c}}function hW(e,t,n,r){let i=(e,t,n)=>{let r=n-t;return r<1e-12?0:(e-t)/r*2-1};return{x:i(e,r.minX,r.maxX),y:i(n,r.minZ,r.maxZ),z:i(t,r.minY,r.maxY)}}var gW=16,_W=.1,vW=Math.PI/4,yW=Math.PI/5,bW=3.2,xW=2e4,SW=(()=>{let e=new Uint8Array(256*4);for(let t=0;t<256;t++){let{r:n,g:r,b:i}=UH(t/255);e.set([n,r,i,255],t*4)}return e})();function CW(e){if(!Array.isArray(e))return e;let t=e.length,n=new Float64Array(t),r=new Float64Array(t),i=new Float64Array(t);for(let a=0;a<t;a++)n[a]=e[a].x,r[a]=e[a].y,i[a]=e[a].z;return{length:t,x:n,y:r,z:i}}var wW=(e,t)=>!t||e>=t[0]&&e<=t[1];function TW(e,t,n,r){let i=new Uint32Array(e.length),a=0;for(let o=0;o<e.length;o++){let s=e.x[o],c=e.y[o],l=e.z[o];s-s===0&&c-c===0&&l-l===0&&wW(s,t)&&wW(c,n)&&wW(l,r)&&(i[a++]=o)}if(a<3)return null;let o=new Float64Array(a*2);for(let t=0;t<a;t++)o[2*t]=e.x[i[t]],o[2*t+1]=e.y[i[t]];try{let e=new IU(o).triangles;for(let t=0;t<e.length;t++)e[t]=i[e[t]];return e.length>=3?e:null}catch{return null}}var EW=We(function({points:e,surface:t,xLabel:n,yLabel:r,zLabel:i,height:a=500,backgroundToken:o=``,xRange:s,yRange:c,zRange:l,viewMode:u,pointRadius:d=4,alarms:f,showMesh:p=!1,meshStyle:m=`filled`,meshOpacity:h=.85,onPlotContextMenu:g},_){let v=K(g);G(()=>{v.current=g},[g]);let y=K(null),b=K(null),x=K(null),S=K(vW),C=K(yW),w=K(bW),T=K(null),E=K({xLabel:n,yLabel:r,zLabel:i,height:a,viewMode:u,pointRadius:d,alarms:f??[],showMesh:p,meshStyle:m,meshOpacity:h});G(()=>{E.current={xLabel:n,yLabel:r,zLabel:i,height:a,viewMode:u,pointRadius:d,alarms:f??[],showMesh:p,meshStyle:m,meshOpacity:h}},[n,r,i,a,u,d,f,p,m,h]);let D=Xe(()=>{let n=CW(e),r=1/0,i=-1/0,a=1/0,o=-1/0,u=1/0,d=-1/0,f=0,p=0,m=0,h=0;for(let e=0;e<n.length;e++){let t=n.x[e],g=n.y[e],_=n.z[e];t-t!==0||g-g!==0||_-_!==0||!wW(t,s)||!wW(g,c)||!wW(_,l)||(t<r&&(r=t),t>i&&(i=t),g<a&&(a=g),g>o&&(o=g),_<u&&(u=_),_>d&&(d=_),f+=t,p+=g,m+=_,h++)}let g=null;if(t&&t.w>=2&&t.h>=2){let e=t.values,n=!1;for(let r=0;r<t.w*t.h;r++){let t=e[r];t-t===0&&(n=!0,t<u&&(u=t),t>d&&(d=t))}n&&(g=t,r=Math.min(r,t.x[0],t.x[1]),i=Math.max(i,t.x[0],t.x[1]),a=Math.min(a,t.y[0],t.y[1]),o=Math.max(o,t.y[0],t.y[1]))}if(h===0&&!g)return null;s&&(r=s[0],i=s[1]),c&&(a=c[0],o=c[1]),l&&(u=l[0],d=l[1]);let _={minX:r,maxX:i,minY:a,maxY:o,minZ:u,maxZ:d},v=h>0?hW(f/h,p/h,m/h,_):{x:0,y:0,z:0};return{cols:h>0?n:null,surface:g,bounds:_,center:v}},[e,t,s,c,l]),O=u??`3d`,k=p&&(O===`3d`||O===`xy`),A=Xe(()=>k&&D?.cols?TW(D.cols,s,c,l):null,[k,D,s,c,l]),j=K({model:D,triangles:A});G(()=>{j.current={model:D,triangles:A}},[D,A]);let M=K({r:null,failed:!1,cols:null,surface:null,tris:null,size:``});function N(e,t,n){let r=M.current;!r.r&&!r.failed&&b.current&&(r.r=NB(b.current,iW),r.failed=!r.r);let i=r.r;if(!i||!b.current)return null;let a=`${e}x${t}@${n}`;r.size!==a&&(i.resize(e,t,n),b.current.style.width=`${e}px`,b.current.style.height=`${t}px`,r.size=a);let{model:o,triangles:s}=j.current,c=o?.cols??null;r.cols!==c&&(i.setPoints(c?.x??null,c?.y,c?.z),r.cols=c);let l=o?.surface??null;return r.surface!==l&&(i.setSurface(l?.values??null,l?.w,l?.h,l?.x,l?.y),r.surface=l),r.tris!==s&&(i.setTriangles(s),r.tris=s),i}W(()=>()=>{M.current.r?.dispose(),M.current.r=null},[]);let P=K(null);function F(){let e=y.current,t=x.current;if(!e||!t)return;let n=Math.max(1,t.clientWidth),r=Math.max(1,t.clientHeight),i=Math.min(2,window.devicePixelRatio||1),a=Math.floor(n*i),o=Math.floor(r*i);(e.width!==a||e.height!==o)&&(e.width=a,e.height=o);let s=e.getContext(`2d`);if(!s)return;s.setTransform(i,0,0,i,0,0);let{bg:c,muted:l,grid:u}=I(),{xLabel:d,yLabel:f,zLabel:p}=E.current,m=Math.max(.25,E.current.pointRadius??4),h=aU({top:0,right:0,bottom:0,left:0},n,r).tiny;s.fillStyle=c,s.fillRect(0,0,n,r);let g=j.current.model,_=N(n,r,i);if(!g){if(_?.setStyle({palette:SW,colorAxis:2,pointRadius:m,fill:!1,wire:!1,fillAlpha:1,wireColor:[0,0,0,0]}),_?.setPoints(null),M.current.cols=null,_?.render(),h)return;s.fillStyle=l,s.font=`13px ${Q.sans}`,s.fillText(`Need at least one sample point`,gW,32);return}let v=g.bounds,b=E.current.viewMode??`3d`,T=b===`xz`?1:b===`yz`?0:2,D=[v.minX,v.minY,v.minZ][T],O=[v.maxX,v.maxY,v.maxZ][T],k=(e,t,n)=>{let r=T===0?e:T===1?t:n,i=O-D;return i>1e-12?(r-D)/i:.5},A,F,L,R=(e,t,r)=>{let i=n-28,a=t/32;for(let t=0;t<32;t++)s.fillStyle=WH(1-t/32),s.fillRect(i,e+t*a,14,a+1);s.strokeStyle=u,s.lineWidth=1,s.strokeRect(i,e,14,t),s.fillStyle=l,s.font=`9px ${Q.mono}`,s.textAlign=`right`,s.fillText(ez(O),i-4,e+4),s.fillText(ez(D),i-4,e+t),s.fillText(r,i-4,e-6)},z=e=>{s.fillStyle=l,s.font=`10px ${Q.sans}`,s.textAlign=`left`,s.globalAlpha=.7,s.fillText(e,gW,r-6),s.globalAlpha=1};if(b!==`3d`){let e,t,i,a,o,c,m,g,_;b===`xy`?(e=d,t=f,i=p,a=v.minX,o=v.maxX,c=v.minY,m=v.maxY,g=0,_=1):b===`xz`?(e=d,t=p,i=f,a=v.minX,o=v.maxX,c=v.minZ,m=v.maxZ,g=0,_=2):(e=f,t=p,i=d,a=v.minY,o=v.maxY,c=v.minZ,m=v.maxZ,g=1,_=2);let y=aU({left:72,right:48,top:24,bottom:52},n,r),x=Math.max(1,n-y.left-y.right),S=Math.max(1,r-y.top-y.bottom),C=o-a||1,w=m-c||1,T=e=>y.left+(e-a)/C*x,D=e=>y.top+S-(e-c)/w*S;A={left:y.left,top:y.top,width:x,height:S},L={kind:`2d`,h:g,v:_},F=(e,t,n)=>{let r=[e,t,n];return[T(r[g]),D(r[_])]};let O=KR(C,8),k=KR(w,8),j=YR(a,o,O),M=YR(c,m,k);s.strokeStyle=u,s.lineWidth=.5,s.globalAlpha=.3;for(let e of j){let t=T(e);s.beginPath(),s.moveTo(t,y.top),s.lineTo(t,y.top+S),s.stroke()}for(let e of M){let t=D(e);s.beginPath(),s.moveTo(y.left,t),s.lineTo(y.left+x,t),s.stroke()}s.globalAlpha=1,s.strokeStyle=u,s.lineWidth=1,s.strokeRect(y.left,y.top,x,S),s.save(),s.beginPath(),s.rect(y.left,y.top,x,S),s.clip();for(let e of E.current.alarms){let{axis:t,value:n,color:r,style:i,width:a}=e,o=null,c=null;b===`xy`?t===`x`?o=T(n):t===`y`&&(c=D(n)):b===`xz`?t===`x`?o=T(n):t===`z`&&(c=D(n)):t===`y`?o=T(n):t===`z`&&(c=D(n)),!(o===null&&c===null)&&(i===`dashed`?s.setLineDash([7,4]):i===`dotted`?s.setLineDash([2,4]):s.setLineDash([]),s.strokeStyle=r,s.lineWidth=a,s.globalAlpha=.9,s.beginPath(),o===null?c!==null&&(s.moveTo(y.left,c),s.lineTo(y.left+x,c)):(s.moveTo(o,y.top),s.lineTo(o,y.top+S)),s.stroke(),s.setLineDash([]),s.globalAlpha=1,s.fillStyle=r,s.font=`bold 10px ${Q.mono}`,s.globalAlpha=.95,o===null?c!==null&&(s.textAlign=`left`,s.textBaseline=`bottom`,s.fillText(ez(n),y.left+3,c-2)):(s.textAlign=`left`,s.textBaseline=`top`,s.fillText(ez(n),o+3,y.top+2)),s.globalAlpha=1,s.textBaseline=`alphabetic`)}if(s.restore(),!h){s.fillStyle=l,s.font=`10px ${Q.mono}`,s.textAlign=`center`,s.textBaseline=`top`;for(let e of j)s.fillText($R(e,O),T(e),y.top+S+6);s.textAlign=`right`,s.textBaseline=`middle`;for(let e of M)s.fillText($R(e,k),y.left-8,D(e));s.textBaseline=`alphabetic`,s.font=`bold 11px ${Q.mono}`,s.textAlign=`center`,s.fillStyle=`#fb7185`,s.fillText(e,y.left+x/2,r-8),s.save(),s.translate(14,y.top+S/2),s.rotate(-Math.PI/2),s.fillStyle=`#38bdf8`,s.textAlign=`center`,s.fillText(t,0,0),s.restore(),R(y.top+8,Math.min(S-20,180),i),z(`2D projection: ${b.toUpperCase()} plane · Color = ${i}`)}}else{let e=S.current,t=C.current,i=w.current,a=pW(fW(g.center,i,e,t),g.center,{x:0,y:1,z:0}),o=Math.PI/3,c=h?3:gW,m=Math.max(1,n-c*2),_=Math.max(1,r-c*2-(h?0:24));A={left:c,top:c,width:m,height:_};let y=e=>[e.x,e.y,e.z];L={kind:`3d`,eye:y(a.eye),right:y(a.right),up:y(a.up),fwd:y(a.fwd),f:1/Math.tan(o/2)};let b=e=>{let t=mW(e,a,o,m,_);return{sx:t.sx+c,sy:t.sy+c,depth:t.depth}};F=(e,t,n)=>{let r=b(hW(e,t,n,v));return r.depth<.02?null:[r.sx,r.sy]};let x=(e,t,n)=>{let r=b(e),i=b(t);r.depth<.02||i.depth<.02||(s.strokeStyle=n.color,s.lineWidth=n.width,s.globalAlpha=n.alpha??1,s.beginPath(),s.moveTo(r.sx,r.sy),s.lineTo(i.sx,i.sy),s.stroke(),s.globalAlpha=1)},T=KR(v.maxX-v.minX,6),D=KR(v.maxY-v.minY,6),O=KR(v.maxZ-v.minZ,6),k=YR(v.minX,v.maxX,T),j=YR(v.minY,v.maxY,D),M=YR(v.minZ,v.maxZ,O),N=XR(v.minX,v.maxX,T/5,k),P=XR(v.minY,v.maxY,D/5,j),I=XR(v.minZ,v.maxZ,O/5,M);for(let[e,t]of[[{x:-1,y:-1,z:-1},{x:1,y:-1,z:-1}],[{x:1,y:-1,z:-1},{x:1,y:-1,z:1}],[{x:1,y:-1,z:1},{x:-1,y:-1,z:1}],[{x:-1,y:-1,z:1},{x:-1,y:-1,z:-1}],[{x:-1,y:1,z:-1},{x:1,y:1,z:-1}],[{x:1,y:1,z:-1},{x:1,y:1,z:1}],[{x:1,y:1,z:1},{x:-1,y:1,z:1}],[{x:-1,y:1,z:1},{x:-1,y:1,z:-1}],[{x:-1,y:-1,z:-1},{x:-1,y:1,z:-1}],[{x:1,y:-1,z:-1},{x:1,y:1,z:-1}],[{x:1,y:-1,z:1},{x:1,y:1,z:1}],[{x:-1,y:-1,z:1},{x:-1,y:1,z:1}]])x(e,t,{color:u,width:1,alpha:.65});if(!h){for(let e of k){let t=hW(e,v.minY,v.minZ,v).x;x({x:t,y:-1,z:-1},{x:t,y:-1,z:1},{color:u,width:.75,alpha:.45})}for(let e of j){let t=hW(v.minX,e,v.minZ,v).z;x({x:-1,y:-1,z:t},{x:1,y:-1,z:t},{color:u,width:.75,alpha:.45})}for(let e of P){let t=hW(v.minX,e,v.minZ,v).z;x({x:-1,y:-1,z:t},{x:1,y:-1,z:t},{color:u,width:.5,alpha:.22})}for(let e of N){let t=hW(e,v.minY,v.minZ,v).x;x({x:t,y:-1,z:-1},{x:t,y:-1,z:1},{color:u,width:.5,alpha:.22})}let e=(e,t)=>{let n=_W*(t?1:.55);x({x:e,y:-1,z:-1},{x:e,y:-1+n,z:-1},{color:`#fb7185`,width:t?1.25:.75,alpha:.95})},t=(e,t)=>{let n=_W*(t?1:.55);x({x:-1,y:-1,z:e},{x:-1+n,y:-1,z:e},{color:`#38bdf8`,width:t?1.25:.75,alpha:.95})},n=(e,t)=>{let n=_W*(t?1:.55);x({x:-1,y:e,z:-1},{x:-1+n,y:e,z:-1},{color:`#4ade80`,width:t?1.25:.75,alpha:.95})};for(let t of N)e(hW(t,v.minY,v.minZ,v).x,!1);for(let t of k)e(hW(t,v.minY,v.minZ,v).x,!0);for(let e of P)t(hW(v.minX,e,v.minZ,v).z,!1);for(let e of j)t(hW(v.minX,e,v.minZ,v).z,!0);for(let e of I)n(hW(v.minX,v.minY,e,v).y,!1);for(let e of M)n(hW(v.minX,v.minY,e,v).y,!0)}let B=(e,t,n)=>{let r=n-t;return r<1e-12?0:(e-t)/r*2-1};for(let e of E.current.alarms){let{axis:t,value:n,color:r,style:i,width:a}=e,o;if(t===`z`){let e=B(n,v.minZ,v.maxZ);o=[{x:-1,y:e,z:-1},{x:1,y:e,z:-1},{x:1,y:e,z:1},{x:-1,y:e,z:1}]}else if(t===`x`){let e=B(n,v.minX,v.maxX);o=[{x:e,y:-1,z:-1},{x:e,y:1,z:-1},{x:e,y:1,z:1},{x:e,y:-1,z:1}]}else{let e=B(n,v.minY,v.maxY);o=[{x:-1,y:-1,z:e},{x:1,y:-1,z:e},{x:1,y:1,z:e},{x:-1,y:1,z:e}]}let c=o.map(e=>b(e));if(c.every(e=>e.depth>=.02)){s.beginPath(),s.moveTo(c[0].sx,c[0].sy);for(let e=1;e<c.length;e++)s.lineTo(c[e].sx,c[e].sy);s.closePath(),s.fillStyle=r,s.globalAlpha=.18,s.fill(),i===`dashed`?s.setLineDash([7,4]):i===`dotted`?s.setLineDash([2,4]):s.setLineDash([]),s.strokeStyle=r,s.lineWidth=a,s.globalAlpha=.9,s.beginPath(),s.moveTo(c[0].sx,c[0].sy);for(let e=1;e<c.length;e++)s.lineTo(c[e].sx,c[e].sy);s.closePath(),s.stroke(),s.setLineDash([]),s.globalAlpha=1;let e=c.reduce((e,t)=>t.sy>e.sy?t:e);s.fillStyle=r,s.font=`bold 10px ${Q.mono}`,s.textAlign=`center`,s.globalAlpha=.95,s.fillText(`${t.toUpperCase()}=${ez(n)}`,e.sx,e.sy-6),s.globalAlpha=1}}if(!h){s.font=`10px ${Q.mono}`,s.textBaseline=`middle`;for(let e of k){let t=hW(e,v.minY,v.minZ,v).x,n=b({x:t,y:-1.2,z:-1.2});n.depth<.02||(s.fillStyle=l,s.textAlign=`center`,s.fillText($R(e,T),n.sx,n.sy+12))}for(let e of j){let t=hW(v.minX,e,v.minZ,v).z,n=b({x:-1.22,y:-1,z:t});n.depth<.02||(s.textAlign=`right`,s.fillText($R(e,D),n.sx-4,n.sy))}for(let e of M){let t=hW(v.minX,v.minY,e,v).y,n=b({x:-1.22,y:t,z:-1.2});n.depth<.02||(s.textAlign=`right`,s.fillText($R(e,O),n.sx-4,n.sy))}s.textBaseline=`alphabetic`,s.font=`bold 11px ${Q.mono}`;let e=b({x:1.15,y:-1,z:-1.15});e.depth>=.02&&(s.fillStyle=`#fb7185`,s.textAlign=`center`,s.fillText(d,e.sx,e.sy+16)),e=b({x:-1.18,y:-1,z:1.15}),e.depth>=.02&&(s.fillStyle=`#38bdf8`,s.textAlign=`center`,s.fillText(f,e.sx-10,e.sy)),e=b({x:-1.18,y:1.15,z:-1.18}),e.depth>=.02&&(s.fillStyle=`#4ade80`,s.textAlign=`center`,s.fillText(p,e.sx-10,e.sy)),R(gW+8,Math.min(r-80,180),p),z(`Drag: rotate | Wheel: zoom | Dbl‑click: reset · ${g.surface?`Surface`:E.current.showMesh?`Mesh: ${E.current.meshStyle}`:`Scatter`} · color = Z`)}}let{showMesh:B,meshStyle:V,meshOpacity:ee}=E.current,te=!!g.surface||B;if(_)_.setBounds(v),_.setView(L,A),_.setStyle({palette:SW,colorAxis:T,pointRadius:m,fill:te&&(V===`filled`||V===`both`),wire:te&&(V===`wireframe`||V===`both`),fillAlpha:ee,wireColor:oW(u,.5)}),_.render(),P.current!==g&&(P.current=g,rV(t));else if(g.cols){let e=g.cols,t=Math.max(1,Math.ceil(e.length/xW));for(let n=0;n<e.length;n+=t){let t=e.x[n],r=e.y[n],i=e.z[n];if(!(t>=v.minX&&t<=v.maxX&&r>=v.minY&&r<=v.maxY&&i>=v.minZ&&i<=v.maxZ))continue;let a=F(t,r,i);a&&(s.fillStyle=WH(k(t,r,i)),s.beginPath(),s.arc(a[0],a[1],m,0,Math.PI*2),s.fill())}}}function I(){if(T.current)return T.current;let e=x.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 T.current=n,n}let L=K(F);G(()=>{L.current=F});let R=K(null);R.current??=sV(()=>L.current(),()=>x.current?.ownerDocument),W(()=>()=>R.current?.cancel(),[]);let z=()=>{S.current=vW,C.current=yW,w.current=bW,R.current.schedule()};return Ye(_,()=>({autoscale:z}),[]),W(()=>cz(x.current,()=>{T.current=null,R.current.schedule()}),[]),W(()=>{T.current=null,R.current.schedule()},[o]),W(()=>{R.current.now()},[D,A,n,r,i,a,u,d,f,p,m,h]),W(()=>{let e=y.current,t=x.current;if(!e||!t)return;let n=()=>R.current.schedule(),r=new oV(()=>{T.current=null,n()});r.observe(t);let i=!1,a=0,o=0,s=t=>{t.button===0&&(i=!0,a=t.clientX,o=t.clientY,e.setPointerCapture(t.pointerId))},c=e=>{if(!i)return;let t=e.clientX-a,r=e.clientY-o;a=e.clientX,o=e.clientY,S.current-=t*.008,C.current+=r*.008,C.current=Math.max(-Math.PI/2+.05,Math.min(Math.PI/2-.05,C.current)),n()},l=()=>{i=!1},u=e=>{e.preventDefault();let t=e.deltaY>0?1.08:.92;w.current=Math.max(1.2,Math.min(12,w.current*t)),n()},d=()=>{S.current=vW,C.current=yW,w.current=bW,n()},f=e=>{e.preventDefault(),v.current?.({clientX:e.clientX,clientY:e.clientY})};return e.addEventListener(`pointerdown`,s),e.addEventListener(`pointermove`,c),e.addEventListener(`pointerup`,l),e.addEventListener(`pointercancel`,l),e.addEventListener(`wheel`,u,{passive:!1}),e.addEventListener(`contextmenu`,f),e.addEventListener(`dblclick`,d),()=>{r.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`pointermove`,c),e.removeEventListener(`pointerup`,l),e.removeEventListener(`pointercancel`,l),e.removeEventListener(`wheel`,u),e.removeEventListener(`contextmenu`,f),e.removeEventListener(`dblclick`,d)}},[]),nt(`div`,{ref:x,className:`chart-canvas-wrap`,children:[q(`canvas`,{ref:y,className:`chart-canvas`,role:`img`,"aria-label":`3D scatter: ${n} vs ${r} vs ${i}`,style:{display:`block`,width:`100%`,height:`100%`,cursor:`grab`}}),q(`canvas`,{ref:b,className:`chart-canvas chart-overlay`,style:{pointerEvents:`none`}})]})}),DW={top:14,right:24,bottom:40,left:64},OW=5;function kW(e){return e===`dashed`?[5,4]:e===`dotted`?[1,4]:[]}function AW(e){return Math.max(10,Math.min(200,Math.ceil(Math.sqrt(e))))}function jW(e,t,n){let r=(e-t)/n;return Math.exp(-.5*r*r)/(n*Math.sqrt(2*Math.PI))}function MW(e,t){let n=e.length;if(n===0)return null;let r=1/0,i=-1/0,a=0;for(let t=0;t<n;t++){let n=e[t];n<r&&(r=n),n>i&&(i=n),a+=n}r===i&&(--r,i+=1);let o=t>0?t:AW(n),s=(i-r)/o,c=Array(o).fill(0),l=a/n,u=0;for(let t=0;t<n;t++){let n=e[t];c[Math.min(o-1,Math.floor((n-r)/s))]++,u+=(n-l)**2}return{lo:r,hi:i,nBins:o,width:s,counts:c,mean:l,sd:Math.sqrt(u/n),total:n}}function NW({values:e,label:t,bins:n=0,color:r=`#38bdf8`,showNormal:i=!1,logY:a=!1,height:o=400,backgroundToken:s=``,onPlotContextMenu:c}){let l=_V(),u=K(null),d=K(null),f=K(null),p=K(null),m=K(0),h=K(null),g=K(c);G(()=>{g.current=c},[c]);let _=K({values:e,label:t,bins:n,color:r,showNormal:i,logY:a,height:o});G(()=>{_.current={values:e,label:t,bins:n,color:r,showNormal:i,logY:a,height:o}},[e,t,n,r,i,a,o]);function v(){if(h.current)return h.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 h.current=n,n}function y(){let e=f.current;return{w:Math.max(1,e?.clientWidth||200),h:Math.max(1,e?.clientHeight||_.current.height)}}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}let x=Xe(()=>MW(e,n),[e,n]),S=K(x);G(()=>{S.current=x},[x]);let C=()=>S.current;function w(){let e=u.current;if(!e)return;let{w:t,h:n}=y(),r=b(e,t,n);if(!r)return;let{top:i,right:a,bottom:o,left:s}=DW,c=t-s-a,d=n-i-o,{bg:f,muted:p,grid:m}=v(),{label:h,color:g,showNormal:x,logY:S}=_.current;r.fillStyle=f,r.fillRect(0,0,t,n);let w=C();if(!w||c<=0||d<=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{lo:T,hi:E,nBins:D,width:O,counts:k,mean:A,sd:j,total:M}=w,N=Math.max(...k),P=S?Math.log10(N+1)+.1:N*1.08,F=e=>s+(e-T)/(E-T)*c;l({left:s,top:i,width:c,height:d,x:{v0:T,v1:E}});let I=e=>i+(P-(S?e>0?Math.log10(e):0:e))/(P-0)*d,L=S?1:KR(P,5),R=YR(0,S?P:N,L);r.strokeStyle=m,r.lineWidth=1,r.setLineDash(kW(`dashed`));for(let e of R){let t=I(e);r.beginPath(),r.moveTo(s,t),r.lineTo(s+c,t),r.stroke()}r.setLineDash([]);let z=Math.max(.5,c/D*.04);for(let e=0;e<D;e++){let t=F(T+e*O)+z/2,n=F(T+(e+1)*O)-z/2,i=I(0),a=I(k[e]);r.fillStyle=g,r.globalAlpha=.75,r.fillRect(t,a,n-t,i-a),r.globalAlpha=1}if(x&&j>0){r.beginPath();for(let e=0;e<=200;e++){let t=T+e/200*(E-T),n=jW(t,A,j)*M*O,i=F(t),a=I(n);e===0?r.moveTo(i,a):r.lineTo(i,a)}r.strokeStyle=`#f97316`,r.lineWidth=1,r.stroke()}r.strokeStyle=p,r.lineWidth=1,r.fillStyle=p,r.font=`11px ${Q.mono}`,r.textAlign=`right`,r.textBaseline=`middle`;for(let e of R){let t=I(e);r.beginPath(),r.moveTo(s-OW,t),r.lineTo(s,t),r.stroke(),r.fillText(S?`10^${e.toFixed(0)}`:$R(e,L),s-4,t)}let B=KR(E-T,qR(c)),V=YR(T,E,B);r.fillStyle=p,r.textAlign=`center`,r.textBaseline=`top`;for(let e of V){let t=F(e);r.beginPath(),r.moveTo(t,i+d),r.lineTo(t,i+d+OW),r.stroke(),r.fillText($R(e,B),t,i+d+OW+2)}r.strokeStyle=m,r.lineWidth=1,r.strokeRect(s,i,c,d),r.fillStyle=p,r.font=`11px ${Q.mono}`,r.textAlign=`center`,r.textBaseline=`bottom`,r.fillText(h,s+c/2,n-4),r.save(),r.translate(14,i+d/2),r.rotate(-Math.PI/2),r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(S?`log₁₀(count)`:`count`,0,0),r.restore()}let T=K(w);T.current=w;let E=K(null);E.current??=sV(()=>T.current(),()=>f.current?.ownerDocument);let D=()=>E.current.schedule();function O(e){let t=d.current;if(!t)return;let{w:n,h:r}=y(),i=b(t,n,r);if(!i||(i.clearRect(0,0,n,r),e===null))return;let{top:a,right:o,bottom:s,left:c}=DW,l=n-c-o,u=r-a-s,{muted:f}=v(),p=C();if(!p)return;let{lo:m,hi:h,width:g,counts:_}=p,x=e=>c+(e-m)/(h-m)*l,S=x(m+e*g),w=x(m+(e+1)*g);i.fillStyle=`rgba(255,255,255,0.12)`,i.fillRect(S,a,w-S,u);let T=(S+w)/2,E=_[e],D=(E/p.total*100).toFixed(1),O=`${ez(m+e*g)} – ${ez(m+(e+1)*g)}`,k=`n = ${E} (${D}%)`;i.font=`11px ${Q.mono}`;let A=i.measureText(k).width,j=i.measureText(O).width,M=Math.max(A,j),N=Math.min(T+8,c+l-M-8);i.fillStyle=f,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(O,N,a+8),i.fillText(k,N,a+22)}function k(){tV(m.current),m.current=eV(()=>O(p.current))}return W(()=>{E.current.now()}),W(()=>()=>E.current?.cancel(),[]),W(()=>{h.current=null,D()},[s]),G(()=>{let e=f.current;if(!e)return;let t=new oV(()=>{h.current=null,D(),k()});return t.observe(e),()=>t.disconnect()}),G(()=>{let e=d.current;if(!e)return;function t(t){let n=e.getBoundingClientRect(),{left:r}=DW,i=n.width-DW.left-DW.right,a=C();if(!a||i<=0){p.current=null,k();return}let o=t.clientX-n.left-r,s=Math.floor(o/i*a.nBins);p.current=s>=0&&s<a.nBins?s:null,k()}function n(){p.current=null,k()}function r(e){e.preventDefault(),g.current?.({clientX:e.clientX,clientY:e.clientY})}return e.addEventListener(`mousemove`,t),e.addEventListener(`mouseleave`,n),e.addEventListener(`contextmenu`,r),()=>{e.removeEventListener(`mousemove`,t),e.removeEventListener(`mouseleave`,n),e.removeEventListener(`contextmenu`,r)}},[]),nt(`div`,{ref:f,style:{position:`relative`,width:`100%`,height:`100%`},children:[q(`canvas`,{ref:u,className:`chart-canvas`,role:`img`,"aria-label":`Histogram of ${t}`}),q(`canvas`,{ref:d,className:`chart-canvas chart-overlay`})]})}var PW=`
483
+ uniform vec2 u_resolution;
484
+ uniform vec4 u_plot; // left, top, width, height (CSS px)
485
+ uniform vec4 u_view; // xmin, xmax, ymin, ymax (relative to the layer origin)
486
+ vec2 project(float x, float y) {
487
+ return vec2(u_plot.x + (x - u_view.x) / (u_view.y - u_view.x) * u_plot.z,
488
+ u_plot.y + (u_view.w - y) / (u_view.w - u_view.z) * u_plot.w);
489
+ }
490
+ vec4 toClip(vec2 p) { vec2 c = p / u_resolution * 2.0 - 1.0; return vec4(c.x, -c.y, 0.0, 1.0); }
491
+ `,FW=`
492
+ uniform vec4 u_clip; // left, top, right, bottom (CSS px)
493
+ uniform float u_dpr;
494
+ uniform float u_height; // canvas height (device px)
495
+ bool outside() {
496
+ vec2 f = vec2(gl_FragCoord.x, u_height - gl_FragCoord.y) / u_dpr;
497
+ return f.x < u_clip.x || f.x > u_clip.z || f.y < u_clip.y || f.y > u_clip.w;
498
+ }
499
+ `,IW=`#version 300 es
500
+ in vec2 a_corner; // (0|1 along x, 0 = lo | 1 = hi)
501
+ in float a_xa; in float a_xb;
502
+ in float a_loa; in float a_lob;
503
+ in float a_hia; in float a_hib;
504
+ in float a_bstart;
505
+ ${PW}
506
+ void main() {
507
+ if (a_bstart > 0.5) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }
508
+ float x = a_corner.x < 0.5 ? a_xa : a_xb;
509
+ float lo = a_corner.x < 0.5 ? a_loa : a_lob;
510
+ float hi = a_corner.x < 0.5 ? a_hia : a_hib;
511
+ gl_Position = toClip(project(x, a_corner.y < 0.5 ? lo : hi));
512
+ }`,LW=`#version 300 es
513
+ in vec2 a_corner; // (0|1, 0|1)
514
+ in float a_x0; in float a_x1; in float a_y0; in float a_y1; in float a_k;
515
+ ${PW}
516
+ flat out float v_k;
517
+ void main() {
518
+ vec2 p0 = project(a_x0, a_y0), p1 = project(a_x1, a_y1);
519
+ // At least a device pixel wide/tall, so thin bars never vanish.
520
+ vec2 lo = min(p0, p1), hi = max(p0, p1);
521
+ vec2 c = (lo + hi) * 0.5;
522
+ vec2 half_ = max((hi - lo) * 0.5, vec2(0.5));
523
+ v_k = a_k;
524
+ gl_Position = toClip(c + (a_corner * 2.0 - 1.0) * half_);
525
+ }`,RW=`#version 300 es
526
+ precision highp float;
527
+ uniform vec4 u_color;
528
+ ${FW}
529
+ out vec4 outColor;
530
+ void main() {
531
+ if (outside()) discard;
532
+ outColor = vec4(u_color.rgb * u_color.a, u_color.a);
533
+ }`,zW=`#version 300 es
534
+ precision highp float;
535
+ flat in float v_k;
536
+ uniform sampler2D u_palette;
537
+ ${FW}
538
+ out vec4 outColor;
539
+ void main() {
540
+ if (outside()) discard;
541
+ vec4 c = texture(u_palette, vec2((v_k + 0.5) / 256.0, 0.5));
542
+ outColor = vec4(c.rgb * c.a, c.a);
543
+ }`,BW=`#version 300 es
544
+ in vec2 a_corner;
545
+ in float a_ax; in float a_ay; in float a_bx; in float a_by;
546
+ in float a_bstart;
547
+ ${PW}
548
+ uniform float u_ext;
549
+ flat out vec2 v_a;
550
+ flat out vec2 v_b;
551
+ out vec2 v_pos;
552
+ void main() {
553
+ if (a_bstart > 0.5) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); v_a = vec2(0.0); v_b = vec2(0.0); v_pos = vec2(0.0); return; }
554
+ vec2 a = project(a_ax, a_ay), b = project(a_bx, a_by);
555
+ vec2 ab = b - a;
556
+ float len = length(ab);
557
+ vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
558
+ vec2 n = vec2(-dir.y, dir.x);
559
+ vec2 base = mix(a, b, step(0.0, a_corner.x));
560
+ vec2 pos = base + dir * (a_corner.x * u_ext) + n * (a_corner.y * u_ext);
561
+ v_a = a; v_b = b; v_pos = pos;
562
+ gl_Position = toClip(pos);
563
+ }`,VW=`#version 300 es
564
+ precision highp float;
565
+ flat in vec2 v_a;
566
+ flat in vec2 v_b;
567
+ in vec2 v_pos;
568
+ uniform vec4 u_color;
569
+ uniform float u_half;
570
+ ${FW}
571
+ out vec4 outColor;
572
+ void main() {
573
+ if (outside()) discard;
574
+ vec2 ab = v_b - v_a;
575
+ float t = clamp(dot(v_pos - v_a, ab) / max(dot(ab, ab), 1e-12), 0.0, 1.0);
576
+ float d = distance(v_pos, v_a + ab * t);
577
+ float aa = max(fwidth(d), 1e-4);
578
+ float cov = clamp((u_half - d) / aa + 0.5, 0.0, 1.0);
579
+ if (cov <= 0.0) discard;
580
+ float a = u_color.a * cov;
581
+ outColor = vec4(u_color.rgb * a, a);
582
+ }`,HW=`#version 300 es
583
+ in vec2 a_corner; // (0|1, 0|1)
584
+ uniform vec4 u_extent; // x0, x1, y0, y1 (relative to the layer origin)
585
+ ${PW}
586
+ out vec2 v_uv;
587
+ void main() {
588
+ v_uv = a_corner;
589
+ gl_Position = toClip(project(mix(u_extent.x, u_extent.y, a_corner.x), mix(u_extent.z, u_extent.w, a_corner.y)));
590
+ }`,UW=`#version 300 es
591
+ precision highp float;
592
+ in vec2 v_uv;
593
+ uniform highp sampler2D u_values;
594
+ uniform sampler2D u_palette;
595
+ uniform vec2 u_range; // vmin, vmax
596
+ ${FW}
597
+ out vec4 outColor;
598
+ void main() {
599
+ if (outside()) discard;
600
+ float v = texture(u_values, v_uv).r;
601
+ if (v < -1.0e37) discard; // an empty cell
602
+ 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;
603
+ vec4 c = texture(u_palette, vec2((floor(t * 255.0) + 0.5) / 256.0, 0.5));
604
+ outColor = vec4(c.rgb * c.a, c.a);
605
+ }`,WW=-3e38;function GW(e){for(let t=0;t<e.length;t++)if(e[t]-e[t]===0)return e[t];return 0}function KW(e){let t=e.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0});if(!t)return null;let n=(e,n,i,a)=>MB(t,`glPlot|${e}|${n}`,()=>r(e,n,i,a)),r=(e,n,r,i)=>{let a=mB(t,t.VERTEX_SHADER,e),o=mB(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(IW,RW,[`a_xa`,`a_xb`,`a_loa`,`a_lob`,`a_hia`,`a_hib`,`a_bstart`],[`u_color`]),a=n(LW,zW,[`a_x0`,`a_x1`,`a_y0`,`a_y1`,`a_k`],[`u_palette`]),o=n(BW,VW,[`a_ax`,`a_ay`,`a_bx`,`a_by`,`a_bstart`],[`u_color`,`u_half`,`u_ext`]),s=n(HW,UW,[],[`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=GW(t),o.oy=GW(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=GW(n),c.oy=GW(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=GW(t),o.oy=GW(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:WW}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 qW(e){let t=K({plot:null,failed:!1,size:``});return W(()=>()=>{t.current.plot?.dispose(),t.current.plot=null},[]),qe((n,r)=>{let i=t.current,a=e.current;if(!i.plot&&!i.failed&&a&&(i.plot=NB(a,KW),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 JW(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 YW=16;function XW(e,t,n,r){let i=JW(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(YW),m=new Int32Array(YW);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(YW-1,Math.floor(a/(2*Math.PI)*YW));p[o]+=t[e],m[o]++}return{n:a,rMin:c,rMax:l,x:d,y:f,means:Array.from({length:YW},(e,t)=>m[t]>0?p[t]/m[t]:0)}}function ZW({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=Xe(()=>XW(e,t,o,s),[e,t,o,s]),_=K(g);G(()=>{_.current=g},[g]);let v=K(null),y=qW(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=KR(w,4),k=YR(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($R(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,oW(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/YW;r.fillStyle=l,r.globalAlpha=.75;for(let i=0;i<YW;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<YW;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??=sV(()=>T.current(),()=>f.current?.ownerDocument);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 oV(()=>{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)},[]),nt(`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 QW(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 $W(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 eG(e,t){let n=new Float64Array(t.length);for(let r=0;r<t.length;r++)n[r]=e[t[r]];return n}function tG(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 nG(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 rG=new Float64Array,iG=new Float64Array;function aG(e,t,n){let r=t>>1;rG.length<r&&(rG=new Float64Array(r),iG=new Float64Array(r));let i=rG.subarray(0,r),a=iG.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}nG(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 oG=new Float64Array,sG=0;function cG(e){if(sG===e)return oG.subarray(0,e);oG.length<e&&(oG=new Float64Array(Math.max(e,oG.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++){oG[t]=.5*(1-i);let e=i*n-a*r;a=a*n+i*r,i=e}return sG=e,oG.subarray(0,e)}var lG={top:14,right:24,bottom:40,left:64},uG=5;function dG(e){let t=1;for(;t<e;)t<<=1;return t}function fG(e,t,n,r){let i=e.length,a=Math.max(2,dG(i)),o=aG(e,a,n===`hann`?cG(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 pG({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=_V(),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 _=Xe(()=>e.length>=4?fG(e,t,a,i):null,[e,t,a,i]),v=Xe(()=>_&&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}=lG,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=KR(I-F,5),V=YR(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:KR(P-N,qR(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})():YR(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-uG,z(e)),r.lineTo(s,z(e)),r.stroke(),r.fillText($R(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+uG),r.stroke(),r.fillText($R(e,T?e:ee),R(e),i+l+uG+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?QW(k,O,Math.log10(N*M),Math.log10(P*M),re):QW(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??=sV(()=>w.current(),()=>p.current?.ownerDocument);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 oV(()=>{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 mG(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 hG(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,mG(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 gG={top:14,right:24,bottom:48,left:64},_G=5;function vG(e,t){let n=e.length;if(n===0)return null;let[r,i,a,o,s]=hG(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 yG({groups:e,color:t=`#fb923c`,whiskers:n=`1.5iqr`,height:r=400,backgroundToken:i=``,onPlotContextMenu:a}){let o=_V(),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=Xe(()=>e.filter(e=>e.values.length>0).map(e=>({label:e.label,box:vG(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}=gG,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=KR(C-S,5),D=YR(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-_G,T(e)),r.lineTo(l,T(e)),r.stroke(),r.fillText($R(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+_G+2,k-4,c-_G-4),r.clip(),r.fillText(n,t,i+f+_G+2),r.restore()}}let v=K(_);v.current=_;let y=K(null);y.current??=sV(()=>v.current(),()=>c.current?.ownerDocument);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 oV(()=>{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 bG(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 xG=e=>e.includes(`.`)&&!e.includes(`e`)?e.replace(/\.?0+$/,``):e;function SG(e){return e>=1e3?`${xG((e/1e3).toPrecision(3))}k`:xG(e.toPrecision(3))}function CG(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 wG={top:14,right:24,bottom:40,left:68},TG=[[8,0,16],[48,0,96],[104,0,144],[160,0,128],[200,32,64],[230,100,16],[250,200,32],[255,255,220]],EG=-80;function DG(e){let t=TG.length-1,n=Math.min(t-1,Math.floor(e*t)),r=e*t-n,[i,a,o]=TG[n],[s,c,l]=TG[n+1];return[i+(s-i)*r,a+(c-a)*r,o+(l-o)*r]}var OG=(()=>{let e=new Uint8Array(256*4);for(let t=0;t<256;t++){let[n,r,i]=DG(t/255);e.set([n,r,i,255],t*4)}return e})();function kG(e){let t=1;for(;t<e;)t<<=1;return t}var AG=(e,t)=>Math.log(1+e/t*9)/Math.log(10),jG=(e,t)=>t*(10**e-1)/9;function MG({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=_V(),d=K(null),f=K(null),p=K(null),m=K(null),h=K(null),g=K(l);G(()=>{g.current=l},[l]);let _=kG(Math.max(4,Math.min(n,4096))),v=Math.max(1,Math.round(_*(1-Math.max(0,Math.min(.95,r))))),y=Xe(()=>{if(!o)return null;let e=_>>1,n=t/2;return Int32Array.from({length:e},(t,r)=>Math.min(e-1,Math.floor(jG((r+.5)/e,n)/n*e)))},[o,_,t]),b=K(null),x=Xe(()=>b.current=CG(e,_,v,i===`hann`,a===`db`,y,b.current),[e,_,v,i,a,y]),S=Xe(()=>({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+EG,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=NB(f.current,KW),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=aU(wG,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=bG(y,N).grid;j&&j.setGrid(`cells`,e.values,e.w,Math.min(e.h,j.maxTextureSize),[0,e.w,0,e.h],OG,P,F),E.current.grid=y,E.current.shown=e,rV(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]=DG(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?AG(e,R):e/R));L.strokeStyle=v,L.lineWidth=.5,L.globalAlpha=.4;let B=YR(0,R,KR(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(SG(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=KR(V,6),te=YR(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($R(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??=sV(()=>M.current(),()=>m.current?.ownerDocument),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 oV(()=>{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)},[]),nt(`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 NG=300,PG=256,FG=-60,IG=[];function LG({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=Xe(()=>CG(e,c,l,i===`hann`,u,null),[e,c,l,i,u]);return q(EW,{points:IG,surface:Xe(()=>RG(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 RG(e,t,n,r,i){let{frames:a,bins:o,values:s}=e;if(a<2||o<2)return;let c=Math.min(a,NG),l=Math.min(o,PG),u=i?20*Math.log10(Math.max(e.max,1e-12))+FG:-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 zG(e,t,n){return Array.from({length:n},(r,i)=>e+(i+1)/(n+1)*(t-e))}function BG(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 VG(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 HG(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 UG={top:14,right:32,bottom:80,left:80};function WG(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 GG=[[33,102,172],[103,169,207],[209,229,240],[247,247,247],[253,219,199],[239,138,98],[178,24,43]],KG=[[13,8,135],[84,2,163],[139,10,165],[185,50,137],[219,92,104],[244,136,73],[254,188,43],[240,249,33]],qG=[[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 JG(e,t){let n=e.length-1,r=Math.min(n-1,Math.floor(t*n));return WG(e[r],e[r+1],t*n-r)}function YG(e,t){return JG(t===`plasma`?KG:t===`viridis`?qG:GG,e)}function XG(e){let t=new Uint8Array(256*4);for(let n=0;n<256;n++){let[r,i,a]=YG(n/255,e);t.set([r,i,a,255],n*4)}return t}function ZG(e){return Math.abs(e)>=1e4||Math.abs(e)<.01&&e!==0?e.toExponential(1):String(parseFloat(e.toPrecision(3)))}function QG(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 $G(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=VG(a),i=n[e.w]-n[0];u=Float64Array.from(n,e=>t+(e-n[0])/i*r)}if(l){let t=VG(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 eK(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 tK(e,t,n,r,i,a){let o=Math.max(1,i),s=Math.max(1,a),c=Int32Array.from({length:o},(e,r)=>eK(t.xB,n+r+.5)),l=new Float32Array(o*s);for(let n=0;n<s;n++){let i=eK(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 nK({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=Xe(()=>r??QG(e??[],t??[],n??[]),[r,e,t,n]),C=Xe(()=>{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=NB(m.current,KW),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=aU(UG,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}`},rV(_.current));let{xCentres:F,yCentres:I,contours:L}=w.current,R=x?x.maxTextureSize:Math.max(1,Math.round(S*N)),z=bG(m,R).grid,B=$G(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?tK(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],XG(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]=YG(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]=YG(Math.max(0,Math.min(1,(n-g)/(v-g))),b);U.fillStyle=.299*r+.587*i+.114*a>128?`#000`:`#fff`,U.fillText(ZG(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?zG(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=>BG(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]=YG(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(ZG(v),ce+12+2,le),r.fillText(ZG(g),ce+12+2,le+ue),r.fillText(ZG((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}=aU(UG,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]}: ${ZG(_)}`;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??=sV(()=>F.current(),()=>_.current?.ownerDocument);let L=()=>{b.current||=eV(()=>{b.current=0,P()})};return W(()=>{I.current.now()},[S,C,i,a,c,l,u]),W(()=>()=>{I.current?.cancel(),tV(b.current)},[]),W(()=>{v.current=null,I.current.schedule()},[d]),G(()=>{let e=_.current;if(!e)return;let t=new oV(()=>{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=eK(i.xB,t.clientX-n.left),o=eK(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)}},[]),nt(`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 rK=2e3,iK=1024;function aK(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<=rK){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(iK),l=(i-r)/iK||1;for(let t=0;t<a;t++)c[Math.max(0,Math.min(iK-1,Math.floor((e[t]-r)/l)))]++;for(let e=0;e<n.length;e++){let i=0;for(let a=0;a<iK;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 oK={top:14,right:24,bottom:48,left:64},sK=120;function cK(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 lK(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]=hG(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:sK},(e,t)=>r+t/(sK-1)*(i-r));return{shapes:n.map((e,n)=>{let{q1:o,median:c,q3:l}=a[n],u=aK(e.values,t>0?t:cK(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 uK({groups:e,color:t=`#818cf8`,showBox:n=!0,bandwidth:r=0,orientation:i=`vertical`,backgroundToken:a=``,onPlotContextMenu:o}){let s=_V(),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=Xe(()=>lK(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}=oK,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=KR(E-T,5),A=YR(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($R(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($R(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<sK;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=sK-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??=sV(()=>y.current(),()=>l.current?.ownerDocument);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 oV(()=>{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 dK={top:48,right:16,bottom:72,left:80},fK=[8,24,64],pK=[56,189,248];function mK(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 hK(e){return`${(e*100).toFixed(1)}%`}function gK(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 _K({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=Xe(()=>gK(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}=dK,{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]=mK(fK,pK,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?hK(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: ${hK(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}=dK,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?hK(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??=sV(()=>x.current(),()=>s.current?.ownerDocument);let C=()=>S.current.schedule(),w=()=>{tV(u.current),u.current=eV(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 oV(()=>{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}=dK,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)}},[]),nt(`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 vK={top:24,right:24,bottom:48,left:64};function yK(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 bK(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 xK(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 SK(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 CK({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=Xe(()=>yK(e,t),[e,t]),f=Xe(()=>n===`pr`?{roc:null,pr:xK(d)}:{roc:bK(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}=vK,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=YR(0,1,KR(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(),SK(r,t,n,a),r.strokeStyle=x,r.lineWidth=1,r.stroke(),r.beginPath(),SK(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=QW(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??=sV(()=>v.current(),()=>s.current?.ownerDocument);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 oV(()=>{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 wK={top:20,right:64,bottom:48,left:64};function TK({xValues:e,series:t,xLabel:n=`Epoch`,backgroundToken:r=``,onPlotContextMenu:i}){let a=_V(),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 _=Xe(()=>{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:tG(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}=wK,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=KR(C.hi-C.lo,5),N=YR(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=KR(D-E,6),F=YR(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?QW(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($R(e,M),l-6,A(e));if(T){let e=KR(w.hi-w.lo,5),t=YR(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($R(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($R(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}=wK,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}: ${ez(e.values[D])}`,T+6,O),O+=14);w(0)}let x=K(y);x.current=y;let S=K(null);S.current??=sV(()=>x.current(),()=>c.current?.ownerDocument);let C=()=>S.current.schedule(),w=()=>{tV(d.current),d.current=eV(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 oV(()=>{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)}},[]),nt(`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 EK={top:40,right:24,bottom:40,left:72},DK=`#ef4444`,OK=`#f97316`,kK=`#22d3ee`;function AK(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 jK({points:e,sigmaLevel:t=3,color:n=`#22d3ee`,backgroundToken:r=``,onPlotContextMenu:i}){let a=_V(),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 _=Xe(()=>AK(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}=EK,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=KR(D-E,5),j=YR(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} ${ez(e)}`,l+u-2,o-5))};M(w,OK,`UCL`,[5,3]),M(C,kK,`CL`,[]),M(T,OK,`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=$W(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?DK: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($R(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}=EK,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}: `}${ez(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?DK:_,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??=sV(()=>S.current(),()=>c.current?.ownerDocument);let w=()=>C.current.schedule(),T=()=>{tV(d.current),d.current=eV(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 oV(()=>{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)}},[]),nt(`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 MK={top:32,right:24,bottom:24,left:24},NK=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],PK=16;function FK(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 IK(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:PK},(e,t)=>FK((t+.5)/PK));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(PK-1,Math.floor(e*PK))):-1}for(let t=0;t<e.length;t++)s[t]<0&&(s[t]=0)}else if(!n&&e.colorIndex){c=NK;for(let t=0;t<e.length;t++)s[t]=Math.max(0,e.colorIndex[t])%NK.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 LK({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=Xe(()=>IK(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 _=qW(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}=MK,{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,oW(e.color,j),1,e.starts)),v.current=w,rV(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($R(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=NK[r%NK.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}=MK,{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??=sV(()=>w.current(),()=>u.current?.ownerDocument);let E=()=>T.current.schedule(),D=()=>{tV(p.current),p.current=eV(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 oV(()=>{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-MK.left-MK.right,a=r.length,o=t.clientX-n.left-MK.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)}},[]),nt(`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 RK(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 zK(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 BK={top:16,right:16,bottom:16,left:16},VK=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function HK(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 UK(e){let[t,n,r]=HK(e);return`rgb(${t},${n},${r})`}var WK=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...HK(t/255),255],t*4);return e})(),GK=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=oW(VK[t%VK.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e});function KK(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 qK({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=Xe(()=>KK(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}=BK,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=NB(s.current,rU),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,rV(l.current));let f=`${c.mode}|${u}|${d}`;return n.style!==f&&(r.setStyle(c.mode===`single`?{kind:`single`,rgba:oW(u,1)}:{kind:c.mode,palette:c.mode===`colormap`?WK:GK()},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`,BK.left+8,BK.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:BK.left,top:BK.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`?UK(i):d.mode===`dataset`?VK[i%VK.length]:c,r.globalAlpha=.8,r.fill()}r.globalAlpha=1}if(l){let e=Math.min(120,Math.floor((n-BK.top-BK.bottom)*.4)),i=t-BK.right-12,o=BK.top+8;for(let t=0;t<e;t++)r.fillStyle=UK(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=BK.left,i=n-BK.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`,E.forEach((n,o)=>{e>t-BK.right-60&&(e=BK.left,i-=14),r.fillStyle=VK[o%VK.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<BK.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??=sV(()=>w.current(),()=>l.current?.ownerDocument);let E=()=>T.current.schedule(),D=()=>{tV(f.current),f.current=eV(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 oV(()=>{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])-BK.left,g=e=>u(i.y[e])-BK.top,_=a+8,y=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==y)&&(t={model:o,key:y,g:RK(i.length,f,p,_,m,g)}),d.current=zK(t.g,n.clientX-r.left-BK.left,n.clientY-r.top-BK.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)}},[]),nt(`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 JK={top:8,right:8,bottom:8,left:8},YK=20,XK=[`#f97316`,`#fb923c`,`#fdba74`,`#fbbf24`,`#fcd34d`,`#4ade80`,`#34d399`,`#38bdf8`,`#818cf8`,`#a78bfa`];function ZK(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 QK(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 $K(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 eq(e){return XK[e%XK.length]}function tq({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=Xe(()=>{let t=ZK(e);return{roots:t,flat:QK(t),numRows:$K(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=JK.left+e.x0*t,o=(e.x1-e.x0)*t;return{x:a,y:i===`topdown`?JK.top+e.depth*YK:JK.top+n-(e.depth+1)*YK,w:o,h:YK-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`,JK.left+8,JK.top+8);return}let{flat:l,numRows:u}=p.current,f=t-JK.left-JK.right,v=u*YK;for(let e of l){let t=_(e,f,v,u,c);if(!(t.w<1)&&(r.fillStyle=eq(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,YK-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+YK/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-JK.left-JK.right,l*YK,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+YK+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??=sV(()=>b.current(),()=>o.current?.ownerDocument);let S=()=>x.current.schedule(),C=()=>{tV(l.current),l.current=eV(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 oV(()=>{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-JK.left-JK.right,f=o*YK,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)}},[]),nt(`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 nq={top:24,right:24,bottom:52,left:56},rq=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`],iq=.8;function aq(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 oq(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 sq({groups:e,columns:t,seriesNames:n,colors:r,mode:i=`grouped`,horizontal:a=!1,valueRange:o,backgroundToken:s=``,onPlotContextMenu:c}){let l=_V(),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=Xe(()=>{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=aq(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]??rq[n%rq.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=aU(nq,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=NB(d.current,KW),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`,nq.left+8,nq.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($R(t,(g-h)/5),n,_+k+4)):(r.textAlign=`right`,r.textBaseline=`middle`,r.fillText($R(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},rV(p.current));let I=Math.min(2,window.devicePixelRatio||1),L=Math.max(1,Math.round(M*I)),R=j.map(e=>{let t=lB(e);return[t[0],t[1],t[2],iq]}),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=oq(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=oq(s,d,L);r.globalAlpha=iq;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]+` `:``}${ez(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??=sV(()=>j.current(),()=>p.current?.ownerDocument);let N=()=>{g.current||=eV(()=>{g.current=0,A()})};return W(()=>{M.current.now()},[y,n,r,i,a,o]),W(()=>()=>{M.current?.cancel(),tV(g.current)},[]),W(()=>{m.current=null,M.current.schedule()},[s]),G(()=>{let e=p.current;if(!e)return;let t=new oV(()=>{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)}},[]),nt(`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 cq=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function lq(e,t){if(!t)return cq[e%cq.length];if(e===0)return t;let n=cq.filter(e=>e.toLowerCase()!==t.toLowerCase());return n[(e-1)%n.length]}var uq={top:36,right:36,bottom:36,left:36};function dq({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`,uq.left+8,uq.top+8);return}let h=c.length,g=t/2,_=n/2,v=Math.min(t-uq.left-uq.right,n-uq.top-uq.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=lq(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=uq.left,i=n-uq.bottom-10;r.font=`9px ${Q.mono}`,r.textBaseline=`top`;for(let n=0;n<l.length&&(r.fillStyle=lq(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-uq.right-30));n++);}}let g=K(h);g.current=h;let _=K(null);_.current??=sV(()=>g.current(),()=>c.current?.ownerDocument);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 oV(()=>{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)}},[]),nt(`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 fq={top:16,right:16,bottom:40,left:52},pq=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function mq(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=>tG(e)),xLo:c,xHi:l,yLo:u,yHi:d}}function hq({series:e,stacked:t=!1,yRange:n,backgroundToken:r=``,onPlotContextMenu:i}){let a=_V(),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=Xe(()=>{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=mq(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=QW(a,o,n,r,i);return{x:eG(a,c),hi:eG(o,c),lo:s?eG(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`,fq.left+8,fq.top+8);return}let h=aU(fq,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($R(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($R(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},rV(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)=>lB(pq[t%pq.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=pq[e%pq.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=pq[n%pq.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=NB(s.current,KW),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}=aU(fq,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=${ez(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??=sV(()=>O.current(),()=>l.current?.ownerDocument);let A=()=>{f.current||=eV(()=>{f.current=0,D()})};return W(()=>{k.current.now()},[e,h,n]),W(()=>()=>{k.current?.cancel(),tV(f.current)},[]),W(()=>{u.current=null,k.current.schedule()},[r]),G(()=>{let e=l.current;if(!e)return;let t=new oV(()=>{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)}},[]),nt(`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 gq={top:16,right:16,bottom:40,left:52},_q=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`];function vq({series:e,complement:t=!1,logX:n=!1,backgroundToken:r=``,onPlotContextMenu:i}){let a=_V(),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=Xe(()=>{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`,gq.left+8,gq.top+8);return}let{top:f,right:m,bottom:y,left:b}=gq,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($R(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=_q[e%_q.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=_q[n%_q.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}=gq,l=n-a-gq.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=ez(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??=sV(()=>x.current(),()=>c.current?.ownerDocument);let C=()=>S.current.schedule(),w=()=>{tV(d.current),d.current=eV(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 oV(()=>{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)}},[]),nt(`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 yq={top:16,right:40,bottom:40,left:52},bq=[`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function xq(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 Sq(e){let[t,n,r]=xq(e);return`rgb(${t},${n},${r})`}var Cq=(()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++)e.set([...xq(t/255),255],t*4);return e})(),wq=()=>{let e=new Uint8Array(1024);for(let t=0;t<256;t++){let[n,r,i]=oW(bq[t%bq.length],1);e.set([n*255,r*255,i*255,255],t*4)}return e};function Tq(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 Eq({points:e,color:t=`#64748b`,colorByNumeric:n=!1,maxRadius:r=24,backgroundToken:i=``,onPlotContextMenu:a}){let o=_V(),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=Xe(()=>Tq(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}=yq,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=NB(c.current,rU),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,rV(u.current));let l=`${o.mode}|${s}`;return n.style!==l&&(r.setStyle(o.mode===`single`?{kind:`single`,rgba:oW(s,1)}:{kind:o.mode,palette:o.mode===`colormap`?Cq:wq()},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`,yq.left+8,yq.top+8);return}let{xLo:p,xHi:m,yLo:h,yHi:C}=d.ext,{top:w,left:T}=yq,{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($R(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($R(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`?Sq(n):d.mode===`dataset`?bq[n%bq.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-yq.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=bq[n%bq.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(`(${ez(a.x[i])}, ${ez(a.y[i])})`),m.push(`size=${ez(a.size[i])}`);let _=a.colorIndex?.[i];_!==void 0&&_>=0&&a.colorLabels?m.push(a.colorLabels[_]):a.colorValue&&m.push(ez(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<yq.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??=sV(()=>T.current(),()=>u.current?.ownerDocument);let D=()=>E.current.schedule(),O=()=>{tV(p.current),p.current=eV(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 oV(()=>{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])-yq.left,h=e=>p(i.y[e])-yq.top,_=a+6,v=`${s}|${c}|${_}`;(!t||t.model!==o||t.key!==v)&&(t={model:o,key:v,g:RK(i.length,l,u,_,m,h)}),f.current=zK(t.g,n.clientX-r.left-yq.left,n.clientY-r.top-yq.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)}},[]),nt(`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 Dq={top:8,right:8,bottom:8,left:8},Oq=[`#f97316`,`#38bdf8`,`#4ade80`,`#a78bfa`,`#fbbf24`,`#fb7185`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function kq(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 Aq(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=Aq(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 jq({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=Xe(()=>kq(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`,Dq.left+8,Dq.top+8);return}let u=p.current,f=t-Dq.left-Dq.right,_=n-Dq.top-Dq.bottom,v=Aq(u,Dq.left,Dq.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=Oq[l%Oq.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??=sV(()=>y.current(),()=>a.current?.ownerDocument);let x=()=>b.current.schedule(),S=()=>{tV(l.current),l.current=eV(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 oV(()=>{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)}},[]),nt(`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 Mq={top:8,right:8,bottom:8,left:8},Nq=14,Pq=8,Fq=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function Iq(e,t,n,r){if(e.length===0||t.length===0)return{nodes:[],links:[]};let i=n-Mq.left-Mq.right,a=r-Mq.top-Mq.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=>Mq.left+e/Math.max(1,c)*(i-Nq),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)*Pq,i=0;for(let e of n)i+=Math.max(8,(d.get(e)??0)/f*r*.8);let o=Mq.top+(a-i-(n.length-1)*Pq)/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:Fq[e.indexOf(a)%Fq.length]}),o+=s+Pq}}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+Nq,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 Lq({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`,Mq.left+8,Mq.top+8);return}let d=Iq(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,Nq,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+Nq+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??=sV(()=>v.current(),()=>o.current?.ownerDocument);let b=()=>y.current.schedule(),x=()=>{tV(u.current),u.current=eV(_)};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 oV(()=>{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)}},[]),nt(`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 Rq={top:24,right:24,bottom:52,left:52};function zq({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`,Rq.left+8,Rq.top+8);return}let{top:h,right:g,bottom:_,left:v}=Rq,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}=Rq,f=t-u-Rq.right,h=n-l-Rq.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??=sV(()=>_.current(),()=>o.current?.ownerDocument);let y=()=>v.current.schedule(),b=()=>{tV(l.current),l.current=eV(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 oV(()=>{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-Rq.left-Rq.right,s=-1,l=20;for(let e=0;e<r.length;e++){let t=Rq.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)}},[]),nt(`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 Bq={top:24,right:24,bottom:48,left:52};function Vq({points:e,color:t=`#a78bfa`,backgroundToken:n=``,onPlotContextMenu:r}){let i=_V(),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`,Bq.left+8,Bq.top+8);return}let{xLo:_,xHi:v,yLo:y,yHi:b}=g(),{top:x,right:S,bottom:C,left:w}=Bq,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($R(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($R(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}=Bq,y=t-v-Bq.right,b=n-_-Bq.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=`(${ez(s.theoretical)}, ${ez(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??=sV(()=>y.current(),()=>s.current?.ownerDocument);let x=()=>b.current.schedule(),S=()=>{tV(u.current),u.current=eV(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 oV(()=>{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}=Bq,p=i-d-Bq.right,h=n.height-u-Bq.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)}},[]),nt(`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 Hq={top:8,right:16,bottom:40,left:120},Uq=22,Wq=3,Gq=[`#38bdf8`,`#4ade80`,`#fb7185`,`#fbbf24`,`#a78bfa`,`#f97316`,`#34d399`,`#e879f9`,`#facc15`,`#60a5fa`];function Kq({tasks:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=_V(),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`,Hq.left+8,Hq.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}=Hq,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*(Uq+Wq)+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($R(t,(g-h)/T),n,r+4)}for(let e=0;e<u.length;e++){let t=u[e],n=v+e*(Uq+Wq),r=Gq[(w.get(t.group??t.label)??0)%Gq.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,Uq-Wq),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+(Uq-Wq)/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}: ${ez(s.start)} → ${ez(s.end)} (${ez(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-Hq.left-Hq.right,y=e=>Hq.left+(e-h)/(g-h)*v,b=Hq.top+i*(Uq+Wq),x=(y(s.start)+y(s.end))/2,S=Math.max(4,Math.min(t-f-8,x-f/2)),C=b-22<Hq.top?b+Uq+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??=sV(()=>_.current(),()=>o.current?.ownerDocument);let y=()=>v.current.schedule(),b=()=>{tV(l.current),l.current=eV(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 oV(()=>{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-Hq.top)/(Uq+Wq));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)}},[]),nt(`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 qq=e=>[...e].filter(e=>Number.isFinite(e.at)).sort((e,t)=>e.at-t.at),Jq=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]},Yq=e=>`#${e.map(e=>Math.round(e).toString(16).padStart(2,`0`)).join(``)}`;function Xq(e,t,n,r){let i=t?qq(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=Jq(o.color),u=Jq(s.color);return Yq([l[0]+(u[0]-l[0])*c,l[1]+(u[1]-l[1])*c,l[2]+(u[2]-l[2])*c])}function Zq(e,t,n,r,i,a=96){let o=i-r||1,s=t?qq(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:Xq(`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:Xq(`gradient`,s,n,r+(t+.5)/a*o)}))}function Qq(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 $q(e,t,n){let r=t?qq(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 eJ=.75*Math.PI,tJ=1.5*Math.PI;function nJ({gauges:e,backgroundToken:t=``,onPlotContextMenu:n}){let r=K(null),i=K(null),a=K(null),o=K(n);G(()=>{o.current=n},[n]);let s=K({gauges:e});G(()=>{s.current={gauges:e}},[e]);function c(){if(a.current)return a.current;let e=i.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 a.current=n,n}function l(){let e=r.current,t=i.current;if(!e||!t)return;let n=Math.max(1,t.clientWidth),a=Math.max(1,t.clientHeight),o=Math.min(2,window.devicePixelRatio||1),l=Math.floor(n*o),u=Math.floor(a*o);(e.width!==l||e.height!==u)&&(e.width=l,e.height=u),e.style.width=`${n}px`,e.style.height=`${a}px`;let d=e.getContext(`2d`);if(!d)return;d.setTransform(o,0,0,o,0,0);let f=c(),{gauges:p}=s.current;if(d.fillStyle=f.bg,d.fillRect(0,0,n,a),p.length===0){d.fillStyle=f.muted,d.font=`13px ${Q.sans}`,d.textAlign=`left`,d.textBaseline=`top`,d.fillText(`No data`,16,16);return}let{cols:m,rows:h}=rJ(p.length,n,a,p.some(e=>e.style===`arc`)?1.15:3.2),g=n/m,_=a/h;p.forEach((e,t)=>{let n=t%m*g,r=Math.floor(t/m)*_;e.style===`arc`?fJ(d,e,n,r,g,_,e.color,e.alarm??null,f):pJ(d,e,n,r,g,_,e.color,e.alarm??null,f)})}let u=K(l);u.current=l;let d=K(null);return d.current??=sV(()=>u.current(),()=>i.current?.ownerDocument),W(()=>{d.current.now()}),W(()=>()=>d.current?.cancel(),[]),W(()=>{a.current=null,d.current.schedule()},[t]),G(()=>{let e=i.current;if(!e)return;let t=new oV(()=>{a.current=null,d.current.schedule()});return t.observe(e),()=>t.disconnect()},[]),q(`div`,{ref:i,style:{position:`relative`,width:`100%`,height:`100%`},children:q(`canvas`,{ref:r,className:`chart-canvas`,role:`img`,"aria-label":`Gauges: ${e.map(e=>`${e.name} ${Number.isFinite(e.value)?iJ(e.value,e.max-e.min):`no value`}${e.unit?` ${e.unit}`:``}`).join(`, `)}`,onContextMenu:e=>{e.preventDefault(),o.current?.({clientX:e.clientX,clientY:e.clientY})}})})}function rJ(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 iJ=(e,t)=>$R(e,KR(Math.abs(t),100)),aJ=(e,t)=>Math.max(0,Math.min(1,(t-e.min)/(e.max-e.min||1))),oJ=(e,t)=>!!t&&Number.isFinite(e.value)&&e.value>=t.value,sJ=e=>(e.colorMode===`gradient`||e.colorMode===`zones`)&&!!e.stops?.length,cJ=(e,t)=>oJ(e,t)?t.color:Xq(e.colorMode,e.stops,e.color,e.value);function lJ(e,t,n){for(let r of Zq(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 uJ(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 dJ=Math.SQRT1_2;function fJ(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=iJ(t.min,u),f=iJ(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,dJ*h+g/2),r=h+t/2+dJ*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+dJ*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=>eJ+e*tJ;e.lineCap=`round`,e.lineWidth=_,e.strokeStyle=c.grid,e.beginPath(),e.arc(b,x,h,eJ,eJ+tJ),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(aJ(t,s.value)),eJ+tJ),e.stroke(),e.globalAlpha=1,e.lineCap=`round`);let C=Number.isFinite(t.value)?aJ(t,t.value):0;if(sJ(t)){let n=tJ/(2*Math.PI),r=lJ(e.createConicGradient(eJ,b,x),t,e=>e*n);r.addColorStop(1,Xq(t.colorMode,t.stops,t.color,t.min)),e.strokeStyle=r,e.globalAlpha=.24,e.beginPath(),e.arc(b,x,h,eJ,eJ+tJ),e.stroke(),e.globalAlpha=1,Number.isFinite(t.value)&&!oJ(t,s)&&(e.beginPath(),e.arc(b,x,h,eJ,Math.max(eJ+1e-4,S(C))),e.stroke())}if(Number.isFinite(t.value)&&(!sJ(t)||oJ(t,s))&&(e.strokeStyle=oJ(t,s)?s.color:o,e.beginPath(),e.arc(b,x,h,eJ,Math.max(eJ+1e-4,S(C))),e.stroke()),s&&s.value>=t.min&&s.value<=t.max){let n=S(aJ(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 w=Number.isFinite(t.value)?iJ(t.value,u):`—`,T=2*(h-_)*.82,E=Math.max(11,h*.42);e.font=`650 ${E}px ${Q.sans}`;let D=e.measureText(w).width;D>T&&(E=Math.max(9,E*T/D),e.font=`650 ${E}px ${Q.sans}`),e.textAlign=`center`,e.textBaseline=`alphabetic`,e.fillStyle=oJ(t,s)||sJ(t)?cJ(t,s):c.ink,e.fillText(w,b,x+E*.32),e.fillStyle=c.muted,t.unit&&(e.font=`600 ${Math.max(9,h*.13)}px ${Q.sans}`,e.fillText(uJ(e,t.unit,T),b,x+E*.32+Math.max(11,h*.19)));let O=x+dJ*h+_/2+6,k=dJ*h;e.textBaseline=`top`,e.font=`${v}px ${Q.mono}`,e.fillText(d,b-k,O),e.fillText(f,b+k,O);let A=2*k-g-16,j=Math.max(10,Math.min(26,h*.13));e.font=`600 ${j}px ${Q.sans}`;let M=e.measureText(t.name).width;M>A&&j>9&&(j=Math.max(9,j*A/M),e.font=`600 ${j}px ${Q.sans}`),e.fillText(uJ(e,t.name,A),b,O+(v-j)/2)}function pJ(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+aJ(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(uJ(e,t.name,f),u,h-p/2-m-4),e.textAlign=`right`,e.fillStyle=oJ(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=oJ(t,s)||sJ(t)?cJ(t,s):c.ink,e.font=`650 ${m}px ${Q.sans}`,e.fillText(Number.isFinite(t.value)?iJ(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)?aJ(t,t.value):0,y=e=>u+e*f;sJ(t)&&(e.strokeStyle=lJ(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)&&!oJ(t,s)&&(e.beginPath(),e.moveTo(u,h),e.lineTo(Math.max(u+.5,y(v)),h),e.stroke())),Number.isFinite(t.value)&&(!sJ(t)||oJ(t,s))&&(e.strokeStyle=oJ(t,s)?s.color:o,e.beginPath(),e.moveTo(u,h),e.lineTo(Math.max(u+.5,y(v)),h),e.stroke()),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()),e.fillStyle=c.muted,e.font=`${Math.max(9,m*.34)}px ${Q.mono}`,e.textBaseline=`top`,e.textAlign=`left`,e.fillText(iJ(t.min,t.max-t.min),u,h+p/2+4),e.textAlign=`right`,e.fillText(iJ(t.max,t.max-t.min),d,h+p/2+4)}function mJ(e,t){let n=e.filter(e=>e.x.length>=2&&hJ(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 hJ(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return!0}function gJ(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 _J(e,t){return e.filter(e=>x(t,e))}var vJ=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?s(new Float64Array,new Float64Array,e.viewport.x0,e.viewport.x1,e.maxPoints):s(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}:T(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:_e(r,i.map(e=>this.#e.get(e)),i,t.x0,t.x1,n)}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 yJ(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 bJ(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)=>yJ(i+(t+.5)*(c/n))),m=Array.from({length:r},(e,t)=>yJ(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 xJ(e,t){return t.some(t=>t.name===e)}function SJ(e,t){return xJ(e,t)?`ƒ ${e}`:e}var CJ=8e3,wJ=3e3,TJ=[];function EJ(e){return`live`in e?e.live.source.columns():`source`in e&&e.source instanceof vJ?e.source.columnMap:void 0}var DJ=4e3,OJ=new WeakMap;function kJ(e,t,n){let r=OJ.get(e);r||OJ.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 AJ=new WeakMap;function jJ(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 MJ(e,t){let n=1/0,r=-1/0;for(let{rows:i,offset:a}of e){let e=AJ.get(i);e||(e=new Map,AJ.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 NJ(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 PJ=new Map;function FJ(e){let t=PJ.get(e);return t||(t=Float64Array.from({length:e},(e,t)=>t),PJ.clear(),PJ.set(e,t)),t}function IJ(e){let{worksheet:t,viewXRange:n,selectedIds:r,selectedDatasets:i,mathChannels:a,datasetOffsets:o,datasetColors:s,datasetPalette:c}=e,l=t.panels,u=t.panelChartSettings,d=t.xKey,f={connections:Xe(()=>d===`ElapsedTime`?e.liveConnections:e.liveConnections.map(e=>{let t=NJ(e.dataset.rows,d);return t===e.dataset.rows?e:{...e,dataset:{...e.dataset,rows:t}}}),[e.liveConnections,d])},[p,m]=Ze({}),h=Xe(()=>l.some(e=>e.kind!==`multiband`),[l]),g=Xe(()=>f.connections.some(e=>r.includes(e.id)),[f.connections,r]),_=Xe(()=>{let e=f.connections.filter(e=>r.includes(e.id));return e.length===1&&i.length===0?e[0]:null},[f.connections,r,i]),v=Xe(()=>gJ(i.map(e=>{let t=p[e.id];return t?{...e.data,rows:t}:e.data})),[i,p]),y=Xe(()=>{let e=f.connections.filter(e=>r.includes(e.id)).map(e=>e.dataset);return e.length===0?v:gJ(v?[v,...e]:e)},[v,f.connections,r]),b=Xe(()=>ZT(a,u,d).map(e=>e.id).join(`
606
+ `),[a,u,d]),x=Xe(()=>{let e=new Set(b.split(`
607
+ `));return a.filter(t=>e.has(t.id))},[a,b]),S=Xe(()=>{if(!y)return null;let e=[...i.map(e=>{let t=p[e.id];return t?{...e.data,rows:t}:e.data}),...f.connections.filter(e=>r.includes(e.id)).map(e=>e.dataset)];if(x.length===0)return{dataset:y,partRows:e.map(e=>e.rows),parts:e};let t=e.map(e=>XT(e,x,d)),n=new Set(t.flatMap(e=>e.ok.map(e=>e.id))),a=x.filter(e=>n.has(e.id)),o=t.map(e=>e.rows),s=t.map(e=>e.ok.map(e=>e.name));if(a.length===0)return{dataset:y,partRows:o,parts:e};let c=a.filter(e=>!y.columnNames.includes(e.name));return{dataset:{meta:y.meta,columnNames:[...y.columnNames,...c.map(e=>e.name)],units:[...y.units,...c.map(e=>e.units)],rows:o.length===1?o[0]:[].concat(...o)},partRows:o,parts:e,okByPart:s}},[y,i,p,f.connections,r,x,d]),C=S?.dataset??null,w=Xe(()=>{let e=f.connections.filter(e=>r.includes(e.id));return e.length===0?i:[...i,...e.map(e=>({id:e.id,name:e.name,data:e.dataset,live:e}))]},[i,f.connections,r]),T=w.length>1,E=Xe(()=>w.length===1?EJ(w[0]):void 0,[w]),D=S?.partRows??TJ;W(()=>{let e=i.filter(e=>e.kind!==`memory`);if(e.length===0)return;if(!n||!h){m(e=>Object.keys(e).length?{}:e);return}let t=!1,r=setTimeout(()=>{(async()=>{let r=await Promise.all(e.map(async e=>{let t={xcol:d,x0:n[0],x1:n[1]};try{let n=e.source,r=await lH(`sampleRows`,()=>n.sampleRows(wJ,t));return[e.id,r]}catch{return null}}));if(t)return;let i={};for(let e of r)e&&(i[e[0]]=e[1]);m(i)})()},150);return()=>{t=!0,clearTimeout(r)}},[i,n,d,h]);let O=Xe(()=>C?.columnNames.join(`
608
+ `)??``,[C]),k=a.map(e=>e.name).join(`
609
+ `),A=Xe(()=>{let e=i.filter(e=>e.kind!==`memory`).flatMap(e=>WR(e.schema));return e.length?e:null},[i]),M=Xe(()=>i.some(e=>e.kind!==`memory`)||!g&&i.some(e=>e.data.rows.length>CJ),[i,g]),N=Xe(()=>{if(M||i.length===0)return null;let e=f.connections.filter(e=>r.includes(e.id));return e.length===1?{conn:e[0],keySuffix:`__${i.length}`,offset:o[e[0].id]??0}:null},[M,i,f.connections,r,o]),P=Xe(()=>{if(!g||i.length===0||M)return null;let e=i.map((e,t)=>{let n=e.data.rows;return{rows:n.length>0&&typeof n[0][d]==`number`?n:D[t]??n,offset:o[e.id]??0}});if(!N)for(let t of f.connections)r.includes(t.id)&&e.push({rows:t.dataset.rows,offset:o[t.id]??0});return MJ(e,d)},[g,i,M,D,o,d,f.connections,r,N]),F=S&&`okByPart`in S?S.okByPart:void 0,I=Xe(()=>{if(!M)return[];let e=w.map((e,t)=>({live:`live`in e&&!!e.live,source:`live`in e&&e.live?e.live.source:e.source,columnSet:new Set(`live`in e&&e.live?e.data.columnNames:e.schema.map(e=>e.name)),keySuffix:T?`__${t}`:``,xOffset:o[e.id]??0,key:`${e.id}|${T?t:``}`}));return w.forEach((t,n)=>{let r=F?.[n],i=D[n];`live`in t&&t.live||!r?.length||!i||e.push({...e[n],live:!1,source:kJ(i,r,d),columnSet:new Set([d,...r]),key:`${e[n].key}|channels`})}),e},[M,w,T,o,F,D,d]),L=Xe(()=>{let e=S?.parts??(C?[C]:[]),t=new Set;for(let n of e)for(let e of _J(n.columnNames,n.rows))t.add(e);let n=C?C.columnNames.filter(e=>t.has(e)):[],r=[...new Set(A?[...n,...A]:n)];if(k===``)return r;let i=new Set(r),a=k.split(`
610
+ `).filter(e=>!i.has(e));return a.length?[...r,...a]:r},[O,k,A]),R=Xe(()=>{let e=[];for(let t of l){if(t.kind!==`multiband`)continue;let n=u[t.id],r=n&&n.kind===`multiband`?n.series:[];e.push([t.id,[...new Set(r.map(e=>e.column).filter(e=>e!==d))]])}return JSON.stringify(e)},[l,u,d]),z=Xe(()=>{let e={};if(!C||M)return e;for(let[t,n]of JSON.parse(R)){let r=[];if(n.length>0)if(!T)r.push(j(C.rows,d,n,CJ));else{let e=Math.max(1,Math.floor(CJ/w.length));for(let t=0;t<w.length;t++){let i=w[t];if(N&&`live`in i&&i.live)continue;let a=D[t]??i.data.rows;r.push(j(a,d,n,e,`__${t}`,o[i.id]??0))}}e[t]=r}return e},[C,R,d,T,w,o,D,N,M]),B=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`multiband`)continue;let n=u[t.id],r=(n&&n.kind===`multiband`?n.series:[]).filter(e=>e.column!==d),i=n&&n.kind===`multiband`?n.layout:`overlay`,a=e=>jJ(e,i),o;if(!T)o=a(r);else{let e=a(r);o=[];for(let t=0;t<w.length;t++){let n=nz(s,w[t].id,t,c);for(let r of e)o.push({...r,id:`${r.id}__${t}`,column:`${r.column}__${t}`,color:n})}}let l=z[t.id]??[],f=T&&n?.kind===`multiband`&&n.envelope?r.flatMap(e=>{let t=mJ(l.flatMap((t,n)=>{let r=t.cols.get(`${e.column}__${n}`);return r?[{x:t.x,y:r}]:[]}),DJ);return t?[{seriesId:e.id,color:e.color,...t}]:[]}):void 0;e[t.id]={effectiveSeries:o,points:l,envelopes:f}}return e},[C,l,u,d,T,w,s,c,z]),V=Xe(()=>{let e={pts:{},colorMeta:{},datasetColors:{}};if(!C)return e;let t={},r={},i={},a=EJ,o=w.map((e,t)=>({id:e.id,rows:D[t]??p[e.id]??e.data.rows,full:a(e)})),f={id:`single`,rows:C.rows,full:w.length===1?a(w[0]):void 0};for(let e of l){if(e.kind!==`xyscatter`)continue;let a=u[e.id];if(!a||a.kind!==`xyscatter`)continue;let{xyXCol:l,xyYCol:p}=a;if(!l||!p){t[e.id]={length:0,x:[],y:[]};continue}if(T){let{cols:r,colors:a}=PH(o,l,p,{xKey:d,viewXRange:n,colorOverrides:s,palette:c});t[e.id]=r,i[e.id]=a;continue}let m=NH(f,l,p,{xKey:d,viewXRange:n,colorCol:a.xyColorCol||void 0});t[e.id]=m?.cols??{length:0,x:[],y:[]},m?.color&&(r[e.id]=m.color)}return{pts:t,colorMeta:r,datasetColors:i}},[C,l,u,n,d,T,w,p,s,c,D]),ee=K(new Map),te=Xe(()=>{let e={};if(!C)return e;let t={length:0,x:[],y:[],z:[]},{rows:r}=C,i=E;for(let a of l){if(a.kind!==`xyzmesh`)continue;let o=u[a.id];if(!o||o.kind!==`xyzmesh`)continue;if(o.xyzMode===`matrix`){let n=(o.xyzColumns??[]).flatMap(e=>{let t=DH(r,e,i);return t?[t]:[]}),s=n[0]?.length??0,c=n.length;if(s<2||c<2){e[a.id]={points:t};continue}let l=ee.current.get(a.id);l?.length!==s*c&&ee.current.set(a.id,l=new Float32Array(s*c)),n.forEach((e,t)=>l.set(e.length===s?e:e.subarray(0,s),t*s));let u=DH(r,d,i),f=u&&!(o.xyzColumns??[]).includes(d)&&u.length>=s&&Number.isFinite(u[0])&&Number.isFinite(u[s-1])?[u[0],u[s-1]]:[0,s-1];e[a.id]={points:t,surface:{w:s,h:c,values:l,x:f,y:[0,c-1]}};continue}let{xyzXCol:s,xyzYCol:c,xyzZCol:l}=o,f=s?DH(r,s,i):void 0,p=c?DH(r,c,i):void 0,m=l?DH(r,l,i):void 0;if(!f||!p||!m){e[a.id]={points:t};continue}let h=n?DH(r,d,i):void 0;if(!n||!h){e[a.id]={points:{length:Math.min(f.length,p.length,m.length),x:f,y:p,z:m}};continue}let[g,_]=n,v=0;for(let e=0;e<h.length;e++)h[e]>=g&&h[e]<=_&&v++;let y=new Float64Array(v),b=new Float64Array(v),x=new Float64Array(v);for(let e=0,t=0;e<h.length;e++)h[e]>=g&&h[e]<=_&&(y[t]=f[e],b[t]=p[e],x[t]=m[e],t++);e[a.id]={points:{length:v,x:y,y:b,z:x}}}return e},[C,l,u,n,d,E]),H=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`histogram`)continue;let n=u[t.id];e[t.id]=n?.kind===`histogram`&&n.histColumn&&OH(C.rows,n.histColumn,E)||new Float64Array}return e},[C,l,u,E]),ne=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`polar`)continue;let n=u[t.id],r=n?.kind===`polar`&&n.polarAngleCol?DH(C.rows,n.polarAngleCol,E):void 0,i=n?.kind===`polar`&&n.polarRadiusCol?DH(C.rows,n.polarRadiusCol,E):void 0;e[t.id]=r&&i?{angles:r,radii:i}:{angles:[],radii:[]}}return e},[C,l,u,E]),re=(e,t,n,r)=>{let i=t&&OH(e,t,E)||new Float64Array,a=n?DH(e,n,E):void 0;return{signal:i,rate:a&&AH(a)||parseFloat(r)||1}},ie=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`spectrum`)continue;let n=u[t.id];n?.kind===`spectrum`&&(e[t.id]=re(C.rows,n.specSignalCol,n.specTimeCol,n.specSampleRate))}return e},[C,l,u,E]),U=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`boxplot`)continue;let n=u[t.id];e[t.id]=n?.kind===`boxplot`&&n.boxValueCol?kH(C.rows,n.boxValueCol,n.boxGroupCol||void 0,E):[]}return e},[C,l,u,E]),ae=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`spectrogram`)continue;let n=u[t.id];n?.kind===`spectrogram`&&(e[t.id]=re(C.rows,n.sgSignalCol,n.sgTimeCol,n.sgSampleRate))}return e},[C,l,u,E]),oe=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`heatmap`)continue;let n=u[t.id];if(!n||n.kind!==`heatmap`){e[t.id]={cells:[],xLabels:[],yLabels:[]};continue}if(n.hmMode===`matrix`){let r=C.rows,i=n.hmColumns.flatMap(e=>{let t=DH(r,e,E);return t?[{name:e,v:t}]:[]}),a=i.reduce((e,t)=>Math.min(e,t.v.length),i.length?1/0:0),o=DH(r,d,E),s,c;if(n.hmSpacing===`values`){o&&HG(o.subarray(0,a))&&(s=Float64Array.from(o.subarray(0,a)));let e=i.map(e=>({c:e,v:parseFloat(e.name)})).sort((e,t)=>t.v-e.v);e.length&&HG(e.map(e=>e.v).reverse())&&(i=e.map(e=>e.c),c=Float64Array.from(e,e=>e.v))}let l=i.length,u=new Float32Array(a*l);i.forEach((e,t)=>u.set(e.v.subarray(0,a),t*a));let f=e=>String(o?+o[e].toPrecision(6):e+1);e[t.id]={cells:[],xLabels:[],yLabels:i.map(e=>e.name),grid:{w:a,h:l,values:u,xLabels:f,yLabels:i.map(e=>e.name)},xCentres:s,yCentres:c}}else if(n.hmMode===`correlation`){let r=n.hmColumns.filter(e=>L.includes(e));if(r.length<2){e[t.id]={cells:[],xLabels:r,yLabels:r};continue}let i=r.map(e=>{let t=[];for(let n of C.rows){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&t.push(r)}return t}),a=i.map(e=>e.reduce((e,t)=>e+t,0)/(e.length||1)),o=[];for(let e=0;e<r.length;e++)for(let t=0;t<r.length;t++){let n=i[e],s=i[t],c=a[e],l=a[t],u=Math.min(n.length,s.length),d=0,f=0,p=0;for(let e=0;e<u;e++){let t=n[e]-c,r=s[e]-l;d+=t*r,f+=t*t,p+=r*r}let m=f>0&&p>0?d/Math.sqrt(f*p):+(e===t);o.push({x:r[t],y:r[e],value:m})}e[t.id]={cells:o,xLabels:r,yLabels:r}}else if(n.hmMode===`binned`||n.hmMode===`count`){let{hmXCol:r,hmYCol:i}=n,a=n.hmMode===`count`?``:n.hmValueCol;if(!r||!i||n.hmMode===`binned`&&!a){e[t.id]={cells:[],xLabels:[],yLabels:[]};continue}let o=e=>{let t=parseFloat(e);return Number.isFinite(t)?t:void 0};e[t.id]=bJ(C.rows,{xCol:r,yCol:i,valueCol:a,xBins:n.hmXBins,yBins:n.hmYBins,xMin:o(n.hmXMin),xMax:o(n.hmXMax),yMin:o(n.hmYMin),yMax:o(n.hmYMax)})}else{let{hmXCol:r,hmYCol:i,hmValueCol:a}=n;if(!r||!i||!a){e[t.id]={cells:[],xLabels:[],yLabels:[]};continue}let o=new Map,s=new Set,c=new Set;for(let e of C.rows){let t=String(e[r]??``),n=String(e[i]??``),l=e[a];if(typeof l!=`number`||!Number.isFinite(l))continue;s.add(t),c.add(n);let u=`${t}\0${n}`,d=o.get(u)??{sum:0,count:0};o.set(u,{sum:d.sum+l,count:d.count+1})}let l=e=>{let t=[...e];return t.every(e=>e.trim()!==``&&Number.isFinite(Number(e)))?t.sort((e,t)=>Number(e)-Number(t)):t.sort()},u=l(s),d=l(c),f,p;if(n.hmSpacing===`values`){let e=Float64Array.from(u,Number),t=Float64Array.from(d,Number);HG(e)&&(f=e),HG(t)&&(d=[...d].reverse(),p=t.reverse())}let m=[];for(let e of d)for(let t of u){let n=o.get(`${t}\0${e}`);m.push({x:t,y:e,value:n?n.sum/n.count:0})}e[t.id]={cells:m,xLabels:u,yLabels:d,xCentres:f,yCentres:p}}}return e},[C,l,u,L,d,E]),se=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`violin`)continue;let n=u[t.id];e[t.id]=n?.kind===`violin`&&n.vlValueCol?kH(C.rows,n.vlValueCol,n.vlGroupCol||void 0,E):[]}return e},[C,l,u,E]),ce=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C;for(let n of l){if(n.kind!==`confusion`)continue;let r=u[n.id];if(!r||r.kind!==`confusion`||!r.cfActualCol||!r.cfPredictedCol){e[n.id]={actual:[],predicted:[]};continue}let{cfActualCol:i,cfPredictedCol:a}=r,o=E?.get(i),s=E?.get(a);if(o&&s){e[n.id]={actual:o,predicted:s};continue}let c=[],l=[];for(let e of t){let t=e[i],n=e[a];t!==void 0&&n!==void 0&&(c.push(t),l.push(n))}e[n.id]={actual:c,predicted:l}}return e},[C,l,u,E]),le=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`roc`)continue;let n=u[t.id],r=n?.kind===`roc`&&n.rocScoreCol?DH(C.rows,n.rocScoreCol,E):void 0,i=n?.kind===`roc`&&n.rocLabelCol?DH(C.rows,n.rocLabelCol,E):void 0;e[t.id]=r&&i?{scores:r,labels:i}:{scores:[],labels:[]}}return e},[C,l,u,E]),ue=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C;for(let n of l){if(n.kind!==`losscurve`)continue;let r=u[n.id];if(!r||r.kind!==`losscurve`){e[n.id]={xValues:[],series:[]};continue}let{lcXCol:i,lcLeftCols:a,lcRightCols:o}=r,s=[...a.map(e=>({...e,axis:`left`})),...o.map(e=>({...e,axis:`right`}))].map(({column:e,color:n,axis:r})=>({label:e,color:n,values:DH(t,e,E)??new Float64Array,axis:r})),c=s[0]?.values.length??t.length,l=i&&DH(t,i,E)||Float64Array.from({length:c},(e,t)=>t);e[n.id]={xValues:l,series:s}}return e},[C,l,u,E]),de=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C;for(let n of l){if(n.kind!==`controlchart`)continue;let r=u[n.id],i=r?.kind===`controlchart`&&r.ccValueCol?DH(t,r.ccValueCol,E):void 0;if(!r||r.kind!==`controlchart`||!i){e[n.id]={length:0,value:[]};continue}let a=0;for(let e=0;e<i.length;e++)i[e]-i[e]===0&&a++;let o=a===i.length?null:new Uint32Array(a),s=o?new Float64Array(a):i;if(o)for(let e=0,t=0;e<i.length;e++)i[e]-i[e]===0&&(o[t]=e,s[t++]=i[e]);let c=r.ccSubgroupCol,l=c?E?.get(c):void 0,d=e=>o?o[e]:e;e[n.id]={length:a,value:s,subgroup:c?e=>String(l?l[d(e)]:t[d(e)]?.[c]??``):void 0}}return e},[C,l,u,E]),fe=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C;for(let n of l){if(n.kind!==`parallelcoords`)continue;let r=u[n.id];if(!r||r.kind!==`parallelcoords`||r.pcColumns.length<2){e[n.id]={length:0,columns:[]};continue}let i=r.pcColumns.map(e=>DH(t,e,E)??new Float64Array),a=Math.min(...i.map(e=>e.length)),o={length:a,columns:i},s=r.pcColorByCol;if(s)if(L.includes(s))o.colorValue=DH(t,s,E);else{let e=new Map,n=new Int32Array(a);for(let r=0;r<a;r++){let i=String(t[r]?.[s]??``),a=e.get(i);a===void 0&&e.set(i,a=e.size),n[r]=a}o.colorIndex=n,o.colorLabels=[...e.keys()]}e[n.id]=o}return e},[C,l,u,L,E]),pe=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C,n={length:0,x:[],y:[]};for(let r of l){if(r.kind!==`embedding`)continue;let i=u[r.id];if(!i||i.kind!==`embedding`||!i.emXCol||!i.emYCol){e[r.id]=n;continue}let{emXCol:a,emYCol:o,emColorCol:s,emColorMode:c,emLabelCol:l}=i,d=DH(t,a,E),f=DH(t,o,E);if(!d||!f){e[r.id]=n;continue}let p=Math.min(d.length,f.length),m={length:p,x:d,y:f};if(s)if(c===`numeric`&&L.includes(s))m.colorValue=DH(t,s,E);else{let e=E?.get(s),n=new Map,r=new Int32Array(p);for(let i=0;i<p;i++){let a=String(e?e[i]:t[i]?.[s]??``),o=n.get(a);o===void 0&&n.set(a,o=n.size),r[i]=o}m.colorIndex=r,m.colorLabels=[...n.keys()]}if(l){let e=E?.get(l);m.label=e?t=>String(e[t]):e=>String(t[e]?.[l]??``)}e[r.id]=m}return e},[C,l,u,L,E]),me=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`flamegraph`)continue;let n=u[t.id];if(!n||n.kind!==`flamegraph`||!n.fgNameCol||!n.fgValueCol){e[t.id]=[];continue}let r=[];for(let e of C.rows){let t=String(e[n.fgNameCol]??``),i=n.fgParentCol?String(e[n.fgParentCol]??``):``,a=e[n.fgValueCol];!t||typeof a!=`number`||!Number.isFinite(a)||r.push({name:t,parent:i,value:a})}e[t.id]=r}return e},[C,l,u]),he=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`barchart`)continue;let n=u[t.id];if(!n||n.kind!==`barchart`||n.bcValueCols.length===0){e[t.id]={groups:[],seriesNames:[]};continue}let r=n.bcValueCols;if(n.bcCategoryCol){let i=new Map;for(let e of C.rows){let t=String(e[n.bcCategoryCol]??`(blank)`);i.has(t)||i.set(t,r.map(()=>0));let a=new Map,o=i.get(t);for(let t=0;t<r.length;t++){let n=e[r[t]];typeof n==`number`&&Number.isFinite(n)&&(o[t]+=n),a.set(r[t],(a.get(r[t])??0)+1)}}e[t.id]={groups:Array.from(i.entries()).map(([e,t])=>({label:e,values:t})),seriesNames:r}}else{let n=C.rows,i=r.map(e=>DH(n,e,E)),a=i.reduce((e,t)=>t?Math.min(e,t.length):e,1/0),o=Number.isFinite(a)?a:n.length,s=i.map(e=>e??new Float64Array(o).fill(NaN));e[t.id]={groups:[],columns:{length:o,values:s},seriesNames:r}}}return e},[C,l,u,E]),ge=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C;for(let n of l){if(n.kind!==`radar`)continue;let r=u[n.id];if(!r||r.kind!==`radar`||r.rdAxesCols.length<3){e[n.id]={axes:[],series:[]};continue}let i=r.rdAxesCols,a=i.map(e=>DH(t,e,E));if(r.rdGroupCol){let o=r.rdGroupCol,s=E?.get(o),c=s?s.length:t.length,l=new Map;for(let e=0;e<c;e++){let n=s?s[e]===s[e]?String(s[e]):`(blank)`:String(t[e][o]??`(blank)`),r=l.get(n);r||l.set(n,r=i.map(()=>0));for(let t=0;t<i.length;t++){let n=a[t]?.[e]??NaN;n-n===0&&(r[t]+=n)}}e[n.id]={axes:i,series:Array.from(l.entries()).map(([e,t])=>({name:e,values:t}))}}else{let t=a.map(e=>{let t=0,n=0;if(e)for(let r=0;r<e.length;r++)e[r]-e[r]===0&&(t+=e[r],n++);return t/(n||1)});e[n.id]={axes:i,series:[{name:`Series 1`,values:t}]}}}return e},[C,l,u,E]),_e=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`areachart`)continue;let n=u[t.id];if(!n||n.kind!==`areachart`||n.acYCols.length===0){e[t.id]=[];continue}let r=C.rows,i=n.acYCols.map(e=>DH(r,e,E)),a=i[0]?.length??r.length,o=(n.acXCol?DH(r,n.acXCol,E):void 0)??FJ(a);e[t.id]=n.acYCols.flatMap((e,t)=>{let n=i[t];return n?[{name:e,x:o,y:n}]:[]})}return e},[C,l,u,E]),ve=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`cdfchart`)continue;let n=u[t.id];if(!n||n.kind!==`cdfchart`){e[t.id]=[];continue}e[t.id]=n.cdValueCols.map(e=>({name:e,values:OH(C.rows,e,E)??new Float64Array}))}return e},[C,l,u,E]),ye=Xe(()=>{let e={};if(!C)return e;let{rows:t}=C,n={length:0,x:[],y:[],size:[]};for(let r of l){if(r.kind!==`bubblechart`)continue;let i=u[r.id];if(!i||i.kind!==`bubblechart`||!i.bbXCol||!i.bbYCol||!i.bbSizeCol){e[r.id]=n;continue}let a=DH(t,i.bbXCol,E),o=DH(t,i.bbYCol,E),s=DH(t,i.bbSizeCol,E);if(!a||!o||!s){e[r.id]=n;continue}let c=Math.min(a.length,o.length,s.length),l=new Float64Array(c);for(let e=0;e<c;e++)l[e]=s[e]===s[e]?Math.max(0,s[e]):NaN;let d=new Float64Array(c);for(let e=0;e<c;e++)d[e]=l[e]===l[e]?a[e]:NaN;let f={length:c,x:d,y:o,size:l};if(i.bbColorCol){if(i.bbColorMode===`numeric`)f.colorValue=DH(t,i.bbColorCol,E);else if(i.bbColorMode===`categorical`){let e=E?.get(i.bbColorCol),n=new Map,r=new Int32Array(c);for(let a=0;a<c;a++){let o=String(e?e[a]:t[a]?.[i.bbColorCol]??``),s=n.get(o);s===void 0&&n.set(o,s=n.size),r[a]=s}f.colorIndex=r,f.colorLabels=[...n.keys()]}}e[r.id]=f}return e},[C,l,u,E]),be=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`treemap`)continue;let n=u[t.id];if(!n||n.kind!==`treemap`||!n.tmNameCol||!n.tmValueCol){e[t.id]=[];continue}let r=[];for(let e of C.rows){let t=String(e[n.tmNameCol]??``),i=n.tmParentCol?String(e[n.tmParentCol]??``):``,a=e[n.tmValueCol];!t||typeof a!=`number`||!Number.isFinite(a)||r.push({name:t,parent:i,value:a})}e[t.id]=r}return e},[C,l,u]),xe=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`sankey`)continue;let n=u[t.id];if(!n||n.kind!==`sankey`||!n.skSourceCol||!n.skTargetCol||!n.skValueCol){e[t.id]={nodeNames:[],links:[]};continue}let r=new Set,i=[];for(let e of C.rows){let t=String(e[n.skSourceCol]??``),a=String(e[n.skTargetCol]??``),o=e[n.skValueCol];!t||!a||typeof o!=`number`||!Number.isFinite(o)||(r.add(t),r.add(a),i.push({source:t,target:a,value:o}))}e[t.id]={nodeNames:Array.from(r),links:i}}return e},[C,l,u]),Se=Xe(()=>{let e={};if(!C)return e;for(let t of l){if(t.kind!==`calibration`)continue;let n=u[t.id],r=n?.kind===`calibration`&&n.cbScoreCol?DH(C.rows,n.cbScoreCol,E):void 0,i=n?.kind===`calibration`&&n.cbLabelCol?DH(C.rows,n.cbLabelCol,E):void 0;if(!n||n.kind!==`calibration`||!r||!i){e[t.id]=[];continue}let a=Math.max(2,n.cbBins),o=new Float64Array(a),s=new Float64Array(a);for(let e=0;e<Math.min(r.length,i.length);e++){let t=r[e],n=i[e];if(t-t!==0||n-n!==0)continue;let c=Math.max(0,Math.min(a-1,Math.floor(t*a)));o[c]+=n,s[c]++}e[t.id]=Array.from({length:a},(e,t)=>({center:(t+.5)/a,actual:s[t]>0?o[t]/s[t]:0,count:s[t]})).filter(e=>e.count>0)}return e},[C,l,u,E]),Ce=Xe(()=>{let e={};if(!C)return e;let t={length:0,theoretical:[],sample:[]},n=e=>{let t=OH(C.rows,e,E);return t?Float64Array.from(t).sort():new Float64Array};for(let r of l){if(r.kind!==`qqplot`)continue;let i=u[r.id];if(!i||i.kind!==`qqplot`||!i.qqValueCol){e[r.id]=t;continue}let a=n(i.qqValueCol),o=a.length;if(o===0){e[r.id]=t;continue}if(i.qqMode===`column`&&i.qqRefCol){let t=n(i.qqRefCol),s=Math.min(o,t.length);e[r.id]={length:s,theoretical:t.subarray(0,s),sample:a.subarray(0,s)}}else{let t=e=>{let t=[2.515517,.802853,.010328],n=[1.432788,.189269,.001308],r=Math.sqrt(-2*Math.log(Math.min(e,1-e))),i=r-(t[0]+t[1]*r+t[2]*r*r)/(1+n[0]*r+n[1]*r*r+n[2]*r*r*r);return e<.5?-i:i},n=new Float64Array(o);for(let e=0;e<o;e++)n[e]=t((e+.5)/o);e[r.id]={length:o,theoretical:n,sample:a}}}return e},[C,l,u,E]),we=Xe(()=>{if(!C)return{};let e={};for(let t of l){if(t.kind!==`gantt`)continue;let n=u[t.id];if(!n||n.kind!==`gantt`||!n.gtLabelCol||!n.gtStartCol||!n.gtEndCol){e[t.id]=[];continue}let r=[];for(let e of C.rows){let t=String(e[n.gtLabelCol]??``),i=e[n.gtStartCol],a=e[n.gtEndCol];if(!t||typeof i!=`number`||typeof a!=`number`||!Number.isFinite(i)||!Number.isFinite(a))continue;let o={label:t,start:i,end:a};n.gtGroupCol&&e[n.gtGroupCol]!==void 0&&(o.group=String(e[n.gtGroupCol])),r.push(o)}e[t.id]=r}return e},[C,l,u]),Te=C&&C.columnNames.indexOf(d)>=0?C.units[C.columnNames.indexOf(d)]??``:``,Ee=Xe(()=>{if(!C)return{};let e={};for(let t=0;t<C.columnNames.length;t++){let n=C.units[t]?.trim();n&&(e[C.columnNames[t]]=n)}if(T)for(let t=0;t<w.length;t++)for(let[n,r]of Object.entries(e))e[`${n}__${t}`]=r;return e},[C,T,w]);return{dataset:y,datasetWithChannels:C,multiDatasetMode:T,numericCols:L,anyDuckDb:M,duckDbLayers:I,liveConn:_,liveOverlay:N,hasLiveSelected:g,staticXRange:P,xUnit:Te,columnUnits:Ee,multibandDataByPanel:B,xyPointsByPanel:V,xyzPointsByPanel:te,histogramDataByPanel:H,polarDataByPanel:ne,spectrumDataByPanel:ie,boxplotDataByPanel:U,spectrogramDataByPanel:ae,heatmapDataByPanel:oe,violinDataByPanel:se,confusionDataByPanel:ce,rocDataByPanel:le,lossCurveDataByPanel:ue,controlChartDataByPanel:de,parallelCoordsDataByPanel:fe,embeddingDataByPanel:pe,flameGraphDataByPanel:me,barChartDataByPanel:he,radarDataByPanel:ge,areaChartDataByPanel:_e,cdfChartDataByPanel:ve,bubbleChartDataByPanel:ye,treemapDataByPanel:be,sankeyDataByPanel:xe,calibrationDataByPanel:Se,qqPlotDataByPanel:Ce,ganttDataByPanel:we,gaugeDataByPanel:Xe(()=>{let e={};if(!C)return e;let t=e=>e.trim()!==``&&Number.isFinite(Number(e))?Number(e):void 0;for(let n of l){if(n.kind!==`gauge`)continue;let r=u[n.id];if(r?.kind!==`gauge`){e[n.id]=[];continue}e[n.id]=r.ggGauges.flatMap(e=>{let n=e.column,r=n?DH(C.rows,n,E):void 0;if(!r)return[];let i=1/0,a=-1/0,o=0,s=0,c=NaN;for(let e=0;e<r.length;e++){let t=r[e];t-t===0&&(t<i&&(i=t),t>a&&(a=t),o+=t,s++,c=t)}let l=s===0?NaN:e.value===`mean`?o/s:e.value===`min`?i:e.value===`max`?a:c,[u,d]=LJ(s?i:0,s?a:1,t(e.min),t(e.max));return[{name:n,unit:Ee[n]??``,value:l,min:u,max:d,alarm:e.alarm??null,color:e.color,style:e.style,colorMode:e.colorMode,stops:e.stops}]})}return e},[C,l,u,E,Ee])}}function LJ(e,t,n,r){t<=e&&(t=e+1);let i=KR(t-e,5),a=n??Math.floor(e/i)*i,o=r??Math.ceil(t/i)*i;return o>a?[a,o]:[a,a+1]}var RJ=`__ref`,zJ=8e3;function BJ(e,t){return e.map(e=>({...e,id:`${e.id}${RJ}`,column:`${e.column}${RJ}`,color:t}))}var VJ=new WeakMap;function HJ(e,t,n){let r=e.data.rows,i=`${t}\n${n.join(`
611
+ `)}`,a=VJ.get(r);a||(a=new Map,VJ.set(r,a));let o=a.get(i);if(o)return o;let s=UJ(j(r,t,n,zJ,RJ)),c={points:s,span:s.length>1?[s.x[0],s.x[s.length-1]]:null};return a.set(i,c),c}function UJ(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 WJ(e,t){return e?t?[Math.min(e[0],t[0]),Math.max(e[1],t[1])]:e:t}function GJ(e,t,n,r,i){e.source.trackCycles(t);let a=r.reference===`dataset`&&i?HJ(i,t,n):null,o=null;return{pull:(i,s,c,l)=>{let u=e.source.version();if(!o||o.ver!==u||o.x0!==i||o.x1!==s||o.mp!==c){let l=ye;if(r.reference===`previous`){let r=e.source.cyclePointsSync(t,`previous`,n,{x0:i,x1:s},c);l={...r,cols:new Map([...r.cols].map(([e,t])=>[e+RJ,t]))}}else a&&(l=de(a.points,i,s));o={ver:u,x0:i,x1:s,mp:c,live:e.source.cyclePointsSync(t,`current`,n,{x0:i,x1:s},c),ref:l}}return[o.ref,le(o.live,l)]},latestT:()=>e.source.latestTimeSync(),xAtTime:n=>e.source.xAtTimeSync(t,n),xBounds:()=>WJ(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 KJ(e,t){return e.reference===`previous`?e.previousColor:e.reference===`dataset`&&t?e.datasetColor:null}function qJ(e,t,n,r,i,a,o){let s=null;return{pull:(o,c,l,u)=>{let d=e.source.version();if(!s||s.ver!==d||s.x0!==o||s.x1!==c||s.mp!==l){let a=e.source.getPointsSync(n,{xKey:t,x0:o-i,x1:c-i},l),u=i===0?a.x:a.x.map(e=>e+i);s={ver:d,x0:o,x1:c,mp:l,pts:{...a,x:u,cols:new Map([...a.cols].map(([e,t])=>[e+r,t]))}}}return[...a,le(s.pts,u)]},xBounds:()=>{let n=e.source.xBoundsSync(t);return n.x1>n.x0?o?[Math.min(o[0],n.x0+i),Math.max(o[1],n.x1+i)]:[n.x0+i,n.x1+i]:o},latestX:()=>{let n=e.source.latestSync(t);return Number.isFinite(n)?n+i:null},version:()=>e.source.version(),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}}}var JJ=`#fb7185`,YJ=2500;function XJ(e){let{panel:t,data:n,settings:r}=e;if(!n.dataset)return{status:`no-data`,node:null,data:null};let i=`${e.background??`theme`}|${e.styleToken}`,a=t=>e.onContextMenu(t),o=(e,t)=>({status:`ready`,node:e,data:t}),s={status:`empty`,node:null,data:null},c=t.id;switch(t.kind){case`multiband`:{let t=n.multibandDataByPanel[c],l=t?.points??[],u=t?.effectiveSeries??[],d=r?.kind===`multiband`?r:null,f=[...new Set((d?.series??[]).map(e=>e.column).filter(t=>t!==e.xKey))],p={xLabel:n.xUnit?`${e.xKey} (${n.xUnit})`:e.xKey,series:u,columnUnits:n.columnUnits,height:e.height,backgroundToken:i,viewXRange:e.viewXRange,onViewXRangeChange:e.onViewXRangeChange,liveZoom:e.liveZoom,liveZoomId:c,xAxisLine:d?.xAxisLine,yAxisLine:d?.yAxisLine,gridLine:d?.gridLine,lineWidth:d?.lineWidth,onPlotContextMenu:a,shiftMode:e.shiftMode},m=d?.beacon;if(m?.enabled&&e.beaconLive&&f.length>0){let t=jJ((d?.series??[]).filter(t=>t.column!==e.xKey),d?.layout??`overlay`),n=m.reference===`dataset`&&m.datasetId?e.findDataset(m.datasetId):void 0,r=KJ(m,!!n),i=r?[...BJ(t,r),...t]:t;return o(q(rH,{...p,series:i,points:[],showLatestValues:!0,liveSource:GJ(e.beaconLive,e.xKey,f,m,n),liveZoomMode:`free`}),{series:i,points:[]})}if(n.anyDuckDb)return u.length===0?s:o(q(wH,{...p,layers:n.duckDbLayers,xKey:e.xKey,columns:f,maxPoints:YJ}),{series:u,columns:f});if(!l.some(e=>e.length>0)||u.length===0)return s;let h=n.liveConn,g=null,_=n.liveOverlay,v=!h&&_&&f.length>0?qJ(_.conn,e.xKey,f,_.keySuffix,_.offset,l,n.staticXRange):void 0,y=v??(h&&f.length>0?{pull:(t,n,r,i)=>{let a=h.source.version();return(!g||g.ver!==a||g.x0!==t||g.x1!==n||g.mp!==r)&&(g={ver:a,x0:t,x1:n,mp:r,pts:h.source.getPointsSync(f,{xKey:e.xKey,x0:t,x1:n},r)}),[le(g.pts,i)]},latestT:()=>h.source.latestTimeSync(),xAtTime:t=>h.source.xAtTimeSync(e.xKey,t),xBounds:()=>{let t=h.source.xBoundsSync(e.xKey);return t.x1>t.x0?[t.x0,t.x1]:null},latestX:()=>{let t=h.source.latestSync(e.xKey);return Number.isFinite(t)?t:null},version:()=>h.source.version(),latestValues:e=>h.source.latestValuesSync(e),...e.xKey===`ElapsedTime`?{}:{spanForSeconds:t=>h.source.xTravelSync(e.xKey,t),bufferedSeconds:()=>{let e=h.source.xBoundsSync(`ElapsedTime`);return e.x1-e.x0}}}:void 0);return o(q(rH,{...p,points:l,envelopes:t?.envelopes,showLatestValues:n.hasLiveSelected,fullXRange:n.staticXRange,liveSource:y,liveWindowSeconds:v?null:e.liveWindowSeconds,onLiveWindowChange:v?void 0:e.onLiveWindowChange,liveZoomMode:v?`free`:`follow`}),{series:u,points:l})}case`xyzmesh`:{let t=r?.kind===`xyzmesh`?r:Xt(4),l=n.xyzPointsByPanel[c];if(!l||l.points.length<1&&!l.surface)return s;let u=!!l.surface;return o(q(EW,{ref:e.xyzRef,points:l.points,surface:l.surface,xLabel:u?(t.xyzColumns??[]).includes(e.xKey)?`Row`:e.xKey:t.xyzXCol,yLabel:u?`Column`:t.xyzYCol,zLabel:u?`Value`:t.xyzZCol,height:e.height,backgroundToken:i,xRange:Wt(t.xyzXScale.scaleMin,t.xyzXScale.scaleMax),yRange:Wt(t.xyzYScale.scaleMin,t.xyzYScale.scaleMax),zRange:Wt(t.xyzZScale.scaleMin,t.xyzZScale.scaleMax),viewMode:t.xyzViewMode,pointRadius:t.xyzPointRadius,showMesh:t.showMesh,meshStyle:t.meshStyle,meshOpacity:t.meshOpacity,alarms:[...t.xyzXScale.alarm?[{axis:`x`,...t.xyzXScale.alarm}]:[],...t.xyzYScale.alarm?[{axis:`y`,...t.xyzYScale.alarm}]:[],...t.xyzZScale.alarm?[{axis:`z`,...t.xyzZScale.alarm}]:[]],onPlotContextMenu:a}),l.surface??l.points)}case`xyscatter`:{let t=r?.kind===`xyscatter`?r:Yt(JJ),l=n.xyPointsByPanel.pts[c]??[];if(l.length===0)return s;let u=n.xyPointsByPanel.colorMeta[c];return o(q(mU,{points:l,xLabel:t.xyXCol,yLabel:t.xyYCol,color:t.xyColor,datasetColors:n.xyPointsByPanel.datasetColors[c],colorLabel:u?.label,colorRange:u?[u.min,u.max]:void 0,pointRadius:t.xyPointRadius,drawMode:t.xyDrawMode,lineWidth:t.xyLineWidth,height:e.height,backgroundToken:i,xAxisLine:t.xyXAxisLine,yAxisLine:t.xyYAxisLine,gridLine:t.xyGridLine,fitSettings:t.xyFit,xScale:t.xyXScale,yScale:t.xyYScale,onPlotContextMenu:a}),l)}case`histogram`:{if(r?.kind!==`histogram`)return s;let t=n.histogramDataByPanel[c]??[];return t.length===0?s:o(q(NW,{values:t,label:r.histColumn,bins:r.histBins,color:r.histColor,showNormal:r.histNormal,logY:r.histLogY,height:e.height,backgroundToken:i,onPlotContextMenu:a}),t)}case`polar`:{if(r?.kind!==`polar`)return s;let t=n.polarDataByPanel[c]??{angles:[],radii:[]};if(t.angles.length===0)return s;let l=parseFloat(r.polarRadiusMin),u=parseFloat(r.polarRadiusMax);return o(q(ZW,{angles:t.angles,radii:t.radii,angleLabel:r.polarAngleCol,radiusLabel:r.polarRadiusCol,color:r.polarColor,mode:r.polarMode,radiusMin:Number.isFinite(l)?l:void 0,radiusMax:Number.isFinite(u)?u:void 0,height:e.height,backgroundToken:i,onPlotContextMenu:a}),t)}case`spectrum`:{if(r?.kind!==`spectrum`)return s;let{signal:t,rate:l}=n.spectrumDataByPanel[c]??{signal:[],rate:1};return t.length<4?s:o(q(pG,{signal:t,sampleRate:l,label:r.specSignalCol,xMode:r.specXMode,yMode:r.specYMode,window:r.specWindow,color:r.specColor,logX:r.specLogX,height:e.height,backgroundToken:i,onPlotContextMenu:a}),t)}case`boxplot`:{if(r?.kind!==`boxplot`)return s;let t=n.boxplotDataByPanel[c]??[];return t.length===0?s:o(q(yG,{groups:t,color:r.boxColor,whiskers:r.boxWhiskers,height:e.height,backgroundToken:i,onPlotContextMenu:a}),t)}case`spectrogram`:{if(r?.kind!==`spectrogram`)return s;let{signal:e,rate:t}=n.spectrogramDataByPanel[c]??{signal:[],rate:1};return e.length<r.sgWindowSize?s:r.sgView===`waterfall`?o(q(LG,{signal:e,sampleRate:t,windowSize:r.sgWindowSize,overlap:r.sgOverlap,winFunc:r.sgWinFunc,yMode:r.sgYMode,backgroundToken:i,onPlotContextMenu:a}),e):o(q(MG,{signal:e,sampleRate:t,windowSize:r.sgWindowSize,overlap:r.sgOverlap,winFunc:r.sgWinFunc,yMode:r.sgYMode,logFreq:r.sgLogFreq,backgroundToken:i,onPlotContextMenu:a}),e)}case`heatmap`:{if(r?.kind!==`heatmap`)return s;let e=n.heatmapDataByPanel[c]??{cells:[],xLabels:[],yLabels:[]};if(e.cells.length===0&&!(e.grid&&e.grid.w*e.grid.h>0))return s;let t=e=>e!==void 0&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):void 0;return o(q(nK,{cells:e.cells,xLabels:e.xLabels,yLabels:e.yLabels,grid:e.grid,showValues:r.hmShowValues,colorScheme:r.hmColorScheme,xCentres:e.xCentres,yCentres:e.yCentres,contours:r.hmContours??0,vMin:t(r.hmRange?.scaleMin),vMax:t(r.hmRange?.scaleMax),backgroundToken:i,onPlotContextMenu:a}),e)}case`violin`:{if(r?.kind!==`violin`)return s;let e=n.violinDataByPanel[c]??[];return e.some(e=>e.values.length>0)?o(q(uK,{groups:e,color:r.vlColor,showBox:r.vlShowBox,bandwidth:parseFloat(r.vlBandwidth)||void 0,orientation:r.vlOrientation,backgroundToken:i,onPlotContextMenu:a}),e):s}case`confusion`:{if(r?.kind!==`confusion`)return s;let e=n.confusionDataByPanel[c]??{actual:[],predicted:[]};return e.actual.length===0?s:o(q(_K,{actual:e.actual,predicted:e.predicted,normalize:r.cfNormalize,backgroundToken:i,onPlotContextMenu:a}),e)}case`roc`:{if(r?.kind!==`roc`)return s;let e=n.rocDataByPanel[c]??{scores:[],labels:[]};return e.scores.length===0?s:o(q(CK,{scores:e.scores,labels:e.labels,mode:r.rocMode,color:r.rocColor,backgroundToken:i,onPlotContextMenu:a}),e)}case`losscurve`:{if(r?.kind!==`losscurve`)return s;let e=n.lossCurveDataByPanel[c]??{xValues:[],series:[]};return e.series.length===0?s:o(q(TK,{xValues:e.xValues,series:e.series,xLabel:r.lcXCol||`Step`,backgroundToken:i,onPlotContextMenu:a}),e)}case`controlchart`:{if(r?.kind!==`controlchart`)return s;let e=n.controlChartDataByPanel[c];return!e||e.length<2?s:o(q(jK,{points:e,sigmaLevel:r.ccSigmaLevel,color:r.ccColor,backgroundToken:i,onPlotContextMenu:a}),e)}case`parallelcoords`:{if(r?.kind!==`parallelcoords`)return s;let e=n.parallelCoordsDataByPanel[c];if(!e||e.length===0||r.pcColumns.length<2)return s;let t=r.pcColorByCol?n.numericCols.includes(r.pcColorByCol):!1;return o(q(LK,{rows:e,axes:r.pcColumns,color:r.pcColor,colorByNumeric:t,backgroundToken:i,onPlotContextMenu:a}),e)}case`embedding`:{if(r?.kind!==`embedding`)return s;let e=n.embeddingDataByPanel[c];return!e||e.length===0?s:o(q(qK,{points:e,color:r.emColor,colorByNumeric:r.emColorMode===`numeric`&&!!r.emColorCol,pointSize:r.emPointSize,backgroundToken:i,onPlotContextMenu:a}),e)}case`flamegraph`:{if(r?.kind!==`flamegraph`)return s;let e=n.flameGraphDataByPanel[c]??[];return e.length===0?s:o(q(tq,{nodes:e,direction:r.fgDirection,backgroundToken:i,onPlotContextMenu:a}),e)}case`barchart`:{if(r?.kind!==`barchart`)return s;let e=n.barChartDataByPanel[c]??{groups:[],seriesNames:[]};if(e.groups.length===0&&!e.columns?.length)return s;let t=e=>e!==void 0&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):void 0,l=r.bcValueScale?{min:t(r.bcValueScale.scaleMin),max:t(r.bcValueScale.scaleMax)}:void 0;return o(q(sq,{groups:e.columns?void 0:e.groups,columns:e.columns,seriesNames:e.seriesNames,mode:r.bcMode,horizontal:r.bcHorizontal,valueRange:l,backgroundToken:i,onPlotContextMenu:a}),e)}case`radar`:{if(r?.kind!==`radar`)return s;let e=n.radarDataByPanel[c]??{axes:[],series:[]};return e.axes.length<3?s:o(q(dq,{axes:e.axes,series:e.series,fill:r.rdFill,color:r.rdColor,backgroundToken:i,onPlotContextMenu:a}),e)}case`areachart`:{if(r?.kind!==`areachart`)return s;let e=n.areaChartDataByPanel[c]??[];if(e.length===0)return s;let t=e=>e!==void 0&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):void 0,l=r.acYScale?{min:t(r.acYScale.scaleMin),max:t(r.acYScale.scaleMax)}:void 0;return o(q(hq,{series:e,stacked:r.acStacked,yRange:l,backgroundToken:i,onPlotContextMenu:a}),e)}case`cdfchart`:{if(r?.kind!==`cdfchart`)return s;let e=n.cdfChartDataByPanel[c]??[];return e.length===0?s:o(q(vq,{series:e,complement:r.cdComplement,logX:r.cdLogX,backgroundToken:i,onPlotContextMenu:a}),e)}case`bubblechart`:{if(r?.kind!==`bubblechart`)return s;let e=n.bubbleChartDataByPanel[c];return!e||e.length===0?s:o(q(Eq,{points:e,color:r.bbColor,colorByNumeric:r.bbColorMode===`numeric`,maxRadius:r.bbMaxRadius,backgroundToken:i,onPlotContextMenu:a}),e)}case`treemap`:{let e=n.treemapDataByPanel[c]??[];return e.length===0?s:o(q(jq,{nodes:e,backgroundToken:i,onPlotContextMenu:a}),e)}case`sankey`:{let e=n.sankeyDataByPanel[c]??{nodeNames:[],links:[]};return e.links.length===0?s:o(q(Lq,{nodeNames:e.nodeNames,links:e.links,backgroundToken:i,onPlotContextMenu:a}),e)}case`calibration`:{if(r?.kind!==`calibration`)return s;let e=n.calibrationDataByPanel[c]??[];return e.length===0?s:o(q(zq,{bins:e,color:r.cbColor,backgroundToken:i,onPlotContextMenu:a}),e)}case`qqplot`:{if(r?.kind!==`qqplot`)return s;let e=n.qqPlotDataByPanel[c];return!e||e.length===0?s:o(q(Vq,{points:e,color:r.qqColor,backgroundToken:i,onPlotContextMenu:a}),e)}case`gauge`:{if(r?.kind!==`gauge`)return s;let e=n.gaugeDataByPanel[c]??[];return e.length===0?s:o(q(nJ,{gauges:e,backgroundToken:i,onPlotContextMenu:a}),e)}case`gantt`:{let e=n.ganttDataByPanel[c]??[];return e.length===0?s:o(q(Kq,{tasks:e,backgroundToken:i,onPlotContextMenu:a}),e)}}return s}var ZJ=500,QJ=1e3;function $J(e){if(Array.isArray(e))return eY(e);if(!e||typeof e!=`object`)return null;let t=-1;for(let n of Object.values(e))Array.isArray(n)&&(t=Math.max(t,eY(n)));return t<0?null:t}function eY(e){let t=e=>!!e&&typeof e==`object`&&e.x instanceof Float64Array;return e.length>0&&t(e[0])?e.reduce((e,n)=>e+(t(n)?n.length:0),0):e.length}function tY(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function nY({stats:e,host:t}){let[n,r]=Ze(null);if(W(()=>{let n=t.current?.ownerDocument.defaultView??window,i=0,a=0,o=0,s=-1,c=-1,l=e.renders,u=t.current?iV(t.current):0,d=f=>{c>=0&&f-s>QJ&&(c=f,s=f,a=0,o=0,l=e.renders,u=t.current?iV(t.current):0),c<0?(c=f,s=f):f!==s&&(o=Math.max(o,f-s),s=f,a++);let p=f-c;if(p>=ZJ){let i=t.current,s=0;if(i)for(let e of i.getElementsByTagName(`canvas`))s+=e.width*e.height;let d=n.performance.memory,m=i?iV(i):0;r({fps:a*1e3/p,repaints:(m-u)*1e3/p,worstFrameMs:o,renderMs:e.lastRenderMs,rendersPerSec:(e.renders-l)*1e3/p,points:$J(e.data),domNodes:i?i.getElementsByTagName(`*`).length:0,canvasMp:s/1e6,heapMb:d?d.usedJSHeapSize/1048576:null}),a=0,o=0,c=f,l=e.renders,u=m}i=n.requestAnimationFrame(d)};return i=n.requestAnimationFrame(d),()=>n.cancelAnimationFrame(i)},[e,t]),!n)return null;let i=n.fps<20?`var(--danger, #e5484d)`:n.fps<45?`var(--accent, #f5a524)`:void 0;return q(`dl`,{className:`kymo-perf-hud`,style:rY,children:[[`FPS`,n.fps.toFixed(0),i],[`Repaints/s`,n.repaints.toFixed(0)],[`Slowest frame`,`${n.worstFrameMs.toFixed(1)} ms`],[`Render`,`${n.renderMs.toFixed(1)} ms`],[`Renders/s`,n.rendersPerSec.toFixed(1)],...n.points===null?[]:[[`Points`,tY(n.points)]],[`DOM nodes`,tY(n.domNodes)],[`Canvas`,`${n.canvasMp.toFixed(2)} MP`],...n.heapMb===null?[]:[[`JS heap`,`${n.heapMb.toFixed(0)} MB`]]].map(([e,t,n])=>nt(`div`,{style:iY,children:[q(`dt`,{style:aY,children:e}),q(`dd`,{style:n?{...oY,color:n}:oY,children:t})]},e))})}var rY={position:`absolute`,top:8,right:8,zIndex:60,flex:`none`,pointerEvents:`none`,userSelect:`none`,margin:0,padding:`6px 9px`,minWidth:148,display:`grid`,gap:1,font:`500 10.5px/1.35 var(--font-sans, system-ui)`,fontVariantNumeric:`tabular-nums`,fontFeatureSettings:`"tnum" 1`,color:`var(--text-strong, #f3f5fa)`,background:`color-mix(in oklch, var(--bg-elevated, #1b2130) 86%, transparent)`,border:`1px solid var(--border, #33405a)`,borderRadius:6,boxShadow:`0 4px 14px color-mix(in oklch, black 28%, transparent)`},iY={display:`flex`,justifyContent:`space-between`,gap:12},aY={color:`var(--text-muted, #8a93a6)`},oY={margin:0,fontWeight:600,textAlign:`right`},sY=3,cY=`data-kymo-annotation-controls`;function lY(e,t,n,r){return e.anchor===`x`&&!r?null:e.points.map(([i,a])=>[e.anchor===`x`?uV(r,i):i*t,a*n])}function uY(e,t,n,r,i){return t.map(([t,a])=>[e.anchor===`x`&&i?dV(i,t):dY(t/Math.max(1,n)),dY(a/Math.max(1,r))])}var dY=e=>Math.round(e*1e4)/1e4,fY=Ge(function({annotations:e,tool:t,plotFrame:n,onChange:r,onToolEnd:i,onSelect:a}){let o=K(null),s=Qe(n.subscribe,n.get),c=s?.x?s:null,[l,u]=Ze({w:0,h:0}),[d,f]=Ze(null),[p,m]=Ze(null),[h,g]=Ze(null),_=K({annotations:e,onChange:r,onToolEnd:i,onSelect:a,tool:t,selected:d,editing:p,frame:c,size:l});_.current={annotations:e,onChange:r,onToolEnd:i,onSelect:a,tool:t,selected:d,editing:p,frame:c,size:l};let v=e=>{_.current.selected!==e&&(_.current.selected=e,f(e),_.current.onSelect(e))};G(()=>{let e=o.current;if(!e)return;let t=e.ownerDocument.defaultView??window,n=()=>u({w:e.clientWidth,h:e.clientHeight});n();let r=new t.ResizeObserver(n);return r.observe(e),()=>r.disconnect()},[]),W(()=>{t&&v(null)}),W(()=>{d&&!e.some(e=>e.id===d)&&v(null)}),W(()=>()=>{_.current.selected&&_.current.onSelect(null)},[]),W(()=>{let e=o.current?.ownerDocument;if(!e)return;let t=e=>{let{selected:t,editing:n,tool:r,annotations:i,onChange:a,onToolEnd:o}=_.current;if(!(n||xY(e.target))){if(e.key===`Escape`&&r){o();return}t&&(e.key===`Delete`||e.key===`Backspace`?(e.preventDefault(),a(i.filter(e=>e.id!==t)),v(null)):e.key===`Escape`&&v(null))}},n=e=>{let t=_.current.selected,n=e.target;t&&!n?.closest?.(`[data-ann-id="${CSS.escape(t)}"], [data-kymo-annotation-controls]`)&&v(null)};return e.addEventListener(`keydown`,t),e.addEventListener(`pointerdown`,n,!0),()=>{e.removeEventListener(`keydown`,t),e.removeEventListener(`pointerdown`,n,!0)}},[]);let{w:y,h:b}=l,x=e=>{let t=o.current.getBoundingClientRect();return[e.clientX-t.left,e.clientY-t.top]},S=(e,t)=>{let n=o.current.ownerDocument,r=t=>e(x(t),t),i=()=>{n.removeEventListener(`pointermove`,r),n.removeEventListener(`pointerup`,i),n.removeEventListener(`pointercancel`,i),t()};n.addEventListener(`pointermove`,r),n.addEventListener(`pointerup`,i),n.addEventListener(`pointercancel`,i)},C=e=>r([..._.current.annotations,e]),w=e=>r(_.current.annotations.map(t=>t.id===e.id?e:t)),T=e=>{if(!t||e.button!==0||p)return;e.preventDefault(),e.stopPropagation();let n=x(e),r={id:crypto.randomUUID(),kind:t.kind,color:t.color,width:t.width,...c?{anchor:`x`}:{}},i=e=>uY(r,e,y,b,c);if(t.kind===`text`){g({...r,points:i([n]),text:``}),m(r.id);return}let a=t.kind===`brush`?[n]:[n,n],o={...r,points:i(a)};g(o);let s=!1;S((t,n)=>{if(s||=Math.hypot(n.clientX-e.clientX,n.clientY-e.clientY)>sY,r.kind===`brush`){let e=a[a.length-1];if(Math.hypot(t[0]-e[0],t[1]-e[1])<2)return;a=[...a,t]}else a=[a[0],t];o={...o,points:i(a)},g(o)},()=>{g(null),s&&o.points.length>=2&&C(o)})},E=(e,t,n)=>{let r=lY(t,y,b,c);if(!r)return;let i=x(e),a=null;S((o,s)=>{if(!a&&Math.hypot(s.clientX-e.clientX,s.clientY-e.clientY)<=sY)return;let{size:c,frame:l}=_.current;a={...t,points:uY(t,n(r,[o[0]-i[0],o[1]-i[1]],o),c.w,c.h,l)},g(a)},()=>{g(null),a&&w(a)})},D=(e,n)=>{t||e.button!==0||p===n.id||(e.preventDefault(),e.stopPropagation(),v(n.id),E(e,n,(e,[t,n])=>e.map(([e,r])=>[e+t,r+n])))},O=(e,t,n)=>{e.button===0&&(e.preventDefault(),e.stopPropagation(),E(e,t,(e,r,i)=>{let a=e.map(e=>[...e]);return t.kind===`arrow`?a[n]=i:(a[+(n===1||n===2)][0]=i[0],a[+(n===2||n===3)][1]=i[1]),a}))},k=e=>{t||e.kind!==`text`&&e.kind!==`box`||(v(e.id),m(e.id))},A=e=>{let t=p;m(null);let n=h&&h.id===t?h:null;if(g(null),e===null||!t)return;let i=e.replace(/\s+$/,``),a=_.current.annotations;if(n){i&&C({...n,text:i});return}let o=a.find(e=>e.id===t);o&&(!i&&o.kind===`text`?r(a.filter(e=>e.id!==t)):w(bY(o,i)))},j=e=>{r(_.current.annotations.filter(t=>t.id!==e)),v(null)},M=(h?e.some(e=>e.id===h.id)?e.map(e=>e.id===h.id?h:e):[...e,h]:e).flatMap(e=>{let t=lY(e,y,b,c);return t?[{a:e,px:t}]:[]}),N=d?M.find(e=>e.a.id===d):void 0,P=N&&N.a.kind!==`text`?yY(N.px):null,F=e=>nt(tt,{children:[q(`svg`,{className:`kymo-ann-svg`,width:y,height:b,viewBox:`0 0 ${y} ${b}`,"aria-hidden":`true`,children:e.map(({a:e,px:t})=>e.kind===`text`?null:q(`g`,{"data-ann-id":e.id,className:`kymo-ann kymo-ann--${e.kind}`,onPointerDown:t=>D(t,e),onDoubleClick:()=>k(e),children:q(hY,{a:e,px:t})},e.id))}),e.map(({a:e,px:t})=>{if(e.kind!==`text`&&e.kind!==`box`)return null;let n=p===e.id;if(!n&&!e.text)return null;let r=e.kind===`text`?{left:t[0][0],top:t[0][1]}:{left:Math.min(t[0][0],t[1][0]),top:Math.min(t[0][1],t[1][1]),transform:`translateY(calc(-100% - 3px))`};return nt(`div`,{"data-ann-id":e.id,className:`kymo-ann-text kymo-ann-text--${e.kind}${d===e.id&&e.kind===`text`?` is-selected`:``}`,style:{...r,color:e.color,fontSize:e.kind===`text`?e.width:12},onPointerDown:t=>D(t,e),onDoubleClick:()=>k(e),children:[n?q(mY,{initial:e.text??``,onDone:A}):e.text,d===e.id&&e.kind===`text`&&!n?q(pY,{onDelete:()=>j(e.id),style:{right:-11,top:-11}}):null]},`t-${e.id}`)})]});return q(`div`,{ref:o,className:`kymo-annotations${t?` is-drawing is-tool-${t.kind}`:``}`,onPointerDown:T,onContextMenu:t?e=>e.preventDefault():void 0,children:y>0&&b>0?nt(tt,{children:[F(M.filter(e=>e.a.anchor!==`x`)),c?q(`div`,{className:`kymo-ann-clip`,style:{clipPath:`inset(0 ${Math.max(0,y-c.left-c.width)}px 0 ${Math.max(0,c.left)}px)`},children:F(M.filter(e=>e.a.anchor===`x`))}):null,nt(`svg`,{className:`kymo-ann-svg`,width:y,height:b,viewBox:`0 0 ${y} ${b}`,"aria-hidden":`true`,children:[P?q(`rect`,{className:`kymo-ann-selection`,x:P.x-6,y:P.y-6,width:P.w+12,height:P.h+12,rx:4}):null,N&&!p&&(N.a.kind===`box`||N.a.kind===`arrow`)?q(`g`,{"data-ann-id":N.a.id,children:gY(N.a,N.px).map(([e,t],n)=>q(`rect`,{className:`kymo-ann-handle kymo-ann-handle--${N.a.kind===`arrow`?`end`:n%2?`nesw`:`nwse`}`,x:e-4.5,y:t-4.5,width:9,height:9,rx:2,onPointerDown:e=>O(e,N.a,n)},n))}):null]}),P&&!p?q(pY,{onDelete:()=>j(N.a.id),id:N.a.id,style:{left:Math.min(y-12,P.x+P.w+6)-10,top:Math.max(10,P.y-6)-10}}):null]}):null})});function pY({onDelete:e,style:t,id:n}){return q(`button`,{type:`button`,className:`kymo-ann-delete`,style:t,"data-ann-id":n,"aria-label":`Delete annotation`,title:`Delete (Del)`,onPointerDown:e=>e.stopPropagation(),onClick:e,children:q(`svg`,{viewBox:`0 0 10 10`,width:`8`,height:`8`,"aria-hidden":`true`,children:q(`path`,{d:`M2 2l6 6M8 2l-6 6`})})})}function mY({initial:e,onDone:t}){let n=K(null),r=K(!1),i=e=>{r.current||(r.current=!0,t(e))};return G(()=>{let t=n.current;if(!t)return;t.textContent=e,t.focus();let r=t.ownerDocument.createRange();r.selectNodeContents(t);let i=t.ownerDocument.defaultView?.getSelection();i?.removeAllRanges(),i?.addRange(r)},[]),q(`div`,{ref:n,className:`kymo-ann-editor`,contentEditable:`plaintext-only`,suppressContentEditableWarning:!0,role:`textbox`,"aria-label":`Annotation text`,"aria-multiline":`true`,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),i(n.current?.innerText??``)):e.key===`Escape`&&(e.preventDefault(),i(null))},onBlur:()=>i(n.current?.innerText??``)})}function hY({a:e,px:t}){let n={stroke:e.color,strokeWidth:e.width,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`},r=t=>q(`path`,{className:`kymo-ann-hit`,d:t,strokeWidth:Math.max(12,e.width+10)});switch(e.kind){case`box`:{let[[i,a],[o,s]]=t,c=`M${i} ${a}H${o}V${s}H${i}Z`;return nt(tt,{children:[r(c),q(`path`,{d:c,...n}),q(`path`,{d:c,fill:e.color,fillOpacity:.06,stroke:`none`,pointerEvents:`none`})]})}case`arrow`:{let[[i,a],[o,s]]=t,c=vY(i,a,o,s,e.width);return nt(tt,{children:[r(`M${i} ${a}L${o} ${s}`),q(`path`,{d:`M${i} ${a}L${c.base[0]} ${c.base[1]}`,...n}),q(`path`,{d:c.d,fill:e.color,stroke:e.color,strokeWidth:1,strokeLinejoin:`round`})]})}case`brush`:{let e=_Y(t);return nt(tt,{children:[r(e),q(`path`,{d:e,...n})]})}}return null}function gY(e,t){if(e.kind===`arrow`)return t;let[[n,r],[i,a]]=t;return[[n,r],[i,r],[i,a],[n,a]]}function _Y(e){if(e.length===0)return``;if(e.length<3)return`M${e[0][0]} ${e[0][1]}`+e.slice(1).map(([e,t])=>`L${e} ${t}`).join(``);let t=`M${e[0][0]} ${e[0][1]}`;for(let n=1;n<e.length-1;n++){let[r,i]=e[n],[a,o]=e[n+1];t+=`Q${r} ${i} ${(r+a)/2} ${(i+o)/2}`}let[n,r]=e[e.length-1];return t+`L${n} ${r}`}function vY(e,t,n,r,i){let a=Math.max(9,i*4),o=Math.atan2(r-t,n-e),s=.42,c=[n-a*Math.cos(o-s),r-a*Math.sin(o-s)],l=[n-a*Math.cos(o+s),r-a*Math.sin(o+s)],u=[n-a*.8*Math.cos(o),r-a*.8*Math.sin(o)];return{d:`M${n} ${r}L${c[0]} ${c[1]}L${l[0]} ${l[1]}Z`,base:u,l:c,r:l}}function yY(e){let t=e.map(e=>e[0]),n=e.map(e=>e[1]),r=Math.min(...t),i=Math.min(...n);return{x:r,y:i,w:Math.max(...t)-r,h:Math.max(...n)-i}}function bY(e,t){if(t)return{...e,text:t};let{text:n,...r}=e;return r}function xY(e){let t=e;return!!t&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))}function SY(e,t,n,r,i,a,o){e.save(),e.scale(i,i),e.lineCap=`round`,e.lineJoin=`round`;for(let i of t){let t=lY(i,n,r,o);t&&(e.save(),i.anchor===`x`&&o&&(e.beginPath(),e.rect(o.left,0,o.width,r),e.clip()),CY(e,i,t,a),e.restore())}e.restore()}function CY(e,t,n,r){if(e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.width,t.kind===`box`)e.strokeRect(n[0][0],n[0][1],n[1][0]-n[0][0],n[1][1]-n[0][1]);else if(t.kind===`brush`)e.stroke(new Path2D(_Y(n)));else if(t.kind===`arrow`){let r=vY(n[0][0],n[0][1],n[1][0],n[1][1],t.width);e.beginPath(),e.moveTo(n[0][0],n[0][1]),e.lineTo(r.base[0],r.base[1]),e.stroke(),e.beginPath(),e.moveTo(n[1][0],n[1][1]),e.lineTo(r.l[0],r.l[1]),e.lineTo(r.r[0],r.r[1]),e.closePath(),e.fill()}if(!t.text)return;let i=t.kind===`text`?t.width:12;e.font=`600 ${i}px ${r}`,e.textBaseline=`top`;let a=t.text.split(`
612
+ `),o=i*1.25,s=n[0][0],c=n[0][1];t.kind===`box`&&(s=Math.min(n[0][0],n[1][0]),c=Math.min(n[0][1],n[1][1])-a.length*o-7),a.forEach((t,n)=>e.fillText(t,s+6,c+2+n*o))}var wY={solid:void 0,dashed:`5 4`,dotted:`1 4`};function TY(e,t,n){if(!e||!(n===`x`?e.x:e.y))return null;if(n===`x`){let n=uV(e,t.value);return n>=e.left-.5&&n<=e.left+e.width+.5?[n,e.top,n,e.top+e.height]:null}let r=fV(e,t.value);return r>=e.top-.5&&r<=e.top+e.height+.5?[e.left,r,e.left+e.width,r]:null}var EY=Ge(function({frame:e,alarm:t,axis:n}){let r=TY(Qe(e.subscribe,e.get),t,n);return r?q(`svg`,{className:`kymo-alarm`,"aria-hidden":`true`,children:q(`line`,{x1:r[0],y1:r[1],x2:r[2],y2:r[3],stroke:t.color,strokeWidth:t.width,strokeDasharray:wY[t.style]})}):null});function DY(e,t,n,r,i){let a=TY(t,n,r);a&&(e.save(),e.scale(i,i),e.strokeStyle=n.color,e.lineWidth=n.width,e.setLineDash(wY[n.style]?.split(` `).map(Number)??[]),e.beginPath(),e.moveTo(a[0],a[1]),e.lineTo(a[2],a[3]),e.stroke(),e.restore())}function OY(e,t,n){return e.handlers?.wsId===n?e.handlers:e.handlers={wsId:n,onViewXRangeChange:r=>{t.view.setXRange(r,n),e.emitter.emit(`viewchange`,r)},onContextMenu:t=>e.emitter.emit(`contextmenu`,t),xyzRef:t=>{e.xyz=t},onAnnotations:n=>t.charts.setAnnotations(e.chartId,n),onAnnotationToolEnd:()=>{e.annotationTool=null,NY(t).bump(),e.emitter.emit(`annotationtool`,null)},onAnnotationSelect:t=>{e.selectedAnnotation=t,e.emitter.emit(`annotationselect`,t)}}}var kY=new WeakMap;function AY(e){let t=kY.get(e);return t||kY.set(e,t=t=>e.view.setLiveWindow(t)),t}var jY=class{mounts=new Map;version=0;listeners=new Set;root=null;engine;constructor(e){this.engine=e}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getVersion=()=>this.version;bump(){this.version++;for(let e of[...this.listeners])e()}add(e){this.mounts.set(e.key,e),this.root||(this.root=et(document.createElement(`div`)),this.root.render(q(zY,{engine:this.engine,registry:this}))),this.bump()}remove(e){this.mounts.delete(e)&&this.bump()}refresh(){this.bump()}dispose(){this.mounts.clear(),this.root?.unmount(),this.root=null}},MY=new WeakMap;function NY(e){let t=MY.get(e);return t||(t=new jY(e),MY.set(e,t)),t}function PY(e,t,n,r={}){e.charts.get(t);let i=NY(e),a={key:crypto.randomUUID(),chartId:t,element:n,options:r,shiftDatasetId:null,emitter:cB(),xyz:null,annotationTool:null,selectedAnnotation:null,plotFrame:hV(),status:null,data:null};i.add(a);let o=!1;return{chartId:t,status:()=>a.status,data:()=>a.data,on:(e,t)=>a.emitter.on(e,t),exportPng(){let r=Array.from(n.querySelectorAll(`canvas`));if(r.length===0)return Promise.reject(new tE(`export_failed`,{reason:`nothing to export`}));let i=document.createElement(`canvas`);i.width=r[0].width,i.height=r[0].height;let o=i.getContext(`2d`);if(!o)return Promise.reject(new tE(`export_failed`,{reason:`canvas unavailable`}));for(let e of r)o.drawImage(e,0,0);let s=e.charts.get(t),c=s.annotations,l=jn(s.settings);return l&&n.clientWidth>0&&DY(o,a.plotFrame.get(),l.alarm,l.axis,i.width/n.clientWidth),c.length&&n.clientWidth>0&&SY(o,c,n.clientWidth,n.clientHeight,i.width/n.clientWidth,Q.sans,a.plotFrame.get()?.x?a.plotFrame.get():null),new Promise((e,t)=>i.toBlob(n=>n?e(n):t(new tE(`export_failed`,{reason:`encode failed`})),`image/png`))},autoscale(){a.xyz?.autoscale()},setShiftMode(e){a.shiftDatasetId!==e&&(a.shiftDatasetId=e,i.bump())},setAnnotationTool(e){a.annotationTool=e?{...e}:null,i.bump()},annotationTool:()=>a.annotationTool,selectedAnnotation:()=>a.selectedAnnotation,setOptions(e){a.options={...e},i.bump()},destroy(){o||(o=!0,a.emitter.clear(),i.remove(a.key))}}}function FY(e){MY.get(e)?.refresh()}function IY(e){MY.get(e)?.dispose(),MY.delete(e)}function LY(e){let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-color-scheme`,`class`,`data-theme`]}),()=>t.disconnect()}var RY=()=>{let e=document.documentElement;return`${e.getAttribute(`data-color-scheme`)??``}|${e.getAttribute(`data-theme`)??``}|${e.className}`};function zY({engine:e,registry:t}){Qe(t.subscribe,t.getVersion);let n=nZ(e),r=Qe(n.store.subscribe,n.store.get),i=new Map;for(let e of t.mounts.values()){let t=r.worksheets.find(t=>t.panels.some(t=>t.id===e.chartId));if(!t)continue;let n=i.get(t.id)??{worksheet:t,mounts:[]};n.mounts.push(e),i.set(t.id,n)}return q(tt,{children:[...i.values()].map(t=>q(UY,{engine:e,worksheet:t.worksheet,mounts:t.mounts},t.worksheet.id))})}var BY=1e3,VY=.25;function HY(e,t,n){let[r,i]=Ze(0),a=K(0),o=K(0);return W(()=>{a.current&&=(o.current=performance.now()-a.current,0)}),W(()=>{if(!n)return;let r=0,s=-1,c=0,l=n=>{if(r=eV(l),a.current||n<c||aV())return;let u=0;for(let n of e)t.includes(n.id)&&(u+=n.source.version());u!==s&&(s=u,c=n+o.current*(1/VY-1),a.current=performance.now(),Ke(()=>i(e=>e+1)))};return r=eV(l),()=>tV(r)},[n,e,t]),Xe(()=>n?e.map(e=>t.includes(e.id)?{...e,dataset:e.source.snapshot(BY)}:e):e,[e,t,n,r])}function UY({engine:e,worksheet:t,mounts:n}){let r=nZ(e),i=Qe(r.store.subscribe,r.store.get),a=r.derived(),o=i.xRanges[t.id]??null,s=i.live.filter(e=>i.selection.includes(e.id)).length,c=e=>{let n=t.panelChartSettings[e];return n?.kind===`multiband`&&n.beacon?.enabled===!0},l=s>0&&t.panels.some(e=>e.kind!==`multiband`||s>1&&!c(e.id)),u=HY(i.live,i.selection,l),d=IJ({worksheet:t,viewXRange:o,selectedIds:i.selection,selectedDatasets:a.selectedDatasets,liveConnections:u,mathChannels:a.channels,datasetOffsets:i.offsets,datasetColors:i.colors,datasetPalette:i.palette}),f=K(oB()).current,p=Qe(LY,RY),m=t.id,h=AY(e),g=i.licensed,_=i.live.find(e=>i.selection.includes(e.id))??null,v=e=>i.datasets.find(t=>t.id===e)??Object.values(a.laps).flatMap(e=>e.laps).find(t=>t.id===e);return q(tt,{children:n.map(n=>{let r=t.panels.find(e=>e.id===n.chartId);if(!r)return null;let s=n.shiftDatasetId?a.selectedDatasets.find(e=>e.id===n.shiftDatasetId):void 0,c=OY(n,e,m);return $e(q(JY,{mount:n,annotations:t.panelChartSettings[r.id]?.annotations,alarm:jn(t.panelChartSettings[r.id]),onAnnotations:c.onAnnotations,onAnnotationToolEnd:c.onAnnotationToolEnd,onAnnotationSelect:c.onAnnotationSelect,render:a=>XJ({panel:r,settings:t.panelChartSettings[r.id],background:n.options.style?.background??t.panelChartBackgrounds[r.id]??null,styleToken:JSON.stringify([p,n.options.theme,n.options.style,Q]),data:d,xKey:t.xKey,height:a,viewXRange:o,onViewXRangeChange:c.onViewXRangeChange,liveZoom:f,liveWindowSeconds:i.liveWindowSeconds,onLiveWindowChange:h,beaconLive:_,findDataset:v,shiftMode:s?WY(e,s.id,s.name):void 0,onContextMenu:c.onContextMenu,xyzRef:c.xyzRef}),licensed:g},n.key),n.element,n.key)})})}function WY(e,t,n){let r=0;return{label:n,onDragStart:()=>{r=e.getState().datasets.find(e=>e.id===t)?.offset??0},onDragOffset:n=>e.datasets.setOffset(t,r+n)}}var GY=[];function KY(e,t){e.data=t}function qY(e,t){e.status!==t&&(e.status=t,e.emitter.emit(`status`,t))}function JY({mount:e,render:t,licensed:n,annotations:r,alarm:i,onAnnotations:a,onAnnotationToolEnd:o,onAnnotationSelect:s}){let c=K(null),[l,u]=Ze(0),d=!!e.options.debug,f=K({renderStart:0,lastRenderMs:0,renders:0,data:null}).current;d&&(f.renderStart=performance.now()),G(()=>{d&&(f.lastRenderMs=performance.now()-f.renderStart,f.renders++)}),G(()=>{let e=c.current;if(!e)return;let t=()=>u(Math.max(120,Math.floor(e.clientHeight)));t();let n=new oV(t);return n.observe(e),()=>n.disconnect()},[]);let{status:p,node:m,data:h}=t(l||400);f.data=h,W(()=>{KY(e,h)}),W(()=>{qY(e,p)});let{theme:g,style:_,className:v}=e.options,y={};return _?.background&&(y[`--chart-bg`]=_.background),_?.muted&&(y[`--chart-muted`]=_.muted),_?.grid&&(y[`--chart-grid`]=_.grid),_?.accent&&(y[`--accent`]=_.accent),nt(`div`,{ref:c,onContextMenu:p===`ready`?void 0:t=>{t.preventDefault(),e.emitter.emit(`contextmenu`,{clientX:t.clientX,clientY:t.clientY})},className:v?`kymo-chart ${v}`:`kymo-chart`,"data-color-scheme":g,"data-status":p,style:y,children:[q(gV.Provider,{value:e.plotFrame.set,children:m}),p===`ready`&&i?q(EY,{frame:e.plotFrame,alarm:i.alarm,axis:i.axis}):null,p===`ready`&&(r?.length||e.annotationTool)?q(fY,{annotations:r??GY,tool:e.annotationTool,plotFrame:e.plotFrame,onChange:a,onToolEnd:o,onSelect:s}):null,d?q(nY,{stats:f,host:c}):null,n===!1?q(sB,{}):null]})}var YY=new WeakMap;function XY(e,t,n,r={}){let i=YY.get(e)??new Map;YY.set(e,i);let a=i.get(t);if(a&&!a.window.closed)return a.window.focus(),a;let o=e.charts.get(t),s=r.title??(o.title||e.charts.label(o.kind)),c=window.open(``,`kymoscope-chart-${t}`,`popup,width=${r.width??960},height=${r.height??600}`);if(!c)throw new tE(`popup_blocked`,{chartId:t});let l=c.document;l.head.replaceChildren(),l.body.replaceChildren(),l.title=s;for(let e of document.querySelectorAll(`style, link[rel="stylesheet"]`)){let t=e.cloneNode(!0);t instanceof HTMLLinkElement&&(t.href=e.href),l.head.appendChild(t)}let u=()=>{for(let e of[...l.documentElement.attributes])l.documentElement.removeAttribute(e.name);for(let e of document.documentElement.attributes)l.documentElement.setAttribute(e.name,e.value);l.body.className=document.body.className};u();let d=new MutationObserver(u);d.observe(document.documentElement,{attributes:!0}),d.observe(document.body,{attributes:!0,attributeFilter:[`class`]}),Object.assign(l.body.style,{margin:`0`,position:`fixed`,inset:`0`,display:`flex`,flexDirection:`column`,background:getComputedStyle(document.body).backgroundColor});let f=l.createElement(`div`);f.className=`kymo-window-controls`;let p=l.createElement(`div`);p.className=`kymo-window-plot`,Object.assign(p.style,{flex:`1`,minHeight:`0`,position:`relative`}),l.body.append(f,p),YB(c);let m=n(p,r.mount),h=cB(),g=!1,_=()=>{g||(g=!0,i.delete(t),XB(c),d.disconnect(),y(),window.removeEventListener(`pagehide`,v),m.destroy(),h.emit(`close`,void 0),h.clear())},v=()=>b.close(),y=e.subscribe(()=>{try{e.charts.get(t)}catch{b.close()}});c.addEventListener(`pagehide`,_),window.addEventListener(`pagehide`,v);let b={chartId:t,window:c,controls:f,view:m,close(){_(),c.closed||c.close()},on:(e,t)=>h.on(e,t)};return i.set(t,b),b}function ZY(e){for(let t of[...YY.get(e)?.values()??[]])t.close()}var QY=12e3,$Y=100;function eX(e,t=!1){let n,r=0;if(t&&e instanceof Float64Array){n=e;let t=0,i=0,a=0,o=n.length&-4;for(let e=0;e<o;e+=4)r+=n[e]*0,t+=n[e+1]*0,i+=n[e+2]*0,a+=n[e+3]*0;for(let e=o;e<n.length;e++)r+=n[e]*0;r+=t+i+a}else{n=new Float64Array(e.length);for(let t=0;t<n.length;t++){let i=+e[t];n[t]=i,r+=i*0}}if(r===0)return ze.add(n),n;for(let e=0;e<n.length;e++){let t=n[e];t-t!==0&&(n[e]=NaN)}return n}function tX(e,t){let n=Object.keys(t.columns);if(n.length===0)throw new tE(`no_columns`);let r=t.columns[n[0]].length;if(n.some(e=>t.columns[e].length!==r))throw new tE(`column_length_mismatch`);let i=new Map(n.map(e=>[e,eX(t.columns[e],t.transfer)]));return nX(e,t.name,i,t.units??{})}function nX(e,t,n,r,i,a){let o=[...n.keys()],s=n.get(o[0]).length,c=o.map(e=>r[e]??``),l=o.map((e,t)=>({name:e,type:`number`,unit:c[t]})),u=!!a&&a.schema.length===o.length&&a.schema.every((e,t)=>e.name===o[t]),d,f;if(u)d=a.rawText??``,f=a.parseConfig;else{let e=[o.join(`,`)];for(let t=0;t<Math.min(s,$Y);t++)e.push(o.map(e=>{let r=n.get(e)[t];return r===r?String(r):``}).join(`,`));d=e.join(`
613
+ `),f=h(d)}let p={id:e,name:t,schema:l,rawText:d,parseConfig:f,fromColumns:!0};if(s>1e6){let e=new vJ(n,r);return{...p,kind:`columnar`,source:e,data:{meta:``,columnNames:o,units:c,rows:e.sampleRowsSync(QY)}}}let m={meta:``,columnNames:o,units:c,rows:R({keys:o,length:s,values:o.map(e=>n.get(e)),text:o.map(()=>null)},i)};return{...p,kind:`memory`,source:new lE(m),data:m}}function rX(e,t,n){let r=e.fromColumns?iX(e):null;if(!r)throw new tE(`invalid_argument`,{reason:`only datasets added with addColumns can be written`});let i=r.values().next().value.length,a=e.columnSpares??new Map,o={};for(let e of t){let t=a.get(e);t&&t.length===i&&t!==r.get(e)?(he(t),o[e]=t):o[e]=new Float64Array(i)}n(o,Object.fromEntries(t.map(e=>[e,r.get(e)])));let s=new Map(a);for(let e of t){let t=r.get(e);t?s.set(e,t):s.delete(e)}return{...aX(e,o,!0),columnSpares:s}}function iX(e){if(e.source instanceof vJ)return new Map(e.source.columnMap);let t=P(e.data.rows);return t?new Map(t.keys.map((e,n)=>[e,t.values[n]])):null}function aX(e,t,n=!1){let r=e.fromColumns?iX(e):null;if(!r)throw new tE(`invalid_argument`,{reason:`only datasets added with addColumns can be replaced`});let i=r;for(let e of Object.keys(t))i.set(e,eX(t[e],n));let a=i.values().next().value.length;for(let e of i.values())if(e.length!==a)throw new tE(`column_length_mismatch`);let o=Object.fromEntries(e.schema.map(e=>[e.name,e.unit])),s=nX(e.id,e.name,i,o,e.kind===`memory`?e.data.rows:void 0,e),c=s.schema.length===e.schema.length&&s.schema.every((t,n)=>t.name===e.schema[n].name);return{...s,schema:c?e.schema:s.schema,beacon:e.beacon}}var oX=new WeakMap;function sX(e){let t=e.fromColumns?iX(e):null;if(!t)return e.rawText??``;let n=e.data.rows,r=oX.get(n);if(r===void 0){let e=[...t.keys()],i=e.map(e=>t.get(e)),a=[e.join(`,`)],o=i[0].length;for(let e=0;e<o;e++)a.push(i.map(t=>t[e]===t[e]?String(t[e]):``).join(`,`));oX.set(n,r=a.join(`
614
+ `))}return r}function cX(e){let t=e,n=new Set;return{get:()=>t,set(e){let r=e(t);if(r!==t){t=r;for(let e of[...n])try{e()}catch(e){console.error(`[kymoscope] subscriber failed`,e)}}},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}function lX(e){let t=null,n;return(...r)=>t&&t.length===r.length&&t.every((e,t)=>e===r[t])?n:(t=r,n=e(...r),n)}function uX(){let e=lX(e=>{let t={};for(let n of e){if(!n.beacon||n.kind!==`memory`)continue;let{channel:e,metric:r,stat:i}=n.beacon,a=dz(n.data.rows,e);if(a.length===0)continue;let o=n.data.units[n.data.columnNames.indexOf(r)]??``;t[n.id]={laps:a.map((e,t)=>{let r={...n.data,rows:n.data.rows.slice(e.start,e.end)};return{...n,id:yz(n.id,t),name:`${n.name} · Cycle ${t+1}`,data:r,source:new lE(r)}}),values:a.map(e=>hz(n.data.rows,e,r,i)),unit:o,isTime:i===`span`&&_z(r,o)}}return t}),t=lX((e,t,n)=>e.flatMap(e=>t[e.id]?t[e.id].laps.filter(e=>n.includes(e.id)):n.includes(e.id)?[e]:[])),n=lX((e,t)=>e.filter(e=>t.includes(e.id))),r=lX(e=>gJ(e.map(e=>e.data))),i=lX((e,t)=>t.length===0?e:gJ(e?[e,...t.map(e=>e.dataset)]:t.map(e=>e.dataset))),a=lX((e,t,n)=>{let r=new Set;if(e)for(let t of n.length>0?n:[e])for(let e of _J(t.columnNames,t.rows))r.add(e);let i=e?e.columnNames.filter(e=>r.has(e)):[],a=t.filter(e=>e.kind!==`memory`).flatMap(e=>WR(e.schema));return[...new Set([...i,...a])]});return{lapsByDataset:e,selectedDatasets:t,selectedLive:n,staticDataset:r,mergedDataset:i,mergedParts:lX((e,t)=>[...e.map(e=>e.data),...t.map(e=>e.dataset)]),numericColumns:lX((e,t,n,r=[])=>{let i=a(e,t,r),o=new Set(i);return[...i,...n.map(e=>e.name).filter(e=>!o.has(e))]}),allColumns:lX((e,t,n)=>[...new Set([...e?.columnNames??[],...t.filter(e=>e.kind!==`memory`).flatMap(e=>e.schema.map(e=>e.name)),...n.map(e=>e.name)])]),columnUnits:lX((e,t)=>{let n={};e&&e.columnNames.forEach((t,r)=>{let i=e.units[r]?.trim();i&&(n[t]=i)});for(let e of t)e.units&&(n[e.name]=e.units);return n})}}var dX=[{kind:`multiband`,label:`Multi-band`},{kind:`xyscatter`,label:`X-Y scatter`},{kind:`xyzmesh`,label:`X-Y-Z mesh`},{kind:`histogram`,label:`Histogram`},{kind:`polar`,label:`Polar`},{kind:`spectrum`,label:`Spectrum`},{kind:`boxplot`,label:`Box Plot`},{kind:`spectrogram`,label:`Spectrogram`},{kind:`heatmap`,label:`Heatmap`},{kind:`violin`,label:`Violin`},{kind:`confusion`,label:`Confusion Matrix`},{kind:`roc`,label:`ROC Curve`},{kind:`losscurve`,label:`Loss Curves`},{kind:`controlchart`,label:`Control Chart`},{kind:`parallelcoords`,label:`Parallel Coords`},{kind:`embedding`,label:`Embedding`},{kind:`flamegraph`,label:`Flame Graph`},{kind:`barchart`,label:`Bar Chart`},{kind:`radar`,label:`Radar`},{kind:`areachart`,label:`Area Chart`},{kind:`cdfchart`,label:`CDF / ECDF`},{kind:`bubblechart`,label:`Bubble Chart`},{kind:`treemap`,label:`Treemap`},{kind:`sankey`,label:`Sankey`},{kind:`calibration`,label:`Calibration Curve`},{kind:`gauge`,label:`Gauges`},{kind:`qqplot`,label:`Q-Q Plot`},{kind:`gantt`,label:`Gantt Chart`}],fX=new Map(dX.map(e=>[e.kind,e.label]));function pX(e){return fX.get(e)??e}var mX=`kymoscope-live.v1`,hX=2e3,gX=30,_X=1e4,vX=300,yX=90,bX=e=>e.startsWith(`eyJ`);function xX(e){try{let t=e.split(`.`)[1]??``,n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)+`===`.slice((t.length+3)%4)),r=JSON.parse(n).exp;return typeof r==`number`?r:null}catch{return null}}function SX(e,t){return`${e.replace(/\/+$/,``)}/v1/streams/${t}/watch`}function CX(e,t,n,r){let i=null,a=null,o=null,s=!1,c=()=>{o&&=(clearTimeout(o),null)},l=(n,r)=>{c();let a=xX(r);if(a===null)return;let u=bX(r),d=u?Math.min(a,Date.now()/1e3+vX):a,f=Math.min(Math.max((d-(u?yX:gX))*1e3-Date.now(),_X),2**31-1);o=setTimeout(async()=>{o=null;let r=null;try{r=await e.getToken(t)}catch{r=null}if(!(s||i!==n||!r)){try{n.send(JSON.stringify({type:`auth`,token:r}))}catch{return}l(n,r)}},f)},u=()=>{s||a||(a=setTimeout(()=>{a=null,d()},hX))},d=async()=>{if(s)return;let a=null;try{a=await e.getToken(t)}catch{a=null}if(s)return;if(!a){r?.(`error`),u();return}let o=new WebSocket(SX(e.url,t),[mX,`bearer.${a}`]);o.binaryType=`arraybuffer`,i=o;let d=a;o.onopen=()=>{r?.(`subscribed`),l(o,d)},o.onmessage=e=>{typeof e.data!=`string`&&n(e.data)},o.onclose=()=>{i===o&&(i=null,c(),!s&&(r?.(`error`),u()))}};return d(),()=>{if(s=!0,a&&=(clearTimeout(a),null),c(),i){let e=i;i=null,e.close(1e3)}}}var wX=class{#e;constructor(e){this.#e=typeof e==`function`?e:()=>e}size(){return this.#e().size}version(){return this.#e().version}columns(){let e=this.#e();return new TX(new Set(e.columnNames),t=>e.mirrorColumn(t))}snapshot(e){return this.#e().toDataset(e)}async getSchema(){let e=this.#e();return e.columnNames.map(t=>({name:t,type:`number`,unit:e.unitOf(t)}))}async getSeries(e){let t=this.#e();return s(t.columnValues(e.viewport.xKey),t.columnValues(e.column),e.viewport.x0,e.viewport.x1,e.maxPoints)}async getSeriesMulti(e,t,n){return this.getSeriesMultiSync(e,t,n)}getSeriesMultiSync(e,t,n){return this.#e().decimateColumns(t.xKey,e,t.x0,t.x1,n)}getPointsSync(e,t,n){return this.#e().decimatePoints(t.xKey,e,t.x0,t.x1,n)}async xBounds(e){return this.xBoundsSync(e)}xBoundsSync(e){return this.#e().columnBounds(e)}xTravelSync(e,t){return this.#e().xTravel(e,t)}latestTimeSync(){return this.#e().latestTime()}xAtTimeSync(e,t){return this.#e().xAtTime(e,t)}latestSync(e){return this.#e().lastValue(e)}latestValuesSync(e){let t=this.#e(),n=new Map;for(let r of e){let e=t.lastValue(r);Number.isFinite(e)&&n.set(r,e)}return n}trackCycles(e){this.#e().trackCycles(e)}cycleSpanSync(e){return this.#e().cycleSpan(e)}decimateCycleSync(e,t,n,r,i){return this.#e().decimateCycle(e,t,n,r.x0,r.x1,i)}cyclePointsSync(e,t,n,r,i){return this.#e().decimateCyclePoints(e,t,n,r.x0,r.x1,i)}async dispose(){}},TX=class extends Map{#e;#t;constructor(e,t){super(),this.#e=e,this.#t=t}get(e){if(!super.has(e)&&this.#e.has(e)){let t=this.#t(e);t&&super.set(e,t)}return super.get(e)}has(e){return this.#e.has(e)}},EX=4096,DX=5e3,OX=class{startedAt=Date.now();n=0;capacity=EX;time=new Float64Array(EX);cols=new Map;order=[];units=new Map;timeColumn;timeUnit;constructor(e=ae,t=`s`){this.timeColumn=e,this.timeUnit=t}get rows(){return this.n}add(e){this.n===this.capacity&&this.grow();let t=this.n;this.time[t]=e.t;for(let n of e.signals){let e=this.cols.get(n.name);e||(e=new Float64Array(this.capacity).fill(NaN),this.cols.set(n.name,e),this.order.push(n.name)),n.unit&&!this.units.get(n.name)&&this.units.set(n.name,n.unit),e[t]=typeof n.value==`number`?n.value:NaN}this.n++}addColumns(e){let t=we(e,this.timeColumn),n=e.t.length;for(;this.n+n>this.capacity;)this.grow();let r=this.n,i=(e,t)=>{if(t instanceof Float64Array||t instanceof Float32Array)e.set(t,r);else for(let i=0;i<n;i++)e[r+i]=+t[i]};i(this.time,e.t);for(let n of t){let t=this.cols.get(n);t||(t=new Float64Array(this.capacity).fill(NaN),this.cols.set(n,t),this.order.push(n));let r=e.units?.[n];r&&!this.units.get(n)&&this.units.set(n,r),i(t,e.columns[n])}this.n+=n}grow(){let e=this.capacity*2,t=new Float64Array(e);t.set(this.time),this.time=t;for(let[t,n]of this.cols){let r=new Float64Array(e).fill(NaN);r.set(n),this.cols.set(t,r)}this.capacity=e}toCsvParts(){let e=[this.timeColumn,...this.order],t=[this.timeUnit,...this.order.map(e=>this.units.get(e)??``)],n=[`${e.map(kX).join(`,`)}\n${t.map(kX).join(`,`)}\n`],r=this.order.map(e=>this.cols.get(e));for(let e=0;e<this.n;e+=DX){let t=Math.min(this.n,e+DX),i=``;for(let n=e;n<t;n++){i+=String(this.time[n]);for(let e of r){let t=e[n];i+=Number.isNaN(t)?`,`:`,${t}`}i+=`
615
+ `}n.push(i)}return n}};function kX(e){let t=/^[=+\-@\t\r]/.test(e)?`'${e}`:e;return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}var AX=512,jX=new WeakMap;function MX(e,t,n){let r=jX.get(e);r||jX.set(e,r=new Map);let i=r.get(t),a={start:n,values:[]};return{carry:{start:e=>{let t=i?.values[e];if(!i||!t)return 0;for(let e=Math.min(n-i.start,t.length-1);e>=0;e--){let n=t[e];if(n!==null&&Number.isFinite(n))return n}return 0},done:(e,t)=>{a.values[e]=t}},keep:()=>{r.set(t,a)}}}function NX(e,t,n){let r=e.endAbs,i=Math.max(n,e.firstAbs);if(i>=r||t.length===0)return;let a=new Set(e.columnNames);for(let n of t){if(!n.enabled)continue;let o=kT(n.formula);if(!o.ok)continue;let{identifiers:s,functions:c}=AT(o.node);if(!s.every(e=>a.has(e)))continue;let l=c.some(e=>DT.includes(e)),u=Math.max(e.firstAbs,i-(l?AX:0)),d=new Map([ae,...s].map(t=>[t,e.range(t,u,r)])),{carry:f,keep:p}=MX(e,`${n.id}|${n.formula}`,u),m=IT(n,e=>d.get(e),ae,r-u,t,f);m.status===`ok`&&(e.writeComputed(n.name,n.units,i,m.values.subarray(i-u)),p())}}function PX(e,t){e.clearComputed(),jX.delete(e),NX(e,t,e.firstAbs)}var FX=1e7,IX=512,LX=400,RX=4e3,zX=1e3;function BX(e,t){let n=new ce(t.capacity??FX,void 0,void 0,(t.maxMemoryMB??IX)*1024*1024);return{meta:e,buffer:n,source:new wX(()=>n),unsub:()=>{},status:`connecting`,error:null,lastFrameAt:Date.now(),lastColCount:0,recorder:null}}function VX(e,t,n=()=>({})){let r=new Map,i=e,a=[],o=[],s=``,c=()=>{let e=[];for(let t of r.values())t.lastColCount=t.buffer.columnNames.length,e.push({...t.meta,dataset:t.buffer.toDataset(LX),source:t.source,rowCount:t.buffer.size,status:t.status,error:t.error,recordingSince:t.recorder?.startedAt??null});a=e,t(a)},l=(e,t)=>{let n=!1,r=e.buffer.endAbs;for(let r of t)r&&typeof r.t==`number`&&Array.isArray(r.signals)&&(e.buffer.push(r),e.recorder?.add(r),n=!0);n&&d(e,r)},u=(e,t)=>{let n=e.buffer.endAbs;e.buffer.pushColumns(t),e.recorder?.addColumns(t),t.t.length>0&&d(e,n)},d=(e,t)=>{NX(e.buffer,o,t),e.lastFrameAt=Date.now();let n=e.status===`stale`||e.status===`connecting`;n&&(e.status=`live`),(n||e.buffer.columnNames.length!==e.lastColCount)&&c()},f=e=>{let t=r.get(e);t&&(t.unsub(),r.delete(e),c())},p=setInterval(()=>{let e=Date.now(),t=!1;for(let n of r.values())n.status===`live`&&e-n.lastFrameAt>RX&&(n.status=`stale`,t=!0);t&&c()},zX);return{connections:()=>a,disconnect:f,startRecording(e){let t=r.get(e);!t||t.recorder||(t.recorder=new OX,c())},stopRecording(e){let t=r.get(e),n=t?.recorder;return!t||!n?null:(t.recorder=null,c(),{csv:n.toCsvParts(),rows:n.rows,name:t.meta.name,startedAt:n.startedAt})},setRelay(e){i=e},setMathChannels(e){let t=JSON.stringify(e.map(e=>[e.id,e.name,e.units,e.formula,e.enabled]));if(t!==s){s=t,o=e;for(let t of r.values())PX(t.buffer,e);r.size>0&&c()}},openLocal(e,t){let i=`local:${crypto.randomUUID()}`,a=BX({id:i,name:e,ownerName:`This page`,visibility:`private`,orgName:null},{...n(),...t});return r.set(i,a),c(),{id:i,push:e=>{r.get(i)===a&&l(a,Array.isArray(e)?e:[e])},pushColumns:e=>{r.get(i)===a&&u(a,e)},close:()=>f(i)}},async connect(e,t,a){if(r.has(e.id))return;let o=i&&e.relay_url?{...i,url:e.relay_url}:i;if(!o)throw new tE(`relay_unavailable`);let s=typeof t==`string`?await M(z(t).secret??t,e.salt):`keyFor`in t?e=>t.keyFor(e):t;if(typeof s!=`function`&&!await se(s,e.key_check))throw new tE(`wrong_password`);let d=BX({id:e.id,name:e.name,ownerName:e.owner_name??``,visibility:e.visibility??`private`,orgName:e.org_name??null,projectName:e.project_name??null},{...n(),...a});r.set(e.id,d);let f=Promise.resolve();d.unsub=CX(o,e.id,t=>{let n=ie(s,t).catch(()=>null);f=f.then(async()=>{try{let t=await n;if(!t||r.get(e.id)!==d)return;if(t.kind===3)return u(d,ke(t.plaintext));if(t.kind!==2)return;let i=Ne(t.plaintext);l(d,Array.isArray(i?.frames)?i.frames:[])}catch{}})},e=>{e===`subscribed`?(d.status=`live`,d.lastFrameAt=Date.now()):e===`error`&&(d.status=`error`,d.error=`connection_error`),c()}),c()},dispose(){clearInterval(p);for(let e of r.values())e.unsub();r.clear(),a=[]}}}var HX=class{past=[];future=[];current=null;lastAt=-1/0;o;equals;constructor(e){this.o=e,this.equals=e.equals??Object.is}get canUndo(){return this.past.length>0}get canRedo(){return this.future.length>0}observe(e){if(this.current===null)return this.current=e,!1;if(this.equals(e,this.current))return!1;let t=this.o.now();return t-this.lastAt<this.o.mergeMs&&this.past.length>0||(this.past.push(this.current),this.past.length>this.o.limit&&this.past.shift()),this.current=e,this.future=[],this.lastAt=t,!0}rebase(e){this.current=e}undo(){if(this.past.length===0)return null;let e=this.past.pop();return this.future.push(this.current),this.current=e,this.lastAt=-1/0,e}redo(){if(this.future.length===0)return null;let e=this.future.pop();return this.past.push(this.current),this.current=e,this.lastAt=-1/0,e}clear(e){this.past=[],this.future=[],this.current=e,this.lastAt=-1/0}},UX={maxChartsPerWorksheet:null,maxChannelsPerChart:null,maxWorksheets:null,maxMathChannels:null,canImportExportWorkspaces:!0},WX=[],GX=[`#a78bfa`,`#38bdf8`,`#fb7185`,`#4ade80`,`#fbbf24`,`#94a3b8`];function KX(e=`ET`){return{id:crypto.randomUUID(),name:`Worksheet`,panels:[],panelChartSettings:{},panelChartBackgrounds:{},xKey:e}}function qX(e,t){let n=e.filter(e=>e.source!==`workbook`),r=new Map,i=[];for(let e of t){let t=n.find(t=>t.name===e.name);if(t&&t.formula===e.formula&&t.units===e.units)continue;let a=t?`${e.name} (workbook)`:e.name;t&&r.set(e.name,a),i.push(Ln({...e,name:a,source:`workbook`}))}return{channels:i,rename:r}}function JX(e,t){let n=JSON.stringify({xKey:e.xKey,panelChartSettings:e.panelChartSettings});for(let[e,r]of t)n=n.split(JSON.stringify(e)).join(JSON.stringify(r));return{...e,...JSON.parse(n)}}function YX(e){return typeof e.text==`function`?e.text():new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=()=>n(r.error),r.readAsText(e)})}function XX(e,t,n){if(!e||!t)return Ft();let{min:r,max:i}=GR(e.rows,t);if(!Number.isFinite(r)||!Number.isFinite(i))return Ft();let a=Math.max(1,Math.round(KR(i-r||1,6)));return{...n,scaleMin:String(Math.floor(r)),scaleMax:String(Math.ceil(i)),majorStep:String(a),minorStep:``}}function ZX(e,t){let n=t.includes(e.xKey)?e.xKey:t.includes(`ET`)?`ET`:t[0],r={...e.panelChartSettings};for(let n of e.panels){let e=r[n.id];if(n.kind===`multiband`){let i=e&&e.kind===`multiband`?e:Jt();r[n.id]={...i,kind:`multiband`,addColumn:i.addColumn&&t.includes(i.addColumn)?i.addColumn:t[0]}}else if(n.kind===`xyscatter`){let i=e&&e.kind===`xyscatter`?e:Yt(GX[2]),a=t.includes(i.xyXCol)?i.xyXCol:t[0],o=t.includes(i.xyYCol)&&i.xyYCol!==t[0]?i.xyYCol:t.length>1?t[1]:t[0];r[n.id]={...i,kind:`xyscatter`,xyXCol:a,xyYCol:o}}else if(n.kind===`xyzmesh`){let i=e&&e.kind===`xyzmesh`?e:Xt(4),a=t.includes(i.xyzXCol)?i.xyzXCol:t[0],o=t.length>1?t[1]:``,s=t.includes(i.xyzYCol)&&i.xyzYCol!==t[0]?i.xyzYCol:t.length>1?t[1]:t[0],c=t.includes(i.xyzZCol)&&i.xyzZCol!==t[0]&&i.xyzZCol!==o?i.xyzZCol:t.length>2?t[2]:t[0];r[n.id]={...i,kind:`xyzmesh`,xyzXCol:a,xyzYCol:s,xyzZCol:c}}}return{...e,xKey:n,panelChartSettings:r}}function QX(e,t){let n=!1,r={...e.panelChartSettings};for(let[i,a]of Object.entries(e.panelChartSettings)){if(a.kind!==`multiband`)continue;let e=a.series.filter(e=>t(e.column));e.length!==a.series.length&&(r[i]={...a,series:e},n=!0)}return n?{...e,panelChartSettings:r}:e}function $X(){return typeof document>`u`?`dark`:sz(null)}function eZ(e={}){let t={...e},n=!1,r=KX(),i=cX({datasets:[],selection:[],worksheets:[r],activeWorksheetId:r.id,xRanges:{},offsets:{},colors:{},liveWindowSeconds:15,live:[],mathChannels:[],limits:{...UX,...t.limits},palette:iz(t.palette,$X()),importing:0,licensed:null,history:{canUndo:!1,canRedo:!1}}),a=cB(),o=()=>{let e=iz(t.palette,$X());i.set(t=>t.palette.join()===e.join()?t:{...t,palette:e})},s=typeof document>`u`?()=>{}:cz(null,o),c=uX(),l=()=>{if(n)throw new tE(`disposed`)},d=e=>{throw a.emit(`limit`,{reason:e}),new tE(`limit_reached`,{reason:e})},f=()=>i.get(),p=lX((e,t)=>t===null?e:e.slice(0,t)),m=()=>{let e=f(),t=c.lapsByDataset(e.datasets),n=c.selectedDatasets(e.datasets,t,e.selection),r=c.selectedLive(e.live,e.selection),i=c.staticDataset(n),a=c.mergedDataset(i,r),o=p(e.mathChannels,e.limits.maxMathChannels);return{laps:t,selectedDatasets:n,selectedLive:r,staticDataset:i,merged:a,channels:o,numericColumns:c.numericColumns(a,n,o,c.mergedParts(n,r)),allColumns:c.allColumns(a,n,o),columnUnits:c.columnUnits(a,o)}},h=(e,t)=>({id:t.id,kind:t.kind,title:t.title??null,settings:e.panelChartSettings[t.id],background:e.panelChartBackgrounds[t.id]??null,annotations:e.panelChartSettings[t.id]?.annotations??WX,layout:t.rect}),g=lX((e,t)=>e.map(e=>({id:e.id,name:e.name,xKey:e.xKey,xRange:t[e.id]??null,charts:e.panels.map(t=>h(e,t))}))),_=lX((e,t,n,r,i,a,o)=>{let s=(e,t)=>{let n=a.findIndex(t=>t.id===e);return n>=0?n:t};return e.map((e,a)=>{let c=i[e.id],l=c?.laps.map(e=>e.id)??[],u=l.filter(e=>t.includes(e)).length;return{id:e.id,name:e.name,kind:e.kind,columns:e.schema.map(e=>({name:e.name,unit:e.unit??``,numeric:e.type===`number`})),rowCount:e.data.rows.length,color:nz(n,e.id,s(e.id,a),o),customColor:e.id in n,offset:r[e.id]??0,parseConfig:e.parseConfig??null,fileInfo:e.info??null,beacon:e.beacon??null,laps:c?c.laps.map((e,i)=>({id:e.id,name:e.name,value:c.values[i],unit:c.unit,isTime:c.isTime,color:nz(n,e.id,s(e.id,i),o),offset:r[e.id]??0,selected:t.includes(e.id)})):null,selected:c?u===0?!1:u===l.length?!0:`partial`:t.includes(e.id)}})}),v=lX((e,t,n,r,i)=>{let a=e.filter(e=>t.includes(e.id)).map(e=>e.id);return e.map((e,o)=>({id:e.id,name:e.name,ownerName:e.ownerName,visibility:e.visibility,orgName:e.orgName,status:e.status,error:e.error,rowCount:e.rowCount,selected:t.includes(e.id),color:nz(n,e.id,a.includes(e.id)?r+a.indexOf(e.id):o,i),recordingSince:e.recordingSince}))}),b=lX(e=>{let t=m();return{datasets:_(e.datasets,e.selection,e.colors,e.offsets,t.laps,t.selectedDatasets,e.palette),selection:e.selection,worksheets:g(e.worksheets,e.xRanges),activeWorksheetId:e.activeWorksheetId,mathChannels:t.channels,live:v(e.live,e.selection,e.colors,t.selectedDatasets.length,e.palette),liveWindowSeconds:e.liveWindowSeconds,limits:e.limits,palette:e.palette,importing:e.importing,licensed:e.licensed,hasData:t.merged!==null,multiDataset:t.selectedDatasets.length+t.selectedLive.length>1,numericColumns:t.numericColumns,allColumns:t.allColumns,columnUnits:t.columnUnits,history:e.history}}),S=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]||JSON.stringify(e)===JSON.stringify(t[n])),C=new HX({limit:100,mergeMs:500,now:()=>Date.now(),equals:(e,t)=>e.liveWindowSeconds===t.liveWindowSeconds&&S(e.worksheets,t.worksheets)&&S(e.channels,t.channels)}),w=!0,T=0,E=e=>{T++;try{e()}finally{T--}},D=e=>[e.worksheets,e.mathChannels,e.liveWindowSeconds],O=[],k=()=>{let e=f();return{worksheets:e.worksheets,channels:e.mathChannels.filter(e=>e.source===`workbook`),liveWindowSeconds:e.liveWindowSeconds,activeWorksheetId:e.activeWorksheetId}},j=()=>i.set(e=>e.history.canUndo===C.canUndo&&e.history.canRedo===C.canRedo?e:{...e,history:{canUndo:C.canUndo,canRedo:C.canRedo}}),M=()=>{if(w)return;let e=D(f());e.every((e,t)=>e===O[t])||(O=e,T?C.rebase(k()):C.observe(k()),j())},N=()=>{O=D(f()),C.clear(k()),j()},P=e=>{w=!0;let t;try{t=e()}finally{w=!1}return N(),t},F=()=>b(f());i.subscribe(()=>{M(),a.emit(`change`,F())});let I=e=>{let t=f(),n=t.worksheets.find(n=>n.id===(e??t.activeWorksheetId));if(!n)throw new tE(`not_found`,{worksheetId:e});return n},L=e=>{for(let t of f().worksheets){let n=t.panels.find(t=>t.id===e);if(n)return{ws:t,panel:n}}throw new tE(`not_found`,{chartId:e})},R=(e,t)=>i.set(n=>{let r=!1,i=n.worksheets.map(n=>{if(n.id!==e)return n;let i=t(n);return i!==n&&(r=!0),i});return r?{...n,worksheets:i}:n}),z=(e,t)=>{let{ws:n}=L(e);R(n.id,n=>({...n,panelChartSettings:{...n.panelChartSettings,[e]:t(n.panelChartSettings[e])}}))},B=e=>i.set(t=>e.length===t.selection.length&&e.every((e,n)=>e===t.selection[n])?t:{...t,selection:e,xRanges:{}}),V=new Set,ee=VX(t.live?.relay,e=>{let t=e.map(e=>e.id),n=t.filter(e=>!V.has(e)),r=[...V].filter(e=>!t.includes(e));if(V=new Set(t),i.set(t=>({...t,live:e})),r.length&&B(f().selection.filter(e=>!r.includes(e))),n.length){let e=f().selection,t=n.filter(t=>!e.includes(t));t.length&&B([...e,...t])}let a=m();if(a.selectedLive.length&&a.merged){let e=a.merged.columnNames;if(e.includes(`ElapsedTime`))for(let t of f().worksheets)e.includes(t.xKey)||E(()=>R(t.id,e=>({...e,xKey:ae})))}},()=>({capacity:t.live?.capacity,maxMemoryMB:t.live?.maxMemoryMB})),te=lX((e,t)=>e.filter(e=>t.some(t=>ZT([e],t.panelChartSettings,t.xKey).length>0))),H=()=>ee.setMathChannels(te(p(f().mathChannels,f().limits.maxMathChannels),f().worksheets));H(),i.subscribe(H);let ne=e=>{i.set(t=>({...t,datasets:[...t.datasets,e]})),B([...f().selection,e.id]);let t=WR(e.schema);t.length&&E(()=>i.set(e=>({...e,worksheets:e.worksheets.map(e=>ZX(e,t))})))},re=Promise.resolve(),ie=async(e,r={})=>{l();let o=e.map(e=>e instanceof File?e:e.file);if(o.length===0)return{ids:[],errors:[]};if(await t.beforeImport?.()===!1)throw new tE(`import_vetoed`);let{signal:s}=r;i.set(e=>({...e,importing:e.importing+o.length}));let c=re.then(async()=>{let e={ids:[],errors:[]},t=o.length,c=e=>{t-=e,i.set(t=>({...t,importing:Math.max(0,t.importing-e)}))};try{let{items:t,errors:i}=await XL(o);c(o.length-t.length);for(let{file:t,error:n}of i)e.errors.push({file:t,error:n}),a.emit(`import`,{file:t,phase:`error`,error:n}),a.emit(`error`,{error:n,context:`import`});for(let i of t){if(n)break;if(s?.aborted){e.cancelled=!0;break}let t=i.main;await new Promise(e=>setTimeout(e,0)),a.emit(`import`,{file:t.name,phase:`start`});try{let o=i.format?await UR({main:t,companions:i.companions,format:i.format.id},{priorInMemoryValues:HL(f().datasets),signal:s,onProgress:e=>a.emit(`import`,{file:t.name,phase:`progress`,fraction:e}),chooseChannels:r.chooseChannels,pickChannels:r.pickChannels}):[await VL(crypto.randomUUID(),t,f().datasets)??await zL(crypto.randomUUID(),t,YX,void 0,HL(f().datasets),s)];if(n){for(let e of o)e.source.dispose();break}if(s?.aborted){for(let e of o)e.source.dispose();throw new tE(`cancelled`)}for(let t of o)ne(t),e.ids.push(t.id);a.emit(`import`,{file:t.name,phase:`done`,datasetId:o[0].id,datasetIds:o.map(e=>e.id)})}catch(n){let r=n instanceof Error?n:Error(String(n));a.emit(`import`,{file:t.name,phase:`error`,error:r}),r instanceof tE&&r.code===`cancelled`?e.cancelled=!0:(e.errors.push({file:t.name,error:r}),a.emit(`error`,{error:r,context:`import`}))}finally{c(1)}if(e.cancelled)break}}finally{t>0&&c(t)}return e});return re=c.catch(()=>void 0),c},U=()=>setTimeout(()=>{n||FY(We)},0),oe=e=>{let t=t=>e.some(e=>t===e||t.startsWith(`${e}::`)),n=f().datasets.filter(t=>e.includes(t.id));for(let e of n)e.source.dispose().catch(()=>void 0);i.set(n=>{let r={...n.offsets},i={...n.colors};for(let e of Object.keys(r))t(e)&&delete r[e];for(let e of Object.keys(i))t(e)&&delete i[e];return{...n,datasets:n.datasets.filter(t=>!e.includes(t.id)),offsets:r,colors:i}}),B(f().selection.filter(e=>!t(e))),n.length>0&&U()},se=async(e,t)=>{let[n,...r]=await UR({main:new File(e.chunks,`${e.name}.krc`),companions:[],format:`krc`,keys:e.keys},{priorInMemoryValues:t});for(let e of r)e.source.dispose();return{...n,file:void 0,name:e.name,info:n.info&&{...n.info,startTime:e.startTime??n.info.startTime,meta:{...n.info.meta,recordingId:e.recordingId}}}},ce={importFiles:ie,warmImport(e={}){l(),jR(!!e.formats?.some(e=>e===`hdf5`||e===`mat`))},async splitByRate(e){l();let t=f().datasets.find(t=>t.id===e);if(!t)throw new tE(`not_found`,{datasetId:e});if(!t.info?.combined||!(t.file instanceof File))throw new tE(`invalid_argument`,{reason:`only a combined multi-rate import can be split`});let n=await UR({main:t.file,companions:t.companions??[],format:t.info.importer},{priorInMemoryValues:HL(f().datasets.filter(t=>t.id!==e)),selection:t.info.selection,split:!0});oe([e]);for(let e of n)ne(e);return n.map(e=>e.id)},async chooseChannels(e,t){l();let n=f().datasets.find(t=>t.id===e);if(!n)throw new tE(`not_found`,{datasetId:e});if(!n.info||!(n.file instanceof File))throw new tE(`invalid_argument`,{reason:`only binary imports have channels to choose`});try{let r=await UR({main:n.file,companions:n.companions??[],format:n.info.importer},{priorInMemoryValues:HL(f().datasets.filter(t=>t.id!==e)),initial:n.info.selection,chooseChannels:t,pickChannels:!0});oe([e]);for(let e of r)ne(e);return r.map(e=>e.id)}catch(e){if(e instanceof tE&&e.code===`cancelled`)return null;throw e}},async combine(e){l();let t=f().datasets.find(t=>t.id===e);if(!t)throw new tE(`not_found`,{datasetId:e});let n=t.info?.splitKey;if(!n||!(t.file instanceof File))throw new tE(`invalid_argument`,{reason:`only datasets split from one file can be combined`});let r=f().datasets.filter(e=>e.info?.splitKey===n),i=await UR({main:t.file,companions:t.companions??[],format:t.info.importer},{priorInMemoryValues:HL(f().datasets.filter(e=>!r.includes(e))),selection:r.flatMap(e=>e.info.selection)});if(i.length!==1){for(let e of i)e.source.dispose();throw new tE(`invalid_argument`,{reason:`these groups have no common time base`})}return oe(r.map(e=>e.id)),ne(i[0]),i[0].id},async openRecording(e){l();let t=await se(e,HL(f().datasets));return ne(t),t.id},async reopenRecording(e,t){l();let n=f().datasets.find(t=>t.id===e);if(!n)throw new tE(`not_found`,{datasetId:e});let r=await se(t,HL(f().datasets.filter(t=>t.id!==e)));i.set(t=>({...t,datasets:t.datasets.map(t=>t.id===e?{...r,id:e,beacon:n.beacon}:t)})),n.source.dispose().catch(()=>void 0),U()},addColumns(e){l();let t=tX(crypto.randomUUID(),e);return ne(t),t.id},replaceColumns(e,t,n={}){l();let r=f().datasets.find(t=>t.id===e);if(!r)throw new tE(`not_found`,{datasetId:e});let a=aX(r,t,n.transfer);i.set(t=>({...t,datasets:t.datasets.map(t=>t.id===e?a:t)}))},writeColumns(e,t,n){l();let r=f().datasets.find(t=>t.id===e);if(!r)throw new tE(`not_found`,{datasetId:e});let a=rX(r,t,n);i.set(t=>({...t,datasets:t.datasets.map(t=>t.id===e?a:t)}))},async addText(e,t=`dataset.csv`){l();let n=await IL(crypto.randomUUID(),t,e);return ne(n),n.id},remove(e){l(),oe([e])},clear(){l(),oe(f().datasets.map(e=>e.id))},async configure(e,t){l();let n=f().datasets.find(t=>t.id===e);if(!n)throw new tE(`not_found`,{datasetId:e});if(t.parseConfig&&(n.kind!==`memory`||!n.parseConfig))throw new tE(`invalid_argument`,{reason:n.parseConfig?`out-of-core datasets cannot be re-parsed`:`binary files have no text parse settings`});if(t.beacon!==void 0&&t.beacon!==null&&n.kind!==`memory`)throw new tE(`invalid_argument`,{reason:`laps need an in-memory dataset`});if(t.beacon!==void 0&&JSON.stringify(t.beacon)!==JSON.stringify(n.beacon??null)){let r=t.beacon??void 0;i.set(t=>({...t,datasets:t.datasets.map(t=>t.id===e?{...t,beacon:r}:t)}));let a=f().selection,o=a.some(t=>t===e||t.startsWith(`${e}::`)),s=a.filter(t=>t!==e&&!t.startsWith(`${e}::`)),c=r?dz(n.data.rows,r.channel):[],l=r&&t.selectCycles===`best`?gz(c.map(e=>hz(n.data.rows,e,r.metric,r.stat))):null,u=l===null?c.map((t,n)=>yz(e,n)):[yz(e,l)];B(o?c.length>0?[...s,...u]:[...s,e]:s)}let r=t.parseConfig;if(!r)return;let a=(()=>{try{let e=y(u(n.rawText??``),r.headerRow);return n.data.columnNames.length===e.length&&n.data.columnNames.every((t,n)=>t===e[n])}catch{return!1}})();if(A(r,n.parseConfig)&&a)return;let o=n.fromColumns?sX(n):n.rawText??``,s=await oE(n.file?{file:n.file,config:r}:{rawText:o,config:r}),c=new lE(s),d=await c.getSchema(),p=n.fromColumns?{rawText:o,fromColumns:!1}:{};i.set(t=>({...t,datasets:t.datasets.map(t=>t.id===e?{...t,...p,data:s,source:c,schema:d,parseConfig:r}:t)})),n.source.dispose().catch(()=>void 0),U();let h=m().selectedDatasets,g=new Set(h.flatMap(e=>e.data.columnNames)),_=s.columnNames.filter(e=>x(s.rows,e)),v=_.find(e=>e===`ET`)??_[0];E(()=>i.set(e=>({...e,worksheets:e.worksheets.map(e=>QX(!g.has(e.xKey)&&v?{...e,xKey:v}:e,e=>g.has(e)))})))},setColor(e,t){l(),i.set(n=>{let r={...n.colors};return t===null?delete r[e]:r[e]=t,{...n,colors:r}})},setOffset(e,t){l(),i.set(n=>({...n,offsets:{...n.offsets,[e]:t}}))},resetOffsets(){l(),i.set(e=>Object.keys(e.offsets).length?{...e,offsets:{}}:e)},select(e){l(),B([...e])},toggle(e){l();let t=f().selection,n=m().laps[e];if(n){let e=n.laps.map(e=>e.id);B(e.every(e=>t.includes(e))?t.filter(t=>!e.includes(t)):[...t,...e.filter(e=>!t.includes(e))]);return}B(t.includes(e)?t.filter(t=>t!==e):[...t,e])},selectAll(){l();let e=m().laps,t=f().live.filter(e=>f().selection.includes(e.id)).map(e=>e.id);B([...f().datasets.flatMap(t=>e[t.id]?e[t.id].laps.map(e=>e.id):[t.id]),...t])},deselectAll(){l(),B([])},raw(e){let t=f().datasets.find(t=>t.id===e);if(!t)throw new tE(`not_found`,{datasetId:e});return{get rawText(){return t.kind===`memory`&&t.fromColumns?sX(t):t.rawText??``},data:t.data,parseConfig:t.parseConfig??null,kind:t.kind,beacon:t.beacon??null}},async columnBounds(e){l();let t=m(),n=t.selectedDatasets.find(t=>t.schema.some(t=>t.name===e));if(n&&n.kind===`memory`){let t=GR(n.data.rows,e);if(Number.isFinite(t.min)&&Number.isFinite(t.max))return t}else if(n){let t=await n.source.xBounds(e).catch(()=>null);if(t&&Number.isFinite(t.x0)&&Number.isFinite(t.x1)&&t.x1>=t.x0)return{min:t.x0,max:t.x1}}let r=t.selectedLive.find(t=>t.dataset.columnNames.includes(e));if(r){let t=r.source.xBoundsSync(e);if(Number.isFinite(t.x0)&&Number.isFinite(t.x1))return{min:t.x0,max:t.x1}}let i=le(e);if(!i)return null;let a=GR(i.rows,e);return Number.isFinite(a.min)&&Number.isFinite(a.max)?a:null}},le=(e,t=I().xKey)=>{let n=m();if(!n.merged)return null;if(!n.channels.find(t=>t.name===e))return n.merged;let r=XT(n.merged,n.channels,t);return{...n.merged,columnNames:[...n.merged.columnNames,...r.ok.map(e=>e.name)],rows:r.rows}},ue=(e,t,n)=>m().selectedLive.length>0?{...n,scaleMin:``,scaleMax:``,majorStep:``,minorStep:``}:XX(le(e,t),e,n),de={fromFileList:e=>Xz(Array.from(e)),async fromDataTransfer(e){return Zz(Array.from(e.items??[]).map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e))},canPick:Qz,pick:$z,tree:(e,t)=>Yz(e,t),isImportable:Jz},fe={add(e=`Worksheet`){l();let t=f(),n=t.limits.maxWorksheets;n!==null&&t.worksheets.length>=n&&d(`worksheets`);let r={...KX(I().xKey||`ET`),name:e};return i.set(e=>({...e,worksheets:[...e.worksheets,r],activeWorksheetId:r.id})),r.id},rename(e,t){l(),I(e),R(e,e=>e.name===t?e:{...e,name:t})},remove(e){l();let t=f();if(I(e),t.worksheets.length<=1)throw new tE(`invalid_argument`,{reason:`the last worksheet cannot be removed`});let n=t.worksheets.findIndex(t=>t.id===e),r=t.worksheets.filter(t=>t.id!==e);i.set(t=>({...t,worksheets:r,activeWorksheetId:t.activeWorksheetId===e?r[Math.max(0,n-1)].id:t.activeWorksheetId}))},reorder(e,t){l(),i.set(n=>{if(e===t||e<0||t<0||e>=n.worksheets.length||t>=n.worksheets.length)return n;let r=[...n.worksheets],[i]=r.splice(e,1);return r.splice(t,0,i),{...n,worksheets:r}})},activate(e){l(),I(e),i.set(t=>t.activeWorksheetId===e?t:{...t,activeWorksheetId:e,xRanges:{...t.xRanges,[e]:null}})},setXKey(e,t){l(),I(e),R(e,e=>QX({...e,xKey:t},e=>e!==t)),i.set(t=>({...t,xRanges:{...t.xRanges,[e]:null},offsets:{},colors:{}}))}},pe={mount(e,t,n){return l(),PY(We,e,t,n)},openWindow(e,t){return l(),L(e),XY(We,e,(t,n)=>PY(We,e,t,n),t)},setFonts(e){e.sans&&(Q.sans=e.sans),e.mono&&(Q.mono=e.mono),FY(We)},kinds:()=>dX,label:pX,add(e,t={}){if(l(),!dX.some(t=>t.kind===e))throw new tE(`invalid_argument`,{kind:e});let n=I(t.worksheetId),r=f().limits.maxChartsPerWorksheet;r!==null&&n.panels.length>=r&&d(`charts-per-worksheet`);let i={...Mt(e,n.panels),...t.title?{title:t.title}:{}};t.layout&&(i.rect={...t.layout});let a=Pn([i],{},GX[2],4)[i.id],o=m().numericColumns;if(o.length&&(a.kind===`multiband`||a.kind===`xyscatter`||a.kind===`xyzmesh`)&&(a=ZX({...n,panels:[i],panelChartSettings:{[i.id]:a}},o).panelChartSettings[i.id],a.kind===`multiband`&&(a={...a,addColumn:o.find(e=>e!==n.xKey)??o[0]})),t.settings&&(a={...a,...t.settings,kind:a.kind}),o.length&&a.kind===`xyscatter`){let e=t.settings??{};a={...a,xyXScale:e.xyXScale??ue(a.xyXCol,n.xKey,a.xyXScale),xyYScale:e.xyYScale??ue(a.xyYCol,n.xKey,a.xyYScale)}}return R(n.id,e=>({...e,panels:t.layout?[...e.panels,i]:Pt([...e.panels,i]),panelChartSettings:{...e.panelChartSettings,[i.id]:a}})),i.id},remove(e){l();let{ws:t}=L(e);R(t.id,t=>{let n={...t.panelChartSettings},r={...t.panelChartBackgrounds};return delete n[e],delete r[e],{...t,panels:Pt(t.panels.filter(t=>t.id!==e)),panelChartSettings:n,panelChartBackgrounds:r}})},rename(e,t){l();let{ws:n}=L(e),r=t?.trim()||void 0;R(n.id,t=>({...t,panels:t.panels.map(t=>{if(t.id!==e)return t;let{title:n,...i}=t;return r?{...i,title:r}:i})}))},update(e,t){l();let{ws:n}=L(e);z(e,e=>{let r={...e,...t,kind:e.kind};if(e.kind===`xyscatter`&&r.kind===`xyscatter`){let i=t;typeof i.xyXCol==`string`&&i.xyXCol!==e.xyXCol&&!(`xyXScale`in i)&&(r={...r,xyXScale:ue(i.xyXCol,n.xKey,e.xyXScale)}),typeof i.xyYCol==`string`&&i.xyYCol!==e.xyYCol&&!(`xyYScale`in i)&&(r={...r,xyYScale:ue(i.xyYCol,n.xKey,e.xyYScale)})}return r})},replaceSettings(e,t){l();let{panel:n}=L(e);if(t.kind!==n.kind)throw new tE(`invalid_argument`,{reason:`settings kind mismatch`});z(e,()=>t)},setBackground(e,t){l();let{ws:n}=L(e);R(n.id,n=>({...n,panelChartBackgrounds:{...n.panelChartBackgrounds,[e]:t}}))},addAnnotation(e,t){l(),L(e);let n=vt({...t,id:t.id||crypto.randomUUID()});if(!n)throw new tE(`invalid_argument`,{reason:`not a valid annotation`});return z(e,e=>({...e,annotations:[...(e.annotations??[]).filter(e=>e.id!==n.id),n]})),n.id},updateAnnotation(e,t,n){l();let r=(L(e).ws.panelChartSettings[e]?.annotations??[]).find(e=>e.id===t);if(!r)throw new tE(`not_found`,{annotationId:t});let i=vt({...r,...n,id:r.id,kind:r.kind});if(!i)throw new tE(`invalid_argument`,{reason:`not a valid annotation`});z(e,e=>({...e,annotations:(e.annotations??[]).map(e=>e.id===i.id?i:e)}))},removeAnnotation(e,t){l(),L(e),z(e,e=>({...e,annotations:(e.annotations??[]).filter(e=>e.id!==t)}))},setAnnotations(e,t){l(),L(e);let n=yt(t)??[];z(e,e=>({...e,annotations:n}))},setLayout(e,t){l();let{ws:n}=L(e);R(n.id,n=>({...n,panels:n.panels.map(n=>n.id===e?{...n,rect:{...t}}:n)}))},setLayouts(e,t){l(),R(e,e=>({...e,panels:e.panels.map(e=>t[e.id]?{...e,rect:{...t[e.id]}}:e)}))},autoLayout(e){l(),R(I(e).id,e=>({...e,panels:Pt(e.panels)}))},get(e){let{ws:t,panel:n}=L(e);return h(t,n)},list(e){let t=I(e);return t.panels.map(e=>h(t,e))},async addSeries(e,t){l();let{ws:n}=L(e),r=n.panelChartSettings[e];if(!r||r.kind!==`multiband`)throw new tE(`invalid_argument`,{reason:`not a multiband chart`});let i=f().limits.maxChannelsPerChart;i!==null&&r.series.length>=i&&d(`channels-per-chart`);let a=m().numericColumns,o=new Set(r.series.map(e=>e.column)),s=t??a.find(e=>e!==n.xKey&&!o.has(e))??a.find(e=>e!==n.xKey)??``;if(!s)return null;let c=In(),u={id:c,column:s,color:GX[r.series.length%GX.length],bandFromPct:0,bandToPct:100,scaleMin:0,scaleMax:1,yMajorStep:0,yMinorStep:0};return z(e,e=>e.kind===`multiband`?{...e,series:[...e.series,u]}:e),await pe.autoScaleSeries(e,c),c},async updateSeries(e,t,n){l();let{ws:r}=L(e),i=r.panelChartSettings[e],a=i&&i.kind===`multiband`?i.series.find(e=>e.id===t):void 0;if(!a)throw new tE(`not_found`,{seriesId:t});z(e,e=>e.kind===`multiband`?{...e,series:e.series.map(e=>e.id===t?{...e,...n,id:e.id}:e)}:e),n.column&&n.column!==a.column&&n.scaleMin===void 0&&n.scaleMax===void 0&&await pe.autoScaleSeries(e,t)},removeSeries(e,t){l(),z(e,e=>e.kind===`multiband`?{...e,series:e.series.filter(e=>e.id!==t)}:e)},reorderSeries(e,t){l(),z(e,e=>{if(e.kind!==`multiband`)return e;let n=new Map(e.series.map(e=>[e.id,e])),r=t.map(e=>n.get(e)).filter(e=>!!e),i=e.series.filter(e=>!t.includes(e.id));return{...e,series:[...r,...i]}})},async autoScaleSeries(e,t){l();let{ws:r}=L(e),i=r.panelChartSettings[e],a=i&&i.kind===`multiband`?i.series.find(e=>e.id===t):void 0;if(!a)return;let o=await ce.columnBounds(a.column);!o||n||z(e,e=>e.kind===`multiband`?{...e,series:e.series.map(e=>e.id===t?{...e,scaleMin:o.min,scaleMax:o.max}:e)}:e)}},me={setXRange(e,t){l();let n=I(t).id;i.set(t=>{let r=t.xRanges[n]??null;return r===e||r&&e&&r[0]===e[0]&&r[1]===e[1]?t:{...t,xRanges:{...t.xRanges,[n]:e}}})},resetZoom(e){me.setXRange(null,e)},setLiveWindow(e){l(),i.set(t=>t.liveWindowSeconds===e?t:{...t,liveWindowSeconds:e})}},he={create(e){l();let n=f(),r=n.limits.maxMathChannels;r!==null&&n.mathChannels.length>=r&&d(`math-channels`);let o=Ln(e);return i.set(e=>({...e,mathChannels:[...e.mathChannels,o]})),Promise.resolve(t.mathChannels?.create(o)).catch(e=>a.emit(`error`,{error:e,context:`mathChannels.create`})),o},update(e,n){l();let r=f().mathChannels.find(t=>t.id===e);if(!r)throw new tE(`not_found`,{channelId:e});i.set(t=>({...t,mathChannels:t.mathChannels.map(t=>t.id===e?{...t,...n,updatedAt:Date.now()}:t)})),r.source!==`workbook`&&Promise.resolve(t.mathChannels?.update(e,n)).catch(e=>a.emit(`error`,{error:e,context:`mathChannels.update`}))},remove(e){l();let n=f().mathChannels.find(t=>t.id===e);if(!n)throw new tE(`not_found`,{channelId:e});i.set(t=>({...t,mathChannels:t.mathChannels.filter(t=>t.id!==e)})),n.source!==`workbook`&&Promise.resolve(t.mathChannels?.remove(e)).catch(e=>a.emit(`error`,{error:e,context:`mathChannels.remove`}))},async importFile(e){l();let{channels:n,errors:r}=await eE(e),a=f(),o=a.limits.maxMathChannels===null?n.length:Math.max(0,a.limits.maxMathChannels-a.mathChannels.length);n.length>0&&o===0&&d(`math-channels`);let s=n.slice(0,o);return i.set(e=>({...e,mathChannels:[...e.mathChannels,...s]})),await t.mathChannels?.importMany(s),{channels:s,errors:r}},async importMany(e){l();let n=f(),r=n.limits.maxMathChannels===null?e.length:Math.max(0,n.limits.maxMathChannels-n.mathChannels.length);e.length>0&&r===0&&d(`math-channels`);let a=e.slice(0,r);return i.set(e=>({...e,mathChannels:[...e.mathChannels,...a]})),await t.mathChannels?.importMany(a),a},exportBlob:()=>QT(f().mathChannels),preview(e,t){let n=m();return n.merged?MT(e,n.merged,I(t).xKey,n.channels.filter(t=>t.id!==e.id)):null},sync(e){l(),i.set(t=>{let n=t.mathChannels.filter(e=>e.source===`workbook`),r=n.length?[...e,...n]:e;return t.mathChannels===r?t:{...t,mathChannels:r}})}},ge={openLocal(e,t){return l(),ee.openLocal(e,t)},async connect(e,t,n){l(),await ee.connect(e,t,n)},startRecording(e){l(),ee.startRecording(e)},stopRecording(e){return l(),ee.stopRecording(e)},rowCount(e){return ee.connections().find(t=>t.id===e)?.source.size()??0},disconnect(e){l(),ee.disconnect(e),B(f().selection.filter(t=>t!==e))}},_e=()=>{f().limits.canImportExportWorkspaces||d(`workspaces-io`)},ve=async e=>{if(e instanceof Blob)try{return JSON.parse(await e.text())}catch{throw new tE(`bad_file`)}if(typeof e==`string`)try{return JSON.parse(e)}catch{throw new tE(`bad_file`)}return e},ye=async e=>e instanceof File?e:new File([JSON.stringify(await ve(e))],`import.json`,{type:`application/json`}),be=e=>e.replace(/[^\w.-]+/g,`_`),xe=e=>new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),Se=e=>{let t=Nn(e.panelChartSettings,GX[2],4),n={};for(let r of e.panels)t[r.id]?.kind===r.kind&&(n[r.id]=t[r.id]);return{...e,panelChartSettings:Pn(e.panels,n,GX[2],4)}},Ce=e=>{let t=m().numericColumns;return t.length?ZX(e,t):e},we=(e,t=0)=>{let n=f().limits.maxWorksheets,r=(n===null?e:e.slice(0,Math.max(1,n))).map(e=>Ce(Se(e))),a=r[Math.min(t,r.length-1)];i.set(e=>({...e,worksheets:r,activeWorksheetId:a.id,xRanges:{}}))},Te=(e,t)=>{let n=I(t),r=f().limits.maxChartsPerWorksheet;r!==null&&n.panels.length>=r&&d(`charts-per-worksheet`);let i=crypto.randomUUID(),a={id:i,kind:e.kind,rect:{x:0,y:0,w:6,h:24},...e.title?{title:e.title}:{}};return R(n.id,t=>({...t,panels:Pt([...t.panels,a]),panelChartSettings:{...t.panelChartSettings,[i]:e.settings},panelChartBackgrounds:e.background===null?t.panelChartBackgrounds:{...t.panelChartBackgrounds,[i]:e.background}})),i},Ee=()=>{let e=f();return Mz({worksheets:e.worksheets,activeWorksheetId:e.activeWorksheetId,channels:te(p(e.mathChannels,e.limits.maxMathChannels),e.worksheets),liveWindowSeconds:e.liveWindowSeconds,laps:e.datasets.find(e=>e.beacon)?.beacon??null})},De=e=>{if(e.worksheets.length===0)throw new tE(`bad_workspace`,{errors:e.errors});let{channels:t,rename:n}=qX(f().mathChannels,e.mathChannels);we(n.size?e.worksheets.map(e=>JX(e,n)):e.worksheets,e.activeIndex),i.set(n=>({...n,mathChannels:[...n.mathChannels.filter(e=>e.source!==`workbook`),...t],liveWindowSeconds:e.liveWindowSeconds===void 0?n.liveWindowSeconds:e.liveWindowSeconds}));let r=e.laps;if(r)for(let e of f().datasets)e.kind!==`memory`||e.beacon||!e.data.columnNames.includes(r.channel)||ce.configure(e.id,{beacon:r}).catch(e=>a.emit(`error`,{error:e,context:`io.openWorkbook`}));return{worksheets:e.worksheets.length,errors:e.errors}},Oe=e=>{if(e===null)return;let t=e.worksheets.map(Ce);w=!0;try{i.set(n=>{let r=t=>e.worksheets.some(e=>e.id===t);return{...n,worksheets:t,activeWorksheetId:r(n.activeWorksheetId)?n.activeWorksheetId:r(e.activeWorksheetId)?e.activeWorksheetId:e.worksheets[0].id,xRanges:Object.fromEntries(Object.entries(n.xRanges).filter(([e])=>r(e))),mathChannels:[...n.mathChannels.filter(e=>e.source!==`workbook`),...e.channels],liveWindowSeconds:e.liveWindowSeconds}})}finally{w=!1}O=D(f()),C.rebase(k()),j()},ke={undo(){l(),Oe(C.undo())},redo(){l(),Oe(C.redo())},clear(){l(),N()}},Ae={hasWork:()=>Uz(f().worksheets),exportWorksheet(e){l(),_e();let t=I(e),n=Nz(t);return{json:n,blob:xe(n),filename:`${be(t.name||`worksheet`)}.json`}},exportChart(e){l(),_e();let{ws:t,panel:n}=L(e),r=Pz(n,t.panelChartSettings[e],t.panelChartBackgrounds[e]??null);return{json:r,blob:xe(r),filename:`${be(n.title?.trim()||n.kind)}.json`}},parseFile:e=>Kz(e),exportWorkspace(){l(),_e();let e=Ee();return{json:e,blob:xe(e),filename:`kymoscope-workspace-${new Date().toISOString().slice(0,10)}.json`}},async exportWorkspaceEncrypted(e){l(),_e();let t=typeof e==`string`?await Sz(Ee(),e):await Cz(Ee(),e);return{json:t,blob:xe(t),filename:`kymoscope-workbook-${new Date().toISOString().slice(0,10)}.kymo`}},async importWorkspace(e,t={}){l(),_e();let n=await ve(e);return wz(n)&&(n=await Dz(n,t)),P(()=>De(Hz(n)))},toWorkbook:Ee,openWorkbook(e){return l(),P(()=>De(Hz(e)))},async importWorksheet(e){l(),_e();let t=f();t.limits.maxWorksheets!==null&&t.worksheets.length>=t.limits.maxWorksheets&&d(`worksheets`);let n=await Kz(await ye(e));if(n.type!==`worksheet`)throw new tE(`bad_file`,{found:n.type});let r=Ce(Se(n.worksheet));return i.set(e=>({...e,worksheets:[...e.worksheets,r],activeWorksheetId:r.id})),r.id},async importChart(e,t){l(),_e();let n=await Kz(await ye(e));if(n.type!==`chart`)throw new tE(`bad_file`,{found:n.type});return Te(n.chart,t)},snapshot(){let e=f();return{datasets:e.datasets,worksheets:e.worksheets,activeWorksheetId:e.activeWorksheetId,selection:e.selection}},restore(e){l();let t=new Set(e.datasets);for(let e of f().datasets)t.has(e)||e.source.dispose().catch(()=>void 0);let n=e.worksheets.length?e.worksheets.map(Se):[KX()];P(()=>i.set(t=>({...t,datasets:e.datasets,worksheets:n,activeWorksheetId:n.some(t=>t.id===e.activeWorksheetId)?e.activeWorksheetId:n[0].id,selection:e.selection,xRanges:{},offsets:{},colors:{}})))},reset(){l(),P(()=>{oe(f().datasets.map(e=>e.id));let e=KX();i.set(t=>({...t,worksheets:[e],activeWorksheetId:e.id,xRanges:{},offsets:{},colors:{},mathChannels:t.mathChannels.filter(e=>e.source!==`workbook`)}))})}},je={merged(e){let t=m();if(!t.merged||t.channels.length===0)return t.merged;let n=XT(t.merged,t.channels,I(e).xKey);return{...t.merged,columnNames:[...t.merged.columnNames,...n.ok.map(e=>e.name)],units:[...t.merged.units,...n.ok.map(e=>e.units)],rows:n.rows}},plotted(){return m().merged}},Me=typeof location<`u`?location.hostname:``,Ne=t.license,Pe=t.licenseKey,Fe=!1,Ie={},Le=e=>{n||i.set(t=>({...t,licensed:e}))},Re=(e,t,n)=>{clearTimeout(Ie[e]);let r=Math.max(0,t-Date.now()),i=r>2**31-1;Ie[e]=setTimeout(()=>{i?Re(e,t,n):n()},i?2**31-1:r)},ze=e=>Re(`renew`,e,()=>void Ve()),Be=e=>Re(`expiry`,e*1e3+1e3,()=>{aB(Pe,Me).then(e=>{n||Le(e.ok)})});async function Ve(){let e=36e5,t,r=null,i;try{t=await Promise.race([Ne.get(),new Promise((e,t)=>{i=setTimeout(()=>t(Error(`timeout`)),3e4)})]),r=await aB(t,Me)}catch{}finally{clearTimeout(i)}if(n)return!1;if(r?.ok)return Pe=t,Fe=!0,Le(!0),Be(r.exp),ze(Math.max(r.exp*1e3-168*e,Date.now()+e)),!0;console.warn(`[kymoscope] license renewal failed (${r?r.reason:`license.get failed or timed out`}): keeping the current key`);let a=await aB(Pe,Me);return n?!1:(Le(a.ok),ze(Date.now()+e),a.ok)}let He=!Ne||t.licenseKey?aB(t.licenseKey,Me).then(e=>(e.ok||console.warn(`[kymoscope] license ${e.reason}: showing attribution`),!Fe&&!n&&(Le(e.ok),e.ok&&Ne&&Be(e.exp)),e.ok)):null,Ue=Ne?Ve():He;w=!1,N();let We={getState:F,subscribe(e){return i.subscribe(e)},on:a.on,licensed:Ue,isLicensed:()=>f().licensed,setOptions(e){if(l(),t={...t,...e},e.live&&ee.setRelay(e.live.relay),e.palette&&o(),e.limits){let t={...f().limits,...e.limits};i.set(e=>{let n=t.maxWorksheets===null?e.worksheets:e.worksheets.slice(0,Math.max(1,t.maxWorksheets)),r=n.some(t=>t.id===e.activeWorksheetId)?e.activeWorksheetId:n[0].id;return{...e,limits:t,activeWorksheetId:r}})}},datasets:ce,folders:de,worksheets:fe,charts:pe,view:me,mathChannels:he,live:ge,io:Ae,history:ke,data:je,dispose(){if(!n){n=!0,clearTimeout(Ie.renew),clearTimeout(Ie.expiry),s(),ZY(We),IY(We),ee.dispose();for(let e of f().datasets)e.source.dispose().catch(()=>void 0);a.clear()}}};return tZ.set(We,{store:i,derived:m,live:ee}),We}var tZ=new WeakMap;function nZ(e){let t=tZ.get(e);if(!t)throw new tE(`invalid_argument`,{reason:`not a Kymoscope engine`});return t}var rZ=class{#e;constructor(e){this.#e=e}head(){let e=this.#e;return`${e.map(e=>kX(e.name)).join(`,`)}\n${e.map(e=>kX(e.unit)).join(`,`)}\n`}append(e){let t=e.columns,n=``;for(let r=0;r<e.length;r++){for(let e=0;e<t.length;e++){let i=t[e][r];n+=(e?`,`:``)+(Number.isNaN(i)?``:String(i))}n+=`
616
+ `}return n}end(){}},iZ=new TextEncoder,aZ=e=>e+7&-8,oZ=104,sZ=64,cZ=104,lZ=160,uZ=4;function dZ(e,t,n){let r=24+t.length*8+n.length,i=new Uint8Array(aZ(r)),a=new DataView(i.buffer);return i.set(iZ.encode(e),0),a.setBigUint64(8,BigInt(r),!0),a.setBigUint64(16,BigInt(t.length),!0),t.forEach((e,t)=>a.setBigUint64(24+t*8,BigInt(e),!0)),i.set(n,24+t.length*8),i}var fZ=(e,t)=>dZ(e,[],iZ.encode(`${t}\0`)),pZ=e=>BigInt(Math.round(e))*1000000n,mZ=class{#e;#t;#n;#r=0;constructor(e,t,n){this.#e=e,this.#t=t?Date.parse(t):Date.now(),this.#n=n}append(e){let t=e.columns,n=t.length,r=new Float64Array(e.length*n);for(let i=0;i<e.length;i++)for(let e=0;e<n;e++)r[i*n+e]=t[e][i];return this.#r+=e.length,new Uint8Array(r.buffer)}end(){if(this.#r!==this.#n)throw Error(`The recording changed while it was exported (${this.#r} of ${this.#n} rows).`)}head(){let e=this.#e.length,t=[],n=64+oZ,r=e=>{let r=n;return t.push(e),n+=e.length,r},i=r(fZ(`##MD`,`<FHcomment><TX>Kymoscope cloud recording</TX><tool_id>Kymoscope</tool_id><tool_vendor>Kymoscope</tool_vendor><tool_version>1</tool_version></FHcomment>`)),a=new Uint8Array(16);new DataView(a.buffer).setBigUint64(0,pZ(this.#t),!0);let o=r(dZ(`##FH`,[0,i],a)),s=this.#e.map(e=>r(fZ(`##TX`,e.name))),c=this.#e.map(e=>e.unit?r(fZ(`##TX`,e.unit)):0),l=n,u=l+sZ,d=this.#e.map((e,t)=>u+cZ+t*lZ),f=dZ(`##DG`,[0,u,u+cZ+e*lZ,0],new Uint8Array(8)),p=new Uint8Array(32),m=new DataView(p.buffer);m.setBigUint64(8,BigInt(this.#n),!0),m.setUint32(24,e*8,!0);let h=dZ(`##CG`,[0,d[0],0,0,0,0],p),g=this.#e.map((t,n)=>{let r=new Uint8Array(72),i=new DataView(r.buffer);return i.setUint8(0,n===0?2:0),i.setUint8(1,+(n===0)),i.setUint8(2,uZ),i.setUint32(4,n*8,!0),i.setUint32(8,64,!0),i.setUint8(20,255),dZ(`##CN`,[n+1<e?d[n+1]:0,0,s[n],0,0,0,c[n],0],r)}),_=new Uint8Array(24);_.set(iZ.encode(`##DT`),0),new DataView(_.buffer).setBigUint64(8,BigInt(24+this.#n*e*8),!0);let v=new Uint8Array(64);v.set(iZ.encode(`MDF 4.10 Kymoscop`),0),new DataView(v.buffer).setUint16(28,410,!0);let y=new Uint8Array(32);new DataView(y.buffer).setBigUint64(0,pZ(this.#t),!0);let b=[v,dZ(`##HD`,[l,o,0,0,0,0],y),...t,f,h,...g,_],x=new Uint8Array(b.reduce((e,t)=>e+t.length,0));return b.reduce((e,t)=>(x.set(t,e),e+t.length),0),x}},hZ={csv:`text/csv`,mf4:`application/octet-stream`};async function gZ(e,t,n,r={}){let i=NR(`krc`,{main:new File(e.chunks,`${e.name}.krc`),companions:[],keys:e.keys},r.signal,r.createWorker);try{let e=await i.plan(),a=[{group:0,channels:e.groups[0].channels.map((e,t)=>t)}],o=t===`csv`?new rZ(xR(e,a)):new mZ(xR(e,a),e.startTime,e.groups[0].samples);await n(o.head()),await i.read(a,`stream`,{chunk:async e=>{await n(o.append(e))},progress:r.onProgress}),o.end()}finally{i.close()}}async function _Z(e,t,n={}){let r=[];return await gZ(e,t,e=>{r.push(e)},n),new Blob(r,{type:hZ[t]})}export{cY as ANNOTATION_CONTROLS_ATTR,pt as ANNOTATION_KINDS,uz as BEACON_STATS,An as CHART_ALARM_FIELDS,dX as CHART_KINDS,bt as DASHBOARD_GRID_COLS,St as DASHBOARD_GRID_GAP_PX,xt as DASHBOARD_GRID_ROWS,tz as DATASET_PALETTE,mt as DEFAULT_ANNOTATION_WIDTH,It as DEFAULT_AXIS_LINE,Rt as DEFAULT_BEACON,Lt as DEFAULT_GRID_LINE,qt as DEFAULT_TRACE_WIDTH,Kt as DEFAULT_XYZ_POINT_RADIUS,Gt as DEFAULT_XY_POINT_RADIUS,hZ as EXPORT_TYPES,Zw as FUNCTION_REFERENCE,qz as IMPORTABLE_EXT,je as KRC_HEADER_BYTES,tE as KymoscopeError,ae as LIVE_TIME_COLUMN,Et as MIN_PANEL_H,Tt as MIN_PANEL_W,UX as UNLIMITED,DT as WINDOW_FN_NAMES,a as WORKBOOK_EXPORT_AAD,Pt as arrangeAutoLayout,gz as bestCycleIndex,Le as bindKeyAad,VH as buildEquation,QT as buildMathChannelsBlob,Yz as buildTree,jn as chartAlarm,pX as chartLabel,Fn as clampPct,Ot as clampRectForKind,kn as coerceAlarmLine,Xq as colorAt,nz as colorForDataset,sz as colorSchemeOf,$q as colorsCss,x as columnIsNumeric,RH as computePolyFit,zH as computeR2,eZ as createEngine,fz as cyclicChannels,SJ as decorateColumnLabel,mn as defaultAreaChartPanelSettings,fn as defaultBarChartPanelSettings,en as defaultBoxPlotPanelSettings,gn as defaultBubbleChartPanelSettings,bn as defaultCalibrationPanelSettings,hn as defaultCdfChartPanelSettings,an as defaultConfusionPanelSettings,cn as defaultControlChartPanelSettings,rz as defaultDatasetPalette,un as defaultEmbeddingPanelSettings,dn as defaultFlameGraphPanelSettings,Sn as defaultGanttPanelSettings,yn as defaultGaugePanelSettings,nn as defaultHeatmapPanelSettings,Zt as defaultHistogramPanelSettings,sn as defaultLossCurvePanelSettings,Jt as defaultMultibandPanelSettings,ln as defaultParallelCoordsPanelSettings,Qt as defaultPolarPanelSettings,xn as defaultQQPlotPanelSettings,pn as defaultRadarPanelSettings,on as defaultRocPanelSettings,vn as defaultSankeyPanelSettings,tn as defaultSpectrogramPanelSettings,$t as defaultSpectrumPanelSettings,_n as defaultTreemapPanelSettings,rn as defaultViolinPanelSettings,Ft as defaultXyAxisScaleSettings,Yt as defaultXyPanelSettings,Xt as defaultXyzPanelSettings,M as deriveKey,c as deriveRawKeyBase64,o as deviceFingerprint,kt as dragLayout,Cz as encryptWorkbookFile,Pn as ensurePanelSettingsForPanels,MT as evalChannel,lz as eventWithin,_Z as exportRecording,gZ as exportRecordingTo,AT as extractFreeIdentifiers,vz as formatLapValue,w as generateApiToken,ge as generateDeviceKeyPair,t as generateRecoveryKeyPair,me as generateSalt,u as getRawNonEmptyLines,pz as guessBeaconChannel,b as hashToken,S as importStreamKey,h as inferParseConfig,Jz as isImportable,xJ as isMathChannelName,E as makeKeyCheck,Ht as newGaugeItem,Ln as newMathChannel,Mt as newPanel,In as newSeriesId,KR as niceMajorStep,cz as observeColorScheme,IL as openDatasetFromText,ie as openMessage,l as openUnderProjectKey,m as openWithKey,v as openWithPassword,y as parseColumnNames,A as parseConfigsEqual,i as parseDatasetWithConfig,kT as parseFormula,xe as parseKrc,De as parseKrcHeader,eE as parseMathChannelsFile,Wt as parseOptionalAxisRange,Nn as parsePanelChartSettingsMap,k as parseRecoveryCode,Qq as presetStops,Ve as projectWrapAad,r as randomKey,H as recordingKeyAad,Ce as recordingKeySealAad,F as recoveryAttestationAad,f as recoveryCode,N as recoveryKeyAad,L as recoveryPrivateKey,ve as sealMessage,d as sealUnderProjectKey,_ as sealWithKey,Ee as sealWithPassword,g as senderBindKey,B as senderBinding,z as splitApiKey,dz as splitLaps,V as streamKeyAad,I as subsampleIndices,mz as suggestBeacon,O as unwrapForDevice,e as unwrapStreamKey,se as verifyKeyCheck,aB as verifyLicense,Me as verifySenderBinding,Se as workbookBodyAad,bz as workbookExportAad,Tz as workbookFileInfo,Oe as workbookKeyAad,pe as wrapForDevice};