kline-orderbook-chart 2.2.3 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/LICENSE +4 -3
- package/README.md +6 -4
- package/dist/chart-engine.mjs +56 -63
- package/dist/chart_engine.js +1 -1
- package/dist/chart_engine_bg.wasm +0 -0
- package/dist/index.d.ts +169 -0
- package/dist/panelWorker.js +7 -7
- package/dist/tickWorker.js +25 -25
- package/package.json +1 -1
- package/dist/ingestWorker.js +0 -14
- package/dist/mboWorker.js +0 -14
- package/dist/tapeScriptWorker.js +0 -19
|
Binary file
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,44 @@ export type DrawingTool =
|
|
|
116
116
|
| 'elliottauto' | 'elliottautorange' | 'elliottzigzag' | 'elliottzigzagrange'
|
|
117
117
|
| 'xabcd' | 'cypher' | 'headshoulders' | 'abcd' | 'trianglepattern' | 'threedrives';
|
|
118
118
|
|
|
119
|
+
export type PriceScaleMode = 'linear' | 'log' | 'percent';
|
|
120
|
+
|
|
121
|
+
export interface ChartLocale {
|
|
122
|
+
/** 12 short month names, January first. `null` restores English. */
|
|
123
|
+
months?: string[] | null;
|
|
124
|
+
/** 7 short weekday names, Sunday first; they lead the crosshair time label. `null` hides them. */
|
|
125
|
+
weekdays?: string[] | null;
|
|
126
|
+
/** Default `'.'`. */
|
|
127
|
+
decimalSeparator?: string;
|
|
128
|
+
/** Thousands separator. Default `''` (none). */
|
|
129
|
+
groupSeparator?: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface VisibleRange {
|
|
133
|
+
/** Unix seconds. */
|
|
134
|
+
from: number;
|
|
135
|
+
to: number;
|
|
136
|
+
priceLow: number;
|
|
137
|
+
priceHigh: number;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface CrosshairSyncEvent {
|
|
141
|
+
visible: boolean;
|
|
142
|
+
/** Time under the cursor, Unix seconds (snapped by the magnet). */
|
|
143
|
+
worldX: number;
|
|
144
|
+
/** Price under the cursor. */
|
|
145
|
+
worldY: number;
|
|
146
|
+
/** Cursor height as a fraction of the pane, 0 at the top. */
|
|
147
|
+
ratio: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface PaneHeights {
|
|
151
|
+
/** Built-in panes by name (`rsi`, `oi`, `fr`, `cvd`, `vpin`, `aggLiq`, …): share of the chart height. */
|
|
152
|
+
[pane: string]: number | Record<string, number> | undefined;
|
|
153
|
+
/** Panes registered by id (Volume Heatmap, custom indicators, extra copies). */
|
|
154
|
+
aux?: Record<string, number>;
|
|
155
|
+
}
|
|
156
|
+
|
|
119
157
|
export interface DrawingStyle {
|
|
120
158
|
/** Stroke color, CSS hex. */
|
|
121
159
|
hex?: string;
|
|
@@ -227,6 +265,11 @@ export interface ChartEngine {
|
|
|
227
265
|
setChartType(type: ChartType): void;
|
|
228
266
|
getChartType(): ChartType;
|
|
229
267
|
setCandleStyle(style: CandleStyle): void;
|
|
268
|
+
/** `'log'` stays linear while the visible prices are not all positive; `'percent'` labels the axis as % from the first visible close. */
|
|
269
|
+
setPriceScale(mode: PriceScaleMode): void;
|
|
270
|
+
getPriceScale(): PriceScaleMode;
|
|
271
|
+
/** Month / weekday names and number separators for the axes, the crosshair labels and the last-price tag. */
|
|
272
|
+
setLocale(locale: ChartLocale): void;
|
|
230
273
|
|
|
231
274
|
// Orderbook heatmap (Professional)
|
|
232
275
|
/**
|
|
@@ -254,6 +297,16 @@ export interface ChartEngine {
|
|
|
254
297
|
/** Current book for the side profile: flat `[price, size, isAsk(0|1)]` triplets. */
|
|
255
298
|
setHeatmapProfileLiveDepth(flat: NumArray): void;
|
|
256
299
|
clearHeatmapProfileLiveDepth(): void;
|
|
300
|
+
/**
|
|
301
|
+
* Wall markers on the side profile, 10 numbers per wall:
|
|
302
|
+
* `[price, isResistance(0|1), status, strength(0–100), currentVol, peakVol, volumeUsd, volumeTrend, persistencePct(0–100), ageSec]`.
|
|
303
|
+
* `status`: 0 new, 1 holding, 2 growing, 3 shrinking, 4 eaten, 5 spoofed. You compute the walls; the chart draws them.
|
|
304
|
+
*/
|
|
305
|
+
setHeatmapWalls(flat: NumArray, stride?: 10): void;
|
|
306
|
+
clearHeatmapWalls(): void;
|
|
307
|
+
/** Largest value of the full history you are about to load in chunks, so colors stay stable from the first chunk. */
|
|
308
|
+
setHeatmapPrefetchRange(max: number): void;
|
|
309
|
+
clearHeatmapPrefetchRange(): void;
|
|
257
310
|
|
|
258
311
|
// Footprint (Professional) — switch with setChartType(1)
|
|
259
312
|
/** Price width of one footprint row. */
|
|
@@ -285,6 +338,16 @@ export interface ChartEngine {
|
|
|
285
338
|
footprintSetStackedImbalanceMode(mode: 0 | 1): void;
|
|
286
339
|
/** Stop drawing stacks older than `bars`; 0 = all. */
|
|
287
340
|
footprintSetStackedImbalanceMaxAge(bars: number): void;
|
|
341
|
+
/** Statistics table under the footprint: one row per enabled statistic, one column per bar. */
|
|
342
|
+
footprintSetClusterEnabled(on: boolean): void;
|
|
343
|
+
footprintGetClusterEnabled(): boolean;
|
|
344
|
+
/** Rows of the statistics table. `sessionDelta` is the running total of delta from the first loaded bar. */
|
|
345
|
+
footprintSetClusterRows(volume: boolean, delta: boolean, deltaPct: boolean, sessionDelta: boolean): void;
|
|
346
|
+
/** Total table height in CSS px; the user can also drag its top edge. */
|
|
347
|
+
footprintSetClusterHeight(px: number): void;
|
|
348
|
+
footprintGetClusterHeight(): number;
|
|
349
|
+
/** Tint for negative delta in the table (`{ r, g, b }` 0–255); `null` uses the ask color. */
|
|
350
|
+
footprintSetStatsNegColor(rgb: { r: number; g: number; b: number } | null): void;
|
|
288
351
|
|
|
289
352
|
// View and coordinates
|
|
290
353
|
/** Show the latest bars and re-enable price auto-scale on every pane. */
|
|
@@ -296,6 +359,54 @@ export interface ChartEngine {
|
|
|
296
359
|
screenToWorld(sx: number, sy: number): { x: number; y: number };
|
|
297
360
|
/** Chart coordinates → canvas CSS px; `null` when the chart is not ready. */
|
|
298
361
|
worldToScreen(x: number, y: number): { x: number; y: number } | null;
|
|
362
|
+
getVisibleRange(): VisibleRange | null;
|
|
363
|
+
/** Show `[from, to]` (Unix seconds). Returns false when the window is narrower than the zoom limit. */
|
|
364
|
+
setVisibleRange(from: number, to: number): boolean;
|
|
365
|
+
/** Called after any frame in which the window moved (pan, zoom, price scale). `null` unsubscribes. */
|
|
366
|
+
onVisibleRangeChange(cb: ((range: VisibleRange) => void) | null): void;
|
|
367
|
+
|
|
368
|
+
// Crosshair sync between charts
|
|
369
|
+
/** Publisher side: called on every crosshair move and hide of this chart. `null` unsubscribes. */
|
|
370
|
+
setCrosshairSyncHandler(cb: ((e: CrosshairSyncEvent) => void) | null): void;
|
|
371
|
+
/** Receiver side: draw the crosshair at a peer's position. Returns false when `worldX` is outside this chart's window. */
|
|
372
|
+
setCrosshairAtWorldX(worldX: number, worldY: number, ratio: number): boolean;
|
|
373
|
+
hideCrosshairExternal(): void;
|
|
374
|
+
/** Pointer crosshair in canvas px. Returns an unsubscribe function. */
|
|
375
|
+
addCrosshairListener(cb: (e: { visible: boolean; sx: number; sy: number; zone: number; pinned: boolean }) => void): () => void;
|
|
376
|
+
|
|
377
|
+
// Panes — users drag a pane's top edge to resize it and double-click to fit its scale
|
|
378
|
+
/** Top-to-bottom pane keys, hidden panes included. */
|
|
379
|
+
getPaneOrder(): string[];
|
|
380
|
+
/** Restore an order from getPaneOrder; unknown keys are dropped, missing ones appended. */
|
|
381
|
+
setPaneOrder(keys: string[]): void;
|
|
382
|
+
/** Maximize a pane, or restore the stack when it is already maximized. */
|
|
383
|
+
togglePaneMaximized(key: string): boolean;
|
|
384
|
+
/** Key of the maximized pane, `''` when none. */
|
|
385
|
+
maximizedPane(): string;
|
|
386
|
+
/** Pane heights to save; `null` when no sub-pane is open. */
|
|
387
|
+
getPaneHeights(): PaneHeights | null;
|
|
388
|
+
/** Apply saved heights. Call after enabling the indicators that own the panes. */
|
|
389
|
+
applyPaneHeights(heights: PaneHeights): void;
|
|
390
|
+
/** Visible sub-panes in canvas px. */
|
|
391
|
+
paneRects(): Record<string, { x: number; y: number; w: number; h: number }>;
|
|
392
|
+
/** Called (at most once per frame) when the pane stack geometry changes. `null` unsubscribes. */
|
|
393
|
+
onPaneLayoutChange(cb: (() => void) | null): void;
|
|
394
|
+
|
|
395
|
+
// Compare series
|
|
396
|
+
/**
|
|
397
|
+
* Add or replace a symbol drawn as a line over the main series, normalized at the anchor bar.
|
|
398
|
+
* `key` is your stable id; `ts` in Unix seconds, ascending. Safe to call on every update.
|
|
399
|
+
*/
|
|
400
|
+
setCompareSeries(key: string, label: string, color: string, ts: NumArray, high: NumArray, low: NumArray, close: NumArray): void;
|
|
401
|
+
removeCompareSeries(key: string): boolean;
|
|
402
|
+
clearCompareSeries(): void;
|
|
403
|
+
compareSeriesCount(): number;
|
|
404
|
+
/** `lineWidth <= 0` keeps the current width. */
|
|
405
|
+
setCompareSeriesStyle(key: string, color: string, lineWidth: number, visible: boolean): void;
|
|
406
|
+
/** `anchorMode`: 0 first visible bar, 1 first loaded bar, 2 session start. `scaleMode`: 0 % change. `percentAxis` labels the price axis in %. */
|
|
407
|
+
setCompareOverlay(anchorMode: 0 | 1 | 2, scaleMode: 0, percentAxis: boolean, showTags: boolean): void;
|
|
408
|
+
/** Draw the main symbol as a close line like the compare series, instead of candles. */
|
|
409
|
+
setCompareMainStyle(asLine: boolean, color: string): void;
|
|
299
410
|
|
|
300
411
|
// Theme and colors
|
|
301
412
|
setTheme(name: 'dark' | 'light'): void;
|
|
@@ -469,6 +580,59 @@ export interface ChartEngine {
|
|
|
469
580
|
disableGaussianVwapCloud(): void;
|
|
470
581
|
isGaussianVwapCloudEnabled(): boolean;
|
|
471
582
|
|
|
583
|
+
/**
|
|
584
|
+
* Volume Heatmap (Professional): one row per statistic under the chart, one cell per bar,
|
|
585
|
+
* colored by its rank. ΔOI rows read setOiDataTs; liquidation rows read setAggLiqData.
|
|
586
|
+
*/
|
|
587
|
+
enableVolumeHeatmap(): void;
|
|
588
|
+
disableVolumeHeatmap(): void;
|
|
589
|
+
isVolumeHeatmapEnabled(): boolean;
|
|
590
|
+
/** Taker-buy volume and total volume per candle. */
|
|
591
|
+
setVolumeHeatmapData(takerBuyVolume: NumArray, totalVolume: NumArray): void;
|
|
592
|
+
/**
|
|
593
|
+
* Visible rows as bits: 1 CVD, 2 total volume, 4 relative volume, 8 delta, 16 delta %,
|
|
594
|
+
* 32 buy volume, 64 sell volume, 128 ΔOI, 256 liquidations, 512 long liquidations, 1024 short liquidations.
|
|
595
|
+
* Rows without data hide.
|
|
596
|
+
*/
|
|
597
|
+
setVolumeHeatmapRows(mask: number): void;
|
|
598
|
+
/** Pane height as a share of the chart, 0.05–0.5. */
|
|
599
|
+
setVolumeHeatmapRatio(ratio: number): void;
|
|
600
|
+
/** What a cell is ranked against: 0 day, 1 week, 2 visible bars, 3 all bars. */
|
|
601
|
+
setVolumeHeatmapGrading(grading: 0 | 1 | 2 | 3): void;
|
|
602
|
+
/** `mode` 0 diverging buy/sell pair, 1 single ramp; `scheme` 0–5. */
|
|
603
|
+
setVolumeHeatmapPalette(mode: 0 | 1, scheme: number): void;
|
|
604
|
+
/** Below 1 lifts small cells. Default 0.75. */
|
|
605
|
+
setVolumeHeatmapContrast(contrast: number): void;
|
|
606
|
+
/** Numbers in the cells; `valueInQuote` shows volume × price. */
|
|
607
|
+
setVolumeHeatmapDisplay(showValues: boolean, valueInQuote: boolean): void;
|
|
608
|
+
/** Readout table in the pane corner. */
|
|
609
|
+
setVolumeHeatmapShowTable(show: boolean): void;
|
|
610
|
+
/** Hover tooltip; `style` 0 details, 1 mini chart. */
|
|
611
|
+
setVolumeHeatmapTooltip(show: boolean, style: 0 | 1): void;
|
|
612
|
+
/** CVD row: 0 restarts each UTC day, 1 runs over the whole history. */
|
|
613
|
+
setVolumeHeatmapCvdAnchor(anchor: 0 | 1): void;
|
|
614
|
+
/** Text size multiplier, 0.6–2. */
|
|
615
|
+
setVolumeHeatmapTextSize(size: number): void;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Liquidation heatmap (Professional): estimated liquidation levels from open interest, drawn behind the candles.
|
|
619
|
+
* Nothing draws until both ready flags are true: reset them when a symbol or timeframe starts loading.
|
|
620
|
+
*/
|
|
621
|
+
enableLiqHeatmap(): void;
|
|
622
|
+
disableLiqHeatmap(): void;
|
|
623
|
+
isLiqHeatmapEnabled(): boolean;
|
|
624
|
+
setLiqHeatmapKlinesReady(ready: boolean): void;
|
|
625
|
+
setLiqHeatmapHistoryReady(ready: boolean): void;
|
|
626
|
+
/** Open interest for the heatmap at its own timestamps (Unix seconds). Without it the heatmap uses setOiDataTs. */
|
|
627
|
+
setLiqHeatmapOiDataTs(timestamps: NumArray, values: NumArray): void;
|
|
628
|
+
/** Draw only levels from the last `bars` candles, 50–5000 (default 2500). */
|
|
629
|
+
setLiqHeatmapLookbackBars(bars: number): void;
|
|
630
|
+
/** Color strength multiplier. */
|
|
631
|
+
setLiqHeatmapIntensity(mult: number): void;
|
|
632
|
+
setLiqHeatmapPalette(index: number): void;
|
|
633
|
+
/** Table of the nearest levels on the right. */
|
|
634
|
+
setLiqHeatmapTable(on: boolean): void;
|
|
635
|
+
|
|
472
636
|
/** RSI (Standard): Wilder's RSI of the closes; overbought / oversold zones at 80–90 and 10–20. */
|
|
473
637
|
enableRsi(): void;
|
|
474
638
|
disableRsi(): void;
|
|
@@ -512,6 +676,11 @@ export interface PanelRenderOptions {
|
|
|
512
676
|
* Tick Stream paints on the main thread unless `'worker'`.
|
|
513
677
|
*/
|
|
514
678
|
renderer?: 'canvas2d' | 'worker';
|
|
679
|
+
/**
|
|
680
|
+
* Worker mode only: an `@font-face` stylesheet for IBM Plex Mono on your own host
|
|
681
|
+
* (relative font URLs resolve against it). `''` loads no font. Default: Google Fonts.
|
|
682
|
+
*/
|
|
683
|
+
fontUrl?: string;
|
|
515
684
|
}
|
|
516
685
|
|
|
517
686
|
export interface OrderbookBridgeOptions extends PanelRenderOptions {
|
package/dist/panelWorker.js
CHANGED
|
@@ -117,7 +117,7 @@ void main() {
|
|
|
117
117
|
m = max(m, texelFetch(uCol, ivec2(i, 0), 0).r);
|
|
118
118
|
}
|
|
119
119
|
frag = vec4(m, 0.0, 0.0, 1.0);
|
|
120
|
-
}`,
|
|
120
|
+
}`,ge=256,Yt=`${ne}${ve}
|
|
121
121
|
uniform sampler2D uField;
|
|
122
122
|
uniform int uFieldRG;
|
|
123
123
|
uniform sampler2D uMax;
|
|
@@ -134,8 +134,8 @@ void main() {
|
|
|
134
134
|
float range = log(max(mx, 1e-10)) - logMin;
|
|
135
135
|
if (!(range > 0.0)) range = 1.0;
|
|
136
136
|
int slot = clamp(int((log(max(m, 1e-10)) - logMin) * (255.0 / range)), 0, 255);
|
|
137
|
-
float lane = float(gl_VertexID % ${
|
|
138
|
-
gl_Position = vec4((float(slot) + 0.5) / 128.0 - 1.0, (lane + 0.5) / ${
|
|
137
|
+
float lane = float(gl_VertexID % ${ge});
|
|
138
|
+
gl_Position = vec4((float(slot) + 0.5) / 128.0 - 1.0, (lane + 0.5) / ${ge/2}.0 - 1.0, 0.0, 1.0);
|
|
139
139
|
}`,Kt=`${ne}
|
|
140
140
|
out vec4 frag;
|
|
141
141
|
void main() { frag = vec4(1.0, 0.0, 0.0, 1.0); }`,qt=`${ne}
|
|
@@ -144,7 +144,7 @@ out vec4 frag;
|
|
|
144
144
|
void main() {
|
|
145
145
|
int x = int(gl_FragCoord.x);
|
|
146
146
|
float n = 0.0;
|
|
147
|
-
for (int i = 0; i < ${
|
|
147
|
+
for (int i = 0; i < ${ge}; i++) n += texelFetch(uHist, ivec2(x, i), 0).r;
|
|
148
148
|
frag = vec4(n, 0.0, 0.0, 1.0);
|
|
149
149
|
}`,jt=`${ne}${ve}
|
|
150
150
|
uniform sampler2D uField;
|
|
@@ -369,9 +369,9 @@ void main() {
|
|
|
369
369
|
vec2 p = (vec2(float(d % w), float(d / w)) + 0.5) / vec2(uNewSize);
|
|
370
370
|
gl_Position = vec4(p * 2.0 - 1.0, 0.0, 1.0);
|
|
371
371
|
gl_PointSize = 1.0;
|
|
372
|
-
}`;var ht=[null,null,null,null];function ge(t,a,o,i){if(a%4===0)return new Uint32Array(t,a,o);let u=ht[i];return(!u||u.length<o)&&(u=ht[i]=new Uint32Array(Math.max(o,16384))),new Uint8Array(u.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),u.subarray(0,o)}function mt(t,a,o){let i=a.byteLength;if(o+27>i)return{p:null,next:i};let u={layer:a[o],flags:a[o+1]},p=o+3,E=()=>{let r=t.getUint32(p,!0);return p+=4,r};u.head=E(),u.tail=E(),u.histN=E(),u.liveN=E(),u.idCap=E(),u.preN=E();let y=u.histN*4,v=u.liveN*5,n=u.preN*4;return p+(y+v+n)*4>i?{p:null,next:i}:(u.hist=y?ge(a.buffer,a.byteOffset+p,y,0):null,p+=y*4,u.live=v?ge(a.buffer,a.byteOffset+p,v,1):null,p+=v*4,u.pre=n?ge(a.buffer,a.byteOffset+p,n,3):null,p+=n*4,{p:u,next:p})}function bt(t,a,o){let i=()=>{let E=t.getInt32(o,!0);return o+=4,E},u=()=>{let E=t.getUint32(o,!0);return o+=4,E},p={bucket:i(),shiftE:i(),nB:u(),shiftK:i(),rowAgg:i(),nK:u(),t0Ceil:i(),tmaxFloor:i(),openFloor:i(),openOk:u(),openC1:i(),tip:u(),liveUntil:u(),histFrom:u(),walkHi:u(),aTo:u(),bFrom:u(),bTo:u(),hFrom:u(),hTo:u(),dimLife:i(),dim:0};return p.dim=t.getFloat32(o,!0),o+=4,{k:p,o}}function _t(t,a,o){let i=o.nB+2*o.nK;if(a+i*4>t.byteLength)return null;let u=ge(t.buffer,t.byteOffset+a,i,2),p=new Int32Array(u.buffer,u.byteOffset,i);return o.colLut=p.subarray(0,o.nB),o.bandLut=p.subarray(o.nB),a+i*4}var no=32,ro=4294967295;var xe=null;function ao(t,a,o){return a%4===0?new Float32Array(t,a,o):((!xe||xe.length<o)&&(xe=new Float32Array(Math.max(o,65536))),new Uint8Array(xe.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),xe.subarray(0,o))}function Tt(t,a,o){let i=a.byteLength;if(o+104>i)return{p:null,data:null,next:i};let u=a[o],p=a[o+1],E=o+3,y=()=>{let x=t.getUint32(E,!0);return E+=4,x},v=()=>{let x=t.getInt32(E,!0);return E+=4,x},n=()=>{let x=t.getFloat32(E,!0);return E+=4,x},r={layer:u,flags:p,seq:y(),baseSeq:y(),cols:y(),rows:y(),shiftX:v(),shiftY:v(),dirtyLo:y(),openR0:y(),openR1:y(),dilateLo:y(),sigma:n(),radius:y(),visTop:y(),rowsVis:y(),hi:n(),lo:n(),gain:n(),curveB:n(),breakpoint:n(),filter:n(),projBase:y(),openEnd:y(),fadeFrom:y(),fadeSpan:n(),headHi:y()};if(p&no){if(E+81>i)return{p:null,data:null,next:i};let x=bt(t,a,E);r.raster=x.k,E=x.o}if(E+=1+a[E],r.raster){let x=_t(a,E,r.raster);if(x===null)return{p:null,data:null,next:i};E=x}r.aLo=Math.min(r.dirtyLo,r.cols),r.head=Math.min(r.headHi,r.aLo),r.aHi=Math.max(r.aLo,r.projBase===ro?r.cols:Math.min(r.projBase+1,r.cols)),r.r1=Math.min(r.openR1,r.rows);let e=Math.max(0,r.r1-r.openR0),A=r.raster?0:r.rows*(r.aHi-r.aLo)+e*(r.aLo-r.head)+r.rows*r.head;if(E+A*4>i)return{p:null,data:null,next:i};let P=A>0?ao(a.buffer,a.byteOffset+E,A):null;return{p:r,data:P,next:E+A*4}}var re=new Float32Array(16384);function Et(t,a,o){let i=a.byteLength;if(o+47>i)return{p:null,col:null,next:i};let u=o+3,p=()=>{let n=t.getFloat32(u,!0);return u+=4,n},E=()=>{let n=t.getUint32(u,!0);return u+=4,n},y={x:p(),y:p(),w:p(),h:p(),barFrac:p(),zoneFrac:p(),opacity:p(),steepness:p(),normMax:p(),backdrop:E(),rows:E()},v=y.rows;if(u+v*8>i)return{p:null,col:null,next:i};re.length<v*8&&(re=new Float32Array(Math.max(v*8,re.length*2)));for(let n=0;n<v;n++,u+=4){let r=n*8;re[r]=t.getFloat32(u,!0),re[r+1]=re[r+2]=re[r+3]=0}for(let n=0;n<v;n++){let r=n*8+4;for(let e=0;e<4;e++,u++)re[r+e]=a[u]/255}return{p:y,col:re.subarray(0,v*8),next:u}}var qo=new Float32Array(4);var C={FILL_RECT:1,FILL_ROUND_RECT:27,FILL_ELLIPSE:38,FILL_RECT_SMOOTH_X:30,STROKE_RECT:2,LINE:3,CANDLE:34,CANDLE_BORDERED:36,OHLC_BAR:37,DASHED_LINE:4,POLYLINE:5,TEXT:6,STYLED_TEXT:33,CIRCLE:7,TRIANGLE:8,SAVE:9,RESTORE:10,CLIP_RECT:11,ROTATED_TEXT:12,BUBBLE_3D:13,BUBBLE_PIE:39,FILL_POLYGON:14,DASHED_POLYLINE:15,GRADIENT_RECT:16,GRADIENT_RECT_H:28,GRADIENT_RECT_H_MULTI:29,LINEAR_POLYLINE:17,SMOOTH_POLYLINE:24,BEGIN_HEATMAP_LAYER:18,END_HEATMAP_LAYER:19,HEATMAP_BITMAP:20,LINE_WITH_EXTEND:21,LABEL_CALLOUT:22,HEATMAP_WORLD:23,HEATMAP_BG:31,HEATMAP_WORLD_INTENSITY:32,HEATMAP_FIELD:40,HEATMAP_BOOK_SYNC:41,HEATMAP_DEPTH:42,OVERLAY:43,OB_HEATMAP:35,DRAW_IMAGE:25,FILL_SMOOTH_BAND:26,END_FRAME:255},io=(()=>{try{return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}catch{return!1}})(),so=io?1.5:1/0;function uo(){return typeof window<"u"&&window.devicePixelRatio||1}function co(t,a){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,a):Object.assign(document.createElement("canvas"),{width:t,height:a})}var le=null,yt=null;function lo(t,a){return le?(le.width!==t||le.height!==a)&&(le.width=t,le.height=a):(le=co(t,a),yt=le.getContext("2d")),yt}var Qe=new Float32Array(0);function fo(t){return Qe.length<t&&(Qe=new Float32Array(t)),Qe}var Le=new Float64Array(0),Ze=new Float64Array(0),et=new Float64Array(0),Me=new Float64Array(0);function ho(t){return Le.length<t&&(Le=new Float64Array(t)),Le}function mo(t){return Ze.length<t&&(Ze=new Float64Array(t)),Ze}function bo(t){return et.length<t&&(et=new Float64Array(t)),et}function _o(t){return Me.length<t&&(Me=new Float64Array(t)),Me}function tt(t,a){if(a<2)return;let o=a-1,i=ho(o),u=mo(o),p=bo(o);for(let y=0;y<o;y++){let v=t[y*2],n=t[y*2+1],r=t[(y+1)*2],e=t[(y+1)*2+1];i[y]=r-v,u[y]=e-n,p[y]=i[y]>0?u[y]/i[y]:0}let E=_o(a);E[0]=p[0],E[a-1]=p[o-1];for(let y=1;y<o;y++){let v=p[y-1],n=p[y];E[y]=v*n<=0?0:(v+n)*.5}for(let y=0;y<o;y++){let v=p[y];if(v===0){E[y]=0,E[y+1]=0;continue}let n=E[y]/v,r=E[y+1]/v,e=n*n+r*r;if(e>9){let A=3/Math.sqrt(e);E[y]=A*n*v,E[y+1]=A*r*v}}}function pt(t,a,o){let i=o-1,u=Le,p=Me;for(let E=0;E<i;E++){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(n,r);continue}let A=e/3;t.bezierCurveTo(y+A,v+p[E]*A,n-A,r-p[E+1]*A,n,r)}}function To(t,a,o){let i=o-1,u=Le,p=Me;for(let E=i-1;E>=0;E--){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(y,v);continue}let A=e/3;t.bezierCurveTo(n-A,r-p[E+1]*A,y+A,v+p[E]*A,y,v)}}var Ft=["left","center","right"],Oe=new Map,Eo=4096;function yo(t,a,o,i){return t<<24|a<<16|o<<8|i}function O(t,a,o,i){let u=yo(t,a,o,i),p=Oe.get(u);return p||(p=`rgba(${t},${a},${o},${(i/255).toFixed(3)})`,Oe.size>=Eo&&Oe.clear(),Oe.set(u,p),p)}var po=new TextDecoder,Rt=typeof SharedArrayBuffer>"u"?null:SharedArrayBuffer,at=t=>Rt&&t.buffer instanceof Rt?t.slice():t,ke=(t,a,o)=>po.decode(at(t.subarray(a,a+o))),Fo=.0137;function Te(t){return Math.round(t+Fo)}function Xe(t,a){return Te(t*a)/a}function ot(t,a){return $e?Ce(t,a):t}var Ge=new Map;function He(t,a){let o=Ge.get(a);if(o!==void 0)return o;let i=t.font,u=t.textBaseline;t.font=a,t.textBaseline="alphabetic";let p=t.measureText("0"),E=p.actualBoundingBoxAscent||0,y=p.actualBoundingBoxDescent||0;return o=(E-y)/2,(!Number.isFinite(o)||o===0)&&(o=(parseFloat(a)||11)*.35),Ge.size>=256&&Ge.clear(),Ge.set(a,o),t.font=i,t.textBaseline=u,o}var At=new WeakMap;function Ro(t,a,o,i,u){let p=At.get(t);p||(p=new Map,At.set(t,p));let E=Math.round(a),y=`${E}|${o}|${i}|${u}`,v=p.get(y);if(v)return v;let n=-E*.25,r=-E*.25,e=t.createRadialGradient(n,r,E*.08,0,0,E);e.addColorStop(0,i),e.addColorStop(1,o);let A=null;u&&(A=t.createRadialGradient(0,0,E*.85,0,0,E*1.2),A.addColorStop(0,u),A.addColorStop(1,u.replace(/[\d.]+\)$/,"0)")));let P=E*.2,x=t.createRadialGradient(n,r,0,n,r,P);return x.addColorStop(0,"rgba(255,255,255,0.22)"),x.addColorStop(1,"rgba(255,255,255,0)"),v={body:e,glow:A,spec:x,hlX:n,hlY:r,specR:P},p.set(y,v),v}function me(t,a,o){let i=Math.max(1,Math.round(a*o)),u=Te(t*o)/o;return i&1?u+.5/o:u}var $e=!0;var wt=0,vt=!1;function nt(t,a){return vt?Ce(t,a):t}function rt(t,a){return vt?Xe(t,a):t}function Ce(t,a){return(Te(t*a+wt)-wt)/a}function be(t,a,o){if(!$e)return t;let i=Ce(t,o);return Math.max(1,Math.round(a*o))&1?i+.5/o:i}function _e(t,a,o,i,u){if(!$e)return St(t,a,o,i,u);let p=Ce(t,u),E=Te(a*u),y=Ce(t+o,u),v=Te((a+i)*u);return{x:p,y:E/u,w:y-p,h:(v-E)/u}}function Ao(t,a,o,i,u){return{x:Math.round(t*u)/u,y:Math.round(a*u)/u,w:Math.max(1,Math.round(o*u))/u,h:Math.max(1,Math.round(i*u))/u}}function St(t,a,o,i,u){let p=Te(a*u),E=Te((a+i)*u);return{x:t,y:p/u,w:o,h:(E-p)/u}}function xt(t,a,o,i,u=null,p=null,E=null,y=null){let v=a.buffer;if(o+i>v.byteLength)return;let n=new DataView(v,o,i),r=new Uint8Array(v,o,i),e=0,A="",P="",x=-1,X="",c=Math.max(1,Math.abs(t.getTransform?.().a||uo())),de=null,I=[],L=y&&y.geom&&y.geom.available?y.geom:null,z=t,te=!1,oe="";for(;e<i;){let he=r[e];if(e+=1,he===C.END_FRAME)break;switch(he){case C.FILL_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,0,0,0,0,0,0,0);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b);let R=_e(s,d,m,l,c);t.fillRect(R.x,R.y,R.w,R.h);break}case C.FILL_RECT_SMOOTH_X:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,0,0,0,0,0,0,1);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b);let R=St(s,d,m,l,c);t.fillRect(R.x,R.y,R.w,R.h);break}case C.FILL_ELLIPSE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s-m,d-l,m*2,l*2,f,h,_,F,-1,0,0,0,0,0,2);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b),t.beginPath(),t.ellipse(s,d,Math.max(m,.1),Math.max(l,.1),0,0,Math.PI*2),t.fill();break}case C.FILL_ROUND_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,b,0,0,0,0,0,0);break}let R=O(f,h,_,F);R!==A&&(t.fillStyle=R,A=R);let T=_e(s,d,m,l,c),w=Math.min(b,T.w*.5,T.h*.5);w<=.5?t.fillRect(T.x,T.y,T.w,T.h):(t.beginPath(),t.moveTo(T.x+w,T.y),t.lineTo(T.x+T.w-w,T.y),t.arcTo(T.x+T.w,T.y,T.x+T.w,T.y+w,w),t.lineTo(T.x+T.w,T.y+T.h-w),t.arcTo(T.x+T.w,T.y+T.h,T.x+T.w-w,T.y+T.h,w),t.lineTo(T.x+w,T.y+T.h),t.arcTo(T.x,T.y+T.h,T.x,T.y+T.h-w,w),t.lineTo(T.x,T.y+w),t.arcTo(T.x,T.y,T.x+w,T.y,w),t.closePath(),t.fill());break}case C.STROKE_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){let k=b*.5;L.rect(s-k,d-k,m+b,l+b,0,0,0,0,0,b,f,h,_,F,0);break}let R=O(f,h,_,F);R!==P&&(t.strokeStyle=R,P=R),b!==x&&(t.lineWidth=b,x=b);let T=be(s,b,c),w=me(d,b,c),D=$e?Math.round(m*c)/c:m,M=Math.round(l*c)/c;t.strokeRect(T,w,D,M);break}case C.LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,F,b,0,0);break}let R=O(f,h,_,F);t.beginPath(),R!==P&&(t.strokeStyle=R,P=R),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke();break}case C.CANDLE:case C.CANDLE_BORDERED:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=r[e+3],R=O(r[e],r[e+1],r[e+2],b);e+=4;let T=r[e+3],w=O(r[e],r[e+1],r[e+2],T);e+=4;let D=null;he===C.CANDLE_BORDERED&&(D=O(r[e],r[e+1],r[e+2],r[e+3]),e+=4);let M=Math.max(1,Math.floor(_*c)),k=Math.max(1,Math.floor(F*c));M>k&&(M=k);let B=Math.min(Math.max(1,Math.floor(h*c)),k);B<M?B=M:(B^M)&1&&(B-=1);let N=s*c,$=M&1?Math.round(N-.5)+.5:Math.round(N),g=Math.max(1,Math.round(c)),U=Math.round(Math.min(l,f)*c),G=Math.max(U+g,Math.round(Math.max(l,f)*c)),W=Math.round(Math.min(d,m)*c),S=Math.max(W+1,Math.round(Math.max(d,m)*c)),V=Math.min(d,m),Be=Math.max(d,m),Ke=Math.min(l,f),qe=Math.max(l,f);if(V<Ke&&W>=U&&(W=U-1),Be>qe&&S<=G&&(S=G+1),T>0&&(W<U||S>G)){w!==A&&(t.fillStyle=w,A=w);let je=($-M/2)/c,Je=M/c;b===255?t.fillRect(je,W/c,Je,(S-W)/c):(W<U&&t.fillRect(je,W/c,Je,(U-W)/c),S>G&&t.fillRect(je,G/c,Je,(S-G)/c))}let K=$-B/2,J=G-U;if(D===null){b>0&&(R!==A&&(t.fillStyle=R,A=R),t.fillRect(K/c,U/c,B/c,J/c));break}let j=Math.max(1,Math.floor(c));if(D!==A&&(t.fillStyle=D,A=D),B<=2*j||J<=2*j){t.fillRect(K/c,U/c,B/c,J/c);break}b===255?t.fillRect(K/c,U/c,B/c,J/c):(t.fillRect(K/c,U/c,B/c,j/c),t.fillRect(K/c,(G-j)/c,B/c,j/c),t.fillRect(K/c,(U+j)/c,j/c,(J-2*j)/c),t.fillRect((K+B-j)/c,(U+j)/c,j/c,(J-2*j)/c)),b>0&&(R!==A&&(t.fillStyle=R,A=R),t.fillRect((K+j)/c,(U+j)/c,(B-2*j)/c,(J-2*j)/c));break}case C.OHLC_BAR:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let F=r[e];e+=1;let b=Math.max(1,Math.floor(h*c)),R=Math.max(1,Math.floor(c)),T=F&1?R:Math.max(R,Math.floor(b/6));T>b&&(T=b);let w=s*c,M=(T&1?Math.round(w-.5)+.5:Math.round(w))-T/2,k=Math.round(Math.min(m,l)*c),B=Math.max(k+1,Math.round(Math.max(m,l)*c));_!==A&&(t.fillStyle=_,A=_),t.fillRect(M/c,k/c,T/c,(B-k)/c);let N=Math.floor((Math.floor(b*.8)-T)/2);if(N>=1){if(!(F&2)){let g=Math.round(d*c-T/2);t.fillRect((M-N)/c,g/c,N/c,T/c)}let $=Math.round(f*c-T/2);t.fillRect((M+T)/c,$/c,N/c,T/c)}break}case C.DASHED_LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,F,b,R,T);break}let w=O(f,h,_,F);t.beginPath(),w!==P&&(t.strokeStyle=w,P=w),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([R,T]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke(),t.setLineDash([]);break}case C.LINEAR_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];e+=4;let h=n.getFloat32(e,!0);if(e+=4,L){let F=0,b=0;for(let R=0;R<s;R++){let T=n.getFloat32(e,!0),w=n.getFloat32(e+4,!0);e+=8,R>0&&L.seg(F,b,T,w,d,m,l,f,h,0,0),F=T,b=w}break}let _=O(d,m,l,f);if(s>1){t.beginPath(),_!==P&&(t.strokeStyle=_,P=_),h!==x&&(t.lineWidth=h,x=h),t.setLineDash([]),t.lineJoin="miter",t.lineCap="butt",t.miterLimit=10;let F=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4,t.moveTo(F,b);for(let R=1;R<s;R++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke()}else e+=s*8;break}case C.SMOOTH_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>1){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.stroke()}else e+=s*8;break}case C.POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>0){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;if(t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2)t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3]);else{t.moveTo(l[0],l[1]);for(let f=0;f<s-1;f++){let h=f>0?f-1:0,_=f,F=f+1,b=f<s-2?f+2:s-1,R=l[h*2],T=l[h*2+1],w=l[_*2],D=l[_*2+1],M=l[F*2],k=l[F*2+1],B=l[b*2],N=l[b*2+1],$=w+(M-R)/6,g=D+(k-T)/6,U=M-(B-w)/6,G=k-(N-D)/6;t.bezierCurveTo($,g,U,G,M,k)}}t.stroke()}break}case C.TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h,m!==A&&(t.fillStyle=m,A=m);let F=`${Math.round(l)}px "IBM Plex Mono",monospace`;F!==X&&(t.font=F,X=F),t.textAlign=Ft[f]||"left",t.textBaseline="alphabetic";let b=d+He(t,F);t.fillText(_,ot(s,c),Xe(b,c));break}case C.STYLED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=r[e];e+=1;let _=n.getUint16(e,!0);e+=2;let F=ke(r,e,_);e+=_,m!==A&&(t.fillStyle=m,A=m);let b=h&2?"italic ":"",R=h&1?"700 ":"",T=`${b}${R}${Math.round(l)}px "IBM Plex Mono",monospace`;T!==X&&(t.font=T,X=T),t.textAlign=Ft[f]||"left",t.textBaseline="alphabetic";let w=d+He(t,T);t.fillText(F,ot(s,c),Xe(w,c));break}case C.CIRCLE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3],F=L?"":O(l,f,h,_);e+=4;let b=r[e],R=r[e+1],T=r[e+2],w=r[e+3],D=L?"":O(b,R,T,w);e+=4;let M=n.getFloat32(e,!0);if(e+=4,L){L.disc(s,d,m,l,f,h,_,b,R,T,w,0,0,0,0,M,0);break}t.beginPath(),t.arc(s,d,m,0,Math.PI*2),F!==A&&(t.fillStyle=F,A=F),t.fill(),M>0&&(D!==P&&(t.strokeStyle=D,P=D),M!==x&&(t.lineWidth=M,x=M),t.stroke());break}case C.TRIANGLE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=r[e],F=r[e+1],b=r[e+2],R=r[e+3];if(e+=4,L){L.tri(s,d,m,l,f,h,_,F,b,R);break}let T=O(_,F,b,R);t.beginPath(),t.moveTo(s,d),t.lineTo(m,l),t.lineTo(f,h),t.closePath(),T!==A&&(t.fillStyle=T,A=T),t.fill();break}case C.SAVE:{t.save(),I.push(de);break}case C.RESTORE:{t.restore(),de=I.length?I.pop():null,L&&L.setClip(de),A="",P="",x=-1,X="";break}case C.CLIP_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=_e(s,d,m,l,c);t.beginPath(),t.rect(f.x,f.y,f.w,f.h),t.clip(),de=f,L&&L.setClip(f);break}case C.ROTATED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h;let F=`${l}px sans-serif`;F!==X&&(t.font=F,X=F),m!==A&&(t.fillStyle=m,A=m),t.textAlign="center",t.textBaseline="alphabetic";let b=He(t,F);t.save(),t.translate(s,d),t.rotate(f),t.fillText(_,0,b),t.restore();break}case C.BUBBLE_PIE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=r[e],R=r[e+1],T=r[e+2],w=r[e+3];e+=4;let D=r[e]!==0;if(e+=1,L){L.pie(s,d,m,l,f,h,_,F,b,R,T,w,D);break}ft(t,s,d,m,l,f,h,_,F,b,R,T,w,D),A="";break}case C.BUBBLE_3D:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3];e+=4;let F=r[e],b=r[e+1],R=r[e+2],T=r[e+3];e+=4;let w=r[e],D=r[e+1],M=r[e+2],k=r[e+3];e+=4;let B=n.getFloat32(e,!0);e+=4;let N=m;if(L){L.disc(s,d,N,l,f,h,_,w,D,M,k,F,b,R,T,B,N<4?0:1);break}if(N<4){let $=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`;t.beginPath(),t.arc(s,d,N,0,Math.PI*2),t.fillStyle=$,t.fill(),A=""}else{let $=Math.round(N),g=N>=6,U=N>=16,G=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`,W=`rgba(${F},${b},${R},${(T/255).toFixed(3)})`,S=U?`rgba(${w},${D},${M},${(k/255*.5).toFixed(3)})`:null,V=Ro(t,$,G,W,S);t.save(),t.translate(s,d),U&&V.glow&&(t.beginPath(),t.arc(0,0,$*1.2,0,Math.PI*2),t.fillStyle=V.glow,t.fill()),t.beginPath(),t.arc(0,0,$,0,Math.PI*2),t.fillStyle=V.body,t.fill(),g&&(t.beginPath(),t.arc(V.hlX,V.hlY,V.specR,0,Math.PI*2),t.fillStyle=V.spec,t.fill()),t.restore(),A=""}break}case C.FILL_POLYGON:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];if(e+=4,L){let _=fo(s*2);for(let F=0;F<s;F++)_[F*2]=n.getFloat32(e,!0),_[F*2+1]=n.getFloat32(e+4,!0),e+=8;L.poly(_,s,d,m,l,f);break}let h=O(d,m,l,f);if(s>2){t.beginPath();let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4,t.moveTo(_,F);for(let b=1;b<s;b++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.closePath(),h!==A&&(t.fillStyle=h,A=h),t.fill()}else e+=s*8;break}case C.FILL_SMOOTH_BAND:{let s=n.getUint16(e,!0);e+=2;let d=n.getUint16(e,!0);e+=2;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=new Float32Array(s*2);for(let h=0;h<s;h++)l[h*2]=n.getFloat32(e,!0),e+=4,l[h*2+1]=n.getFloat32(e,!0),e+=4;let f=new Float32Array(d*2);for(let h=0;h<d;h++)f[h*2]=n.getFloat32(e,!0),e+=4,f[h*2+1]=n.getFloat32(e,!0),e+=4;s>=2&&d>=2&&(t.beginPath(),m!==A&&(t.fillStyle=m,A=m),s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.lineTo(f[(d-1)*2],f[(d-1)*2+1]),d===2?t.lineTo(f[0],f[1]):(tt(f,d),To(t,f,d)),t.closePath(),t.fill());break}case C.DASHED_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);if(e+=4,s>1){t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([l,f]),t.lineJoin="round";let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4,t.moveTo(h,_);for(let F=1;F<s;F++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke(),t.setLineDash([])}else e+=s*8;break}case C.GRADIENT_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),F=t.createLinearGradient(_.x,_.y,_.x,_.y+_.h);F.addColorStop(0,f),F.addColorStop(1,h),t.fillStyle=F,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),F=t.createLinearGradient(_.x,_.y,_.x+_.w,_.y);F.addColorStop(0,f),F.addColorStop(1,h),t.fillStyle=F,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H_MULTI:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=_e(s,d,m,l,c),_=t.createLinearGradient(h.x,h.y,h.x+h.w,h.y);for(let F=0;F<f;F++){let b=n.getFloat32(e,!0);e+=4;let R=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4,_.addColorStop(b<0?0:b>1?1:b,R)}t.fillStyle=_,A="",t.fillRect(h.x,h.y,h.w,h.h);break}case C.BEGIN_HEATMAP_LAYER:{let s=e-1,d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);if(e+=4,!u||l===0)break;let f=z.canvas.width,h=z.canvas.height,_=`${d}|${m}|${f}|${h}|${c}`;if(u.getKey()===_&&u.getCanvas()){let F=f/c,b=h/c;z.drawImage(u.getCanvas(),0,0,F,b),e=s+l}else{let F=Math.min(c,so),b=Math.max(1,Math.round(f/c*F)),R=Math.max(1,Math.round(h/c*F)),T=u.ensureSize(b,R,F);if(!T)break;T.save(),T.setTransform(1,0,0,1,0,0),T.clearRect(0,0,b,R),T.restore(),t=T,A="",P="",x=-1,X="",te=!0,oe=_}break}case C.END_HEATMAP_LAYER:{if(!te)break;let s=z.canvas.width/c,d=z.canvas.height/c;z.drawImage(u.getCanvas(),0,0,s,d),u.setKey(oe),t=z,A="",P="",x=-1,X="",te=!1,oe="";break}case C.HEATMAP_BITMAP:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=m*l*4;if(e+f>r.byteLength){e=r.byteLength;break}let h=new Uint8ClampedArray(r.buffer,r.byteOffset+e,f);e+=f;let _=new ImageData(at(h),m,l),F=lo(m,l);if(!F)break;F.putImageData(_,0,0),t.drawImage(le,s,d,m,l);break}case C.HEATMAP_WORLD:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=n.getUint32(e,!0);e+=4;let h=n.getUint32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getFloat32(e,!0);e+=4;let D=n.getFloat32(e,!0);e+=4;let M=n.getFloat32(e,!0);e+=4;let k=r[e];e+=1;let B=(k&1)!==0,N=f*h*4;if(e+N>r.byteLength){e=r.byteLength;break}if(!p||s===0||d===0){e+=N;break}let $=p.ensureSize(s,d);if(!$){e+=N;break}if(B&&$.clearRect(0,0,s,d),N>0){let g=new Uint8ClampedArray(r.buffer,r.byteOffset+e,N),U=new ImageData(at(g),f,h);$.putImageData(U,m,l)}if(e+=N,b>0&&R>0&&D>0&&M>0){let g=Ao(T,w,D,M,c);if(g.w>0&&g.h>0){let U=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(p.getCanvas(),_,F,b,R,g.x,g.y,g.w,g.h),t.imageSmoothingEnabled=U}}break}case C.LINE_WITH_EXTEND:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=r[e];e+=1,f!==P&&(t.strokeStyle=f,P=f),h!==x&&(t.lineWidth=h,x=h),t.setLineDash(_>0?[_,F]:[]);let R=1e5,T=s,w=d,D=m,M=l,k=m-s,B=l-d,N=Math.hypot(k,B);if(N>0&&b!==0){let $=k/N,g=B/N;b&1&&(T=s-$*R,w=d-g*R),b&2&&(D=m+$*R,M=l+g*R),b&4&&g<0&&(T=s-$*R,w=d-g*R),b&8&&g>0&&(D=m+$*R,M=l+g*R)}t.beginPath(),t.moveTo(be(T,h,c),me(w,h,c)),t.lineTo(be(D,h,c),me(M,h,c)),t.stroke(),_>0&&t.setLineDash([]);break}case C.LABEL_CALLOUT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=r[e];e+=1;let b=r[e];e+=1;let R=n.getUint16(e,!0);e+=2;let T=ke(r,e,R);e+=R;let w=`${Math.round(h)}px "IBM Plex Mono",monospace`;w!==X&&(t.font=w,X=w);let D=4,M=6,k=T.indexOf(`
|
|
372
|
+
}`;var ht=[null,null,null,null];function Ne(t,a,o,i){if(a%4===0)return new Uint32Array(t,a,o);let u=ht[i];return(!u||u.length<o)&&(u=ht[i]=new Uint32Array(Math.max(o,16384))),new Uint8Array(u.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),u.subarray(0,o)}function mt(t,a,o){let i=a.byteLength;if(o+27>i)return{p:null,next:i};let u={layer:a[o],flags:a[o+1]},p=o+3,E=()=>{let r=t.getUint32(p,!0);return p+=4,r};u.head=E(),u.tail=E(),u.histN=E(),u.liveN=E(),u.idCap=E(),u.preN=E();let y=u.histN*4,v=u.liveN*5,n=u.preN*4;return p+(y+v+n)*4>i?{p:null,next:i}:(u.hist=y?Ne(a.buffer,a.byteOffset+p,y,0):null,p+=y*4,u.live=v?Ne(a.buffer,a.byteOffset+p,v,1):null,p+=v*4,u.pre=n?Ne(a.buffer,a.byteOffset+p,n,3):null,p+=n*4,{p:u,next:p})}function bt(t,a,o){let i=()=>{let E=t.getInt32(o,!0);return o+=4,E},u=()=>{let E=t.getUint32(o,!0);return o+=4,E},p={bucket:i(),shiftE:i(),nB:u(),shiftK:i(),rowAgg:i(),nK:u(),t0Ceil:i(),tmaxFloor:i(),openFloor:i(),openOk:u(),openC1:i(),tip:u(),liveUntil:u(),histFrom:u(),walkHi:u(),aTo:u(),bFrom:u(),bTo:u(),hFrom:u(),hTo:u(),dimLife:i(),dim:0};return p.dim=t.getFloat32(o,!0),o+=4,{k:p,o}}function _t(t,a,o){let i=o.nB+2*o.nK;if(a+i*4>t.byteLength)return null;let u=Ne(t.buffer,t.byteOffset+a,i,2),p=new Int32Array(u.buffer,u.byteOffset,i);return o.colLut=p.subarray(0,o.nB),o.bandLut=p.subarray(o.nB),a+i*4}var no=32,ro=4294967295;var xe=null;function ao(t,a,o){return a%4===0?new Float32Array(t,a,o):((!xe||xe.length<o)&&(xe=new Float32Array(Math.max(o,65536))),new Uint8Array(xe.buffer,0,o*4).set(new Uint8Array(t,a,o*4)),xe.subarray(0,o))}function Tt(t,a,o){let i=a.byteLength;if(o+104>i)return{p:null,data:null,next:i};let u=a[o],p=a[o+1],E=o+3,y=()=>{let x=t.getUint32(E,!0);return E+=4,x},v=()=>{let x=t.getInt32(E,!0);return E+=4,x},n=()=>{let x=t.getFloat32(E,!0);return E+=4,x},r={layer:u,flags:p,seq:y(),baseSeq:y(),cols:y(),rows:y(),shiftX:v(),shiftY:v(),dirtyLo:y(),openR0:y(),openR1:y(),dilateLo:y(),sigma:n(),radius:y(),visTop:y(),rowsVis:y(),hi:n(),lo:n(),gain:n(),curveB:n(),breakpoint:n(),filter:n(),projBase:y(),openEnd:y(),fadeFrom:y(),fadeSpan:n(),headHi:y()};if(p&no){if(E+81>i)return{p:null,data:null,next:i};let x=bt(t,a,E);r.raster=x.k,E=x.o}if(E+=1+a[E],r.raster){let x=_t(a,E,r.raster);if(x===null)return{p:null,data:null,next:i};E=x}r.aLo=Math.min(r.dirtyLo,r.cols),r.head=Math.min(r.headHi,r.aLo),r.aHi=Math.max(r.aLo,r.projBase===ro?r.cols:Math.min(r.projBase+1,r.cols)),r.r1=Math.min(r.openR1,r.rows);let e=Math.max(0,r.r1-r.openR0),A=r.raster?0:r.rows*(r.aHi-r.aLo)+e*(r.aLo-r.head)+r.rows*r.head;if(E+A*4>i)return{p:null,data:null,next:i};let P=A>0?ao(a.buffer,a.byteOffset+E,A):null;return{p:r,data:P,next:E+A*4}}var re=new Float32Array(16384);function Et(t,a,o){let i=a.byteLength;if(o+47>i)return{p:null,col:null,next:i};let u=o+3,p=()=>{let n=t.getFloat32(u,!0);return u+=4,n},E=()=>{let n=t.getUint32(u,!0);return u+=4,n},y={x:p(),y:p(),w:p(),h:p(),barFrac:p(),zoneFrac:p(),opacity:p(),steepness:p(),normMax:p(),backdrop:E(),rows:E()},v=y.rows;if(u+v*8>i)return{p:null,col:null,next:i};re.length<v*8&&(re=new Float32Array(Math.max(v*8,re.length*2)));for(let n=0;n<v;n++,u+=4){let r=n*8;re[r]=t.getFloat32(u,!0),re[r+1]=re[r+2]=re[r+3]=0}for(let n=0;n<v;n++){let r=n*8+4;for(let e=0;e<4;e++,u++)re[r+e]=a[u]/255}return{p:y,col:re.subarray(0,v*8),next:u}}var qo=new Float32Array(4);var C={FILL_RECT:1,FILL_ROUND_RECT:27,FILL_ELLIPSE:38,FILL_RECT_SMOOTH_X:30,STROKE_RECT:2,LINE:3,CANDLE:34,CANDLE_BORDERED:36,OHLC_BAR:37,DASHED_LINE:4,POLYLINE:5,TEXT:6,STYLED_TEXT:33,CIRCLE:7,TRIANGLE:8,SAVE:9,RESTORE:10,CLIP_RECT:11,ROTATED_TEXT:12,BUBBLE_3D:13,BUBBLE_PIE:39,FILL_POLYGON:14,DASHED_POLYLINE:15,GRADIENT_RECT:16,GRADIENT_RECT_H:28,GRADIENT_RECT_H_MULTI:29,LINEAR_POLYLINE:17,SMOOTH_POLYLINE:24,BEGIN_HEATMAP_LAYER:18,END_HEATMAP_LAYER:19,HEATMAP_BITMAP:20,LINE_WITH_EXTEND:21,LABEL_CALLOUT:22,HEATMAP_WORLD:23,HEATMAP_BG:31,HEATMAP_WORLD_INTENSITY:32,HEATMAP_FIELD:40,HEATMAP_BOOK_SYNC:41,HEATMAP_DEPTH:42,OVERLAY:43,OB_HEATMAP:35,DRAW_IMAGE:25,FILL_SMOOTH_BAND:26,END_FRAME:255},io=(()=>{try{return typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches}catch{return!1}})(),so=io?1.5:1/0;function uo(){return typeof window<"u"&&window.devicePixelRatio||1}function co(t,a){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,a):Object.assign(document.createElement("canvas"),{width:t,height:a})}var le=null,yt=null;function lo(t,a){return le?(le.width!==t||le.height!==a)&&(le.width=t,le.height=a):(le=co(t,a),yt=le.getContext("2d")),yt}var Qe=new Float32Array(0);function fo(t){return Qe.length<t&&(Qe=new Float32Array(t)),Qe}var Le=new Float64Array(0),Ze=new Float64Array(0),et=new Float64Array(0),Me=new Float64Array(0);function ho(t){return Le.length<t&&(Le=new Float64Array(t)),Le}function mo(t){return Ze.length<t&&(Ze=new Float64Array(t)),Ze}function bo(t){return et.length<t&&(et=new Float64Array(t)),et}function _o(t){return Me.length<t&&(Me=new Float64Array(t)),Me}function tt(t,a){if(a<2)return;let o=a-1,i=ho(o),u=mo(o),p=bo(o);for(let y=0;y<o;y++){let v=t[y*2],n=t[y*2+1],r=t[(y+1)*2],e=t[(y+1)*2+1];i[y]=r-v,u[y]=e-n,p[y]=i[y]>0?u[y]/i[y]:0}let E=_o(a);E[0]=p[0],E[a-1]=p[o-1];for(let y=1;y<o;y++){let v=p[y-1],n=p[y];E[y]=v*n<=0?0:(v+n)*.5}for(let y=0;y<o;y++){let v=p[y];if(v===0){E[y]=0,E[y+1]=0;continue}let n=E[y]/v,r=E[y+1]/v,e=n*n+r*r;if(e>9){let A=3/Math.sqrt(e);E[y]=A*n*v,E[y+1]=A*r*v}}}function pt(t,a,o){let i=o-1,u=Le,p=Me;for(let E=0;E<i;E++){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(n,r);continue}let A=e/3;t.bezierCurveTo(y+A,v+p[E]*A,n-A,r-p[E+1]*A,n,r)}}function To(t,a,o){let i=o-1,u=Le,p=Me;for(let E=i-1;E>=0;E--){let y=a[E*2],v=a[E*2+1],n=a[(E+1)*2],r=a[(E+1)*2+1],e=u[E];if(e<=0){t.lineTo(y,v);continue}let A=e/3;t.bezierCurveTo(n-A,r-p[E+1]*A,y+A,v+p[E]*A,y,v)}}var Ft=["left","center","right"],Oe=new Map,Eo=4096;function yo(t,a,o,i){return t<<24|a<<16|o<<8|i}function O(t,a,o,i){let u=yo(t,a,o,i),p=Oe.get(u);return p||(p=`rgba(${t},${a},${o},${(i/255).toFixed(3)})`,Oe.size>=Eo&&Oe.clear(),Oe.set(u,p),p)}var po=new TextDecoder,Rt=typeof SharedArrayBuffer>"u"?null:SharedArrayBuffer,at=t=>Rt&&t.buffer instanceof Rt?t.slice():t,ke=(t,a,o)=>po.decode(at(t.subarray(a,a+o))),Fo=.0137;function Te(t){return Math.round(t+Fo)}function Xe(t,a){return Te(t*a)/a}function ot(t,a){return $e?Ce(t,a):t}var Ge=new Map;function He(t,a){let o=Ge.get(a);if(o!==void 0)return o;let i=t.font,u=t.textBaseline;t.font=a,t.textBaseline="alphabetic";let p=t.measureText("0"),E=p.actualBoundingBoxAscent||0,y=p.actualBoundingBoxDescent||0;return o=(E-y)/2,(!Number.isFinite(o)||o===0)&&(o=(parseFloat(a)||11)*.35),Ge.size>=256&&Ge.clear(),Ge.set(a,o),t.font=i,t.textBaseline=u,o}var At=new WeakMap;function Ro(t,a,o,i,u){let p=At.get(t);p||(p=new Map,At.set(t,p));let E=Math.round(a),y=`${E}|${o}|${i}|${u}`,v=p.get(y);if(v)return v;let n=-E*.25,r=-E*.25,e=t.createRadialGradient(n,r,E*.08,0,0,E);e.addColorStop(0,i),e.addColorStop(1,o);let A=null;u&&(A=t.createRadialGradient(0,0,E*.85,0,0,E*1.2),A.addColorStop(0,u),A.addColorStop(1,u.replace(/[\d.]+\)$/,"0)")));let P=E*.2,x=t.createRadialGradient(n,r,0,n,r,P);return x.addColorStop(0,"rgba(255,255,255,0.22)"),x.addColorStop(1,"rgba(255,255,255,0)"),v={body:e,glow:A,spec:x,hlX:n,hlY:r,specR:P},p.set(y,v),v}function me(t,a,o){let i=Math.max(1,Math.round(a*o)),u=Te(t*o)/o;return i&1?u+.5/o:u}var $e=!0;var wt=0,vt=!1;function nt(t,a){return vt?Ce(t,a):t}function rt(t,a){return vt?Xe(t,a):t}function Ce(t,a){return(Te(t*a+wt)-wt)/a}function be(t,a,o){if(!$e)return t;let i=Ce(t,o);return Math.max(1,Math.round(a*o))&1?i+.5/o:i}function _e(t,a,o,i,u){if(!$e)return St(t,a,o,i,u);let p=Ce(t,u),E=Te(a*u),y=Ce(t+o,u),v=Te((a+i)*u);return{x:p,y:E/u,w:y-p,h:(v-E)/u}}function Ao(t,a,o,i,u){return{x:Math.round(t*u)/u,y:Math.round(a*u)/u,w:Math.max(1,Math.round(o*u))/u,h:Math.max(1,Math.round(i*u))/u}}function St(t,a,o,i,u){let p=Te(a*u),E=Te((a+i)*u);return{x:t,y:p/u,w:o,h:(E-p)/u}}function xt(t,a,o,i,u=null,p=null,E=null,y=null){let v=a.buffer;if(o+i>v.byteLength)return;let n=new DataView(v,o,i),r=new Uint8Array(v,o,i),e=0,A="",P="",x=-1,X="",c=Math.max(1,Math.abs(t.getTransform?.().a||uo())),de=null,I=[],L=y&&y.geom&&y.geom.available?y.geom:null,z=t,te=!1,oe="";for(;e<i;){let he=r[e];if(e+=1,he===C.END_FRAME)break;switch(he){case C.FILL_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,0,0,0,0,0,0,0);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b);let R=_e(s,d,m,l,c);t.fillRect(R.x,R.y,R.w,R.h);break}case C.FILL_RECT_SMOOTH_X:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,0,0,0,0,0,0,1);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b);let R=St(s,d,m,l,c);t.fillRect(R.x,R.y,R.w,R.h);break}case C.FILL_ELLIPSE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];if(e+=4,L){L.rect(s-m,d-l,m*2,l*2,f,h,_,F,-1,0,0,0,0,0,2);break}let b=O(f,h,_,F);b!==A&&(t.fillStyle=b,A=b),t.beginPath(),t.ellipse(s,d,Math.max(m,.1),Math.max(l,.1),0,0,Math.PI*2),t.fill();break}case C.FILL_ROUND_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.rect(s,d,m,l,f,h,_,F,b,0,0,0,0,0,0);break}let R=O(f,h,_,F);R!==A&&(t.fillStyle=R,A=R);let T=_e(s,d,m,l,c),w=Math.min(b,T.w*.5,T.h*.5);w<=.5?t.fillRect(T.x,T.y,T.w,T.h):(t.beginPath(),t.moveTo(T.x+w,T.y),t.lineTo(T.x+T.w-w,T.y),t.arcTo(T.x+T.w,T.y,T.x+T.w,T.y+w,w),t.lineTo(T.x+T.w,T.y+T.h-w),t.arcTo(T.x+T.w,T.y+T.h,T.x+T.w-w,T.y+T.h,w),t.lineTo(T.x+w,T.y+T.h),t.arcTo(T.x,T.y+T.h,T.x,T.y+T.h-w,w),t.lineTo(T.x,T.y+w),t.arcTo(T.x,T.y,T.x+w,T.y,w),t.closePath(),t.fill());break}case C.STROKE_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){let k=b*.5;L.rect(s-k,d-k,m+b,l+b,0,0,0,0,0,b,f,h,_,F,0);break}let R=O(f,h,_,F);R!==P&&(t.strokeStyle=R,P=R),b!==x&&(t.lineWidth=b,x=b);let T=be(s,b,c),w=me(d,b,c),D=$e?Math.round(m*c)/c:m,M=Math.round(l*c)/c;t.strokeRect(T,w,D,M);break}case C.LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,F,b,0,0);break}let R=O(f,h,_,F);t.beginPath(),R!==P&&(t.strokeStyle=R,P=R),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke();break}case C.CANDLE:case C.CANDLE_BORDERED:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=r[e+3],R=O(r[e],r[e+1],r[e+2],b);e+=4;let T=r[e+3],w=O(r[e],r[e+1],r[e+2],T);e+=4;let D=null;he===C.CANDLE_BORDERED&&(D=O(r[e],r[e+1],r[e+2],r[e+3]),e+=4);let M=Math.max(1,Math.floor(_*c)),k=Math.max(1,Math.floor(F*c));M>k&&(M=k);let B=Math.min(Math.max(1,Math.floor(h*c)),k);B<M?B=M:(B^M)&1&&(B-=1);let g=s*c,$=M&1?Math.round(g-.5)+.5:Math.round(g),N=Math.max(1,Math.round(c)),U=Math.round(Math.min(l,f)*c),G=Math.max(U+N,Math.round(Math.max(l,f)*c)),W=Math.round(Math.min(d,m)*c),S=Math.max(W+1,Math.round(Math.max(d,m)*c)),V=Math.min(d,m),Be=Math.max(d,m),Ke=Math.min(l,f),qe=Math.max(l,f);if(V<Ke&&W>=U&&(W=U-1),Be>qe&&S<=G&&(S=G+1),T>0&&(W<U||S>G)){w!==A&&(t.fillStyle=w,A=w);let je=($-M/2)/c,Je=M/c;b===255?t.fillRect(je,W/c,Je,(S-W)/c):(W<U&&t.fillRect(je,W/c,Je,(U-W)/c),S>G&&t.fillRect(je,G/c,Je,(S-G)/c))}let K=$-B/2,J=G-U;if(D===null){b>0&&(R!==A&&(t.fillStyle=R,A=R),t.fillRect(K/c,U/c,B/c,J/c));break}let j=Math.max(1,Math.floor(c));if(D!==A&&(t.fillStyle=D,A=D),B<=2*j||J<=2*j){t.fillRect(K/c,U/c,B/c,J/c);break}b===255?t.fillRect(K/c,U/c,B/c,J/c):(t.fillRect(K/c,U/c,B/c,j/c),t.fillRect(K/c,(G-j)/c,B/c,j/c),t.fillRect(K/c,(U+j)/c,j/c,(J-2*j)/c),t.fillRect((K+B-j)/c,(U+j)/c,j/c,(J-2*j)/c)),b>0&&(R!==A&&(t.fillStyle=R,A=R),t.fillRect((K+j)/c,(U+j)/c,(B-2*j)/c,(J-2*j)/c));break}case C.OHLC_BAR:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let F=r[e];e+=1;let b=Math.max(1,Math.floor(h*c)),R=Math.max(1,Math.floor(c)),T=F&1?R:Math.max(R,Math.floor(b/6));T>b&&(T=b);let w=s*c,M=(T&1?Math.round(w-.5)+.5:Math.round(w))-T/2,k=Math.round(Math.min(m,l)*c),B=Math.max(k+1,Math.round(Math.max(m,l)*c));_!==A&&(t.fillStyle=_,A=_),t.fillRect(M/c,k/c,T/c,(B-k)/c);let g=Math.floor((Math.floor(b*.8)-T)/2);if(g>=1){if(!(F&2)){let N=Math.round(d*c-T/2);t.fillRect((M-g)/c,N/c,g/c,T/c)}let $=Math.round(f*c-T/2);t.fillRect((M+T)/c,$/c,g/c,T/c)}break}case C.DASHED_LINE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);if(e+=4,L){L.seg(s,d,m,l,f,h,_,F,b,R,T);break}let w=O(f,h,_,F);t.beginPath(),w!==P&&(t.strokeStyle=w,P=w),b!==x&&(t.lineWidth=b,x=b),t.setLineDash([R,T]),t.moveTo(be(s,b,c),me(d,b,c)),t.lineTo(be(m,b,c),me(l,b,c)),t.stroke(),t.setLineDash([]);break}case C.LINEAR_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];e+=4;let h=n.getFloat32(e,!0);if(e+=4,L){let F=0,b=0;for(let R=0;R<s;R++){let T=n.getFloat32(e,!0),w=n.getFloat32(e+4,!0);e+=8,R>0&&L.seg(F,b,T,w,d,m,l,f,h,0,0),F=T,b=w}break}let _=O(d,m,l,f);if(s>1){t.beginPath(),_!==P&&(t.strokeStyle=_,P=_),h!==x&&(t.lineWidth=h,x=h),t.setLineDash([]),t.lineJoin="miter",t.lineCap="butt",t.miterLimit=10;let F=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4,t.moveTo(F,b);for(let R=1;R<s;R++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke()}else e+=s*8;break}case C.SMOOTH_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>1){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.stroke()}else e+=s*8;break}case C.POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);if(e+=4,s>0){let l=new Float32Array(s*2);for(let f=0;f<s;f++)l[f*2]=n.getFloat32(e,!0),e+=4,l[f*2+1]=n.getFloat32(e,!0),e+=4;if(t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([]),t.lineJoin="round",t.lineCap="round",s===2)t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3]);else{t.moveTo(l[0],l[1]);for(let f=0;f<s-1;f++){let h=f>0?f-1:0,_=f,F=f+1,b=f<s-2?f+2:s-1,R=l[h*2],T=l[h*2+1],w=l[_*2],D=l[_*2+1],M=l[F*2],k=l[F*2+1],B=l[b*2],g=l[b*2+1],$=w+(M-R)/6,N=D+(k-T)/6,U=M-(B-w)/6,G=k-(g-D)/6;t.bezierCurveTo($,N,U,G,M,k)}}t.stroke()}break}case C.TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h,m!==A&&(t.fillStyle=m,A=m);let F=`${Math.round(l)}px "IBM Plex Mono",monospace`;F!==X&&(t.font=F,X=F),t.textAlign=Ft[f]||"left",t.textBaseline="alphabetic";let b=d+He(t,F);t.fillText(_,ot(s,c),Xe(b,c));break}case C.STYLED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=r[e];e+=1;let _=n.getUint16(e,!0);e+=2;let F=ke(r,e,_);e+=_,m!==A&&(t.fillStyle=m,A=m);let b=h&2?"italic ":"",R=h&1?"700 ":"",T=`${b}${R}${Math.round(l)}px "IBM Plex Mono",monospace`;T!==X&&(t.font=T,X=T),t.textAlign=Ft[f]||"left",t.textBaseline="alphabetic";let w=d+He(t,T);t.fillText(F,ot(s,c),Xe(w,c));break}case C.CIRCLE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3],F=L?"":O(l,f,h,_);e+=4;let b=r[e],R=r[e+1],T=r[e+2],w=r[e+3],D=L?"":O(b,R,T,w);e+=4;let M=n.getFloat32(e,!0);if(e+=4,L){L.disc(s,d,m,l,f,h,_,b,R,T,w,0,0,0,0,M,0);break}t.beginPath(),t.arc(s,d,m,0,Math.PI*2),F!==A&&(t.fillStyle=F,A=F),t.fill(),M>0&&(D!==P&&(t.strokeStyle=D,P=D),M!==x&&(t.lineWidth=M,x=M),t.stroke());break}case C.TRIANGLE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=r[e],F=r[e+1],b=r[e+2],R=r[e+3];if(e+=4,L){L.tri(s,d,m,l,f,h,_,F,b,R);break}let T=O(_,F,b,R);t.beginPath(),t.moveTo(s,d),t.lineTo(m,l),t.lineTo(f,h),t.closePath(),T!==A&&(t.fillStyle=T,A=T),t.fill();break}case C.SAVE:{t.save(),I.push(de);break}case C.RESTORE:{t.restore(),de=I.length?I.pop():null,L&&L.setClip(de),A="",P="",x=-1,X="";break}case C.CLIP_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=_e(s,d,m,l,c);t.beginPath(),t.rect(f.x,f.y,f.w,f.h),t.clip(),de=f,L&&L.setClip(f);break}case C.ROTATED_TEXT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getUint16(e,!0);e+=2;let _=ke(r,e,h);e+=h;let F=`${l}px sans-serif`;F!==X&&(t.font=F,X=F),m!==A&&(t.fillStyle=m,A=m),t.textAlign="center",t.textBaseline="alphabetic";let b=He(t,F);t.save(),t.translate(s,d),t.rotate(f),t.fillText(_,0,b),t.restore();break}case C.BUBBLE_PIE:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e],h=r[e+1],_=r[e+2],F=r[e+3];e+=4;let b=r[e],R=r[e+1],T=r[e+2],w=r[e+3];e+=4;let D=r[e]!==0;if(e+=1,L){L.pie(s,d,m,l,f,h,_,F,b,R,T,w,D);break}ft(t,s,d,m,l,f,h,_,F,b,R,T,w,D),A="";break}case C.BUBBLE_3D:{let s=nt(n.getFloat32(e,!0),c);e+=4;let d=rt(n.getFloat32(e,!0),c);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=r[e],f=r[e+1],h=r[e+2],_=r[e+3];e+=4;let F=r[e],b=r[e+1],R=r[e+2],T=r[e+3];e+=4;let w=r[e],D=r[e+1],M=r[e+2],k=r[e+3];e+=4;let B=n.getFloat32(e,!0);e+=4;let g=m;if(L){L.disc(s,d,g,l,f,h,_,w,D,M,k,F,b,R,T,B,g<4?0:1);break}if(g<4){let $=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`;t.beginPath(),t.arc(s,d,g,0,Math.PI*2),t.fillStyle=$,t.fill(),A=""}else{let $=Math.round(g),N=g>=6,U=g>=16,G=`rgba(${l},${f},${h},${(_/255).toFixed(3)})`,W=`rgba(${F},${b},${R},${(T/255).toFixed(3)})`,S=U?`rgba(${w},${D},${M},${(k/255*.5).toFixed(3)})`:null,V=Ro(t,$,G,W,S);t.save(),t.translate(s,d),U&&V.glow&&(t.beginPath(),t.arc(0,0,$*1.2,0,Math.PI*2),t.fillStyle=V.glow,t.fill()),t.beginPath(),t.arc(0,0,$,0,Math.PI*2),t.fillStyle=V.body,t.fill(),N&&(t.beginPath(),t.arc(V.hlX,V.hlY,V.specR,0,Math.PI*2),t.fillStyle=V.spec,t.fill()),t.restore(),A=""}break}case C.FILL_POLYGON:{let s=n.getUint16(e,!0);e+=2;let d=r[e],m=r[e+1],l=r[e+2],f=r[e+3];if(e+=4,L){let _=fo(s*2);for(let F=0;F<s;F++)_[F*2]=n.getFloat32(e,!0),_[F*2+1]=n.getFloat32(e+4,!0),e+=8;L.poly(_,s,d,m,l,f);break}let h=O(d,m,l,f);if(s>2){t.beginPath();let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4,t.moveTo(_,F);for(let b=1;b<s;b++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.closePath(),h!==A&&(t.fillStyle=h,A=h),t.fill()}else e+=s*8;break}case C.FILL_SMOOTH_BAND:{let s=n.getUint16(e,!0);e+=2;let d=n.getUint16(e,!0);e+=2;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=new Float32Array(s*2);for(let h=0;h<s;h++)l[h*2]=n.getFloat32(e,!0),e+=4,l[h*2+1]=n.getFloat32(e,!0),e+=4;let f=new Float32Array(d*2);for(let h=0;h<d;h++)f[h*2]=n.getFloat32(e,!0),e+=4,f[h*2+1]=n.getFloat32(e,!0),e+=4;s>=2&&d>=2&&(t.beginPath(),m!==A&&(t.fillStyle=m,A=m),s===2?(t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3])):(tt(l,s),t.moveTo(l[0],l[1]),pt(t,l,s)),t.lineTo(f[(d-1)*2],f[(d-1)*2+1]),d===2?t.lineTo(f[0],f[1]):(tt(f,d),To(t,f,d)),t.closePath(),t.fill());break}case C.DASHED_POLYLINE:{let s=n.getUint16(e,!0);e+=2;let d=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);if(e+=4,s>1){t.beginPath(),d!==P&&(t.strokeStyle=d,P=d),m!==x&&(t.lineWidth=m,x=m),t.setLineDash([l,f]),t.lineJoin="round";let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4,t.moveTo(h,_);for(let F=1;F<s;F++)t.lineTo(n.getFloat32(e,!0),n.getFloat32(e+4,!0)),e+=8;t.stroke(),t.setLineDash([])}else e+=s*8;break}case C.GRADIENT_RECT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),F=t.createLinearGradient(_.x,_.y,_.x,_.y+_.h);F.addColorStop(0,f),F.addColorStop(1,h),t.fillStyle=F,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let _=_e(s,d,m,l,c),F=t.createLinearGradient(_.x,_.y,_.x+_.w,_.y);F.addColorStop(0,f),F.addColorStop(1,h),t.fillStyle=F,A="",t.fillRect(_.x,_.y,_.w,_.h);break}case C.GRADIENT_RECT_H_MULTI:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=r[e];e+=1;let h=_e(s,d,m,l,c),_=t.createLinearGradient(h.x,h.y,h.x+h.w,h.y);for(let F=0;F<f;F++){let b=n.getFloat32(e,!0);e+=4;let R=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4,_.addColorStop(b<0?0:b>1?1:b,R)}t.fillStyle=_,A="",t.fillRect(h.x,h.y,h.w,h.h);break}case C.BEGIN_HEATMAP_LAYER:{let s=e-1,d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);if(e+=4,!u||l===0)break;let f=z.canvas.width,h=z.canvas.height,_=`${d}|${m}|${f}|${h}|${c}`;if(u.getKey()===_&&u.getCanvas()){let F=f/c,b=h/c;z.drawImage(u.getCanvas(),0,0,F,b),e=s+l}else{let F=Math.min(c,so),b=Math.max(1,Math.round(f/c*F)),R=Math.max(1,Math.round(h/c*F)),T=u.ensureSize(b,R,F);if(!T)break;T.save(),T.setTransform(1,0,0,1,0,0),T.clearRect(0,0,b,R),T.restore(),t=T,A="",P="",x=-1,X="",te=!0,oe=_}break}case C.END_HEATMAP_LAYER:{if(!te)break;let s=z.canvas.width/c,d=z.canvas.height/c;z.drawImage(u.getCanvas(),0,0,s,d),u.setKey(oe),t=z,A="",P="",x=-1,X="",te=!1,oe="";break}case C.HEATMAP_BITMAP:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=m*l*4;if(e+f>r.byteLength){e=r.byteLength;break}let h=new Uint8ClampedArray(r.buffer,r.byteOffset+e,f);e+=f;let _=new ImageData(at(h),m,l),F=lo(m,l);if(!F)break;F.putImageData(_,0,0),t.drawImage(le,s,d,m,l);break}case C.HEATMAP_WORLD:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=n.getUint32(e,!0);e+=4;let h=n.getUint32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getFloat32(e,!0);e+=4;let D=n.getFloat32(e,!0);e+=4;let M=n.getFloat32(e,!0);e+=4;let k=r[e];e+=1;let B=(k&1)!==0,g=f*h*4;if(e+g>r.byteLength){e=r.byteLength;break}if(!p||s===0||d===0){e+=g;break}let $=p.ensureSize(s,d);if(!$){e+=g;break}if(B&&$.clearRect(0,0,s,d),g>0){let N=new Uint8ClampedArray(r.buffer,r.byteOffset+e,g),U=new ImageData(at(N),f,h);$.putImageData(U,m,l)}if(e+=g,b>0&&R>0&&D>0&&M>0){let N=Ao(T,w,D,M,c);if(N.w>0&&N.h>0){let U=t.imageSmoothingEnabled;t.imageSmoothingEnabled=!1,t.drawImage(p.getCanvas(),_,F,b,R,N.x,N.y,N.w,N.h),t.imageSmoothingEnabled=U}}break}case C.LINE_WITH_EXTEND:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=r[e];e+=1,f!==P&&(t.strokeStyle=f,P=f),h!==x&&(t.lineWidth=h,x=h),t.setLineDash(_>0?[_,F]:[]);let R=1e5,T=s,w=d,D=m,M=l,k=m-s,B=l-d,g=Math.hypot(k,B);if(g>0&&b!==0){let $=k/g,N=B/g;b&1&&(T=s-$*R,w=d-N*R),b&2&&(D=m+$*R,M=l+N*R),b&4&&N<0&&(T=s-$*R,w=d-N*R),b&8&&N>0&&(D=m+$*R,M=l+N*R)}t.beginPath(),t.moveTo(be(T,h,c),me(w,h,c)),t.lineTo(be(D,h,c),me(M,h,c)),t.stroke(),_>0&&t.setLineDash([]);break}case C.LABEL_CALLOUT:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let l=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let f=O(r[e],r[e+1],r[e+2],r[e+3]);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=r[e];e+=1;let b=r[e];e+=1;let R=n.getUint16(e,!0);e+=2;let T=ke(r,e,R);e+=R;let w=`${Math.round(h)}px "IBM Plex Mono",monospace`;w!==X&&(t.font=w,X=w);let D=4,M=6,k=T.indexOf(`
|
|
373
373
|
`)>=0?T.split(`
|
|
374
|
-
`):[T],B=Math.round(h),
|
|
374
|
+
`):[T],B=Math.round(h),g=3,$=0;for(let K=0;K<k.length;K++){let J=t.measureText(k[K]).width;J>$&&($=J)}let N=k.length*B+(k.length-1)*g+D*2,U=Math.ceil($)+D*2,G,W;switch(b){case 1:W=d-M-N,G=s-U/2;break;case 2:W=d+M,G=s-U/2;break;case 3:W=d-N/2,G=s+M;break;case 4:W=d-N/2,G=s-M-U;break;default:W=d-N/2,F===1?G=s-U/2:F===2?G=s-U:G=s;break}let S=_e(G,W,U,N,c),V=Math.min(3,S.w*.5,S.h*.5),Be=()=>{t.beginPath(),V<=.5?t.rect(S.x,S.y,S.w,S.h):(t.moveTo(S.x+V,S.y),t.lineTo(S.x+S.w-V,S.y),t.arcTo(S.x+S.w,S.y,S.x+S.w,S.y+V,V),t.lineTo(S.x+S.w,S.y+S.h-V),t.arcTo(S.x+S.w,S.y+S.h,S.x+S.w-V,S.y+S.h,V),t.lineTo(S.x+V,S.y+S.h),t.arcTo(S.x,S.y+S.h,S.x,S.y+S.h-V,V),t.lineTo(S.x,S.y+V),t.arcTo(S.x,S.y,S.x+V,S.y,V)),t.closePath()};if(m!==A&&(t.fillStyle=m,A=m),Be(),t.fill(),_>0&&(l!==P&&(t.strokeStyle=l,P=l),_!==x&&(t.lineWidth=_,x=_),t.setLineDash([]),Be(),t.stroke()),b>=1&&b<=4){switch(m!==A&&(t.fillStyle=m,A=m),t.beginPath(),b){case 1:t.moveTo(s-M/2,W+N),t.lineTo(s+M/2,W+N),t.lineTo(s,d);break;case 2:t.moveTo(s-M/2,W),t.lineTo(s+M/2,W),t.lineTo(s,d);break;case 3:t.moveTo(G,d-M/2),t.lineTo(G,d+M/2),t.lineTo(s,d);break;case 4:t.moveTo(G+U,d-M/2),t.lineTo(G+U,d+M/2),t.lineTo(s,d);break}t.closePath(),t.fill()}f!==A&&(t.fillStyle=f,A=f),t.textAlign="center",t.textBaseline="alphabetic";let Ke=He(t,w),qe=G+U/2;for(let K=0;K<k.length;K++){let J=W+D+B/2+K*(B+g);t.fillText(k[K],ot(qe,c),Xe(J+Ke,c))}break}case C.DRAW_IMAGE:{let s=n.getFloat32(e,!0);e+=4;let d=n.getFloat32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getUint32(e,!0);if(e+=4,!E||f===0||m<=0||l<=0)break;let h=E.get(f);if(!h)break;try{t.drawImage(h,s,d,m,l)}catch(_){E.delete(f),console.warn("[canvasRenderer] drawImage failed for id="+f,_?.message||_)}break}case C.HEATMAP_BG:{let s=r[e],d=r[e+1],m=r[e+2],l=r[e+3],f=r[e+4],h=r[e+5],_=r[e+6],F=r[e+7],b=r[e+8]!==0;e+=9,y&&(t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,t.canvas.width,t.canvas.height),t.restore(),y.bg(s,d,m,l,f,h,_,F,b));break}case C.HEATMAP_WORLD_INTENSITY:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getUint32(e,!0);e+=4;let l=n.getUint32(e,!0);e+=4;let f=n.getUint32(e,!0);e+=4;let h=n.getUint32(e,!0);e+=4;let _=n.getFloat32(e,!0);e+=4;let F=n.getFloat32(e,!0);e+=4;let b=n.getFloat32(e,!0);e+=4;let R=n.getFloat32(e,!0);e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getFloat32(e,!0);e+=4;let D=n.getFloat32(e,!0);e+=4;let M=n.getFloat32(e,!0);e+=4;let k=n.getUint32(e,!0);e+=4;let B=r[e];e+=1;let g=n.getFloat32(e,!0);e+=4;let $=(B&2)!==0,N=(B&4)!==0,U=B&8?1:0,G=f*h;if(e+G>r.byteLength){e=r.byteLength;break}if(y){let W=G>0?new Uint8Array(r.buffer,r.byteOffset+e,G):null;y.heatmap({worldCols:s,worldRows:d,patchX:m,patchY:l,patchW:f,patchH:h,srcX:_,srcY:F,srcW:b,srcH:R,destX:T,destY:w,destW:D,destH:M,lutSeq:k,hd:$,subpx:N,subTexelX:g,fullRebuild:(B&1)!==0,layer:U,clip:de},W)}e+=G;break}case C.HEATMAP_FIELD:{let s=Tt(n,r,e);if(e=s.next,s.p&&y&&typeof y.heatField=="function"&&y.heatField(s.p,s.data),a.buffer!==v)return;break}case C.HEATMAP_BOOK_SYNC:{let s=mt(n,r,e);e=s.next,s.p&&y&&typeof y.heatBook=="function"&&y.heatBook(s.p);break}case C.HEATMAP_DEPTH:{let s=Et(n,r,e);e=s.next,s.p&&y&&typeof y.heatDepth=="function"&&y.heatDepth(s.p,s.col);break}case C.OVERLAY:{e+=3,L&&(L.setClip(null),L.flush(),L=null);break}case C.OB_HEATMAP:{let s=n.getUint32(e,!0);e+=4;let d=n.getUint32(e,!0);e+=4;let m=n.getFloat32(e,!0);e+=4;let l=n.getFloat32(e,!0);e+=4;let f=n.getFloat32(e,!0);e+=4;let h=n.getFloat32(e,!0);e+=4;let _=r[e],F=r[e+1],b=r[e+2],R=r[e+3];e+=4;let T=n.getFloat32(e,!0);e+=4;let w=n.getUint32(e,!0);e+=4,e+=1;let D=s*d*2;if(e+D>r.byteLength){e=r.byteLength;break}y&&typeof y.obHeatmap=="function"&&y.obHeatmap({cols:s,rows:d,destX:m,destY:l,destW:f,destH:h,bgR:_,bgG:F,bgB:b,bgA:R,alphaMul:T,lutSeq:w},D>0?new Uint8Array(r.buffer,r.byteOffset+e,D):null),e+=D;break}default:e=i;break}}if(te&&u){let he=z.canvas.width/c,s=z.canvas.height/c;z.drawImage(u.getCanvas(),0,0,he,s),u.invalidate()}L&&L.flush()}var wo=`#version 300 es
|
|
375
375
|
in vec2 aPos;
|
|
376
376
|
uniform vec4 uRect; // clip-space x0,y0 (bottom-left) .. x1,y1 (top-right)
|
|
377
377
|
out vec2 vUv;
|
|
@@ -411,4 +411,4 @@ void main() {
|
|
|
411
411
|
// best is the normalised byte; land on the matching LUT texel centre.
|
|
412
412
|
vec4 lut = texture(uLut, vec2((best * 255.0 + 0.5) / 256.0, side > 0.5 ? 0.75 : 0.25));
|
|
413
413
|
outColor = vec4(lut.rgb, lut.a * uAlpha);
|
|
414
|
-
}`;function Lt(t,a,o){let i=t.createShader(a);if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){let u=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`ob shader compile failed: ${u}`)}return i}function Mt(t,a={}){let o=null,i=null,u=null,p=null,E=null,y=null,v=null,n=null,r=null,e=null,A=-1,P=1,x=1,X=1,c=!1;try{o=t.getContext("webgl2",{alpha:!0,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,desynchronized:!1,premultipliedAlpha:!1})}catch{o=null}if(o)try{let I=Lt(o,o.VERTEX_SHADER,wo),L=Lt(o,o.FRAGMENT_SHADER,vo);if(i=o.createProgram(),o.attachShader(i,I),o.attachShader(i,L),o.linkProgram(i),o.deleteShader(I),o.deleteShader(L),!o.getProgramParameter(i,o.LINK_STATUS))throw new Error(`ob program link failed: ${o.getProgramInfoLog(i)}`);u=o.createVertexArray(),o.bindVertexArray(u),p=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,p),o.bufferData(o.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),o.STATIC_DRAW);let z=o.getAttribLocation(i,"aPos");o.enableVertexAttribArray(z),o.vertexAttribPointer(z,2,o.FLOAT,!1,0,0),o.bindVertexArray(null),E=o.createTexture(),o.bindTexture(o.TEXTURE_2D,E);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);y=o.createTexture(),o.bindTexture(o.TEXTURE_2D,y);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);v=o.getUniformLocation(i,"uRect"),n=o.getUniformLocation(i,"uGrid"),r=o.getUniformLocation(i,"uAlpha"),e=o.getUniformLocation(i,"uPool"),o.useProgram(i),o.uniform1i(o.getUniformLocation(i,"uCells"),0),o.uniform1i(o.getUniformLocation(i,"uLut"),1),o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_ALIGNMENT,1),x=t.width,X=t.height,o.viewport(0,0,x,X),c=!0}catch(I){console.warn("[ObWebgl] init failed:",I?.message||I),c=!1}o&&typeof t.addEventListener=="function"&&t.addEventListener("webglcontextlost",I=>{I.preventDefault(),c=!1;try{a.onContextLost?.()}catch{}});function de(I){if(I===A)return;let L=a.fetchLut?.();!L||L.length<512*4||(o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,y),o.texImage2D(o.TEXTURE_2D,0,o.RGBA8,256,2,0,o.RGBA,o.UNSIGNED_BYTE,L),A=I)}return{get available(){return c},obHeatmap(I,L){if(!c||(o.viewport(0,0,x,X),o.clearColor(I.bgR/255,I.bgG/255,I.bgB/255,I.bgA/255),o.clear(o.COLOR_BUFFER_BIT),!I.cols||!I.rows||!L||I.destW<=0||I.destH<=0)||L.length<I.cols*I.rows*2)return;o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,E),o.texImage2D(o.TEXTURE_2D,0,o.RG8,I.cols,I.rows,0,o.RG,o.UNSIGNED_BYTE,L),de(I.lutSeq);let z=I.destX*P/x*2-1,te=(I.destX+I.destW)*P/x*2-1,oe=1-I.destY*P/X*2,he=1-(I.destY+I.destH)*P/X*2;o.useProgram(i),o.bindVertexArray(u),o.uniform4f(v,z,he,te,oe),o.uniform2f(n,I.cols,I.rows),o.uniform1f(r,I.alphaMul),o.uniform1f(e,Math.min(32,Math.max(1,Math.ceil(I.rows/Math.max(I.destH*P,1))))),o.drawArrays(o.TRIANGLE_STRIP,0,4),o.bindVertexArray(null)},resize(I,L,z){x=Math.max(1,I),X=Math.max(1,L),P=z>0?z:1,c&&o.viewport(0,0,x,X)},destroy(){if(c=!1,!!o){try{o.deleteTexture(E),o.deleteTexture(y),o.deleteBuffer(p),o.deleteVertexArray(u),o.deleteProgram(i),o.getExtension("WEBGL_lose_context")?.loseContext()}catch{}o=null}}}}function Ct(t,a,o){let i=t&&t[a];typeof i=="function"&&i.apply(t,o||[])}var It=Object.freeze({COL:0,PRICE:1,BID:2,ASK:3,BUY:4,SELL:5,SESS_BUY:6,SESS_SELL:7,TIME_MS:8,CUM:9,PEAK_BID:10,PEAK_ASK:11,LTQ:12,LTQ_AGE:13,LTQ_BUY:14,IMB:15,IMB_BUY:16,PULL:17,PULL_AGE:18,PULL_BID:19,ABSORB:20,MARKER:21,WALL:22,LEN:23});function Dt(t){if(!t||!t.length)return"";let a="";for(let o=0;o<t.length;o++){let i=o===It.LTQ_AGE||o===It.PULL_AGE?Math.floor(t[o]/250):t[o];a+=`${i}|`}return a}var We=null,Ie=null,pe=null;async function So(){let t=typeof globalThis>"u"?null:globalThis,a=t&&t.__mrdWasmResp;if(!a)return null;t.__mrdWasmResp=null;try{let o=await a;return o&&o.ok?o:null}catch{return null}}function xo(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let t=a=>new URL(a+self.location.search,self.location.href).href;return{glue:t("./chart_engine.js"),wasm:t("./chart_engine_bg.wasm")}}var Pt=null,Lo=!1;function Mo(){return!!Pt&&typeof WorkerGlobalScope>"u"&&globalThis.crossOriginIsolated===!0&&typeof SharedArrayBuffer<"u"}async function Co(){let t=new URL(Pt,globalThis.location?.href),a=new URL(t.pathname.replace(/\.js$/,"_bg.wasm")+t.search,t),o=await import(t.href);return await o.default({module_or_path:a.href}),o}async function Ut(){return We?{module:We,memory:Ie}:pe||(pe=(async()=>{let t=globalThis.__mrdBoot;if(t?.("engine"),Mo())try{let p=await Co();return Ie=p.wasm_memory(),We=p,Lo=!0,t?.("engineReady"),{module:p,memory:Ie}}catch(p){console.warn("[mrd-chart] shared-memory engine failed, using the standard build:",p?.message||p)}let a=xo(),o=a?await import(a.glue):await import("./chart_engine.js"),i=a?null:await So(),u=a?a.wasm:i;try{await(u?o.default({module_or_path:u}):o.default())}catch(p){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",p);let E=a?a.wasm:new URL("./chart_engine_bg.wasm",import.meta.url),y=await fetch(E);if(!y.ok)throw new Error(`kline-orderbook-chart: engine file request failed (${y.status} ${y.statusText}) at ${E}`);let v=await y.arrayBuffer(),n=new Uint8Array(v,0,Math.min(4,v.byteLength));if(n[0]!==0||n[1]!==97||n[2]!==115||n[3]!==109)throw new Error(`kline-orderbook-chart: ${E} did not return the engine file (got HTML or a 404 page). With Vite, add optimizeDeps: { exclude: ['kline-orderbook-chart'] } to vite.config. See https://tapedelta.com/docs/charting-library/getting-started#bundlers`);await o.default(v)}return Ie=o.wasm_memory(),We=o,t?.("engineReady"),{module:o,memory:Ie}})(),pe.catch(()=>{pe=null}),pe)}async function Bt(t){if(!Array.isArray(t)||!t.length||typeof FontFace!="function"||!self.fonts)return;let a=!1,o=new Promise(u=>setTimeout(()=>{a=!0,u()},1500)),i=t.map(async u=>{try{let p={weight:u.weight,style:u.style};u.unicodeRange&&(p.unicodeRange=u.unicodeRange);let E=new FontFace(u.family,`url(${u.src})`,p);await E.load(),a||self.fonts.add(E)}catch{}});await Promise.race([Promise.all(i),o])}function Nt(t){let a=t.get_hover_price();return a>0?{price:a,qty:t.get_hover_qty(),side:t.get_hover_side()===2?"ask":"bid"}:null}var Io={OrderbookEngine:{gl:!0,readState(t){let a=Nt(t),o=null;if(t.is_range_active()){let i=t.get_range_low_price(),u=t.get_range_high_price();u>i&&(o={low:i,high:u,delta:u-i,deltaPct:i>0?(u-i)/i*100:0,bidQty:t.get_range_bid_qty(),askQty:t.get_range_ask_qty(),ticks:t.get_range_tick_count(),mode:t.get_range_mode()===2?"hover":"measure"})}return{hover:a,range:o}},sig:t=>`${t.hover?`${t.hover.price}|${t.hover.qty}|${t.hover.side}`:""}#${t.range?`${t.range.low}|${t.range.high}|${t.range.bidQty}|${t.range.askQty}|${t.range.mode}`:""}`,clickHover:Nt},DomLadderEngine:{gl:!0,lut:"dom",readState(t){let a=t.get_hover_price();return{hover:a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null,info:a>0&&typeof t.hover_row_info=="function"?t.hover_row_info():null,viewLocked:t.is_view_locked(),m1:t.momentum_1m(),buy1m:t.buy_volume_1m(),sell1m:t.sell_volume_1m(),map:typeof t.ladder_view_map=="function"?t.ladder_view_map():null,lanes:typeof t.ladder_lane_map=="function"?t.ladder_lane_map():null,colScroll:typeof t.column_scroll_state=="function"?t.column_scroll_state():null}},sig:t=>{let a=t.map,o=a&&a.length?`${a.length}|${a[0]}|${a[1]}|${a[2]}|${a[3]}|${a[a.length-1]}`:"",i=t.lanes,u=i&&i.length?i.join("|"):"",p=t.colScroll,E=p&&p.length>=2?`${p[0]}|${p[1]}`:"";return`${t.hover?`${t.hover.price}|${t.hover.side}`:""}#${t.viewLocked}#${t.m1}|${t.buy1m}|${t.sell1m}#${o}#${u}#${E}#${Dt(t.info)}`},clickHover(t){let a=t.get_hover_price();return a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null}},MboScannerEngine:{gl:!1,selfPaced:!0,idleTickMs:250,readState(t){try{return JSON.parse(t.status_json())}catch{return{}}},sig:t=>`${t.rows}|${t.live}|${t.since}|${t.sort}|${t.desc}|${Math.floor((t.frames||0)/500)}|${(t.quietMs||0)>5e3}`,clickHover:()=>null,ports:{s:"mbo_summary",e:"mbo_events"}}},De=new Map,H=null,Z=null,ut=null,Ot=null,Y=null,q=null,Q=null,se=null,ie=1,Re=!1,Ye=!1,ee=!1,Ue=!1,we=!1,Ee=!0,fe=null,gt="",kt=typeof self.requestAnimationFrame=="function",ze=!0,it=0,Do=1500;function ye(t,a,o){try{self.postMessage({t,...a},o||[])}catch{}}function Ae(t){ee||(ee=!0,Ve(),ye("dead",{err:String(t&&t.message?t.message:t)}))}function ae(){Ye||!Re||ee||we||fe!==null||ze&&(fe=kt?self.requestAnimationFrame(st):setTimeout(st,16))}function Ve(){ue!==null&&(clearTimeout(ue),ue=null),fe!==null&&(kt?self.cancelAnimationFrame(fe):clearTimeout(fe),fe=null)}var ue=null;function Po(){Ye||!Re||ee||we||!ze||fe!==null||ue!==null||(ue=setTimeout(()=>{ue=null,st()},Z.idleTickMs))}function Pe(){Ee=!0,ae()}function Gt(){try{q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.fillStyle="#787b86",q.font=`600 ${Math.round(12*ie)}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`,q.textAlign="center",q.textBaseline="middle",q.fillText("Enterprise license required",Y.width/2,Y.height/2),q.restore()}catch{}}function ct(){if(ee)return!1;if(we)return Gt(),!0;try{if(H.render()>0){let a=H.get_command_buffer_ptr(),o=H.get_command_buffer_len();q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.restore(),xt(q,ut,a,o,null,null,null,se)}return!0}catch(t){return t instanceof WebAssembly.RuntimeError&&Ae(t),!1}}function st(){if(fe=null,Ye||!Re||ee||we)return;let t=!1;try{H.set_now_ms?.(Date.now()),t=Ee||H.is_dirty()}catch(i){Ae(i);return}ue!==null&&(clearTimeout(ue),ue=null);let a=Ue&&it>0&&Date.now()-it>Do;t&&Ue&&!a?Ee=!0:t&&(Ee=!ct(),Bo());let o=Ee;if(!o)try{o=Z.selfPaced?H.wants_frame():H.is_dirty()}catch{o=!1}o?ae():Z.idleTickMs&&Po()}function Uo(){if(ee||!Y)return null;let t=Y.width,a=Y.height;if(!(t>0)||!(a>0)||!ct())return null;try{let o=new OffscreenCanvas(t,a),i=o.getContext("2d");return i?(se&&Q&&i.drawImage(Q,0,0),i.drawImage(Y,0,0),o.transferToImageBitmap()):null}catch{return null}}function Bo(){if(ee||!Z)return;let t=null;try{t=Z.readState(H)}catch{return}let a=Z.sig(t);a!==gt&&(gt=a,ye("state",t,t.map&&t.map.buffer?[t.map.buffer]:[]))}function No(){try{H?.set_render_backend(0)}catch{}try{se?.destroy()}catch{}se=null,Pe()}function go(){if(!(!Q||!Z.gl||typeof H.set_render_backend!="function"))try{let t=Z.lut==="dom"?()=>H.dom_lut_rgba():()=>H.ob_lut_rgba(),a=Mt(Q,{fetchLut:t,onContextLost:No});if(!a.available){a.destroy();return}a.resize(Q.width,Q.height,ie),se=a,H.set_render_backend(1)}catch(t){console.warn("[PanelEngine/worker] GL band unavailable, using Canvas2D:",t?.message||t),se=null}}function Fe(t,a){if(!(ee||!H))try{Ct(H,t,a),Ee=!0}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o)}}async function Oo(t){if(Z=Io[t.engine],!Z)throw new Error(`unknown panel engine: ${t.engine}`);Y=t.canvas,Q=t.gl||null,ie=t.dpr||1,we=!!t.blocked;let[{module:a,memory:o}]=await Promise.all([Ut(),Bt(t.opts.fonts)]);ut=o,Ot=a,q=Y.getContext("2d"),q.setTransform(ie,0,0,ie,0,0);let i=a[t.engine];if(typeof i!="function")throw new Error(`engine missing in wasm: ${t.engine}`);H=new i(t.cssW,t.cssH);try{H.set_license_token?.(t.opts.licenseToken||"",Date.now(),t.opts.host||"")}catch(u){console.warn("[PanelEngine/worker] set_license_token failed:",u.message)}for(let[u,p]of t.opts.boot||[])Fe(u,p);go(),we&&Gt(),ye("ready",{})}self.onmessage=t=>{let a=t.data;if(a)switch(a.t){case"init":Oo(a).catch(o=>Ae(o));return;case"call":Fe(a.m,a.a),ae();return;case"calls":for(let[o,i]of a.batch)Fe(o,i);ae();return;case"query":{let o=null;try{let i=H&&H[a.m];typeof i=="function"&&(o=i.apply(H,a.a||[]))}catch{o=null}ye("reply",{id:a.id,v:o});return}case"capture":{let o=Uo();ye("reply",{id:a.id,v:o},o?[o]:[]);return}case"domVol":{let o=a.flat;if(!o)return;for(let i=0;i+2<o.length;i+=3)Fe("push_dom_vol",[o[i],o[i+1],o[i+2]]);ae();return}case"ingest":{if(ee||!H||!a.buf)return;try{H.ingest(new Uint8Array(a.buf))}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o);return}ae();return}case"mbo":{let o=a.flat;if(!o)return;Fe("set_mbo_blocks",[o]),ae();return}case"port":{let o=De.get(a.key);if(o){o.onmessage=null;try{o.close()}catch{}De.delete(a.key)}let i=Z?.ports;if(!a.port||!i)return;De.set(a.key,a.port),a.port.onmessage=u=>{let p=u.data,E=p&&i[p.t];!E||!p.f||(Fe(E,[a.key,p.f]),ae())};return}case"click":{if(ee||!H)return;let o=null;try{H.set_hover(a.x,a.y),o=Z.clickHover(H)}catch{return}Ee=!0,ae(),o&&ye("click",{hover:o});return}case"resize":{if(ee||!H)return;ie=a.dpr||1;let o=Y.width!==a.bufW||Y.height!==a.bufH;Y.width!==a.bufW&&(Y.width=a.bufW),Y.height!==a.bufH&&(Y.height=a.bufH),q.setTransform(ie,0,0,ie,0,0),Q&&(Q.width!==a.bufW&&(Q.width=a.bufW),Q.height!==a.bufH&&(Q.height=a.bufH),se?.resize(a.bufW,a.bufH,ie));try{H.resize(a.cssW,a.cssH)}catch(i){Ae(i);return}o&&ct(),Pe();return}case"life":if(a.v==="start")Re=!0,Pe();else if(a.v==="stop")Re=!1,Ve();else if(a.v==="destroy"){Ye=!0,Re=!1,Ve();for(let o of De.values()){o.onmessage=null;try{o.close()}catch{}}De.clear();try{se?.destroy()}catch{}se=null;try{H?.free()}catch{}H=null}return;case"vis":ze=!!a.v,ze?Pe():Ve();return;case"busy":Ue=!!a.v,it=Ue?Date.now():0,Ue||Pe();return;case"heap":{let o=0;try{o=Ot?.wasm_heap_used?.()||0}catch{}ye("heap",{bytes:ut?.buffer?.byteLength||0,used:o});return}default:}};
|
|
414
|
+
}`;function Lt(t,a,o){let i=t.createShader(a);if(t.shaderSource(i,o),t.compileShader(i),!t.getShaderParameter(i,t.COMPILE_STATUS)){let u=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`ob shader compile failed: ${u}`)}return i}function Mt(t,a={}){let o=null,i=null,u=null,p=null,E=null,y=null,v=null,n=null,r=null,e=null,A=-1,P=1,x=1,X=1,c=!1;try{o=t.getContext("webgl2",{alpha:!0,depth:!1,stencil:!1,antialias:!1,preserveDrawingBuffer:!1,desynchronized:!1,premultipliedAlpha:!1})}catch{o=null}if(o)try{let I=Lt(o,o.VERTEX_SHADER,wo),L=Lt(o,o.FRAGMENT_SHADER,vo);if(i=o.createProgram(),o.attachShader(i,I),o.attachShader(i,L),o.linkProgram(i),o.deleteShader(I),o.deleteShader(L),!o.getProgramParameter(i,o.LINK_STATUS))throw new Error(`ob program link failed: ${o.getProgramInfoLog(i)}`);u=o.createVertexArray(),o.bindVertexArray(u),p=o.createBuffer(),o.bindBuffer(o.ARRAY_BUFFER,p),o.bufferData(o.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),o.STATIC_DRAW);let z=o.getAttribLocation(i,"aPos");o.enableVertexAttribArray(z),o.vertexAttribPointer(z,2,o.FLOAT,!1,0,0),o.bindVertexArray(null),E=o.createTexture(),o.bindTexture(o.TEXTURE_2D,E);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);y=o.createTexture(),o.bindTexture(o.TEXTURE_2D,y);for(let[te,oe]of[[o.TEXTURE_MIN_FILTER,o.NEAREST],[o.TEXTURE_MAG_FILTER,o.NEAREST],[o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE],[o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE]])o.texParameteri(o.TEXTURE_2D,te,oe);v=o.getUniformLocation(i,"uRect"),n=o.getUniformLocation(i,"uGrid"),r=o.getUniformLocation(i,"uAlpha"),e=o.getUniformLocation(i,"uPool"),o.useProgram(i),o.uniform1i(o.getUniformLocation(i,"uCells"),0),o.uniform1i(o.getUniformLocation(i,"uLut"),1),o.disable(o.DEPTH_TEST),o.enable(o.BLEND),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA),o.pixelStorei(o.UNPACK_ALIGNMENT,1),x=t.width,X=t.height,o.viewport(0,0,x,X),c=!0}catch(I){console.warn("[ObWebgl] init failed:",I?.message||I),c=!1}o&&typeof t.addEventListener=="function"&&t.addEventListener("webglcontextlost",I=>{I.preventDefault(),c=!1;try{a.onContextLost?.()}catch{}});function de(I){if(I===A)return;let L=a.fetchLut?.();!L||L.length<512*4||(o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,y),o.texImage2D(o.TEXTURE_2D,0,o.RGBA8,256,2,0,o.RGBA,o.UNSIGNED_BYTE,L),A=I)}return{get available(){return c},obHeatmap(I,L){if(!c||(o.viewport(0,0,x,X),o.clearColor(I.bgR/255,I.bgG/255,I.bgB/255,I.bgA/255),o.clear(o.COLOR_BUFFER_BIT),!I.cols||!I.rows||!L||I.destW<=0||I.destH<=0)||L.length<I.cols*I.rows*2)return;o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,E),o.texImage2D(o.TEXTURE_2D,0,o.RG8,I.cols,I.rows,0,o.RG,o.UNSIGNED_BYTE,L),de(I.lutSeq);let z=I.destX*P/x*2-1,te=(I.destX+I.destW)*P/x*2-1,oe=1-I.destY*P/X*2,he=1-(I.destY+I.destH)*P/X*2;o.useProgram(i),o.bindVertexArray(u),o.uniform4f(v,z,he,te,oe),o.uniform2f(n,I.cols,I.rows),o.uniform1f(r,I.alphaMul),o.uniform1f(e,Math.min(32,Math.max(1,Math.ceil(I.rows/Math.max(I.destH*P,1))))),o.drawArrays(o.TRIANGLE_STRIP,0,4),o.bindVertexArray(null)},resize(I,L,z){x=Math.max(1,I),X=Math.max(1,L),P=z>0?z:1,c&&o.viewport(0,0,x,X)},destroy(){if(c=!1,!!o){try{o.deleteTexture(E),o.deleteTexture(y),o.deleteBuffer(p),o.deleteVertexArray(u),o.deleteProgram(i),o.getExtension("WEBGL_lose_context")?.loseContext()}catch{}o=null}}}}function Ct(t,a,o){let i=t&&t[a];typeof i=="function"&&i.apply(t,o||[])}var It=Object.freeze({COL:0,PRICE:1,BID:2,ASK:3,BUY:4,SELL:5,SESS_BUY:6,SESS_SELL:7,TIME_MS:8,CUM:9,PEAK_BID:10,PEAK_ASK:11,LTQ:12,LTQ_AGE:13,LTQ_BUY:14,IMB:15,IMB_BUY:16,PULL:17,PULL_AGE:18,PULL_BID:19,ABSORB:20,MARKER:21,WALL:22,LEN:23});function Dt(t){if(!t||!t.length)return"";let a="";for(let o=0;o<t.length;o++){let i=o===It.LTQ_AGE||o===It.PULL_AGE?Math.floor(t[o]/250):t[o];a+=`${i}|`}return a}var We=null,Ie=null,pe=null;async function So(){let t=typeof globalThis>"u"?null:globalThis,a=t&&t.__mrdWasmResp;if(!a)return null;t.__mrdWasmResp=null;try{let o=await a;return o&&o.ok?o:null}catch{return null}}function xo(){if(typeof WorkerGlobalScope>"u"||!self.location?.search)return null;let t=a=>new URL(a+self.location.search,self.location.href).href;return{glue:t("./chart_engine.js"),wasm:t("./chart_engine_bg.wasm")}}var Pt=null,Lo=!1;function Mo(){return!!Pt&&typeof WorkerGlobalScope>"u"&&globalThis.crossOriginIsolated===!0&&typeof SharedArrayBuffer<"u"}async function Co(){let t=new URL(Pt,globalThis.location?.href),a=new URL(t.pathname.replace(/\.js$/,"_bg.wasm")+t.search,t),o=await import(t.href);return await o.default({module_or_path:a.href}),o}async function Ut(){return We?{module:We,memory:Ie}:pe||(pe=(async()=>{let t=globalThis.__mrdBoot;if(t?.("engine"),Mo())try{let p=await Co();return Ie=p.wasm_memory(),We=p,Lo=!0,t?.("engineReady"),{module:p,memory:Ie}}catch(p){console.warn("[mrd-chart] shared-memory engine failed, using the standard build:",p?.message||p)}let a=xo(),o=a?await import(a.glue):await import("./chart_engine.js"),i=a?null:await So(),u=a?a.wasm:i;try{await(u?o.default({module_or_path:u}):o.default())}catch(p){console.warn("[mrd-chart] WebAssembly streaming init failed, retrying with arrayBuffer fallback:",p);let E=a?a.wasm:new URL("./chart_engine_bg.wasm",import.meta.url),y=await fetch(E);if(!y.ok)throw new Error(`kline-orderbook-chart: engine file request failed (${y.status} ${y.statusText}) at ${E}`);let v=await y.arrayBuffer(),n=new Uint8Array(v,0,Math.min(4,v.byteLength));if(n[0]!==0||n[1]!==97||n[2]!==115||n[3]!==109)throw new Error(`kline-orderbook-chart: ${E} did not return the engine file (got HTML or a 404 page). With Vite, add optimizeDeps: { exclude: ['kline-orderbook-chart'] } to vite.config. See https://tapedelta.com/docs/charting-library/getting-started#bundlers`);await o.default(v)}return Ie=o.wasm_memory(),We=o,t?.("engineReady"),{module:o,memory:Ie}})(),pe.catch(()=>{pe=null}),pe)}async function Bt(t){if(!Array.isArray(t)||!t.length||typeof FontFace!="function"||!self.fonts)return;let a=!1,o=new Promise(u=>setTimeout(()=>{a=!0,u()},1500)),i=t.map(async u=>{try{let p={weight:u.weight,style:u.style};u.unicodeRange&&(p.unicodeRange=u.unicodeRange);let E=new FontFace(u.family,`url(${u.src})`,p);await E.load(),a||self.fonts.add(E)}catch{}});await Promise.race([Promise.all(i),o])}function gt(t){let a=t.get_hover_price();return a>0?{price:a,qty:t.get_hover_qty(),side:t.get_hover_side()===2?"ask":"bid"}:null}var Io={OrderbookEngine:{gl:!0,readState(t){let a=gt(t),o=null;if(t.is_range_active()){let i=t.get_range_low_price(),u=t.get_range_high_price();u>i&&(o={low:i,high:u,delta:u-i,deltaPct:i>0?(u-i)/i*100:0,bidQty:t.get_range_bid_qty(),askQty:t.get_range_ask_qty(),ticks:t.get_range_tick_count(),mode:t.get_range_mode()===2?"hover":"measure"})}return{hover:a,range:o}},sig:t=>`${t.hover?`${t.hover.price}|${t.hover.qty}|${t.hover.side}`:""}#${t.range?`${t.range.low}|${t.range.high}|${t.range.bidQty}|${t.range.askQty}|${t.range.mode}`:""}`,clickHover:gt},DomLadderEngine:{gl:!0,lut:"dom",readState(t){let a=t.get_hover_price();return{hover:a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null,info:a>0&&typeof t.hover_row_info=="function"?t.hover_row_info():null,viewLocked:t.is_view_locked(),m1:t.momentum_1m(),buy1m:t.buy_volume_1m(),sell1m:t.sell_volume_1m(),map:typeof t.ladder_view_map=="function"?t.ladder_view_map():null,lanes:typeof t.ladder_lane_map=="function"?t.ladder_lane_map():null,colScroll:typeof t.column_scroll_state=="function"?t.column_scroll_state():null}},sig:t=>{let a=t.map,o=a&&a.length?`${a.length}|${a[0]}|${a[1]}|${a[2]}|${a[3]}|${a[a.length-1]}`:"",i=t.lanes,u=i&&i.length?i.join("|"):"",p=t.colScroll,E=p&&p.length>=2?`${p[0]}|${p[1]}`:"";return`${t.hover?`${t.hover.price}|${t.hover.side}`:""}#${t.viewLocked}#${t.m1}|${t.buy1m}|${t.sell1m}#${o}#${u}#${E}#${Dt(t.info)}`},clickHover(t){let a=t.get_hover_price();return a>0?{price:a,side:t.get_hover_side()===1?"ask":"bid"}:null}},MboScannerEngine:{gl:!1,selfPaced:!0,idleTickMs:250,readState(t){try{return JSON.parse(t.status_json())}catch{return{}}},sig:t=>`${t.rows}|${t.live}|${t.since}|${t.sort}|${t.desc}|${Math.floor((t.frames||0)/500)}|${(t.quietMs||0)>5e3}`,clickHover:()=>null,ports:{s:"mbo_summary",e:"mbo_events"}}},De=new Map,H=null,Z=null,ut=null,Ot=null,Y=null,q=null,Q=null,se=null,ie=1,Re=!1,Ye=!1,ee=!1,Ue=!1,we=!1,Ee=!0,fe=null,Nt="",kt=typeof self.requestAnimationFrame=="function",ze=!0,it=0,Do=1500;function ye(t,a,o){try{self.postMessage({t,...a},o||[])}catch{}}function Ae(t){ee||(ee=!0,Ve(),ye("dead",{err:String(t&&t.message?t.message:t)}))}function ae(){Ye||!Re||ee||we||fe!==null||ze&&(fe=kt?self.requestAnimationFrame(st):setTimeout(st,16))}function Ve(){ue!==null&&(clearTimeout(ue),ue=null),fe!==null&&(kt?self.cancelAnimationFrame(fe):clearTimeout(fe),fe=null)}var ue=null;function Po(){Ye||!Re||ee||we||!ze||fe!==null||ue!==null||(ue=setTimeout(()=>{ue=null,st()},Z.idleTickMs))}function Pe(){Ee=!0,ae()}function Gt(){try{q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.fillStyle="#787b86",q.font=`600 ${Math.round(12*ie)}px ui-monospace, 'SF Mono', Menlo, Consolas, monospace`,q.textAlign="center",q.textBaseline="middle",q.fillText("Enterprise license required",Y.width/2,Y.height/2),q.restore()}catch{}}function ct(){if(ee)return!1;if(we)return Gt(),!0;try{if(H.render()>0){let a=H.get_command_buffer_ptr(),o=H.get_command_buffer_len();q.save(),q.setTransform(1,0,0,1,0,0),q.clearRect(0,0,Y.width,Y.height),q.restore(),xt(q,ut,a,o,null,null,null,se)}return!0}catch(t){return t instanceof WebAssembly.RuntimeError&&Ae(t),!1}}function st(){if(fe=null,Ye||!Re||ee||we)return;let t=!1;try{H.set_now_ms?.(Date.now()),t=Ee||H.is_dirty()}catch(i){Ae(i);return}ue!==null&&(clearTimeout(ue),ue=null);let a=Ue&&it>0&&Date.now()-it>Do;t&&Ue&&!a?Ee=!0:t&&(Ee=!ct(),Bo());let o=Ee;if(!o)try{o=Z.selfPaced?H.wants_frame():H.is_dirty()}catch{o=!1}o?ae():Z.idleTickMs&&Po()}function Uo(){if(ee||!Y)return null;let t=Y.width,a=Y.height;if(!(t>0)||!(a>0)||!ct())return null;try{let o=new OffscreenCanvas(t,a),i=o.getContext("2d");return i?(se&&Q&&i.drawImage(Q,0,0),i.drawImage(Y,0,0),o.transferToImageBitmap()):null}catch{return null}}function Bo(){if(ee||!Z)return;let t=null;try{t=Z.readState(H)}catch{return}let a=Z.sig(t);a!==Nt&&(Nt=a,ye("state",t,t.map&&t.map.buffer?[t.map.buffer]:[]))}function go(){try{H?.set_render_backend(0)}catch{}try{se?.destroy()}catch{}se=null,Pe()}function No(){if(!(!Q||!Z.gl||typeof H.set_render_backend!="function"))try{let t=Z.lut==="dom"?()=>H.dom_lut_rgba():()=>H.ob_lut_rgba(),a=Mt(Q,{fetchLut:t,onContextLost:go});if(!a.available){a.destroy();return}a.resize(Q.width,Q.height,ie),se=a,H.set_render_backend(1)}catch(t){console.warn("[PanelEngine/worker] GL band unavailable, using Canvas2D:",t?.message||t),se=null}}function Fe(t,a){if(!(ee||!H))try{Ct(H,t,a),Ee=!0}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o)}}async function Oo(t){if(Z=Io[t.engine],!Z)throw new Error(`unknown panel engine: ${t.engine}`);Y=t.canvas,Q=t.gl||null,ie=t.dpr||1,we=!!t.blocked;let[{module:a,memory:o}]=await Promise.all([Ut(),Bt(t.opts.fonts)]);ut=o,Ot=a,q=Y.getContext("2d"),q.setTransform(ie,0,0,ie,0,0);let i=a[t.engine];if(typeof i!="function")throw new Error(`engine missing in wasm: ${t.engine}`);H=new i(t.cssW,t.cssH);try{H.set_license_token?.(t.opts.licenseToken||"",Date.now(),t.opts.host||"")}catch(u){console.warn("[PanelEngine/worker] set_license_token failed:",u.message)}for(let[u,p]of t.opts.boot||[])Fe(u,p);No(),we&&Gt(),ye("ready",{})}self.onmessage=t=>{let a=t.data;if(a)switch(a.t){case"init":Oo(a).catch(o=>Ae(o));return;case"call":Fe(a.m,a.a),ae();return;case"calls":for(let[o,i]of a.batch)Fe(o,i);ae();return;case"query":{let o=null;try{let i=H&&H[a.m];typeof i=="function"&&(o=i.apply(H,a.a||[]))}catch{o=null}ye("reply",{id:a.id,v:o});return}case"capture":{let o=Uo();ye("reply",{id:a.id,v:o},o?[o]:[]);return}case"domVol":{let o=a.flat;if(!o)return;for(let i=0;i+2<o.length;i+=3)Fe("push_dom_vol",[o[i],o[i+1],o[i+2]]);ae();return}case"ingest":{if(ee||!H||!a.buf)return;try{H.ingest(new Uint8Array(a.buf))}catch(o){o instanceof WebAssembly.RuntimeError&&Ae(o);return}ae();return}case"mbo":{let o=a.flat;if(!o)return;Fe("set_mbo_blocks",[o]),ae();return}case"port":{let o=De.get(a.key);if(o){o.onmessage=null;try{o.close()}catch{}De.delete(a.key)}let i=Z?.ports;if(!a.port||!i)return;De.set(a.key,a.port),a.port.onmessage=u=>{let p=u.data,E=p&&i[p.t];!E||!p.f||(Fe(E,[a.key,p.f]),ae())};return}case"click":{if(ee||!H)return;let o=null;try{H.set_hover(a.x,a.y),o=Z.clickHover(H)}catch{return}Ee=!0,ae(),o&&ye("click",{hover:o});return}case"resize":{if(ee||!H)return;ie=a.dpr||1;let o=Y.width!==a.bufW||Y.height!==a.bufH;Y.width!==a.bufW&&(Y.width=a.bufW),Y.height!==a.bufH&&(Y.height=a.bufH),q.setTransform(ie,0,0,ie,0,0),Q&&(Q.width!==a.bufW&&(Q.width=a.bufW),Q.height!==a.bufH&&(Q.height=a.bufH),se?.resize(a.bufW,a.bufH,ie));try{H.resize(a.cssW,a.cssH)}catch(i){Ae(i);return}o&&ct(),Pe();return}case"life":if(a.v==="start")Re=!0,Pe();else if(a.v==="stop")Re=!1,Ve();else if(a.v==="destroy"){Ye=!0,Re=!1,Ve();for(let o of De.values()){o.onmessage=null;try{o.close()}catch{}}De.clear();try{se?.destroy()}catch{}se=null;try{H?.free()}catch{}H=null}return;case"vis":ze=!!a.v,ze?Pe():Ve();return;case"busy":Ue=!!a.v,it=Ue?Date.now():0,Ue||Pe();return;case"heap":{let o=0;try{o=Ot?.wasm_heap_used?.()||0}catch{}ye("heap",{bytes:ut?.buffer?.byteLength||0,used:o});return}default:}};
|