-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
880 lines (813 loc) · 493 KB
/
Copy pathindex.js
File metadata and controls
880 lines (813 loc) · 493 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
import"./chunk-FPALNCRK.js";import"./chunk-4C666HHU.js";var He=0,ue=0,ui=performance.now();function Bn(){let e=performance.now(),t=e-ui,i=He,r=ue*1e3/t,n=1e3/i,s=ue;return He=0,ue=0,ui=e,{avg:i,real_fps:r,virtual_fps:n,num_frames:s,elapsed:t}}function Nn(e){He=(He*ue+e)/(ue+1),ue+=1}var $=new Map;async function On(e){return await new Promise(requestAnimationFrame),await $.get(e)?.promise}async function pt(e,t){if($.has(e)&&(await $.get(e)?.promise,$.has(e))){await $.get(e)?.promise;return}$.set(e,Promise.withResolvers());try{return await t()}finally{let i=$.get(e);$.delete(e),i?.resolve(void 0)}}var zn=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,Hn=zn?5e6:1e7,Yn=":host{position:absolute;top:0px;left:0px;right:0px;bottom:0px;overflow:scroll;overflow-anchor:none;overscroll-behavior:none;-webkit-overflow-scrolling:touch;}div.rt-virtual-panel{position:absolute;top:0;left:0;right:0;pointer-events:none;}div.rt-scroll-table-clip{position:sticky;contain:strict;overflow-anchor:none;width:100%;height:100%;}slot{position:absolute;overflow:hidden;overflow-anchor:none;}",Wn=":host ::slotted(table){--regular-table--transform-x:0px;--regular-table--transform-y:0px;--regular-table--clip-x:0px;--regular-table--clip-y:0px;}",Un="--regular-table--clip-x",$n="--regular-table--clip-y",Gn="--regular-table--transform-x",Vn="--regular-table--transform-y",jn='<div class="rt-virtual-panel"></div><div class="rt-scroll-table-clip"><slot></slot></div>',Xn=1,qn=class extends HTMLElement{f;a;i;r;G;q;_;b;p;U;s;e;t;it;st;table_model;n;T;Y;h;o;async draw(e={}){return typeof e.throttle<"u"&&!e.throttle?await di.call(this,e):await pt(this,()=>di.call(this,e))}async flush(){do await On(this);while(this.T)}async predraw(e,t,i={}){let{invalid_viewport:r=!0,preserve_width:n=!1,cache:s=!1,scroll_left:o=this.scrollLeft,scroll_top:l=this.scrollTop,container_height:a=t,throttle:u}=i,c=()=>Object.assign(()=>!0,{inline:!0}),d=async()=>(await this.draw({invalid_viewport:r,preserve_width:n,cache:s,throttle:u}),c());if(!this.t)return console.warn("data listener not configured"),c();let{num_columns:h,num_rows:p}=await this.j(s);if(!this.e.row_height)return await d();let f=p||0,_=h||0,g=this.K(()=>e,()=>t,()=>a);this.r=g;let m=Math.round(this.P(f)),v=Number.isFinite(g.containerHeight)?Math.min(l,Math.max(0,m-g.containerHeight)):l,b,y,A=!1,T=!1;for(let k=0;k<2;k++){let P=this.t.row_headers_length,S=this.Z(f,_,v,o),D=this.Ce(S,_);if(D===void 0)return await d();if(S.end_col=Math.min(_,D+Xn),k===0){let{invalid_row:E,invalid_column:R}=this.J(S);T=!!(this.p||R),A=T||E||r}else if(Math.floor(S.start_col)===Math.floor(b.start_col)&&Math.ceil(S.end_col)<=Math.ceil(b.end_col)){S.end_col=b.end_col,b=S;break}if(b=S,!A)break;y=await this.t.view(Math.floor(b.start_col),Math.floor(b.start_row),Math.ceil(b.end_col),Math.ceil(b.end_row));let C=y.num_row_headers??y.row_headers?.[0]?.length??0;if(C===P)break;this.t.row_headers_length=C}let x=this.t;return Object.assign(()=>{if(this.r=g,this.Q(b),this.ee(r,f,_,n),!A||y===void 0)return this.w(b),!0;let k=!0,P=()=>{k&&(this.w(b),k=!1);for(let D of this.n)D({detail:this})},S=this.table_model.draw_sync(g,x,this.U,n,b,_,y,P);return this.te(b,f,_,n,T),x===this.t&&(this.p=!1),S||this.draw({invalid_viewport:!0}),S},{inline:!1})}async j(e){e||this.table_model.Te();let t=await this.table_model.Se(this.t);return this.Y=t.num_columns||0,this.e.row_height=t.row_height||this.e.row_height,t.num_row_headers!==void 0&&(this.t.row_headers_length=t.num_row_headers),t.num_column_headers!==void 0&&(this.t.column_headers_length=t.num_column_headers),t}K(e,t,i){let r=this.i==="none"||this.i==="horizontal";return{width:this.i==="none"||this.i==="vertical"?1/0:e(),height:r?1/0:t(),containerHeight:r?1/0:i()}}ee(e,t,i,r){this.ie(t),r||this.se(e,i)}te(e,t,i,r,n){this.w(e);let s=this.e.row_height;this.table_model.header.reset_header_cache(),s!==this.e.row_height&&this.ie(t),r||this.se(n,i)}Ce(e,t){if(this.i==="none"||this.i==="vertical")return e.end_col;let{indices:i,override:r}=this.e,n=c=>r[c]??i[c],s=this.t.row_headers_length,o=0;for(let c=0;c<s;c++){let d=n(c);if(d===void 0)return;o+=d}let l=Math.floor(e.start_col),a=i[s+l]??0,u=l;for(;u<t&&o-a<=this.r.width;){let c=n(s+u);if(c===void 0)return;o+=c,u++}return u}Ee(){if(this._===void 0||this.b===void 0||!this.t||this.i==="none"||this.i==="vertical"||this.b>=(this.Y??0))return;let{indices:e,override:t}=this.e,i=this.t.row_headers_length,r=0;for(let s=0;s<i;s++)r+=e[s]||0;for(let s=this._;s<this.b;s++){let o=i+s,l=t[o]??e[o];if(l===void 0)return;r+=l}let n=e[i+this._];r-(n??0)<=this.r.width&&this.draw({invalid_viewport:!0})}xe(){if(!this.o){this.o=[document.createElement("table"),document.createElement("td")],this.o[0].style.visibility="hidden",this.o[0].style.position="absolute";let e=document.createElement("tbody"),t=document.createElement("tr");this.o[1].textContent="X",t.appendChild(this.o[1]),e.appendChild(t),this.o[0].appendChild(e)}this.appendChild(this.o[0]),this.e.row_height=this.o[1].offsetHeight,this.o[0].remove()}Le(){if(this.attachShadow({mode:"open"}),!this.shadowRoot)return;let e=new CSSStyleSheet;e.replaceSync(Yn);let t=new CSSStyleSheet;t.replaceSync(Wn),this.f=t.cssRules[0],this.shadowRoot.adoptedStyleSheets=[e,t],this.shadowRoot.innerHTML=jn;let[i,r]=this.shadowRoot.children;this.s=r,this.a=i,this.ne()}ne(){this.s&&(this.i==="both"||this.i==="vertical"?this.s.style.top="0px":this.s.style.removeProperty("top"),this.i==="both"||this.i==="horizontal"?this.s.style.left="0px":this.s.style.removeProperty("left"),this.i!=="both"?this.s.style.contain="none":this.s.style.removeProperty("contain"))}Z(e,t,i,r){let{start_row:n,end_row:s}=this.He(e,i),{start_col:o,end_col:l}=this.V(t,r);return{start_col:o,end_col:l,start_row:n,end_row:s}}J({start_col:e,end_col:t,start_row:i,end_row:r}){i=Math.floor(i),r=Math.ceil(r),e=Math.floor(e),t=Math.ceil(t);let n=this._!==e,s=this.G!==i||this.q!==r||this.b!==t;return{invalid_column:n,invalid_row:s}}Q({start_col:e,end_col:t,start_row:i,end_row:r}){this._=Math.floor(e),this.b=Math.ceil(t),this.G=Math.floor(i),this.q=Math.ceil(r)}se(e,t){if(e)if(this.i==="vertical"||this.i==="none"){let i=0;for(let r of this.e.indices)i+=r||0;this.a.style.width=i.toPrecision(10)+"px"}else{let i=this.Re(t);if(i!==0){let r=this.r.width+i+2;this.a.style.width=r.toPrecision(10)+"px"}else this.a.style.width="1px"}}ie(e){let t=this.P(e);this.a.style.height=`${t.toPrecision(10)}px`}P(e){let{row_height:t=0}=this.e,i=this.t.column_headers_length*t;return Math.min(Hn,e*t+i)}w(e){let t=(this.e.row_height||0)*(e.start_row%1)||0,i=(this.table_model.c||0)+Math.floor(e.start_col),r=(this.e.indices[i]??this.table_model.Ae())*(e.start_col%1)||0;this.f.style.setProperty(Un,`${r}px`),this.f.style.setProperty($n,`${t}px`),this.f.style.setProperty(Gn,`${-r}px`),this.f.style.setProperty(Vn,`${-t}px`)}V(e,t){if(this.i==="none"||this.i==="vertical")return{start_col:0,end_col:1/0};{let i=this.Pe(t),r=this.table_model.num_columns()||Math.min(e,Math.ceil(this.r.width/60)),n=i+r+1;return{start_col:i,end_col:n}}}He(e,t){let{height:i,containerHeight:r}=this.r,n=this.e.row_height||0,s=this.t.column_headers_length,o=Math.round(this.P(e)),l=Math.max(1,o-r),a=Math.max(Math.ceil(t),0)/l,u=i/n-s,c=Math.max(0,(e||0)-u)*a,d=Math.max(0,Math.min(c+u,e));return{start_row:c,end_row:d}}Pe(e){let t=this.t.row_headers_length,i=0,r=0,n=0;for(;r<e;){let s=this.e.indices[i+t];n=e-r,i+=1,r+=s!==void 0?s:60}return i+=n/(this.e.indices[i+t-1]||60),Math.max(0,i-1)}Ve(e){let t=0;if(this.t.row_headers_length>0)for(let n of this.e.indices.slice(0,this.t.row_headers_length))t+=n||0;let i=this.t.row_headers_length,r=e;for(;t<this.r.width&&r>=0;)r--,t+=this.e.indices[r+i]||60;return Math.min(e-1,r+1)}Re(e){let t=this.t.row_headers_length,i=this.Ve(e),r=t,n=0;for(;r<i+t;)n+=this.e.indices[r]||60,r++;if(r<this.e.indices.length){let s=0,o=this.t.row_headers_length;for(let l=0;l<o&&l<this.e.indices.length;l++)s+=this.e.indices[l]||0;n+=Math.max(0,(this.e.indices[r]||0)-(this.r.width-(s||0))||0)}return n}};async function di(e){let t=performance.now(),{invalid_viewport:i=!0,preserve_width:r=!1}=e,{num_columns:n,num_rows:s}=await this.j(e.cache);this.e.row_height||this.xe();let o=s||0,l=n||0;this.r=this.K(()=>this.s.clientWidth,()=>this.s.clientHeight,()=>this.clientHeight),this.ee(i,o,l,r);let a=this.Z(o,l,this.scrollTop,this.scrollLeft),{invalid_row:u,invalid_column:c}=this.J(a);this.Q(a);let d=this.p||c;if(d||u||i){let h=!0;await this.table_model.draw(this.r,this.t,this.U,r,a,l,async()=>{h&&(this.w(a),h=!1);for(let p of this.n)await p({detail:this})}),this.te(a,o,l,r,d),this.p=!1}else this.w(a);Nn(performance.now()-t)}var G=new WeakMap,Ce=new WeakMap,pi=class{e;De;table;cells;rows;constructor(e,t,i){this.e=e,this.De=t,this.table=i,this.cells=[],this.rows=[]}num_columns(){return this.S(Math.max(0,this.rows.length-1)).row_container.length}num_rows(){return this.cells.length}nt(e,t){G.set(e,t)}D(e,t){let i=Ce.get(e);i!==t&&(i!==void 0&&e.classList.remove(`rt-col-${i}`),e.classList.add(`rt-col-${t}`),Ce.set(e,t))}g(e){let t=Ce.get(e);t!==void 0&&(e.classList.remove(`rt-col-${t}`),Ce.delete(e))}M(e){if(!e)return{value:void 0};let t=G.get(e);return t||(t={value:void 0},G.set(e,t)),t}re(e,t){let{tr:i,row_container:r}=this.S(e),n=r[t];return n&&(i.removeChild(n),r.splice(t,1,void 0)),n}v(e,t){if(!(e<0||t<0))return this.cells[e]?.[t]}S(e){let t=this.rows[e];t||(t=this.rows[e]=document.createElement("tr"),this.table.appendChild(t));let i=this.cells[e];return i||(i=this.cells[e]=[]),{tr:t,row_container:i}}z(e="TD",t,i){let{tr:r,row_container:n}=this.S(t),s=n[i];if(!s)if(i<n.length){s=n[i]=document.createElement(e);let o=n.slice(i+1).find(l=>l);r.insertBefore(s,o||null)}else s=n[i]=document.createElement(e),r.appendChild(s);if(s.tagName!==e){let o=document.createElement(e);r.replaceChild(o,s),this.cells[t].splice(i,1,o),s=o}return s}oe(e){for(let t=0;t<this.rows.length;t++){let i=this.rows[t],r=this.cells[t];r.length=(Array.isArray(e)?e[t]:e)||0;let n=this.cells[t].filter(o=>o!==void 0).length,s=[];for(let o=n;o<i.children.length;o++)s.push(i.children[o]);for(let o of s)o.remove()}}E(e){e=Math.min(e,this.rows.length);let t=[];for(let i=e;i<this.table.children.length;i++)t.push(this.table.children[i]);for(let i of t)i.remove();this.rows.length=e,this.cells.length=e}},Kn=!1,Zn=class extends qn{le;ae;he;de;L;O;ce;ue;register_listeners(){this.addEventListener("mousedown",this.ze.bind(this)),this.addEventListener("scroll",this.W.bind(this),{passive:!0}),this.Oe()}async W(e){if(e.stopPropagation(),this.ce=this.scrollLeft,this.ue=this.scrollTop,this.T){this.O=!0;return}this.T=!0;let t=this.s.clientWidth,i=this.s.clientHeight,r=this.clientHeight;try{await pt(this,async()=>{do{this.O=!1;let n=await this.predraw(t,i,{invalid_viewport:!1,cache:!0,throttle:!1,container_height:r,scroll_left:this.ce,scroll_top:this.ue});n.inline||(await new Promise(requestAnimationFrame),n())}while(this.O)})}finally{this.T=!1}this.dispatchEvent(new CustomEvent("regular-table-scroll"))}Oe(){this.addEventListener("mousewheel",this.We.bind(this),{passive:!0}),Kn&&(this.addEventListener("touchmove",this.ke.bind(this)),this.addEventListener("touchstart",this.Be.bind(this),{passive:!0}))}We(e){if(!window.hasOwnProperty("safari"))return;let t=e,{clientWidth:i,clientHeight:r,scrollTop:n,scrollLeft:s}=this;t.preventDefault(),t.returnValue=!1;let o=Math.max(1,this.a.offsetHeight-r),l=Math.max(1,this.a.offsetWidth-i);this.scrollTop=Math.max(0,Math.min(o,n+t.deltaY)),this.scrollLeft=Math.max(0,Math.min(l,s+t.deltaX)),this.W(t)}ke(e){e.stopPropagation(),e.preventDefault(),e.returnValue=!1;let{clientWidth:t,clientHeight:i}=this,r=Math.max(1,this.a.offsetHeight-i),n=Math.max(1,this.a.offsetWidth-t);this.scrollTop=Math.min(r,(this.le||0)+((this.he||0)-e.touches[0].pageY)),this.scrollLeft=Math.min(n,(this.ae||0)+((this.de||0)-e.touches[0].pageX)),this.W(e)}Be(e){this.he=e.touches[0].pageY,this.de=e.touches[0].pageX,this.le=this.scrollTop,this.ae=this.scrollLeft}async Fe(e){let t=e.target,i=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=G.get(t);if(i&&r){e.stopImmediatePropagation(),e.shiftKey?(this.e.override={},this.e.auto=[],this.e.indices=[]):(delete this.e.override[r.size_key],this.e.auto[r.size_key]=void 0,this.e.indices[r.size_key]=void 0),this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.V(0,this.scrollLeft)},this.t.row_headers_length);for(let n of e.shiftKey?[this.table_model.header.cells[this.table_model.header.cells.length-1],...this.table_model.body.cells]:this.table_model.body.cells)for(let s of e.shiftKey?n:[n[r.virtual_x]])s&&(s.classList.remove("rt-cell-clip"),this.h||this.table_model.body.g(s));await this.draw({cache:!0})}}async $e(e){if(e.button!==0)return;let t=e.target,i=t.classList.contains("rt-column-resize");for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let r=G.get(t);i&&r&&(this.Ne(e,t,r),e.stopImmediatePropagation())}async ze(e){let t=performance.now();this.L&&t-this.L<500?(this.L=t,await this.Fe(e)):(this.L=t,await this.$e(e))}Ne(e,t,i){let{virtual_x:r,size_key:n}=i,s=e.pageX,o=(r||0)+t.colSpan-1,l=this.table_model.header.get_column_header(o),a=this.e.indices[n||0]||0,u=d=>pt(this,async()=>await this.Ie(d,l,s,a,n||0,o)),c=()=>{document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",c);let d=this.e.override[n||0],h=this.e.indices[n||0]!==d;this.e.indices[n||0]=d,h&&this.draw({cache:!0})};document.addEventListener("mousemove",u),document.addEventListener("mouseup",c)}async Ie(e,t,i,r,n,s){await new Promise(requestAnimationFrame);let o=e.pageX-i,l=Math.max(1,r+o);if(this.e.override[n]=l,o<0)await this.draw({preserve_width:!0,throttle:!1,cache:!0});else{this.table_model.updateColumnWidthStyles({start_row:0,end_row:0,...this.V(0,this.scrollLeft)},this.t.row_headers_length);let a=(this.e.auto[n]||0)>l;t.classList.toggle("rt-cell-clip",a);for(let u of this.table_model.body.cells){let c=u[s];c&&(c.classList.toggle("rt-cell-clip",a),this.h||(a?this.table_model.body.D(c,n):this.table_model.body.g(c)))}}}},hi=new WeakMap,Qn=class extends pi{l;d;H;constructor(e,t,i,r){super(e,t,i),this.l=[],this.d=[],this.H=r}me(e,t,i){let r=this.z("TH",t,e[t]||0);e[t]+=1;let n=hi.get(r);if(n!==void 0&&n.value===i&&r.lastChild===n.resize&&r.firstChild===(i instanceof HTMLElement?i:n.span))return r;if(r.removeAttribute("colspan"),r.textContent="",n===void 0){let s=document.createElement("span");s.className="rt-column-resize",n={value:void 0,span:document.createElement("span"),resize:s},hi.set(r,n)}return i instanceof HTMLElement?r.appendChild(i):(n.span.textContent=String(i??""),r.appendChild(n.span)),r.appendChild(n.resize),n.value=i,r}Xe(e,t,i){let r=this.M(i);return this.g(i),r.column_header=e,r.value=t,r}Ge(e,t,i,r){let n=this.M(i);if(n.column_header=e,n.value=t,n.size_key=Array.isArray(r)?r[0]:r,!Array.isArray(r)||r.length<=1){this.D(i,n.size_key||0),this.H?.(i);let s=this.e.override[n.size_key||0],o=this.e.auto[n.size_key||0]||0;i.classList.toggle("rt-cell-clip",!!s&&o>s)}else this.g(i);return n}get_column_header(e){return this.z("TH",this.num_rows()-1,e)}draw(e,t,i,r,n,s,o,l,a){let u=t?.length;if(u===0)return;let c,d,h,p;l=typeof l>"u"?u-1:l;for(let f=0;f<u;f++){if(h=t[f]?t[f]:"",this.d[f]=this.d[f]||0,f<l)a&&this.l?.[f]?.[0]?.value===h?(c=this.l[f][1],this.l[f][2]+=1,i===1&&(this.l[f][0].row_header_x=Array.isArray(n)?n[0]:n)):(this.fe(f),c=this.me(this.d,f,h),d=this.Xe(t,h,c),this.l[f]=[d,c,1]);else{c=this.me(this.d,f,h),d=this.Ge(e.length>0?e:t,h,c,n),typeof p>"u"&&(p={th:c,metadata:d});for(let[_]of this.l)_.size_key=d.size_key;c.removeAttribute("colspan")}this.S(f).tr.classList.toggle("rt-autosize",f===l),c.classList.toggle("rt-group-corner",r===void 0),d&&(d.x=typeof r>"u"?r:Math.floor(r),d.column_header_y=f,d.x0=Math.floor(s),d.virtual_x=o,i===1?(d.type="corner",d.row_header_x=Array.isArray(n)?n[0]:n):(d.type="column_header",delete d.row_header_x))}return this.E(this.d.length),p=p||{th:c,metadata:d},p}fe(e){let t=this.l[e];if(!t)return;let[,i,r]=t;if(r>1){let n=String(r);i.getAttribute("colspan")!==n&&i.setAttribute("colspan",n)}else i.hasAttribute("colspan")&&i.removeAttribute("colspan")}flush_colspans(){for(let e=0;e<this.l.length;e++)this.fe(e)}clean(){this.flush_colspans(),this.oe(this.d)}reset_header_cache(){this.d=[],this.l=[]}},Jn=class extends pi{h;_e(e,t,i,r,{column_name:n},{ridx_offset:s},o){let l=this.z(e,t,r),a=this.M(l);a.y=t+Math.floor(s);let u=a.size_key=o||0;e==="TD"&&(a.column_header=n);let c=this.e.override[u],d=!!c&&(this.e.auto[u]||0)>c;return l.classList.toggle("rt-cell-clip",d),this.h||d?this.D(l,u):this.g(l),a.value!==i&&(i instanceof HTMLElement?(l.textContent="",l.appendChild(i)):l.textContent=String(i??"")),a.value=i,{td:l,metadata:a}}draw(e,t,i,r=!1,n,s,o,l){let{cidx:a,column_data:u,row_headers:c,column_data_listener_metadata:d}=t,{row_height:h}=i,p,f=[],_=[],g=0,m=[],v=r?i.row_headers_length??1:1,b=(i.ridx_offset??0)%1!==0?1:0,y=!1,A=Math.floor(i.ridx_offset),T=Math.ceil(i.y1),x=Math.ceil(i.x1),k=n===void 0?n:Math.floor(n),P=s===void 0?void 0:Math.floor(s),S=Math.floor((n??0)-(s??0));for(let C=0;C<v;C++){g=0,y=!1;let E=a+C;for(let R of u){let I;if(r){let F=R,Ne=F[C],ai=f[C]||1,Oe=this.v(g-ai,E),In=this.M(Oe),ci=m[g]||1,ze=this.v(g,E-ci),Fn=this.M(ze);if(l&&ze&&(Fn.value===Ne||Ne===void 0)&&!ze.hasAttribute("rowspan")){let K=m[g]=ci+1;ze.setAttribute("colspan",String(K)),this.re(g,E)}else if(l&&Oe&&In.value===Ne&&!Oe.hasAttribute("colspan")){let K=f[C]=ai+1;Oe.setAttribute("rowspan",String(K)),this.re(g,E)}else{I=this._e("TH",g,Ne,E,t,i,C);let K=I.td,Z=I.metadata;K.style.display="",K.removeAttribute("rowspan"),K.removeAttribute("colspan"),Z.type="row_header",Z.row_header=F,Z.row_header_x=C,Z.y0=A,Z.y1=T,Z.virtual_x=C,P!==void 0&&(Z.x0=P),f[C]=1,m[g]=1,_[C]=I}}else{I=this._e("TD",g,R,a,t,i,o??0);let F=I.metadata;d&&(F.user=d[g]),F.type="body",F.x=k||0,F.x1=x,F.row_header=c?.[g]||[],F.y0=A,F.y1=T,F.dx=S,F.dy=(F.y??0)-A,F.virtual_x=a,P!==void 0&&(F.x0=P),_[0]=I}if(g++,p=I?I.metadata:p,h=h||I?.td.offsetHeight,(g-b)*(h??0)>e){y=!0;break}}}let D=y?g:g+b;if(D>g){let C=this.rows[g],E=this.rows[g-1];(l&&(i.row_headers_length??0)>0||!C||!E||C.children.length!==E.children.length||C.querySelector("[colspan],[rowspan]")!==null||E.querySelector("[colspan],[rowspan]")!==null)&&(D=g)}return this.E(D),{tds:_,ridx:D,drawn_ridx:g,row_height:h}}clean({ridx:e,cidx:t,drawn_ridx:i=e}){if(this.E(e),this.oe(t),i<this.rows.length){let r=this.rows[i],n=this.rows[i-1],s=c=>c?.children[c.children.length-1],o=s(r),l=s(n),a=o&&G.get(o),u=l&&G.get(l);(!a||!u||a.x!==u.x||r.children.length!==n.children.length)&&this.E(i)}}},es=class{e;c=0;header;body;qe(e,t){let{start_row:i=0,start_col:r=0,end_col:n=0,end_row:s=0}=e,o=this.e.indices[(this.c||0)+Math.floor(e.start_col)]??0;return{viewport_width:0,selected_id:t,ridx_offset:i,sub_cell_offset:o,x0:r,x1:n,y1:s,row_height:this.e.row_height,row_headers_length:this.c}}Ae(){let e=0,t=0;for(let i of this.e.indices)i&&(e+=i,t++);return t?e/t:60}Ue(e,t,i,r,n,s,o,l,a,u){let c=[`${t}`],d=[],h={column_name:c,cidx:0,column_data:e,row_headers:e,first_col:!0},p=Math.floor(o),f=this.body.draw(r,h,{...n,x0:0},!0,void 0,void 0,p,u),_=[];for(let m=0;m<t;m++){let v=this.header.draw(c,Array(i).fill(""),1,void 0,m,o,m,l,a);v&&_.push(v)}for(let m=0;m<_.length;m++){let{th:v}=_[m];n.viewport_width+=this.e.indices[m]||v.offsetWidth}n.row_height=n.row_height||f.row_height;let g=e[0].length;if(!s)for(let m=0;m<t;m++){let{td:v,metadata:b}=f.tds[m]||{},{th:y,metadata:A}=_[m]||{};(v||y)&&d.push([y||v,A||b])}return{cont_body:f,first_col:!1,Ye:g,last_cells:d}}je(e,t,i,r,n,s){let o=0,l=0;for(;this.e.indices.length>n+s+o+1&&l+t.viewport_width<i;)o++,l+=this.e.indices[n+s+o]||0;if(l+t.viewport_width<i){let a=Math.min(r,e.start_col+5);e.end_col=Math.max(1,Math.min(r,a))}else e.end_col=Math.max(1,Math.min(r,e.start_col+o))}Ke(e,t,i,r,n,s,o,l,a,u){let c=t.column_headers?.[e]||[],d=t.data[e],h=t.metadata?.[e],p={column_name:c,cidx:i,column_data:d,column_data_listener_metadata:h,row_headers:t.row_headers,first_col:o},f=e+r,_=i+Math.floor(r),g=this.header.draw(c,c,void 0,f,_,r,i,l,a),m=this.body.draw(n,p,s,!1,f,r,_,u);return{cont_head:g,cont_body:m}}async Ze(e,t,i,r,n,s,o,l,a){let u=Math.max(r+Math.floor(a),0),c=structuredClone(e);c.start_col=u,this.je(c,n,s,o,l,a);let d=await t(Math.floor(c.start_col),Math.floor(c.start_row),Math.ceil(c.end_col),Math.ceil(c.end_row)),h,p;if(typeof d.column_header_merge_depth<"u"&&(h=d.column_header_merge_depth),typeof d.merge_headers<"u"&&(p=d.merge_headers),d.data.length===0)return{column_header_merge_depth:h,merge_headers:p};e.end_col=c.start_col+d.data.length;for(let f=0;f<d.data.length;f++)i.data[r+f]=d.data[f],d.metadata&&i.metadata&&(i.metadata[r+f]=d.metadata[f]),i.column_headers&&d.column_headers?.[f]&&(i.column_headers[r+f]=d.column_headers[f]);return{column_header_merge_depth:h,merge_headers:p}}R(e,t){this.body.clean({ridx:e?.ridx||0,cidx:t,drawn_ridx:e?.drawn_ridx??e?.ridx??0}),this.header.clean()}},ts=0,is=class extends es{table;u;k=new Map;A=new Map;B;C;Je;m;be=new WeakSet;pe={};F=!1;we;constructor(e,t,i){super(),this.e=t,this.clear(i);let[r]=i.children,[n,s]=r.children;this.table=r,this.B=`rt-scope-${ts++}`,this.table.classList.add(this.B),this.m=new ResizeObserver(this.Qe.bind(this)),this.header=new Qn(t,e,n,o=>this.H(o)),this.body=new Jn(t,e,s)}dispose(){this.m?.disconnect()}H(e){!this.m||this.be.has(e)||(this.be.add(e),this.m.observe(e))}Qe(e){if(this.F){for(let r of e)this.m.unobserve(r.target),this.m.observe(r.target);return}let t=this.table.currentCSSZoom??1,i=[];for(let r of e){let n=Ce.get(r.target);if(n===void 0||this.e.override[n]!==void 0)continue;let s=r.target.getBoundingClientRect().width/t;s&&this.e.indices[n]!==s&&i.push([n,s])}if(i.length>0){this.ge();for(let[r,n]of i)this.e.indices[r]=n,this.e.auto[r]=n,this.$(r);this.we?.()}}num_columns(){return this.header.num_columns()}clear(e){e.innerHTML='<table cellspacing="0"><thead></thead><tbody></tbody></table>'}N(e){for(let[,t]of e){let i=t?.size_key;if(i===void 0)return!0;let r=this.e.override[i];if(r!==void 0){if(this.pe[i]!==r)return!0}else if(!this.e.indices[i])return!0}return!1}autosize_cells(e,t){let i=this.table.currentCSSZoom??1,r=[];for(let[n,s]of e){let o=n.getBoundingClientRect();r.push({cell:n,metadata:s,box:o})}for(let{metadata:n,box:s}of r)if(this.e.row_height=t??Math.max(10,Math.min(this.e.row_height??s.height/i,s.height/i)),n?.size_key!==void 0){this.e.indices[n.size_key]=s.width/i;let o=this.e.override[n.size_key];s.width/i&&o===void 0&&(this.e.auto[n.size_key]=s.width/i),o!==void 0&&(this.pe[n.size_key]=o)}}updateColumnWidthStyles(e,t){if(!this.ge())return;let i;for(i=0;i<t;i++)this.$(i);let r=Math.floor(e.start_col);for(let n=i;n<i+(Math.floor(e.end_col)-r);n++)this.$(n+r)}$(e){let t=this.e.override[e],i=this.e.auto[e];t!==void 0?this.Me(e,t,t):i!==void 0?this.Me(e,i,void 0):this.et(e)}ge(){let e=this.table.getRootNode();if(!(!e||!e.adoptedStyleSheets))return this.u||(this.u=new CSSStyleSheet),e.adoptedStyleSheets.includes(this.u)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,this.u]),this.u}tt(e){let t=this.k.get(e);if(t)return t;let i=this.u;if(!i)return;let r=i.cssRules.length;return i.insertRule(`.${this.B} .rt-col-${e}{}`,r),t=i.cssRules[r],this.k.set(e,t),t}Me(e,t,i){let r=i===void 0?`${t}`:`${t}|${i}`;if(this.A.get(e)===r)return;let n=this.tt(e);n&&(n.style.minWidth=`${t}px`,i===void 0?n.style.removeProperty("max-width"):n.style.maxWidth=`${i}px`,this.A.set(e,r))}et(e){if(this.A.get(e)==="")return;let t=this.k.get(e);t&&(t.style.removeProperty("min-width"),t.style.removeProperty("max-width")),this.A.set(e,"")}async Se(e){return this.C?this.C:await e.view(0,0,0,0)}Te(){this.C=void 0,this.Je=void 0}async draw(e,t,i,r,n,s,o){let l=this.C=await t.view(Math.floor(n.start_col),Math.floor(n.start_row),Math.ceil(n.end_col),Math.ceil(n.end_row)),a=this.ve(e,t,i,r,n,s,l);this.F=!0;try{let u=a.next();for(;!u.done;)await o(),u=a.next(u.value==="style"?void 0:await u.value.fetch())}finally{this.F=!1,a.return(!1)}}draw_sync(e,t,i,r,n,s,o,l){this.C=o;let a=this.ve(e,t,i,r,n,s,o),u=a.next();for(;!u.done;)u.value==="style"&&l(),u=a.next();return u.value}*ve(e,t,i,r,n,s,o){let{width:l,height:a}=e,{column_header_merge_depth:u,merge_headers:c="both"}=o,d=c==="both"||c==="row",h=c==="both"||c==="column",p=n.start_col??0;if(o.row_headers){let T=0;for(let x of o.row_headers)x.length>T&&(T=x.length);this.c=T;for(let x=0;x<o.row_headers.length;x++)o.row_headers[x].length=this.c||0}t.row_headers_length=o.num_row_headers??o.row_headers?.[0]?.length??0,t.column_headers_length=o.num_column_headers??o.column_headers?.[0]?.length??0;let{view:f,row_headers_length:_,column_headers_length:g}=t,m=this.qe(n,i),v,b=0,y=[],A=!0;if(o.row_headers?.length){let T=this.Ue(o.row_headers,_,g,a,m,r,p,u,h,d);v=T.cont_body,A=T.first_col,b=T.Ye,y=T.last_cells}try{let T=0,x=0,k=s-n.start_col,P=this.e.indices.some(Boolean);for(;T<k;){if(!o.data[T]){this.header.flush_colspans(),this.updateColumnWidthStyles(n,t.row_headers_length);let E=yield{fetch:()=>this.Ze(n,f,o,T,m,l,s,b,p)};if(E?.column_header_merge_depth!==void 0&&(u=E.column_header_merge_depth),E?.merge_headers!==void 0&&(c=E.merge_headers),!o.data[T])return this.R(v,b),this.updateColumnWidthStyles(n,t.row_headers_length),yield"style",this.N(y)&&this.autosize_cells(y,this.e.row_height),this.I(m,l)}let{cont_head:S,cont_body:D}=this.Ke(T,o,b,p,a,m,A,u,h,d);if(v=D,A=!1,!r)for(let{td:E,metadata:R}of v.tds)y.push([S?.th||E,S?.metadata||R]);let C=this.e.indices[b+Math.floor(p)]||(P?x:0);if(!C){if(C=S?.th?.offsetWidth||0,!C)for(let{td:E}of v.tds)C+=E?.offsetWidth||0;x=C}if(m.viewport_width+=C,m.row_height=m.row_height||v.row_height,b++,T++,this.I(m,l)){if(this.R(v,b),this.updateColumnWidthStyles(n,t.row_headers_length),yield"style",r)return!0;m.viewport_width=0,this.N(y)&&this.autosize_cells(y,this.e.row_height),x=0;let E=m.row_headers_length||0;for(let R=0;R<y.length;R++){let I=R<E?R:Math.floor(p)+R;m.viewport_width+=this.e.indices[I]||0}if(this.I(m,l))return!0}}return this.R(v,b),this.updateColumnWidthStyles(n,t.row_headers_length),yield"style",this.N(y)&&this.autosize_cells(y,this.e.row_height),!0}finally{this.R(v,b)}}I(e,t){return e.viewport_width-e.sub_cell_offset>t}},rs=["both","horizontal","vertical","none"],ns=class extends Zn{X;constructor(){super(),this.e={auto:[],override:{},indices:[]},this.n=[],this.X=!1}connectedCallback(){this.X||(this.Le(),this.register_listeners(),this.setAttribute("tabindex","0"),this.X=!0,this.ye())}ye(){this.table_model?.dispose(),this.table_model=new is(this.s,this.e,this),this.table_model.we=()=>this.Ee(),this.table_model.body.h=this.h}resetAutoSize(e){(!e||e.auto)&&(this.e.auto=[]),(!e||e.override)&&(this.e.override={}),(!e||e.indices)&&(this.e.indices=[]),(!e||e.row_height)&&(this.e.row_height=void 0)}saveColumnSizes(){return structuredClone(this.e.override)}restoreColumnSizes(e){this.e.override=structuredClone(e)}clear(){this.ye()}addStyleListener(e){this.n.push(e);let t=!0;return()=>{if(!t)return;t=!1,this.n=this.n.slice();let i=this.n.indexOf(e);this.n.splice(i,1)}}removeStyleListener(e){let t=this.n.length;this.n=this.n.filter(i=>i!==e),console.assert(this.n.length===t-1,"No listener found")}getMeta(e){if(e!==void 0){if(e instanceof HTMLElement)return G.get(e);if("row_header_x"in e&&e.row_header_x&&e.row_header_x>=0){if(e.row_header_x<this.t.row_headers_length){let t=this.table_model.body.v(e.y,e.row_header_x);return this.getMeta(t)}}else if("column_header_y"in e&&e.column_header_y>=0){if(e.column_header_y<this.t.column_headers_length){let t=this.table_model.header.v(e.column_header_y,e.x);return this.getMeta(t)}}else if("dx"in e)return this.getMeta(this.table_model.body.v(e.dy,e.dx+(this.table_model.c||0)))}}getDrawFPS(){return Bn()}async scrollToCell(e,t){if(!this.t){console.warn("data listener not configured");return}let i=this.e.row_height||0;this.scrollTop=Math.ceil(i*t);let r=0;for(;e>0;)e--,r+=this.e.indices[e+this.t.row_headers_length]||60;this.scrollLeft=Math.ceil(r),await new Promise(requestAnimationFrame),await this.flush()}setDataListener(e,{virtual_mode:t="both",preserve_state:i=!1,column_classes:r=!1}={}){console.assert(rs.indexOf(t)>-1,`Unknown virtual_mode ${t}; valid options are "both" (default), "horizontal", "vertical" or "none"`);let n=this.i!==t;i?(console.assert(!n,"preserve_state called with modified virtual_mode"),this.t.view=e):(this.i=t,this.h=r,this.table_model&&(this.table_model.body.h=r),this.p=!0,this.t={view:e,row_headers_length:0,column_headers_length:0},n&&this.ne())}};document.createElement("regular-table").constructor===HTMLElement&&window.customElements.define("regular-table",ns);var Q=class{selected;row;column_names;removeConfigs;insertConfigs;panel;constructor(t,i,r,n,s,o){this.selected=t,this.row=i,this.column_names=r,this.removeConfigs=n,this.insertConfigs=s,this.panel=o}get removeFilters(){return this.removeConfigs.flatMap(t=>t.filter??[])}get insertFilters(){return this.insertConfigs.flatMap(t=>t.filter??[])}};function mi(e){return e&&!("format"in e)?e:void 0}var ss={float:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},fi={dateStyle:"short",timeStyle:"medium"},os={dateStyle:"short"};function gi(e,t){let i=t??ss[e]??{};return new Intl.NumberFormat(navigator.languages,i)}function _i(e){if(!e||!("format"in e)){let i=mi(e),r={timeZone:i?.timeZone??void 0,dateStyle:i?.dateStyle==="disabled"?void 0:i?.dateStyle??fi.dateStyle,timeStyle:i?.timeStyle==="disabled"?void 0:i?.timeStyle??fi.timeStyle};return new Intl.DateTimeFormat(navigator.languages,r)}let t={timeZone:e.timeZone??void 0,hour12:e.hour12??!0,fractionalSecondDigits:e.fractionalSecondDigits};return e.year!=="disabled"&&(t.year=e.year??"2-digit"),e.month!=="disabled"&&(t.month=e.month??"numeric"),e.day!=="disabled"&&(t.day=e.day??"numeric"),e.weekday&&e.weekday!=="disabled"&&(t.weekday=e.weekday),e.hour!=="disabled"&&(t.hour=e.hour??"numeric"),e.minute!=="disabled"&&(t.minute=e.minute??"numeric"),e.second!=="disabled"&&(t.second=e.second??"numeric"),new Intl.DateTimeFormat(navigator.languages,t)}function bi(e){let t=mi(e),i={timeZone:"utc",dateStyle:t?.dateStyle==="disabled"?void 0:t?.dateStyle??os.dateStyle};return new Intl.DateTimeFormat(navigator.languages,i)}function yi(e){return e.split("|").at(-1)??e}function $e(e,t){return t.type==="body"||t.type==="column_header"||t.type==="corner"?e._column_types[t.x]:e._row_header_types[(t.row_header_x??0)-1]}var W=Symbol("Perspective Column Config");function fe(e,t,i=!1){let r=e._config.group_by.length===0&&e._config.split_by.length===0,n=i||e._edit_mode==="EDIT";return r&&n}var ls=/^__(?:ROW_PATH(?:_\d+)?|ID|GROUPING_ID)__$/;function _t(e){return ls.test(e)}var as=class{format(e){return e?"true":"false"}},cs=class{_formatters;constructor(){this._formatters=new Map}create_datetime_formatter(e,t){return _i(t.date_format)}create_date_formatter(e,t){return bi(t.date_format)}create_number_formatter(e,t){return gi(e,t.number_format)}create_boolean_formatter(e,t){return new as}get(e,t){let i=[e,...Object.values(t.date_format??{}),...Object.values(t.number_format??{})].join("-");return this._formatters.has(i)||(e==="date"?this._formatters.set(i,this.create_date_formatter(e,t)):e==="datetime"?this._formatters.set(i,this.create_datetime_formatter(e,t)):e==="integer"||e==="float"?this._formatters.set(i,this.create_number_formatter(e,t)):e==="boolean"?this._formatters.set(i,this.create_boolean_formatter(e,t)):this._formatters.set(i,!1)),this._formatters.get(i)}},Di=new cs;function Ii(e,t){return Di.get(e,t)}function Ge(e,t,i={},r=!1){if(t===null)return null;let n=r&&this._table_schema[e]||this._schema[e]||this._window_schema?.[e]||"string",s=i[e]||{};if((n==="integer"||n==="float")&&!r&&(s?.number_fg_mode==="bar"||s?.number_fg_mode==="label-bar"))return"";if(s?.format==="link"&&n==="string"){let o=document.createElement("a");return o.setAttribute("href",t),o.setAttribute("target","_blank"),o.textContent=t,o}else if(s?.format==="bold"&&n==="string"){let o=document.createElement("b");return o.textContent=t,o}else if(s?.format==="italics"&&n==="string"){let o=document.createElement("i");return o.textContent=t,o}else{let o=Di.get(n,s);return o?o.format(t):String(t)}}function*us(e=[],t,i){let r=i[W]||{};for(let n of e){let s=["TOTAL",...n],o=s[s.length-1],l=s.slice(0,s.length-1).fill(""),a=Ge.call(this,t[l.length-1],o,r,!0);a instanceof HTMLElement?l=l.concat(a):l=l.concat({toString:()=>String(a??"")}),l.length=t.length+1,yield l}}function*ds(e=[],t,i){let r=i[W]||{};for(let n of e)yield n.map((s,o)=>Ge.call(this,t[o],s,r,!0))}function*hs(e=[],t,i){let r=i[W]||{};for(let n of e){let s=[""];for(let o in n)s.push(Ge.call(this,t[o],n[o],r,!0));yield n}}function ps(e){let t,i,r,n,s;return async function(o,l,a,u,c){let d={},h={start_row:a,start_col:l,end_row:c,end_col:u,id:!0},p=null;if(u-l>0&&c-a>0){this._is_old_viewport=this._last_window?.start_row===a&&this._last_window?.end_row===c&&this._last_window?.start_col===l&&this._last_window?.end_col===u;let[k,P]=await Promise.all([this._view.to_columns_string(h),this._view.num_columns()]);p=P,d=JSON.parse(k);let S=Object.keys(d).filter(C=>!_t(C)),D=!1;for(let C=0;C<S.length;C++)this._column_paths[h.start_col+C]!==S[C]&&(D=!0,this._column_paths[h.start_col+C]=S[C]);if(D){let[C,E]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...C,...E};for(let R=0;R<S.length;R++){let I=S[R].split("|"),F=I[Math.min(this._config.split_by.length,I.length-1)];this._is_editable[R+h.start_col]=!!this._table_schema[F],this._column_types[R+h.start_col]=this._schema[F]}}this._last_window=h,this._ids=d.__ID__||Array(c-a).fill(null).map((C,E)=>[E+a]),this._reverse_columns=this._column_paths.slice(l,u).reduce((C,E,R)=>(C.set(E,R),C),new Map),this._reverse_ids=this._ids?.reduce((C,E,R)=>(C.set(E?.join("|"),R),C),new Map)}else p=await this._view.num_columns();let f=[],_=[],g=[],m=[],v=e.hasAttribute("settings")&&(this._panel===void 0||e.getActivePanel()===this._panel);for(let k=l;k<Math.min(u,this._column_paths.length);++k){let P=this._column_paths[k],S=P.split("|");if(S.length<this._config.split_by.length+1){let E=S.pop(),R="\u200B".repeat(S.length+1);for(;S.length<this._config.split_by.length;)S.push(R);S.push(E)}let D=d[P]||new Array(c-a).fill(null),C=Math.min(o[W]?.[S[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);f.push(D.map((E,R)=>(d?.__ROW_PATH__?.[R]?.length??0)<C?"":Ge.call(this,S[this._config.split_by.length],E,o[W]||{}))),_.push(D),v&&S.push(""),g.push(S),m.push(P)}let b=u-l>0&&c-a>0;b&&(this.last_column_paths=i,this.last_meta=t,this.last_ids=r,this.last_reverse_ids=n,this.last_reverse_columns=s,i=m,t=_,r=this._ids,n=this._reverse_ids,s=this._reverse_columns);let y=d.__ROW_PATH__!==void 0,A=this._config.group_rollup_mode==="flat",T=Array.from((y?A?ds:us:hs).call(this,d.__ROW_PATH__,this._config.group_by,o)),x=b?T[0]?.length:fs(this._config);return{num_column_headers:this._config.split_by.length+(v?2:1),num_row_headers:x,num_rows:this._num_rows,num_columns:p,row_headers:T,column_headers:g,data:f,metadata:_,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}function fs(e){return e.group_rollup_mode==="flat"?e.group_by.length:e.group_rollup_mode==="total"||e.group_by.length===0?0:e.group_by.length+1}var vi=new Map,de=null;function xt(e){let t=e.startsWith("#")?e.slice(1):e;if(t.length===3||t.length===4){let i=parseInt(t[0]+t[0],16),r=parseInt(t[1]+t[1],16),n=parseInt(t[2]+t[2],16);if(!isNaN(i)&&!isNaN(r)&&!isNaN(n))return[i,r,n]}else if(t.length===6||t.length===8){let i=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),n=parseInt(t.slice(4,6),16);if(!isNaN(i)&&!isNaN(r)&&!isNaN(n))return[i,r,n]}return null}function Fi(e){let t=e.match(/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)/i);return t?[Math.round(parseFloat(t[1])),Math.round(parseFloat(t[2])),Math.round(parseFloat(t[3]))]:null}function ms(e){if(!de){let i=document.createElement("canvas");i.width=i.height=1,de=i.getContext("2d")}if(!de)return[0,0,0];de.fillStyle="#000",de.fillStyle=e;let t=de.fillStyle;return xt(t)??Fi(t)??[0,0,0]}function me(e){let t=e.trim(),i=vi.get(t);if(i)return i;let r=xt(t)??Fi(t)??ms(t);return vi.set(t,r),r}function ft(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function te([e,t,i]){return`#${ft(e)}${ft(t)}${ft(i)}`}function gs(e,t){if(e.length===0)return[0,0,0];if(t<=e[0].offset)return e[0].rgb;let i=e[e.length-1];if(t>=i.offset)return i.rgb;for(let r=0;r+1<e.length;r++){let n=e[r],s=e[r+1];if(t>s.offset)continue;let o=s.offset-n.offset,l=o>0?(t-n.offset)/o:0;return[n.rgb[0]+(s.rgb[0]-n.rgb[0])*l,n.rgb[1]+(s.rgb[1]-n.rgb[1])*l,n.rgb[2]+(s.rgb[2]-n.rgb[2])*l]}return i.rgb}function _s([e,t,i]){let r=e/255,n=t/255,s=i/255,o=Math.max(r,n,s),l=Math.min(r,n,s),a=(o+l)/2,u=o-l,c=0,d=0;return u!==0&&(d=a>.5?u/(2-o-l):u/(o+l),o===r?c=((n-s)/u+(n<s?6:0))*60:o===n?c=((s-r)/u+2)*60:c=((r-n)/u+4)*60),[c,d,a]}function xi([e,t,i]){let r=(e%360+360)%360/360;if(t===0){let l=Math.round(i*255);return[l,l,l]}let n=i<.5?i*(1+t):i+t-i*t,s=2*i-n,o=l=>(l<0&&(l+=1),l>1&&(l-=1),l<1/6?s+(n-s)*6*l:l<1/2?n:l<2/3?s+(n-s)*(2/3-l)*6:s);return[Math.round(o(r+1/3)*255),Math.round(o(r)*255),Math.round(o(r-1/3)*255)]}function bs(e,t,i=.5){return[Math.round(Math.sqrt(e[0]*e[0]*(1-i)+t[0]*t[0]*i)),Math.round(Math.sqrt(e[1]*e[1]*(1-i)+t[1]*t[1]*i)),Math.round(Math.sqrt(e[2]*e[2]*(1-i)+t[2]*t[2]*i))]}function wi(e,t){return te(bs(me(e),[t[0],t[1],t[2]],.5))}function We([e,t,i,r],n=[255,255,255]){function s(o,l){return((1-r)*(n[o]/255)+r*(l/255))*255}return[s(0,e),s(1,t),s(2,i)]}function Ae([e,t,i]){return Math.sqrt(e*e*.299+t*t*.587+i*i*.114)>130?"#161616":"#ffffff"}function ys(e){let t=e.trim();if(t.startsWith("#"))return/^#[0-9a-f]+$/i.test(t)?xt(t):null;let i=t.match(/^rgba?\(([^)]*)\)$/i);if(!i)return null;let r=i[1].split("/")[0].split(/[\s,]+/).filter(a=>a.length>0);if(r.length<3||r.length>4)return null;let n=a=>{let u=a.endsWith("%"),c=parseFloat(u?a.slice(0,-1):a);return isFinite(c)?Math.max(0,Math.min(255,Math.round(u?c/100*255:c))):null},s=n(r[0]),o=n(r[1]),l=n(r[2]);return s===null||o===null||l===null?null:[s,o,l]}function Bi(e){let t=e.trim().match(/^linear-gradient\s*\((.*)\)$/is);if(!t)return null;let i=t[1],r=[],n=0,s=0;for(let l=0;l<i.length;l++){let a=i[l];a==="("?n++:a===")"?n--:a===","&&n===0&&(r.push(i.substring(s,l)),s=l+1)}r.push(i.substring(s));let o=[];for(let l=0;l<r.length;l++){let a=r[l].trim();if(!a)return null;let u=a.toLowerCase();if(l===0&&(u.startsWith("to ")||/^[-\d.]+(deg|rad|grad|turn)$/.test(u)))continue;let c=a.match(/\s([^\s)]+)$/),d=a,h=null;if(c){let f=c[1];if(f.endsWith("%")){let _=parseFloat(f.slice(0,-1));if(!isFinite(_))return null;d=a.substring(0,c.index).trim(),h=_/100}else if(/^[-\d.]/.test(f))return null}let p=ys(d);if(!p)return null;o.push([p,h])}return o}function vs(e){let t=Bi(e);if(!t||t.length<2)return null;let i=t.map(([,s])=>s),r=i.length-1;i[0]===null&&(i[0]=0),i[r]===null&&(i[r]=1);for(let s=1;s<r;s++){if(i[s]!==null)continue;let o=s+1;for(;i[o]===null;)o++;let l=i[s-1],a=i[o],u=o-(s-1);for(let c=s;c<o;c++)i[c]=l+(c-(s-1))/u*(a-l);s=o-1}let n=t.map(([s],o)=>({rgb:s,offset:Math.max(0,Math.min(1,i[o]))}));return n.sort((s,o)=>s.offset-o.offset),n}function xs(e){let t=Bi(e);if(!t||t.length===0)return null;let i=[];for(let[r,n]of t){if(n!==null)return null;i.push(r)}return i}function mt(e){return`linear-gradient(to right, ${[...e].sort((t,i)=>t.offset-i.offset).map(t=>{let i=Math.round(Math.max(0,Math.min(1,t.offset))*1e3)/10;return`${t.color} ${i}%`}).join(", ")})`}function ws(e){return`linear-gradient(to right, ${e.join(", ")})`}function Es(e){let[t,i,r]=_s(e),[n,s,o]=e,[l,a,u]=xi([t-15,i,r]),[c,d,h]=xi([t+15,i,r]);return`linear-gradient(to right top,rgb(${l},${a},${u}),rgb(${n},${s},${o}) 50%,rgb(${c},${d},${h}))`}function J(e){let t=me(e),i=Es(t);return[e,t[0],t[1],t[2],i,`rgba(${t[0]},${t[1]},${t[2]},1)`,`rgba(${t[0]},${t[1]},${t[2]},0)`]}var Cs=new Set(["sum","avg","stddev","var","diff","rate","ema"]);function Ss(e,t,i){return e==="count"?"integer":Cs.has(e)?"float":i[t]??"string"}function gt(e,t){if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++)if(e[i]!==t[i])return!0;return!1}function Ei(e,t){if(e.length!==t.length)return!0;for(let i=0;i<e.length;i++){if(e[i].length!==t[i].length)return!0;for(let r=0;r<e[i].length;r++)if(e[i][r]!==t[i][r])return!0}return!1}function pe(e,t,i){let r=window.getComputedStyle(e).getPropertyValue(t).trim();return r.length>0?r:i}function As(e,t){let i=s=>{let o=[];for(let l=1;;l++){let a=pe(e,`${s}${l}--color`,"");if(!a)break;o.push(te(me(a)))}return o},r=i("--psp-datagrid--series-");if(r.length>0)return r;let n=i("--psp-charts--series-");return n.length>0?n:[te(me(t))]}function Ni(e){let t=pe(e,"--psp-theme-name",""),i=me(pe(e,"--psp--background-color","#FFFFFF")),r=J(pe(e,"--psp-datagrid--pos-cell--color","#338DCD")),n=J(pe(e,"--psp-datagrid--neg-cell--color","#FF5942")),s=J(wi(r[0],i)),o=J(wi(n[0],i)),l=J(pe(e,"--psp-active--color","#ff0000")),a=As(e,l[0]),u=[{rgb:[o[1],o[2],o[3]],offset:0},{rgb:i,offset:.5},{rgb:[s[1],s[2],s[3]],offset:1}];return{_theme:t,_plugin_background:i,_color:l,_pos_fg_color:r,_neg_fg_color:n,_pos_bg_color:s,_neg_bg_color:o,_default_bg_color_stops:u,_series_palette:a}}async function Ci(e,t,i,r={}){let n=await i.get_config(),s=Ni(e);if(this?.model?._config){let y=this.model._config,A=gt(y.group_by,n.group_by),T=(y.group_by.length===0||n.group_by.length===0)&&A,x=gt(y.split_by,n.split_by),k=gt(y.columns,n.columns),P=Ei(y.filter,n.filter),S=Ei(y.sort,n.sort),D=y.group_rollup_mode!==n.group_rollup_mode,C=y.split_rollup_mode!==n.split_rollup_mode,E=this.model._theme!==s._theme;this._reset_scroll_top=A,this._reset_scroll_left=x,this._reset_select=A||x||P||S||k,this._reset_column_size=D||C||x||A||k||E||T}let o=this.getAttribute("slot")??void 0,[l,a,u,c,d]=await Promise.all([t.schema(),i.num_rows(),i.schema(),i.expression_schema(),this.parentElement.getEditPort({panel:o})]),h={...u,...c},p={...l,...c},f=Object.fromEntries(Object.entries(n.windows??{}).map(([y,A])=>[y,Ss(A.aggregate,A.column,p)])),_=[],g=[],m=[],v=this._edit_mode||"READ_ONLY";v==="SELECT_ROW_TREE"&&n.group_by.length===0?(v="READ_ONLY",this._edit_mode=v):v==="SELECT_ROW_TREE"&&n.group_rollup_mode==="flat"&&(v="SELECT_ROW",this._edit_mode=v),this._edit_button!==void 0&&(this._edit_button.dataset.editMode=v);let b=Object.assign(r,{_panel:o,_edit_port:d,_view:i,_table:t,_table_schema:p,_config:n,_num_rows:a,_schema:h,_window_schema:f,_ids:[],...s,_column_paths:_,_column_types:m,_is_editable:g,_edit_mode:v,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:n.group_by.map(y=>p[y]??f[y]),_series_color_map:new Map,_series_color_seed:new Map});return e.setDataListener(ps(this.parentElement).bind(b,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both",column_classes:!0}),b}var Se=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION","SELECT_ROW_TREE"];function Ts(e){return e?e._config.group_by.length>0&&e._config.group_rollup_mode!=="flat":!1}function bt(e,t=!0){if(typeof e>"u"){let r=Se.indexOf(this._edit_mode);do r=(r+1)%Se.length;while(Se[r]==="SELECT_ROW_TREE"&&!Ts(this.model));e=Se[r]}let i=this.getAttribute("slot")??void 0;this.parentElement?.setSelection?.(void 0,{panel:i}),this._edit_mode=e,this.model&&(this.model._edit_mode=e,this.model._tree_selection_id=void 0,this.model._selection_state={selected_areas:[],dirty:!0}),t&&this.parentElement?.restore?.({plugin_config:{edit_mode:e}},{panel:i}),this._edit_button!==void 0&&(this._edit_button.dataset.editMode=e)}function Si(e){typeof e>"u"&&(e=!this._is_scroll_lock),this._is_scroll_lock=e,this.classList.toggle("sub-cell-scroll-disabled",e),this._scroll_lock!==void 0&&this._scroll_lock.classList.toggle("lock-scroll",e)}function yt(e,t=!1){if(t&&(this._cached_column_sizes=e),!this._initialized)return;let i=this.regular_table,r={...i.saveColumnSizes()},{group_by:n}=this.model._config,s=n?.length>0?n.length+1:0;for(let o of Object.keys(e))if(o==="__ROW_PATH__")r[s-1]=e[o];else{let l=this.model._column_paths.indexOf(o);if(l===-1)continue;r[l+s]=e[o]}i.restoreColumnSizes(r)}function Oi(){if(!this._initialized)return{};if(this._cached_column_sizes){let n=this._cached_column_sizes;return this._cached_column_sizes=void 0,n}let e=this.regular_table.saveColumnSizes(),{group_by:t}=this.model._config,i=t?.length>0?t.length+1:0,r={};for(let n of Object.keys(e)){let s=Number(n);if(e[s]!==void 0){let o=s-i;o>-1?r[this.model._column_paths[o]]=e[s]:o===-1&&(r.__ROW_PATH__=e[s])}}return r}var Ye={top:"none",right:"none",bottom:"none",left:"none"};function vt(e,t){let i=e.split("|");return i.slice(0,Math.min(t,i.length-1))}function Ms(e,t,i){let r=e[i];if(r===void 0)return null;if(i+1>=e.length)return 0;let n=e[i+1];if(n===void 0)return null;let s=vt(r,t),o=vt(n,t),l=0;for(;l<s.length&&l<o.length&&s[l]===o[l];)l++;return l===s.length&&l===o.length?t:l}function Rs(e,t,i,r){let n=e[i];return n===void 0?!1:r<vt(n,t).length}function zi(e){if(e.single_header_row||e.split_by_len===0)return Ye;if(e.is_corner)return e.corner_needs_border?{...Ye,right:e.y===0&&e.row_kind==="group"?"miter-start":e.is_last_header_row?"miter-end":"full"}:Ye;if(e.x===void 0)return Ye;let t=e.x+e.colspan-1,i=Ms(e.paths,e.split_by_len,t),r=t>=e.paths.length-1,n="none";i!==null&&(e.row_kind==="group"?i<=e.y&&(n=i===e.y?"miter-start":"full"):(i<e.split_by_len||r)&&(n=e.is_last_header_row?"miter-end":"full"));let s=e.row_kind==="group"&&Rs(e.paths,e.split_by_len,e.x,e.y)?"miter-both":"none";return{top:"none",right:n,bottom:s,left:"none"}}var Hi={top:{full:"psp-b-t","miter-start":"psp-b-t-ml","miter-end":"psp-b-t-mr","miter-both":"psp-b-t-mlr"},right:{full:"psp-b-r","miter-start":"psp-b-r-mt","miter-end":"psp-b-r-mb","miter-both":"psp-b-r-mtb"},bottom:{full:"psp-b-b","miter-start":"psp-b-b-ml","miter-end":"psp-b-b-mr","miter-both":"psp-b-b-mlr"},left:{full:"psp-b-l","miter-start":"psp-b-l-mt","miter-end":"psp-b-l-mb","miter-both":"psp-b-l-mtb"}},oc=Object.values(Hi).map(e=>Object.values(e)).flat();function Yi(e,t){for(let i of["top","right","bottom","left"]){let r=t[i];for(let[n,s]of Object.entries(Hi[i]))e.classList.toggle(s,n===r)}}function Wi(e){return e._config.group_by.length-(e._config.group_rollup_mode==="flat"?1:0)}function ks(e,t,i){let r=e._config.split_by.length,n=t.length<=1,s=Wi(e);for(let o=0;o<t.length;o++){let{cells:l}=t[o],a=o<r;for(let u=0;u<l.length;u++){let{element:c,metadata:d}=l[u];if(!d||(c.style.backgroundColor="",c.classList.toggle("psp-header-group",!0),c.classList.toggle("psp-header-leaf",!1),c.classList.toggle("psp-header-group-corner",d.type==="corner"),c.classList.toggle("psp-color-mode-bar",!1),c.classList.toggle("psp-color-mode-label-bar",!1),c.classList.toggle("psp-header-sort-asc",!1),c.classList.toggle("psp-header-sort-desc",!1),c.classList.toggle("psp-header-sort-col-asc",!1),c.classList.toggle("psp-header-sort-col-desc",!1),c.classList.toggle("psp-header-sort-abs-asc",!1),c.classList.toggle("psp-header-sort-abs-desc",!1),c.classList.toggle("psp-header-sort-abs-col-asc",!1),c.classList.toggle("psp-header-sort-abs-col-desc",!1),c.classList.toggle("psp-sort-enabled",!1),c.classList.toggle("psp-menu-enabled",!1),c.classList.toggle("psp-menu-open",!1),!a))continue;let h=d.type==="corner",p=d.type==="column_header"&&d.x>=0,f=zi({paths:e._column_paths,split_by_len:r,x:p?d.x:void 0,colspan:c.colSpan||1,y:o,row_kind:"group",is_corner:h,corner_needs_border:h&&e._config.group_by.length>0&&d.row_header_x===s,is_last_header_row:!1,single_header_row:n});Yi(c,f),c.classList.toggle("psp-header-border",f.right!=="none"),c.classList.toggle("psp-is-top",f.right==="miter-start")}}}function Ls(e,t,i,r){let n=Array.from(t.children[0].children[0].children),s=n.length,o=i.hasAttribute("settings");if(s<=1?n[0]?.removeAttribute("id"):n.forEach((l,a)=>{let u=o?1:0,c=a===s-(u+1)?"psp-column-titles":a===s-u?"psp-column-edit-buttons":null;c?l.setAttribute("id",c):l.removeAttribute("id")}),i.classList.toggle("psp-menu-open",!!r),o&&s>=2){let l=Array.from(n[s-2].children),a=Array.from(n[s-1].children);if(l&&a){n.slice(0,s-2).forEach(u=>{Array.from(u.children).forEach(c=>{c.classList.toggle("psp-menu-open",!1)})});for(let u=0;u<l.length;u++){let c=l[u],d=a[u],h=c.textContent===r;if(c.classList.toggle("psp-menu-open",h),d.classList.toggle("psp-menu-open",h),e._config.columns.length>1)for(let p of t.querySelectorAll("td")){let f=t.getMeta(p);if(!f?.column_header)continue;let _=f.column_header[f.column_header.length-2]===r;p.classList.toggle("psp-menu-open",_)}}}}}function Ai(e,t,i,r,n,s){let o=Wi(e),l=e._config.split_by.length,a=e._column_settings_selected_column;for(let{element:u,metadata:c}of t.cells){if(!c||c.type==="body"||c.type==="row_header")continue;let d=c.column_header?.[e._config.split_by.length],h=e._config.sort.find(T=>T[0]===d),p=typeof c.x>"u",f=zi({paths:e._column_paths,split_by_len:l,x:p?void 0:c.x,colspan:u.colSpan||1,y:l+(r?1:0),row_kind:r?"menu":"name",is_corner:c.type==="corner",corner_needs_border:c.type==="corner"&&e._config.group_by.length>0&&c.row_header_x===o,is_last_header_row:n,single_header_row:s});Yi(u,f),u.classList.toggle("psp-header-border",f.right!=="none"),u.classList.toggle("psp-header-group",!1),u.classList.toggle("psp-header-leaf",!0);let _=p?void 0:e._column_paths[c.x]?.split("|").length-1,g=e._config.split_by.length>0&&_!==void 0&&_<e._config.split_by.length;u.classList.toggle("psp-split-total",g&&_===0),u.classList.toggle("psp-split-subtotal",g&&_>0),u.classList.toggle("psp-is-top",!1),u.classList.toggle("psp-header-corner",p),u.classList.toggle("psp-header-sort-asc",!r&&!!h&&h[1]==="asc"),u.classList.toggle("psp-header-sort-desc",!r&&!!h&&h[1]==="desc"),u.classList.toggle("psp-header-sort-col-asc",!r&&!!h&&h[1]==="col asc"),u.classList.toggle("psp-header-sort-col-desc",!r&&!!h&&h[1]==="col desc"),u.classList.toggle("psp-header-sort-abs-asc",!r&&!!h&&h[1]==="asc abs"),u.classList.toggle("psp-header-sort-abs-desc",!r&&!!h&&h[1]==="desc abs"),u.classList.toggle("psp-header-sort-abs-col-asc",!r&&!!h&&h[1]==="col asc abs"),u.classList.toggle("psp-header-sort-abs-col-desc",!r&&!!h&&h[1]==="col desc abs");let m=$e(e,c),v=m==="integer"||m==="float",b=m==="string",y=m==="date",A=m==="datetime";if(u.classList.toggle("psp-menu-enabled",(b||v||y||A)&&!p&&c.column_header_y===e._config.split_by.length+1),u.classList.toggle("psp-sort-enabled",(b||v||y||A)&&!p&&c.column_header_y===e._config.split_by.length),u.classList.toggle("psp-is-width-override",i.saveColumnSizes()[c.size_key]!==void 0),e._config.columns.length>1&&a){let T=c.column_header?.[c.column_header.length-2]===a;u.classList.toggle("psp-menu-open",T)}}}var Ps={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},Ds={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0};async function Is(e,t,i,r,n){let s=t.getMeta(n);if(!s?.column_header)return;let o=s.column_header[e._config.split_by.length],l=r.ctrlKey||r.metaKey||r.altKey?Fs:Bs,a=r.shiftKey,u=l(e,`${o}`,a);await i.restore({sort:u},{panel:e._panel})}function Fs(e,t,i){let r=[],n=!1;for(let s of e._config.sort){let[o,l]=s;if(o===t){n=!0;let a=Ui(e,t,l,i);a&&r.push(a)}else r.push(s)}return n||r.push([t,i?"desc abs":"desc"]),r}function Bs(e,t,i){for(let[r,n]of e._config.sort)if(r===t){let s=Ui(e,t,n,i);return s?[s]:[]}return[[t,i?"desc abs":"desc"]]}function Ui(e,t,i,r){let n=e._config.split_by.length>0?Ds:Ps,s=i?n[i]:"desc";if(s)return[t,s]}async function $i(e,t,i){let r=t.getMeta(i.target);if(!r||r.type!=="row_header")return;let n=i.target.classList.contains("psp-tree-label-collapse");i.shiftKey&&n?e._view.set_depth(r.row_header.filter(s=>s!==void 0).length-2):i.shiftKey?e._view.set_depth(r.row_header.filter(s=>s!==void 0).length-1):n?e._view.collapse(r.y):e._view.expand(r.y),e._num_rows=await e._view.num_rows(),e._num_columns=await e._view.num_columns(),t.draw()}function Ns(e,t,i){return async r=>{let n=r;if(n.which!==1)return;let s=n.target;if(s?.tagName!=="A"){for(;s&&s.tagName!=="TD"&&s.tagName!=="TH";)if(s=s.parentElement,!s||!t.contains(s))return;if(s){if(s.classList.contains("psp-tree-label")){e._edit_mode!=="SELECT_ROW_TREE"&&$i(e,t,n);return}if(s.classList.contains("psp-menu-enabled")){let o=t.getMeta(s)?.column_header?.[e._config.split_by.length];await i.toggleColumnSettings(`${o}`,{panel:e._panel})}else s.classList.contains("psp-sort-enabled")&&Is(e,t,i,n,s)}}}}function Os(e,t,i){return async r=>{let n=r;if(n.which!==1)return;let s=n.target;if(s?.tagName!=="A"){for(;s&&s.tagName!=="TD"&&s.tagName!=="TH";)if(s=s.parentElement,!s||!t.contains(s))return;s&&s.classList.contains("psp-tree-label")&&e._edit_mode==="SELECT_ROW_TREE"&&$i(e,t,n)}}}function zs(e){return t=>{let i=t;if(i.which!==1)return;let r=i.target;for(;r&&r.tagName!=="TD"&&r.tagName!=="TH";)if(r=r.parentElement,!r||!e.contains(r))return;r&&(r.classList.contains("psp-tree-label")&&i.offsetX<26||r.classList.contains("psp-header-leaf")&&!r.classList.contains("psp-header-corner"))&&i.stopImmediatePropagation()}}function Gi(e,t,i){let r=e.getMeta(i);if(!r)return!1;let n=t._schema[t._column_paths[r.x]],s=i.textContent||"",o=t._ids[r.y-r.y0][0];if(n==="float"||n==="integer"){let a=parseFloat(s.replace(/,/g,""));if(isNaN(a))return!1;s=a}else if(n==="date"||n==="datetime"){let a=Date.parse(s);if(isNaN(a))return!1;s=a}else n==="boolean"&&(s=s==="true"?!1:s==="false"?!0:null);let l={__INDEX__:o,[t._column_paths[r.x]]:s};return t._table.update([l],{port_id:t._edit_port,format:null}),!0}function Hs(e,t,i,r){let n=t.getMeta(r.target);if(n?.type==="body"||n?.type==="column_header"){let s=e._is_editable[n.x],o=$e(e,n)==="boolean",l=r.target.classList.contains("psp-null");s&&o&&!l&&Gi(t,e,r.target)}}var Ue=new WeakMap;function Vi(e,t){return e!=="boolean"&&!(e==="string"&&t==="link")}function ji(e,t,i){let r=t.getMeta(i);if(r?.type!=="body"||!fe(e,void 0)||!e._is_editable[r.x])return!1;let n=$e(e,r),s=t[W]||{},o=r.column_header?.[e._config.split_by.length],l=o?s[o.toString()]?.format:void 0;return Vi(n,l)}function Xi(e,t){let i=Ue.get(e);i!==t&&(i?.removeAttribute("contenteditable"),t.setAttribute("contenteditable","true"),Ue.set(e,t))}function Ys(e,t){t.removeAttribute("contenteditable"),Ue.get(e)===t&&Ue.delete(e)}function Ws(e,t,i){return r=>{let n=r.target;n?.tagName==="TD"&&ji(e,t,n)&&Xi(t,n)}}function wt(e,t,i){ji(e,t,i)&&Xi(t,i)}function Us(e,t,i,r){return n=>{let s=n.target,o=!1;if(fe(e,i)&&r.has(t)){s.classList.remove("psp-error");let l=r.get(t);r.delete(t),l.content!==s.textContent&&(Gi(t,e,s)||(s.textContent=l.content||"",s.classList.add("psp-error"),s.focus(),o=!0))}!o&&s?.hasAttribute?.("contenteditable")&&Ys(t,s)}}function $s(e,t,i,r){return n=>{let s=n.target;wt(e,t,s);let o=t.getMeta(s);if(o?.type==="body"){let l={x:o.x,y:o.y,content:s.textContent||void 0};r.set(t,l)}}}function Gs(e,t,i,r){let n=r.get(i),s=i.getRootNode();if(n){for(let{element:o,metadata:l}of t)if(l.type==="body"&&l.x===n.x&&l.y===n.y){s.activeElement!==o&&(wt(e,i,o),o.focus({preventScroll:!0}));return}document.activeElement!==document.body&&i.contains(s.activeElement)&&s.activeElement.blur()}}function Vs(e,t,i){let r=t.get(e);if(!r)return!1;let n=e.getRootNode(),s=e.children[0]?.children[1];if(s)for(let o of s.children)for(let l of o.children){let a=e.getMeta(l);if(a?.type==="body"&&a.x===r.x&&a.y===r.y)return n.activeElement!==l&&(i&&wt(i,e,l),l.focus({preventScroll:!0})),!0}return document.activeElement!==document.body&&e.contains(n.activeElement)&&n.activeElement.blur(),!1}function js(e){let t;return async function(i,r,n,s,o,l){if(t){await t;return}let a;t=new Promise(c=>a=c);let u=await e(i,r,n,s,o,l);return t=void 0,a(),u}}function Ti(e){if(e.isContentEditable){let t=e.getRootNode().getSelection()?.getRangeAt(0);if(!t)return 0;let i=t.cloneRange();return i.selectNodeContents(e),i.setEnd(t.endContainer,t.endOffset),i.toString().length}else return e.selectionStart||0}var he=js(async function(e,t,i,r,n,s){let o=t.getMeta(r);if(!o||o.type!=="body")return;let l=e._column_paths.length,a=e._num_rows,u=i.get(t);if(!u)return;o.x+n<l&&0<=o.x+n&&(u.x=o.x+n),o.y+s<a&&0<=o.y+s&&(u.y=o.y+s);let c=Math.max(o.x0-10,0),d=Math.min(o.x0+10,l),h=Math.max(o.y0-5,0),p=Math.min(o.y0+10,a),f=o.x0+n,_=o.y0+s;for(;!Vs(t,i,e)&&f>=c&&f<d&&_>=h&&_<p;)await t.scrollToCell(f,_),i.set(t,u),f+=n,_+=s});function Xs(e,t,i){let r=t.getMeta(i);return r?.type==="body"&&r.y===e._num_rows-1}function qs(e,t,i,r,n){let s=t.getRootNode().activeElement;switch(n.target.classList.remove("psp-error"),n.key){case"Enter":n.preventDefault(),Xs(e,t,s)?(s.blur(),r.delete(t)):n.shiftKey?he(e,t,r,s,0,-1):he(e,t,r,s,0,1);break;case"ArrowLeft":Ti(s)===0&&(n.preventDefault(),he(e,t,r,s,-1,0));break;case"ArrowUp":n.preventDefault(),he(e,t,r,s,0,-1);break;case"ArrowRight":Ti(s)===(s.textContent?.length||0)&&(n.preventDefault(),he(e,t,r,s,1,0));break;case"ArrowDown":n.preventDefault(),he(e,t,r,s,0,1);break;default:}}function Ks(e,t,i,r){return n=>{let s=n;if(e._edit_mode==="EDIT"){if(!fe(e,i))return;qs(e,t,i,r,s)}else console.debug(`Mode ${e._edit_mode} for "keydown" event not yet implemented`)}}function Zs(e,t,i){return r=>{let n=r;if(e._edit_mode==="EDIT"){if(!fe(e,i))return;Hs(e,t,i,n)}}}async function qi({_view:e,_config:t},i,r){let n=t.group_by,s=t.split_by,o=i>=0?i:0,l=o+1,a=await e.to_json({start_row:o,end_row:l}),u=a.map(_=>_.__ROW_PATH__)[0]||[],c=n.map((_,g)=>{let m=u[g];return m?[_,"==",m]:void 0}).filter(_=>_!==void 0),d=Object.keys(a[0]).filter(_=>!_t(_))[r],h={row:a[0],column_names:[],config:{filter:[]}},p=[];if(d){let _=d.split("|");h.column_names=[_[s.length]],p=s.map((g,m)=>{let v=_[m];return v?[g,"==",v]:void 0}).filter(g=>g!==void 0).filter(([,,g])=>!_t(g))}let f=t.filter.concat(c).concat(p);return h.config={filter:f},h}function Qs(e,t,i,r){return async n=>{let s=n,o=t.getMeta(s.target);if(!o||o.type!=="body"||e._edit_mode==="SELECT_ROW_TREE")return;let{x:l,y:a}=o,{row:u,column_names:c,config:d}=await qi(e,a,l),h=r.getAttribute("slot")??void 0;i.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:u,column_names:c,config:d,panel:h}}))}}var Js="mouse-selected-area",eo=(e,t,{className:i=Js,selected:r=[],onSelect:n}={})=>(e.model._selection_state={selected_areas:r,dirty:!0},t.addEventListener("mousedown",to(e,t,i)),t.addEventListener("mouseover",io(e,t,i)),t.addEventListener("mouseup",ro(e,t,i,n)),t.addStyleListener(()=>ee(e,t,i)),t);function Ve(e){return e==="SELECT_ROW_TREE"}var to=(e,t,i)=>r=>{let n=r;if(n.button===0&&je(e.model._edit_mode)){if(Ve(e.model._edit_mode))return;e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={};let s=t.getMeta(n.target);if(s?.type==="body"&&s.x!==void 0&&s.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:s.x,y:s.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let o={x0:s.x,x1:s.x,y0:s.y,y1:s.y};e.model._selection_state.potential_selection=o,ee(e,t,i,e.model._selection_state.selected_areas.concat([o]));return}}e.model._selection_state.selected_areas=[]},io=(e,t,i)=>r=>{let n=r,s=e.model._edit_mode;if(je(s)&&!Ve(s)&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0){let o=t.getMeta(n.target);if(o?.type==="body"&&o.x!==void 0&&o.y!==void 0){let l={x0:Math.min(o.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(o.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(o.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(o.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=l,ee(e,t,i,e.model._selection_state.selected_areas.concat([l]))}}},ro=(e,t,i,r)=>n=>{let s=n,o=e.model._edit_mode;if(je(o)){let l=t.getMeta(s.target);if(!l)return;if(Ve(o)){if((l.type==="body"||l.type==="row_header")&&l.y!==void 0&&l.y>=0){let a=e.model._selection_state.selected_areas;if(a.length>0&&a[0].y0===l.y)e.model._selection_state.selected_areas=[],e.model._selection_state.dirty=!0,ee(e,t,i,[]),r?.(a[0],!0);else{let u={x0:0,x1:0,y0:l.y,y1:l.y};e.model._selection_state.selected_areas=[u],e.model._selection_state.dirty=!0,ee(e,t,i),r?.(u,!1)}}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0;return}if((e.model._selection_state.old_selected_areas?.length??0)>0){let a=e.model._selection_state.old_selected_areas[0];if(a.x0===a.x1&&a.y0===a.y1&&l?.type==="body"&&a.x0===l.x&&a.y0===l.y){e.model._selection_state.selected_areas=[],e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0,ee(e,t,i,[]);return}}if(e.model._selection_state.old_selected_areas=[],e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0&&l?.type==="body"&&l.x!==void 0&&l.y!==void 0){let a={x0:Math.min(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(l.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(l.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(a),ee(e,t,i)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function Mi(e){return e==="SELECT_COLUMN"||e==="SELECT_REGION"}function Ri(e){return e==="SELECT_ROW"||e==="SELECT_REGION"||e==="SELECT_ROW_TREE"}function no(e,t,{x0:i,x1:r,y0:n,y1:s}){let o={},l=t.model._edit_mode;i!==void 0&&Mi(l)&&(o.start_col=i),r!==void 0&&Mi(l)&&(o.end_col=r+1),n!==void 0&&Ri(l)&&(o.start_row=n),s!==void 0&&Ri(l)&&(o.end_row=s+1),e.setSelection(o,{panel:t.model._panel})}var so={SELECT_REGION:(e,t)=>t.x0<=e.x&&e.x<=t.x1&&t.y0<=e.y&&e.y<=t.y1,SELECT_ROW:(e,t)=>t.y0<=e.y&&e.y<=t.y1,SELECT_ROW_TREE:(e,t)=>t.y0<=e.y&&e.y<=t.y1,SELECT_COLUMN:(e,t)=>t.x0<=e.x&&e.x<=t.x1};function je(e){return e==="SELECT_REGION"||e==="SELECT_ROW"||e==="SELECT_COLUMN"||e==="SELECT_ROW_TREE"}var ee=(e,t,i,r)=>{let n=e.model._edit_mode;if(je(n))if(r=e.model._selection_state.selected_areas.slice(0),e.model._selection_state.potential_selection&&r.push(e.model._selection_state.potential_selection),r.length>0)no(e.parentElement,e,r[0]),Ve(n)||oo(e,t,r,i);else{e.parentElement.setSelection(void 0,{panel:e.model._panel});let s=t.querySelectorAll("tbody td");for(let o of s)o.classList.remove(i)}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let s=t.querySelectorAll("tbody td, tbody th");for(let o of s)o.classList.remove(i)}},oo=(e,t,i,r)=>{let n=so[e.model._edit_mode];if(!n||i.length===0)return;let s=t.querySelectorAll("tbody td");for(let o of s){let l=t.getMeta(o);if(!l||l.type!=="body")continue;let a=!1;for(let u of i)u.x0!==void 0&&u.y0!==void 0&&u.x1!==void 0&&u.y1!==void 0&&n(l,u)&&(a=!0,e.model._selection_state.dirty=!0,o.classList.add(r));a||o.classList.remove(r)}};function lo(e,t,i,r){if(t.length===0)return;let n=e._column_settings_selected_column,s=t.length,o=r.hasAttribute("settings")&&r.getActivePanel()===e._panel;if(s<=1?t[0]?.row.removeAttribute("id"):t.forEach(({row:c},d)=>{let h=o?1:0,p=d===s-(h+1)?"psp-column-titles":d===s-h?"psp-column-edit-buttons":null;p?c.setAttribute("id",p):c.removeAttribute("id")}),r.classList.toggle("psp-menu-open",!!n),o&&s>=2){let c=t[s-2],d=t[s-1];if(c&&d){t.slice(0,s-2).forEach(({cells:h})=>{h.forEach(({element:p})=>{p.classList.toggle("psp-menu-open",!1)})});for(let h=0;h<c.cells.length;h++){let p=c.cells[h]?.element,f=d.cells[h]?.element;if(!p||!f)continue;let _=p.textContent===n;p.classList.toggle("psp-menu-open",_),f.classList.toggle("psp-menu-open",_)}}}let l=s<=1,a=e._config.split_by.length,u=e._config.split_by.length+1;if(a<t.length){let c=t[a];c&&Ai(e,c,i,!1,u>=t.length,l)}if(u<t.length){let c=t[u];c&&Ai(e,c,i,!0,!0,l)}}function ao(e,t,i,[,,,,,r,n],[,,,,,s,o],l){let a=e._ids?.[t.dy??0]?.join("|"),u=(l?(t.column_header??[]).slice(0,-1):t.column_header??[]).join("|");if(e.last_reverse_columns?.has(u)&&e.last_reverse_ids?.has(a)){let c=e.last_reverse_ids?.get(a),d=e.last_reverse_columns.get(u);e._is_old_viewport?d!==void 0&&c!==void 0&&e.last_meta?.[d]?.[c]!==void 0&&e.last_meta[d][c]>(t.user??0)?(i.style.setProperty("--pulse--background-color-start",s),i.style.setProperty("--pulse--background-color-end",o),i.style.animationName==="pulse_neg"?i.style.animation="pulse_neg2 0.5s linear":i.style.animation="pulse_neg 0.5s linear"):d!==void 0&&c!==void 0&&e.last_meta?.[d]?.[c]!==void 0&&e.last_meta[d][c]<(t.user??0)?(i.style.setProperty("--pulse--background-color-start",r),i.style.setProperty("--pulse--background-color-end",n),i.style.animationName==="pulse_pos"?i.style.animation="pulse_pos2 0.5s linear":i.style.animation="pulse_pos 0.5s linear"):c!==t.dy&&(i.style.animation=""):i.style.animation=""}else i.style.animation=""}var ki=1;function co(e,t,i,r){if(r==null){e.style.removeProperty("--psp-bar-size"),e.removeAttribute("data-psp-label");return}let n=Math.max(0,Math.min(ki,Math.abs(r/t.fg_gradient)*ki)),s=Number.isFinite(n)?(n*100).toFixed(2):"100";if(e.style.setProperty("--psp-bar-size",`${s}%`),e.style.setProperty("--psp-bar-anchor",r<0?"100%":"0%"),t.number_fg_mode==="label-bar"){let o=Ii(i??"float",t);e.setAttribute("data-psp-label",o?o.format(r):String(r))}else e.removeAttribute("data-psp-label")}function uo(e,t,i,r,n,s){let o=(n.user??0)>0,l=(n.user??0)<0,a;t?.pos_bg_color!==void 0?a=t.pos_bg_color:a=e._pos_bg_color;let u;t?.neg_bg_color!==void 0?u=t.neg_bg_color:u=e._neg_bg_color;let c=o?a:l?u:["",e._plugin_background[0],e._plugin_background[1],e._plugin_background[2],"","",""];{let[g,m,v,b]=c;if(r.style.position="",n._is_hidden_by_aggregate_depth)r.style.animation="",r.style.backgroundColor="";else if(t?.number_bg_mode==="color")r.style.animation="",r.style.backgroundColor=g;else if(t?.number_bg_mode==="gradient"){let y=t.bg_color_stops??e._default_bg_color_stops,A=.5+.5*Math.max(-1,Math.min(1,(n.user??0)/(t.bg_gradient??1))),T=gs(y,A),x=Ae(T);r.style.animation="",r.style.color=x,r.style.backgroundColor=te(T)}else t?.number_bg_mode==="pulse"?(ao(e,n,r,a,u,s),r.style.backgroundColor=""):(t?.number_bg_mode==="disabled"||t?.number_bg_mode,r.style.animation="",r.style.backgroundColor="")}let d;t?.pos_fg_color!==void 0?d=t.pos_fg_color:d=e._pos_fg_color;let h;t?.neg_fg_color!==void 0?h=t.neg_fg_color:h=e._neg_fg_color;let p=o?d:l?h:["",e._plugin_background[0],e._plugin_background[1],e._plugin_background[2],"","",""],[f,,,,_]=p;if(n._is_hidden_by_aggregate_depth)r.style.backgroundColor="",r.style.color="",r.style.removeProperty("--psp-bar-size"),r.removeAttribute("data-psp-label");else if(t?.number_fg_mode==="disabled")if(t?.number_bg_mode==="color"){let g=e._plugin_background,m=Ae(We([c[1],c[2],c[3],1],g));r.style.color=m}else t?.number_bg_mode==="gradient"||(r.style.color="");else t?.number_fg_mode==="bar"||t?.number_fg_mode==="label-bar"?(r.style.color="",r.style.setProperty("--psp-label-bar-color",_),r.style.setProperty("--psp-label-bar-bg",f),co(r,t,i,n.user)):(t?.number_fg_mode==="color"||!t?.number_fg_mode)&&(r.style.color=f)}function ho(e,t,i,r){let n=r.column_header?.[e._config.split_by.length],s=t?.color!==void 0?t.color:e._color,[o,l,a,u]=s;if(r._is_hidden_by_aggregate_depth)i.style.backgroundColor="",i.style.color="";else if(t?.string_color_mode==="foreground"&&r.user!==null)i.style.color=o,i.style.backgroundColor="",t?.format==="link"&&i.children[0]&&(i.children[0].style.color=o);else if(t?.string_color_mode==="background"&&r.user!==null){let c=e._plugin_background,d=Ae(We([l,a,u,1],c));i.style.color=d,i.style.backgroundColor=o}else if(t?.string_color_mode==="series"&&r.user!==null&&n){e._series_color_map.has(n)||(e._series_color_map.set(n,new Map),e._series_color_seed.set(n,0));let c=e._series_color_map.get(n);if(r.user&&!c.has(r.user)){let y=e._series_color_seed.get(n)??0;c.set(r.user,y),e._series_color_seed.set(n,y+1)}let d=c.get(r.user)??0,h=t?.palette_colors,p=h&&h.length>0?h:e._series_palette,f=p[d%p.length],[_,g,m]=me(f),v=e._plugin_background,b=Ae(We([_,g,m,1],v));i.style.color=b,i.style.backgroundColor=f}else i.style.backgroundColor="",i.style.color=""}function po(e,t,i,r){let n=t?.color!==void 0?t.color:e._color,[s,o,l,a]=n;if(r._is_hidden_by_aggregate_depth)i.style.backgroundColor="",i.style.color="";else if(t?.datetime_color_mode==="foreground"&&r.user!==null)i.style.color=s,i.style.backgroundColor="";else if(t?.datetime_color_mode==="background"&&r.user!==null){let u=e._plugin_background,c=Ae(We([o,l,a,1],u));i.style.color=c,i.style.backgroundColor=s}else i.style.backgroundColor="",i.style.color=""}function fo(e,t,i,r){if(r._is_hidden_by_aggregate_depth)i.style.backgroundColor="",i.style.color="";else{let[n]=r.user===!0?e._pos_fg_color:r.user===!1?e._neg_fg_color:["",0,0,0,""];i.style.backgroundColor="",i.style.color=n}}function mo(e,t,i,r){let n=r.value!==void 0&&r.value!==null&&r.value?.toString()?.trim().length>0,s=(r.row_header_x??0)>=e._config.group_by.length,o=t.getMeta({dx:0,dy:(r.y??0)-(r.y0??0)+1}),l=o&&o.row_header&&typeof o.row_header[(r.row_header_x??0)+1]<"u";i.classList.toggle("psp-tree-label",n&&!s),i.classList.toggle("psp-tree-label-expand",n&&!s&&!l),i.classList.toggle("psp-tree-label-collapse",n&&!s&&l),i.classList.toggle("psp-tree-leaf",n&&s)}var Li=new WeakMap;function go(e,t){let i=e.getRootNode();if(!i||!i.adoptedStyleSheets)return;let r=Li.get(e);r||(r={table:void 0,scope:void 0,sheet:new CSSStyleSheet,rules:new Map},Li.set(e,r));let n=e.children[0];if(n&&(r.table!==n&&(r.table=n,r.scope=Array.from(n.classList).find(s=>s.startsWith("rt-scope-")),r.sheet.replaceSync(""),r.rules.clear()),!!r.scope)){i.adoptedStyleSheets.includes(r.sheet)||(i.adoptedStyleSheets=[...i.adoptedStyleSheets,r.sheet]);for(let[s,o]of t){let l=r.rules.get(s);if(l===void 0){let a=r.sheet.cssRules.length;r.sheet.insertRule(`.${r.scope} td.rt-col-${s}, .${r.scope} th.rt-col-${s}{text-align:${o}}`,a),l={rule:r.sheet.cssRules[a],last:o},r.rules.set(s,l)}else l.last!==o&&(l.rule.style.textAlign=o,l.last=o)}}}var _o=1,bo=2,yo=4,vo=8,xo=16,wo=32,Eo=64;function Co(e){if(!e)return 0;let t=0;for(let i=0;i<e.length;i++)e[i]!==void 0&&t++;return t}function So(e,t,i,r,n,s,o){let l=n?e._tree_selection_id:void 0;o.classList.toggle("flat-group-rollup-mode",e._config.group_rollup_mode==="flat");let a=e._config.group_rollup_mode==="rollup",u=e._config.split_by.length,c=e._config.group_by.length,d=e._pos_bg_color,h=e._config.columns.length>1?e._column_settings_selected_column:void 0,p=new Map,f=(g,m,v,b)=>{let y=p.get(g);if(y)return y;let A=v?i[v.toString()]:void 0,T=m===void 0?void 0:e._column_paths[m]?.split("|").length-1,x=u>0&&T!==void 0&&T<u,k=b==="integer"||b==="float",P=k&&(A?.number_bg_mode==="gradient"||A?.number_bg_mode==="pulse"||A?.number_fg_mode==="bar"||A?.number_fg_mode==="label-bar")||b==="string"&&(A?.string_color_mode==="series"||A?.format==="link"),S=s&&!!e._is_editable[m??-1];return y={plugin:A,type:b,is_numeric:k,is_rollup_col:x,n_split_levels:T,column_name:v?.toString(),mods:(r?1:0)|(n?2:0)|(S?4:0)|(x?8:0)|(T===0?16:0)|(v===h?32:0)|(h?64:0)|(a?128:0)|(A?.number_fg_mode==="bar"?256:0)|(A?.number_fg_mode==="label-bar"?512:0),value_styled:P,text_editable:S&&Vi(b,A?.format),boolean_editable:S&&b==="boolean"},p.set(g,y),y},_=new Map;for(let{element:g,metadata:m,isHeader:v}of t){let b=m.column_header?.[u]?.toString?.()??m.column_header?.[u],y=m.x,A=$e(e,m),T=y??-1-(m.row_header_x??0),x=f(T,y,b,A),k=m.size_key;k!==void 0&&!_.has(k)&&_.set(k,!v&&x.is_numeric?"right":"left");let P=a&&(E=>E===0?!1:E-1<Math.min(c,x.plugin?.aggregate_depth||0))(Co(m.row_header));m._is_hidden_by_aggregate_depth=P;let S=(m.value===null?_o:0)|(m.user===null?bo:0)|(P?yo:0);if(x.is_numeric||x.type==="boolean"){let E=m.user;S|=(E===!0||E>0?vo:0)|(E===!1||E<0?xo:0)}let D=!1,C=!1;if(n&&l){let E=e._ids[(m.y??0)-(m.y0??0)],R=!0;for(let I=0;I<l.length;I++)if(l[I]!==E[I]){R=!1;break}D=E.length===l.length&&R,C=E.length!==l.length&&R,S|=(D?wo:0)|(C?Eo:0)}if(!v){let E=m.__psp_style_memo;if(E!==void 0&&E.plugin===x.plugin&&E.type===x.type&&E.mods===x.mods&&E.theme===d&&E.bits===S&&(!x.value_styled||E.value===m.user))continue;E!==void 0?(E.plugin=x.plugin,E.type=x.type,E.mods=x.mods,E.theme=d,E.bits=S,E.value=x.value_styled?m.user:void 0):m.__psp_style_memo={plugin:x.plugin,type:x.type,mods:x.mods,theme:d,bits:S,value:x.value_styled?m.user:void 0}}g.classList.toggle("psp-split-total",x.is_rollup_col&&x.n_split_levels===0),g.classList.toggle("psp-split-subtotal",x.is_rollup_col&&x.n_split_levels>0),x.is_numeric?uo(e,x.plugin,x.type,g,m,r):x.type==="boolean"?fo(e,x.plugin,g,m):x.type==="string"?ho(e,x.plugin,g,m):x.type==="date"||x.type==="datetime"?po(e,x.plugin,g,m):(g.style.backgroundColor="",g.style.color=""),g.classList.toggle("psp-bool-type",x.type==="boolean"&&m.user!==null),g.classList.toggle("psp-null",m.value===null),g.classList.toggle("psp-menu-open",!!h&&b===h),g.classList.toggle("psp-color-mode-bar",x.plugin?.number_fg_mode==="bar"&&x.is_numeric),g.classList.toggle("psp-color-mode-label-bar",x.plugin?.number_fg_mode==="label-bar"&&x.is_numeric),v&&mo(e,o,g,m),g.classList.toggle("psp-select-region-inactive",!1),n&&(l?v&&m.type==="row_header"&&m.row_header_x!==void 0&&m.row_header_x<e._ids[(m.y??0)-(m.y0??0)].length?g.classList.toggle("psp-select-region",!1):(g.classList.toggle("psp-select-region",D),g.classList.toggle("psp-select-region-inactive",C)):g.classList.toggle("psp-select-region",!1)),!v&&m.type==="body"&&(g.classList.toggle("psp-editable",x.text_editable),x.text_editable?g.setAttribute("tabindex","-1"):g.hasAttribute("tabindex")&&g.removeAttribute("tabindex"),g.classList.toggle("boolean-editable",x.boolean_editable&&m.user!==null))}go(o,_)}function Ao(e,t,i,r,n){return function(){let s=i[W]||{},o=r.hasAttribute("settings"),l=t._edit_mode==="SELECT_ROW_TREE",a=fe(t,r),u=fe(t,r,!0);e.classList.toggle("edit-mode-allowed",u);let c=[],d=[],h=i.children[0]?.children[1];if(h)for(let f of h.children)for(let _ of f.children){let g=i.getMeta(_);if(g&&(g.type==="body"||g.type==="row_header")){let m=_.tagName==="TH";c.push({element:_,metadata:g,isHeader:m})}}let p=i.children[0]?.children[0];if(p)for(let f of p.children){let _={row:f,cells:[]};for(let g of f.children){let m=i.getMeta(g);_.cells.push({element:g,metadata:m})}d.push(_)}So(t,c,s,o,l,a,i),ks(t,d,i),lo(t,d,i,r),Gs(t,c,i,n)}}async function To(e){let t=this.parentElement,i=this.getAttribute("slot")??void 0,r=await t.getTable({panel:i});if(this._initialized)await Ci.call(this,this.regular_table,r,e,this.model);else{if(this.innerHTML="",this.shadowRoot?this.shadowRoot.appendChild(this.regular_table):this.appendChild(this.regular_table),this.model=await Ci.call(this,this.regular_table,r,e),!this.model)return;let n=this.model,s=this.regular_table,o=async(a,u)=>{if(n._edit_mode!=="SELECT_ROW_TREE")return;if(u)n._tree_selection_id=void 0;else{let f=a.y0-(n._last_window?.start_row??0);f>=0&&f<n._ids.length&&(n._tree_selection_id=n._ids[f])}let{row:c,column_names:d,config:h}=await qi(n,a.y0,0),p;if(u){if((n._last_insert_configs?.length||0)>0)p=new Q(!1,c,[],n._last_insert_configs??[],[]);else throw new Error("Suprious deselect");n._last_insert_configs=void 0}else p=new Q(!0,c,d,n._last_insert_configs??[],[h]),n._last_insert_configs=[h];p.panel=this.getAttribute("slot")??void 0,await s.draw({preserve_width:!0}),t.dispatchEvent(new CustomEvent("perspective-global-filter",{bubbles:!0,composed:!0,detail:p}))};eo(this,this.regular_table,{className:"psp-select-region",onSelect:o});let l=new WeakMap;this.regular_table.addStyleListener(Ao(this,this.model,this.regular_table,t,l)),this.regular_table.addEventListener("click",zs(this.regular_table)),this.regular_table.addEventListener("click",Qs(this.model,this.regular_table,t,this)),this.regular_table.addEventListener("mousedown",Ns(this.model,this.regular_table,t)),this.regular_table.addEventListener("dblclick",Os(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",Zs(this.model,this.regular_table,t)),this.regular_table.addEventListener("pointerdown",Ws(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",$s(this.model,this.regular_table,t,l)),this.regular_table.addEventListener("focusout",Us(this.model,this.regular_table,t,l)),this.regular_table.addEventListener("keydown",Ks(this.model,this.regular_table,t,l)),t.addEventListener("perspective-toggle-column-settings",a=>{let u=a;if(!this.isConnected)return;let c=u.detail.open&&a.target===this?u.detail.column_name??void 0:void 0;Ls(this.model,this.regular_table,t,c),this.model._column_settings_selected_column=c}),this._initialized=!0}}function Pi(e){if(typeof e=="string")return vs(e)??void 0}function Mo(e){if(typeof e=="string")return xs(e)?.map(te)??void 0}function Ro(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let i={};for(let[s,o]of Object.entries(t))o.column_size_override!==void 0&&(this.model?._config.split_by?.length||(i[s]=o.column_size_override),delete o.column_size_override);this._columns_config=structuredClone(t);let r={};if(t)for(let[s,o]of Object.entries(t)){let l=Pi(o.fg_colors),a=Pi(o.bg_colors),u=(c,d)=>J(te(c[d].rgb));r[s]={...o,pos_fg_color:l?u(l,l.length-1):void 0,neg_fg_color:l?u(l,0):void 0,pos_bg_color:a?u(a,a.length-1):void 0,neg_bg_color:a?u(a,0):void 0,color:o.color?J(o.color):void 0,bg_color_stops:a,palette_colors:Mo(o.palette)}}"edit_mode"in e?Se.indexOf(e.edit_mode)!==-1?bt.call(this,e.edit_mode,!1):console.error("Unknown edit mode "+e.edit_mode):bt.call(this,"READ_ONLY",!1),"scroll_lock"in e?Si.call(this,e.scroll_lock):Si.call(this,!1);let n=this.regular_table;yt.call(this,i,!0),n[W]=r}function ko(){if(this.regular_table){let e={scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode};return JSON.parse(JSON.stringify(e))}return{}}async function Lo(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=Oi.call(this),i=this.regular_table.draw({invalid_columns:!0});this._reset_scroll_top&&(this.regular_table.scrollTop=0,this._reset_scroll_top=!1),this._reset_scroll_left&&(this.regular_table.scrollLeft=0,this._reset_scroll_left=!1),this._reset_select&&(this.regular_table.dispatchEvent(new CustomEvent("psp-deselect-all",{bubbles:!1})),this._reset_select=!1),this._reset_column_size&&(this.regular_table.resetAutoSize(),this._reset_column_size=!1),yt.call(this,t),await i,Object.keys(t).length>0&&yt.call(this,t),this._toolbar?.classList.toggle("aggregated",this.model._config.group_by.length>0||this.model._config.split_by.length>0)}function Po(e,t,i,r,n,s){let o=[];if((n?.split_by?.length??0)===0&&o.push({kind:"Number",key:"column_size_override",default:0,min:1}),e==="integer"||e==="float"){let u=this.model._pos_fg_color[0],c=this.model._neg_fg_color[0],d=this.model._pos_bg_color[0],h=this.model._neg_bg_color[0];o.push({kind:"Enum",key:"number_fg_mode",default:"color",variants:[{value:"disabled",label:"Disabled"},{value:"color",label:"Color"},{value:"bar",label:"Bar"},{value:"label-bar",label:"Gradient"}]});let p=r?.number_fg_mode??"color";p!=="disabled"&&o.push({kind:"GradientStops",key:"fg_colors",default:mt([{color:c,offset:0},{color:u,offset:1}]),discrete:!0}),(p==="bar"||p==="label-bar")&&o.push({kind:"Number",key:"fg_gradient",default:s?.abs_max??0,include:!0}),o.push({kind:"Enum",key:"number_bg_mode",default:"disabled",variants:[{value:"disabled",label:"Disabled"},{value:"color",label:"Color"},{value:"gradient",label:"Gradient"},{value:"pulse",label:"Pulse"}]});let f=r?.number_bg_mode??"disabled";f!=="disabled"&&(f==="color"?o.push({kind:"GradientStops",key:"bg_colors",default:mt([{color:h,offset:0},{color:d,offset:1}]),discrete:!0}):o.push({kind:"GradientStops",key:"bg_colors",default:mt([{color:h,offset:0},{color:te(this.model._plugin_background),offset:.5},{color:d,offset:1}])})),f==="gradient"&&o.push({kind:"Number",key:"bg_gradient",include:!0,default:s?.abs_max??0}),o.push({kind:"NumberFormat"})}else if(e==="date"||e==="datetime")o.push({kind:"DatetimeFormat"}),o.push({kind:"Enum",key:"datetime_color_mode",default:"none",variants:[{value:"none",label:"None"},{value:"foreground",label:"Foreground"},{value:"background",label:"Background"}]}),(r?.datetime_color_mode??"none")!=="none"&&o.push({kind:"Color",key:"color",default:this.model._color[0]});else if(e==="string"){o.push({kind:"StringFormat"}),o.push({kind:"Enum",key:"string_color_mode",default:"none",variants:[{value:"none",label:"None"},{value:"foreground",label:"Foreground"},{value:"background",label:"Background"},{value:"series",label:"Series"}]});let u=r?.string_color_mode??"none";u==="series"?o.push({kind:"Palette",key:"palette",default:ws(this.model._series_palette)}):u!=="none"&&o.push({kind:"Color",key:"color",default:this.model._color[0]})}let l=n?.group_by??[],a=(n?.group_rollup_mode??"rollup")==="rollup";return l.length>0&&a&&o.push({kind:"AggregateDepth"}),{fields:o}}var Do='regular-table{--psp-datagrid--hover--border-color:var(--psp-inactive--color,#c5c9d080);margin:12px 0 0 12px;padding:0;font-family:inherit;& div[tabindex]{outline:none}&>div{position:absolute;inset:0;overflow:hidden}& th{text-align:center}& thead tr:not(.rt-autosize) th{max-width:0;overflow:hidden}& thead tr:last-child .rt-float,& tbody .rt-float,& thead .rt-integer,& tbody .rt-integer{text-align:right}& tbody th{text-align:left}& span.rt-tree-container{align-items:center;height:100%;display:flex}& thead .rt-string,& tbody .rt-string,& thead .rt-date,& tbody .rt-date,& thead .rt-datetime,& tbody .rt-datetime{text-align:left}& thead tr:last-child th{border-bottom:1px solid #8b868045}& tbody tr:first-child td,& tbody tr:first-child th{border-top:1px solid #0000!important}& th{position:relative}& tr th span.rt-tree-group{border-left:1px solid #eee;height:100%;margin-left:5px;margin-right:15px}& td,& th{white-space:nowrap;height:var(--psp-datagrid--row--height,19px);padding:0 5px}& table *{box-sizing:border-box}& table{color:#666;outline:none;position:absolute}& span.rt-row-header-icon{color:#aaa;font-family:var(--psp-button--font-family);padding-right:4px}& span.rt-column-header-icon{width:10px;font-size:10px;font-family:var(--psp-button--font-family);padding-left:3px;display:inline-block}& span.rt-row-header-icon:hover{color:#1a7da1;text-shadow:0 0 3px #1a7da1}& .rt-selected td{background-color:#eee}& .rt-cell-clip{text-overflow:ellipsis;overflow:hidden}& td span.rt-group-name,& th span.rt-group-name{flex:1;height:100%;margin-right:-5px;padding-left:8px;padding-right:5px}& th span.rt-group-name{text-align:left}& td th span.rt-group-leaf,& th span.rt-group-leaf{height:100%;margin-left:16px}& .rt-column-resize{cursor:col-resize;width:10px;height:100%;position:absolute;top:0;right:0}& a{color:var(--psp-datagrid--pos-cell--color)}& a:visited{color:var(--psp-active--color)}& td.psp-null:after,& th.psp-null:after{content:var(--psp-label--null--content,"-");color:var(--psp-label--null--color,inherit);font-size:var(--psp-label--null--font-size,inherit);vertical-align:middle}}regular-table{--psp-mh-color:var(--psp-inactive--border-color,#8b868045);--psp-mh-gap:8px}regular-table thead th{box-shadow:var(--psp-miter-top,0 0 0 0 transparent), var(--psp-miter-right,0 0 0 0 transparent), var(--psp-miter-bottom,0 0 0 0 transparent), var(--psp-miter-left,0 0 0 0 transparent)}.psp-b-r{--psp-miter-right:1px 0px 0px 0px var(--psp-mh-color)}.psp-b-r-mt{--psp-miter-right:calc(var(--psp-mh-gap) / 2 + 1px) calc(var(--psp-mh-gap) / 2) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-r-mb{--psp-miter-right:calc(var(--psp-mh-gap) / 2 + 1px) calc(var(--psp-mh-gap) / -2) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-r-mtb{--psp-miter-right:calc(var(--psp-mh-gap) + 1px) 0px 0px calc(-1 * var(--psp-mh-gap)) var(--psp-mh-color)}.psp-b-l{--psp-miter-left:-1px 0px 0px 0px var(--psp-mh-color)}.psp-b-l-mt{--psp-miter-left:calc(var(--psp-mh-gap) / -2 - 1px) calc(var(--psp-mh-gap) / 2) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-l-mb{--psp-miter-left:calc(var(--psp-mh-gap) / -2 - 1px) calc(var(--psp-mh-gap) / -2) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-l-mtb{--psp-miter-left:calc(-1 * var(--psp-mh-gap) - 1px) 0px 0px calc(-1 * var(--psp-mh-gap)) var(--psp-mh-color)}.psp-b-b{--psp-miter-bottom:0px 1px 0px 0px var(--psp-mh-color)}.psp-b-b-ml{--psp-miter-bottom:calc(var(--psp-mh-gap) / 2) calc(var(--psp-mh-gap) / 2 + 1px) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-b-mr{--psp-miter-bottom:calc(var(--psp-mh-gap) / -2) calc(var(--psp-mh-gap) / 2 + 1px) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-b-mlr{--psp-miter-bottom:0px calc(var(--psp-mh-gap) + 1px) 0px calc(-1 * var(--psp-mh-gap)) var(--psp-mh-color)}.psp-b-t{--psp-miter-top:0px -1px 0px 0px var(--psp-mh-color)}.psp-b-t-ml{--psp-miter-top:calc(var(--psp-mh-gap) / 2) calc(var(--psp-mh-gap) / -2 - 1px) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-t-mr{--psp-miter-top:calc(var(--psp-mh-gap) / -2) calc(var(--psp-mh-gap) / -2 - 1px) 0px calc(var(--psp-mh-gap) / -2) var(--psp-mh-color)}.psp-b-t-mlr{--psp-miter-top:0px calc(-1 * var(--psp-mh-gap) - 1px) 0px calc(-1 * var(--psp-mh-gap)) var(--psp-mh-color)}regular-table{& tbody{& tr:hover th.psp-tree-leaf:not(.psp-select-region):not(.psp-select-region-inactive),& tr:hover th.psp-tree-label:not(.psp-select-region):not(.psp-select-region-inactive),& tr:hover td:not(.psp-select-region):not(.psp-select-region-inactive),& tr:hover:after{box-shadow:0px 1px 0px var(--psp-datagrid--hover--border-color,#c5c9d080);border-color:var(--psp-datagrid--hover--border-color,#c5c9d080)!important;&.psp-menu-open{box-shadow:inset -2px 0px 0px var(--psp--color), inset 2px 0px 0px var(--psp--color), 0px 1px 0px var(--psp-datagrid--hover--border-color,#c5c9d080)}}& tr:last-child:hover td:not(.psp-select-region):not(.psp-select-region-inactive).psp-menu-open{box-shadow:inset -2px 0px 0px var(--psp--color), inset 2px 0px 0px var(--psp--color), inset 0px -2px 0px var(--psp--color), 0px 1px 0px var(--psp-datagrid--hover--border-color,#c5c9d080)}& tr:hover+tr th.psp-tree-leaf:not(.psp-select-region):not(.psp-select-region-inactive),& tr:hover+tr th.psp-tree-label:not(.psp-select-region):not(.psp-select-region-inactive),& tr:hover+tr td:not(.psp-select-region):not(.psp-select-region-inactive){border-top-color:#0000}& tr{& th:first-child:not(:empty),& th:first-child:empty+th:not(:empty),& th:first-child:empty~th:empty+th:not(:empty),& td:first-child{border-left-width:1px;border-left-color:#0000}& th:last-child,& td:last-child{border-right-width:0;border-right-color:#0000}}& tr:hover{color:inherit;& th:first-child:not(:empty),& th:first-child:empty+th:not(:empty),& th:first-child:empty~th:empty+th:not(:empty),& td:first-child{border-left-color:var(--psp-datagrid--hover--border-color,#c5c9d080)!important}& th:last-child,& td:last-child{border-right-color:var(--psp-datagrid--hover--border-color,#c5c9d080)!important}}}}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table,:host(:not(.sub-cell-scroll-disabled)) regular-table table{& tbody td,& thead th:not(.rt-group-corner){transform:translate(var(--regular-table--transform-x,0px))}& tbody{transform:translate(0, var(--regular-table--transform-y,0px))}& tbody tr:first-child{& td,& th,&:after{clip-path:polygon(0 var(--regular-table--clip-y,0), 0 200%, 200% 200%, 200% var(--regular-table--clip-y,0))}}& tbody tr td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) 0, var(--regular-table--clip-x,0) 200%, 200% 200%, 200% 0)}& tbody tr:first-child td:first-of-type{clip-path:polygon(var(--regular-table--clip-x,0) var(--regular-table--clip-y,0), var(--regular-table--clip-x,0) 200%, 200% 200%, 200% var(--regular-table--clip-y,0))}& thead tr:last-child:after,& tbody tr:not(:first-child):after{transform:translate(var(--regular-table--transform-x,0px))}& tbody tr:hover:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0), 0 200%, 200% 200%, 200% var(--regular-table--clip-y,0))}& thead tr th.rt-group-corner+th:not(.rt-group-corner){clip-path:polygon(var(--regular-table--clip-x,0) 0, var(--regular-table--clip-x,0) 200%, 200% 200%, 200% 0)}}regular-table{outline:none;&::-webkit-scrollbar,&::-webkit-scrollbar-corner{background-color:#0000;width:12px;height:12px}&::-webkit-scrollbar-thumb{background-clip:content-box;background:var(--psp--color);border:5.5px solid var(--psp--background-color);min-width:10%;max-width:50%;min-height:10%;max-height:50%}}perspective-viewer,:host{& .psp-menu-enabled{border-radius:3px 3px 0 0;padding:0 6px;font-size:8px}& .psp-menu-enabled:hover,& tr:not(.rt-autosize) th.psp-menu-open{color:var(--psp--background-color);background-color:var(--psp--color);border-bottom-color:var(--psp--color);cursor:pointer}& tr:not(.rt-autosize) th.psp-menu-open{&:before{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:10px;height:8px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--column-settings--mask-image);mask-image:var(--psp-icon--column-settings--mask-image);background-color:var(--psp--background-color);margin-right:4px;display:inline-block}}& td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--psp--color), inset 2px 0px 0px var(--psp--color)}& tr:first-child td.psp-menu-open{border-top-color:var(--psp--color)!important}& tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--psp--color), inset 2px 0px 0px var(--psp--color), inset 0px -2px 0px var(--psp--color)}}perspective-viewer,:host-context(perspective-viewer){& regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--psp-inactive--border-color,#8b868045)}}.psp-sort-enabled:hover{cursor:pointer}regular-table.flat-group-rollup-mode.vertical-row-headers th.psp-tree-label:not(:last-of-type){writing-mode:vertical-lr}.psp-select-region-inactive,:hover .psp-select-region-inactive,:hover th.psp-tree-leaf.psp-select-region-inactive,:hover th.psp-tree-label.psp-select-region-inactive{background-color:var(--psp-inactive--color)!important;color:var(--psp--background-color)!important;border-color:var(--psp--background-color)!important}.psp-error{color:red}td:focus{outline:1px dotted #666}perspective-viewer.dragging,:host-context(perspective-viewer.dragging){& regular-table{pointer-events:none}}.psp-header-border:last-child{border-right-width:0}.psp-header-sort-desc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-desc--mask-image);mask-image:var(--psp-icon--sort-desc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-asc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-asc--mask-image);mask-image:var(--psp-icon--sort-asc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-col-desc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-col-desc--mask-image);mask-image:var(--psp-icon--sort-col-desc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-col-asc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-col-asc--mask-image);mask-image:var(--psp-icon--sort-col-asc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-abs-desc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-abs-desc--mask-image);mask-image:var(--psp-icon--sort-abs-desc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-abs-asc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-abs-asc--mask-image);mask-image:var(--psp-icon--sort-abs-asc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-abs-col-desc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-abs-col-desc--mask-image);mask-image:var(--psp-icon--sort-abs-col-desc--mask-image);margin-left:4px;display:inline-block}.psp-header-sort-abs-col-asc:after{background-repeat:no-repeat;background-color:var(--psp--color);content:"";width:14px;height:11px;-webkit-mask-size:cover;mask-size:cover;-webkit-mask-image:var(--psp-icon--sort-abs-col-asc--mask-image);mask-image:var(--psp-icon--sort-abs-col-asc--mask-image);margin-left:4px;display:inline-block}:host-context(perspective-viewer.shift-active) :is(.psp-header-sort-asc,.psp-header-sort-desc,.psp-header-sort-col-asc,.psp-header-sort-col-desc):after,perspective-viewer.shift-active :is(.psp-header-sort-asc,.psp-header-sort-desc,.psp-header-sort-col-asc,.psp-header-sort-col-desc):after{background-color:var(--shift-active--color,var(--psp-datagrid--pos-cell--color,#1078d1))}:host-context(perspective-viewer.shift-active) :is(.psp-tree-label-expand,.psp-tree-label-collapse):before,perspective-viewer.shift-active :is(.psp-tree-label-expand,.psp-tree-label-collapse):before{color:var(--shift-active--color,var(--psp-datagrid--pos-cell--color,#1078d1))}tbody th:last-of-type{border-right:1px solid var(--psp-inactive--border-color,#8b868045);text-overflow:ellipsis;overflow:hidden}tbody th:empty{background-image:linear-gradient(to right, transparent 9px, var(--psp-inactive--border-color,#eee) 10px, transparent 11px);pointer-events:none;background-repeat:no-repeat;min-width:20px;max-width:20px}regular-table:not(.flat-group-rollup-mode){& .psp-tree-label{min-width:0;max-width:0}& .psp-tree-label:before{color:var(--psp--color);font-family:var(--psp-button--font-family,inherit);padding-right:11px}& .psp-tree-label-expand:before{content:var(--psp-label--tree-expand--content,"+")}& .psp-tree-label-collapse:before{content:var(--psp-label--tree-collapse--content,"-")}& .psp-tree-label-expand,& .psp-tree-label-collapse{cursor:pointer}& .psp-tree-label:hover:before{color:var(--psp-active--color);text-shadow:0px 0px 5px var(--psp-active--color)}}.psp-tree-leaf{padding-left:24px}.psp-align-right{text-align:right}.psp-color-mode-bar,.psp-color-mode-label-bar{background-image:var(--psp-label-bar-color);background-repeat:no-repeat;background-origin:content-box;background-size:var(--psp-bar-size,0%) 80%;background-position-x:var(--psp-bar-anchor,0%);background-position-y:50%;padding:0 2px}.psp-color-mode-label-bar{isolation:isolate;position:relative}.psp-color-mode-label-bar:before{color:#0000;content:attr(data-psp-label);white-space:nowrap;height:0;padding:0 3px;display:block}.psp-color-mode-label-bar:after{color:var(--psp-label-bar-bg);content:attr(data-psp-label);mix-blend-mode:difference;justify-content:flex-end;align-items:center;padding:0 5px;display:inline-flex;position:absolute;inset:0}.psp-align-left{text-align:left}.psp-positive:not(:focus){color:var(--psp-datagrid--pos-cell--color)}.psp-negative:not(:focus){color:var(--psp-datagrid--neg-cell--color)}regular-table table tbody td{min-width:52px!important}.psp-is-width-override .rt-column-resize,.rt-column-resize:hover{border:1px dashed #999;border-width:1px 1px 0 0}.boolean-editable{cursor:pointer}regular-table table tbody td.psp-editable{user-select:text}regular-table table{user-select:none;color:inherit;border-collapse:separate;font-size:1em;& th{font-weight:400}& td,& th{border-color:var(--psp-inactive--border-color,#8b868045);height:var(--psp-datagrid--row--height,23px)}& .psp-header-group{text-overflow:ellipsis}& th.psp-header-leaf{border-bottom-width:0;& span{height:var(--psp-datagrid--row--height,23px);min-height:var(--psp-datagrid--row--height,23px)}}& td,& th.psp-tree-label,& th.psp-tree-label,& th.psp-tree-leaf,& tbody tr:first-child th{border-style:solid;border-width:1px 0 0}& tbody th:empty{background-position:0 -10px}& td.psp-select-region,& th.psp-select-region{background-color:var(--psp--color)!important;color:var(--psp--background-color)!important;border-color:var(--psp--background-color)!important}}regular-table tbody tr:hover td.psp-select-region:not(.psp-select-region-inactive),regular-table tbody tr:hover+tr td.psp-select-region:not(.psp-select-region-inactive){border-color:var(--psp--background-color)!important}regular-table tbody tr:hover{& td.psp-select-region.psp-menu-open{&:not(.psp-select-region-inactive){box-shadow:inset -2px 0px 0px var(--psp--background-color), inset 2px 0px 0px var(--psp--background-color)}}}:host-context(perspective-viewer[settings]) td.psp-select-region.psp-menu-open{box-shadow:inset -2px 0px 0px var(--psp--background-color), inset 2px 0px 0px var(--psp--background-color)}:host(.active) regular-table #psp-column-edit-buttons th:not(.rt-group-corner) span:not(.rt-column-resize):before{content:var(--psp-datagrid--column-edit-button--content,"Edit")}perspective-viewer:not([settings]),:host-context(perspective-viewer:not([settings])){& regular-table #psp-column-edit-buttons:after{content:none}}regular-table table thead tr:last-child:after{box-sizing:border-box;width:10000px;height:var(--psp-datagrid--row--height,23px);content:" ";border-bottom:1px solid var(--psp-inactive--border-color);display:block}regular-table table tbody tr:after{box-sizing:border-box;width:10000px;height:var(--psp-datagrid--row--height,23px);content:" ";border-top:1px solid #0000;display:block}regular-table table tbody tr:not(:first-child):after{border-top:1px solid var(--psp-inactive--border-color)}regular-table table tbody tr:hover:not(:first-child):after,regular-table table tbody tr:hover+tr:after{border-top:1px solid var(--psp-datagrid--hover--border-color)}@keyframes pulse_pos{0%{background-color:var(--pulse--background-color-start,#0080ff80)}to{background-color:var(--pulse--background-color-end,#0080ff00)}}@keyframes pulse_pos2{0%{background-color:var(--pulse--background-color-start,#0080ff80)}to{background-color:var(--pulse--background-color-end,#0080ff00)}}@keyframes pulse_neg{0%{background-color:var(--pulse--background-color-start,#ff190080)}to{background-color:var(--pulse--background-color-end,#ff190000)}}@keyframes pulse_neg2{0%{background-color:var(--pulse--background-color-start,#ff190080)}to{background-color:var(--pulse--background-color-end,#ff190000)}}',Io=class Ki extends HTMLElement{static _global_stylesheet_installed=!1;static _sheet;static renderTarget=window.CSS?.supports&&window.CSS?.supports("selector(:host-context(foo))")?"shadow":"light";regular_table;model;_toolbar;_edit_button;_scroll_lock;_is_scroll_lock;_edit_mode;_initialized;_reset_scroll_top;_reset_scroll_left;_reset_select;_reset_column_size;_columns_config={};_persist_column_sizes=()=>{if(!this.model||this.model._config.split_by?.length>0)return;let t=structuredClone(this._columns_config);for(let r of[...this.model._column_paths,"__ROW_PATH__"])t[r]&&delete t[r].column_size_override;let i=Oi.call(this);for(let[r,n]of Object.entries(i))n!==void 0&&(t[r]??={},t[r].column_size_override=n);this._columns_config=t,this.parentElement?.restore?.({columns_config:JSON.parse(JSON.stringify(t))},{panel:this.model._panel})};_on_column_resize=t=>{t.composedPath().some(i=>i instanceof HTMLElement&&i.classList.contains("rt-column-resize"))&&document.addEventListener("mouseup",this._persist_column_sizes,{once:!0})};constructor(){super(),this.regular_table=document.createElement("regular-table"),this.regular_table.part="regular-table",this._is_scroll_lock=!1,this._edit_mode="READ_ONLY";let t=Ki;t._sheet||(t._sheet=new CSSStyleSheet,t._sheet.replaceSync(Do)),t.renderTarget==="shadow"?this.attachShadow({mode:"open"}).adoptedStyleSheets.push(t._sheet):t.renderTarget==="light"&&!t._global_stylesheet_installed&&(t._global_stylesheet_installed=!0,document.adoptedStyleSheets.push(t._sheet))}connectedCallback(){this.regular_table.addEventListener("mousedown",this._on_column_resize),this._toolbar||(this._toolbar=document.createElement("perspective-viewer-datagrid-toolbar")),this.parentElement&&this.insertAdjacentElement("afterend",this._toolbar)}disconnectedCallback(){this.regular_table.removeEventListener("mousedown",this._on_column_resize),document.removeEventListener("mouseup",this._persist_column_sizes),this._toolbar?.parentElement?.removeChild?.(this._toolbar)}async activate(t){return await To.call(this,t)}get_static_config(){return{name:"Datagrid",category:"Basic",select_mode:"toggle",config_column_names:["Columns"],group_rollup_modes:["rollup","flat","total"],split_rollup_modes:["flat","rollup"],priority:1,can_render_column_styles:!0}}plugin_config_schema(){let t=[];return t.push({kind:"Enum",key:"edit_mode",default:"READ_ONLY",variants:[{value:"EDIT",label:"Edit"},{value:"READ_ONLY",label:"Read-only"},{value:"SELECT_ROW",label:"Row Select"},{value:"SELECT_COLUMN",label:"Column Select"},{value:"SELECT_REGION",label:"Region Select"},{value:"SELECT_ROW_TREE",label:"Tree Select"}]}),t.push({kind:"Bool",key:"scroll_lock",default:!1}),{fields:t}}column_config_schema(t,i,r,n,s,o){return Po.call(this,t,i,r,n,s,o)}async draw(t){return await Lo.call(this,t)}async update(t){if(this.model===void 0)await this.draw(t);else if(this.model._config.split_by?.length>0){let i=await t.dimensions();this.model._num_rows=i.num_view_rows,await this.regular_table.draw()}else this.model._num_rows=await t.num_rows(),await this.regular_table.draw()}async render(t,i){let r=await t.to_columns(i),n=await t.column_paths(i),s=i?.end_row!==void 0&&i?.end_row!==null&&i?.start_row!==void 0&&i?.start_row!==null?i.end_row-i.start_row:await t.num_rows(),o="";for(let l=0;l<s;l++){for(let a of n){let u=r[a],c=this.model._schema[a],d=this.regular_table[W],h=yi(a),p=Ii(c,d?.[h]||{});p?o+=p.format(u[l])+" ":o+=u[l]+" "}o+=`
`}return o.trim()}async resize(t){!this.isConnected||this.offsetParent==null||this._initialized&&await this.regular_table.draw()}async presize(t,i){if(!this.isConnected||this.offsetParent==null||!this._initialized)return;let r=this.getBoundingClientRect();return await this.regular_table.predraw(Math.max(0,this.regular_table.clientWidth+(t-r.width)),Math.max(0,this.regular_table.clientHeight+(i-r.height)))}async clear(){this.regular_table.resetAutoSize(),this.regular_table.clear()}save(){return ko.call(this)}restore(t,i){return Ro.call(this,t,i??{})}async deselect(){let t=this.model;t?._selection_state&&(t._selection_state.selected_areas=[],t._selection_state.old_selected_areas=[],t._selection_state.potential_selection=void 0,t._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},t._selection_state.dirty=!0,t._tree_selection_id=void 0,this._initialized&&await this.regular_table.draw({preserve_width:!0}))}restyle(){!this.model||!this.isConnected||Object.assign(this.model,Ni(this.regular_table))}delete(){this.disconnectedCallback(),this._toolbar=void 0,this.regular_table.table_model&&this.regular_table.resetAutoSize(),this.regular_table.clear()}},Fo=':host{height:100%;display:block;position:relative}:host #container{flex-direction:column;justify-content:stretch;align-items:stretch;display:flex;position:absolute;inset:0}:host #toolbar{align-items:stretch;height:100%;display:flex}:host #toolbar .hover-target{cursor:pointer;align-items:center;margin:0;display:inline-flex;&:hover{box-shadow:-4px 0 0 var(--psp--color), 4px 0 0 var(--psp--color);background-color:var(--psp--color)}}:host #slot-container{flex:1;position:relative}#scroll_lock.lock-scroll:before{-webkit-mask-image:var(--psp-toolbar-scroll-lock-active--content)}#scroll_lock:before{-webkit-mask-image:var(--psp-toolbar-scroll-lock--content)}#select_mode:before{content:"highlight_alt"}#edit_mode:before{-webkit-mask-image:""}#edit_mode[data-edit-mode=READ_ONLY]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-read-only--content)}#edit_mode[data-edit-mode=EDIT]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-edit--content)}:host(.aggregated) #toolbar #edit_mode[data-edit-mode=EDIT]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-read-only--content)}#edit_mode[data-edit-mode=SELECT_ROW]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-select-row--content)}#edit_mode[data-edit-mode=SELECT_COLUMN]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-select-column--content)}#edit_mode[data-edit-mode=SELECT_REGION]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-select-region--content)}#edit_mode[data-edit-mode=SELECT_ROW_TREE]:before{-webkit-mask-image:var(--psp-toolbar-edit-mode-select-row-tree--content)}#edit_mode[data-edit-mode=READ_ONLY] span:before{content:var(--psp-label--edit-mode-read-only--content,"Read Only")}#edit_mode[data-edit-mode=EDIT] span:before{content:var(--psp-label--edit-mode-edit--content,"Editable")}#edit_mode[data-edit-mode=SELECT_ROW] span:before{content:var(--psp-label--edit-mode-select-row--content,"Row Select")}#edit_mode[data-edit-mode=SELECT_COLUMN] span:before{content:var(--psp-label--edit-mode-select-column--content,"Column Select")}#edit_mode[data-edit-mode=SELECT_REGION] span:before{content:var(--psp-label--edit-mode-select-region--content,"Region Select")}#edit_mode[data-edit-mode=SELECT_ROW_TREE] span:before{content:var(--psp-label--edit-mode-select-row-tree--content,"Tree Select")}#scroll_lock span:before{content:var(--psp-label--scroll-lock-toggle--content,"Free Scroll")}#scroll_lock.lock-scroll span:before{content:var(--psp-label--scroll-lock-alt-toggle--content,"Align Scroll")}.button:before{content:"";background-color:var(--psp--color);width:21px;height:21px;-webkit-mask-size:cover;mask-size:cover}.button.editable:before,.button.lock-scroll:before{color:inherit}.button{user-select:none;box-sizing:border-box;font-size:var(--label--font-size,.75em);white-space:nowrap;border:1px solid #0000;border-radius:3px;justify-content:center;align-items:center;width:37px;height:22px;padding:0 5px;display:inline-flex}.button>span{margin:0;padding:0;display:none}.hover-target:focus-within .button,.hover-target:hover .button{background-color:var(--psp--color);color:var(--psp--background-color);opacity:1;cursor:pointer;align-items:center;display:flex;position:relative}.hover-target:focus-within .button:before,.hover-target:hover .button:before{background-color:var(--psp--background-color)}.hover-target:focus-within .button>span,.hover-target:hover .button>span{white-space:pre-wrap;background-color:var(--psp--color);text-align:center;border-radius:0 0 3px 3px;width:35px;height:auto;margin:0;padding:5px;font-size:9px;line-height:1;display:block;position:absolute;top:calc(100% + 3px);left:50%;translate:-50%}',Zi=new CSSStyleSheet;Zi.replaceSync(Fo);var Bo=class extends HTMLElement{_initialized=!1;connectedCallback(){if(this._initialized)return;this._initialized=!0;let e=this.previousElementSibling?.getAttribute("slot");this.setAttribute("slot",e?`statusbar-extra-${e}`:"statusbar-extra"),this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(Zi),this.shadowRoot.innerHTML=`
<div id="toolbar">
<span class="hover-target">
<span id="edit_mode" class="button" data-edit-mode="READ_ONLY">
<span></span>
</span>
</span>
</div>
`;let t=this.parentElement,i=this.previousElementSibling,r=i?.tagName==="PERSPECTIVE-VIEWER-DATAGRID"?i:t.getPlugin("Datagrid");r._edit_button=this.shadowRoot.querySelector("#edit_mode"),r._edit_button.dataset.editMode=r._edit_mode??"READ_ONLY",r._edit_button.addEventListener("click",()=>{bt.call(r),r.regular_table.draw()})}};async function No(){if(customElements.get("perspective-viewer-datagrid")){console.warn('Custom element "perspective-viewer-datagrid" is already registered; skipping duplicate registration (Perspective was loaded more than once on this page).');return}customElements.define("perspective-viewer-datagrid-toolbar",Bo),customElements.define("perspective-viewer-datagrid",Io),await customElements.whenDefined("perspective-viewer"),customElements.get("perspective-viewer").registerPlugin("perspective-viewer-datagrid")}No();var Te="Series Charts",Et="Cartesian Charts",Ct="Hierarchical Charts",Qi="Financial Charts",St="Map Charts",Oo=["X Axis"],Xe=["Y Axis"],V="select",j="toggle",_e=["legend_mode","legend_width_px","legend_height_px","legend_anchor","legend_x","legend_y","legend_opacity"],Me=["auto_alt_y_axis","facet_mode","series_zoom_mode","include_zero","domain_mode","line_width_px","point_size_px","band_inner_frac","bar_inner_pad",..._e],ke={facet_mode:"overlay"},At={...ke,include_zero:!0},Ji=["facet_mode","facet_zoom_mode","domain_mode","line_width_px","point_size_px",..._e],er=["facet_mode","series_zoom_mode","domain_mode","band_inner_frac","bar_inner_pad","wick_width_px","ohlc_line_width_px"],tr=[..._e],zo=["facet_zoom_mode",..._e],Pt=["facet_mode","facet_zoom_mode","domain_mode","map_tile_provider","map_tile_alpha","numeric_axes",..._e],Ho=[...Pt,"point_size_px"],Yo=[...Pt,"line_width_px"],Wo=[...Pt,"gradient_color_mode","gradient_radius_px","gradient_intensity","gradient_heat_max"],Uo=["facet_mode","facet_zoom_mode","domain_mode","gradient_color_mode","gradient_radius_px","gradient_intensity","gradient_heat_max",..._e];function B(e,t,i,r,n,s,o,l){return{name:e,tag:t,category:i,selectMode:r,initial:{count:n,names:s},max_cells:l?.max_cells??1e7,max_columns:l?.max_columns??1e4,applicable_plugin_fields:o,...l?.default_chart_type?{default_chart_type:l.default_chart_type}:{},...l?.plugin_field_defaults?{plugin_field_defaults:l.plugin_field_defaults}:{},...l?.group_by_role?{group_by_role:l.group_by_role}:{},...l?.split_by_role?{split_by_role:l.split_by_role}:{},...l?.connects_row_order?{connects_row_order:l.connects_row_order}:{}}}var ir=["Open","Close","High","Low","Tooltip"],rr=["Size","Color","Tooltip"],qe={group_by_role:"X Axis",split_by_role:"Series"},$o={group_by_role:"Y Axis",split_by_role:"Series"},Tt={},nr={group_by_role:"Hierarchy",split_by_role:"Facets"},Go={group_by_role:"X Axis",split_by_role:"Y Axis"},sr={group_by_role:"X Axis",split_by_role:"Series"},Mt={},Vo=[B("X Bar","x-bar",Te,V,1,Oo,Me,{...$o,default_chart_type:"bar",plugin_field_defaults:At}),B("Y Bar","y-bar",Te,V,1,Xe,Me,{...qe,default_chart_type:"bar",plugin_field_defaults:At}),B("Y Line","y-line",Te,V,1,Xe,Me,{...qe,default_chart_type:"line",plugin_field_defaults:ke}),B("Y Scatter","y-scatter",Te,V,1,Xe,Me,{...qe,default_chart_type:"scatter",plugin_field_defaults:ke}),B("Y Area","y-area",Te,V,1,Xe,Me,{...qe,default_chart_type:"area",plugin_field_defaults:At}),B("X/Y Scatter","scatter",Et,j,2,["X Axis","Y Axis","Color","Size","Label","Tooltip"],Ji,{...Tt}),B("X/Y Line","line",Et,V,2,["X Axis","Y Axis","Tooltip"],Ji,{...Tt,connects_row_order:!0}),B("Density","density",Et,j,2,["X Axis","Y Axis","Color","Tooltip"],Uo,{...Tt}),B("Treemap","treemap",Ct,j,1,rr,tr,{...nr}),B("Sunburst","sunburst",Ct,j,1,rr,tr,{...nr}),B("Heatmap","heatmap",Ct,V,1,["Color"],zo,{...Go}),B("Candlestick","candlestick",Qi,j,1,ir,er,{...sr,default_chart_type:"candlestick",plugin_field_defaults:ke}),B("OHLC","ohlc",Qi,j,1,ir,er,{...sr,default_chart_type:"ohlc",plugin_field_defaults:ke}),B("Map Scatter","map-scatter",St,j,2,["Longitude","Latitude","Color","Size","Label","Tooltip"],Ho,{...Mt}),B("Map Line","map-line",St,V,2,["Longitude","Latitude","Tooltip"],Yo,{...Mt,connects_row_order:!0}),B("Map Density","map-density",St,j,2,["Longitude","Latitude","Color","Tooltip"],Wo,{...Mt})],or=Vo;function dr(e){let t=e.trim();if(t.startsWith("#")){let r=t.slice(1);return r.length===3&&(r=r[0]+r[0]+r[1]+r[1]+r[2]+r[2]),[parseInt(r.slice(0,2),16)/255,parseInt(r.slice(2,4),16)/255,parseInt(r.slice(4,6),16)/255]}let i=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1]/255,+i[2]/255,+i[3]/255]:[.5,.5,.5]}function Dt(e){let t=i=>Math.round(Math.max(0,Math.min(1,i))*255).toString(16).padStart(2,"0");return`#${t(e[0])}${t(e[1])}${t(e[2])}`}var Re=[{offset:0,color:[3/255,102/255,214/255,1]},{offset:1,color:[255/255,127/255,14/255,1]}];function jo(e){if(!e)return Re.slice();let t=e.trim();if(!t)return Re.slice();let i=t.indexOf("(");if(i<0||!/^linear-gradient\s*\(/i.test(t))return Re.slice();let r=t.lastIndexOf(")");if(r<=i)return Re.slice();let n=t.substring(i+1,r),s=[],o=0,l=0;for(let d=0;d<n.length;d++){let h=n[d];h==="("?o++:h===")"?o--:h===","&&o===0&&(s.push(n.substring(l,d)),l=d+1)}s.push(n.substring(l));let a=[],u=0;if(s.length>0){let d=s[0].trim().toLowerCase();(d.startsWith("to ")||/^[-\d.]+(deg|rad|grad|turn)/.test(d))&&(u=1)}for(let d=u;d<s.length;d++){let h=s[d].trim();if(!h)continue;let p=h.match(/\s([\-\d.]+)%\s*$/),f=p?h.substring(0,p.index).trim():h,_=p?parseFloat(p[1])/100:null;try{let g=dr(f);a.push({color:g,offset:_})}catch{}}if(a.length===0)return Re.slice();if(a.length===1){let[d,h,p]=a[0].color;return[{offset:0,color:[d,h,p,1]},{offset:1,color:[d,h,p,1]}]}a[0].offset===null&&(a[0].offset=0),a[a.length-1].offset===null&&(a[a.length-1].offset=1);for(let d=1;d<a.length-1;d++){if(a[d].offset!==null)continue;let h=d+1;for(;h<a.length&&a[h].offset===null;)h++;let p=a[d-1].offset,f=a[h].offset,_=h-(d-1);for(let g=d;g<h;g++)a[g].offset=p+(g-(d-1))/_*(f-p);d=h-1}let c=0;return a.map(d=>{let h=Math.max(c,Math.min(1,d.offset));return c=h,{offset:h,color:[d.color[0],d.color[1],d.color[2],1]}})}function Xo(e){return`${Math.round(Math.max(0,Math.min(1,e))*1e3)/10}%`}function qo(e){return`linear-gradient(to right, ${[...e].sort((t,i)=>t.offset-i.offset).map(t=>`${Dt([t.color[0],t.color[1],t.color[2]])} ${Xo(t.offset)}`).join(", ")})`}function Ko(e){return`linear-gradient(to right, ${e.map(Dt).join(", ")})`}function Zo(e,t){if(e.length===0)return[0,0,0,1];if(t<=e[0].offset)return e[0].color.slice();let i=e[e.length-1];if(t>=i.offset)return i.color.slice();let r=0,n=e.length-1;for(;n-r>1;){let u=r+n>>1;e[u].offset<=t?r=u:n=u}let s=e[r],o=e[n],l=o.offset-s.offset,a=l>0?(t-s.offset)/l:0;return[s.color[0]+(o.color[0]-s.color[0])*a,s.color[1]+(o.color[1]-s.color[1])*a,s.color[2]+(o.color[2]-s.color[2])*a,s.color[3]+(o.color[3]-s.color[3])*a]}var Qo=":host{--psp-charts--tooltip--color:var(--psp--color);--psp-charts--tooltip--background:var(--psp--background-color);--psp-charts--tooltip--border-color:var(--psp-inactive--border-color);width:100%;height:100%;font-family:inherit;display:block;position:relative;overflow:hidden}.webgl-container{position:absolute;inset:6px}.webgl-canvas{width:100%;height:100%;position:absolute;top:0;left:0}.webgl-gridlines,.webgl-chrome{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.zoom-controls{z-index:2;pointer-events:auto;display:none;position:absolute;top:8px;left:50%;transform:translate(-50%)}.zoom-controls.visible{gap:6px;display:flex}.zoom-reset{background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);font:11px var(--psp-charts--font-family);cursor:pointer;opacity:.7;border-radius:4px;padding:4px 12px;transition:opacity .15s}.zoom-reset:hover{opacity:1}.webgl-tooltip{pointer-events:auto;font:11px var(--psp-charts--font-family);background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);white-space:pre;z-index:10;border-radius:3px;padding:3px;line-height:16px;position:absolute;overflow-y:auto}",Jo=[{id:"osm",label:"OpenStreetMap",template:"https://tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\xA9 OpenStreetMap contributors",tile_size:256,max_zoom:19},{id:"versatiles-satellite",label:"Satellite (VersaTiles)",template:"https://tiles.versatiles.org/tiles/satellite/{z}/{x}/{y}",attribution:"\xA9 VersaTiles (versatiles.org/sources)",tile_size:256,max_zoom:12}],el=class{constructor(e,t,i,r=256,n=19,s=[]){this.id=e,this.template=t,this.attribution=i,this.tileSize=r,this.maxZoom=n,this.subdomains=s}urlFor(e,t,i){let r=this.template.replace("{z}",String(e)).replace("{x}",String(t)).replace("{y}",String(i));if(this.subdomains.length>0){let n=(t+i)%this.subdomains.length;r=r.replace("{s}",this.subdomains[n])}return r}};function lr(e){if(typeof e!="object"||e===null)throw new TypeError("TileSourceSpec must be an object");let t=e,i=c=>{let d=t[c];if(typeof d!="string"||d.length===0)throw new TypeError(`TileSourceSpec.${c} must be a non-empty string`);return d},r=i("id"),n=i("label"),s=i("template"),o=i("attribution");for(let c of["{z}","{x}","{y}"])if(!s.includes(c))throw new TypeError(`TileSourceSpec.template must contain "${c}"`);let l=t.subdomains??[];if(!Array.isArray(l)||l.some(c=>typeof c!="string"||c.length===0))throw new TypeError("TileSourceSpec.subdomains must be an array of non-empty strings");let a=Object.freeze([...l]);if(s.includes("{s}")&&a.length===0)throw new TypeError('TileSourceSpec.template uses "{s}" but no subdomains were given');let u=(c,d)=>{let h=t[c];if(h===void 0)return d;if(typeof h!="number"||!Number.isFinite(h)||h<=0)throw new TypeError(`TileSourceSpec.${c} must be a positive number`);return h};return Object.freeze({id:r,label:n,template:s,subdomains:a,attribution:o,tile_size:u("tile_size",256),max_zoom:u("max_zoom",19)})}function tl(e){let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0).toString(16)}var il=class{_specs=new Map;constructor(e){for(let t of e){let i=lr(t);this._specs.set(i.id,i)}}register(e){let t=lr(e);return this._specs.set(t.id,t),t}list(){return[...this._specs.values()]}specFor(e){return this._specs.get(e)}sourceFor(e){let t=this._specs.get(e)??this._specs.values().next().value,i=tl(`${t.template}\0${t.subdomains.join(",")}`);return new el(`${t.id}@${i}`,t.template,t.attribution,t.tile_size,t.max_zoom,t.subdomains)}},ge=new il(Jo);var rl={facet_mode:"grid",shared_x_axis:!0,shared_y_axis:!0,coordinated_tooltip:!1,zoom_mode:"shared",facet_padding:6},nl={auto_alt_y_axis:!1,facet_mode:"grid",facet_zoom_mode:"shared",series_zoom_mode:"dynamic",include_zero:!1,domain_mode:"expand",line_width_px:2,point_size_px:8,band_inner_frac:.5,bar_inner_pad:.1,wick_width_px:1,ohlc_line_width_px:1,gradient_radius_px:32,gradient_intensity:.6,gradient_heat_max:4,gradient_color_mode:"mean",map_tile_provider:ge.list()[0].id,map_tile_alpha:1,numeric_axes:!0,legend_mode:"sidebar",legend_width_px:0,legend_height_px:160,legend_anchor:"top-right",legend_x:0,legend_y:0,legend_opacity:1},sl=class{_element=null;_emit=null;_pointerId=null;_onWheel=null;_onPointerDown=null;_onPointerMove=null;_onPointerUp=null;_onPointerLeave=null;_onClick=null;_onDblClick=null;attach(e,t){this.detach(),this._element=e,this._emit=t,this._onWheel=i=>{let r=e.getBoundingClientRect(),n=i.clientX-r.left,s=i.clientY-r.top;i.preventDefault(),t({type:"wheel",mx:n,my:s,deltaY:i.deltaY})},this._onPointerDown=i=>{if(i.button!==0)return;let r=e.getBoundingClientRect(),n=i.clientX-r.left,s=i.clientY-r.top;e.setPointerCapture(i.pointerId),this._pointerId=i.pointerId,t({type:"pointerdown",mx:n,my:s,pointerId:i.pointerId})},this._onPointerMove=i=>{let r=e.getBoundingClientRect(),n=i.clientX-r.left,s=i.clientY-r.top;t({type:"pointermove",mx:n,my:s})},this._onPointerUp=i=>{if(this._pointerId!==null){try{e.releasePointerCapture(this._pointerId)}catch{}this._pointerId=null}t({type:"pointerup"})},this._onPointerLeave=()=>{t({type:"pointerleave"})},this._onClick=i=>{let r=e.getBoundingClientRect();t({type:"click",mx:i.clientX-r.left,my:i.clientY-r.top})},this._onDblClick=i=>{let r=e.getBoundingClientRect();t({type:"dblclick",mx:i.clientX-r.left,my:i.clientY-r.top})},e.addEventListener("wheel",this._onWheel,{passive:!1}),e.addEventListener("pointerdown",this._onPointerDown),e.addEventListener("pointermove",this._onPointerMove),e.addEventListener("pointerup",this._onPointerUp),e.addEventListener("pointerleave",this._onPointerLeave),e.addEventListener("click",this._onClick),e.addEventListener("dblclick",this._onDblClick)}detach(){this._element&&(this._onWheel&&this._element.removeEventListener("wheel",this._onWheel),this._onPointerDown&&this._element.removeEventListener("pointerdown",this._onPointerDown),this._onPointerMove&&this._element.removeEventListener("pointermove",this._onPointerMove),this._onPointerUp&&this._element.removeEventListener("pointerup",this._onPointerUp),this._onPointerLeave&&this._element.removeEventListener("pointerleave",this._onPointerLeave),this._onClick&&this._element.removeEventListener("click",this._onClick),this._onDblClick&&this._element.removeEventListener("dblclick",this._onDblClick)),this._element=null,this._emit=null,this._pointerId=null,this._onPointerLeave=null,this._onClick=null,this._onDblClick=null}},ol=["--psp-charts--font-family","font-family","--psp--background-color","--psp-charts--axis-ticks--color","--psp--color","--psp-charts--axis-lines--color","--psp-charts--gridline--color","--psp-charts--gradient--background","--psp-charts--full-gradient--background","--psp-charts--legend--color","--psp-charts--legend-border--color","--psp-charts--tooltip--background","--psp-charts--tooltip--color","--psp-charts--tooltip--border-color","--psp-charts--area--opacity","--psp-charts--heatmap-gap--px","--psp-charts--sunburst-gap--px"];function kt(e){let t=getComputedStyle(e),i={};for(let r of ol){let n=t.getPropertyValue(r).trim();n&&(i[r]=n)}for(let r=1;;r++){let n=`--psp-charts--series-${r}--color`,s=t.getPropertyValue(n).trim();if(!s)break;i[n]=s}return i}function ll(){let e=[];for(let t of Array.from(document.styleSheets)){let i;try{i=t.cssRules}catch{continue}let r=t.href??document.baseURI;for(let n of Array.from(i)){if(!(n instanceof CSSFontFaceRule))continue;let s=n.style,o=s.getPropertyValue("font-family").trim(),l=s.getPropertyValue("src").trim();!o||!l||e.push({family:al(o),src:cl(l,r),style:ie(s,"font-style"),weight:ie(s,"font-weight"),stretch:ie(s,"font-stretch"),unicodeRange:ie(s,"unicode-range"),variant:ie(s,"font-variant"),featureSettings:ie(s,"font-feature-settings"),display:ie(s,"font-display")})}}return e}function ie(e,t){return e.getPropertyValue(t).trim()||void 0}function al(e){if(e.length>=2){let t=e.charCodeAt(0),i=e.charCodeAt(e.length-1);if(t===i&&(t===34||t===39))return e.slice(1,-1)}return e}function cl(e,t){return e.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/g,(i,r,n)=>{try{return`url(${new URL(n,t).href})`}catch{return i}})}var ul=class{_glCanvas;_parent;_div=null;constructor(e,t){this._glCanvas=e,this._parent=t}pin(e,t,i){this.dismiss();let r=document.createElement("div");r.className="webgl-tooltip",r.style.maxHeight=`${Math.round(i.cssHeight*.6)}px`,r.textContent=e.join(`
`),getComputedStyle(this._parent).position==="static"&&(this._parent.style.position="relative"),r.style.left="-9999px",r.style.top="0px",this._parent.appendChild(r),this._div=r;let n=r.getBoundingClientRect().width,s=r.getBoundingClientRect().height,o=t.px+12,l=t.py-s-8;o+n>i.cssWidth&&(o=t.px-n-12),o<0&&(o=4),l<0&&(l=t.py+12),l+s>i.cssHeight&&(l=i.cssHeight-s-4),r.style.left=`${o}px`,r.style.top=`${l}px`}dismiss(){this._div&&(this._div.remove(),this._div=null)}setCursor(e){this._glCanvas.style.cursor=e}},re="worker",dl="blit",hl='var ws=Object.defineProperty;var Bu=(e,t,n)=>t in e?ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var Eu=(e,t)=>{for(var n in t)ws(e,n,{get:t[n],enumerable:!0})};var d=(e,t,n)=>Bu(e,typeof t!="symbol"?t+"":t,n);var Yn,Kr=G(()=>{Yn="attribute vec2 a_start;attribute vec2 a_end;attribute float a_color_start;attribute float a_color_end;attribute float a_corner;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform vec2 u_color_range;uniform sampler2D u_gradient_lut;varying float v_edge_dist;varying vec3 v_color;float A(float B,float C,float D){if(D<=C){return 0.5;}else if(C<0.&&D>0.){float E=max(-C,D);return clamp(0.5+0.5*(B/E),0.,1.);}return clamp((B-C)/(D-C),0.,1.);}void main(){float C=u_color_range.x;float D=u_color_range.y;float F=0.5*(a_color_start+a_color_end);float G=A(F,C,D);v_color=texture2D(u_gradient_lut,vec2(G,0.5)).rgb;vec4 H=u_projection*vec4(a_start,0.,1.);vec4 I=u_projection*vec4(a_end,0.,1.);vec2 J=H.xy*u_resolution*0.5;vec2 K=I.xy*u_resolution*0.5;vec2 L=K-J;float M=length(L);L=M>0.001?L/M:vec2(1.,0.);vec2 N=vec2(-L.y,L.x);float O=step(1.5,a_corner);float P=1.-mod(a_corner,2.)*2.;vec4 Q=mix(H,I,O);float R=(u_line_width+1.5)*0.5;vec2 S=(N*P*R)/(u_resolution*0.5);gl_Position=Q+vec4(S,0.,0.);v_edge_dist=P;}"});var zn,Jr=G(()=>{zn="precision highp float;uniform float u_line_width;varying float v_edge_dist;varying vec3 v_color;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(v_color,C);}"});var Xn,Qr=G(()=>{Xn="attribute vec2 a_position;attribute float a_color_value;attribute float a_size_value;uniform mat4 u_projection;uniform float u_point_size;uniform vec2 u_color_range;uniform vec2 u_size_range;uniform vec2 u_point_size_range;varying float v_color_t;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);float A=u_size_range.y-u_size_range.x;if(A>0.){float B=clamp((a_size_value-u_size_range.x)/A,0.,1.);gl_PointSize=mix(u_point_size_range.x,u_point_size_range.y,B);}else{gl_PointSize=u_point_size;}v_point_size=gl_PointSize;float C=u_color_range.x;float D=u_color_range.y;if(D<=C){v_color_t=0.5;}else if(C<0.&&D>0.){float E=max(-C,D);v_color_t=clamp(0.5+0.5*(a_color_value/E),0.,1.);}else{v_color_t=clamp((a_color_value-C)/(D-C),0.,1.);}}"});var $n,eo=G(()=>{$n="precision highp float;varying float v_color_t;varying float v_point_size;uniform sampler2D u_gradient_lut;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5){discard;}float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);vec4 E=texture2D(u_gradient_lut,vec2(clamp(v_color_t,0.,1.),0.5));gl_FragColor=vec4(E.rgb,E.a*D);}"});var Ft,to=G(()=>{Ft="attribute vec2 a_corner;attribute vec2 a_position;attribute float a_color_value;uniform vec2 u_radius_ndc;uniform mat4 u_projection;uniform vec2 u_color_range;varying vec2 v_uv;varying float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}"});var si,no=G(()=>{si="precision highp float;uniform float u_intensity;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);float B=max(0.,1.-A);B=B*B*u_intensity;if(B<=0.){discard;}gl_FragColor=vec4(B,B*v_color_t,0.,0.);}"});var li,io=G(()=>{li="precision highp float;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);if(A>=1.){discard;}float B=(v_color_t-0.5)*2.;gl_FragColor=vec4(max(0.,B),max(0.,-B),0.,0.);}"});var Rs,Ms=G(()=>{Rs=`#version 300 es\nin vec2 a_corner;in vec2 a_position;in float a_color_value;uniform mat4 u_projection;uniform vec2 u_radius_ndc;uniform vec2 u_color_range;out vec2 v_uv;out float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}`});var Fs,Ss=G(()=>{Fs=`#version 300 es\nprecision highp float;uniform float u_intensity;in vec2 v_uv;in float v_color_t;layout(location=0)out vec4 A;layout(location=1)out vec4 B;void main(){float C=length(v_uv);float D=max(0.0f,1.0f-C);D=D*D*u_intensity;if(D<=0.0f){discard;}A=vec4(D,D*v_color_t,0.0f,0.0f);float E=(v_color_t-0.5f)*2.0f;B=vec4(max(0.0f,E),max(0.0f,-E),0.0f,0.0f);}`});var ai,ro=G(()=>{ai="attribute vec2 a_corner;varying vec2 v_uv;void main(){v_uv=a_corner*0.5+0.5;gl_Position=vec4(a_corner,0.,1.);}"});var ui,oo=G(()=>{ui="precision highp float;uniform sampler2D u_heat;uniform sampler2D u_extreme;uniform sampler2D u_gradient_lut;uniform float u_heat_max;uniform int u_color_mode;varying vec2 v_uv;void main(){vec4 A=texture2D(u_heat,v_uv);float B=A.r;float C=A.g;if(B<=0.){discard;}float D;float E;float F=clamp(B/max(u_heat_max,1e-4),0.,1.);if(u_color_mode==0){D=pow(F,0.6);E=clamp(B,0.,1.);}else if(u_color_mode==2){vec4 G=texture2D(u_extreme,v_uv);float H=G.r;float I=G.g;float J=max(H,I);if(J<=0.){D=0.5;}else if(H>=I){D=clamp(0.5+H*0.5,0.5,1.);}else{D=clamp(0.5-I*0.5,0.,0.5);}E=F;}else if(u_color_mode==3){float K=C-0.5*B;float L=clamp(abs(K)/max(u_heat_max,1e-4),0.,1.);float M=K>=0.?1.:-1.;D=clamp(0.5+0.5*M*L,0.,1.);E=L;}else{D=clamp(C/B,0.,1.);E=F;}vec4 N=texture2D(u_gradient_lut,vec2(D,0.5));gl_FragColor=vec4(N.rgb,N.a*E);}"});var mi,so=G(()=>{mi="attribute vec2 a_corner;uniform mat4 u_projection;uniform vec2 u_extent_min;uniform vec2 u_extent_max;uniform vec2 u_uv_min;uniform vec2 u_uv_max;varying vec2 v_uv;void main(){vec2 A=mix(u_extent_min,u_extent_max,a_corner);vec2 B=mix(u_uv_min,u_uv_max,vec2(a_corner.x,1.-a_corner.y));v_uv=B;gl_Position=u_projection*vec4(A,0.,1.);}"});var fi,lo=G(()=>{fi="precision highp float;varying vec2 v_uv;uniform sampler2D u_tile;uniform float u_alpha;void main(){vec4 A=texture2D(u_tile,v_uv);gl_FragColor=vec4(A.rgb,A.a*u_alpha);}"});function cm(e,t){if(t.width<=0||t.height<=0)return e;let n=e.xMax-e.xMin,i=e.yMax-e.yMin;if(n<=0||i<=0)return e;let r=t.width/t.height;if(n/i<r){let s=(e.xMin+e.xMax)/2,l=i*r/2;return{xMin:s-l,xMax:s+l,yMin:e.yMin,yMax:e.yMax}}else{let s=(e.yMin+e.yMax)/2,l=n/r/2;return{xMin:e.xMin,xMax:e.xMax,yMin:s-l,yMax:s+l}}}var It,di=G(()=>{"use strict";It=class{constructor(){d(this,"be",1);d(this,"ge",1);d(this,"Ee",0);d(this,"Pe",0);d(this,"St",0);d(this,"Ft",1);d(this,"It",0);d(this,"Dt",1);d(this,"Ke",null);d(this,"Pr",!1);d(this,"$i",!1);d(this,"ji",!1);d(this,"Bt",null);d(this,"Et",null);d(this,"si",null);d(this,"Zi",!1);d(this,"qi",0);d(this,"Ki",0);d(this,"Qt",null);d(this,"en",null);d(this,"tn",null);d(this,"nn",null)}get lockedAxis(){return this.Ke}get scaleX(){return this.be}get scaleY(){return this.ge}set scaleX(t){this.be=t}set scaleY(t){this.ge=t}get normTranslateX(){return this.Ee}get normTranslateY(){return this.Pe}set normTranslateX(t){this.Ee=t}set normTranslateY(t){this.Pe=t}get baseXRange(){return this.Ft-this.St}get baseYRange(){return this.Dt-this.It}setBaseDomain(t,n,i,r){let o=n-t;if(this.isXDefault()||!this.$i)this.St=t,this.Ft=n;else{let l=this.Ft-this.St,a=(this.St+this.Ft)/2+this.Ee*l;this.St=t,this.Ft=n,this.Ee=o>0?(a-(t+n)/2)/o:0}let s=r-i;if(this.isYDefault()||!this.ji)this.It=i,this.Dt=r;else{let l=this.Dt-this.It,a=(this.It+this.Dt)/2+this.Pe*l;this.It=i,this.Dt=r,this.Pe=s>0?(a-(i+r)/2)/s:0}}pinAxis(t){t==="x"?this.$i=!0:this.ji=!0}unpinAxis(t){t==="x"?this.$i=!1:this.ji=!1}configure(t){this.Ke=t.lockAxis??null,this.Pr=t.lockAspect??!1,this.Ke==="x"?(this.be=1,this.Ee=0):this.Ke==="y"&&(this.ge=1,this.Pe=0)}isXDefault(){return this.be===1&&this.Ee===0}isYDefault(){return this.ge===1&&this.Pe===0}isDefault(){return this.isXDefault()&&this.isYDefault()}getVisibleDomain(){let t=this.Ft-this.St,n=this.Dt-this.It,i=t/this.be,r=n/this.ge,o=(this.St+this.Ft)/2+this.Ee*t,s=(this.It+this.Dt)/2+this.Pe*n,l={xMin:o-i/2,xMax:o+i/2,yMin:s-r/2,yMax:s+r/2};return this.Pr&&this.Et?cm(l,this.Et.e):l}attach(t,n,i){this.detach(),this.Bt=t,this.Et=n,this.si=i,this.Qt=r=>{r.preventDefault();let o=t.getBoundingClientRect(),s=r.clientX-o.left,l=r.clientY-o.top,a=this.Et.e;if(s<a.x||s>a.x+a.width||l<a.y||l>a.y+a.height)return;let u=(s-a.x)/a.width,m=(l-a.y)/a.height,f=this.be,c=this.ge,p=Math.pow(1.1,-r.deltaY/100);this.Ke!=="x"&&(this.be=Math.max(1,Math.min(1e5,this.be*p))),this.Ke!=="y"&&(this.ge=Math.max(1,Math.min(1e5,this.ge*p))),this.Ke!=="x"&&f!==this.be&&(this.Ee+=(u-.5)*(1/f-1/this.be)),this.Ke!=="y"&&c!==this.ge&&(this.Pe+=(.5-m)*(1/c-1/this.ge)),this.si()},this.en=r=>{if(r.button!==0)return;let o=t.getBoundingClientRect(),s=r.clientX-o.left,l=r.clientY-o.top,a=this.Et.e;s>=a.x&&s<=a.x+a.width&&l>=a.y&&l<=a.y+a.height&&(this.Zi=!0,this.qi=r.clientX,this.Ki=r.clientY,t.setPointerCapture(r.pointerId))},this.tn=r=>{if(!this.Zi)return;let o=r.clientX-this.qi,s=r.clientY-this.Ki;this.qi=r.clientX,this.Ki=r.clientY;let l=this.Et.e;this.Ke!=="x"&&l.width>0&&(this.Ee-=o/(l.width*this.be)),this.Ke!=="y"&&l.height>0&&(this.Pe+=s/(l.height*this.ge)),this.si()},this.nn=()=>{this.Zi=!1},t.addEventListener("wheel",this.Qt,{passive:!1}),t.addEventListener("pointerdown",this.en),t.addEventListener("pointermove",this.tn),t.addEventListener("pointerup",this.nn)}updateLayout(t){this.Et=t}detach(){this.Bt&&(this.Qt&&this.Bt.removeEventListener("wheel",this.Qt),this.en&&this.Bt.removeEventListener("pointerdown",this.en),this.tn&&this.Bt.removeEventListener("pointermove",this.tn),this.nn&&this.Bt.removeEventListener("pointerup",this.nn)),this.Bt=null,this.si=null}reset(){this.be=1,this.ge=1,this.Ee=0,this.Pe=0}serialize(){return{scaleX:this.be,scaleY:this.ge,normTranslateX:this.Ee,normTranslateY:this.Pe}}restore(t){this.be=t.scaleX,this.ge=t.scaleY,this.Ee=t.normTranslateX,this.Pe=t.normTranslateY}}});function Gs(e){return e&&!("format"in e)?e:void 0}function uo(e,t){let n=t??dm[e]??{};return new Intl.NumberFormat(navigator.languages,n)}function mo(e){if(!e||!("format"in e)){let n=Gs(e),i={timeZone:n?.timeZone??void 0,dateStyle:n?.dateStyle==="disabled"?void 0:n?.dateStyle??Ps.dateStyle,timeStyle:n?.timeStyle==="disabled"?void 0:n?.timeStyle??Ps.timeStyle};return new Intl.DateTimeFormat(navigator.languages,i)}let t={timeZone:e.timeZone??void 0,hour12:e.hour12??!0,fractionalSecondDigits:e.fractionalSecondDigits};return e.year!=="disabled"&&(t.year=e.year??"2-digit"),e.month!=="disabled"&&(t.month=e.month??"numeric"),e.day!=="disabled"&&(t.day=e.day??"numeric"),e.weekday&&e.weekday!=="disabled"&&(t.weekday=e.weekday),e.hour!=="disabled"&&(t.hour=e.hour??"numeric"),e.minute!=="disabled"&&(t.minute=e.minute??"numeric"),e.second!=="disabled"&&(t.second=e.second??"numeric"),new Intl.DateTimeFormat(navigator.languages,t)}function Ws(e){let t=Gs(e),n={timeZone:"utc",dateStyle:t?.dateStyle==="disabled"?void 0:t?.dateStyle??pm.dateStyle};return new Intl.DateTimeFormat(navigator.languages,n)}function fo(e){return e.split("|").at(-1)??e}var dm,Ps,pm,ks=G(()=>{"use strict";dm={float:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},Ps={dateStyle:"short",timeStyle:"medium"},pm={dateStyle:"short"}});var bi,Ns=G(()=>{"use strict";bi=class{constructor(t,n=128){d(this,"on");d(this,"g",new Map);d(this,"Te",new Map);d(this,"Gr");this.on=t,this.Gr=n}async fetchRow(t){if(!this.on)throw new Error("LazyRowFetcher disposed");let n=this.g.get(t);if(n)return this.g.delete(t),this.g.set(t,n),n;let i=this.Te.get(t);if(i)return i;let r=this.Lo(t);this.Te.set(t,r);try{let o=await r;if(!this.on)return o;if(this.g.set(t,o),this.g.size>this.Gr){let s=this.g.keys().next().value;s!==void 0&&this.g.delete(s)}return o}finally{this.Te.delete(t)}}async Lo(t){let n=this.on;if(!n)throw new Error("LazyRowFetcher disposed");let i=new Map;return await n.with_typed_arrays({start_row:t,end_row:t+1,float32:!0},(r,o,s,l)=>{for(let a=0;a<r.length;a++){let u=r[a];if(u.startsWith("__"))continue;let m=o[a],f=s[a],c=l[a];(f?!(f[0]>>0&1):!1)?i.set(u,null):c?i.set(u,c[m[0]]):i.set(u,m[0])}}),i}dispose(){this.on=null,this.g.clear(),this.Te.clear()}get isDisposed(){return this.on===null}}});function Os(e,t){let n=Math.floor(Math.log10(e)),i=e/Math.pow(10,n),r;return t?i<1.5?r=1:i<3?r=2:i<7?r=5:r=10:i<=1?r=1:i<=2?r=2:i<=5?r=5:r=10,r*Math.pow(10,n)}function ne(e,t,n){n<1&&(n=1);let i=Os(t-e,!1),r=Os(i/n,!0),o=Math.ceil(e/r)*r,s=Math.floor(t/r)*r,l=[];for(let a=o;a<=s+r*.001;a+=r)l.push(a);return l}function me(e){if(!Number.isFinite(e))return"-";let t=Math.abs(e);return t===0?"0":t>=1e9?(e/1e9).toFixed(1)+"B":t>=1e6?(e/1e6).toFixed(1)+"M":t>=1e3?(e/1e3).toFixed(1)+"K":Number.isInteger(e)?e.toString():t>=1?e.toFixed(1):e.toFixed(2)}function Dt(e,t){let n=Us.get(e);return n||(n=new Intl.DateTimeFormat(void 0,t),Us.set(e,n)),n}function ve(e,t){let n=new Date(e);return isNaN(n.getTime())?me(e):t!==void 0&&t>0?t>=864e5*28?Dt("ym",{year:"numeric",month:"short"}).format(n):t>=864e5?Dt("md",{month:"short",day:"numeric"}).format(n):t>=36e5?Dt("mdh",{month:"short",day:"numeric",hour:"numeric"}).format(n):t>=6e4?Dt("hm",{hour:"numeric",minute:"2-digit"}).format(n):Dt("hms",{hour:"numeric",minute:"2-digit",second:"2-digit"}).format(n):Dt("ymd",{year:"numeric",month:"short",day:"numeric"}).format(n)}var Us,Ae=G(()=>{"use strict";Us=new Map});var Vs,Hs=G(()=>{Vs=[{id:"osm",label:"OpenStreetMap",template:"https://tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"\\xA9 OpenStreetMap contributors",tile_size:256,max_zoom:19},{id:"versatiles-satellite",label:"Satellite (VersaTiles)",template:"https://tiles.versatiles.org/tiles/satellite/{z}/{x}/{y}",attribution:"\\xA9 VersaTiles (versatiles.org/sources)",tile_size:256,max_zoom:12}]});function Ys(e){if(typeof e!="object"||e===null)throw new TypeError("TileSourceSpec must be an object");let t=e,n=m=>{let f=t[m];if(typeof f!="string"||f.length===0)throw new TypeError(`TileSourceSpec.${m} must be a non-empty string`);return f},i=n("id"),r=n("label"),o=n("template"),s=n("attribution");for(let m of["{z}","{x}","{y}"])if(!o.includes(m))throw new TypeError(`TileSourceSpec.template must contain "${m}"`);let l=t.subdomains??[];if(!Array.isArray(l)||l.some(m=>typeof m!="string"||m.length===0))throw new TypeError("TileSourceSpec.subdomains must be an array of non-empty strings");let a=Object.freeze([...l]);if(o.includes("{s}")&&a.length===0)throw new TypeError(\'TileSourceSpec.template uses "{s}" but no subdomains were given\');let u=(m,f)=>{let c=t[m];if(c===void 0)return f;if(typeof c!="number"||!Number.isFinite(c)||c<=0)throw new TypeError(`TileSourceSpec.${m} must be a positive number`);return c};return Object.freeze({id:i,label:r,template:o,subdomains:a,attribution:s,tile_size:u("tile_size",256),max_zoom:u("max_zoom",19)})}function gm(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}var co,po,je,gi=G(()=>{"use strict";Hs();co=class{constructor(t,n,i,r=256,o=19,s=[]){this.id=t;this.template=n;this.attribution=i;this.tileSize=r;this.maxZoom=o;this.subdomains=s}urlFor(t,n,i){let r=this.template.replace("{z}",String(t)).replace("{x}",String(n)).replace("{y}",String(i));if(this.subdomains.length>0){let o=(n+i)%this.subdomains.length;r=r.replace("{s}",this.subdomains[o])}return r}};po=class{constructor(t){d(this,"sn",new Map);for(let n of t){let i=Ys(n);this.sn.set(i.id,i)}}register(t){let n=Ys(t);return this.sn.set(n.id,n),n}list(){return[...this.sn.values()]}specFor(t){return this.sn.get(t)}sourceFor(t){let n=this.sn.get(t)??this.sn.values().next().value,i=gm(`${n.template}\\0${n.subdomains.join(",")}`);return new co(`${n.id}@${i}`,n.template,n.attribution,n.tile_size,n.max_zoom,n.subdomains)}},je=new po(Vs)});var zs,mt,bo=G(()=>{"use strict";gi();zs={facet_mode:"grid",shared_x_axis:!0,shared_y_axis:!0,coordinated_tooltip:!1,zoom_mode:"shared",facet_padding:6},mt={auto_alt_y_axis:!1,facet_mode:"grid",facet_zoom_mode:"shared",series_zoom_mode:"dynamic",include_zero:!1,domain_mode:"expand",line_width_px:2,point_size_px:8,band_inner_frac:.5,bar_inner_pad:.1,wick_width_px:1,ohlc_line_width_px:1,gradient_radius_px:32,gradient_intensity:.6,gradient_heat_max:4,gradient_color_mode:"mean",map_tile_provider:je.list()[0].id,map_tile_alpha:1,numeric_axes:!0,legend_mode:"sidebar",legend_width_px:0,legend_height_px:160,legend_anchor:"top-right",legend_x:0,legend_y:0,legend_opacity:1}});function ke(e,t,n,i,r,o,s={}){if(!e)return;let l=e.getContext("2d");if(!l)return;l.save(),l.setTransform(1,0,0,1,0,0),l.scale(o,o),l.font=`11px ${r.fontFamily}`;let a=16,u=8,m=0;for(let x of n){let h=l.measureText(x).width;h>m&&(m=h)}let f=m+u*2,c=n.length*a+u*2-4,p=t.px+12,b=t.py-c-8;p+f>i.cssWidth&&(p=t.px-f-12),b<0&&(b=t.py+12),b+c>i.cssHeight&&(b=i.cssHeight-c-4);let g=n.length>0;if(s.crosshair&&(l.strokeStyle=r.Pt,l.globalAlpha=.3,l.lineWidth=1,l.setLineDash([4,4]),l.beginPath(),l.moveTo(t.px,i.e.y),l.lineTo(t.px,i.e.y+i.e.height),l.moveTo(i.e.x,t.py),l.lineTo(i.e.x+i.e.width,t.py),l.stroke(),l.setLineDash([]),l.globalAlpha=1),s.highlightRadius&&s.highlightRadius>0&&(l.strokeStyle=r.Pt,l.globalAlpha=.8,l.lineWidth=2,l.beginPath(),l.arc(t.px,t.py,s.highlightRadius,0,Math.PI*2),l.stroke(),l.globalAlpha=1),g){l.fillStyle=r.li,l.strokeStyle=r.Wr,l.lineWidth=1,l.beginPath(),l.roundRect(p,b,f,c,4),l.fill(),l.stroke(),l.fillStyle=r.kr,l.textAlign="left",l.textBaseline="top";for(let x=0;x<n.length;x++)l.fillText(n[x],p+u,b+u+x*a)}l.restore()}var hi,Bt=G(()=>{"use strict";hi=class{constructor(){d(this,"Ve",null);d(this,"ln",0);d(this,"an",null);d(this,"Ln",null);d(this,"yt",!1)}get isPinned(){return this.yt}setHost(t){this.yt&&(this.Ln?.dismiss(),this.yt=!1),this.Ln=t}setCursor(t){this.Ln?.setCursor(t)}attach(t){this.detach(),this.Ve=t}detach(){this.ln&&(cancelAnimationFrame(this.ln),this.ln=0),this.an!==null&&(clearTimeout(this.an),this.an=null),this.Ve=null}dispatchHover(t,n){if(this.yt||!this.Ve||this.ln||this.an!==null)return;let i=()=>{this.ln=0,this.an=null,this.Ve?.onHover(t,n)};typeof requestAnimationFrame=="function"?this.ln=requestAnimationFrame(i):this.an=setTimeout(i,16)}dispatchLeave(){this.yt||!this.Ve||this.Ve.onLeave()}dispatchClick(t,n){if(this.Ve&&!this.Ve.onClickPre?.(t,n)){if(this.yt){let i=this.Ve;this.dismiss(),i.onUnpin?.();return}this.Ve.onPin?.(t,n)}}dispatchDblClick(t,n){this.Ve?.onDblClick?.(t,n)}pin(t,n,i){t.length!==0&&(this.Ln?.pin(t,n,i),this.yt=!0)}dismiss(){this.Ln?.dismiss(),this.yt=!1}}});function he(e,t,n){return Math.min(n,Math.max(t,e))}function go(e){return Number.isFinite(e)?he(e,0,1):0}function $s(e,t){return t>0?go(e/t):0}function js(e){return e==="top-right"||e==="bottom-right"}function Zs(e){return e==="bottom-left"||e==="bottom-right"}function Le(e,t){return e.legend_width_px>0?he(e.legend_width_px,ct,yi):t}function Ze(e,t,n=80){return!t||e.legend_mode!=="sidebar"?16:Le(e,n)}function _i(e,t,n){return!t||e.legend_mode!=="sidebar"?0:Le(e,n)}function Et(e){return Math.round(e*1e4)/1e4}var ct,yi,xi,hm,xm,dt,ft,Xs,ym,Cm,_m,Ci,Ne=G(()=>{"use strict";bo();ct=48,yi=512,xi=48,hm=160,xm=160,dt=18,ft=5,Xs=12,ym=10,Cm=3;_m=["legend_mode","legend_width_px","legend_height_px","legend_anchor","legend_x","legend_y","legend_opacity"],Ci=class e{constructor(){d(this,"we",null);d(this,"Gt",0);d(this,"Ye",null);d(this,"un",!1);d(this,"Ji",!1);d(this,"Nr","")}clampScroll(t,n){return this.Gt=he(this.Gt,0,Math.max(0,n-t)),this.Gt}setPainted(t){this.we=t}clearPainted(){this.we=null}floatingBox(t,n,i){let r=he(t.legend_width_px>0?t.legend_width_px:hm,ct,Math.max(ct,Math.floor(n/2))),o=he(t.legend_height_px>0?t.legend_height_px:xm,xi,Math.max(xi,i-8)),s=Math.max(0,n-r),l=Math.max(0,i-o),a=go(t.legend_x)*s,u=go(t.legend_y)*l;return{x:js(t.legend_anchor)?s-a:a,y:Zs(t.legend_anchor)?l-u:u,width:r,height:o}}reconcileConfig(t,n){if(this.Ye){for(let i of _m)if(t[i]!==n[i]){this.Ye=null;return}}}cancelGesture(){this.Ye=null,this.un=!1}handleEvent(t,n){switch(t.type){case"wheel":return this.Qt(t.mx,t.my,t.deltaY,n);case"pointerdown":return this.en(t.mx,t.my,n);case"pointermove":return this.tn(t.mx,t.my,n);case"pointerup":return this.nn(n);case"click":return this.To(t.mx,t.my,n);case"dblclick":return this.wo(t.mx,t.my,n);case"pointerleave":return this.Ji=!1,this.ai("",n),!1}}hitTest(t,n){let i=this.we;if(!i)return"none";let r=i.box;if(i.mode==="floating"){let s=t>=r.x-ft&&t<=r.x+r.width+ft,l=n>=r.y-ft&&n<=r.y+r.height+ft;if(!s||!l)return"none";let a=Math.abs(t-r.x)<=ft,u=Math.abs(t-(r.x+r.width))<=ft,m=Math.abs(n-(r.y+r.height))<=ft;return u&&n>=r.y+r.height-Xs||m&&t>=r.x+r.width-Xs?"resize-se":u?"resize-e":a?"resize-w":m?"resize-s":this.Or(t,n)?"scrollbar":n<=r.y+dt?"move":"body"}let o=n>=r.y&&n<=r.y+r.height;return o&&t>=r.x-14&&t<=r.x+2?"resize-w":o&&t>=r.x&&t<=r.x+r.width?this.Or(t,n)?"scrollbar":"body":"none"}Ur(){let t=this.we;return!!t&&t.contentHeight>t.content.height+.5}Or(t,n){let i=this.we;if(!i||!this.Ur())return!1;let r=i.content;return t>=r.x+r.width-ym&&t<=r.x+r.width&&n>=r.y&&n<=r.y+r.height}Qt(t,n,i,r){return this.Ye?!0:this.hitTest(t,n)==="none"?!1:(this.Ur()&&this.Hr(this.Gt+i,r),!0)}en(t,n,i){let r=this.hitTest(t,n);if(r==="none")return!1;let o=this.we;if(this.un=!1,r==="scrollbar")return this.Ye={kind:"scrollbar",startMy:n,startScroll:this.Gt},!0;let s={legend_width_px:i.cfg.legend_width_px,legend_height_px:i.cfg.legend_height_px,legend_x:i.cfg.legend_x,legend_y:i.cfg.legend_y};return r==="resize-w"||r==="resize-e"||r==="resize-s"||r==="resize-se"?(this.Ye={kind:r,startMx:t,startMy:n,startBox:{...o.box},startGutter:o.sidebarGutter??o.box.width,snapshot:s},this.ai(r==="resize-s"?"ns-resize":r==="resize-se"?"nwse-resize":"ew-resize",i),!0):(o.mode==="floating"&&(this.Ye={kind:"move",startMx:t,startMy:n,startBox:{...o.box},moved:!1,snapshot:s}),!0)}tn(t,n,i){if(this.Ye)return this.Mo(t,n,i),!0;let r=this.hitTest(t,n),o=r!=="none";return o&&!this.Ji&&i.dispatchLeave(),this.Ji=o,this.ai(e.Ro(r),i),o&&this.we.mode==="floating"}nn(t){let n=this.Ye;if(!n)return!1;if(this.Ye=null,n.kind==="scrollbar")return this.un=!0,!0;if(n.kind==="move"&&!n.moved)return!0;this.un=!0;let i={},r=t.cfg;return r.legend_width_px!==n.snapshot.legend_width_px&&(i.legend_width_px=Math.round(r.legend_width_px)),r.legend_height_px!==n.snapshot.legend_height_px&&(i.legend_height_px=Math.round(r.legend_height_px)),Et(r.legend_x)!==Et(n.snapshot.legend_x)&&(i.legend_x=Et(r.legend_x)),Et(r.legend_y)!==Et(n.snapshot.legend_y)&&(i.legend_y=Et(r.legend_y)),Object.keys(i).length>0&&t.postDelta(i),!0}wo(t,n,i){let r=this.hitTest(t,n);if(r==="none")return!1;let o=r==="resize-w"||r==="resize-e"||r==="resize-se",s=r==="resize-s"||r==="resize-se";if(!o&&!s)return this.we.mode==="floating";let l=i.cfg,a={};return o&&l.legend_width_px!==mt.legend_width_px&&(l.legend_width_px=mt.legend_width_px,a.legend_width_px=l.legend_width_px),s&&l.legend_height_px!==mt.legend_height_px&&(l.legend_height_px=mt.legend_height_px,a.legend_height_px=l.legend_height_px),Object.keys(a).length>0&&(i.repaint(this.we.mode==="sidebar"),i.postDelta(a)),!0}To(t,n,i){if(this.un)return this.un=!1,!0;let r=this.hitTest(t,n);if(r==="none")return!1;if(r==="scrollbar")return!0;if(this.we.mode==="floating"){for(let o of i.legendRects){let s=o.rect;if(t>=s.x&&t<=s.x+s.width&&n>=s.y&&n<=s.y+s.height)return!1}return!0}return!1}Mo(t,n,i){let r=this.Ye,o=i.cfg,{cssWidth:s,cssHeight:l}=i,a=Math.max(ct,Math.floor(s/2));switch(r.kind){case"scrollbar":{let u=this.we;if(!u||u.content.height<=0)return;let m=u.contentHeight/u.content.height;this.Hr(r.startScroll+(n-r.startMy)*m,i);return}case"move":{if(!r.moved){if(Math.hypot(t-r.startMx,n-r.startMy)<Cm)return;r.moved=!0,this.ai("grabbing",i)}let u=r.startBox.width,m=r.startBox.height,f=he(r.startBox.x+(t-r.startMx),0,Math.max(0,s-u)),c=he(r.startBox.y+(n-r.startMy),0,Math.max(0,l-m));this.ui(i,f,c,u,m),i.repaint(!1);return}case"resize-w":{if(this.we?.mode==="sidebar"){o.legend_width_px=he(Math.round(r.startGutter+(r.startMx-t)),ct,Math.min(yi,a)),i.repaint(!0);return}let u=r.startBox.x+r.startBox.width,m=he(Math.round(r.startBox.width+(r.startMx-t)),ct,Math.min(yi,a));o.legend_width_px=m,this.ui(i,u-m,r.startBox.y,m,r.startBox.height),i.repaint(!1);return}case"resize-e":case"resize-se":{let u=he(Math.round(r.startBox.width+(t-r.startMx)),ct,Math.min(yi,a));o.legend_width_px=u;let m=r.kind==="resize-se"?this.Vr(r.startBox,r.startMy,n,i):r.startBox.height;this.ui(i,r.startBox.x,r.startBox.y,u,m),i.repaint(!1);return}case"resize-s":{let u=this.Vr(r.startBox,r.startMy,n,i);this.ui(i,r.startBox.x,r.startBox.y,r.startBox.width,u),i.repaint(!1);return}}}Vr(t,n,i,r){let o=he(Math.round(t.height+(i-n)),xi,Math.max(xi,r.cssHeight-8));return r.cfg.legend_height_px=o,o}ui(t,n,i,r,o){let s=Math.max(0,t.cssWidth-r),l=Math.max(0,t.cssHeight-o),a=t.cfg.legend_anchor;t.cfg.legend_x=$s(js(a)?s-n:n,s),t.cfg.legend_y=$s(Zs(a)?l-i:i,l)}Hr(t,n){let i=this.we;if(!i)return;let r=he(t,0,Math.max(0,i.contentHeight-i.content.height));r!==this.Gt&&(this.Gt=r,n.repaint(!1))}static Ro(t){switch(t){case"resize-w":case"resize-e":return"ew-resize";case"resize-s":return"ns-resize";case"resize-se":return"nwse-resize";case"move":return"grab";default:return""}}ai(t,n){t!==this.Nr&&(this.Nr=t,n.setCursor(t))}}});function vi(e){let t=e.trim();if(t.startsWith("#")){let i=t.slice(1);return i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),[parseInt(i.slice(0,2),16)/255,parseInt(i.slice(2,4),16)/255,parseInt(i.slice(4,6),16)/255]}let n=t.match(/rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)/);return n?[+n[1]/255,+n[2]/255,+n[3]/255]:[.5,.5,.5]}var ho=G(()=>{"use strict"});function qs(e){if(!e)return pt.slice();let t=e.trim();if(!t)return pt.slice();let n=t.indexOf("(");if(n<0||!/^linear-gradient\\s*\\(/i.test(t))return pt.slice();let i=t.lastIndexOf(")");if(i<=n)return pt.slice();let r=t.substring(n+1,i),o=[],s=0,l=0;for(let c=0;c<r.length;c++){let p=r[c];p==="("?s++:p===")"?s--:p===","&&s===0&&(o.push(r.substring(l,c)),l=c+1)}o.push(r.substring(l));let a=[],u=0;if(o.length>0){let c=o[0].trim().toLowerCase();(c.startsWith("to ")||/^[-\\d.]+(deg|rad|grad|turn)/.test(c))&&(u=1)}for(let c=u;c<o.length;c++){let p=o[c].trim();if(!p)continue;let b=p.match(/\\s([\\-\\d.]+)%\\s*$/),g=b?p.substring(0,b.index).trim():p,x=b?parseFloat(b[1])/100:null;try{let h=vi(g);a.push({color:h,offset:x})}catch{}}if(a.length===0)return pt.slice();if(a.length===1){let[c,p,b]=a[0].color;return[{offset:0,color:[c,p,b,1]},{offset:1,color:[c,p,b,1]}]}a[0].offset===null&&(a[0].offset=0),a[a.length-1].offset===null&&(a[a.length-1].offset=1);for(let c=1;c<a.length-1;c++){if(a[c].offset!==null)continue;let p=c+1;for(;p<a.length&&a[p].offset===null;)p++;let b=a[c-1].offset,g=a[p].offset,x=p-(c-1);for(let h=c;h<p;h++)a[h].offset=b+(h-(c-1))/x*(g-b);c=p-1}let m=0;return a.map(c=>{let p=Math.max(m,Math.min(1,c.offset));return m=p,{offset:p,color:[c.color[0],c.color[1],c.color[2],1]}})}function xo(e){let t=e.trim();if(t.startsWith("#")){let a=t.slice(1);return/^[0-9a-f]+$/i.test(a)?a.length===3||a.length===4?[parseInt(a[0]+a[0],16)/255,parseInt(a[1]+a[1],16)/255,parseInt(a[2]+a[2],16)/255]:a.length===6||a.length===8?[parseInt(a.slice(0,2),16)/255,parseInt(a.slice(2,4),16)/255,parseInt(a.slice(4,6),16)/255]:null:null}let n=t.match(/^rgba?\\(([^)]*)\\)$/i);if(!n)return null;let i=n[1].split("/")[0].split(/[\\s,]+/).filter(a=>a.length>0);if(i.length<3||i.length>4)return null;let r=a=>{let u=a.endsWith("%"),m=parseFloat(u?a.slice(0,-1):a);if(!isFinite(m))return null;let f=u?m/100*255:m;return Math.max(0,Math.min(255,Math.round(f)))/255},o=r(i[0]),s=r(i[1]),l=r(i[2]);return o===null||s===null||l===null?null:[o,s,l]}function Ks(e){let t=e.trim().match(/^linear-gradient\\s*\\((.*)\\)$/is);if(!t)return null;let n=t[1],i=[],r=0,o=0;for(let l=0;l<n.length;l++){let a=n[l];a==="("?r++:a===")"?r--:a===","&&r===0&&(i.push(n.substring(o,l)),o=l+1)}i.push(n.substring(o));let s=[];for(let l=0;l<i.length;l++){let a=i[l].trim();if(!a)return null;let u=a.toLowerCase();if(l===0&&(u.startsWith("to ")||/^[-\\d.]+(deg|rad|grad|turn)$/.test(u)))continue;let m=a.match(/\\s([^\\s)]+)$/),f=a,c=null;if(m){let b=m[1];if(b.endsWith("%")){let g=parseFloat(b.slice(0,-1));if(!isFinite(g))return null;f=a.substring(0,m.index).trim(),c=g/100}else if(/^[-\\d.]/.test(b))return null}let p=xo(f);if(!p)return null;s.push([p,c])}return s}function Js(e){let t=Ks(e);if(!t||t.length<2)return null;let n=t.map(([,o])=>o),i=n.length-1;n[0]===null&&(n[0]=0),n[i]===null&&(n[i]=1);for(let o=1;o<i;o++){if(n[o]!==null)continue;let s=o+1;for(;n[s]===null;)s++;let l=n[o-1],a=n[s],u=s-(o-1);for(let m=o;m<s;m++)n[m]=l+(m-(o-1))/u*(a-l);o=s-1}let r=t.map(([o],s)=>({offset:Math.max(0,Math.min(1,n[s])),color:[o[0],o[1],o[2],1]}));return r.sort((o,s)=>o.offset-s.offset),r}function Ai(e){let t=Ks(e);if(!t||t.length===0)return null;let n=[];for(let[i,r]of t){if(r!==null)return null;n.push(i)}return n}function Re(e,t){if(e.length===0)return[0,0,0,1];if(t<=e[0].offset)return e[0].color.slice();let n=e[e.length-1];if(t>=n.offset)return n.color.slice();let i=0,r=e.length-1;for(;r-i>1;){let u=i+r>>1;e[u].offset<=t?i=u:r=u}let o=e[i],s=e[r],l=s.offset-o.offset,a=l>0?(t-o.offset)/l:0;return[o.color[0]+(s.color[0]-o.color[0])*a,o.color[1]+(s.color[1]-o.color[1])*a,o.color[2]+(s.color[2]-o.color[2])*a,o.color[3]+(s.color[3]-o.color[3])*a]}function bt(e,t,n){if(!isFinite(e)||t===n)return .5;let i;if(t>=0?i=n:n<=0?i=-t:i=Math.max(-t,n),i<=0)return .5;let r=.5+.5*(e/i);return r<0?0:r>1?1:r}function Li(e,t){if(!isFinite(e)||!isFinite(t)||e>=t)return[0,0];let n;return e>=0?n=t:t<=0?n=-e:n=Math.max(-e,t),n<=0?[0,0]:[-n,n]}function Qs(e){if(e.length===0)return pt.slice();if(e.length===1){let[n,i,r]=e[0];return[{offset:0,color:[n,i,r,1]},{offset:1,color:[n,i,r,1]}]}let t=e.length-1;return e.map(([n,i,r],o)=>({offset:o/t,color:[n,i,r,1]}))}function el(e,t=256){let n=new Uint8Array(t*4);for(let i=0;i<t;i++){let r=t===1?0:i/(t-1),o=Re(e,r);n[i*4]=Math.round(o[0]*255),n[i*4+1]=Math.round(o[1]*255),n[i*4+2]=Math.round(o[2]*255),n[i*4+3]=Math.round(o[3]*255)}return n}var pt,de=G(()=>{"use strict";ho();pt=[{offset:0,color:[3/255,102/255,214/255,1]},{offset:1,color:[255/255,127/255,14/255,1]}]});function vm(e){return isFinite(e)?e<0?0:e>1?1:e:.5}function tl(e){return!isFinite(e)||e<0?1:e}function nl(e){let t=(o,s)=>e[o]||s,n=e["--psp-charts--gradient--background"]||e["--psp-charts--full-gradient--background"]||"linear-gradient(#0366d6 0%, #ff7f0e 100%)",i=qs(n),r=[];for(let o=1;;o++){let s=e[`--psp-charts--series-${o}--color`];if(!s)break;r.push(vi(s))}return{fontFamily:t("--psp-charts--font-family",t("font-family","monospace")),backgroundColor:t("--psp--background-color","rgba(255, 255, 255, 1)"),Pt:t("--psp-charts--axis-ticks--color","rgba(160, 0, 0, 0.8)"),Me:t("--psp--color","rgba(180, 0, 0, 0.9)"),mi:t("--psp-charts--axis-lines--color","rgba(160, 0, 0, 0.4)"),Tn:t("--psp-charts--gridline--color","rgba(255, 0, 0, 1)"),k:i,mn:t("--psp-charts--legend--color","rgba(180, 180, 180, 0.9)"),Qi:t("--psp-charts--legend-border--color","rgba(128,128,128,0.3)"),li:t("--psp-charts--tooltip--background","rgba(155,155,155,0.8)"),kr:t("--psp-charts--tooltip--color","#161616"),Wr:t("--psp-charts--tooltip--border-color","#fff"),fi:vm(parseFloat(t("--psp-charts--area--opacity","0.85"))),Yr:tl(parseFloat(t("--psp-charts--heatmap-gap--px","0"))),zr:tl(parseFloat(t("--psp-charts--sunburst-gap--px","1"))),Ge:r}}var il=G(()=>{"use strict";ho();de()});function rl(e,t,n){if(!n)return e;let i=t?.[n];if(!i)return e;let r=e,o=Lm(i.gradient);o&&(r={...r,k:o});let s=Am(i.palette);return s&&(r={...r,Ge:s}),r}function Am(e){return typeof e!="string"?null:Ai(e)}function Lm(e){return typeof e!="string"?null:Js(e)}var ol=G(()=>{"use strict";de()});function ll(e,t,n){let i=gt.get(e);i?(i.fullRender=t,i.render2D=n):(i={glManager:e,fullRender:t,render2D:n,waiters:[]},gt.set(e,i));let r=Promise.withResolvers();return i.waiters.push(r),Ti||(Ti=fl(ml)),r.promise}function al(e,t){if(!wi.has(e)){t();return}let n=cn.get(e);n||(n=[],cn.set(e,n)),n.push(t)}function ul(e){let t=gt.get(e);if(t){gt.delete(e);for(let n of t.waiters)n.resolve()}cn.delete(e),wi.delete(e)}async function ml(){let e=Array.from(gt.values());gt.clear();let t=new Map;for(let n of e){if(n.glManager.isContextLost()){for(let o of n.waiters)o.resolve();continue}let i=n.glManager.backendId,r=t.get(i);r?r.push(n):t.set(i,[n])}await Promise.all(Array.from(t.values()).map(Tm)),Ti=0,gt.size>0&&(Ti=fl(ml))}async function Tm(e){for(let t of e)await wm(t)}async function wm(e){wi.add(e.glManager);try{e.glManager.beginFrame(),e.fullRender()}catch(t){console.error("scheduler: fullRender threw",t);for(let n of e.waiters)n.reject(t);sl(e.glManager);return}try{await e.glManager.awaitGpuFence(),e.render2D(),e.glManager.endFrame();for(let t of e.waiters)t.resolve()}catch(t){console.error("scheduler: present failed",t);try{e.glManager.endFrame()}catch{}for(let n of e.waiters)n.reject(t)}finally{sl(e.glManager)}}function sl(e){wi.delete(e);let t=cn.get(e);if(t){cn.delete(e);for(let n of t)try{n()}catch(i){console.error("scheduler: deferred op threw",i)}}}function fl(e){return typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(e,16)}var gt,Ti,wi,cn,yo=G(()=>{"use strict";gt=new Map,Ti=0,wi=new Set,cn=new Map});var cl,Mm,Rm,Se,dn=G(()=>{"use strict";ks();Ns();Ae();di();bo();Bt();Ne();il();ol();yo();cl=!0,Mm=(()=>{if(cl)return me;{let e=uo("float");return t=>e.format(t)}})(),Rm=(()=>{if(cl)return ve;{let e=mo();return t=>e.format(t)}})(),Se=class{constructor(){d(this,"t",null);d(this,"K",null);d(this,"u",null);d(this,"Xr",null);d(this,"wn",[]);d(this,"$r",{});d(this,"h",null);d(this,"Mn",[]);d(this,"M",[]);d(this,"C",[]);d(this,"B",[]);d(this,"ze",{});d(this,"ci",!1);d(this,"di",!1);d(this,"Ct",{});d(this,"Rn",{});d(this,"er",new Map);d(this,"pi");d(this,"W",{...zs});d(this,"i",{...mt});d(this,"R",new Ci);d(this,"L",new hi);d(this,"bi",null);d(this,"gi",Promise.resolve());d(this,"fn",null);d(this,"jr",null);d(this,"We",null)}setGridlineCanvas(t){this.K=t}setChromeCanvas(t){this.u=t}setOverlayPresenter(t){this.Xr=t}presentOverlay(){this.Xr?.()}setTheme(t){this.$r=t,this.fn=null}setZoomController(t){this.h=t,t.configure(this.getZoomConfig())}getZoomControllerForFacet(t){if(this.W.zoom_mode==="shared")return this.h;if(!this.h)return null;let n=this.Mn[t];return n||(n=new It,n.configure(this.getZoomConfig()),this.Mn[t]=n),n}computeEffectiveFacetFlags(){let t=this.W.zoom_mode==="independent",n=!t&&this.W.shared_x_axis,i=!t&&this.W.shared_y_axis;return this.ci=n,this.di=i,{independentZoom:t,effectiveSharedX:n,effectiveSharedY:i}}syncFacetZoomLayouts(t){let n=this.W.zoom_mode==="independent";for(let i=0;i<t.length;i++)if(this.getZoomControllerForFacet(i)?.updateLayout(t[i].layout),!n)return}setZoomBaseDomain(t,n,i,r){this.h&&this.h.setBaseDomain(t,n,i,r);for(let o of this.Mn)o&&o.setBaseDomain(t,n,i,r)}getZoomConfig(){return{}}setColumnSlots(t){this.M=t}setViewPivots(t,n){this.C=t,this.B=n}setColumnTypes(t){this.ze=t,this.Zr()}resetExpandedDomain(){}setGroupByTypes(t){this.Ct=t}setColumnsConfig(t){this.Rn=t??{},this.Zr(),this.fn=null}Zr(){this.er=new Map;for(let[t,n]of Object.entries(this.Rn)){let i=this.ze[t]??this.Ct[t],r=this.So(i,n);r&&this.er.set(t,r)}}So(t,n){if(!(!t||!n)){if(t==="integer"||t==="float"){let i=n.number_format;if(!i)return;let r=uo(t,i);return o=>r.format(o)}if(t==="datetime"){let i=n.date_format;if(!i)return;let r=mo(i);return o=>r.format(o)}if(t==="date"){let i=n.date_format;if(!i)return;let r=Ws(i);return o=>r.format(o)}}}getColumnFormatter(t,n="value"){if(t){let o=this.er.get(fo(t));if(o)return o}if(n==="tick")return;let i=t?fo(t):void 0,r=i?this.ze[i]??this.Ct[i]:void 0;return r==="date"||r==="datetime"?Rm:Mm}setDefaultChartType(t){this.pi=t}setFacetConfig(t){this.W={...t}}setPluginConfig(t){this.R.reconcileConfig(this.i,t),this.i={...t},this.W={...this.W,facet_mode:t.facet_mode,zoom_mode:t.facet_zoom_mode},this.xi=t.series_zoom_mode==="dynamic"}colorScaleColumn(){return null}T(){let t=this.colorScaleColumn();return(!this.fn||this.jr!==t)&&(this.jr=t,this.fn=rl(nl(this.$r),this.Rn,t)),this.fn}invalidateTheme(){this.fn=null}setView(t){this.We&&this.We.dispose(),this.We=new bi(t);let n=this.L.isPinned;this.L.dismiss(),n&&this.emitUnselect()}deselect(){this.L.dismiss()}tooltipCallbacks(){return{onHover:()=>{},onLeave:()=>{}}}attachTooltip(t){this.L.attach(this.tooltipCallbacks()),this.L.setHost(t),this.bi=t}async buildClickDetail(t){let n={};if(t.rowIdx!=null&&t.rowIdx>=0&&this.We)try{let r=await this.We.fetchRow(t.rowIdx);n=Object.fromEntries(r)}catch{n={}}let i=[];for(let r=0;r<this.C.length;r++){let o=t.groupByValues[r];o!=null&&o!==""&&i.push([this.C[r],"==",o])}for(let r=0;r<this.B.length;r++){let o=t.splitByValues[r];o!=null&&o!==""&&i.push([this.B[r],"==",o])}return{row:n,column_names:[t.columnName],config:{filter:i}}}emitUserClick(t){let n={row:t.row,column_names:t.column_names,config:t.config};this.bi?.emitUserClick?.(n)}emitUserSelect(t){let n={selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig};this.bi?.emitUserSelect?.(n)}emitClickAndSelect(t){let n=this.gi.then(async()=>{let i=await this.buildClickDetail(t);this.emitUserClick(i),this.emitUserSelect({selected:!0,row:i.row,column_names:i.column_names,insertConfig:i.config})});return this.gi=n.catch(i=>{console.error("emitClickAndSelect failed",i)}),n}emitUnselect(t={}){let n=this.gi.then(()=>{this.emitUserSelect({selected:!1,row:t.row??{},column_names:t.column_names??[],insertConfig:{filter:[]}})});this.gi=n.catch(i=>{console.error("emitUnselect failed",i)})}requestRender(t){return ll(t,()=>{this.wn=[],this.Wt(t)},()=>this.qr())}he(t){this.wn.push(t)}qr(){let t=this.wn;this.wn=[];for(let n of t)n()}renderFrameSync(t){this.wn=[],this.Wt(t),this.qr()}destroy(){this.L.detach(),this.L.dismiss(),this.We&&(this.We.dispose(),this.We=null),this.destroyInternal()}}});var Mi,dl=G(()=>{"use strict";Mi=class{constructor(t,n,i,r,o){d(this,"nt",new Map);d(this,"xe");d(this,"Re");d(this,"kt");d(this,"Kr");this.xe=t,this.Re=i,this.kt=o,this.Kr=Math.max(1,Math.ceil((n-t)/o))}Jr(t,n){return n*this.Kr+t}insert(t,n,i){let r=Math.floor((n-this.xe)/this.kt),o=Math.floor((i-this.Re)/this.kt),s=this.Jr(r,o),l=this.nt.get(s);l||(l=[],this.nt.set(s,l)),l.push(t)}query(t,n,i,r,o,s,l){let a=Math.ceil(i/r/this.kt),u=Math.ceil(i/o/this.kt),m=Math.floor((t-this.xe)/this.kt),f=Math.floor((n-this.Re)/this.kt),c=-1,p=i*i;for(let b=f-u;b<=f+u;b++)for(let g=m-a;g<=m+a;g++){let x=this.nt.get(this.Jr(g,b));if(x)for(let h of x){let y=(s[h]-t)*r,_=(l[h]-n)*o,C=y*y+_*_;C<p&&(p=C,c=h)}}return c}}});var Ri,pl=G(()=>{"use strict";dl();Ri=class{constructor(){d(this,"Sn",null);d(this,"Fn",!0)}markDirty(){this.Fn=!0}get isDirty(){return this.Fn}rebuild(t,n,i){if(n===0){this.Sn=null,this.Fn=!1;return}let r=t.xMax-t.xMin||1,o=t.yMax-t.yMin||1,l=(r+o)/2/Math.max(1,Math.sqrt(n)),a=new Mi(t.xMin,t.xMax,t.yMin,t.yMax,l);i((u,m,f)=>a.insert(u,m,f)),this.Sn=a,this.Fn=!1}query(t,n,i,r,o,s,l){return!this.Sn||!s||!l?-1:this.Sn.query(t,n,i,r,o,s,l)}clear(){this.Sn=null,this.Fn=!0}}});function qe(e,t,n=[]){let i=new Map;for(let o of e.keys()){if(o.startsWith("__"))continue;let s=o.lastIndexOf("|");if(s===-1)continue;let l=o.substring(0,s);i.has(l)||i.set(l,new Set),i.get(l).add(o)}let r=[];for(let[o,s]of i){let l=new Map,a=!0;for(let u of t){if(!u)continue;let m=`${o}|${u}`,f=e.get(m);if(!s.has(m)||!f?.values){a=!1;break}l.set(u,m)}if(a){for(let u of n){if(!u)continue;let m=`${o}|${u}`;s.has(m)&&e.get(m)?.values&&l.set(u,m)}r.push({prefix:o,colNames:l})}}return r}var pn=G(()=>{"use strict"});var Si,bl=G(()=>{"use strict";Si=class{constructor(t){d(this,"data");d(this,"dictionary",[]);d(this,"dictMap",new Map);this.data=new Int32Array(t),this.data.fill(-1)}set(t,n){let i=this.dictMap.get(n);return i===void 0&&(i=this.dictionary.length,this.dictionary.push(n),this.dictMap.set(n,i)),this.data[t]=i,i}get(t){let n=this.data[t];return n<0?null:this.dictionary[n]}}});function gl(e,t,n,i){let r;if(!e)r="(null)";else{let s=e.valid;if(!(s?!!(s[t>>3]>>(t&7)&1):!0))r="(null)";else if(e.indices&&e.dictionary)r=e.dictionary[e.indices[t]]??"(null)";else if(e.values){let a=e.values[t];r=a==null?"(null)":String(a)}else r="(null)"}let o=i.get(r);return o===void 0&&(o=n.length,n.push(r),i.set(r,o)),o}function Sm(e,t,n,i,r,o){let s=t?[t,n]:[n],l=[];return i&&l.push(i),r&&l.push(r),o&&l.push(o),qe(e,s,l).map(a=>({prefix:a.prefix,xColName:t?a.colNames.get(t):"",yColName:a.colNames.get(n),colorColName:i?`${a.prefix}|${i}`:"",sizeColName:r?`${a.prefix}|${r}`:"",labelColName:o?`${a.prefix}|${o}`:""}))}function hl(e,t,n,i){e.glyph.ensureProgram(e,t);let r=e.s,o=e.H;e.i.domain_mode==="expand"?(e.xe=e.In,e.it=e.Dn,e.Re=e.Bn,e.rt=e.En,e.b=e.yi,e.p=e.Ci,e.ot=e._i,e.st=e.vi):(e.xe=1/0,e.it=-1/0,e.Re=1/0,e.rt=-1/0,e.b=1/0,e.p=-1/0,e.ot=1/0,e.st=-1/0,e.In=1/0,e.Dn=-1/0,e.Bn=1/0,e.En=-1/0,e.yi=1/0,e.Ci=-1/0,e._i=1/0,e.vi=-1/0),e.S=NaN,e.F=NaN,e._t=0,e.cn.clear(),e.tr=0;let l=e.M,a=l[0]||"",u=l[1]||"",m=l[2]||"",f=l[3]||"",c=l[4]||"";e.ke=a,e.Se=u,e.Qr=!a,e.Ne=!!a&&e.ze[a]==="string",e.ye=!!u&&e.ze[u]==="string",e.dn=[],e.pn=[],e.eo=new Map,e.to=new Map,e.lt=null,e.ut=null,e.Ne&&(e.S=0,e.xe=0,e.it=0,e.In=1/0,e.Dn=-1/0),e.ye&&(e.F=0,e.Re=0,e.rt=0,e.Bn=1/0,e.En=-1/0);let p=t.v.totalCapacity||i;if(e.B.length>0){if(e.A=Sm(n,a,u,m,f,c),e.A.length===0){e.w=0,e.V=[];return}if(e.Je=e.A[0].xColName,e.Xe=e.A[0].yColName,e.s=m,e.ie=f,e.Ai=c,e.H=!1,m){let x=n.get(e.A[0].colorColName);e.H=x?.type==="string"}t.ensureBufferCapacity(p*e.A.length)}else if(e.A=[],e.Je=a,e.Xe=u,e.s=m,e.ie=f,e.Ai=c,e.H=!1,e.s){let x=n.get(e.s);e.H=x?.type==="string"}(e.s!==r||e.H!==o)&&(e.c=new Map);let b=Math.max(1,e.A.length);e.w=p,e.V=new Array(b).fill(0);let g=b*p;e.Y=new Float32Array(g),e.X=new Float32Array(g),e.vt=new Float32Array(g),e.Nt=new Int32Array(g),e.Ot=c?new Si(g):null}function xl(e,t,n,i,r,o){if(!e.Xe)return;let s=r;if(s===0||e.w===0)return;let l=e.A.length>0,a=[];if(l)for(let b of e.A){let g=b.xColName?n.get(b.xColName):null,x=n.get(b.yColName);if(!x||!e.ye&&!x.values)continue;let h=b.sizeColName?n.get(b.sizeColName):null,y=b.colorColName?n.get(b.colorColName)??null:null,_=b.labelColName?n.get(b.labelColName)??null:null;a.push({xCol:g?.values??null,yCol:x.values??null,xColData:g??null,yColData:x,xValid:g?.valid,yValid:x.valid,colorCol:y,sizeCol:h?.values??null,labelCol:_})}else{let b=e.Je?n.get(e.Je):null,g=e.Xe?n.get(e.Xe):null;if(!g||!e.ye&&!g.values)return;let x=e.s?n.get(e.s)??null:null,h=e.Ai?n.get(e.Ai)??null:null;a.push({xCol:b?.values??null,yCol:g.values??null,xColData:b??null,yColData:g,xValid:b?.valid,yValid:g?.valid,colorCol:x,sizeCol:null,labelCol:h})}if(a.length===0)return;e.no<s&&(e.nr=new Float32Array(s*2),e.ir=new Float32Array(s),e.rr=new Float32Array(s),e.no=s);let u=e.nr,m=e.ir,f=e.rr,c=!l&&e.ie?n.get(e.ie)?.values??null:null;if(e.H&&e.s){for(let b of a){let g=b.colorCol?.dictionary;if(g)for(let x=0;x<g.length;x++){let h=g[x];e.c.has(h)||e.c.set(h,e.c.size)}}e.c.size>0&&(e.b=0,e.p=e.c.size-1)}!e.s&&e.A.length>1&&(e.b=0,e.p=e.A.length-1);for(let b=0;b<a.length;b++){let g=a[b],x=e.V[b]??0,h=b*e.w,y=e.w-x;if(y<=0)continue;let _=g.colorCol?.valid,C=0;for(let L=0;L<s&&C<y;L++){let T=L;if(!e.ye&&g.yValid&&!(g.yValid[T>>3]>>(T&7)&1)||!e.Ne&&g.xCol&&g.xValid&&!(g.xValid[T>>3]>>(T&7)&1))continue;let w=_!==void 0&&!(_[T>>3]>>(T&7)&1),M;if(e.ye)M=gl(g.yColData,T,e.pn,e.to);else if(g.yCol){if(M=g.yCol[T],isNaN(M))continue}else continue;let D;if(e.Ne)D=gl(g.xColData,T,e.dn,e.eo);else if(g.xCol){if(D=g.xCol[T],isNaN(D))continue}else D=i+T;let[I,F]=e.projectPoint(D,M);if(isNaN(I)||isNaN(F))continue;I<e.xe&&(e.xe=I),I>e.it&&(e.it=I),F<e.Re&&(e.Re=F),F>e.rt&&(e.rt=F),isNaN(e.S)&&(e.S=I),isNaN(e.F)&&(e.F=F);let B=I-e.S,N=F-e.F,k=h+x+C;e.Y[k]=B,e.X[k]=N,e.Nt[k]=i+T,u[C*2]=B,u[C*2+1]=N;let Y=g.colorCol;if(w)m[C]=.5,e.vt[k]=.5;else if(Y&&!e.H&&Y.values){let W=Y.values[T];m[C]=W,e.vt[k]=W,W<e.b&&(e.b=W),W>e.p&&(e.p=W)}else if(Y&&e.H&&Y.indices&&Y.dictionary){let W=Y.dictionary[Y.indices[T]];e.c.has(W)||(e.c.set(W,e.c.size),e.p=e.c.size-1);let H=e.c.get(W);m[C]=H,e.vt[k]=H}else m[C]=b,e.vt[k]=b;if(e.Ot&&g.labelCol){let W=g.labelCol,H=W.valid;!(H!==void 0&&!(H[T>>3]>>(T&7)&1))&&W.indices&&W.dictionary&&e.Ot.set(k,W.dictionary[W.indices[T]])}if(g.sizeCol){let W=g.sizeCol[T];f[C]=W,W<e.ot&&(e.ot=W),W>e.st&&(e.st=W)}else if(c){let W=c[T];f[C]=W,W<e.ot&&(e.ot=W),W>e.st&&(e.st=W)}else f[C]=0;C++}if(C===0)continue;let v=(h+x)*2*Float32Array.BYTES_PER_ELEMENT;t.v.upload("a_position",u.subarray(0,C*2),v,2);let A=(h+x)*Float32Array.BYTES_PER_ELEMENT;t.v.upload("a_color_value",m.subarray(0,C),A),t.v.upload("a_size_value",f.subarray(0,C),A),e.V[b]=x+C,e.V[b]>e.tr&&(e.tr=e.V[b])}let p=0;for(let b of e.V)p+=b;e._t=p,t.uploadedCount=p,e.cn.markDirty(),isFinite(e.xe)&&e.setZoomBaseDomain(e.xe,e.it,e.Re,e.rt)}var yl=G(()=>{"use strict";pn();bl()});function Pt(e,t,n,i,r){let o=e.getContext("2d");o&&(o.save(),o.setTransform(1,0,0,1,0,0),o.scale(r,r),o.font=`11px ${i.fontFamily}`,o.fillStyle=i.Me,o.textAlign="center",o.textBaseline="middle",o.fillText(t,n.x+n.width/2,n.y+n.height/2),o.restore())}var Fi=G(()=>{"use strict"});var ie,Ke=G(()=>{"use strict";ie=class{constructor(t,n,i){d(this,"margins");d(this,"e");d(this,"cssWidth");d(this,"cssHeight");d(this,"$",0);d(this,"J",1);d(this,"j",0);d(this,"Q",1);this.cssWidth=t,this.cssHeight=n;let o=(i.leftExtra??55)+(i.hasYLabel?16:0),l=(i.bottomExtra??24)+(i.hasXLabel?18:0),a=0,u=i.rightExtra??(i.hasLegend?80:16),m=i.originX??0,f=i.originY??0,c=i.cellWidth??t,p=i.cellHeight??n,b=m+o,g=f+a,x=Math.max(1,c-o-u),h=Math.max(1,p-a-l),y=t-(b+x),_=n-(g+h);this.margins={top:g,right:y,bottom:_,left:b},this.e={x:b,y:g,width:x,height:h}}buildProjectionMatrix(t,n,i,r,o,s,l=.02,a=0,u=0){let m=n-t,f=r-i;m===0&&(m=1),f===0&&(f=1);let c=m*l,p=f*l,b=s&&o==="y"&&i>=0,g=s&&o==="y"&&r<=0,x=s&&o==="x"&&t>=0,h=s&&o==="x"&&n<=0;t-=c,n+=c,i-=p,r+=p,b?(i=0,r+=p):g&&(r=0,i-=p),x?(t=0,n+=c):h&&(n=0,t-=c),this.$=t,this.J=n,this.j=i,this.Q=r;let y=2*this.margins.left/this.cssWidth-1,_=1-2*this.margins.right/this.cssWidth,C=2*this.margins.bottom/this.cssHeight-1,v=1-2*this.margins.top/this.cssHeight,A=(_-y)/(n-t),L=(v-C)/(r-i),T=y-A*(t-a),w=C-L*(i-u);return new Float32Array([A,0,0,0,0,L,0,0,0,0,-1,0,T,w,0,1])}E(t,n){let{x:i,y:r,width:o,height:s}=this.e,l=(t-this.$)/(this.J-this.$),a=(n-this.j)/(this.Q-this.j);return{px:i+l*o,py:r+(1-a)*s}}}});function bn(e){return e.cells.filter(t=>t.isBottomEdge).map(t=>t.layout)}function gn(e){return e.cells.filter(t=>t.isLeftEdge).map(t=>t.layout)}function Gm(e,t,n,i){if(e<=1)return{cols:1,rows:1};let r=1,o=e,s=1/0,l=e;for(let a=1;a<=e;a++){let u=Math.ceil(e/a),m=Math.max(1,(t-(a-1)*i)/a),f=Math.max(1,(n-(u-1)*i)/u),c=m/f,p=Math.max(c,1/c),b=a*u;(p<s||p===s&&b<l)&&(r=a,o=u,s=p,l=b)}return{cols:r,rows:o}}function Fe(e,t){let n=e.length,{cssWidth:i,cssHeight:r}=t;if(n<=0||i<=0||r<=0)return{cells:[]};let o=t.titleBand??Em,s=t.hasLegend?t.legendWidth??Pm:0,l=t.xAxis??"cell",a=t.yAxis??"cell",u=l==="none"&&a==="none",m=a==="outer"?Fm+(t.hasYLabel?Dm:0):0,f=l==="outer"?Im+(t.hasXLabel?Bm:0):0,c=0,p=s,b=m,g=c,x=Math.max(1,i-m-p),h=Math.max(1,r-c-f),y=Math.max(0,t.gap??0),{cols:_,rows:C}=Gm(n,x,h,y),v=Math.max(0,_-1)*y,A=Math.max(0,C-1)*y,L=Math.max(1,(x-v)/_),T=Math.max(1,(h-A)/C),w=[];for(let F=0;F<n;F++){let B=Math.floor(F/_),N=F-B*_,k=B===C-1||F+_>=n,Y=N===0,W=b+N*(L+y),H=g+B*(T+y),U=H+o,z=W,q=L,ae=Math.max(1,T-o),Be=new ie(i,r,{hasXLabel:l==="cell"&&t.hasXLabel===!0,hasYLabel:a==="cell"&&t.hasYLabel===!0,hasLegend:!1,leftExtra:a==="cell"?void 0:0,bottomExtra:l==="cell"?void 0:0,rightExtra:u?0:void 0,originX:z,originY:U,cellWidth:q,cellHeight:ae}),we=o>0?{x:z,y:H,width:q,height:o}:void 0;w.push({index:F,label:e[F],layout:Be,titleRect:we,isLeftEdge:Y,isBottomEdge:k})}let M=t.hasLegend?{x:b+x,y:c,width:s,height:h}:void 0,D=l==="outer"?{x:b,y:g+h,width:x,height:f}:void 0;return{cells:w,legendRect:M,outerXAxisRect:D,outerYAxisRect:a==="outer"?{x:0,y:g,width:m,height:h}:void 0}}var Fm,Im,Dm,Bm,Em,Pm,Gt=G(()=>{"use strict";Ke();Fm=55,Im=24,Dm=16,Bm=18,Em=18,Pm=96});function Wm(e,t){if(t<=0)return[];let n=new Array(t);for(let i=0;i<t;i++){let r=t===1?.5:i/(t-1),o=Re(e,r);n[i]=[o[0],o[1],o[2]]}return n}function pe(e,t,n){if(e.length>0){if(e.length>=n)return e.slice(0,n);let i=new Array(n);for(let r=0;r<n;r++)i[r]=e[r%e.length];return i}return Wm(t,n)}var hn=G(()=>{"use strict";de()});function ht(e){e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)}function xt(e,t,n,i){e.enable(e.SCISSOR_TEST),e.scissor(Math.round(t.margins.left*n),Math.round(t.margins.bottom*n),Math.round(t.e.width*n),Math.round(t.e.height*n));try{i()}finally{e.disable(e.SCISSOR_TEST)}}function Je(e,t,n,i){ht(e),xt(e,t,n,i)}var xn=G(()=>{"use strict"});function yn(e,t,n){let i=e.gl,r;if(t?.texture){if(r=t.texture,t.lastStops===n)return t}else r=i.createTexture();let o=el(n,Cl);return i.bindTexture(i.TEXTURE_2D,r),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,Cl,1,0,i.RGBA,i.UNSIGNED_BYTE,o),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),{texture:r,lastStops:n}}function Oe(e,t,n,i=0){let r=e.gl;r.activeTexture(r.TEXTURE0+i),r.bindTexture(r.TEXTURE_2D,t),r.uniform1i(n,i)}var Cl,Wt=G(()=>{"use strict";de();Cl=256});function ue(e,t,n){e.width=Math.round(t.cssWidth*n),e.height=Math.round(t.cssHeight*n);let i=e.getContext("2d");return i?(i.scale(n,n),i.clearRect(0,0,t.cssWidth,t.cssHeight),i):null}function oe(e,t){let n=e.getContext("2d");return n?(n.setTransform(t,0,0,t,0,0),n):null}var yt=G(()=>{"use strict"});function Ii(e,t,n,i,r,o,s){let l=r==="bottom"?1:-1;e.textAlign="center",e.textBaseline=r==="bottom"?"top":"bottom";let a=l*8;for(let u of n){let m=o(u);m<t.x-1||m>t.x+t.width+1||(e.beginPath(),e.moveTo(m,i),e.lineTo(m,i+l*5),e.stroke(),e.fillText(s(u),m,i+a))}}function Di(e,t,n,i,r,o,s){let l=r==="left"?-1:1;e.textAlign=r==="left"?"right":"left",e.textBaseline="middle";let a=l*8;for(let u of n){let m=o(u);m<t.y-1||m>t.y+t.height+1||(e.beginPath(),e.moveTo(i,m),e.lineTo(i+l*5,m),e.stroke(),e.fillText(s(u),i+a,m))}}function kt(e,t,n,i){for(let r of n){let o=Math.round(i(r))+.5;o<t.x||o>t.x+t.width||(e.beginPath(),e.moveTo(o,t.y),e.lineTo(o,t.y+t.height),e.stroke())}}function Nt(e,t,n,i){for(let r of n){let o=Math.round(i(r))+.5;o<t.y||o>t.y+t.height||(e.beginPath(),e.moveTo(t.x,o),e.lineTo(t.x+t.width,o),e.stroke())}}var Bi=G(()=>{"use strict"});function Ot(e,t,n){let{e:i}=n,r=Math.max(2,Math.floor(i.width/90)),o=Math.max(2,Math.floor(i.height/60));return{xTicks:ne(e.min,e.max,r),yTicks:ne(t.min,t.max,o)}}function Co(e,t,n,i,r,o){let s=oe(e,o);if(!s)return;let{e:l}=t;s.strokeStyle=r.Tn,s.lineWidth=1,kt(s,l,n,a=>t.E(a,0).px),Nt(s,l,i,a=>t.E(0,a).py)}function _l(e,t,n){if(n)return n;let i=t.length>1?t[1]-t[0]:0;return e.isDate?r=>ve(r,i):me}function vl(e,t,n,i,r,o,s,l,a){let{Pt:u,Me:m,mi:f,fontFamily:c}=s,p=_l(t,n,a);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(o.x,r),e.lineTo(o.x+o.width,r),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${c}`;for(let b of i)Ii(e,b.e,n,r,"bottom",g=>b.E(g,0).px,p);l&&t.label&&(e.fillStyle=m,e.font=`13px ${c}`,e.textAlign="center",e.textBaseline="bottom",e.fillText(t.label,l.cx,l.baselineY))}function Al(e,t,n,i,r,o,s,l,a){let{Pt:u,Me:m,mi:f,fontFamily:c}=s,p=_l(t,n,a);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(r,o.y),e.lineTo(r,o.y+o.height),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${c}`;for(let b of i)Di(e,b.e,n,r,"left",g=>b.E(0,g).py,p);l&&t.label&&(e.fillStyle=m,e.font=`13px ${c}`,e.save(),e.translate(14,l.pivotY),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="bottom",e.fillText(t.label,0,0),e.restore())}function Ei(e,t,n,i,r,o,s,l){let a=oe(e,s);if(!a)return;let{e:u}=n;vl(a,t,i,[n],u.y+u.height,u,r,o?{cx:u.x+u.width/2,baselineY:n.cssHeight-2}:null,l)}function Pi(e,t,n,i,r,o,s,l){let a=oe(e,s);if(!a)return;let{e:u}=n;Al(a,t,i,[n],u.x,u,r,o?{pivotY:u.y+u.height/2}:null,l)}function Cn(e,t,n,i,r,o,s,l,a){let u=oe(e,l);u&&vl(u,n,i,r,t.y,t,o,s?{cx:t.x+t.width/2,baselineY:t.y+t.height-2}:null,a)}function _n(e,t,n,i,r,o,s,l,a){let u=oe(e,l);u&&Al(u,n,i,r,t.x+t.width,t,o,s?{pivotY:t.y+t.height/2}:null,a)}var _o=G(()=>{"use strict";Ae();yt();Bi()});function Gi(e,t){if(t>vn||t<-vn)return[NaN,NaN];let n=e*Math.PI*6378137/180,i=t*Math.PI/180,r=6378137*Math.log(Math.tan(Math.PI/4+i/2));return[n,r]}function Wi(e,t){let n=e*180/(Math.PI*6378137),i=Math.atan(Math.exp(t/6378137))*360/Math.PI-90;return[n,i]}function Ll(e,t,n){let i=1<<e,r=2*xe/i,o=-xe+t*r,s=o+r,l=xe-n*r,a=l-r;return{xMin:o,yMin:a,xMax:s,yMax:l}}function Tl(e,t=256,n=19){if(!isFinite(e)||e<=0)return 0;let i=Math.log2(2*xe/(t*e));return Math.max(0,Math.min(n,Math.floor(i)))}function wl(e,t){let n=1<<t,i=2*xe/n,r=Math.floor((e.xMin+xe)/i),o=Math.floor((e.xMax+xe)/i),s=Math.floor((xe-e.yMax)/i),l=Math.floor((xe-e.yMin)/i),a=[];for(let u=s;u<=l;u++)if(!(u<0||u>=n))for(let m=r;m<=o;m++)m<0||m>=n||a.push({z:t,x:m,y:u});return a}var xe,vn,ki=G(()=>{"use strict";xe=Math.PI*6378137,vn=85.0511287798066});function Ni(e){let t=e.e,n=Math.max(2,Math.floor(t.width/90)),i=Math.max(2,Math.floor(t.height/60)),r=vo(e.$),o=vo(e.J),s=Ml(Wi(0,e.j)[1]),l=Ml(Wi(0,e.Q)[1]),a=Rl(r,o,n),u=Rl(s,l,i),m=Sl(a),f=Sl(u);return{xTicks:a.map(c=>c/180*xe),yTicks:u.map(c=>Gi(0,c)[1]),formatX:c=>Fl(vo(c),m,"E","W"),formatY:c=>Fl(Wi(0,c)[1],f,"N","S")}}function vo(e){return e/xe*180}function Ml(e){return Math.max(-vn,Math.min(vn,e))}function Rl(e,t,n){return!isFinite(e)||!isFinite(t)||t<=e?[]:ne(e,t,n)}function Sl(e){return e.length>1?Math.abs(e[1]-e[0]):1}function Fl(e,t,n,i){let r=t>=1?0:Math.min(6,Math.ceil(-Math.log10(t)+1e-9)),o=String(parseFloat(Math.abs(e).toFixed(r)));return parseFloat(o)===0?"0\\xB0":`${o}\\xB0${e>0?n:i}`}var Il=G(()=>{"use strict";Ae();ki()});function Ao(e,t,n,i,r){if(r===0)return{x:e-n/2,y:t,width:n,height:i};if(r===90)return{x:e-i/2,y:t,width:i,height:n};let o=(n+i)/Math.SQRT2;return{x:e-o,y:t,width:o,height:o}}function Lo(e,t){return e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height}function Dl(e,t){return e.x+e.width+14>t.x+t.width}function To(e,t){return e.x>=t.x&&e.x+e.width<=t.x+t.width&&e.y>=t.y&&e.y+e.height<=t.y+t.height}function Ct(e,t,n){if(n<=0)return"";if(e.measureText(t).width<=n)return t;let i=0,r=t.length;for(;i<r;){let o=i+r+1>>1,s=t.slice(0,o)+"\\u2026";e.measureText(s).width<=n?i=o:r=o-1}return i===0?"":t.slice(0,i)+"\\u2026"}function Bl(e,t,n,i){if(i<=0||n<=0)return[];if(e.measureText(t).width<=n)return[t];let r=[],o=t;for(;o.length>0&&r.length<i;){let s=r.length===i-1,l=o.length;for(;l>0&&e.measureText(o.slice(0,l)).width>n;)l--;if(l===0&&(l=1),l===o.length){r.push(o);break}let a=l,u=o.lastIndexOf(" ",l);if(u>0&&(a=u),s){r.push(Ct(e,o,n));break}r.push(o.slice(0,a)),o=o.slice(a).trimStart()}return r.length===1&&r[0].length<=2?[]:r}var Oi=G(()=>{"use strict"});function Ui(e,t,n,i){let r=[];if(i<=n)return r;let o=n,s=e[n];for(let l=n+1;l<i;l++){let a=e[l];a!==s&&(r.push({startIdx:o,endIdx:l-1,label:t[s]??""}),o=l,s=a)}return r.push({startIdx:o,endIdx:i-1,label:t[s]??""}),r}function An(e,t,n){if(n<t)return[];let i=[];for(let r of e){if(r.endIdx<t||r.startIdx>n)continue;let o=r.startIdx<t?t:r.startIdx,s=r.endIdx>n?n:r.endIdx;o===r.startIdx&&s===r.endIdx?i.push(r):i.push({startIdx:o,endIdx:s,label:r.label})}return i}var Ln=G(()=>{"use strict"});function wo(e,t){return e.E(t,0).px}function Mo(e,t){return e.E(0,t).py}function Vm(e,t,n){let i=Math.max(0,n-100);return e*16>i?{size:t*6.62+10,rotation:90}:e*(t*6+10)>i?{size:t*4+20,rotation:45}:{size:km,rotation:0}}function El(e,t){let n=e.levels.length,i=[];for(let r=0;r<n;r++){let o=e.levels[r];r===n-1?i.push(Vm(e.numRows,o.maxLabelChars,t)):i.push({size:Nm,rotation:0})}return i}function Pl(e){let t=e.levels.length,n=[],i=6.2;for(let r=0;r<t;r++)if(r===t-1){let o=e.levels[r].maxLabelChars;n.push(Math.max(Om,o*i+Hm))}else n.push(Um);return n}function Gl(e){let t=0;for(let n of e)t+=n;return t}function Ue(e,t){return e.numRows===0||e.levels.length===0?24:Gl(El(e,t).map(n=>n.size))}function Ht(e){return e.numRows===0||e.levels.length===0?55:Gl(Pl(e))}function Ym(e,t,n,i){let r=t-e+1;if(r<=0)return[];let o=Math.max(1,Math.floor(n/i));if(r<=o){let a=[];for(let u=e;u<=t;u++)a.push(u);return a}let s=Math.ceil(r/o),l=[];for(let a=e;a<=t;a+=s)l.push(a);return l}function Wl(e,t){return e.labels[t]??""}function kl(e,t,n,i){let r=i?Math.min(t,n):t,o=i?Math.max(t,n):n,s=Math.max(0,Math.ceil(r)),l=Math.min(e-1,Math.floor(o));return l<s?null:[s,l]}function Nl(e,t,n,i){let r=[];for(let o of e){let s=t(o.startIdx-.5),l=t(o.endIdx+.5),a=Math.max(n,Math.min(s,l)),u=Math.min(i,Math.max(s,l));u>a&&r.push({run:o,nearEdge:s,farEdge:l,nearClip:a,farClip:u})}return r}function be(e,t,n,i){if(n.numRows===0||n.levels.length===0)return;let{Pt:r,Me:o,fontFamily:s}=i,{e:l}=t,a=l.y+l.height;e.strokeStyle=r,e.fillStyle=r,e.lineWidth=1,e.font=`${Ut}px ${s}`;let u=El(n,l.width),m=kl(n.numRows,t.$,t.J,!1);if(!m)return;let[f,c]=m,p=n.levels.length,b=a;for(let x=p-1;x>=0;x--){let h=n.levels[x],y=u[x],_=b;b+=y.size,x===p-1?zm(e,t,h,f,c,_,y,s,r):Xm(e,t,h,f,c,_,s,r)}let g=n.levelLabels.filter(x=>!!x).join(" / ");g&&(e.fillStyle=o,e.font=`13px ${s}`,e.textAlign="center",e.textBaseline="bottom",e.fillText(g,l.x+l.width/2,t.cssHeight-2))}function zm(e,t,n,i,r,o,s,l,a){let{e:u}=t,f=Math.max(40,Math.min(n.maxLabelChars*6.2+8,u.width/2)),c=s.rotation===0?Ym(i,r,u.width,f):$m(i,r);e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let x of c){let h=wo(t,x);h<u.x-1||h>u.x+u.width+1||(e.moveTo(h,o),e.lineTo(h,o+Hi))}e.stroke(),e.font=`${Ut}px ${l}`;let p=o+Hi+3,b={x:u.x,width:u.width,y:o,height:9999},g=[];for(let x of c){let h=wo(t,x);if(h<u.x-1||h>u.x+u.width+1)continue;let y=Wl(n,x);if(!y)continue;let _=e.measureText(y).width,C=Ao(h,p,_,Ro,s.rotation);if(To(C,b)){if(s.rotation===0){if(g.some(v=>Lo(v,C)))continue}else if(g.some(v=>Dl(v,C)))continue;g.push(C),Ol(e,y,h,p,s.rotation,"center")}}}function Xm(e,t,n,i,r,o,s,l){let{e:a}=t,u=An(n.runs,i,r);if(u.length===0)return;let m=Nl(u,b=>wo(t,b),a.x,a.x+a.width);if(m.length===0)return;e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let b of m)e.moveTo(b.nearClip,o+3),e.lineTo(b.farClip,o+3),e.moveTo(b.nearEdge,o),e.lineTo(b.nearEdge,o+3),e.moveTo(b.farEdge,o),e.lineTo(b.farEdge,o+3);e.stroke(),e.font=`${Ut}px ${s}`;let f=o+3+4,c=[],p={x:a.x,width:a.width,y:o,height:9999};for(let b of m){let g=(b.nearClip+b.farClip)/2,x=b.run.label;if(!x)continue;let h=b.farClip-b.nearClip-4,y=Ct(e,x,h);if(!y)continue;let _=e.measureText(y).width,C=Ao(g,f,_,Ro,0);To(C,p)&&(c.some(v=>Lo(v,C))||(c.push(C),Ol(e,y,g,f,0,"center")))}}function $m(e,t){let n=[];for(let i=e;i<=t;i++)n.push(i);return n}function Ie(e,t,n,i){if(n.numRows===0||n.levels.length===0)return;let{Pt:r,Me:o,fontFamily:s}=i,{e:l}=t,a=l.x;e.strokeStyle=r,e.fillStyle=r,e.lineWidth=1,e.font=`${Ut}px ${s}`;let u=Pl(n),m=kl(n.numRows,t.j,t.Q,!0);if(!m)return;let[f,c]=m,p=n.levels.length,b=a;for(let x=p-1;x>=0;x--){let h=n.levels[x],y=u[x],_=b;b-=y,x===p-1?jm(e,t,h,f,c,_,s,r):Zm(e,t,h,f,c,_,y,s,r)}let g=n.levelLabels.filter(x=>!!x).join(" / ");g&&(e.fillStyle=o,e.font=`13px ${s}`,e.save(),e.translate(14,l.y+l.height/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="bottom",e.fillText(g,0,0),e.restore())}function jm(e,t,n,i,r,o,s,l){let{e:a}=t,u=Ro+4,m=r-i+1,f=Math.max(1,Math.floor(a.height/u)),c=m<=f?1:Math.ceil(m/f);e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let p=i;p<=r;p+=c){let b=Mo(t,p);b<a.y-1||b>a.y+a.height+1||(e.moveTo(o-Hi,b),e.lineTo(o,b))}e.stroke(),e.font=`${Ut}px ${s}`,e.textAlign="right",e.textBaseline="middle";for(let p=i;p<=r;p+=c){let b=Mo(t,p);if(b<a.y-1||b>a.y+a.height+1)continue;let g=Wl(n,p);g&&e.fillText(g,o-Hi-3,b)}}function Zm(e,t,n,i,r,o,s,l,a){let{e:u}=t,m=An(n.runs,i,r);if(m.length===0)return;let f=Nl(m,p=>Mo(t,p),u.y,u.y+u.height);if(f.length===0)return;e.strokeStyle=a,e.fillStyle=a;let c=o-3;e.beginPath();for(let p of f)e.moveTo(c,p.nearClip),e.lineTo(c,p.farClip),e.moveTo(c,p.nearEdge),e.lineTo(o,p.nearEdge),e.moveTo(c,p.farEdge),e.lineTo(o,p.farEdge);e.stroke(),e.font=`${Ut}px ${l}`,e.textAlign="right",e.textBaseline="middle";for(let p of f){let b=(p.nearClip+p.farClip)/2,g=p.run.label;if(!g)continue;let x=s-6,h=Ct(e,g,x);h&&e.fillText(h,c-3,b)}}function Ol(e,t,n,i,r,o){if(r===0){e.textAlign=o==="end"?"right":"center",e.textBaseline="top",e.fillText(t,n,i);return}e.save(),e.translate(n,i),e.rotate(-r*Math.PI/180),e.textAlign="right",e.textBaseline="middle",e.fillText(t,-2,0),e.restore()}var km,Nm,Hi,Ut,Ro,Om,Um,Hm,Vt=G(()=>{"use strict";Oi();Ln();km=25,Nm=22,Hi=5,Ut=11,Ro=14,Om=55,Um=60,Hm=10});function qm(e){return`rgb(${Math.round(e[0]*255)},${Math.round(e[1]*255)},${Math.round(e[2]*255)})`}function Yi(e,t,n,i,r=1){return e.save(),e.fillStyle=n.backgroundColor,e.strokeStyle=n.Qi,e.lineWidth=1,e.beginPath(),e.rect(t.x+.5,t.y+.5,t.width-1,t.height-1),e.globalAlpha=Math.min(1,Math.max(0,r)),e.fill(),e.globalAlpha=1,e.stroke(),e.beginPath(),e.moveTo(t.x+.5,t.y+dt+.5),e.lineTo(t.x+t.width-.5,t.y+dt+.5),e.stroke(),i&&(e.fillStyle=n.mn,e.font=`bold 10px ${n.fontFamily}`,e.textAlign="left",e.textBaseline="middle",e.fillText(_t(e,i,Math.max(0,t.width-16)),t.x+8,t.y+dt/2+.5)),e.restore(),{x:t.x+8,y:t.y+dt+4,width:Math.max(0,t.width-12),height:Math.max(0,t.height-dt-8)}}function Fo(e,t,n,i,r){if(i<=t.height)return;let o=t.x+t.width-Vi,s=Math.max(20,t.height/i*t.height),l=t.height-s,a=i-t.height,u=t.y+(a>0?n/a*l:0);e.save(),e.fillStyle=r.Qi,e.fillRect(o,t.y,Vi,t.height),e.fillStyle=r.mn,e.fillRect(o,u,Vi,s),e.restore()}function _t(e,t,n){if(n<=0)return"";if(e.measureText(t).width<=n)return t;let i=0,r=t.length;for(;i<r;){let o=Math.ceil((i+r)/2);e.measureText(t.slice(0,o)+"\\u2026").width<=n?i=o:r=o-1}return i>0?t.slice(0,i)+"\\u2026":"\\u2026"}function Yt(e,t,n,i,r,o,s){let l={x:t.e.x+t.e.width+12,y:t.margins.top+20,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};He(e,l,n,i,r,o,s&&{...s,sidebarGutter:t.margins.right})}function He(e,t,n,i,r,o=me,s){let l=e.getContext("2d");if(!l)return;let a=r.mn,u=r.Qi,m=r.fontFamily,f=s?.mode==="floating",c,p,b,g=t,x=16;f?(g=Yi(l,t,r,n.label,s?.opacity),c=g.x,p=g.y+4,b=Math.max(8,g.height-12)):(c=t.x,p=t.y,b=Math.min(120,t.height*.4),l.fillStyle=a,l.font=`9px ${m}`,l.textAlign="left",l.textBaseline="bottom",l.fillText(n.label,c,p-4));let h=n.max,y=n.min,_=l.createLinearGradient(0,p,0,p+b),C=16;for(let L=0;L<=C;L++){let T=L/C,w=h+T*(y-h),M=bt(w,n.min,n.max),D=Re(i,M);_.addColorStop(T,qm(D))}l.fillStyle=_,l.fillRect(c,p,x,b),l.strokeStyle=u,l.lineWidth=1,l.strokeRect(c,p,x,b),l.fillStyle=a,l.font=`10px ${m}`,l.textAlign="left",l.textBaseline="middle";let v=c+x+5,A=Math.max(0,g.x+g.width-v);if(l.fillText(_t(l,o(n.max),A),v,p+2),l.fillText(_t(l,o((n.min+n.max)/2),A),v,p+b/2),l.fillText(_t(l,o(n.min),A),v,p+b-2),n.min<0&&n.max>0){let L=(n.max-0)/(n.max-n.min),T=p+L*b;l.strokeStyle=a,l.lineWidth=1,l.beginPath(),l.moveTo(c+x,T),l.lineTo(c+x+4,T),l.stroke(),l.fillStyle=a,l.fillText("0",v,T)}s&&s.legend.setPainted({mode:s.mode,box:t,content:g,contentHeight:Math.min(g.height,b+8),sidebarGutter:s.sidebarGutter})}function zi(e,t,n,i,r,o){let s={x:t.e.x+t.e.width+12,y:t.margins.top+10,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};vt(e,s,n,i,r,o&&{...o,sidebarGutter:t.margins.right})}function vt(e,t,n,i,r,o){let s=e.getContext("2d");if(!s)return;if(n.size===0){o?.legend.clearPainted();return}let l=r.mn,a=r.fontFamily,u=o?.mode==="floating",m=t;u&&(m=Yi(s,t,r,o?.title??"Legend",o?.opacity));let f=10,c=So,p=n.size*c,b=o?o.legend.clampScroll(m.height,p):0,g=p>m.height,x=Math.max(0,m.width-f-6-(g?Vi+4:0));s.save(),s.beginPath(),s.rect(m.x,m.y,m.width,m.height),s.clip(),s.font=`11px ${a}`,s.textAlign="left",s.textBaseline="middle";let h=Math.floor(b/c),y=m.x,_=0,C=m.y+c/2+h*c-b;for(let[v,A]of n){if(_<h){_++;continue}if(C-c/2>=m.y+m.height)break;let L=i[A]??i[A%i.length]??[0,0,0];s.fillStyle=`rgb(${Math.round(L[0]*255)},${Math.round(L[1]*255)},${Math.round(L[2]*255)})`,s.fillRect(y,C-f/2,f,f),s.fillStyle=l,s.fillText(_t(s,v,x),y+f+6,C),C+=c,_++}s.restore(),Fo(s,m,b,p,r),o&&o.legend.setPainted({mode:o.mode,box:t,content:m,contentHeight:p,sidebarGutter:o.sidebarGutter})}var So,Vi,Tn=G(()=>{"use strict";Ae();Ne();de();So=18,Vi=4});function Qe(e){return isNaN(e)?0:e}function Ul(e,t){let n=t.gl,i=t.dpr,r=n.canvas.width/i,o=n.canvas.height/i;if(r<=0||o<=0)return;let s=e.A.length>0,l=e.W.facet_mode,a=s&&l==="grid";e.computeEffectiveFacetFlags();let u=e.s!==""&&e.b<e.p,m=a&&e.W.zoom_mode==="independent",f;if(e.h&&!m?f=e.h.getVisibleDomain():f={xMin:e.xe,xMax:e.it,yMin:e.Re,yMax:e.rt},!isFinite(f.xMin)||!isFinite(f.yMin))return;let c=e.T(),p=c.Ge,b=e.ze[e.ke]||"",g=e.ze[e.Se]||"",x=b==="date"||b==="datetime",h=g==="date"||g==="datetime",y=e.H,_=!y&&!e.s,C=c.k;if(y||_){let v=_?Math.max(1,e.A.length):Math.max(1,e.c.size);if(e.Li&&e.or===p&&e.sr===v)C=e.Li;else{let A=pe(p,c.k,v);C=Qs(A),e.Li=C,e.or=p,e.sr=v}}else e.Li=null,e.or=null,e.sr=-1;e.re=yn(t,e.re,C),a?Qm(e,t,f,c,{xIsDate:x,yIsDate:h,cssWidth:r,cssHeight:o}):(e.d=null,Jm(e,t,f,c,{xIsDate:x,yIsDate:h,cssWidth:r,cssHeight:o,hasColorCol:u})),e.he(()=>Ve(e))}function Xi(e,t,n,i){return{min:t,max:n,label:e.ke||(e.Qr?"Row":e.Je||""),isDate:i}}function $i(e,t,n,i){return{min:t,max:n,label:e.Se||e.Xe,isDate:i}}function ji(e,t){let n=0;for(let r of e)r.length>n&&(n=r.length);return{levels:[{labels:e.slice(),runs:[],maxLabelChars:n}],numRows:e.length,levelLabels:[t]}}function Km(e,t,n,i,r,o,s,l,a){if(e.Ne&&e.lt){let u=oe(t,a);u&&be(u,n,e.lt,l)}else Ei(t,i,n,o,l,!0,a,e.getColumnFormatter(e.Je,"tick"));if(e.ye&&e.ut){let u=oe(t,a);u&&Ie(u,n,e.ut,l)}else Pi(t,r,n,s,l,!0,a,e.getColumnFormatter(e.Xe,"tick"))}function Jm(e,t,n,i,r){let o=t.gl,{cssWidth:s,cssHeight:l,xIsDate:a,yIsDate:u,hasColorCol:m}=r;e.lt=e.Ne&&e.dn.length>0?ji(e.dn,e.ke||e.Je||""):null,e.ut=e.ye&&e.pn.length>0?ji(e.pn,e.Se||e.Xe||""):null;let f=Ze(e.i,m),c=55+(e.Se?16:0),p=Math.max(1,s-c-f),b=e.ut?Ht(e.ut):void 0,g=e.lt?Ue(e.lt,p):void 0,x=e.Pn==="map",h=x&&!e.i.numeric_axes,y=new ie(s,l,h?{hasXLabel:!1,hasYLabel:!1,hasLegend:m,leftExtra:0,bottomExtra:0,rightExtra:m&&e.i.legend_mode==="sidebar"?Le(e.i,80):0}:{hasXLabel:!!e.ke,hasYLabel:!!e.Se,hasLegend:m,leftExtra:b,bottomExtra:g,rightExtra:f});e.l=y,e.h&&e.h.updateLayout(y);let _=y.buildProjectionMatrix(n.xMin,n.xMax,n.yMin,n.yMax,void 0,void 0,void 0,Qe(e.S),Qe(e.F)),C=Xi(e,n.xMin,n.xMax,a),v=$i(e,n.yMin,n.yMax,u),A=Ot(C,v,y),L=e.Ne?[]:A.xTicks,T=e.ye?[]:A.yTicks,w=t.dpr,M=e.K;M&&!x?e.he(()=>{ue(M,y,w),Co(M,y,L,T,i,w)}):M&&x&&e.he(()=>ue(M,y,w)),Je(o,y,t.dpr,()=>{x&&e.renderBackground(t,y,_,n,Qe(e.S),Qe(e.F)),e.glyph.draw(e,t,_)}),e.ue=C,e.me=v,e.Ti=L,e.Fe=T,e.wi=i.k,e.Mi=m}function Qm(e,t,n,i,r){let o=t.gl,{cssWidth:s,cssHeight:l,xIsDate:a,yIsDate:u}=r;e.lt=e.Ne&&e.dn.length>0?ji(e.dn,e.ke||e.Je||""):null,e.ut=e.ye&&e.pn.length>0?ji(e.pn,e.Se||e.Xe||""):null;let m=e.A.map(M=>M.prefix),f=e.H&&e.c.size>1,c=!!e.s&&!e.H&&e.b<e.p,p=f||c,b=e.Pn==="map",g=b&&!e.i.numeric_axes,x=Fe(m,{cssWidth:s,cssHeight:l,xAxis:g?"none":e.ci?"outer":"cell",yAxis:g?"none":e.di?"outer":"cell",hasLegend:p&&e.i.legend_mode==="sidebar",legendWidth:Le(e.i,96),hasXLabel:!g&&!!e.ke,hasYLabel:!g&&!!e.Se,gap:e.W.facet_padding});if(e.d=x,x.cells.length>1){let M=x.cells[0].layout.e;for(let D=1;D<x.cells.length;D++){let I=x.cells[D].layout.e;if(I.width!==M.width||I.height!==M.height){console.warn(`facet-grid: cell ${D} size (${I.width}\\xD7${I.height}) differs from cell 0 (${M.width}\\xD7${M.height})`);break}}}e.l=x.cells[0]?.layout??null,e.syncFacetZoomLayouts(x.cells);let h=e.W.zoom_mode==="independent",y=Xi(e,n.xMin,n.xMax,a),_=$i(e,n.yMin,n.yMax,u),C=x.cells[0]?.layout,v=C?Ot(y,_,C):{xTicks:[],yTicks:[]},A=e.Ne?[]:v.xTicks,L=e.ye?[]:v.yTicks,T=t.dpr,w=e.K;w&&C&&e.he(()=>ue(w,C,T)),ht(o);for(let M=0;M<x.cells.length;M++){let D=x.cells[M],I=e.getZoomControllerForFacet(M),F=h&&I?I.getVisibleDomain():n,B=D.layout.buildProjectionMatrix(F.xMin,F.xMax,F.yMin,F.yMax,void 0,void 0,void 0,Qe(e.S),Qe(e.F));w&&!b&&e.he(()=>{let N=h?Ot(Xi(e,F.xMin,F.xMax,a),$i(e,F.yMin,F.yMax,u),D.layout).xTicks:A,k=h?Ot(Xi(e,F.xMin,F.xMax,a),$i(e,F.yMin,F.yMax,u),D.layout).yTicks:L;Co(w,D.layout,N,k,i,T)}),xt(o,D.layout,t.dpr,()=>{b&&e.renderBackground(t,D.layout,B,F,Qe(e.S),Qe(e.F)),e.glyph.drawSeries(e,t,B,M)})}e.ue=y,e.me=_,e.Ti=A,e.Fe=L,e.wi=i.k,e.Mi=p}function Ve(e){ef(e),e.presentOverlay()}function ef(e){!e.u||!e.l||!e.ue||!e.me||!e.t||(ue(e.u,e.l,e.t.dpr),e.d?nf(e):tf(e))}function tf(e){let t=e.l,n=e.T(),i=e.t?.dpr??1;if(e.Pn==="map"){if(e.i.numeric_axes){let l=Ni(t);Ei(e.u,e.ue,t,l.xTicks,n,!!e.ke,i,l.formatX),Pi(e.u,e.me,t,l.yTicks,n,!!e.Se,i,l.formatY)}e.renderMapChrome(e.u,t,n,i)}else Km(e,e.u,t,e.ue,e.me,e.Ti,e.Fe,n,i);let o=e.i.legend_mode,s=!1;if(e.Mi&&o!=="none"){let l=e.wi??n.k,a=o==="floating",u={mode:a?"floating":"sidebar",legend:e.R,title:e.s??void 0,opacity:e.i.legend_opacity},m=a?e.R.floatingBox(e.i,t.cssWidth,t.cssHeight):null;if(e.H&&e.c.size>0){let f=pe(n.Ge,l,e.c.size);m?vt(e.u,m,e.c,f,n,u):zi(e.u,t,e.c,f,n,u),s=!0}else if(e.s){let f={min:e.b,max:e.p,label:e.s},c=e.getColumnFormatter(e.s,"value");m?He(e.u,m,f,l,n,c,u):Yt(e.u,t,f,l,n,c,u),s=!0}}s||e.R.clearPainted(),Hl(e,e.u,t,0,1),e.fe>=0&&e.Y&&e.X&&sf(e,e.u,t)}function nf(e){let t=e.d,n=e.u,i=e.T(),r=e.t?.dpr??1,o=e.Ti,s=e.Fe,l=e.ue,a=e.me,u=e.Pn==="map",m=e.ci&&!e.Ne,f=e.di&&!e.ye,c=e.W.zoom_mode==="independent",p=u&&e.i.numeric_axes,b=p&&t.cells.length>0?Ni(t.cells[0].layout):null;u&&e.renderMapChrome(n,e.l,i,r),(!u||b)&&m&&t.outerXAxisRect&&Cn(n,t.outerXAxisRect,l,b?b.xTicks:o,bn(t),i,!!e.ke,r,b?b.formatX:e.getColumnFormatter(e.Je,"tick")),(!u||b)&&f&&t.outerYAxisRect&&_n(n,t.outerYAxisRect,a,b?b.yTicks:s,gn(t),i,!!e.Se,r,b?b.formatY:e.getColumnFormatter(e.Xe,"tick"));for(let _=0;_<t.cells.length;_++){let C=t.cells[_],v=c?e.getZoomControllerForFacet(_):null,A=v?v.getVisibleDomain():null,L=A?{...l,min:A.xMin,max:A.xMax}:l,T=A?{...a,min:A.yMin,max:A.yMax}:a,w=p?Ni(C.layout):null,M=w||(c?Ot(L,T,C.layout):{xTicks:o,yTicks:s});if((!u||w)&&!m)if(e.Ne&&e.lt){let D=oe(n,r);D&&be(D,C.layout,e.lt,i)}else Ei(n,L,C.layout,M.xTicks,i,!!e.ke,r,w?w.formatX:e.getColumnFormatter(e.Je,"tick"));if((!u||w)&&!f)if(e.ye&&e.ut){let D=oe(n,r);D&&Ie(D,C.layout,e.ut,i)}else Pi(n,T,C.layout,M.yTicks,i,!!e.Se,r,w?w.formatY:e.getColumnFormatter(e.Xe,"tick"));C.titleRect&&Pt(n,C.label,C.titleRect,i,r),Hl(e,n,C.layout,_,_+1)}let g=e.i.legend_mode,x=g==="floating",h=x?e.R.floatingBox(e.i,e.l.cssWidth,e.l.cssHeight):t.legendRect,y=!1;if(e.Mi&&g!=="none"&&h){let _=e.wi??i.k,C={mode:x?"floating":"sidebar",legend:e.R,title:e.s??void 0,sidebarGutter:x?void 0:t.legendRect?.width,opacity:e.i.legend_opacity};if(e.H&&e.c.size>0){let v=pe(i.Ge,_,Math.max(1,e.c.size));vt(n,h,e.c,v,i,C),y=!0}else e.s&&(He(n,x?h:{x:h.x,y:h.y+20,width:h.width,height:h.height-20},{min:e.b,max:e.p,label:e.s},_,i,e.getColumnFormatter(e.s,"value"),C),y=!0)}if(y||e.R.clearPainted(),e.fe>=0&&e.Y&&e.X){let _=isNaN(e.S)?0:e.S,C=isNaN(e.F)?0:e.F,v=e.Y[e.fe]+_,A=e.X[e.fe]+C,L=rf(e,e.fe),T=e.glyph.tooltipOptions(),w=e.N.lines??[];for(let M=0;M<t.cells.length;M++){let D=t.cells[M],I=M===L,F=D.layout.E(v,A),B=D.layout.e;if(F.px<B.x||F.px>B.x+B.width||F.py<B.y||F.py>B.y+B.height)continue;let N=e.W.coordinated_tooltip;ke(n,F,I||N?w:[],D.layout,i,r,{crosshair:T.crosshair,highlightRadius:I?T.highlightRadius:0})}}}function rf(e,t){return e.w<=0?0:Math.floor(t/e.w)}function Hl(e,t,n,i,r){if(!e.Ot||!e.Y||!e.X)return;let o=e.Ot.dictionary,s=e.Ot.data,l=e.Y,a=e.X,u=isNaN(e.S)?0:e.S,m=isNaN(e.F)?0:e.F,f=e.w;if(f<=0)return;let c=0;for(let y=i;y<r;y++)c+=e.V[y]??0;if(c===0)return;let p=e.t?.dpr??1,b=oe(t,p);if(!b)return;let g=e.T(),x=n.e,h=Math.max(1,Math.ceil(c/of));b.save(),b.font=`11px ${g.fontFamily}`,b.fillStyle=g.Me,b.textAlign="left",b.textBaseline="middle";for(let y=i;y<r;y++){let _=e.V[y]??0,C=y*f;for(let v=0;v<_;v+=h){let A=C+v,L=s[A];if(L<0)continue;let{px:T,py:w}=n.E(l[A]+u,a[A]+m);T<x.x||T>x.x+x.width||w<x.y||w>x.y+x.height||b.fillText(o[L],T+8,w-4)}}b.restore()}function sf(e,t,n){let i=e.fe;if(i<0||!e.Y||!e.X)return;let r=isNaN(e.S)?0:e.S,o=isNaN(e.F)?0:e.F,s=n.E(e.Y[i]+r,e.X[i]+o),l=e.N.lines??[],a=e.T();ke(t,s,l,n,a,e.t?.dpr??1,e.glyph.tooltipOptions())}var of,Io=G(()=>{"use strict";Fi();Ke();Gt();hn();de();xn();Wt();Bt();_o();yt();Il();Vt();Tn();Ne();of=5e3});function lf(e){if(!e.cn.isDirty||!e.Y||!e.X)return;let t=e.Y,n=e.X,i=Math.max(1,e.A.length),r=e.w,o=isNaN(e.S)?0:e.S,s=isNaN(e.F)?0:e.F;e.cn.rebuild({xMin:e.xe-o,xMax:e.it-o,yMin:e.Re-s,yMax:e.rt-s},e._t,l=>{for(let a=0;a<i;a++){let u=e.V[a]??0,m=a*r;for(let f=0;f<u;f++)l(m+f,t[m+f],n[m+f])}})}function Do(e,t,n){if(!e.Y||!e.X)return;let{layout:i,facetIdx:r}=af(e,t,n);if(!i){Vl(e);return}let o=i.e;if(t<o.x||t>o.x+o.width||n<o.y||n>o.y+o.height){Vl(e);return}let s=i.$,l=i.J,a=i.j,u=i.Q,m=s+(t-o.x)/o.width*(l-s),f=u-(n-o.y)/o.height*(u-a),c=o.width/(l-s),p=o.height/(u-a),b=isNaN(e.S)?0:e.S,g=isNaN(e.F)?0:e.F,x=m-b,h=f-g,y=r<0?uf(e,x,h,c,p):mf(e,r,x,h,c,p);if(y!==e.fe||r!==e.Gn){if(e.fe=y,e.Gn=r,y>=0){let _=e.N.beginHover(y);e.glyph.buildTooltipLines(e,y).then(C=>{e.N.commitHover(_,C)&&Ve(e)})}else e.N.clearHover();Ve(e)}}function Vl(e){(e.fe!==-1||e.Gn!==-1)&&(e.fe=-1,e.Gn=-1,Ve(e))}function af(e,t,n){if(e.d){let i=e.d.cells;for(let r=0;r<i.length;r++){let o=i[r].layout.e;if(t>=o.x&&t<=o.x+o.width&&n>=o.y&&n<=o.y+o.height)return{layout:i[r].layout,facetIdx:r}}return{layout:null,facetIdx:-1}}return{layout:e.l,facetIdx:-1}}function uf(e,t,n,i,r){lf(e);let o=e.cn.query(t,n,wn,i,r,e.Y,e.X);if(o>=0)return o;let s=wn*wn,l=Math.max(1,e.A.length),a=e.w,u=e.Y,m=e.X;for(let f=0;f<l;f++){let c=e.V[f]??0,p=f*a;for(let b=0;b<c;b++){let g=p+b,x=(u[g]-t)*i,h=(m[g]-n)*r,y=x*x+h*h;y<s&&(s=y,o=g)}}return o}function mf(e,t,n,i,r,o){let s=e.V[t]??0;if(s===0)return-1;let l=e.w,a=t*l,u=e.Y,m=e.X,f=wn*wn,c=-1;for(let p=0;p<s;p++){let b=a+p,g=(u[b]-n)*r,x=(m[b]-i)*o,h=g*g+x*x;h<f&&(f=h,c=b)}return c}function Yl(e,t){if(e.L.dismiss(),e.lr=t,t<0||!e.Y||!e.X)return;let n=ff(e,t);if(!n)return;let i=isNaN(e.S)?0:e.S,r=isNaN(e.F)?0:e.F,o=n.E(e.Y[t]+i,e.X[t]+r),s=e.N.beginPin();e.glyph.buildTooltipLines(e,t).then(l=>{e.N.isPinFresh(s)&&e.lr===t&&l.length!==0&&e.L.pin(l,o,n)}),e.fe=-1,e.Gn=-1,Ve(e)}function ff(e,t){if(e.d&&e.w>0){let n=Math.floor(t/e.w),i=e.d.cells[n];if(i)return i.layout}return e.l}function zl(e){e.L.dismiss(),e.lr=-1}var wn,Xl=G(()=>{"use strict";Io();wn=24});var zt,Bo=G(()=>{"use strict";zt=class{constructor(){d(this,"lines",null);d(this,"hoveredTarget",null);d(this,"ar",0);d(this,"ur",0)}beginHover(t){return this.lines=null,this.hoveredTarget=t,++this.ar}commitHover(t,n){return t!==this.ar?!1:(this.lines=n,!0)}clearHover(){this.lines=null,this.hoveredTarget=null,this.ar++}beginPin(){return++this.ur}isPinFresh(t){return t===this.ur}invalidatePin(){this.ur++}}});function j(e,t,n,i,r,o){let s=e.shaders.getOrCreate(t,n,i),l=e.gl,a={program:s};for(let u of r)a[u]=l.getUniformLocation(s,u);for(let u of o)a[u]=l.getAttribLocation(s,u);return a}var fe=G(()=>{"use strict"});async function Zi(e,t){let n=[];if(!e.Nt||!e.We)return n;let i=e.Nt[t];if(i<0)return n;if(e.A.length>0&&e.w>0){let s=Math.floor(t/e.w),l=e.A[s];l?.prefix&&n.push(l.prefix)}let r=await e.We.fetchRow(i),o=e.A.length>0&&e.w>0?e.A[Math.floor(t/e.w)]?.prefix??null:null;for(let[s,l]of r){if(l==null)continue;let a=s;if(o!==null){let u=`${o}|`;if(!s.startsWith(u))continue;a=s.substring(u.length)}else if(s.includes("|"))continue;if(typeof l=="number"){let u=e.getColumnFormatter(s,"value")(l);n.push(`${a}: ${u}`)}else n.push(`${a}: ${l}`)}return n}var Eo=G(()=>{"use strict"});function cf(e,t,n,i,r){if(t.uniformMatrix4fv(e.u_projection,!1,n),t.uniform1f(e.u_point_size,i.i.point_size_px*r),i.b>=i.p)t.uniform2f(e.u_color_range,0,0);else if(i.s&&!i.H){let[s,l]=Li(i.b,i.p);t.uniform2f(e.u_color_range,s,l)}else t.uniform2f(e.u_color_range,i.b,i.p);i.ot<i.st?t.uniform2f(e.u_size_range,i.ot,i.st):t.uniform2f(e.u_size_range,0,0);let o=Math.min(i.i.point_size_px,3);t.uniform2f(e.u_point_size_range,Math.max(2*r,i.i.point_size_px/o*r),i.i.point_size_px*o*r)}function $l(e,t,n,i){let r=n.gl;if(!t.re)return!1;r.useProgram(e.program),cf(e,r,i,t,n.dpr),Oe(n,t.re.texture,e.u_gradient_lut,0);let o=n.v.peek("a_position"),s=n.v.peek("a_color_value"),l=n.v.peek("a_size_value");return!o||!s||!l?!1:(r.bindBuffer(r.ARRAY_BUFFER,o.buffer),r.enableVertexAttribArray(e.a_position),r.vertexAttribPointer(e.a_position,2,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.enableVertexAttribArray(e.a_color_value),r.vertexAttribPointer(e.a_color_value,1,r.FLOAT,!1,0,0),r.bindBuffer(r.ARRAY_BUFFER,l.buffer),r.enableVertexAttribArray(e.a_size_value),r.vertexAttribPointer(e.a_size_value,1,r.FLOAT,!1,0,0),!0)}var Xt,Po=G(()=>{"use strict";Wt();de();fe();Eo();Qr();eo();Xt=class{constructor(){d(this,"name","point");d(this,"g",null)}ensureProgram(t,n){this.g||(this.g=j(n,"scatter",Xn,$n,["u_projection","u_point_size","u_color_range","u_gradient_lut","u_size_range","u_point_size_range"],["a_position","a_color_value","a_size_value"]))}draw(t,n,i){let r=this.g;if(!r||!$l(r,t,n,i))return;let o=n.gl,s=Math.max(1,t.A.length),l=t.w;for(let a=0;a<s;a++){let u=t.V[a]??0;u<=0||o.drawArrays(o.POINTS,a*l,u)}}drawSeries(t,n,i,r){let o=this.g;if(!o||!$l(o,t,n,i))return;let s=t.V[r]??0;if(s<=0)return;let l=n.gl,a=t.w;l.drawArrays(l.POINTS,r*a,s)}buildTooltipLines(t,n){return Zi(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:6}}destroy(t){this.g=null}}});function J(e){let t=e.gl;if(e.isWebGL2){let i=t;return{setDivisor(r,o){r<0||i.vertexAttribDivisor(r,o)},drawArraysInstanced(r,o,s,l){i.drawArraysInstanced(r,o,s,l)}}}let n=t.getExtension("ANGLE_instanced_arrays");return{setDivisor(i,r){i<0||n?.vertexAttribDivisorANGLE(i,r)},drawArraysInstanced(i,r,o,s){n?.drawArraysInstancedANGLE(i,r,o,s)}}}function et(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,1,2,3]),e.STATIC_DRAW),t}function qi(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),t}function tt(e,t,n,i,r,o=0){if(n<0)return!0;let s=e.v.peek(i);if(!s)return!1;let l=e.gl;return l.bindBuffer(l.ARRAY_BUFFER,s.buffer),l.enableVertexAttribArray(n),l.vertexAttribPointer(n,r,l.FLOAT,!1,0,o*r*Float32Array.BYTES_PER_ELEMENT),t.setDivisor(n,1),!0}var De=G(()=>{"use strict"});function jl(e,t,n,i){let r=n.gl;if(!t.re)return!1;let o=n.dpr;if(r.useProgram(e.program),r.uniformMatrix4fv(e.u_projection,!1,i),r.uniform2f(e.u_resolution,r.canvas.width,r.canvas.height),r.uniform1f(e.u_line_width,t.i.line_width_px*o),t.b>=t.p)r.uniform2f(e.u_color_range,0,0);else if(t.s&&!t.H){let[a,u]=Li(t.b,t.p);r.uniform2f(e.u_color_range,a,u)}else r.uniform2f(e.u_color_range,t.b,t.p);Oe(n,t.re.texture,e.u_gradient_lut,0);let s=J(n),{setDivisor:l}=s;return r.bindBuffer(r.ARRAY_BUFFER,e.cornerBuffer),r.enableVertexAttribArray(e.a_corner),r.vertexAttribPointer(e.a_corner,1,r.FLOAT,!1,0,0),l(e.a_corner,0),r.enableVertexAttribArray(e.a_start),l(e.a_start,1),r.enableVertexAttribArray(e.a_end),l(e.a_end,1),r.enableVertexAttribArray(e.a_color_start),l(e.a_color_start,1),r.enableVertexAttribArray(e.a_color_end),l(e.a_color_end,1),!0}function Zl(e,t,n,i){let r=t.V[i]??0;if(r<2)return;let o=n.gl,s=t.w,l=2*Float32Array.BYTES_PER_ELEMENT,a=Float32Array.BYTES_PER_ELEMENT,u=n.v.peek("a_position"),m=n.v.peek("a_color_value");if(!u||!m)return;let f=i*s*l;o.bindBuffer(o.ARRAY_BUFFER,u.buffer),o.vertexAttribPointer(e.a_start,2,o.FLOAT,!1,l,f),o.vertexAttribPointer(e.a_end,2,o.FLOAT,!1,l,f+l);let c=i*s*a;o.bindBuffer(o.ARRAY_BUFFER,m.buffer),o.vertexAttribPointer(e.a_color_start,1,o.FLOAT,!1,a,c),o.vertexAttribPointer(e.a_color_end,1,o.FLOAT,!1,a,c+a),J(n).drawArraysInstanced(o.TRIANGLE_STRIP,0,4,r-1)}function ql(e,t){let{setDivisor:n}=J(t);n(e.a_start,0),n(e.a_end,0),n(e.a_color_start,0),n(e.a_color_end,0)}var $t,Go=G(()=>{"use strict";Wt();De();fe();de();Ae();Kr();Jr();$t=class{constructor(){d(this,"name","line");d(this,"g",null)}ensureProgram(t,n){if(this.g)return;let i=j(n,"line",Yn,zn,["u_projection","u_resolution","u_line_width","u_color_range","u_gradient_lut"],["a_start","a_end","a_color_start","a_color_end","a_corner"]);this.g={...i,cornerBuffer:et(n.gl)}}draw(t,n,i){let r=this.g;if(!r||!jl(r,t,n,i))return;let s=Math.max(1,t.A.length);for(let l=0;l<s;l++)Zl(r,t,n,l);ql(r,n)}drawSeries(t,n,i,r){let o=this.g;o&&jl(o,t,n,i)&&(Zl(o,t,n,r),ql(o,n))}async buildTooltipLines(t,n){let i=[];if(!t.Y||!t.X)return i;if(t.A.length>0&&t.w>0){let c=Math.floor(n/t.w),p=t.A[c];p&&i.push(p.prefix)}let r=t.Y[n],o=t.X[n],s=t.ze[t.ke]||"",a=s==="date"||s==="datetime"?ve(r):me(r);i.push(`${t.ke||"Row"}: ${a}`);let u=t.ze[t.Se]||"",f=u==="date"||u==="datetime"?ve(o):me(o);return i.push(`${t.Se}: ${f}`),i}tooltipOptions(){return{crosshair:!0,highlightRadius:5}}destroy(t){let n=this.g;n?.cornerBuffer&&t.t&&t.t.gl.deleteBuffer(n.cornerBuffer),this.g=null}}});function hf(e){switch(e){case"density":return df;case"extreme":return bf;case"signed":return gf;case"mean":default:return pf}}function Kl(e){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function Wo(e,t,n,i){return j(e,t,n,i,["u_projection","u_radius_ndc","u_intensity","u_color_range"],["a_corner","a_position","a_color_value"])}function xf(e){let t=e.gl;if(e.isWebGL2){let n=t;if(n.getExtension("EXT_color_buffer_float"))return{internalFormat:n.RGBA16F,format:n.RGBA,type:n.HALF_FLOAT,isFloat:!0}}return{internalFormat:t.RGBA,format:t.RGBA,type:t.UNSIGNED_BYTE,isFloat:!1}}function Jl(e){let t=e.v.peek("a_position"),n=e.v.peek("a_color_value");return!!t&&!!n}function Cf(e,t){if(!e.s||e.H)return t.robustBounds=null,null;let n=t.robustBounds;if(n&&n.dataCount===e._t&&n.colorName===e.s&&n.colorIsString===e.H)return{lo:n.lo,hi:n.hi};let i=_f(e);return i?(t.robustBounds={lo:i.lo,hi:i.hi,dataCount:e._t,colorName:e.s,colorIsString:e.H},i):(t.robustBounds=null,null)}function _f(e){if(!e.vt||e._t<2)return null;let t=e.w,n=Math.max(1,e.A.length),i=Math.max(1,Math.ceil(e._t/yf)),r=[],o=e.vt;for(let m=0;m<n;m++){let f=e.V[m]??0,c=m*t;for(let p=0;p<f;p+=i){let b=o[c+p];Number.isFinite(b)&&r.push(b)}}if(r.length<2)return null;r.sort((m,f)=>m-f);let s=Math.floor(r.length*.05),l=Math.min(r.length-1,Math.ceil(r.length*.95)),a=r[s],u=r[l];return u>a?{lo:a,hi:u}:e.p>e.b?{lo:e.b,hi:e.p}:null}var df,pf,bf,gf,jt,yf,ko=G(()=>{"use strict";Wt();De();fe();Eo();to();no();io();Ms();Ss();ro();oo();df=0,pf=1,bf=2,gf=3,jt=class{constructor(){d(this,"name","density");d(this,"g",null)}ensureProgram(t,n){if(this.g){this.ensureHeatTarget(t,n);return}let i=n.gl,r=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),i.STATIC_DRAW);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),i.STATIC_DRAW);let{internalFormat:s,format:l,type:a,isFloat:u}=xf(n),m=Kl(i),f=i.createFramebuffer();this.g={splat:Wo(n,"density-splat",Ft,si),extremeSplat:null,mrtSplat:null,resolve:j(n,"density-resolve",ai,ui,["u_heat","u_extreme","u_gradient_lut","u_heat_max","u_color_mode"],["a_corner"]),quadCornerBuffer:r,tripleCornerBuffer:o,heatTexture:m,heatFramebuffer:f,extremeTexture:null,extremeFramebuffer:null,mrtFramebuffer:null,heatWidth:0,heatHeight:0,heatType:a,heatInternalFormat:s,heatFormat:l,floatFbo:u,indexedBlend:null,signedDowngradeWarned:!1,robustBounds:null},this.ensureHeatTarget(t,n)}draw(t,n,i){let r=this.g;if(!r||!Jl(n))return;let o=Math.max(1,t.A.length),s=t.w,l=0;for(let a=0;a<o;a++)l+=t.V[a]??0;l!==0&&this.runSplatAndResolve(t,n,r,i,a=>{for(let u=0;u<o;u++){let m=t.V[u]??0;m<=0||a(u*s,m)}})}drawSeries(t,n,i,r){let o=this.g;if(!o||!Jl(n))return;let s=t.V[r]??0;if(s<=0)return;let l=t.w;this.runSplatAndResolve(t,n,o,i,a=>a(r*l,s))}buildTooltipLines(t,n){return Zi(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:0}}destroy(t){let n=this.g;if(!n||!t.t){this.g=null;return}let i=t.t.gl;i.deleteBuffer(n.quadCornerBuffer),i.deleteBuffer(n.tripleCornerBuffer),i.deleteTexture(n.heatTexture),i.deleteFramebuffer(n.heatFramebuffer),n.extremeTexture&&i.deleteTexture(n.extremeTexture),n.extremeFramebuffer&&i.deleteFramebuffer(n.extremeFramebuffer),n.mrtFramebuffer&&i.deleteFramebuffer(n.mrtFramebuffer),this.g=null}ensureHeatTarget(t,n){let i=this.g;if(!i)return;let r=n.gl,o=r.canvas.width,s=r.canvas.height;if(!(o===i.heatWidth&&s===i.heatHeight)&&!(o<=0||s<=0)){if(this.allocAccumTexture(r,i,i.heatTexture,o,s),r.bindFramebuffer(r.FRAMEBUFFER,i.heatFramebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i.heatTexture,0),i.extremeTexture&&(this.allocAccumTexture(r,i,i.extremeTexture,o,s),i.extremeFramebuffer&&(r.bindFramebuffer(r.FRAMEBUFFER,i.extremeFramebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,i.extremeTexture,0)),i.mrtFramebuffer)){let l=r;l.bindFramebuffer(l.FRAMEBUFFER,i.mrtFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,i.heatTexture,0),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT1,l.TEXTURE_2D,i.extremeTexture,0)}r.bindFramebuffer(r.FRAMEBUFFER,null),i.heatWidth=o,i.heatHeight=s}}allocAccumTexture(t,n,i,r,o){t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,n.heatInternalFormat,r,o,0,n.heatFormat,n.heatType,null)}ensureExtremeTarget(t,n){let i=t.gl;if(n.extremeTexture)return;let r=Kl(i);if(n.extremeTexture=r,n.extremeFramebuffer=i.createFramebuffer(),this.allocAccumTexture(i,n,r,n.heatWidth,n.heatHeight),i.bindFramebuffer(i.FRAMEBUFFER,n.extremeFramebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,r,0),n.indexedBlend===null){let o=t.isWebGL2?i.getExtension("OES_draw_buffers_indexed"):null;n.indexedBlend=o??!1}if(n.indexedBlend){let o=i;n.mrtFramebuffer=o.createFramebuffer(),o.bindFramebuffer(o.FRAMEBUFFER,n.mrtFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,n.heatTexture,0),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT1,o.TEXTURE_2D,r,0)}i.bindFramebuffer(i.FRAMEBUFFER,null)}ensureExtremeSplatProgram(t,n){return n.extremeSplat||(n.extremeSplat=Wo(t,"density-extreme",Ft,li)),n.extremeSplat}ensureMrtSplatProgram(t,n){return n.mrtSplat||(n.mrtSplat=Wo(t,"density-mrt",Rs,Fs)),n.mrtSplat}activeMode(t,n,i){let r=n.i.gradient_color_mode;return r==="signed"&&!i.floatFbo?(this.warnDowngradeOnce(i,"signed mode requires a float framebuffer (EXT_color_buffer_float); falling back to mean."),"mean"):r==="extreme"&&!t.isWebGL2?(this.warnDowngradeOnce(i,"extreme mode requires WebGL2 (for MAX blend and a second color attachment); falling back to mean."),"mean"):r}warnDowngradeOnce(t,n){t.signedDowngradeWarned||(t.signedDowngradeWarned=!0,console.warn(`Density: ${n}`))}runSplatAndResolve(t,n,i,r,o){if(this.ensureHeatTarget(t,n),i.heatWidth===0||i.heatHeight===0||!t.re)return;let s=this.activeMode(n,t,i),l=t.b<t.p&&(!!t.s||t.A.length>1),a=0,u=0;if(s!=="density"&&l&&(a=t.b,u=t.p,!t.H&&(s==="mean"||s==="extreme"))){let f=Cf(t,i);f&&(a=f.lo,u=f.hi)}s==="extreme"&&this.ensureExtremeTarget(n,i),s==="extreme"&&i.indexedBlend?this.runMrtExtremePass(n,i,r,t.i.gradient_intensity,n.dpr*t.i.gradient_radius_px,a,u,o):(this.runHeatPass(n,i,r,t.i.gradient_intensity,n.dpr*t.i.gradient_radius_px,a,u,o),s==="extreme"&&this.runExtremePass(n,i,r,t.i.gradient_intensity,n.dpr*t.i.gradient_radius_px,a,u,o)),this.runResolvePass(n,i,t,s)}runHeatPass(t,n,i,r,o,s,l,a){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST);u.bindFramebuffer(u.FRAMEBUFFER,n.heatFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE),u.blendEquation(u.FUNC_ADD),this.bindSplatProgram(u,n.splat,i,r,o,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,n.splat,a),this.unbindSplatInstancing(t,n.splat)}runExtremePass(t,n,i,r,o,s,l,a){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST),f=this.ensureExtremeSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.extremeFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE);let c=u;c.blendEquation(c.MAX),this.bindSplatProgram(u,f,i,r,o,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,f,a),this.unbindSplatInstancing(t,f),u.blendEquation(u.FUNC_ADD)}runMrtExtremePass(t,n,i,r,o,s,l,a){let u=t.gl,m=n.indexedBlend,f=!!u.getParameter(u.SCISSOR_TEST),c=this.ensureMrtSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.mrtFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),u.drawBuffers([u.COLOR_ATTACHMENT0,u.COLOR_ATTACHMENT1]),this.clearTarget(u,f),m.enableiOES(u.BLEND,0),m.enableiOES(u.BLEND,1),m.blendEquationiOES(0,u.FUNC_ADD),m.blendFunciOES(0,u.ONE,u.ONE),m.blendEquationiOES(1,u.MAX),m.blendFunciOES(1,u.ONE,u.ONE),this.bindSplatProgram(u,c,i,r,o,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,c,a),this.unbindSplatInstancing(t,c),m.blendEquationiOES(0,u.FUNC_ADD),m.blendEquationiOES(1,u.FUNC_ADD),m.blendFunciOES(0,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),m.blendFunciOES(1,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawBuffers([u.COLOR_ATTACHMENT0])}clearTarget(t,n){n&&t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),n&&t.enable(t.SCISSOR_TEST)}bindSplatProgram(t,n,i,r,o,s,l,a,u){t.useProgram(n.program),t.uniformMatrix4fv(n.u_projection,!1,i),t.uniform1f(n.u_intensity,r);let m=2*o/Math.max(1,s),f=2*o/Math.max(1,l);t.uniform2f(n.u_radius_ndc,m,f),t.uniform2f(n.u_color_range,a,u)}bindAndDispatchInstanced(t,n,i,r){let o=t.gl;o.bindBuffer(o.ARRAY_BUFFER,n.quadCornerBuffer),o.enableVertexAttribArray(i.a_corner),o.vertexAttribPointer(i.a_corner,2,o.FLOAT,!1,0,0);let s=J(t);s.setDivisor(i.a_corner,0),s.setDivisor(i.a_position,1),s.setDivisor(i.a_color_value,1);let l=t.v.peek("a_position"),a=t.v.peek("a_color_value");r((u,m)=>{let f=2*Float32Array.BYTES_PER_ELEMENT,c=Float32Array.BYTES_PER_ELEMENT;o.bindBuffer(o.ARRAY_BUFFER,l.buffer),o.enableVertexAttribArray(i.a_position),o.vertexAttribPointer(i.a_position,2,o.FLOAT,!1,f,u*f),o.bindBuffer(o.ARRAY_BUFFER,a.buffer),o.enableVertexAttribArray(i.a_color_value),o.vertexAttribPointer(i.a_color_value,1,o.FLOAT,!1,c,u*c),s.drawArraysInstanced(o.TRIANGLE_STRIP,0,4,m)})}unbindSplatInstancing(t,n){let i=J(t);i.setDivisor(n.a_position,0),i.setDivisor(n.a_color_value,0)}runResolvePass(t,n,i,r){let o=t.gl;o.bindFramebuffer(o.FRAMEBUFFER,null),o.viewport(0,0,o.canvas.width,o.canvas.height),o.blendEquation(o.FUNC_ADD),o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);let s=n.resolve;o.useProgram(s.program),o.uniform1f(s.u_heat_max,i.i.gradient_heat_max),o.uniform1i(s.u_color_mode,hf(r)),o.activeTexture(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,n.heatTexture),o.uniform1i(s.u_heat,0),o.activeTexture(o.TEXTURE1),o.bindTexture(o.TEXTURE_2D,n.extremeTexture??n.heatTexture),o.uniform1i(s.u_extreme,1),Oe(t,i.re.texture,s.u_gradient_lut,2),o.bindBuffer(o.ARRAY_BUFFER,n.tripleCornerBuffer),o.enableVertexAttribArray(s.a_corner),o.vertexAttribPointer(s.a_corner,2,o.FLOAT,!1,0,0),o.drawArrays(o.TRIANGLES,0,3)}};yf=5e4});var At,Ki,Ji,Qi,No=G(()=>{"use strict";dn();pl();yl();Io();Xl();Bo();Po();Go();ko();At=class extends Se{constructor(n){super();d(this,"glyph");d(this,"Pn","cartesian");d(this,"re",null);d(this,"Je","");d(this,"Xe","");d(this,"ke","");d(this,"Se","");d(this,"Qr",!1);d(this,"s","");d(this,"ie","");d(this,"Ai","");d(this,"H",!1);d(this,"Ne",!1);d(this,"ye",!1);d(this,"dn",[]);d(this,"pn",[]);d(this,"eo",new Map);d(this,"to",new Map);d(this,"lt",null);d(this,"ut",null);d(this,"A",[]);d(this,"xe",1/0);d(this,"it",-1/0);d(this,"Re",1/0);d(this,"rt",-1/0);d(this,"S",NaN);d(this,"F",NaN);d(this,"b",1/0);d(this,"p",-1/0);d(this,"ot",1/0);d(this,"st",-1/0);d(this,"In",1/0);d(this,"Dn",-1/0);d(this,"Bn",1/0);d(this,"En",-1/0);d(this,"yi",1/0);d(this,"Ci",-1/0);d(this,"_i",1/0);d(this,"vi",-1/0);d(this,"w",0);d(this,"V",[]);d(this,"tr",0);d(this,"Y",null);d(this,"X",null);d(this,"vt",null);d(this,"Nt",null);d(this,"Ot",null);d(this,"_t",0);d(this,"c",new Map);d(this,"N",new zt);d(this,"nr",null);d(this,"ir",null);d(this,"rr",null);d(this,"no",0);d(this,"cn",new Ri);d(this,"l",null);d(this,"fe",-1);d(this,"lr",-1);d(this,"Gn",-1);d(this,"d",null);d(this,"ue",null);d(this,"me",null);d(this,"Ti",null);d(this,"Fe",null);d(this,"wi",null);d(this,"Mi",!1);d(this,"Li",null);d(this,"or",null);d(this,"sr",-1);this.glyph=n}colorScaleColumn(){return this.s||null}repaintChrome(){Ve(this)}projectPoint(n,i){return[n,i]}renderBackground(n,i,r,o,s,l){}renderMapChrome(n,i,r,o){}tooltipCallbacks(){return{onHover:(n,i)=>Do(this,n,i),onLeave:()=>{this.fe!==-1&&(this.fe=-1,Ve(this))},onPin:(n,i)=>{if(Do(this,n,i),this.fe>=0){let r=this.fe;Yl(this,r),this.Fo(r)}},onUnpin:()=>{this.emitUnselect()}}}async Fo(n){if(!this.Nt)return;let i=this.Nt[n],r=this.M[1]||this.M[0]||"",o=[];if(this.A.length>0&&this.w>0){let s=Math.floor(n/this.w),l=this.A[s];l?.prefix&&this.B.length>0&&(o=l.prefix.split("|"))}await this.emitClickAndSelect({rowIdx:i!=null&&i>=0?i:null,columnName:r,groupByValues:[],splitByValues:o})}async uploadAndRender(n,i,r,o){let s=o-r;this.t=n,r===0&&hl(this,n,i,o),s!==0&&(xl(this,n,i,r,s,o),this.i.domain_mode==="expand"&&(this.Ne||(this.In=this.xe,this.Dn=this.it),this.ye||(this.Bn=this.Re,this.En=this.rt),this.yi=this.b,this.Ci=this.p,this._i=this.ot,this.vi=this.st),await this.requestRender(n))}resetExpandedDomain(){this.In=1/0,this.Dn=-1/0,this.Bn=1/0,this.En=-1/0,this.yi=1/0,this.Ci=-1/0,this._i=1/0,this.vi=-1/0}Wt(n){n.uploadedCount===0&&this._t===0||(this.t=n,Ul(this,n))}destroyInternal(){this.glyph.destroy(this),this.re=null,this.Y=null,this.X=null,this.vt=null,this.Nt=null,this.Ot=null,this.N.clearHover(),this.c.clear(),this.cn.clear(),this.nr=null,this.ir=null,this.rr=null,this.A=[],this.V=[],zl(this)}},Ki=class extends At{constructor(){super(new Xt)}},Ji=class extends At{constructor(){super(new $t)}},Qi=class extends At{constructor(){super(new jt)}}});var Vr,bu=G(()=>{"use strict";Vr=class{constructor(t=256){d(this,"Le",new Map);d(this,"bo");this.bo=t}get(t){let n=this.Le.get(t);return n!==void 0&&(this.Le.delete(t),this.Le.set(t,n)),n}set(t,n,i){if(this.Le.has(n)){let r=this.Le.get(n);t.deleteTexture(r),this.Le.delete(n)}for(this.Le.set(n,i);this.Le.size>this.bo;){let r=this.Le.keys().next().value;if(r===void 0)break;let o=this.Le.get(r);t.deleteTexture(o),this.Le.delete(r)}}has(t){return this.Le.has(t)}dispose(t){for(let n of this.Le.values())t.deleteTexture(n);this.Le.clear()}}});function nn(e,t,n,i){return`${e}/${t}/${n}/${i}`}var Yr,gu=G(()=>{"use strict";Yr=class{constructor(){d(this,"Te",new Map);d(this,"go",()=>{})}setOnLoad(t){this.go=t}load(t,n,i,r){let o=nn(t.id,n,i,r),s=this.Te.get(o);if(s)return s.promise;let l=new AbortController,a=t.urlFor(n,i,r),u=this.Bo(a,l.signal).then(m=>(this.Te.delete(o),m&&this.go(),m)).catch(()=>(this.Te.delete(o),null));return this.Te.set(o,{promise:u,abort:l}),u}cancelAll(){for(let t of this.Te.values())t.abort.abort();this.Te.clear()}cancelExcept(t){for(let[n,i]of this.Te)t.has(n)||(i.abort.abort(),this.Te.delete(n))}async Bo(t,n){let i=self.origin?.startsWith("http")?`${self.origin}/`:void 0,r=await fetch(t,{signal:n,referrer:i});if(!r.ok)return null;let o=await r.blob();return await createImageBitmap(o)}}});var zr,hu=G(()=>{"use strict";ki();bu();gu();so();lo();fe();zr=class{constructor(){d(this,"r",null);d(this,"O",null);d(this,"g",new Vr);d(this,"Jn",new Yr);d(this,"Qn",null);d(this,"ho",1);d(this,"xo",()=>{})}setOnTileLoad(t){this.xo=t,this.Jn.setOnLoad(t)}setSource(t,n){this.Qn?.id!==n.id&&(this.g.dispose(t),this.Jn.cancelAll(),this.Qn=n)}setAlpha(t){this.ho=Math.max(0,Math.min(1,t))}get source(){return this.Qn}render(t,n,i,r,o,s){let l=this.Qn;if(!l)return;this.Eo(t);let a=this.r,u=this.O;if(!a||!u)return;let m=t.gl,f=t.dpr,c=Math.max(1,n.e.width*f),p=r.xMax-r.xMin;if(!isFinite(p)||p<=0)return;let b=p/c,g=Tl(b,l.tileSize,l.maxZoom),x=wl(r,g),h=new Set;for(let _ of x)h.add(nn(l.id,_.z,_.x,_.y));this.Jn.cancelExcept(h),m.useProgram(a.program),m.uniformMatrix4fv(a.u_projection,!1,i),m.uniform1f(a.u_alpha,this.ho),m.bindBuffer(m.ARRAY_BUFFER,u),m.enableVertexAttribArray(a.a_corner),m.vertexAttribPointer(a.a_corner,2,m.FLOAT,!1,0,0),m.activeTexture(m.TEXTURE0),m.uniform1i(a.u_tile,0);let y=m.isEnabled(m.BLEND);m.enable(m.BLEND),m.blendFunc(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA);for(let _ of x)this.Po(m,a,l,_,o,s);y||m.disable(m.BLEND)}destroy(t){this.Jn.cancelAll(),this.g.dispose(t),this.O&&(t.deleteBuffer(this.O),this.O=null),this.r=null}Po(t,n,i,r,o,s){let l=Ll(r.z,r.x,r.y),a={xMin:l.xMin-o,xMax:l.xMax-o,yMin:l.yMin-s,yMax:l.yMax-s},u=nn(i.id,r.z,r.x,r.y),m=this.g.get(u);if(m){this.yo(t,n,m,a,[0,0],[1,1]);return}this.Go(t,i,r);for(let f=1;f<=6;f++){let c=r.z-f;if(c<0)return;let p=r.x>>f,b=r.y>>f,g=nn(i.id,c,p,b),x=this.g.get(g);if(!x)continue;let h=1<<f,y=r.x-p*h,_=r.y-b*h,C=1/h,v=[y*C,_*C],A=[v[0]+C,v[1]+C];this.yo(t,n,x,a,v,A);return}}yo(t,n,i,r,o,s){t.bindTexture(t.TEXTURE_2D,i),t.uniform2f(n.u_extent_min,r.xMin,r.yMin),t.uniform2f(n.u_extent_max,r.xMax,r.yMax),t.uniform2f(n.u_uv_min,o[0],o[1]),t.uniform2f(n.u_uv_max,s[0],s[1]),t.drawArrays(t.TRIANGLE_STRIP,0,4)}Go(t,n,i){let r=nn(n.id,i.z,i.x,i.y);this.g.has(r)||this.Jn.load(n,i.z,i.x,i.y).then(o=>{if(!o)return;if(this.Qn?.id!==n.id){o.close();return}let s=t.createTexture();if(!s){o.close();return}t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o),this.g.set(t,r,s),this.xo()})}Eo(t){if(this.r&&this.O)return;let n=t.gl;this.r=j(t,"map-tile",mi,fi,["u_projection","u_extent_min","u_extent_max","u_uv_min","u_uv_max","u_tile","u_alpha"],["a_corner"]);let i=n.createBuffer();i&&(n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),this.O=i)}}});var Xr={};Eu(Xr,{MapChart:()=>rn,MapDensityChart:()=>Cs,MapLineChart:()=>ys,MapScatterChart:()=>xs});var rn,xs,ys,Cs,$r=G(()=>{"use strict";No();Po();Go();ko();hu();gi();ki();yt();rn=class extends At{constructor(n){super(n);d(this,"Pn","map");d(this,"tt");this.tt=new zr,this.tt.setOnTileLoad(()=>{this.t&&this.requestRender(this.t)})}projectPoint(n,i){return Gi(n,i)}getZoomConfig(){return{lockAspect:!0}}setPluginConfig(n){super.setPluginConfig(n),this.t&&this.tt.setSource(this.t.gl,je.sourceFor(n.map_tile_provider)),this.tt.setAlpha(n.map_tile_alpha)}renderBackground(n,i,r,o,s,l){this.tt.source||(this.tt.setSource(n.gl,je.sourceFor(this.i.map_tile_provider)),this.tt.setAlpha(this.i.map_tile_alpha)),this.tt.render(n,i,r,o,s,l)}renderMapChrome(n,i,r,o){if(!n)return;let s=oe(n,o);if(!s)return;let l=this.tt.source?.attribution??"";if(!l)return;let a=i.e;s.save(),s.font=`10px ${r.fontFamily}`,s.textAlign="right",s.textBaseline="bottom";let u=4,f=s.measureText(l).width,c=12,p=a.x+a.width-4,b=a.y+a.height-4;s.fillStyle="rgba(255, 255, 255, 0.75)",s.fillRect(p-f-u*2,b-c-u,f+u*2,c+u),s.fillStyle=r.Me,s.fillText(l,p-u,b-u/2),s.restore()}destroyInternal(){this.t&&this.tt.destroy(this.t.gl),super.destroyInternal()}},xs=class extends rn{constructor(){super(new Xt)}},ys=class extends rn{constructor(){super(new $t)}},Cs=class extends rn{constructor(){super(new jt)}}});typeof window>"u"&&(globalThis.window={});var un=class{constructor(t){d(this,"gt");d(this,"o",new Map);d(this,"vn",0);d(this,"ei",0);this.gt=t}get totalCapacity(){return this.vn}get maxCapacity(){return this.ei}set maxCapacity(t){this.ei=t}ensureCapacity(t){this.vn=this.ei>0?Math.min(t,this.ei):t}peek(t){return this.o.get(t)}getOrCreate(t,n,i){let r=this.vn*n*i,o=this.o.get(t);if(o&&o.byteCapacity>=r)return o;let s=this.gt;o&&s.deleteBuffer(o.buffer);let l=s.createBuffer();return s.bindBuffer(s.ARRAY_BUFFER,l),s.bufferData(s.ARRAY_BUFFER,r,s.DYNAMIC_DRAW),o={buffer:l,byteCapacity:r},this.o.set(t,o),o}upload(t,n,i,r=1){let o=this.gt,s=this.getOrCreate(t,r,n.BYTES_PER_ELEMENT);if(!1){let l=i+n.byteLength;if(l>s.byteCapacity)throw new Error(`BufferPool.upload("${t}"): write ${i}..${l} exceeds capacity ${s.byteCapacity} (_totalCapacity=${this.vn}, components=${r}, bytes=${n.BYTES_PER_ELEMENT}). Did you pass the full scratch buffer instead of a subarray(0, n)?`)}return o.bindBuffer(o.ARRAY_BUFFER,s.buffer),o.bufferSubData(o.ARRAY_BUFFER,i,n),s.buffer}releaseAll(){for(let t of this.o.values())this.gt.deleteBuffer(t.buffer);this.o.clear(),this.vn=0}};var mn=class{constructor(t){d(this,"gt");d(this,"ti",new Map);this.gt=t}precompile(t){for(let n of t)this.getOrCreate(n.name,n.vert,n.frag)}getOrCreate(t,n,i){let r=this.ti.get(t);if(r)return r;let o=this.gt,s=o.createShader(o.VERTEX_SHADER);if(o.shaderSource(s,n),o.compileShader(s),!o.getShaderParameter(s,o.COMPILE_STATUS)){let a=o.getShaderInfoLog(s);throw o.deleteShader(s),new Error(`Vertex shader compile error [${t}]: ${a}`)}let l=o.createShader(o.FRAGMENT_SHADER);if(o.shaderSource(l,i),o.compileShader(l),!o.getShaderParameter(l,o.COMPILE_STATUS)){let a=o.getShaderInfoLog(l);throw o.deleteShader(s),o.deleteShader(l),new Error(`Fragment shader compile error [${t}]: ${a}`)}if(r=o.createProgram(),o.attachShader(r,s),o.attachShader(r,l),o.linkProgram(r),!o.getProgramParameter(r,o.LINK_STATUS)){let a=o.getProgramInfoLog(r);throw o.deleteProgram(r),o.deleteShader(s),o.deleteShader(l),new Error(`Shader link error [${t}]: ${a}`)}return o.deleteShader(s),o.deleteShader(l),this.ti.set(t,r),r}releaseAll(){for(let t of this.ti.values())this.gt.deleteProgram(t);this.ti.clear()}};var Hn="attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;attribute float a_series_id;attribute float a_axis;uniform mat4 u_proj_left;uniform mat4 u_proj_right;uniform float u_hover_series;uniform float u_horizontal;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec2 A;if(u_horizontal>0.5){A=vec2(mix(a_y0,a_y1,a_corner.x),a_x_center+(a_corner.y-0.5)*2.*a_half_width);}else{A=vec2(a_x_center+(a_corner.x-0.5)*2.*a_half_width,mix(a_y0,a_y1,a_corner.y));}mat4 B=a_axis<0.5?u_proj_left:u_proj_right;gl_Position=B*vec4(A,0.,1.);v_color=a_color;v_hover=abs(a_series_id-u_hover_series)<0.5?1.:0.;v_local=a_corner;}";var Vn="precision highp float;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec3 A=v_color;if(v_hover>0.5){A=mix(A,vec3(1.),0.25);}gl_FragColor=vec4(A,1.);}";Kr();Jr();Qr();eo();var jn="attribute vec2 a_position;uniform mat4 u_projection;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);}";var Zn="precision highp float;uniform vec3 u_color;uniform float u_opacity;void main(){gl_FragColor=vec4(u_color,u_opacity);}";var Xe="attribute vec2 a_start;attribute vec2 a_end;attribute float a_corner;attribute float a_real_start;attribute float a_real_end;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform float u_interp_alpha;varying float v_edge_dist;varying float v_seg_alpha;void main(){vec4 A=u_projection*vec4(a_start,0.,1.);vec4 B=u_projection*vec4(a_end,0.,1.);vec2 C=A.xy*u_resolution*0.5;vec2 D=B.xy*u_resolution*0.5;vec2 E=D-C;float F=length(E);E=F>0.001?E/F:vec2(1.,0.);vec2 G=vec2(-E.y,E.x);float H=step(1.5,a_corner);float I=1.-mod(a_corner,2.)*2.;vec4 J=mix(A,B,H);float K=(u_line_width+1.5)*0.5;vec2 L=(G*I*K)/(u_resolution*0.5);gl_Position=J+vec4(L,0.,0.);v_edge_dist=I;float M=a_real_start*a_real_end;v_seg_alpha=mix(u_interp_alpha,1.,step(0.5,M));}";var $e="precision highp float;uniform vec4 u_color;uniform float u_line_width;varying float v_edge_dist;varying float v_seg_alpha;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(u_color.rgb,u_color.a*C*v_seg_alpha);}";var qn="attribute vec2 a_position;attribute vec3 a_color;uniform mat4 u_projection;uniform float u_point_size;varying vec3 v_color;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);gl_PointSize=u_point_size;v_point_size=u_point_size;v_color=a_color;}";var Kn="precision highp float;varying vec3 v_color;varying float v_point_size;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5)discard;float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);gl_FragColor=vec4(v_color,D);}";var Jn="attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;uniform mat4 u_projection;varying vec3 v_color;void main(){float A=a_x_center+(a_corner.x-0.5)*2.*a_half_width;float B=mix(a_y0,a_y1,a_corner.y);gl_Position=u_projection*vec4(A,B,0.,1.);v_color=a_color;}";var Qn="precision highp float;varying vec3 v_color;void main(){gl_FragColor=vec4(v_color,1.);}";var ei="attribute vec2 a_corner;attribute vec2 a_cell;attribute float a_color_t;uniform mat4 u_projection;uniform vec2 u_cell_inset;uniform vec2 u_cell_size;varying float v_color_t;void main(){vec2 A=0.5*u_cell_size;vec2 B=u_cell_size-2.*u_cell_inset;float C=a_cell.x-A.x+u_cell_inset.x+a_corner.x*B.x;float D=a_cell.y-A.y+u_cell_inset.y+a_corner.y*B.y;gl_Position=u_projection*vec4(C,D,0.,1.);v_color_t=a_color_t;}";var ti="precision highp float;uniform sampler2D u_gradient_lut;varying float v_color_t;void main(){float A=clamp(v_color_t,0.,1.);vec4 B=texture2D(u_gradient_lut,vec2(A,0.5));gl_FragColor=vec4(B.rgb,1.);}";var ni="attribute float a_strip_t;attribute float a_side;attribute vec2 a_angles;attribute vec2 a_radii;attribute vec4 a_color;uniform vec2 u_center;uniform vec2 u_resolution;uniform float u_border_px;varying vec4 v_color;varying vec2 v_edge;void main(){float A=u_border_px*0.5;float B=a_radii.x+A;float C=a_radii.y-A;if(C<=B){gl_Position=vec4(2.,2.,2.,1.);v_color=vec4(0.);v_edge=vec2(0.);return;}float D=mix(B,C,a_side);float E=A/max(D,1.);float F=a_angles.y-a_angles.x;E=min(E,F*0.5);float G=mix(a_angles.x+E,a_angles.y-E,a_strip_t);vec2 H=u_center+vec2(cos(G),sin(G))*D;vec2 I=(H/u_resolution)*2.-1.;gl_Position=vec4(I.x,-I.y,0.,1.);v_color=a_color;v_edge=vec2(a_strip_t,a_side);}";var ii="precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}";var ri="attribute vec2 a_position;attribute vec4 a_color;uniform vec2 u_resolution;varying vec4 v_color;void main(){vec2 A=(a_position/u_resolution)*2.-1.;A.y=-A.y;gl_Position=vec4(A,0.,1.);v_color=a_color;}";var oi="precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}";to();no();io();ro();oo();so();lo();var ao=[{name:"bar",vert:Hn,frag:Vn},{name:"line",vert:Yn,frag:zn},{name:"scatter",vert:Xn,frag:$n},{name:"bar-area",vert:jn,frag:Zn},{name:"bar-scatter",vert:qn,frag:Kn},{name:"line-uniform",vert:Xe,frag:$e},{name:"candlestick-body",vert:Jn,frag:Qn},{name:"heatmap",vert:ei,frag:ti},{name:"sunburst-arc",vert:ni,frag:ii},{name:"treemap",vert:ri,frag:oi},{name:"density-splat",vert:Ft,frag:si},{name:"density-extreme",vert:Ft,frag:li},{name:"density-resolve",vert:ai,frag:ui},{name:"map-tile",vert:mi,frag:fi}];var fm=1,ut=class{constructor(t,n={}){d(this,"id");d(this,"canvas");d(this,"gl");d(this,"isWebGL2");d(this,"shaders");d(this,"Sr");d(this,"Fr",null);d(this,"qt");d(this,"ht",!1);d(this,"ni",new Set);this.id=fm++,this.canvas=t,this.qt=n.precompile??!1;let i=t.getContext("webgl2",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(i)this.gl=i,this.isWebGL2=!0;else{let r=t.getContext("webgl",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(!r)throw new Error("WebGL is not supported");this.gl=r,this.isWebGL2=!1}this.shaders=new mn(this.gl),this.qt&&this.shaders.precompile(ao),this.Sr=this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),this.isWebGL2||(this.Fr=this.gl.getExtension("ANGLE_instanced_arrays")),t.addEventListener("webglcontextlost",r=>{this.ht||r.preventDefault()}),t.addEventListener("webglcontextrestored",()=>{this.shaders.releaseAll(),this.shaders=new mn(this.gl),this.qt&&this.shaders.precompile(ao);for(let r of this.ni)r()})}resetVertexArrayState(){let t=this.gl;for(let n=0;n<this.Sr;n++)t.disableVertexAttribArray(n),this.isWebGL2?t.vertexAttribDivisor(n,0):this.Fr?.vertexAttribDivisorANGLE(n,0)}onRestore(t){return this.ni.add(t),()=>this.ni.delete(t)}isContextLost(){return this.ht||this.gl.isContextLost()}get destroyed(){return this.ht}destroy(){this.ht=!0,this.ni.clear(),this.shaders.releaseAll();let t=this.gl.getExtension("WEBGL_lose_context");t&&t.loseContext()}};var fn=class{constructor(t,n={}){d(this,"D");d(this,"ii");d(this,"Ir");d(this,"o");d(this,"ri",0);d(this,"Yi",0);d(this,"zi",0);d(this,"Xi",1);d(this,"ht",!1);d(this,"oi",null);d(this,"xt",null);d(this,"An",null);d(this,"Kt",null);t instanceof ut?(this.D=t,this.ii=!1):(this.D=new ut(t,{precompile:n.precompile??!1}),this.ii=!0),this.o=new un(this.D.gl),this.Ir=this.D.onRestore(()=>{this.o.releaseAll(),this.o=new un(this.D.gl),this.ri=0})}get gl(){return this.D.gl}get backendId(){return this.D.id}isContextLost(){return this.ht||this.D.isContextLost()}get isWebGL2(){return this.D.isWebGL2}get shaders(){return this.D.shaders}get v(){return this.o}get uploadedCount(){return this.ri}set uploadedCount(t){this.ri=t}resize(t,n,i){this.Yi=t,this.zi=n,this.Xi=i;let r=Math.round(t*i),o=Math.round(n*i),s=this.D.canvas;(s.width!==r||s.height!==o)&&(s.width=r,s.height=o,this.D.gl.viewport(0,0,r,o))}requestResize(t,n,i){this.Kt={cssWidth:t,cssHeight:n,dpr:i}}applyPendingResize(){if(!this.Kt)return!1;let{cssWidth:t,cssHeight:n,dpr:i}=this.Kt;return this.Kt=null,this.resize(t,n,i),!0}beginFrame(){if(this.ii){this.applyPendingResize();return}let t=this.Kt;this.Kt=null,t?this.resize(t.cssWidth,t.cssHeight,t.dpr):this.resize(this.Yi,this.zi,this.Xi);let n=this.D.gl,i=this.D.canvas;n.bindFramebuffer(n.FRAMEBUFFER,null),n.viewport(0,0,i.width,i.height),n.disable(n.SCISSOR_TEST),n.disable(n.DEPTH_TEST),this.D.resetVertexArrayState()}get cssWidth(){return this.Yi}get cssHeight(){return this.zi}get dpr(){return this.Xi}clear(){this.D.gl.clearColor(0,0,0,0),this.D.gl.clear(this.D.gl.COLOR_BUFFER_BIT|this.D.gl.DEPTH_BUFFER_BIT),this.ri=0}setFrameCallback(t){this.oi=t}endFrame(){if(!this.oi||this.isContextLost())return;let t=this.D.canvas;if(typeof t.transferToImageBitmap!="function")return;let n=t.transferToImageBitmap();this.oi(n)}async awaitGpuFence(){if(!this.D.isWebGL2){this.D.gl.finish();return}let t=this.D.gl,n=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n){t.finish();return}try{let i=t.SYNC_FLUSH_COMMANDS_BIT;for(;;){let r=t.clientWaitSync(n,i,0);if(r===t.ALREADY_SIGNALED||r===t.CONDITION_SATISFIED)return;if(r===t.WAIT_FAILED){t.finish();return}if(i=0,await this.Ao(),this.ht)return}}finally{t.deleteSync(n)}}ensureBufferCapacity(t){this.o.ensureCapacity(t)}Ao(){return this.xt||(this.xt=new MessageChannel,this.xt.port1.start()),new Promise(t=>{let n=this.xt;this.An=t,n.port1.addEventListener("message",()=>{this.An=null,t()},{once:!0}),n.port2.postMessage(null)})}destroy(){if(this.ht=!0,this.oi=null,this.Ir(),this.o.releaseAll(),this.An){let t=this.An;this.An=null,t()}this.xt&&(this.xt.port1.close(),this.xt.port2.close(),this.xt=null),this.ii&&this.D.destroy()}};var ci=class{constructor(t,n={}){d(this,"Dr");d(this,"qt");d(this,"Jt",[]);d(this,"Br",0);this.Dr=Math.max(1,t),this.qt=n.precompile??!1}acquire(){let t;if(this.Jt.length<this.Dr)t=this.Er(),this.Jt.push(t);else{let n=this.Br%this.Jt.length;this.Br++,this.Jt[n].isContextLost()&&(this.Jt[n]=this.Er()),t=this.Jt[n]}return t}Er(){let t=new OffscreenCanvas(1,1);return new ut(t,{precompile:this.qt})}};di();di();function Bs(e,t,n,i){let{controller:r,layout:o}=e,s=o.e,l=r.getVisibleDomain(),a=l.xMin+(t-s.x)/s.width*(l.xMax-l.xMin),u=l.yMax-(n-s.y)/s.height*(l.yMax-l.yMin),m=Math.pow(1.1,-i/100),f=r.lockedAxis;f!=="x"&&(r.scaleX=Math.max(1,Math.min(1e5,r.scaleX*m))),f!=="y"&&(r.scaleY=Math.max(1,Math.min(1e5,r.scaleY*m)));let c=r.getVisibleDomain(),p=c.xMin+(t-s.x)/s.width*(c.xMax-c.xMin),b=c.yMax-(n-s.y)/s.height*(c.yMax-c.yMin),g=r.baseXRange,x=r.baseYRange;f!=="x"&&g>0&&(r.normTranslateX+=(a-p)/g),f!=="y"&&x>0&&(r.normTranslateY+=(u-b)/x)}function Es(e,t,n){let{controller:i,layout:r}=e,o=i.getVisibleDomain(),s=r.e,l=(o.xMax-o.xMin)/s.width,a=(o.yMax-o.yMin)/s.height,u=i.lockedAxis,m=i.baseXRange,f=i.baseYRange;u!=="x"&&m>0&&(i.normTranslateX-=t*l/m),u!=="y"&&f>0&&(i.normTranslateY+=n*a/f)}var pi=class{constructor(t){d(this,"rn");this.rn=t}pin(t,n,i){this.rn({kind:"pinTooltip",lines:t,pos:n,bounds:i})}dismiss(){this.rn({kind:"dismissTooltip"})}setCursor(t){this.rn({kind:"setCursor",cursor:t})}emitUserClick(t){this.rn({kind:"userClick",detail:t})}emitUserSelect(t){this.rn({kind:"userSelect",selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig})}};No();dn();var er=class{constructor(t=1024){d(this,"size");d(this,"value");d(this,"colorValue");d(this,"sizeSign");d(this,"x0");d(this,"y0");d(this,"x1");d(this,"y1");d(this,"a0");d(this,"a1");d(this,"r0");d(this,"r1");d(this,"depth");d(this,"parent");d(this,"firstChild");d(this,"nextSibling");d(this,"lastChild");d(this,"childCount");d(this,"leafRowIdx");d(this,"name");d(this,"colorLabel");d(this,"count",0);d(this,"capacity",0);this.io(t)}reset(){this.count>0&&(this.x0.fill(0,0,this.count),this.y0.fill(0,0,this.count),this.x1.fill(0,0,this.count),this.y1.fill(0,0,this.count),this.a0.fill(0,0,this.count),this.a1.fill(0,0,this.count),this.r0.fill(0,0,this.count),this.r1.fill(0,0,this.count)),this.count=0}allocate(){this.count===this.capacity&&this.io(this.capacity*2);let t=this.count++;return this.firstChild[t]=-1,this.nextSibling[t]=-1,this.lastChild[t]=-1,this.childCount[t]=0,this.leafRowIdx[t]=-1,this.size[t]=0,this.value[t]=0,this.colorValue[t]=NaN,this.sizeSign[t]=1,this.name[t]="",this.colorLabel[t]="",t}appendChild(t,n){this.parent[n]=t,this.depth[n]=this.depth[t]+1,this.nextSibling[n]=-1;let i=this.lastChild[t];i===-1?this.firstChild[t]=n:this.nextSibling[i]=n,this.lastChild[t]=n,this.childCount[t]++}isLeaf(t){return this.firstChild[t]===-1}io(t){let n=Math.max(t,1024),i=(r,o)=>{let s=new o(n);return r&&r.length>0&&s.set(r),s};this.size=i(this.size,Float32Array),this.value=i(this.value,Float32Array),this.colorValue=i(this.colorValue,Float32Array),this.sizeSign=i(this.sizeSign,Int8Array),this.x0=i(this.x0,Float32Array),this.y0=i(this.y0,Float32Array),this.x1=i(this.x1,Float32Array),this.y1=i(this.y1,Float32Array),this.a0=i(this.a0,Float32Array),this.a1=i(this.a1,Float32Array),this.r0=i(this.r0,Float32Array),this.r1=i(this.r1,Float32Array),this.depth=i(this.depth,Int32Array),this.parent=i(this.parent,Int32Array),this.firstChild=i(this.firstChild,Int32Array),this.nextSibling=i(this.nextSibling,Int32Array),this.lastChild=i(this.lastChild,Int32Array),this.childCount=i(this.childCount,Int32Array),this.leafRowIdx=i(this.leafRowIdx,Int32Array),this.name?this.name.length=n:this.name=new Array(n),this.colorLabel?this.colorLabel.length=n:this.colorLabel=new Array(n),this.capacity=n}};function Ql(e,t){let n=[],i=t;for(;e.parent[i]!==-1;)n.push(e.name[i]),i=e.parent[i];return n.reverse()}Bo();function tr(e){for(let t of e.keys())if(!t.startsWith("__"))return t;return""}var Zt=class extends Se{constructor(){super(...arguments);d(this,"ie","");d(this,"s","");d(this,"Ce","empty");d(this,"a",new er);d(this,"Z",-1);d(this,"_",-1);d(this,"ce",[]);d(this,"Ut",new Map);d(this,"Ri",0);d(this,"b",1/0);d(this,"p",-1/0);d(this,"c",new Map);d(this,"q",null);d(this,"oe",0);d(this,"N",new zt)}colorScaleColumn(){return this.M[1]||null}};pn();Ln();Ae();function Lt(e,t,n,i,r){if(!e||t<=0)return null;let o=new Float64Array(t),s=1/0,l=-1/0;for(let u=0;u<t;u++){let m=e[u+n];o[u]=m,m<s&&(s=m),m>l&&(l=m)}let a=1/0;for(let u=1;u<t;u++){let m=Math.abs(o[u]-o[u-1]);m>0&&m<a&&(a=m)}return(!isFinite(a)||a===0)&&(a=Math.max(1,l-s)),{categoryPositions:o,numericCategoryDomain:{min:s-a/2,max:l+a/2,isDate:r,label:i,bandWidth:a}}}function qt(e,t){if(e.length!==1)return{mode:"category"};let n=t[e[0]];return n==="date"||n==="datetime"||n==="integer"||n==="float"?{mode:"numeric",numericType:n}:{mode:"category"}}function vf(e,t,n){return!t||e==null||Number.isNaN(e)?"":n==="boolean"?e?"true":"false":n==="date"||n==="datetime"?ve(e):n==="integer"?String(e|0):n==="float"?me(e):String(e)}function Oo(e,t,n){let i=e.values,r=e.valid,o=new Int32Array(t),s=[""],l=new Map;l.set("",0);let a=new Map;for(let u=0;u<t;u++){if(!(r?!!(r[u>>3]>>(u&7)&1):!0)){o[u]=0;continue}let f=i[u],c=a.get(f);if(c===void 0){let p=vf(f,!0,n);c=l.get(p),c===void 0&&(c=s.length,s.push(p),l.set(p,c)),a.set(f,c)}o[u]=c}return{indices:o,dictionary:s}}function Kt(e,t,n,i=[],r){if(r?.mode==="numeric"){let m=e.get("__ROW_PATH_0__");if(m&&m.type!=="string"&&m.values){let f=0,c=m.values,p=m.valid;for(;f<t;){let b=p?!!(p[f>>3]>>(f&7)&1):!0,g=c[f];if(b&&g!=null&&!Number.isNaN(g))break;f++}return{rowPaths:[],numCategories:Math.max(0,t-f),rowOffset:f}}}let o=[];for(let m=0;;m++){let f=e.get(`__ROW_PATH_${m}__`);if(!f)break;if(f.type==="string"&&f.indices&&f.dictionary)o.push({indices:f.indices,dictionary:f.dictionary});else if(f.values){let c=i[m]??"string";o.push(Oo(f,t,c))}else break}let s=0;if(n>0&&o.length>0)for(;s<t;){let m=!1;for(let f of o){let c=f.dictionary[f.indices[s]];if(c!=null&&c!==""){m=!0;break}}if(m)break;s++}let l=Math.max(0,t-s),a=o.length;return{rowPaths:n>0&&a>0?o.map((m,f)=>{let c=new Array(l),p=0;for(let g=0;g<l;g++){let x=m.dictionary[m.indices[g+s]]??"";c[g]=x,x.length>p&&(p=x.length)}let b=f===a-1?[]:Ui(m.indices,m.dictionary,s,s+l).map(g=>({startIdx:g.startIdx-s,endIdx:g.endIdx-s,label:g.label}));return{labels:c,runs:b,maxLabelChars:p}}):[],numCategories:l,rowOffset:s}}function Uo(e,t,n,i){if(e.length===0)return null;for(let c of e)if(c.type!=="string")return null;let r=Math.max(0,t-n),o=[],s=new Map,l=e.map(()=>new Int32Array(r)),a=c=>{let p=s.get(c);return p===void 0&&(p=o.length,o.push(c),s.set(c,p)),p};for(let c=0;c<e.length;c++){let p=e[c].data,b=l[c];for(let g=0;g<r;g++){let x=g+n,h;if(!p)h="(null)";else{let y=p.valid;if(!(y?!!(y[x>>3]>>(x&7)&1):!0))h="(null)";else if(p.indices&&p.dictionary)h=p.dictionary[p.indices[x]]??"(null)";else if(p.values){let C=p.values[x];h=C==null?"(null)":String(C)}else h="(null)"}b[g]=a(h)}}let u=0;for(let c of o)c.length>u&&(u=c.length);return{domain:{levels:[{labels:o.slice(),runs:[],maxLabelChars:u}],numRows:o.length,levelLabels:[i]},perColumnSlots:l}}function Mn(e){e.a.reset(),e.Ut.clear();let t=e.a.allocate();e.a.name[t]="Total",e.a.depth[t]=0,e.a.parent[t]=-1,e.Ut.set(t,new Map),e.Z=t,e._=t,e.ce=[t],e.Ri=0,e.b=1/0,e.p=-1/0,e.c.clear(),e.q=null,e.oe=0}function Af(e,t,n){let i=e.Ut.get(t);i||(i=new Map,e.Ut.set(t,i));let r=i.get(n);if(r!==void 0)return r;let o=e.a.allocate();return e.a.name[o]=n,e.a.appendChild(t,o),i.set(n,o),o}function nr(e,t,n,i,r,o,s){let l=e.Z,a=t.length;for(let u=0;u<a;u++){let m=Af(e,l,t[u]);u===a-1&&((s===0||a===s)&&(e.a.size[m]=Math.abs(n),e.a.sizeSign[m]=n<0?-1:1,e.a.leafRowIdx[m]=o),isNaN(i)||(e.a.colorValue[m]=i,i<e.b&&(e.b=i),i>e.p&&(e.p=i)),r&&(e.a.colorLabel[m]=r,e.c.has(r)||e.c.set(r,e.c.size))),l=m}}function ta(e,t){let n=e.valid;return!n||!!(n[t>>3]>>(t&7)&1)}function ir(e,t){return e?.values?ta(e,t)?e.values[t]:0:1}function rr(e,t,n){let i=NaN,r="";return!t||!ta(t,n)?{colorValue:i,colorLabel:r}:(e.Ce==="numeric"&&t.values?i=t.values[n]:e.Ce==="series"&&t.indices&&t.dictionary&&(r=t.dictionary[t.indices[n]]),{colorValue:i,colorLabel:r})}function ea(e,t){if(e.Ce!=="series"||!t?.dictionary)return;let n=t.dictionary;for(let i=0;i<n.length;i++){let r=n[i];e.c.has(r)||e.c.set(r,e.c.size)}}function Lf(e,t){if(e.B.length===0)return null;let n=e.ie?[e.ie]:[],i=e.s?[e.s]:[],r=qe(t,n,i);return r.length===0?null:r.map(o=>({prefix:o.prefix,sizeCol:e.ie?t.get(`${o.prefix}|${e.ie}`)??null:null,colorCol:e.s?t.get(`${o.prefix}|${e.s}`)??null:null}))}function Rn(e,t){let n=[];for(let g=0;;g++){let x=t.get(`__ROW_PATH_${g}__`);if(!x)break;if(x.type==="string"&&x.indices&&x.dictionary)n.push({indices:x.indices,dictionary:x.dictionary,valid:x.valid});else if(x.values){let h=e.C[g],y=e.Ct[h]??"string";n.push(Oo(x,x.values.length,y))}else break}let i=n.length>0,r=e.C.length,o=Lf(e,t),s=o!==null,l=e.ie?t.get(e.ie):null,a=e.s?t.get(e.s):null,u=s?o[0].sizeCol:l,m=i?n[0].indices.length:u?.values?.length??0;if(m===0)return;if(s)for(let g of o)ea(e,g.colorCol);else ea(e,a);let f=e.Ri,c=s&&i?r+1:r;if(!i){let g;for(let[h,y]of t){if(h.startsWith("__")||s&&h.includes("|"))continue;let _=h.lastIndexOf("|"),C=_===-1?h:h.substring(_+1);if(!(C===e.ie||C===e.s)&&y.type==="string"&&y.indices&&y.dictionary){g=y;break}}let x=s?o:null;for(let h=0;h<m;h++){let y=g?.indices&&g?.dictionary?g.dictionary[g.indices[h]]:`Row ${f+h}`;if(x)for(let _ of x){let C=ir(_.sizeCol,h),{colorValue:v,colorLabel:A}=rr(e,_.colorCol,h);nr(e,[_.prefix,y],C,v,A,f+h,c)}else{let _=ir(l,h),{colorValue:C,colorLabel:v}=rr(e,a,h);nr(e,[y],_,C,v,f+h,c)}}e.Ri=f+m;return}let p=s?1:0,b=new Array(n.length+p);for(let g=0;g<m;g++){let x=0;for(let h=0;h<n.length;h++){let y=n[h];if(y.valid&&!(y.valid[g>>3]>>(g&7)&1))break;let _=y.dictionary[y.indices[g]];if(!_&&_!=="0")break;b[p+x++]=_}if(x!==0)if(s)for(let h of o){b[0]=h.prefix;let y=b.slice(0,x+1),_=ir(h.sizeCol,g),{colorValue:C,colorLabel:v}=rr(e,h.colorCol,g);nr(e,y,_,C,v,f+g,c)}else{let h=b.slice(0,x),y=ir(l,g),{colorValue:_,colorLabel:C}=rr(e,a,g);nr(e,h,y,_,C,f+g,c)}}e.Ri=f+m}function Sn(e){let t=e.a,n=t.value,i=t.size,r=t.firstChild,o=t.nextSibling,s=new Int32Array(128);s[0]=e.Z,s[1]=0;let l=1;for(let a=0;a<t.count;a++)n[a]=0;for(;l>0;){l--;let a=s[l*2];if(s[l*2+1]===0){s[l*2+1]=1,l++;for(let m=r[a];m!==-1;m=o[m]){if((l+1)*2>s.length){let f=new Int32Array(s.length*2);f.set(s),s=f}s[l*2]=m,s[l*2+1]=0,l++}}else if(r[a]===-1){let m=i[a];n[a]=m>0?m:0}else{let m=0;for(let f=r[a];f!==-1;f=o[f])m+=n[f];n[a]=m}}if(e.ce.length>1){let a=[];for(let f=1;f<e.ce.length;f++)a.push(t.name[e.ce[f]]);let u=e.Z,m=!0;for(let f of a){let p=e.Ut.get(u)?.get(f);if(p===void 0){m=!1;break}u=p}if(m&&t.firstChild[u]!==-1){e._=u,or(e,u);return}}e._=e.Z,e.ce=[e.Z]}function or(e,t){let n=[],i=t;for(;i!==-1;)n.unshift(i),i=e.a.parent[i];e.ce=n}var Tf=1,Ho=14,na=1,ia=4;function sr(e,t,n,i,r,o,s,l,a){if(e.x0[t]=Math.round(n),e.y0[t]=Math.round(i),e.x1[t]=Math.round(r),e.y1[t]=Math.round(o),e.firstChild[t]===-1||(r-n)*(o-i)<ia)return;let m=e.depth[t]-s,f=a&&m===1&&e.firstChild[t]!==-1,c=f?Ho:na,p=f?Tf:na,b=e.x0[t]+p,g=e.y0[t]+c,x=e.x1[t]-p,h=e.y1[t]-p;if(x<=b||h<=g)return;let y=0;for(let _=e.firstChild[t];_!==-1;_=e.nextSibling[_])e.value[_]>0&&(l[y++]=_);y!==0&&Fn(e,l,0,y,b,g,x,h,s,l.subarray(y),a)}function Fn(e,t,n,i,r,o,s,l,a,u,m){let f=i-n;if(f===0)return;if(f===1){sr(e,t[n],r,o,s,l,a,u,m);return}let c=0;for(let v=n;v<i;v++)c+=e.value[t[v]];let p=c/2,b=0,g=n+1,x=1/0;for(let v=n;v<i-1;v++){b+=e.value[t[v]];let A=Math.abs(b-p);A<x&&(x=A,g=v+1)}let h=0;for(let v=n;v<g;v++)h+=e.value[t[v]];let y=h/c,_=s-r,C=l-o;if(_>=C){let v=Math.round(r+_*y);Fn(e,t,n,g,r,o,v,l,a,u,m),Fn(e,t,g,i,v,o,s,l,a,u,m)}else{let v=Math.round(o+C*y);Fn(e,t,n,g,r,o,s,v,a,u,m),Fn(e,t,g,i,r,v,s,l,a,u,m)}}function ra(e,t,n,i){e.oe=Vo(e,t,n,i,0)}function Vo(e,t,n,i,r){let o=e.a,s=o.x0,l=o.y0,a=o.x1,u=o.y1,m=o.depth,f=o.firstChild,c=o.nextSibling,p=o.value;(!e.q||e.q.length<o.count)&&(e.q=new Int32Array(o.count));let b=e.q,g=r,x=new Int32Array(128);x[0]=t;let h=1;for(;h>0;){h--;let y=x[h];if(p[y]<=0||(m[y]>=i&&(b[g++]=y),m[y]-i>=n))continue;let _=a[y]-s[y],C=u[y]-l[y];if(!(_*C<ia))for(let v=f[y];v!==-1;v=c[v]){if(h>=x.length){let A=new Int32Array(x.length*2);A.set(x),x=A}x[h++]=v}}return g}hn();Gt();Ne();de();function lr(e,t,n){return .299*e+.587*t+.114*n}function wf(e,t){let n=Re(e,t);return[n[0],n[1],n[2]]}function In(e,t,n,i){let r=e.a,o=r.colorValue[t];if(e.Ce==="numeric"&&!isNaN(o)&&e.p>e.b)return wf(n,bt(o,e.b,e.p));let s=e.c.get(r.colorLabel[t])??0;return i[s%i.length]??[0,0,0]}function ar(e,t,n,i,r){let o=In(e,t,n,i),s=e.a.sizeSign[t]<0?r:1;return[o[0],o[1],o[2],s]}fe();function ur(e,t,n,i,r,o,s){let l=Math.round(i*n),a=Math.round(r*n);(t.width!==l||t.height!==a)&&(t.width=l,t.height=a,e.At=!0);let u=t.getContext("2d");if(u){if(e.At){e.de?.close(),e.de=null,e.At=!1;let m=++e.Wn;o(u),createImageBitmap(t).then(f=>{e.Wn===m?(e.de?.close(),e.de=f):f.close()})}else e.de&&(u.clearRect(0,0,t.width,t.height),u.drawImage(e.de,0,0));s&&(u.save(),u.scale(n,n),s(u),u.restore())}}Oi();Ke();Tn();Ne();function oa(e,t,n,i,r,o,s,l){if(n.length===0)return;let{li:a,kr:u,Wr:m}=t;e.font=`11px ${l}`;let f=16,c=8,p=0;for(let y of n){let _=e.measureText(y).width;_>p&&(p=_)}let b=p+c*2,g=n.length*f+c*2-4,x=i+12,h=r-g-8;x+b>o&&(x=i-b-12),x<0&&(x=4),h<0&&(h=r+12),h+g>s&&(h=s-g-4),e.fillStyle=a,e.strokeStyle=m,e.lineWidth=1,e.beginPath(),e.roundRect(x,h,b,g,4),e.fill(),e.stroke(),e.fillStyle=u,e.textAlign="left",e.textBaseline="top";for(let y=0;y<n.length;y++)e.fillText(n[y],x+c,h+c+y*f)}var sa=24,Mf=8,la=12,aa=2,ua=" \\u203A ";function mr(e,t,n,i,r){e.$e=[];let o=e.T().li;t.fillStyle=o,t.fillRect(0,0,n,sa),t.font=`11px ${i}`,t.textAlign="left",t.textBaseline="middle";let s=Mf,l=e.a;for(let a=0;a<e.ce.length;a++){let u=e.ce[a],m=a===e.ce.length-1,f=l.name[u];t.fillStyle=r;let c=t.measureText(f).width;t.fillText(f,s,la),e.$e.push({nodeId:u,x0:s-aa,y0:0,x1:s+c+aa,y1:sa}),s+=c,m||(t.fillText(ua,s,la),s+=t.measureText(ua).width)}}function fr(e,t,n,i,r,o,s,l){let a=e.N.hoveredTarget===n?e.N.lines??[]:[];a.length!==0&&oa(t,e.T(),a,i,r,o,s,l)}function cr(e,t,n,i,r,o,s,l=null){let a=e.i,u=e.Ce==="series"&&e.c.size>1,m=e.Ce==="numeric"&&e.b<e.p;if(a.legend_mode==="none"||!u&&!m){e.R.clearPainted();return}let f=a.legend_mode==="floating",c={mode:f?"floating":"sidebar",legend:e.R,title:e.s||"Legend",opacity:a.legend_opacity},p=f?e.R.floatingBox(a,o,s):null;if(u)p?vt(t,p,e.c,n,r,c):l?vt(t,l,e.c,n,r,{...c,sidebarGutter:l.width}):zi(t,ma(o,s,a),e.c,n,r,c);else{let b={min:e.b,max:e.p,label:e.s},g=e.getColumnFormatter(e.s,"value");p?He(t,p,b,i,r,g,c):Yt(t,ma(o,s,a),b,i,r,g,c)}}function ma(e,t,n){return new ie(e,t,{hasXLabel:!1,hasYLabel:!1,hasLegend:!0,rightExtra:Le(n,80)})}function fa(e,t){if(e._===-1)return;let n=t.gl,i=t.cssWidth,r=t.cssHeight;if(i<=0||r<=0)return;let o=e.a,s=e.B.length>0&&e.W.facet_mode==="grid",l=e.ce.length>1?28:0,a=e.Ce==="series"?e.c.size>1:e.Ce==="numeric"&&e.b<e.p,u=_i(e.i,a,90),m=new Int32Array(Math.max(o.count,64));if(s)Rf(e,m,i,r,l,u);else{e.d=null;let b=o.depth[e._];sr(o,e._,0,l,i-u,r,b,m,e.Si),ra(e,e._,100,b),zo(e);let g=e.Oe,x=e.je;for(let h=0;h<e.oe;h++)g[h]=b,x[h]=e._}if(!e.r){let b=j(t,"treemap",ri,oi,["u_resolution"],["a_position","a_color"]);e.r=b.program,e.I=b}let f=e.T(),c=f.k,p=pe(f.Ge,c,Math.max(1,e.c.size));if(e.K){let b=e.K.getContext("2d");b&&b.clearRect(0,0,e.K.width,e.K.height)}e.At=!0,Sf(e,n,c,p,f.fi),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.r),n.uniform2f(e.I.u_resolution,i,r),n.bindBuffer(n.ARRAY_BUFFER,e.Ht),n.enableVertexAttribArray(e.I.a_position),n.vertexAttribPointer(e.I.a_position,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,e.Vt),n.enableVertexAttribArray(e.I.a_color),n.vertexAttribPointer(e.I.a_color,4,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,e.mr),e.he(()=>Jt(e))}function Rf(e,t,n,i,r,o){let s=e.a,l=[],a=[];for(let b=s.firstChild[e.Z];b!==-1;b=s.nextSibling[b])s.value[b]<=0||(l.push(b),a.push(s.name[b]));let u=Math.max(1,i-r),m=Math.max(1,n-o),f=Fe(a,{cssWidth:m,cssHeight:u,hasLegend:!1,xAxis:"none",yAxis:"none",gap:e.W.facet_padding});e.d=f,zo(e);let c=e.Oe,p=0;for(let b=0;b<l.length;b++){let g=l[b],x=f.cells[b];if(!x)continue;let h=s.name[g],y=e.mt.get(h)??g,_=s.depth[y],C=x.layout.e;sr(s,y,C.x,C.y+r,C.x+C.width,C.y+r+C.height,_,t,e.Si);let v=Vo(e,y,100,_,p);c.length<v&&zo(e);let A=e.Oe,L=e.je;for(let T=p;T<v;T++)A[T]=_,L[T]=y;p=v}e.oe=p}function zo(e){let t=e.q?.length??e.a.count;(!e.Oe||e.Oe.length<t)&&(e.Oe=new Int32Array(t)),(!e.je||e.je.length<t)&&(e.je=new Int32Array(t))}function Sf(e,t,n,i,r){let o=e.a,s=e.q,l=e.oe,a=e.Oe,u=e.je,m=x=>a?a[x]:o.depth[e._],f=x=>u?u[x]:e._,c=0;for(let x=0;x<l;x++){let h=s[x];if(h===f(x))continue;let y=o.x1[h]-o.x0[h],_=o.y1[h]-o.y0[h];y<1||_<1||(o.firstChild[h]===-1?c++:o.depth[h]-m(x)===1&&(c+=2))}let p=new Float32Array(c*6*2),b=new Float32Array(c*6*4),g=0;for(let x=0;x<l;x++){let h=s[x];if(h===f(x))continue;let y=o.x0[h],_=o.y0[h],C=o.x1[h],v=o.y1[h],A=C-y,L=v-_;if(!(A<1||L<1)){if(o.firstChild[h]===-1){let T=ar(e,h,n,i,r);g=Yo(p,b,g,y,_,C-1,v-1,T)}else if(o.depth[h]-m(x)===1){let w=[.25,.25,.25,1];g=Yo(p,b,g,y,v-1,C,v,w),g=Yo(p,b,g,C-1,_,C,v,w)}}}e.mr=g,e.Ht||(e.Ht=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.Ht),t.bufferData(t.ARRAY_BUFFER,p.subarray(0,g*2),t.DYNAMIC_DRAW),e.Vt||(e.Vt=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.Vt),t.bufferData(t.ARRAY_BUFFER,b.subarray(0,g*4),t.DYNAMIC_DRAW)}function Yo(e,t,n,i,r,o,s,l){let a=n*2,u=n*4;e[a+0]=i,e[a+1]=r,e[a+2]=o,e[a+3]=r,e[a+4]=i,e[a+5]=s,e[a+6]=o,e[a+7]=r,e[a+8]=o,e[a+9]=s,e[a+10]=i,e[a+11]=s;for(let m=0;m<6;m++)t[u+m*4+0]=l[0],t[u+m*4+1]=l[1],t[u+m*4+2]=l[2],t[u+m*4+3]=l[3];return n+6}function Jt(e){Ff(e),e.presentOverlay()}function Ff(e){if(!e.u||e._===-1)return;let t=e.t;if(!t)return;let{dpr:n,cssWidth:i,cssHeight:r}=t,o=e.se!==-1?e.se:e.P;ur(e,e.u,n,i,r,s=>If(e,s,n,i,r),o!==-1?s=>{let l=e.T(),{fontFamily:a}=l,u=e.a;Df(s,u,o);let m=e.q,f=e.oe,c=e.Oe,p=e.je;for(let b=0;b<f;b++){let g=m[b],x=p?p[b]:e._;if(g===x||u.firstChild[g]===-1)continue;let h=u.x1[g]-u.x0[g],y=u.y1[g]-u.y0[g],_=c?c[b]:u.depth[e._],C=u.depth[g]-_;C===1?dr(s,u,g,h,y,l,!e.Si):C===2&&dr(s,u,g,h,y,l,!0)}if(u.firstChild[o]===-1){let b=l.k,g=pe(l.Ge,b,Math.max(1,e.c.size)),x=u.x1[o]-u.x0[o],h=u.y1[o]-u.y0[o];ca(e,s,o,x,h,a,b,g,!0)}e.se===-1&&e.P!==-1&&Bf(e,s,e.P,i,r,a)}:null)}function If(e,t,n,i,r){let o=e.u;t.clearRect(0,0,o.width,o.height),t.save(),t.scale(n,n);let s=e.T(),{fontFamily:l,Me:a}=s,u=s.k,m=pe(s.Ge,u,Math.max(1,e.c.size)),f=e.a,c=e.q,p=e.oe,b=e.Oe,g=e.je;for(let x=0;x<p;x++){let h=c[x],y=g?g[x]:e._;if(h===y||f.firstChild[h]!==-1)continue;let _=f.x1[h]-f.x0[h],C=f.y1[h]-f.y0[h];ca(e,t,h,_,C,l,u,m)}for(let x=0;x<p;x++){let h=c[x],y=g?g[x]:e._;if(h===y||f.firstChild[h]===-1)continue;let _=f.x1[h]-f.x0[h],C=f.y1[h]-f.y0[h],v=b?b[x]:f.depth[e._],A=f.depth[h]-v;A===1?dr(t,f,h,_,C,s,!e.Si):A===2&&dr(t,f,h,_,C,s,!0)}if(e.ce.length>1&&mr(e,t,i,l,a),cr(e,o,m,u,s,i,r),e.d){t.font=`11px ${l}`,t.fillStyle=a,t.textAlign="center",t.textBaseline="top";for(let x of e.d.cells){let h=x.layout.e;t.fillText(x.label,h.x+h.width/2,h.y-14)}}t.restore()}function ca(e,t,n,i,r,o,s,l,a=!1){if(i<30||r<14)return;let c=e.a,p=In(e,n,s,l),b=lr(p[0],p[1],p[2]),g=a?b>.5?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.9)":b>.5?"rgba(0,0,0,0.5)":"rgba(255,255,255,0.55)",x=Math.min(11,Math.floor(r/2));if(x<7)return;t.font=`${x}px ${o}`;let h=i-8,y=x*1.3,_=Math.max(1,Math.floor((r-8)/y)),C=Bl(t,c.name[n],h,_);if(C.length===0)return;let v=C.length*y,A=c.y0[n]+(r-v)/2+y/2;t.fillStyle=g,t.textAlign="center",t.textBaseline="middle";let L=c.x0[n]+i/2;for(let T=0;T<C.length;T++)t.fillText(C[T],L,A+T*y)}function dr(e,t,n,i,r,{fontFamily:o,Me:s,backgroundColor:l},a){let u=t.x0[n],m=t.y0[n],f=t.name[n];if(a){if(i<60||r<30)return;let c=12;e.font=`${c}px ${o}`;let p=f,b=i-16;if(e.measureText(p).width>b){for(;p.length>1;)if(p=p.slice(0,-1),e.measureText(p+"\\u2026").width<=b){p+="\\u2026";break}}if(p.length<=3)return;e.save(),e.beginPath(),e.rect(u,m,i,r),e.clip();let x=u+i/2,h=m+r/2;e.textAlign="center",e.textBaseline="middle",e.lineWidth=2,e.strokeStyle=s,e.lineJoin="round",e.strokeText(p,x,h),e.fillStyle=l,e.fillText(p,x,h),e.restore()}else{if(i<40||r<22)return;let c=11;e.font=`${c}px ${o}`;let p=f,b=i-10;if(e.measureText(p).width>b){for(;p.length>1;)if(p=p.slice(0,-1),e.measureText(p+"\\u2026").width<=b){p+="\\u2026";break}}e.fillStyle=s,e.globalAlpha=.85,e.textAlign="left",e.textBaseline="top",e.fillText(p,u+5,m+4),e.globalAlpha=1}}function Df(e,t,n){e.strokeStyle="rgba(255,255,255,0.9)",e.lineWidth=2,e.strokeRect(t.x0[n],t.y0[n],t.x1[n]-t.x0[n],t.y1[n]-t.y0[n])}function Bf(e,t,n,i,r,o){let s=e.a,l=(s.x0[n]+s.x1[n])/2,a=(s.y0[n]+s.y1[n])/2;fr(e,t,n,l,a,i,r,o)}async function Ye(e,t,n){let i=e.a,r=Ql(i,t),o=e.B.length>0&&e.W.facet_mode==="grid",s=o?r.slice(0,e.B.length):[],l=o?r.slice(e.B.length,e.B.length+e.C.length):r.slice(0,e.C.length),a=n==="leaf"?i.leafRowIdx[t]??null:null;await e.emitClickAndSelect({rowIdx:a!=null&&a>=0?a:null,columnName:e.ie,groupByValues:l,splitByValues:s})}async function Tt(e,t){let n=e.a,i=[],r=[],o=t;for(;n.parent[o]!==-1;)r.push(n.name[o]),o=n.parent[o];r.reverse(),r.length>0?i.push(r.join(" \\u203A ")):i.push(n.name[t]);let s=e.getColumnFormatter(e.ie,"value");if(i.push(`Value: ${s(n.value[t])}`),e.s&&!isNaN(n.colorValue[t])){let u=e.getColumnFormatter(e.s,"value");i.push(`${e.s}: ${u(n.colorValue[t])}`)}let l=n.leafRowIdx[t];if(n.firstChild[t]===-1&&l!==-1&&e.We){let u=await e.We.fetchRow(l);for(let[m,f]of u)f!=null&&(m===e.s&&!isNaN(n.colorValue[t])||(typeof f=="number"?i.push(`${m}: ${e.getColumnFormatter(m,"value")(f)}`):i.push(`${m}: ${f}`)))}return n.firstChild[t]!==-1&&i.push(`Children: ${n.childCount[t]}`),i}function pr(e,t,n,i){e.L.dismiss(),e.se=t;let r=e.t?.cssWidth??0,o=e.t?.cssHeight??0;Tt(e,t).then(s=>{e.se===t&&s.length!==0&&e.L.pin(s,{px:n.cx,py:n.cy},{cssWidth:r,cssHeight:o})}),e.P=-1,i()}function br(e){e.L.dismiss(),e.se=-1}function gr(e,t,n){let i=e.a;if(e.B.length>0&&e.W.facet_mode==="grid"){let r=t;for(;r!==-1&&i.parent[r]!==e.Z;)r=i.parent[r];r!==-1&&e.mt.set(i.name[r],t),e.P=-1,n();return}e._=t,or(e,t),e.P=-1,n()}function Xo(e,t,n){let i=e.a,r=i.x0,o=i.y0,s=i.x1,l=i.y1,a=i.depth,u=i.firstChild,m=e.q,f=e.oe,c=e.Oe,p=e.je,b=-1,g=1/0,x=-1,h=1/0,y=-1;if(!m)return{leafId:-1,branchId:-1,inHeader:!1};for(let _=0;_<f;_++){let C=m[_],v=p?p[_]:e._;if(C===v||!(t>=r[C]&&t<=s[C]&&n>=o[C]&&n<=l[C]))continue;let A=(s[C]-r[C])*(l[C]-o[C]);if(u[C]!==-1){A<h&&(h=A,x=C);let L=c?c[_]:a[e._],T=a[C]-L;if(T===1&&n<=o[C]+Ho&&(y=C),T===2){let w=s[C]-r[C],M=l[C]-o[C];if(w>=60&&M>=30){let D=o[C]+M/2,I=r[C]+w/2;Math.abs(n-D)<10&&Math.abs(t-I)<w*.4&&(y=C)}}}else A<g&&(g=A,b=C)}return y!==-1?{leafId:-1,branchId:y,inHeader:!0}:{leafId:b,branchId:x,inHeader:!1}}function da(e,t,n){if(e.se!==-1)return;for(let l of e.$e)if(t>=l.x0&&t<=l.x1&&n>=l.y0&&n<=l.y1){e.L.setCursor("pointer"),e.P=-1,Jt(e);return}let{leafId:i,branchId:r,inHeader:o}=Xo(e,t,n),s=o?r:i!==-1?i:r;if(s!==e.P){if(e.P=s,e.L.setCursor(r!==-1?"pointer":"default"),s!==-1){let l=e.N.beginHover(s);Tt(e,s).then(a=>{e.N.commitHover(l,a)&&Jt(e)})}else e.N.clearHover();Jt(e)}}function pa(e,t,n){if(e.se!==-1){Dn(e),e.emitUnselect();return}for(let s of e.$e)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e._&&(hr(e,s.nodeId),e.emitUnselect());return}let{leafId:i,branchId:r,inHeader:o}=Xo(e,t,n);r!==-1&&o?(hr(e,r),Ye(e,r,"branch")):i!==-1?(ga(e,i),Ye(e,i,"leaf")):r!==-1&&(hr(e,r),Ye(e,r,"branch"))}function ba(e,t,n){let i=e.se!==-1;Dn(e),i&&e.emitUnselect();let{leafId:r,branchId:o}=Xo(e,t,n),s=e.a,l=o;if(l===-1&&r!==-1){let a=s.parent[r];a!==e._&&a!==-1&&(l=a)}l!==-1&&l!==e._&&s.firstChild[l]!==-1&&(hr(e,l),Ye(e,l,"branch"),r!==-1&&s.firstChild[r]===-1&&(ga(e,r),Ye(e,r,"leaf")))}function hr(e,t){gr(e,t,()=>{e.t&&e.requestRender(e.t)})}function ga(e,t){let n=e.a,i=(n.x0[t]+n.x1[t])/2,r=(n.y0[t]+n.y1[t])/2;pr(e,t,{cx:i,cy:r},()=>Jt(e))}function Dn(e){br(e)}var xr=class extends Zt{constructor(){super(...arguments);d(this,"r",null);d(this,"I",null);d(this,"Ht",null);d(this,"Vt",null);d(this,"mr",0);d(this,"P",-1);d(this,"se",-1);d(this,"$e",[]);d(this,"de",null);d(this,"At",!0);d(this,"Wn",0);d(this,"mt",new Map);d(this,"d",null);d(this,"Si",!1);d(this,"Oe",null);d(this,"je",null)}tooltipCallbacks(){return{onHover:(n,i)=>da(this,n,i),onLeave:()=>{this.P!==-1&&this.se===-1&&(this.P=-1,this.t&&this.requestRender(this.t))},onClickPre:(n,i)=>(pa(this,n,i),!0),onDblClick:(n,i)=>ba(this,n,i)}}async uploadAndRender(n,i,r,o){if(this.t=n,r===0){let s=this.M;if(this.ie=s[0]||tr(i)||"",this.s=s[1]||"",!this.s)this.Ce="empty";else{let l=this.ze[this.s],a=l==="float"||l==="integer"||l==="date"||l==="datetime";this.Ce=a?"numeric":"series"}this.P=-1,this.se=-1,this.$e=[],this.mt.clear(),this.d=null,this.Oe=null,this.je=null,this.mr=0,this.N.clearHover(),this.N.invalidatePin(),Dn(this),this.de?.close(),this.de=null,this.At=!0,this.Wn++,Mn(this)}Rn(this,i),Sn(this),this.Z!==-1&&await this.requestRender(n)}Wt(n){this.Z!==-1&&(this.t=n,fa(this,n))}destroyInternal(){Dn(this),this.de?.close(),this.de=null;let n=this.t?.gl;n&&(this.Ht&&n.deleteBuffer(this.Ht),this.Vt&&n.deleteBuffer(this.Vt)),this.Ht=null,this.Vt=null,this.r=null,this.I=null,this.Z=-1,this._=-1,this.ce=[],this.Ut.clear(),this.q=null,this.oe=0,this.$e=[],this.mt.clear(),this.d=null,this.Oe=null,this.je=null}};hn();De();fe();var ha=4,Bn=30;function Ef(e,t){let n=0,i=e.depth[t],r=new Int32Array(128);r[0]=t;let o=1;for(;o>0;){o--;let s=r[o],l=e.depth[s]-i;l>n&&(n=l);for(let a=e.firstChild[s];a!==-1;a=e.nextSibling[a]){if(o>=r.length){let u=new Int32Array(r.length*2);u.set(r),r=u}r[o++]=a}}return n}function $o(e,t,n){let i=e.depth[t],r=Math.max(1,Ef(e,t)),s=Math.max(0,n-Bn)/r;e.a0[t]=0,e.a1[t]=2*Math.PI,e.r0[t]=0,e.r1[t]=Bn,xa(e,t,0,2*Math.PI,Bn,s,i)}function xa(e,t,n,i,r,o,s){let l=e.value[t];if(l<=0)return;let a=i-n,u=n;for(let m=e.firstChild[t];m!==-1;m=e.nextSibling[m]){let f=e.value[m];if(f<=0)continue;let c=f/l,p=u,b=u+a*c;u=b;let g=r,x=r+o;e.a0[m]=p,e.a1[m]=b,e.r0[m]=g,e.r1[m]=x;let h=b-p,y=(g+x)/2;h*y*o<ha||e.firstChild[m]!==-1&&xa(e,m,p,b,x,o,s)}}function ya(e,t){e.oe=jo(e,t,0)}function jo(e,t,n){let i=e.a,r=i.a0,o=i.a1,s=i.r0,l=i.r1,a=i.firstChild,u=i.nextSibling,m=i.value;(!e.q||e.q.length<i.count)&&(e.q=new Int32Array(i.count));let f=e.q,c=n,p=new Int32Array(128);p[0]=t;let b=1;for(;b>0;){b--;let g=p[b];if(m[g]<=0)continue;f[c++]=g;let x=o[g]-r[g],h=(s[g]+l[g])/2,y=x*h,_=l[g]-s[g];if(!(y*_<ha))for(let C=a[g];C!==-1;C=u[C]){if(b>=p.length){let v=new Int32Array(p.length*2);v.set(p),p=v}p[b++]=C}}return c}Gt();Ne();var yr=32,Pf=28,Gf=90;function Cr(e,t){if(e.m.length===0)return{centerX:e.ft,centerY:e.ct};let n=e.a;for(let i of e.m){let r=t;for(;r!==-1;){if(r===i.drillRoot)return{centerX:i.centerX,centerY:i.centerY};r=n.parent[r]}}return{centerX:e.ft,centerY:e.ct}}function va(e,t){if(e._===-1)return;let n=t.gl,i=t.cssWidth,r=t.cssHeight;if(i<=0||r<=0)return;let o=e.B.length>0&&e.W.facet_mode==="grid",s=e.Ce==="series"?e.c.size>1:e.Ce==="numeric"&&e.b<e.p,l=!o&&e.ce.length>1?Pf:0,a=_i(e.i,s,Gf);if(o)Wf(e,i,r,a);else{e.d=null,e.m=[];let b=i-a,g=r-l;e.ft=b/2,e.ct=l+g/2,e.fr=Math.max(0,Math.min(b,g)/2-4),$o(e.a,e._,e.fr),ya(e,e._)}kf(e,t);let u=e.T(),m=u.k,f=pe(u.Ge,m,Math.max(1,e.c.size));if(e.K){let b=e.K.getContext("2d");b&&b.clearRect(0,0,e.K.width,e.K.height)}let c=t.dpr;e.At=!0,Nf(e,n,m,f,u.fi,c),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.r);let p=e.I;if(n.uniform2f(p.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(p.u_border_px,u.zr*c),e.m.length>0)for(let b of e.m)b.instanceCount!==0&&(n.uniform2f(p.u_center,b.centerX*c,b.centerY*c),Ca(e,n,t,b.instanceStart,b.instanceCount));else n.uniform2f(p.u_center,e.ft*c,e.ct*c),Ca(e,n,t,0,e.cr);e.he(()=>nt(e))}function Wf(e,t,n,i){let r=e.a,o=[],s=[];for(let f=r.firstChild[e.Z];f!==-1;f=r.nextSibling[f])r.value[f]<=0||(o.push(f),s.push(r.name[f]));let l=Math.max(1,t-i),a=Fe(s,{cssWidth:l,cssHeight:n,hasLegend:!1,xAxis:"none",yAxis:"none",gap:e.W.facet_padding});e.d=a;let u=[],m=0;for(let f=0;f<o.length;f++){let c=o[f],p=a.cells[f];if(!p)continue;let b=r.name[c],g=e.mt.get(b)??c,x=p.layout.e,h=x.x+x.width/2,y=x.y+x.height/2,_=Math.max(0,Math.min(x.width,x.height)/2-4);$o(r,g,_);let C=jo(e,g,m),v=m,A=C-m;u.push({label:b,centerX:h,centerY:y,maxRadius:_,drillRoot:g,instanceStart:v,instanceCount:A,nodeStart:v,nodeCount:A}),m=C}e.oe=m,e.m=u,u.length>0&&(e.ft=u[0].centerX,e.ct=u[0].centerY,e.fr=u[0].maxRadius)}function kf(e,t){if(e.r)return;let n=t.gl,i=j(t,"sunburst-arc",ni,ii,["u_center","u_resolution","u_border_px"],["a_strip_t","a_side","a_angles","a_radii","a_color"]);e.r=i.program,e.I=i;let r=new Float32Array((yr+1)*2*2);for(let o=0;o<=yr;o++){let s=o/yr,l=o*4;r[l+0]=s,r[l+1]=0,r[l+2]=s,r[l+3]=1}e.bn=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.bn),n.bufferData(n.ARRAY_BUFFER,r,n.STATIC_DRAW),e.gn=n.createBuffer()}function Nf(e,t,n,i,r,o){let s=e.a,l=e.q,a=e.m.length>0,u=a?e.m.reduce((p,b)=>p+b.instanceCount,0):e.oe,m=new Float32Array(u*8),f=0,c=(p,b,g)=>{let x=f;for(let h=p;h<b;h++){let y=l[h];if(y===g)continue;let _=s.a0[y],C=s.a1[y],v=s.r0[y],A=s.r1[y];if(C<=_||A<=v)continue;let L=ar(e,y,n,i,r),T=f*8;m[T+0]=_,m[T+1]=C,m[T+2]=v*o,m[T+3]=A*o,m[T+4]=L[0],m[T+5]=L[1],m[T+6]=L[2],m[T+7]=L[3],f++}return{rangeStart:x,rangeCount:f-x}};if(a)for(let p of e.m){let b=p.instanceStart,g=b+p.instanceCount,{rangeStart:x,rangeCount:h}=c(b,g,p.drillRoot);p.instanceStart=x,p.instanceCount=h}else c(0,e.oe,e._);e.cr=f,t.bindBuffer(t.ARRAY_BUFFER,e.gn),t.bufferData(t.ARRAY_BUFFER,m.subarray(0,f*8),t.DYNAMIC_DRAW)}function Ca(e,t,n,i,r){if(r===0)return;let o=e.I;t.bindBuffer(t.ARRAY_BUFFER,e.bn);let s=2*Float32Array.BYTES_PER_ELEMENT;t.enableVertexAttribArray(o.a_strip_t),t.vertexAttribPointer(o.a_strip_t,1,t.FLOAT,!1,s,0),t.enableVertexAttribArray(o.a_side),t.vertexAttribPointer(o.a_side,1,t.FLOAT,!1,s,Float32Array.BYTES_PER_ELEMENT);let l=J(n),{setDivisor:a}=l;a(o.a_strip_t,0),a(o.a_side,0),t.bindBuffer(t.ARRAY_BUFFER,e.gn);let u=8*Float32Array.BYTES_PER_ELEMENT,m=Float32Array.BYTES_PER_ELEMENT,f=i*u;t.enableVertexAttribArray(o.a_angles),t.vertexAttribPointer(o.a_angles,2,t.FLOAT,!1,u,f),a(o.a_angles,1),t.enableVertexAttribArray(o.a_radii),t.vertexAttribPointer(o.a_radii,2,t.FLOAT,!1,u,f+2*m),a(o.a_radii,1),t.enableVertexAttribArray(o.a_color),t.vertexAttribPointer(o.a_color,4,t.FLOAT,!1,u,f+4*m),a(o.a_color,1),l.drawArraysInstanced(t.TRIANGLE_STRIP,0,2*(yr+1),r),a(o.a_angles,0),a(o.a_radii,0),a(o.a_color,0)}function nt(e){Of(e),e.presentOverlay()}function Of(e){if(!e.u||e._===-1)return;let t=e.t;if(!t)return;let{dpr:n,cssWidth:i,cssHeight:r}=t;ur(e,e.u,n,i,r,o=>Uf(e,o,n,i,r),e.P!==-1?o=>{Hf(o,e,e.P),Vf(e,o,e.P,i,r,e.T().fontFamily)}:null)}function Uf(e,t,n,i,r){let o=e.u;t.clearRect(0,0,o.width,o.height),t.save(),t.scale(n,n);let s=e.T(),{fontFamily:l,Me:a,li:u}=s,m=s.k,f=pe(s.Ge,m,Math.max(1,e.c.size)),c=e.a,p=e.q,b=e.oe,g=e.m.length>0;if(g)for(let h of e.m){let y=h.nodeStart+h.nodeCount;for(let _=h.nodeStart;_<y;_++){let C=p[_];C!==h.drillRoot&&_a(e,t,C,l,m,f,h.centerX,h.centerY)}}else for(let h=0;h<b;h++){let y=p[h];y!==e._&&_a(e,t,y,l,m,f,e.ft,e.ct)}let x=Math.max(0,Bn-s.zr*.5);if(t.fillStyle=u,t.textAlign="center",t.textBaseline="middle",g){for(let h of e.m)if(t.beginPath(),t.fillStyle=u,t.arc(h.centerX,h.centerY,x,0,2*Math.PI),t.fill(),t.fillStyle=a,t.font=`11px ${l}`,t.fillText(c.name[h.drillRoot],h.centerX,h.centerY),e.d){let y=e.d.cells.find(_=>_.label===h.label);y?.titleRect&&(t.fillStyle=a,t.font=`11px ${l}`,t.textBaseline="middle",t.fillText(h.label,y.titleRect.x+y.titleRect.width/2,y.titleRect.y+y.titleRect.height/2))}}else t.beginPath(),t.arc(e.ft,e.ct,x,0,2*Math.PI),t.fill(),t.fillStyle=a,t.font=`11px ${l}`,t.fillText(c.name[e._],e.ft,e.ct);!g&&e.ce.length>1&&mr(e,t,i,l,a),cr(e,o,f,m,s,i,r,g?e.d?.legendRect??null:null),t.restore()}function _a(e,t,n,i,r,o,s,l){let a=e.a,u=a.a0[n],m=a.a1[n],f=a.r0[n],c=a.r1[n],p=c-f,b=(f+c)/2,x=(m-u)*b;if(p<16||x<8)return;let h=Math.min(11,Math.floor(x*.7));if(h<7)return;t.font=`${h}px ${i}`;let y=a.name[n],_=p-4,C=y;if(t.measureText(C).width>_){for(;C.length>1;)if(C=C.slice(0,-1),t.measureText(C+"\\u2026").width<=_){C+="\\u2026";break}}if(C.length<2)return;let v=(u+m)/2;t.save(),t.translate(s,l);let A=v,L=v>Math.PI/2&&v<3*Math.PI/2;e.ro==="upright"&&L&&(A+=Math.PI),t.rotate(A);let T=In(e,n,r,o),w=lr(T[0],T[1],T[2]);t.fillStyle=w>.5?"rgba(0,0,0,0.85)":"rgba(255,255,255,0.9)",t.textAlign="center",t.textBaseline="middle";let M=e.ro==="upright"&&L?-b:b;t.fillText(C,M,0),t.restore()}function Hf(e,t,n){let i=t.a,r=i.a0[n],o=i.a1[n],s=i.r0[n],l=i.r1[n],{centerX:a,centerY:u}=Cr(t,n);e.strokeStyle="rgba(255,255,255,0.9)",e.lineWidth=2,e.beginPath(),e.arc(a,u,l,r,o),e.arc(a,u,s,o,r,!0),e.closePath(),e.stroke()}function Vf(e,t,n,i,r,o){let s=e.a,l=(s.a0[n]+s.a1[n])/2,a=(s.r0[n]+s.r1[n])/2,{centerX:u,centerY:m}=Cr(e,n),f=u+Math.cos(l)*a,c=m+Math.sin(l)*a;fr(e,t,n,f,c,i,r,o)}function Aa(e,t,n){if(e.m.length===0)return{centerX:e.ft,centerY:e.ct,drillRoot:e._};for(let i of e.m){let r=t-i.centerX,o=n-i.centerY;if(!(Math.sqrt(r*r+o*o)>i.maxRadius+4))return{centerX:i.centerX,centerY:i.centerY,drillRoot:i.drillRoot}}return null}function Yf(e,t,n){let i=e.a,r=t;for(;r!==-1;){if(r===n)return!0;r=i.parent[r]}return!1}function La(e,t,n){let i=Aa(e,t,n);if(!i)return-1;let r=e.a,o=e.q,s=e.oe;if(!o)return-1;let l=t-i.centerX,a=n-i.centerY,u=Math.sqrt(l*l+a*a),m=Math.atan2(a,l);if(m<0&&(m+=2*Math.PI),u<r.r1[e.Z]+.001&&i.drillRoot!==e.Z)return i.drillRoot;let f=e.m.length>0;for(let c=0;c<s;c++){let p=o[c];if(p===i.drillRoot||f&&!Yf(e,p,i.drillRoot))continue;let b=r.a0[p],g=r.a1[p],x=r.r0[p],h=r.r1[p];if(!(u<x||u>h)&&!(m<b||m>g))return p}return-1}function Ta(e,t,n){if(e.se!==-1)return;for(let o of e.$e)if(t>=o.x0&&t<=o.x1&&n>=o.y0&&n<=o.y1){e.L.setCursor("pointer"),e.P!==-1&&(e.P=-1,nt(e));return}let i=La(e,t,n),r=e.a;if(e.L.setCursor(i!==-1&&r.firstChild[i]!==-1?"pointer":"default"),i!==e.P){if(e.P=i,i!==-1){let o=e.N.beginHover(i);Tt(e,i).then(s=>{e.N.commitHover(o,s)&&nt(e)})}else e.N.clearHover();nt(e)}}function wa(e,t,n){if(e.se!==-1){_r(e),e.emitUnselect();return}for(let s of e.$e)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e._&&(Zo(e,s.nodeId),e.emitUnselect());return}let i=e.a,r=Aa(e,t,n);if(r){let s=t-r.centerX,l=n-r.centerY;if(Math.sqrt(s*s+l*l)<i.r1[e.Z]+.001){let u=i.parent[r.drillRoot];if(u!==-1&&u!==e.Z)Zo(e,u),e.emitUnselect();else if(e.m.length>0){let m=e.m.find(f=>f.drillRoot===r.drillRoot);m&&(e.mt.delete(m.label),e.emitUnselect()),e.t&&e.requestRender(e.t)}return}}let o=La(e,t,n);o!==-1&&(i.firstChild[o]!==-1?(Zo(e,o),Ye(e,o,"branch")):(zf(e,o),Ye(e,o,"leaf")))}function Zo(e,t){gr(e,t,()=>{e.t&&e.requestRender(e.t)})}function zf(e,t){let n=e.a,i=(n.a0[t]+n.a1[t])/2,r=(n.r0[t]+n.r1[t])/2,{centerX:o,centerY:s}=Cr(e,t),l=o+Math.cos(i)*r,a=s+Math.sin(i)*r;pr(e,t,{cx:l,cy:a},()=>nt(e))}function _r(e){br(e)}var vr=class extends Zt{constructor(){super(...arguments);d(this,"r",null);d(this,"I",null);d(this,"bn",null);d(this,"gn",null);d(this,"cr",0);d(this,"ro","upright");d(this,"ft",0);d(this,"ct",0);d(this,"fr",0);d(this,"P",-1);d(this,"se",-1);d(this,"$e",[]);d(this,"de",null);d(this,"At",!0);d(this,"Wn",0);d(this,"d",null);d(this,"mt",new Map);d(this,"m",[])}tooltipCallbacks(){return{onHover:(n,i)=>Ta(this,n,i),onLeave:()=>{this.P!==-1&&this.se===-1&&(this.P=-1,nt(this))},onClickPre:(n,i)=>(wa(this,n,i),!0)}}async uploadAndRender(n,i,r,o){if(this.t=n,r===0){let s=this.M;if(this.ie=s[0]||tr(i)||"",this.s=s[1]||"",!this.s)this.Ce="empty";else{let l=this.ze[this.s],a=l==="float"||l==="integer"||l==="date"||l==="datetime";this.Ce=a?"numeric":"series"}this.P=-1,this.se=-1,this.$e=[],this.mt.clear(),this.d=null,this.m=[],this.cr=0,this.N.clearHover(),this.N.invalidatePin(),_r(this),this.de?.close(),this.de=null,this.At=!0,this.Wn++,Mn(this)}Rn(this,i),Sn(this),this.Z!==-1&&await this.requestRender(n)}Wt(n){this.Z!==-1&&(this.t=n,va(this,n))}destroyInternal(){_r(this),this.de?.close(),this.de=null;let n=this.t?.gl;n&&(this.bn&&n.deleteBuffer(this.bn),this.gn&&n.deleteBuffer(this.gn)),this.bn=null,this.gn=null,this.r=null,this.I=null,this.Z=-1,this._=-1,this.ce=[],this.Ut.clear(),this.q=null,this.oe=0,this.$e=[],this.d=null,this.mt.clear(),this.m=[]}};dn();var Qt=class extends Se{constructor(){super(...arguments);d(this,"Ie",[]);d(this,"te",0);d(this,"dt",0);d(this,"r",null);d(this,"O",null);d(this,"l",null);d(this,"ue",null);d(this,"me",null);d(this,"Fe",null);d(this,"xi",!0)}getZoomConfig(){return{lockAxis:"y"}}};pn();function Ar(e,t=.5,n=.1){let i=t/Math.max(1,e),r=i*(1-n)/2;return{slotWidth:i,halfWidth:r}}de();function Ma(e,t,n="bar"){let i=t?.[e]?.chart_type?.toLowerCase?.();return i==="bar"||i==="line"||i==="scatter"||i==="area"?i:n}function Ra(e,t,n){let i=n?.[e]?.stack;return typeof i=="boolean"?i:t==="bar"||t==="area"}function qo(e,t){return t?.[e]?.alt_axis===!0}function Sa(e,t,n){let i=n?.[e.aggName];if(!i)return null;let r=typeof i.palette=="string"?Xf(i.palette):null;if(r&&r.length>0){let o=t?0:e.splitIdx%r.length;return r[o]}return typeof i.color=="string"?xo(i.color)??null:null}var Lr=new Map;function Xf(e){let t=Lr.get(e);return t===void 0&&(t=Ai(e),Lr.size>256&&Lr.clear(),Lr.set(e,t)),t}function Fa(e,t,n){if(t!=="line"&&t!=="area")return"skip";let i=n?.[e]?.interpolate;return i===void 0||t==="area"?"solid":i}var Ia=50,wt=0,Tr=1;function wr(){return{count:0,catIdx:new Int32Array(0),seriesId:new Int32Array(0),axis:new Uint8Array(0),chartType:new Uint8Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),y0:new Float64Array(0),y1:new Float64Array(0)}}function $f(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),seriesId:new Int32Array(t),axis:new Uint8Array(t),chartType:new Uint8Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),y0:new Float64Array(t),y1:new Float64Array(t)}}function En(e,t,n,i,r){let o=e.seriesId[t],s=e.catIdx[t];return{catIdx:s,aggIdx:Math.floor(o/n),splitIdx:o%n,seriesId:o,xCenter:e.xCenter[t],halfWidth:e.halfWidth[t],y0:e.y0[t],y1:e.y1[t],value:i[s*r+o],axis:e.axis[t],chartType:e.chartType[t]===wt?"bar":"area"}}function Da(e,t){return e&&e.length>=t?e:new Float64Array(Math.max(t,e?.length??0))}function Ba(e,t){e[t>>3]|=1<<(t&7)}function Ea(e){let{columns:t,numRows:n,columnSlots:i,groupBy:r,splitBy:o,groupByTypes:s,columnsConfig:l,defaultChartType:a,autoAltYAxis:u,bandInnerFrac:m,barInnerPad:f,includeZero:c,facetSplits:p,scratchBars:b,scratchPosStack:g,scratchNegStack:x}=e,h=qt(r,s),y={aggregates:[],splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:h,numericCategoryDomain:null,categoryPositions:null,series:[],bars:wr(),posStack:g??null,negStack:x??null,samples:new Float32Array(0),sampleValid:new Uint8Array(0),leftDomain:{min:0,max:0},rightDomain:null,hasRightAxis:!1,leftValueAxisMode:"numeric",rightValueAxisMode:null,leftValueCategoryDomain:null,rightValueCategoryDomain:null},_=i.filter(R=>!!R);if(_.length===0)return y;let C=[];if(o.length>0){for(let R of qe(t,[],_))R.colNames.size>0&&C.push(R.prefix);C.length===0&&C.push("")}else C.push("");let v=r.map(R=>s[R]??"string"),{rowPaths:A,numCategories:L,rowOffset:T}=Kt(t,n,r.length,v,h);if(L===0)return{...y,rowPaths:A,rowOffset:T};let w=[],M=_.length,D=C.length;for(let R=0;R<M;R++)for(let E=0;E<D;E++){let P=_[R],O=C[E],X=O===""?P:`${O}${M>1?` | ${P}`:""}`,V=Ma(P,l,a),Z=Ra(P,V,l),ge=Fa(P,V,l);w.push({seriesId:R*D+E,aggIdx:R,splitIdx:E,aggName:P,splitKey:O,label:X,color:[.5,.5,.5],axis:0,chartType:V,stack:Z,start:-1,end:-1,interpolateMode:ge})}let I=[];for(let R=0;R<M;R++)I.push(c?{min:0,max:0}:{min:1/0,max:-1/0});let F=L,B=w.length,N=p?F*M*D:F*M,k=Da(g??null,N),Y=Da(x??null,N);k.fill(0,0,N),Y.fill(0,0,N);let W=new Float32Array(F*B),H=new Uint8Array(F*B+7>>3),U=null,z=null,q=1;if(h.mode==="numeric"&&F>0){let R=t.get("__ROW_PATH_0__"),E=Lt(R?.values,F,T,r[0]??"",h.numericType==="date"||h.numericType==="datetime");E&&(U=E.categoryPositions,z=E.numericCategoryDomain,q=E.numericCategoryDomain.bandWidth)}let ae=Ar(M,m,f),Be=ae.slotWidth*q,we=ae.halfWidth*q,Me=new Float64Array(M),st=(M-1)/2;for(let R=0;R<M;R++)Me[R]=(R-st)*Be;let sn=new Array(M*D),ln=new Array(M*D);for(let R=0;R<M;R++){let E=_[R];for(let P=0;P<D;P++){let O=C[P],X=O===""?E:`${O}|${E}`,V=t.get(X),Z=R*D+P;sn[Z]=V?.values??null,ln[Z]=V?.valid??null}}let an=new Array(M),ye=new Array(M),se=!1;for(let R=0;R<M;R++){let E=_[R],P=C[0],O=P===""?E:`${P}|${E}`;an[R]=t.get(O)?.type==="string",ye[R]=qo(E,l)?1:0,an[R]&&(se=!0)}let Q=[],re=[],Ee=[],Pe=[];for(let R=0;R<M;R++){let E=_[R];for(let P=0;P<D;P++){let O=C[P],X=O===""?E:`${O}|${E}`,V=R*D+P,Z={name:X,type:an[R]?"string":"numeric",data:t.get(X)};ye[R]===0?(Q.push(Z),Ee.push(V)):(re.push(Z),Pe.push(V))}}let Ls=Q.map(R=>R.name).filter((R,E,P)=>P.indexOf(R)===E).join(", "),qr=re.map(R=>R.name).filter((R,E,P)=>P.indexOf(R)===E).join(", "),Ge=Q.length>0?Uo(Q,n,T,Ls):null,K=re.length>0?Uo(re,n,T,qr):null,Mt=new Array(M*D).fill(null);if(Ge)for(let R=0;R<Ee.length;R++)Mt[Ee[R]]=Ge.perColumnSlots[R];if(K)for(let R=0;R<Pe.length;R++)Mt[Pe[R]]=K.perColumnSlots[R];let Tu=F*M*D,$=$f(b??null,Tu),ee=0;for(let R=0;R<F;R++){let E=R+T;for(let P=0;P<M;P++)for(let O=0;O<D;O++){let X=P*D+O,V=Mt[X];if(V){let le=P*D+O,Ce=R*B+le;W[Ce]=V[R],Ba(H,Ce);continue}let Z=sn[X];if(!Z)continue;let ge=ln[X];if(ge&&!(ge[E>>3]>>(E&7)&1))continue;let te=Z[E];if(!isFinite(te))continue;let St=P*D+O,at=R*B+St;W[at]=te,Ba(H,at)}}for(let R=0;R<B;R++){let E=-1,P=-1;for(let O=0;O<F;O++){let X=O*B+R;H[X>>3]>>(X&7)&1&&(E===-1&&(E=O),P=O)}w[R].start=E,w[R].end=P}for(let R=0;R<B;R++){let E=w[R];if(!(E.start<0)&&E.interpolateMode!=="skip"){if(E.chartType==="line"){let P=E.start;for(let O=E.start+1;O<=E.end;O++){let X=O*B+R;if(H[X>>3]>>(X&7)&1){if(O-P>1){let Z=P*B+R,ge=W[Z],te=W[X],St=U?U[P]:P,le=(U?U[O]:O)-St;for(let Ce=1;Ce<O-P;Ce++){let ce=P+Ce,_e=U?U[ce]:ce,Du=le===0?0:(_e-St)/le;W[ce*B+R]=ge+(te-ge)*Du}}P=O}}}else if(E.chartType==="area"){for(let P=0;P<E.start;P++)W[P*B+R]=0;for(let P=E.end+1;P<F;P++)W[P*B+R]=0;E.start=0,E.end=F-1}}}for(let R=0;R<F;R++){let E=U?U[R]:R;for(let P=0;P<M;P++){let O=Me[P],X=E+O,V=I[P];for(let Z=0;Z<D;Z++){let ge=P*D+Z,te=w[ge];if(R<te.start||R>te.end)continue;let St=te.chartType==="line"||te.chartType==="area"&&te.interpolateMode!=="skip",at=R*B+ge;if(!St&&!(H[at>>3]>>(at&7)&1))continue;let le=W[at];if((te.chartType==="bar"||te.chartType==="area")&&te.stack){if(le===0&&(te.chartType!=="area"||te.interpolateMode==="skip"))continue;let Ce=p?(R*M+P)*D+Z:R*M+P,ce,_e;le>=0?(ce=k[Ce],_e=ce+le,k[Ce]=_e):(ce=Y[Ce],_e=ce+le,Y[Ce]=_e),ce<V.min&&(V.min=ce),_e<V.min&&(V.min=_e),ce>V.max&&(V.max=ce),_e>V.max&&(V.max=_e),$.catIdx[ee]=R,$.seriesId[ee]=ge,$.axis[ee]=0,$.chartType[ee]=te.chartType==="bar"?wt:Tr,$.xCenter[ee]=X,$.halfWidth[ee]=we,$.y0[ee]=ce,$.y1[ee]=_e,ee++}else if(le<V.min&&(V.min=le),le>V.max&&(V.max=le),c&&(0<V.min&&(V.min=0),0>V.max&&(V.max=0)),te.chartType==="bar"||te.chartType==="area"){if(le===0)continue;$.catIdx[ee]=R,$.seriesId[ee]=ge,$.axis[ee]=0,$.chartType[ee]=te.chartType==="bar"?wt:Tr,$.xCenter[ee]=X,$.halfWidth[ee]=we,$.y0[ee]=0,$.y1[ee]=le,ee++}}}}$.count=ee;let Rt=!1;if(u&&M>=2&&!se){let R=new Array(M),E=0,P=1/0;for(let O=0;O<M;O++){let X=I[O],V=Math.max(Math.abs(X.min),Math.abs(X.max),1e-12);R[O]=V,V>E&&(E=V),V<P&&(P=V)}if(E/P>Ia){let O=E/Math.sqrt(Ia);for(let X=0;X<M;X++)if(R[X]<O)for(let Z of w)Z.aggIdx===X&&(Z.axis=1);for(let X=0;X<$.count;X++)$.axis[X]=w[$.seriesId[X]].axis;Rt=w.some(X=>X.axis===1)}}let Ts=!1;for(let R=0;R<M;R++)if(qo(_[R],l))for(let E of w)E.aggIdx===R&&(E.axis=1,Ts=!0);if(Ts){for(let R=0;R<$.count;R++)$.axis[R]=w[$.seriesId[R]].axis;Rt=!0}let We=c?{min:0,max:0}:{min:1/0,max:-1/0},lt=c?{min:0,max:0}:{min:1/0,max:-1/0};for(let R=0;R<$.count;R++){let E=$.axis[R]===0?We:lt,P=$.y0[R],O=$.y1[R];P<E.min&&(E.min=P),O<E.min&&(E.min=O),P>E.max&&(E.max=P),O>E.max&&(E.max=O)}for(let R=0;R<B;R++){let E=w[R];if(E.stack&&(E.chartType==="bar"||E.chartType==="area")||E.start<0)continue;let P=E.chartType==="line"||E.chartType==="area"&&E.interpolateMode!=="skip",O=E.axis===0?We:lt;for(let X=E.start;X<=E.end;X++){let V=X*B+R;if(!P&&!(H[V>>3]>>(V&7)&1))continue;let Z=W[V];Z<O.min&&(O.min=Z),Z>O.max&&(O.max=Z)}}(!isFinite(We.min)||!isFinite(We.max)||We.min===0&&We.max===0)&&(We.min=0,We.max=1);let wu=!isFinite(lt.min)||!isFinite(lt.max)||lt.min===0&<.max===0,Mu=Rt?wu?{min:0,max:1}:lt:null,Ru=Ge?"category":"numeric",Su=Rt?K?"category":"numeric":null,Fu=Ge&&Ge.domain.numRows>0?{min:0,max:Math.max(0,Ge.domain.numRows-1)}:We,Iu=K&&K.domain.numRows>0&&Rt?{min:0,max:Math.max(0,K.domain.numRows-1)}:Mu;return{aggregates:_,splitPrefixes:C,rowPaths:A,numCategories:L,rowOffset:T,axisMode:h,numericCategoryDomain:z,categoryPositions:U,series:w,bars:$,posStack:k,negStack:Y,samples:W,sampleValid:H,leftDomain:Fu,rightDomain:Iu,hasRightAxis:Rt,leftValueAxisMode:Ru,rightValueAxisMode:Su,leftValueCategoryDomain:Ge?.domain??null,rightValueCategoryDomain:K?.domain??null}}Ke();xn();Bt();De();var Ko=wt;function Pa(e,t,n,i){let r=i?.start??0,o=i?.count??e.kn;if(e.kn===0||o===0)return;let s=e.I,l=J(n),{setDivisor:a}=l;t.bindBuffer(t.ARRAY_BUFFER,e.O),t.enableVertexAttribArray(s.a_corner),t.vertexAttribPointer(s.a_corner,2,t.FLOAT,!1,0,0),a(s.a_corner,0),tt(n,l,s.a_x_center,"bar_x",1,r)&&tt(n,l,s.a_half_width,"bar_hw",1,r)&&tt(n,l,s.a_y0,"bar_y0",1,r)&&tt(n,l,s.a_y1,"bar_y1",1,r)&&tt(n,l,s.a_color,"bar_color",3,r)&&tt(n,l,s.a_series_id,"bar_sid",1,r)&&tt(n,l,s.a_axis,"bar_axis",1,r)&&l.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,o),a(s.a_x_center,0),a(s.a_half_width,0),a(s.a_y0,0),a(s.a_y1,0),a(s.a_color,0),a(s.a_series_id,0),a(s.a_axis,0)}var Mr=10;function en(e){return e.De>=0?En(e._e,e.De,e.pe.length,e.Qe,e.f.length):e.Be}function Jo(e,t,n){if(!e.l)return;let i=e.l,r;if(e.d){let C=e.d.cells,v=-1;for(let A=0;A<C.length;A++){let L=C[A].layout.e;if(t>=L.x&&t<=L.x+L.width&&n>=L.y&&n<=L.y+L.height){v=A;break}}if(v<0){Ga(e);return}i=C[v].layout,r=v}let o=i.e;if(t<o.x||t>o.x+o.width||n<o.y||n>o.y+o.height){Ga(e);return}let s=i.$,l=i.J,a=i.j,u=i.Q,m,f,c,p;if(e.et){let C=s,v=l,A=Math.min(a,u),L=Math.max(a,u),T=C+(t-o.x)/o.width*(v-C);m=A+(n-o.y)/o.height*(L-A),f=T,c=o.height/(L-A),p=o.width/(v-C)}else m=s+(t-o.x)/o.width*(l-s),f=u-(n-o.y)/o.height*(u-a),c=o.width/(l-s),p=o.height/(u-a);let b=e.hn&&e.ne&&!e.et?e.ne.max-(n-o.y)/o.height*(e.ne.max-e.ne.min):f,g=e.hn&&e.ne&&!e.et?o.height/(e.ne.max-e.ne.min):p,x=-1,h=null,y=e.Yt,_=y.length<=1;for(let C=y.length-1;C>=0;C--){let v=y[C],A=_?void 0:{start:v.aggStart,end:v.aggEnd};switch(v.chartType){case"scatter":case"line":h=Zf(e,v.chartType,m,f,b,c,p,g,r,A);break;case"bar":x=jf(e,m,f,b,r,A);break;case"area":{let L=qf(e,m,f,b,r,A);L&&(L.idx>=0?x=L.idx:h=L.bar);break}}if(x>=0||h)break}Kf(e,x,h)}function jf(e,t,n,i,r,o){let s=e._e,l=s.chartType,a=s.seriesId,u=s.xCenter,m=s.halfWidth,f=s.y0,c=s.y1,p=s.axis,b=e.ee,g=Math.max(1,e.pe.length);for(let x=0;x<s.count;x++){if(l[x]!==wt||b.has(a[x])||r!==void 0&&a[x]%g!==r)continue;if(o!==void 0){let T=Math.floor(a[x]/g);if(T<o.start||T>o.end)continue}let h=u[x],y=m[x];if(t<h-y||t>h+y)continue;let _=p[x]===0?n:i,C=f[x],v=c[x],A=C<v?C:v,L=C<v?v:C;if(_>=A&&_<=L)return x}return-1}function Zf(e,t,n,i,r,o,s,l,a,u){let m=e.te,f=e.f.length;if(m===0||f===0)return null;let c=e.Qe,p=e.zt,g=Mr*Mr,x=null,h=e.le;for(let y of e.f){if(y.chartType!==t||e.ee.has(y.seriesId)||a!==void 0&&y.splitIdx!==a||u!==void 0&&(y.aggIdx<u.start||y.aggIdx>u.end))continue;let _=y.axis===1?r:i,C=y.axis===1?l:s,v=h?0:Math.max(0,Math.floor(n-Mr/o)),A=h?m-1:Math.min(m-1,Math.ceil(n+Mr/o));for(let L=v;L<=A;L++){let T=L*f+y.seriesId;if(!(p[T>>3]>>(T&7)&1))continue;let w=c[T],M=h?h[L]:L,D=(M-n)*o,I=(w-_)*C,F=D*D+I*I;F<g&&(g=F,x={catIdx:L,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:M,halfWidth:0,y0:0,y1:w,value:w,axis:y.axis,chartType:"bar"})}}return x}function qf(e,t,n,i,r,o){let s=Math.round(t);if(s<0||s>=e.te||Math.abs(t-s)>.5)return null;let l=e.f.length,a=e.Qe,u=e.zt,m=e._e,f=m.chartType,c=m.catIdx,p=m.seriesId,b=m.axis,g=m.y0,x=m.y1,h=e.pe.length;for(let y=0;y<m.count;y++){if(f[y]!==Tr||c[y]!==s||e.ee.has(p[y])||r!==void 0&&p[y]%h!==r)continue;if(o!==void 0){let T=Math.floor(p[y]/Math.max(1,h));if(T<o.start||T>o.end)continue}let _=b[y]===0?n:i,C=g[y],v=x[y],A=C<v?C:v,L=C<v?v:C;if(_>=A&&_<=L)return{idx:y,bar:null}}for(let y of e.f){if(y.chartType!=="area"||y.stack||e.ee.has(y.seriesId)||r!==void 0&&y.splitIdx!==r||o!==void 0&&(y.aggIdx<o.start||y.aggIdx>o.end))continue;let _=s*l+y.seriesId;if(!(u[_>>3]>>(_&7)&1))continue;let C=a[_],v=y.axis===1?i:n,A=Math.min(0,C),L=Math.max(0,C);if(v>=A&&v<=L)return{idx:-1,bar:{catIdx:s,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:s,halfWidth:.5,y0:0,y1:C,value:C,axis:y.axis,chartType:"area"}}}return null}function Ga(e){(e.De!==-1||e.Be!==null)&&(e.De=-1,e.Be=null,e.t&&e.requestRender(e.t))}function Kf(e,t,n){let i=e.De===t,r=(e.Be?.seriesId??-1)===(n?.seriesId??-1)&&(e.Be?.catIdx??-1)===(n?.catIdx??-1);i&&r||(e.De=t,e.Be=n,e.t&&e.requestRender(e.t))}function Wa(e,t,n){if(e.xn.length===0)return!1;for(let i of e.xn){let r=i.rect;if(t>=r.x&&t<=r.x+r.width&&n>=r.y&&n<=r.y+r.height){let o=i.seriesIds.some(s=>!e.ee.has(s));for(let s of i.seriesIds)o?e.ee.add(s):e.ee.delete(s);return e.Lt=null,e.oo=!1,e.Fi=null,e.t&&(Rr(e,e.t),Sr(e,e.t),e.requestRender(e.t)),!0}}return!1}function Qo(e,t){let n=[],i=e.f[t.seriesId],r=Jf(e,t.catIdx);r&&n.push(r);let o=e.getColumnFormatter(i.aggName,"value");return n.push(`${i.aggName}: ${o(t.value)}`),i.splitKey&&n.push(`Split: ${i.splitKey}`),t.y0!==0&&(n.push(`Base: ${o(t.y0)}`),n.push(`Top: ${o(t.y1)}`)),n}function Jf(e,t){if(e.Ue==="numeric"&&e.le){let i=e.le[t];if(i==null)return"";let r=e.C[0];return e.getColumnFormatter(r,"value")(i)}if(e.Ie.length===0)return"";let n=[];for(let i of e.Ie){let r=i.labels[t];r!=null&&r!==""&&n.push(r)}return n.join(" / ")}function ka(e,t){t<0||t>=e._e.count||(e.dr=t,Oa(e,En(e._e,t,e.pe.length,e.Qe,e.f.length)))}function Na(e,t){e.dr=-1,Oa(e,t)}function Oa(e,t){if(e.L.dismiss(),!e.l)return;let n=es(e,t);if(!n)return;let r=(e.f[t.seriesId]?.chartType??"bar")==="bar"?(t.y0+t.y1)/2:t.y1,o=t.axis===0?e.et?n.E(r,t.xCenter):n.E(t.xCenter,r):ts(e,t.xCenter,r,n),s=Qo(e,t);s.length!==0&&(e.L.pin(s,o,n),e.De=-1,e.Be=null,e.t&&e.requestRender(e.t))}Ae();_o();Ae();yt();Vt();Bi();function Ua(e,t,n){if(n)return n;if(!e.isDate)return me;let i=t.length>1?t[1]-t[0]:0;return r=>ve(r,i)}function ns(e,t,n,i,r,o,s){let{Me:l,fontFamily:a}=o,{e:u}=t,m=r==="bottom"?u.y+u.height:u.y;e.fillStyle=l,e.font=`11px ${a}`,e.lineWidth=1,Ii(e,u,i,m,r,f=>t.E(f,0).px,Ua(n,i,s)),e.font=`13px ${a}`,e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,u.x+u.width/2,r==="bottom"?t.cssHeight-2:10)}function is(e,t,n,i,r,o,s){let{Me:l,fontFamily:a}=o,{e:u}=t,m=r==="left"?u.x:u.x+u.width;e.fillStyle=l,e.font=`11px ${a}`,e.lineWidth=1,Di(e,u,i,m,r,f=>t.E(0,f).py,Ua(n,i,s)),e.font=`13px ${a}`,e.save(),r==="left"?(e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2)):(e.translate(t.cssWidth-10,u.y+u.height/2),e.rotate(Math.PI/2)),e.textAlign="center",e.textBaseline="bottom",e.fillText(n.label,0,0),e.restore()}function Fr(e,t,n,i,r,o){ns(e,t,n,i,"bottom",r,o)}function Ir(e,t,n,i,r,o){is(e,t,n,i,"left",r,o)}function Dr(e,t,n,i,r,o,s,l=!1,a={}){let u=ue(e,i,o);if(!u)return;let{e:m}=i;if(u.strokeStyle=r.mi,u.lineWidth=1,u.beginPath(),u.moveTo(m.x,m.y),u.lineTo(m.x,m.y+m.height),u.lineTo(m.x+m.width,m.y+m.height),s&&(l?(u.moveTo(m.x,m.y),u.lineTo(m.x+m.width,m.y)):(u.moveTo(m.x+m.width,m.y),u.lineTo(m.x+m.width,m.y+m.height))),u.stroke(),l){if(t.mode==="category"?Ie(u,i,t.domain,r):Ir(u,i,t.domain,t.ticks,r,a.category),n.mode==="category"?be(u,i,n.domain,r):ns(u,i,n.domain,n.ticks,"bottom",r,a.value),s)if(s.mode==="category")be(u,i,s.domain,r);else{let f=i.$,c=i.J;i.$=s.domain.min,i.J=s.domain.max,ns(u,i,s.domain,s.ticks,"top",r,a.alt),i.$=f,i.J=c}}else if(t.mode==="category"?be(u,i,t.domain,r):Fr(u,i,t.domain,t.ticks,r,a.category),n.mode==="category"?Ie(u,i,n.domain,r):is(u,i,n.domain,n.ticks,"left",r,a.value),s)if(s.mode==="category")Ie(u,i,s.domain,r);else{let f=i.j,c=i.Q;i.j=s.domain.min,i.Q=s.domain.max,is(u,i,s.domain,s.ticks,"right",r,a.alt),i.j=f,i.Q=c}}function Br(e,t,n,i,r,o=!1){let s=ue(e,t,r);s&&(s.strokeStyle=i.Tn,s.lineWidth=1,o?kt(s,t.e,n,l=>t.E(l,0).px):Nt(s,t.e,n,l=>t.E(0,l).py))}Vt();Gt();Fi();yt();Bi();Tn();Ne();var it=null;function Ha(e){if(it&&it.xCenters.length>=e&&it.colors.length>=e*3)return it;let t=Math.max(e,it?.xCenters.length??0);return it={xCenters:new Float32Array(t),halfWidths:new Float32Array(t),y0s:new Float32Array(t),y1s:new Float32Array(t),seriesIds:new Float32Array(t),axes:new Float32Array(t),colors:new Float32Array(t*3)},it}function Rr(e,t){let n=e._e,i=n.count,r=e.pe.length,o=e.Xt&&r>0,s=0;if(e.Ii=null,e.Nn=null,e.On=null,i>0){let a=Ha(i);(!e.Un||e.Un.length<i)&&(e.Un=new Int32Array(i));let u=e.Un,m=e.ae,f=e.f,c=e.ee,p=n.chartType,b=n.seriesId,g=n.xCenter,x=n.halfWidth,h=n.y0,y=n.y1,_=n.axis,C=Math.max(1,e.Tt.length),v=o?I=>I%r*C+Math.floor(I/r):I=>r>0?Math.floor(I/r):I,A=o?r*C:C,L=new Array(A).fill(0);for(let I=0;I<i;I++)p[I]!==Ko||c.has(b[I])||L[v(b[I])]++;let T=[],w=new Int32Array(A),M=0;for(let I=0;I<A;I++)T.push({start:M,count:L[I]}),w[I]=M,M+=L[I];o?(e.On=null,e.Nn=Array.from({length:r},(I,F)=>T.slice(F*C,(F+1)*C)),e.Ii=Array.from({length:r},(I,F)=>{let B=T[F*C],N=T[(F+1)*C-1];return{start:B.start,count:N.start+N.count-B.start}})):(e.On=T,e.Nn=null);let D=I=>w[v(I)]++;for(let I=0;I<i;I++){if(p[I]!==Ko)continue;let F=b[I];if(c.has(F))continue;let B=D(F);a.xCenters[B]=g[I]-m,a.halfWidths[B]=x[I],a.y0s[B]=h[I],a.y1s[B]=y[I],a.seriesIds[B]=F,a.axes[B]=_[I];let N=f[F].color;a.colors[B*3]=N[0],a.colors[B*3+1]=N[1],a.colors[B*3+2]=N[2],u[B]=I,s++}}else o&&(e.Ii=Array.from({length:r},()=>({start:0,count:0})));if(e.kn=s,s===0){e.Ze=null;return}let l=it;t.v.ensureCapacity(s),t.v.upload("bar_x",l.xCenters.subarray(0,s),0,1),t.v.upload("bar_hw",l.halfWidths.subarray(0,s),0,1),t.v.upload("bar_y0",l.y0s.subarray(0,s),0,1),t.v.upload("bar_y1",l.y1s.subarray(0,s),0,1),t.v.upload("bar_sid",l.seriesIds.subarray(0,s),0,1),t.v.upload("bar_axis",l.axes.subarray(0,s),0,1),t.v.upload("bar_color",l.colors.subarray(0,s*3),0,3),(!e.Ze||e.Ze.length<s*3)&&(e.Ze=new Float32Array(Math.max(s*3,e.Ze?.length??0))),e.Ze.set(l.colors.subarray(0,s*3))}function Qf(e,t){let n=e.kn;if(n===0)return;let i=e.Un,r=e.f,o=e._e.seriesId,s=Ha(n);for(let a=0;a<n;a++){let u=r[o[i[a]]].color;s.colors[a*3]=u[0],s.colors[a*3+1]=u[1],s.colors[a*3+2]=u[2]}let l=e.Ze;if(l&&l.length>=n*3){let a=!0;for(let u=0;u<n*3;u++)if(l[u]!==s.colors[u]){a=!1;break}if(a)return}t.v.upload("bar_color",s.colors.subarray(0,n*3),0,3),(!l||l.length<n*3)&&(e.Ze=new Float32Array(n*3)),e.Ze.set(s.colors.subarray(0,n*3))}function Va(e){e.U.lines.invalidateBuffers(e),e.U.scatter.invalidateBuffers(e),e.U.areas.invalidateBuffers(e)}function Sr(e,t){e.U.lines.rebuildBuffers(e,t),e.U.scatter.rebuildBuffers(e,t),e.U.areas.rebuildBuffers(e,t)}function Ya(e,t){let n=t.gl,i=t.dpr,r=n.canvas.width/i,o=n.canvas.height/i;if(r<=0||o<=0||e.te===0)return;let s=e.T();rs(e)&&e.kn>0&&Qf(e,t);let l=e.et,a=e.Ue==="numeric",u=a?e.G.min:-.5,m=a?e.G.max:e.te-.5,f=e.pr.min,c=e.pr.max;e.h&&(l?e.h.setBaseDomain(f,c,u,m):e.h.setBaseDomain(u,m,f,c));let p=u,b=m,g=f,x=c,h=e.ne?.min??0,y=e.ne?.max??1;if(e.h){let H=e.h.getVisibleDomain();l?(g=H.xMin,x=H.xMax,p=H.yMin,b=H.yMax):(p=H.xMin,b=H.xMax,g=H.yMin,x=H.yMax)}let _=l?!e.h?.isYDefault():!e.h?.isXDefault();if(e.xi&&e.h&&_){let H=lc(e,p,b);H.hasLeft&&(g=H.leftMin,x=H.leftMax),e.ne&&H.hasRight&&(h=H.rightMin,y=H.rightMax)}if(e.i.include_zero&&(g>0&&(g=0),x<0&&(x=0),e.ne&&(h>0&&(h=0),y<0&&(y=0))),e.Xt&&e.pe.length>1){tc(e,t,{horizontal:l,numericCat:a,cssWidth:r,cssHeight:o,visCatMin:p,visCatMax:b,visValMin:g,visValMax:x,visRightMin:h,visRightMax:y});return}e.d=null;let C=e.f.length>1,v=e.C.length>0,A={levels:e.Ie,numRows:e.te,levelLabels:e.C.slice()},L=e.yn,T=e.Hn==="category"&&L!==null&&L.numRows>0,w;if(l){let H=a?55:Ht(A),U=H+(v?16:0),z=Ze(e.i,C),q=Math.max(1,r-U-z),ae=T?Ue(L,q):void 0;w=new ie(r,o,{hasXLabel:!0,hasYLabel:v,hasLegend:C,leftExtra:H,bottomExtra:ae,rightExtra:z})}else if(a){let H=T?Ht(L):void 0;w=new ie(r,o,{hasXLabel:v,hasYLabel:!0,hasLegend:C,bottomExtra:24,leftExtra:H,rightExtra:Ze(e.i,C)})}else{let H=T?Ht(L):55,U=H+16,z=Ze(e.i,C),q=Math.max(1,r-U-z),ae=Ue(A,q);w=new ie(r,o,{hasXLabel:v,hasYLabel:!0,hasLegend:C,bottomExtra:ae,leftExtra:T?H:void 0,rightExtra:z})}e.l=w,e.h&&e.h.updateLayout(w);let M=e.i.include_zero,D=l?w.buildProjectionMatrix(g,x,b,p,"x",M,void 0,0,e.ae):w.buildProjectionMatrix(p,b,g,x,"y",M,void 0,e.ae,0),I;if(e.hn&&e.ne&&!l){let H=w.$,U=w.J,z=w.j,q=w.Q;I=w.buildProjectionMatrix(p,b,h,y,"y",M,void 0,e.ae,0),w.$=H,w.J=U,w.j=z,w.Q=q}else I=D;let F=ne(g,x,6),B=e.hn&&e.ne&&!l?ne(h,y,6):null,N=A,k={min:g,max:x,label:e.br},Y=e.ne&&!l?{min:h,max:y,label:e.so}:null;e.K&&Br(e.K,w,F,s,t.dpr,l);let W=e.f.length>1?en(e):null;Je(n,w,t.dpr,()=>{za(e,n,t,D,I,s.fi,l,W?W.seriesId:-1)}),e.ue=N,e.me=k,e.Fe=F,e.Di=Y,e.Bi=B,e.qe=a?ne(p,b,6):null,e.he(()=>Er(e))}function za(e,t,n,i,r,o,s,l,a){let u=e.Yt,m=u.length<=1;for(let f of u){let c=m?void 0:{start:f.aggStart,end:f.aggEnd};switch(f.chartType){case"area":s||e.U.areas.draw(e,t,n,i,r,o,a,c);break;case"bar":{t.useProgram(e.r);let p=e.I;t.uniformMatrix4fv(p.u_proj_left,!1,i),t.uniformMatrix4fv(p.u_proj_right,!1,r),t.uniform1f(p.u_horizontal,s?1:0),t.uniform1f(p.u_hover_series,l),Pa(e,t,n,ec(e,f,a));break}case"line":s||e.U.lines.draw(e,t,n,i,r,a,c);break;case"scatter":s||e.U.scatter.draw(e,t,n,i,r,a,c);break}}}function ec(e,t,n){let i=n!==void 0?e.Nn?.[n]:e.On;if(!i)return n!==void 0?{start:0,count:0}:void 0;let r=i[t.aggStart],o=i[t.aggEnd];return{start:r.start,count:o.start+o.count-r.start}}function tc(e,t,n){let i=t.gl,r=t.dpr,o=e.T(),{horizontal:s,numericCat:l,cssWidth:a,cssHeight:u,visCatMin:m,visCatMax:f,visValMin:c,visValMax:p,visRightMin:b,visRightMax:g}=n,x=e.C.length>0,h=e.yn,y=e.Hn==="category"&&h!==null&&h.numRows>0,_=e.Tt.length>1,C=l?"outer":"cell",v=y?"cell":"outer",A=Fe(e.pe,{cssWidth:a,cssHeight:u,xAxis:s?v:C,yAxis:s?C:v,hasLegend:_&&e.i.legend_mode==="sidebar",legendWidth:Le(e.i,96),hasXLabel:s?!0:x,hasYLabel:s?x:!0,gap:e.W.facet_padding});if(e.d=A,e.l=A.cells[0]?.layout??null,A.cells.length===0||!e.l)return;e.syncFacetZoomLayouts(A.cells);let L=ne(c,p,6),T=l?ne(m,f,6):null,w=A.cells[0].layout,M=e.K;M&&e.he(()=>ue(M,w,r));let D=e.i.include_zero,I=e.f.length>1?en(e):null,F=e.hn&&e.ne!==null&&!s;ht(i);for(let B=0;B<A.cells.length;B++){let k=A.cells[B].layout,Y=s?k.buildProjectionMatrix(c,p,f,m,"x",D,void 0,0,e.ae):k.buildProjectionMatrix(m,f,c,p,"y",D,void 0,e.ae,0),W=Y;if(F){let H=k.$,U=k.J,z=k.j,q=k.Q;W=k.buildProjectionMatrix(m,f,b,g,"y",D,void 0,e.ae,0),k.$=H,k.J=U,k.j=z,k.Q=q}M&&e.he(()=>nc(M,k,L,o,r,s)),xt(i,k,r,()=>{za(e,i,t,Y,W,o.fi,s,I&&I.splitIdx===B?I.seriesId:-1,B)})}e.ue={levels:e.Ie,numRows:e.te,levelLabels:e.C.slice()},e.me={min:c,max:p,label:e.br},e.Fe=L,e.Di=null,e.Bi=null,e.qe=T,e.he(()=>Er(e))}function nc(e,t,n,i,r,o){let s=oe(e,r);s&&(s.strokeStyle=i.Tn,s.lineWidth=1,o?kt(s,t.e,n,l=>t.E(l,0).px):Nt(s,t.e,n,l=>t.E(0,l).py))}function es(e,t){return e.d?e.d.cells[t.splitIdx]?.layout??null:e.l}function Er(e){ic(e),e.presentOverlay()}function ic(e){if(!e.u||!e.l||!e.me||!e.Fe)return;if(e.d){rc(e);return}let t=e.T(),n;if(e.Ue==="numeric"&&e.G&&e.qe)n={mode:"numeric",domain:{min:e.G.min,max:e.G.max,isDate:e.G.isDate,label:e.G.label},ticks:e.qe};else if(e.ue)n={mode:"category",domain:e.ue};else return;let i=e.f.find(a=>a.axis===0),r=e.f.find(a=>a.axis===1),o=e.C[0],s=e.Hn==="category"&&e.yn?{mode:"category",domain:e.yn}:{mode:"numeric",domain:e.me,ticks:e.Fe},l;e.Di&&e.Bi&&(l=e.ao==="category"&&e.gr?{mode:"category",domain:e.gr}:{mode:"numeric",domain:e.Di,ticks:e.Bi}),Dr(e.u,n,s,e.l,t,e.t?.dpr??1,l,e.et,{value:e.getColumnFormatter(i?.aggName??null,"tick"),alt:e.getColumnFormatter(r?.aggName??null,"tick"),category:e.getColumnFormatter(o,"tick")}),sc(e),en(e)&&$a(e)}function rc(e){let t=e.d,n=e.u,i=e.T(),r=e.t?.dpr??1,o=e.et,s=e.C.length>0,l=e.Ue==="numeric"&&e.G!==null&&e.qe!==null;if(!ue(n,e.l,r))return;let a=e.ue,u=e.me,m=e.Fe,f=e.yn,c=e.Hn==="category"&&f!==null&&f.numRows>0,p=e.f.find(h=>h.axis===0),b=e.getColumnFormatter(p?.aggName??null,"tick"),g=e.getColumnFormatter(e.C[0],"tick");for(let h of t.cells){let y=h.layout,_=y.e,C=oe(n,r);C&&(C.strokeStyle=i.mi,C.lineWidth=1,C.beginPath(),C.moveTo(_.x,_.y),C.lineTo(_.x,_.y+_.height),C.lineTo(_.x+_.width,_.y+_.height),C.stroke(),o?(!l&&a&&Ie(C,y,a,i),c&&be(C,y,f,i)):(!l&&a&&be(C,y,a,i),c&&Ie(C,y,f,i)),h.titleRect&&Pt(n,h.label,h.titleRect,i,r))}let x=l?{min:e.G.min,max:e.G.max,isDate:e.G.isDate,label:e.G.label}:null;o?(x&&t.outerYAxisRect&&_n(n,t.outerYAxisRect,x,e.qe,gn(t),i,s,r,g),!c&&t.outerXAxisRect&&Cn(n,t.outerXAxisRect,u,m,bn(t),i,!0,r,b)):(x&&t.outerXAxisRect&&Cn(n,t.outerXAxisRect,x,e.qe,bn(t),i,s,r,g),!c&&t.outerYAxisRect&&_n(n,t.outerYAxisRect,u,m,gn(t),i,!0,r,b)),oc(e,t),en(e)&&$a(e)}function Xa(e,t,n,i,r){let o=e.u.getContext("2d");if(!o)return;o.save();let s=e.T(),l=t;n.mode==="floating"&&(l=Yi(o,t,s,n.title,n.opacity));let a=10,u=So,m=i*u,f=e.R.clampScroll(l.height,m),c=m>l.height,p=Math.max(0,l.width-a-6-(c?10:0));o.beginPath(),o.rect(l.x,l.y,l.width,l.height),o.clip(),o.font=`11px ${s.fontFamily}`,o.textAlign="left",o.textBaseline="middle";let b=l.x,g=Math.floor(f/u),x=l.y+u/2+g*u-f;for(let h=g;h<i&&x-u/2<l.y+l.height;h++){let y=r(h),_=Math.round(y.color[0]*255),C=Math.round(y.color[1]*255),v=Math.round(y.color[2]*255);o.globalAlpha=y.hidden?.3:1,o.fillStyle=`rgb(${_},${C},${v})`,o.fillRect(b,x-a/2,a,a);let A=_t(o,y.label,p),L=o.measureText(A).width;o.fillStyle=s.mn,o.fillText(A,b+a+6,x),y.hidden&&(o.strokeStyle=s.mn,o.lineWidth=1,o.beginPath(),o.moveTo(b+a+6,x),o.lineTo(b+a+6+L,x),o.stroke()),o.globalAlpha=1,e.xn.push({seriesIds:y.seriesIds,rect:{x:b-2,y:x-u/2,width:Math.min(a+6+L+4,Math.max(1,l.width)),height:u}}),x+=u}o.restore(),Fo(o,l,f,m,s),e.R.setPainted({mode:n.mode,box:t,content:l,contentHeight:m,sidebarGutter:n.sidebarGutter})}function oc(e,t){if(e.xn=[],!e.u||!e.l)return;let n=e.i,i=e.Tt.length,r=n.legend_mode==="floating";if(i<=1||n.legend_mode==="none"||!r&&!t.legendRect){e.R.clearPainted();return}let o=Array.from({length:i},()=>[]),s=Array.from({length:i},()=>[.5,.5,.5]);for(let u of e.f)u.aggIdx>=0&&u.aggIdx<i&&(o[u.aggIdx].push(u.seriesId),s[u.aggIdx]=u.color);let l=e.l,a=r?e.R.floatingBox(n,l.cssWidth,l.cssHeight):{x:t.legendRect.x+12,y:t.legendRect.y+10,width:Math.max(1,t.legendRect.width-16),height:Math.max(1,t.legendRect.height-20)};Xa(e,a,{mode:r?"floating":"sidebar",legend:e.R,title:"Legend",sidebarGutter:r?void 0:t.legendRect.width,opacity:n.legend_opacity},i,u=>({label:e.Tt[u],color:s[u],seriesIds:o[u],hidden:o[u].every(m=>e.ee.has(m))}))}function sc(e){if(e.xn=[],!e.u||!e.l)return;let t=e.i,n=e.f;if(n.length<=1||t.legend_mode==="none"){e.R.clearPainted();return}let i=e.l,r=t.legend_mode==="floating",o=r?e.R.floatingBox(t,i.cssWidth,i.cssHeight):{x:i.e.x+i.e.width+12,y:i.margins.top+10,width:Math.max(1,i.cssWidth-i.e.x-i.e.width-16),height:Math.max(1,i.e.height-10)};Xa(e,o,{mode:r?"floating":"sidebar",legend:e.R,title:e.B.join(" / ")||"Legend",sidebarGutter:r?void 0:i.margins.right,opacity:t.legend_opacity},n.length,s=>({label:n[s].label,color:n[s].color,seriesIds:[n[s].seriesId],hidden:e.ee.has(n[s].seriesId)}))}function $a(e){if(!e.u||!e.l)return;let t=en(e);if(!t)return;let n=es(e,t);if(!n)return;let r=(e.f[t.seriesId]?.chartType??"bar")==="bar"?(t.y0+t.y1)/2:t.y1,o=t.axis===0?e.et?n.E(r,t.xCenter):n.E(t.xCenter,r):ts(e,t.xCenter,r,n),s=Qo(e,t),l=e.T();ke(e.u,o,s,n,l,e.t?.dpr??1)}function ts(e,t,n,i){let r=i??e.l,{x:o,y:s,width:l,height:a}=r.e,u=(t-r.$)/(r.J-r.$),m=e.ne,f=(n-m.min)/(m.max-m.min);return{px:o+u*l,py:s+(1-f)*a}}function lc(e,t,n){let i=e.Lt;if(i&&i.catMin===t&&i.catMax===n&&i.hidden===e.ee)return i;let r=mc(e),o=1/0,s=-1/0,l=!1,a=1/0,u=-1/0,m=!1;if(r.n>0){let c=e.le,p,b;if(c){let v=ac(c,r.n,t,n);p=v.lo,b=v.hi}else p=Math.max(0,Math.floor(t)),b=Math.min(r.n-1,Math.ceil(n));let g=r.leftMin,x=r.leftMax,h=r.rightMin,y=r.rightMax,_=r.hasLeft,C=r.hasRight;for(let v=p;v<=b;v++)_[v]&&(g[v]<o&&(o=g[v]),x[v]>s&&(s=x[v]),l=!0),C[v]&&(h[v]<a&&(a=h[v]),y[v]>u&&(u=y[v]),m=!0)}let f=i??uc();return f.catMin=t,f.catMax=n,f.hidden=e.ee,f.leftMin=o,f.leftMax=s,f.hasLeft=l,f.rightMin=a,f.rightMax=u,f.hasRight=m,e.Lt=f,f}function ac(e,t,n,i){if(t===0||n>i)return{lo:0,hi:-1};let r=0,o=t;for(;r<o;){let a=r+o>>>1;e[a]<n?r=a+1:o=a}let s=Math.max(0,r-1);for(r=0,o=t;r<o;){let a=r+o>>>1;e[a]<=i?r=a+1:o=a}let l=Math.min(t-1,r);return{lo:s,hi:l}}function uc(){return{catMin:0,catMax:0,hidden:new Set,leftMin:0,leftMax:0,hasLeft:!1,rightMin:0,rightMax:0,hasRight:!1}}function mc(e){let t=e.te,n=e.uo,i=n&&n.leftMin.length>=t;if(n&&i&&e.Fi===e.ee)return n;!n||!i?(n={leftMin:new Float64Array(t),leftMax:new Float64Array(t),rightMin:new Float64Array(t),rightMax:new Float64Array(t),hasLeft:new Uint8Array(t),hasRight:new Uint8Array(t),n:t},e.uo=n):n.n=t;for(let g=0;g<t;g++)n.leftMin[g]=1/0,n.leftMax[g]=-1/0,n.rightMin[g]=1/0,n.rightMax[g]=-1/0,n.hasLeft[g]=0,n.hasRight[g]=0;let r=e._e,o=e.ee,s=r.catIdx,l=r.seriesId,a=r.y0,u=r.y1,m=r.axis;for(let g=0;g<r.count;g++){if(o.has(l[g]))continue;let x=s[g];if(x<0||x>=t)continue;let h=a[g],y=u[g],_=h<y?h:y,C=h<y?y:h;m[g]===1?(_<n.rightMin[x]&&(n.rightMin[x]=_),C>n.rightMax[x]&&(n.rightMax[x]=C),n.hasRight[x]=1):(_<n.leftMin[x]&&(n.leftMin[x]=_),C>n.leftMax[x]&&(n.leftMax[x]=C),n.hasLeft[x]=1)}let f=[e.Vn,e.Yn],c=e.Qe,p=e.zt,b=e.f.length;for(let g of f)for(let x of g){if(o.has(x.seriesId))continue;let h=x.axis===1,y=x.seriesId;for(let _=0;_<t;_++){let C=_*b+y;if(!(p[C>>3]>>(C&7)&1))continue;let v=c[C];h?(v<n.rightMin[_]&&(n.rightMin[_]=v),v>n.rightMax[_]&&(n.rightMax[_]=v),n.hasRight[_]=1):(v<n.leftMin[_]&&(n.leftMin[_]=v),v>n.leftMax[_]&&(n.leftMax[_]=v),n.hasLeft[_]=1)}}return e.Fi=o,n}hn();De();fe();var Pn=new Float32Array(0),Gn=new Uint8Array(0);function fc(e){return Pn.length>=e||(Pn=new Float32Array(Math.max(e,Pn.length*2))),Pn}function cc(e){return Gn.length>=e||(Gn=new Uint8Array(Math.max(e,Gn.length*2))),Gn}function dc(e){return e==="solid"?1:e==="transparent"?.5:0}var Pr=class{constructor(){d(this,"r",null);d(this,"o",null)}ensureProgram(t){if(this.r)return this.r;let n=et(t.gl),i=j(t,"bar-line",Xe,$e,["u_projection","u_color","u_resolution","u_line_width","u_interp_alpha"],["a_start","a_end","a_corner","a_real_start","a_real_end"]);return this.r={...i,cornerBuffer:n},this.r}invalidateBuffers(t){let n=this.o;if(!n||!t.t){this.o=null;return}let i=t.t.gl;for(let r of n.series)i.deleteBuffer(r.gpuBuffer),i.deleteBuffer(r.gpuRealBuffer);this.o=null}rebuildBuffers(t,n){let i=t.Vn;if(i.length===0){this.o=null;return}if(t.te===0){this.o=null;return}this.ensureProgram(n);let o=n.gl,s=t.Qe,l=t.zt,a=t.ae,u=t.le,m=t.f.length,f=[];for(let c of i){let p=t.f[c.seriesId],b=p.start,g=p.end;if(b<0||g<b)continue;let x=g-b+1;if(x<2)continue;let h=fc(x*2),y=cc(x),_=0;for(let A=b;A<=g;A++){let L=u?u[A]-a:A,T=A*m+c.seriesId;h[_*2]=L,h[_*2+1]=s[T],y[_]=l[T>>3]>>(T&7)&1,_++}let C=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,C),o.bufferData(o.ARRAY_BUFFER,h.subarray(0,_*2),o.STATIC_DRAW);let v=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,v),o.bufferData(o.ARRAY_BUFFER,y.subarray(0,_),o.STATIC_DRAW),f.push({seriesId:c.seriesId,axis:c.axis,color:[c.color[0],c.color[1],c.color[2]],gpuBuffer:C,gpuRealBuffer:v,count:x,interpolateMode:p.interpolateMode})}this.o={series:f}}draw(t,n,i,r,o,s,l){let a=this.o,u=this.r;if(!a||!u||a.series.length===0)return;let m=i.dpr;n.useProgram(u.program),n.uniform2f(u.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(u.u_line_width,t.i.line_width_px*m);let f=J(i),{setDivisor:c,drawArraysInstanced:p}=f;n.bindBuffer(n.ARRAY_BUFFER,u.cornerBuffer),n.enableVertexAttribArray(u.a_corner),n.vertexAttribPointer(u.a_corner,1,n.FLOAT,!1,0,0),c(u.a_corner,0);let b=2*Float32Array.BYTES_PER_ELEMENT,g=Uint8Array.BYTES_PER_ELEMENT,x=t.ee;for(let h of a.series){if(x.has(h.seriesId)||s!==void 0&&t.f[h.seriesId].splitIdx!==s)continue;let y=t.f[h.seriesId].aggIdx;if(l!==void 0&&(y<l.start||y>l.end))continue;n.uniformMatrix4fv(u.u_projection,!1,h.axis===1?o:r);let _=t.f[h.seriesId].color;n.uniform4f(u.u_color,_[0],_[1],_[2],1),n.uniform1f(u.u_interp_alpha,dc(h.interpolateMode)),n.enableVertexAttribArray(u.a_start),c(u.a_start,1),n.enableVertexAttribArray(u.a_end),c(u.a_end,1),n.enableVertexAttribArray(u.a_real_start),c(u.a_real_start,1),n.enableVertexAttribArray(u.a_real_end),c(u.a_real_end,1),n.bindBuffer(n.ARRAY_BUFFER,h.gpuBuffer),n.vertexAttribPointer(u.a_start,2,n.FLOAT,!1,b,0),n.vertexAttribPointer(u.a_end,2,n.FLOAT,!1,b,b),n.bindBuffer(n.ARRAY_BUFFER,h.gpuRealBuffer),n.vertexAttribPointer(u.a_real_start,1,n.UNSIGNED_BYTE,!1,g,0),n.vertexAttribPointer(u.a_real_end,1,n.UNSIGNED_BYTE,!1,g,g),p(n.TRIANGLE_STRIP,0,4,h.count-1)}c(u.a_start,0),c(u.a_end,0),c(u.a_real_start,0),c(u.a_real_end,0)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let i=this.r;i&&n.deleteBuffer(i.cornerBuffer)}this.r=null,this.o=null}};fe();var ze=new Float32Array(0),Te=new Float32Array(0);function pc(e){ze.length<e*2&&(ze=new Float32Array(Math.max(e*2,ze.length*2))),Te.length<e*3&&(Te=new Float32Array(Math.max(e*3,Te.length*2)))}var Gr=class{constructor(){d(this,"r",null);d(this,"o",null)}ensureProgram(t){if(this.r)return this.r;let n=t.gl,i=j(t,"bar-scatter",qn,Kn,["u_projection","u_point_size"],["a_position","a_color"]);return this.r={...i,posLeftBuffer:n.createBuffer(),posRightBuffer:n.createBuffer(),colorLeftBuffer:n.createBuffer(),colorRightBuffer:n.createBuffer()},this.r}invalidateBuffers(t){this.o=null}rebuildBuffers(t,n){let i=t.Yn;if(i.length===0){this.o=null;return}let r=t.te,o=t.f.length;if(r===0||o===0){this.o=null;return}let s=this.ensureProgram(n),l=n.gl,a=t.Qe,u=t.zt,m=t.le,f=t.ae,c=t.ee,p=0,b=0;for(let _ of i)if(!c.has(_.seriesId))for(let C=0;C<r;C++){let v=C*o+_.seriesId;u[v>>3]>>(v&7)&1&&(_.axis===1?b++:p++)}let g=p+b;if(g===0){this.o=null;return}pc(g);let x=[],h=0,y=p;for(let _ of i){if(c.has(_.seriesId))continue;let C=_.axis===1?y-p:h,v=_.color[0],A=_.color[1],L=_.color[2];for(let w=0;w<r;w++){let M=w*o+_.seriesId;if(!(u[M>>3]>>(M&7)&1))continue;let D=m?m[w]-f:w,I=a[M];_.axis===1?(ze[y*2]=D,ze[y*2+1]=I,Te[y*3]=v,Te[y*3+1]=A,Te[y*3+2]=L,y++):(ze[h*2]=D,ze[h*2+1]=I,Te[h*3]=v,Te[h*3+1]=A,Te[h*3+2]=L,h++)}let T=_.axis===1?y-p:h;T>C&&x.push({seriesId:_.seriesId,axis:_.axis,first:C,count:T-C})}p>0&&(l.bindBuffer(l.ARRAY_BUFFER,s.posLeftBuffer),l.bufferData(l.ARRAY_BUFFER,ze.subarray(0,p*2),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,s.colorLeftBuffer),l.bufferData(l.ARRAY_BUFFER,Te.subarray(0,p*3),l.STATIC_DRAW)),b>0&&(l.bindBuffer(l.ARRAY_BUFFER,s.posRightBuffer),l.bufferData(l.ARRAY_BUFFER,ze.subarray(p*2,g*2),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,s.colorRightBuffer),l.bufferData(l.ARRAY_BUFFER,Te.subarray(p*3,g*3),l.STATIC_DRAW)),this.o={leftCount:p,rightCount:b,seriesRanges:x}}draw(t,n,i,r,o,s,l){let a=this.o,u=this.r;if(!a||!u||a.leftCount===0&&a.rightCount===0)return;let m=i.dpr;if(n.useProgram(u.program),n.uniform1f(u.u_point_size,t.i.point_size_px*m),s!==void 0||l!==void 0){for(let f of a.seriesRanges){if(s!==void 0&&t.f[f.seriesId].splitIdx!==s)continue;let c=t.f[f.seriesId].aggIdx;l!==void 0&&(c<l.start||c>l.end)||os(n,u,f.axis===1?u.posRightBuffer:u.posLeftBuffer,f.axis===1?u.colorRightBuffer:u.colorLeftBuffer,f.count,f.axis===1?o:r,f.first)}return}os(n,u,u.posLeftBuffer,u.colorLeftBuffer,a.leftCount,r),os(n,u,u.posRightBuffer,u.colorRightBuffer,a.rightCount,o)}destroy(t){let n=t.t?.gl;if(n){let i=this.r;i&&(n.deleteBuffer(i.posLeftBuffer),n.deleteBuffer(i.posRightBuffer),n.deleteBuffer(i.colorLeftBuffer),n.deleteBuffer(i.colorRightBuffer))}this.r=null,this.o=null}};function os(e,t,n,i,r,o,s=0){r!==0&&(e.uniformMatrix4fv(t.u_projection,!1,o),e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(t.a_position),e.vertexAttribPointer(t.a_position,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(t.a_color),e.vertexAttribPointer(t.a_color,3,e.FLOAT,!1,0,0),e.drawArrays(e.POINTS,s,r))}fe();var Wn=new Float32Array(0);function bc(e){return Wn.length>=e||(Wn=new Float32Array(Math.max(e,Wn.length*2))),Wn}var Wr=class{constructor(){d(this,"r",null);d(this,"o",null)}ensureProgram(t){return this.r?this.r:(this.r=j(t,"bar-area",jn,Zn,["u_projection","u_color","u_opacity"],["a_position"]),this.r)}invalidateBuffers(t){let n=this.o;if(!n||!t.t){this.o=null;return}let i=t.t.gl;for(let r of n.series)i.deleteBuffer(r.gpuBuffer);this.o=null}rebuildBuffers(t,n){let i=t.Ei;if(i.length===0){this.o=null;return}let r=t.te,o=t.f.length;if(r===0||o===0){this.o=null;return}this.ensureProgram(n);let s=n.gl,l=t.Qe,a=t.zt,u=t.le,m=t.ae,f=t.hr,c=t._e,p=[];for(let b of i){let g=t.f[b.seriesId],x=gc(b,r,o,l,a,f,c.y0,c.y1,u,m,g.start,g.end,g.interpolateMode);if(x.totalVertices===0)continue;let h=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,h),s.bufferData(s.ARRAY_BUFFER,x.scratch.subarray(0,x.totalVertices*2),s.STATIC_DRAW),p.push({seriesId:b.seriesId,axis:b.axis,color:[b.color[0],b.color[1],b.color[2]],gpuBuffer:h,strips:x.descriptors})}this.o={series:p}}draw(t,n,i,r,o,s,l,a){let u=this.o,m=this.r;if(!u||!m||u.series.length===0)return;n.useProgram(m.program),n.uniform1f(m.u_opacity,s);let f=t.ee;for(let c of u.series){if(f.has(c.seriesId)||l!==void 0&&t.f[c.seriesId].splitIdx!==l)continue;let p=t.f[c.seriesId].aggIdx;if(a!==void 0&&(p<a.start||p>a.end))continue;n.uniformMatrix4fv(m.u_projection,!1,c.axis===1?o:r);let b=t.f[c.seriesId].color;n.uniform3f(m.u_color,b[0],b[1],b[2]),n.bindBuffer(n.ARRAY_BUFFER,c.gpuBuffer),n.enableVertexAttribArray(m.a_position),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,0);for(let g of c.strips)n.bindBuffer(n.ARRAY_BUFFER,c.gpuBuffer),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,g.offsetBytes),n.drawArrays(n.TRIANGLE_STRIP,0,g.vertexCount)}}destroy(t){this.invalidateBuffers(t),this.r=null}};function gc(e,t,n,i,r,o,s,l,a,u,m,f,c){let p=bc(t*4),b=[],g=e.seriesId*1e9,x=c!=="skip",h=0,y=0;for(let _=0;_<t;_++){let C=0,v=0,A=!1;if(e.stack){let L=o?.get(g+_);L!==void 0&&(C=s[L],v=l[L],A=!0)}else{let L=_*n+e.seriesId;x?_>=m&&_<=f&&(v=i[L],A=!0):r[L>>3]>>(L&7)&1&&(v=i[L],A=!0)}if(A){let L=a?a[_]-u:_;p[h++]=L,p[h++]=C,p[h++]=L,p[h++]=v}else if(h>y){let L=(h-y)/2;L>=4&&b.push({offsetBytes:y*4,vertexCount:L}),y=h}}if(h>y){let _=(h-y)/2;_>=4&&b.push({offsetBytes:y*4,vertexCount:_})}return{descriptors:b,totalVertices:h/2,scratch:p}}De();fe();function kn(e,t){return e&&(t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max)),{min:t.min,max:t.max}}var rt=class extends Qt{constructor(n="vertical"){super();d(this,"et");d(this,"I",null);d(this,"Tt",[]);d(this,"pe",[]);d(this,"f",[]);d(this,"Xt",!1);d(this,"d",null);d(this,"Ii",null);d(this,"Yt",[]);d(this,"On",null);d(this,"Nn",null);d(this,"_e",wr());d(this,"xr",[]);d(this,"Vn",[]);d(this,"Yn",[]);d(this,"Ei",[]);d(this,"br","");d(this,"so","");d(this,"Hn","numeric");d(this,"ao",null);d(this,"yn",null);d(this,"gr",null);d(this,"hr",null);d(this,"Ze",null);d(this,"Pi",null);d(this,"Gi",null);d(this,"yr",null);d(this,"Cr",null);d(this,"pr",{min:0,max:1});d(this,"ne",null);d(this,"hn",!1);d(this,"zn",null);d(this,"Xn",null);d(this,"Wi",null);d(this,"Ue","category");d(this,"G",null);d(this,"ae",0);d(this,"qe",null);d(this,"le",null);d(this,"ee",new Set);d(this,"De",-1);d(this,"dr",-1);d(this,"Be",null);d(this,"Qe",new Float32Array(0));d(this,"zt",new Uint8Array(0));d(this,"U",{lines:new Pr,scatter:new Gr,areas:new Wr});d(this,"Di",null);d(this,"Bi",null);d(this,"kn",0);d(this,"Un",new Int32Array(0));d(this,"xn",[]);d(this,"oo",!1);d(this,"Lt",null);d(this,"uo",null);d(this,"Fi",null);this.et=n==="horizontal"}getZoomConfig(){return{lockAxis:this.et?"x":"y"}}repaintChrome(){Er(this)}tooltipCallbacks(){return{onHover:(n,i)=>Jo(this,n,i),onLeave:()=>{(this.De!==-1||this.Be)&&(this.De=-1,this.Be=null,this.t&&this.requestRender(this.t))},onClickPre:(n,i)=>Wa(this,n,i),onPin:(n,i)=>{if(Jo(this,n,i),this.De>=0){let r=this.De;ka(this,r);let o=En(this._e,r,this.pe.length,this.Qe,this.f.length);this.mo(o)}else if(this.Be){let r=this.Be;Na(this,r),this.mo(r)}},onUnpin:()=>{this.emitUnselect()}}}async mo(n){if(!this.Tt[n.aggIdx])return;let i=this.Ue==="numeric"&&this.le?[this.le[n.catIdx]??null]:this.Ie.map(s=>s.labels[n.catIdx]??null),r=this.pe[n.splitIdx]??"",o=this.B.length>0&&r!==""?r.split("|"):[];await this.emitClickAndSelect({rowIdx:n.catIdx+this.dt,columnName:this.Tt[n.aggIdx],groupByValues:i,splitByValues:o})}async uploadAndRender(n,i,r,o){this.t=n;let s=n.gl;if(r!==0)return;if(!this.r){let u=j(n,"bar",Hn,Vn,["u_proj_left","u_proj_right","u_hover_series","u_horizontal"],["a_corner","a_x_center","a_half_width","a_y0","a_y1","a_color","a_series_id","a_axis"]);this.r=u.program,this.I=u,this.O=qi(s)}let l=this.B.length>0&&this.W.facet_mode==="grid",a=Ea({columns:i,numRows:o,columnSlots:this.M,groupBy:this.C,splitBy:this.B,groupByTypes:this.Ct,columnsConfig:this.Rn,defaultChartType:this.pi,autoAltYAxis:this.i.auto_alt_y_axis,bandInnerFrac:this.i.band_inner_frac,barInnerPad:this.i.bar_inner_pad,includeZero:this.i.include_zero,facetSplits:l,scratchBars:this._e,scratchPosStack:this.yr,scratchNegStack:this.Cr});if(this.i.domain_mode==="expand"){let u=xc(a);this.Wi!==u&&(this.zn=null,this.Xn=null,this.Wi=u),this.zn=kn(this.zn,a.leftDomain),a.rightDomain&&(this.Xn=kn(this.Xn,a.rightDomain))}else this.zn=null,this.Xn=null,this.Wi=null;this.Tt=a.aggregates,this.pe=a.splitPrefixes,this.Xt=l&&a.splitPrefixes.length>1,this.Ie=a.rowPaths,this.te=a.numCategories,this.dt=a.rowOffset,this.Ue=a.axisMode.mode,this.G=a.numericCategoryDomain,this.le=a.categoryPositions,this.ae=a.numericCategoryDomain?.min??0,this.f=a.series,this._e=a.bars,this.yr=a.posStack,this.Cr=a.negStack,this.Qe=a.samples,this.xr.length=0,this.Vn.length=0,this.Yn.length=0,this.Ei.length=0;for(let u of a.series)switch(u.chartType){case"bar":this.xr.push(u);break;case"line":this.Vn.push(u);break;case"scatter":this.Yn.push(u);break;case"area":this.Ei.push(u);break}this.br=ja(a.series,0),this.so=ja(a.series,1),this.Yt.length=0;{let u=Math.max(1,a.splitPrefixes.length);for(let m=0;m<a.aggregates.length;m++){let f=a.series[m*u].chartType,c=this.Yt[this.Yt.length-1];c&&c.chartType===f?c.aggEnd=m:this.Yt.push({chartType:f,aggStart:m,aggEnd:m})}}this.hr=hc(this._e),this.Lt=null,this.oo=!1,this.Pi=null,this.Gi=null,this.Fi=null,this.Ze=null,this.De=-1,this.Be=null,this.zt=a.sampleValid,this.pr=a.leftDomain,this.ne=a.rightDomain,this.hn=a.hasRightAxis,this.Hn=a.leftValueAxisMode,this.ao=a.rightValueAxisMode,this.yn=a.leftValueCategoryDomain,this.gr=a.rightValueCategoryDomain,rs(this),Rr(this,n),Va(this),Sr(this,n),await this.requestRender(n)}Wt(n){this.r&&(this.t=n,Ya(this,n))}resetExpandedDomain(){this.zn=null,this.Xn=null,this.Wi=null}destroyInternal(){if(this.t){let n=this.t.gl;this.O&&n.deleteBuffer(this.O),Cc(this)}this.r=null,this.I=null,this.O=null,this.Xt=!1,this.d=null,this.Ii=null,this.Nn=null,this.On=null,this.Yt.length=0,this._e=wr(),this.f=[],this.xr=[],this.Vn=[],this.Yn=[],this.Ei=[],this.hr=null,this.Pi=null,this.Gi=null,this.Ze=null,this.yr=null,this.Cr=null,this.Ie=[],this.te=0,this.ee.clear(),this.De=-1,this.Be=null}};function hc(e){let t=new Map;for(let n=0;n<e.count;n++)e.chartType[n]===1&&t.set(e.seriesId[n]*1e9+e.catIdx[n],n);return t}function ja(e,t){let n=new Set,i=[];for(let r of e)r.axis===t&&(n.has(r.aggName)||(n.add(r.aggName),i.push(r.aggName)));return i.join(", ")}function xc(e){let t=Math.max(1,e.splitPrefixes.length),n=[];for(let i=0;i<e.aggregates.length;i++)n.push(`${e.aggregates[i]}:${e.series[i*t].axis}`);return n.join("\\0")}function rs(e){let t=e.T(),n=t.Ge,i=t.k,r=e.Rn,o=e.Xt?Math.max(1,e.Tt.length):e.f.length,s=e.Gi;if(e.Pi&&s&&s.Ge===n&&s.k===i&&s.seriesLength===o&&s.columnsConfig===r)return!1;let l=yc(n,i,o);e.Pi=l,e.Gi={Ge:n,k:i,seriesLength:o,columnsConfig:r};for(let a=0;a<e.f.length;a++){let u=e.f[a],m=e.Xt?l[u.aggIdx]:l[a];u.color=Sa(u,e.Xt,r)??m}return!0}function yc(e,t,n){return pe(e,t,n)}function Cc(e){e.U.lines.destroy(e),e.U.scatter.destroy(e),e.U.areas.destroy(e)}var kr=class extends rt{constructor(){super("horizontal")}};dn();Ke();Ln();function ss(e){let{columns:t,numRows:n,groupBy:i,splitBy:r,groupByTypes:o}=e,s=qt(i,o),l={xLevels:[],yColumnNames:[],yLevels:[],numX:0,numY:0,rowOffset:0,cells:[],cells2D:[],colorMin:0,colorMax:1,xAxisMode:s,yAxisMode:{mode:"category"},xPositions:null,yPositions:null,xNumericDomain:null,yNumericDomain:null},a=i.map(w=>o[w]??"string"),{rowPaths:u,numCategories:m,rowOffset:f}=Kt(t,n,i.length,a,s),c=null,p=null;if(s.mode==="numeric"&&m>0){let w=t.get("__ROW_PATH_0__"),M=Lt(w?.values,m,f,i[0]??"",s.numericType==="date"||s.numericType==="datetime");M&&(c=M.categoryPositions,p=M.numericCategoryDomain)}let b=[];for(let w of t.keys())w.startsWith("__")||!t.get(w)?.values||b.push(w);let g=b.length;if(m===0||g===0)return{...l,xLevels:u,rowOffset:f};let x=Ac(b),h=_c(r,o),y={mode:"category"},_=null,C=null;if(h.mode==="numeric"){let w=vc(b,h.numericType);if(w){let M=Lt(w,g,0,r[0]??"",h.numericType==="date"||h.numericType==="datetime");M&&(y=h,_=M.categoryPositions,C=M.numericCategoryDomain)}}let v=[],A=new Array(m*g).fill(null),L=1/0,T=-1/0;for(let w=0;w<g;w++){let M=t.get(b[w]),D=M.values,I=M.valid;for(let F=0;F<m;F++){let B=F+f;if(I&&!(I[B>>3]>>(B&7)&1))continue;let N=D[B];if(!isFinite(N))continue;let k={xIdx:F,yIdx:w,value:N};v.push(k),A[w*m+F]=k,N<L&&(L=N),N>T&&(T=N)}}return!isFinite(L)||!isFinite(T)?(L=0,T=1):L===T&&(T=L+1),{xLevels:u,yColumnNames:b,yLevels:x,numX:m,numY:g,rowOffset:f,cells:v,cells2D:A,colorMin:L,colorMax:T,xAxisMode:s,yAxisMode:y,xPositions:c,yPositions:_,xNumericDomain:p,yNumericDomain:C}}function _c(e,t){if(e.length!==1)return{mode:"category"};let n=t[e[0]];return n==="date"||n==="datetime"||n==="integer"||n==="float"?{mode:"numeric",numericType:n}:{mode:"category"}}function vc(e,t){let n=new Float64Array(e.length);for(let i=0;i<e.length;i++){let r=e[i],o=r.indexOf("|"),s=o===-1?r:r.slice(0,o),l;if(t==="date"||t==="datetime"?(l=Date.parse(s),isFinite(l)||(l=Date.parse(s.replace(" ","T")))):l=Number(s),!isFinite(l))return null;n[i]=l}return n}function Za(e,t){return t.map(n=>{let i=new Map;for(let[r,o]of e){if(r.startsWith("__ROW_PATH_")||r==="__GROUPING_ID__"){i.set(r,o);continue}let s=r.lastIndexOf("|");(s===-1?r:r.slice(s+1))===n&&i.set(r,o)}return{label:n,columns:i}})}function Ac(e){if(e.length===0)return[];let t=0,n=e.map(r=>r.split("|"));for(let r of n)r.length>t&&(t=r.length);if(t===0)return[];let i=[];for(let r=0;r<t;r++){let o=[],s=new Map,l=new Int32Array(e.length),a=new Array(e.length),u=0;for(let c=0;c<e.length;c++){let p=n[c][r]??"",b=s.get(p);b===void 0&&(b=o.length,o.push(p),s.set(p,b)),l[c]=b,a[c]=p,p.length>u&&(u=p.length)}let f=r===t-1?[]:Ui(l,o,0,e.length);i.push({labels:a,runs:f,maxLabelChars:u})}return i}Ke();Fi();xn();De();fe();yt();Gt();Vt();Ln();Oi();function as(e,t){return t?.skipLeafLevel&&e.length>0?e.slice(0,-1):e}var Lc=80,Tc=20,ls=5,us=11;function tn(e,t){return e.E(0,t).py}function qa(e,t){let n=as(e.levels,t),i=n.length,r=[];for(let o=0;o<i;o++){let s=n[o].maxLabelChars;if(o===i-1){let l=Math.max(Lc,s*6.5+16);r.push({size:l})}else{let l=Math.max(Tc,s*6.5+16);r.push({size:l})}}return r}function Ka(e,t){let n=as(e.levels,t);if(e.numRows===0||n.length===0)return 55;let i=qa(e,t),r=0;for(let o of i)r+=o.size;return r}function wc(e,t){return e.labels[t]??""}function ms(e,t,n,i,r){let o=as(n.levels,r);if(n.numRows===0||o.length===0)return;let{Pt:s,Me:l,fontFamily:a}=i,{e:u}=t;e.strokeStyle=s,e.fillStyle=s,e.lineWidth=1,e.font=`${us}px ${a}`;let m=qa(n,r),f=Math.max(0,Math.ceil(t.j)),c=Math.min(n.numRows-1,Math.floor(t.Q));if(c<f)return;let p=o.length,b=u.x;for(let x=p-1;x>=0;x--){let h=o[x],y=m[x],_=b,C=b-y.size;b=C,x===p-1?Mc(e,t,h,f,c,_,C,a,s):Rc(e,t,h,f,c,C,_,a,s)}let g=n.levelLabels.filter(x=>!!x).join(" / ");g&&(e.fillStyle=l,e.font=`13px ${a}`,e.save(),e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="top",e.fillText(g,0,0),e.restore())}function Mc(e,t,n,i,r,o,s,l,a){let u=t.e;e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let f=i;f<=r;f++){let c=tn(t,f);c<u.y-1||c>u.y+u.height+1||(e.moveTo(o,c),e.lineTo(o-ls,c))}e.stroke(),e.font=`${us}px ${l}`,e.textAlign="right",e.textBaseline="middle";let m=o-ls-4-s-4;for(let f=i;f<=r;f++){let c=tn(t,f);if(c<u.y-1||c>u.y+u.height+1)continue;let p=wc(n,f);if(!p)continue;let b=Ct(e,p,m);b&&e.fillText(b,o-ls-4,c)}}function Rc(e,t,n,i,r,o,s,l,a){let u=t.e,m=An(n.runs,i,r);if(m.length===0)return;e.strokeStyle=a,e.fillStyle=a;let f=s-3;e.beginPath();for(let c of m){let p=tn(t,c.endIdx+.5),b=tn(t,c.startIdx-.5),g=Math.min(p,b),x=Math.max(p,b),h=Math.max(u.y,g),y=Math.min(u.y+u.height,x);y<=h||(e.moveTo(f,h),e.lineTo(f,y),e.moveTo(f,h),e.lineTo(f+3,h),e.moveTo(f,y),e.lineTo(f+3,y))}e.stroke(),e.font=`${us}px ${l}`;for(let c of m){let p=tn(t,c.endIdx+.5),b=tn(t,c.startIdx-.5),g=Math.min(p,b),x=Math.max(p,b),h=Math.max(u.y,g),y=Math.min(u.y+u.height,x);if(y<=h)continue;let _=(h+y)/2,C=o+(s-o-3)/2,v=c.label;if(!v)continue;let A=y-h-4,L=Ct(e,v,Math.max(0,A));L&&(e.save(),e.translate(C,_),e.rotate(-Math.PI/2),e.textAlign="center",e.textBaseline="middle",e.fillText(L,0,0),e.restore())}}Ae();Tn();Ne();de();Wt();Bt();function cs(e,t,n){if(e.fo=t,e.co=n,e.m.length>0){for(let r=0;r<e.m.length;r++){let o=e.m[r],s=o.layout.e;if(t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height)continue;let l=Qa(o.layout,o.pipeline.numX,o.pipeline.numY,o.pipeline.cells2D,o.pipeline.xPositions,o.pipeline.yPositions,o.pipeline.xNumericDomain?.bandWidth??1,o.pipeline.yNumericDomain?.bandWidth??1,t,n);fs(e,l,r);return}fs(e,null,-1);return}if(!e.l)return;let i=Qa(e.l,e.wt,e.Mt,e.ki,e.Rt,e.$n,e.pt?.bandWidth??1,e.bt?.bandWidth??1,t,n);fs(e,i,-1)}function Ja(e,t,n){if(e.length===0)return-1;let i=0,r=e.length-1;for(;i<r;){let s=i+r>>1;e[s]<t?i=s+1:r=s}let o=i;return o>0&&Math.abs(e[o-1]-t)<Math.abs(e[o]-t)&&(o-=1),Math.abs(e[o]-t)>n*.5?-1:o}function Qa(e,t,n,i,r,o,s,l,a,u){let m=e.e;if(a<m.x||a>m.x+m.width||u<m.y||u>m.y+m.height)return null;let f=e.$,c=e.J,p=e.j,b=e.Q,g=f+(a-m.x)/m.width*(c-f),x=b-(u-m.y)/m.height*(b-p),h=r?Ja(r,g,s):Math.round(g),y=o?Ja(o,x,l):Math.round(x);return h<0||h>=t||y<0||y>=n?null:i[y*t+h]??null}function fs(e,t,n){let i=e.He;(i?.xIdx??-1)===(t?.xIdx??-1)&&(i?.yIdx??-1)===(t?.yIdx??-1)&&e.jn===n||(e.He=t,e.jn=n,e.t&&e._r&&e._r())}function eu(e,t){let n=[];for(let i of e){let r=i.labels[t];r!=null&&r!==""&&n.push(r)}return n.join(" / ")}function ds(e){if(!e.u||!e.He)return;let t,n,i,r,o=null;if(e.jn>=0){let p=e.m[e.jn];if(!p)return;t=p.layout,n=p.pipeline.xLevels,i=p.pipeline.yLevels,r=p.pipeline.xPositions,o=p.label}else{if(!e.l)return;t=e.l,n=e.$t,i=e.jt,r=e.Rt}let s=e.He,l={px:e.fo,py:e.co},a=[];o&&a.push(o);let u=e.Zt.mode==="numeric"&&r?e.getColumnFormatter(e.C[0],"value")(r[s.xIdx]):eu(n,s.xIdx),m=eu(i,s.yIdx);u&&a.push(u),m&&a.push(m);let f=e.getColumnFormatter(e.M[0],"value");a.push(`Value: ${f(s.value)}`);let c=e.T();ke(e.u,l,a,t,c,e.t?.dpr??1)}var ps={skipLeafLevel:!0};function tu(e,t){let n=t.gl,i=t.dpr,r=n.canvas.width/i,o=n.canvas.height/i;if(r<=0||o<=0)return;if(e.m.length>0){Fc(e,t,r,o);return}if(e.wt===0||e.Mt===0)return;let s=e.T(),l={levels:e.$t,numRows:e.wt,levelLabels:e.C.slice()},a={levels:e.jt,numRows:e.Mt,levelLabels:[]},u=e.Zt.mode==="numeric",m=e.Zn.mode==="numeric",f=Ze(e.i,!0),c=m?55:Ka(a,ps),p=u?24:Ue(l,Math.max(1,r-c-30-f)),b=new ie(r,o,{hasXLabel:e.C.length>0,hasYLabel:!1,hasLegend:!0,bottomExtra:p,leftExtra:c,rightExtra:f});e.l=b,e.h&&e.h.updateLayout(b);let g=u?e.pt.min:-.5,x=u?e.pt.max:e.wt-.5,h=m?e.bt.min:-.5,y=m?e.bt.max:e.Mt-.5;e.h&&e.h.setBaseDomain(g,x,h,y);let _=e.h?e.h.getVisibleDomain():{xMin:g,xMax:x,yMin:h,yMax:y},C=b.buildProjectionMatrix(_.xMin,_.xMax,_.yMin,_.yMax,void 0,void 0,0,e.S,e.F),v=b.e,A=v.width/(_.xMax-_.xMin),L=v.height/(_.yMax-_.yMin),T=s.Yr*.5,w=u?e.pt.bandWidth:1,M=m?e.bt.bandWidth:1,D=Math.min(w*.5,A>0?T/A:0),I=Math.min(M*.5,L>0?T/L:0);if(e.K){let F=ue(e.K,b,t.dpr)}nu(e,t),iu(e,t),e.re=yn(t,e.re,s.k),Je(n,b,t.dpr,()=>{n.useProgram(e.r);let F=e.I;n.uniformMatrix4fv(F.u_projection,!1,C),n.uniform2f(F.u_cell_inset,D,I),n.uniform2f(F.u_cell_size,w,M),Oe(t,e.re.texture,F.u_gradient_lut,0),ru(e,n,t,0,e.po)}),e.he(()=>Nr(e))}function nu(e,t){if(e.r)return;let n=t.gl,i=j(t,"heatmap",ei,ti,["u_projection","u_cell_inset","u_cell_size","u_gradient_lut"],["a_corner","a_cell","a_color_t"]);e.r=i.program,e.I=i;let r=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,r),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),e.O=r}function iu(e,t){let n=e.nt.length;if(e.po=n,n===0)return;let i=new Float32Array(n*2),r=new Float32Array(n);if(e.m.length>0){let o=0;for(let s of e.m){let l=s.pipeline.xPositions,a=s.pipeline.yPositions,u=s.xOrigin,m=s.yOrigin;for(let f of s.pipeline.cells)i[o*2]=l?l[f.xIdx]-u:f.xIdx,i[o*2+1]=a?a[f.yIdx]-m:f.yIdx,r[o]=bt(f.value,e.b,e.p),o++}}else{let o=e.Rt,s=e.$n,l=e.S,a=e.F;for(let u=0;u<n;u++){let m=e.nt[u];i[u*2]=o?o[m.xIdx]-l:m.xIdx,i[u*2+1]=s?s[m.yIdx]-a:m.yIdx,r[u]=bt(m.value,e.b,e.p)}}t.v.ensureCapacity(n),t.v.upload("heatmap_cell",i,0,2),t.v.upload("heatmap_t",r,0,1)}function ru(e,t,n,i,r){if(r===0)return;let o=e.I,s=J(n),{setDivisor:l}=s,a=Float32Array.BYTES_PER_ELEMENT;t.bindBuffer(t.ARRAY_BUFFER,e.O),t.enableVertexAttribArray(o.a_corner),t.vertexAttribPointer(o.a_corner,2,t.FLOAT,!1,0,0),l(o.a_corner,0);let u=n.v.peek("heatmap_cell"),m=n.v.peek("heatmap_t");!u||!m||(t.bindBuffer(t.ARRAY_BUFFER,u.buffer),t.enableVertexAttribArray(o.a_cell),t.vertexAttribPointer(o.a_cell,2,t.FLOAT,!1,0,i*2*a),l(o.a_cell,1),t.bindBuffer(t.ARRAY_BUFFER,m.buffer),t.enableVertexAttribArray(o.a_color_t),t.vertexAttribPointer(o.a_color_t,1,t.FLOAT,!1,0,i*a),l(o.a_color_t,1),s.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,r),l(o.a_cell,0),l(o.a_color_t,0))}function Nr(e){Sc(e),e.presentOverlay()}function Sc(e){if(!e.u)return;if(e.m.length>0){Ic(e);return}if(!e.l)return;let t=e.l,n=e.T(),i=e.t?.dpr??1,r=ue(e.u,t,i);if(!r)return;r.strokeStyle=n.Tn,r.lineWidth=1,r.beginPath(),r.moveTo(t.e.x,t.e.y),r.lineTo(t.e.x,t.e.y+t.e.height),r.lineTo(t.e.x+t.e.width,t.e.y+t.e.height),r.stroke();let o={levels:e.$t,numRows:e.wt,levelLabels:e.C.slice()},s={levels:e.jt,numRows:e.Mt,levelLabels:[]},l=e.C[0],a=e.C[1]??e.B[0];if(e.Zt.mode==="numeric"&&e.pt){let m=ne(t.$,t.J,6);Fr(r,t,e.pt,m,n,e.getColumnFormatter(l,"tick"))}else be(r,t,o,n);if(e.Zn.mode==="numeric"&&e.bt){let m=ne(t.j,t.Q,6);Ir(r,t,e.bt,m,n,e.getColumnFormatter(a,"tick"))}else ms(r,t,s,n,ps);let u=e.i.legend_mode;if(u==="none")e.R.clearPainted();else{let m={min:e.b,max:e.p,label:e.qn},f=e.getColumnFormatter(e.M[0],"value"),c={mode:u==="floating"?"floating":"sidebar",legend:e.R,title:e.qn,opacity:e.i.legend_opacity};u==="floating"?He(e.u,e.R.floatingBox(e.i,t.cssWidth,t.cssHeight),m,n.k,n,f,c):Yt(e.u,t,m,n.k,n,f,c)}e.He&&ds(e)}function Fc(e,t,n,i){let r=t.gl,o=e.T(),{effectiveSharedX:s,effectiveSharedY:l}=e.computeEffectiveFacetFlags(),a=Fe(e.m.map(m=>m.label),{cssWidth:n,cssHeight:i,xAxis:s?"outer":"cell",yAxis:l?"outer":"cell",hasLegend:e.i.legend_mode==="sidebar",legendWidth:Le(e.i,96),hasXLabel:e.C.length>0,hasYLabel:!1,gap:8});e.d=a;for(let m=0;m<e.m.length;m++){let f=a.cells[m];f&&(e.m[m].layout=f.layout)}e.syncFacetZoomLayouts(a.cells),nu(e,t),iu(e,t),e.re=yn(t,e.re,o.k),r.useProgram(e.r);let u=e.I;Oe(t,e.re.texture,u.u_gradient_lut,0),ht(r);for(let m=0;m<e.m.length;m++){let f=e.m[m];if(f.instanceCount===0)continue;let{numX:c,numY:p}=f.pipeline;if(c===0||p===0)continue;let b=f.layout,g=f.pipeline.xAxisMode.mode==="numeric",x=f.pipeline.yAxisMode.mode==="numeric",h=g?f.pipeline.xNumericDomain.min:-.5,y=g?f.pipeline.xNumericDomain.max:c-.5,_=x?f.pipeline.yNumericDomain.min:-.5,C=x?f.pipeline.yNumericDomain.max:p-.5,v=e.getZoomControllerForFacet(m);v&&v.setBaseDomain(h,y,_,C);let A=v?v.getVisibleDomain():{xMin:h,xMax:y,yMin:_,yMax:C},L=b.buildProjectionMatrix(A.xMin,A.xMax,A.yMin,A.yMax,void 0,void 0,0,f.xOrigin,f.yOrigin),T=b.e,w=T.width/(A.xMax-A.xMin),M=T.height/(A.yMax-A.yMin),D=o.Yr*.5,I=g?f.pipeline.xNumericDomain.bandWidth:1,F=x?f.pipeline.yNumericDomain.bandWidth:1,B=Math.min(I*.5,w>0?D/w:0),N=Math.min(F*.5,M>0?D/M:0);xt(r,b,t.dpr,()=>{r.uniformMatrix4fv(u.u_projection,!1,L),r.uniform2f(u.u_cell_inset,B,N),r.uniform2f(u.u_cell_size,I,F),ru(e,r,t,f.instanceStart,f.instanceCount)})}e.he(()=>Nr(e))}function Ic(e){if(!e.u||!e.d)return;let t=e.T(),n=e.t?.dpr??1,i=ue(e.u,e.m[0].layout,n);if(!i)return;let r=e.ci,o=e.di,s=e.d;for(let f=0;f<e.m.length;f++){let c=e.m[f],p=s.cells[f],b=c.layout,g=b.e;i.strokeStyle=t.Tn,i.lineWidth=1,i.beginPath(),i.moveTo(g.x,g.y),i.lineTo(g.x,g.y+g.height),i.lineTo(g.x+g.width,g.y+g.height),i.stroke();let x={levels:c.pipeline.xLevels,numRows:c.pipeline.numX,levelLabels:e.C.slice()},h={levels:c.pipeline.yLevels,numRows:c.pipeline.numY,levelLabels:[]},y=e.C[0],_=e.C[1]??e.B[0];if(!r||p.isBottomEdge)if(c.pipeline.xAxisMode.mode==="numeric"&&c.pipeline.xNumericDomain){let C=ne(b.$,b.J,6);Fr(i,b,c.pipeline.xNumericDomain,C,t,e.getColumnFormatter(y,"tick"))}else be(i,b,x,t);if(!o||p.isLeftEdge)if(c.pipeline.yAxisMode.mode==="numeric"&&c.pipeline.yNumericDomain){let C=ne(b.j,b.Q,6);Ir(i,b,c.pipeline.yNumericDomain,C,t,e.getColumnFormatter(_,"tick"))}else ms(i,b,h,t,ps)}for(let f=0;f<s.cells.length;f++){let c=s.cells[f],p=e.m[f];!p||!c.titleRect||Pt(e.u,p.label,c.titleRect,t,n)}let l=e.i.legend_mode,a=l==="floating",u=e.m[0].layout,m=a?e.R.floatingBox(e.i,u.cssWidth,u.cssHeight):s.legendRect;l!=="none"&&m?He(e.u,a?m:{x:m.x,y:m.y+20,width:m.width,height:Math.max(1,m.height-20)},{min:e.b,max:e.p,label:""},t.k,t,e.getColumnFormatter(e.M[0],"value"),{mode:a?"floating":"sidebar",legend:e.R,title:e.qn,sidebarGutter:a?void 0:s.legendRect?.width,opacity:e.i.legend_opacity}):e.R.clearPainted(),e.He&&ds(e)}var Or=class extends Se{constructor(){super(...arguments);d(this,"r",null);d(this,"I",null);d(this,"O",null);d(this,"re",null);d(this,"$t",[]);d(this,"jt",[]);d(this,"vr",[]);d(this,"wt",0);d(this,"Mt",0);d(this,"dt",0);d(this,"Zt",{mode:"category"});d(this,"Zn",{mode:"category"});d(this,"Rt",null);d(this,"$n",null);d(this,"pt",null);d(this,"bt",null);d(this,"S",0);d(this,"F",0);d(this,"nt",[]);d(this,"ki",[]);d(this,"po",0);d(this,"b",0);d(this,"p",1);d(this,"qn","");d(this,"He",null);d(this,"l",null);d(this,"fo",0);d(this,"co",0);d(this,"m",[]);d(this,"d",null);d(this,"jn",-1);d(this,"_r",()=>Nr(this))}colorScaleColumn(){return this.M[0]||null}tooltipCallbacks(){return{onHover:(n,i)=>cs(this,n,i),onLeave:()=>{this.He&&(this.He=null,this._r())},onPin:(n,i)=>{cs(this,n,i),this.He&&this.Io(this.He.xIdx,this.He.yIdx)},onUnpin:()=>{this.emitUnselect()}}}async Io(n,i){let r=this.Zt.mode==="numeric"&&this.Rt?[this.Rt[n]??null]:this.$t.map(l=>l.labels[n]??null),o=this.jt.slice(0,this.B.length).map(l=>l.labels[i]??null),s=this.M[0]??"";await this.emitClickAndSelect({rowIdx:n+this.dt,columnName:s,groupByValues:r,splitByValues:o})}async uploadAndRender(n,i,r,o){if(this.t=n,r!==0)return;let s=this.M.filter(l=>!!l);if(s.length>1){let l=Za(i,s),a=[],u=[],m=1/0,f=-1/0;for(let c of l){let p=ss({columns:c.columns,numRows:o,groupBy:this.C,splitBy:this.B,groupByTypes:this.Ct}),b=u.length;for(let g of p.cells)u.push({xIdx:g.xIdx,yIdx:g.yIdx,value:g.value});a.push({label:c.label,pipeline:p,layout:new ie(1,1,{hasXLabel:!1,hasYLabel:!1,hasLegend:!1}),instanceStart:b,instanceCount:p.cells.length,xOrigin:p.xNumericDomain?.min??0,yOrigin:p.yNumericDomain?.min??0}),isFinite(p.colorMin)&&p.colorMin<m&&(m=p.colorMin),isFinite(p.colorMax)&&p.colorMax>f&&(f=p.colorMax)}!isFinite(m)||!isFinite(f)?(m=0,f=1):m===f&&(f=m+1),this.$t=[],this.jt=[],this.vr=[],this.wt=0,this.Mt=0,this.dt=0,this.ki=[],this.l=null,this.Zt={mode:"category"},this.Zn={mode:"category"},this.Rt=null,this.$n=null,this.pt=null,this.bt=null,this.S=0,this.F=0,this.m=a,this.nt=u,this.b=m,this.p=f,this.qn=s.join(", ")}else{let l=ss({columns:i,numRows:o,groupBy:this.C,splitBy:this.B,groupByTypes:this.Ct});this.m=[],this.d=null,this.$t=l.xLevels,this.jt=l.yLevels,this.vr=l.yColumnNames,this.wt=l.numX,this.Mt=l.numY,this.dt=l.rowOffset,this.nt=l.cells,this.ki=l.cells2D,this.b=l.colorMin,this.p=l.colorMax,this.qn=s[0]??"Color",this.Zt=l.xAxisMode,this.Zn=l.yAxisMode,this.Rt=l.xPositions,this.$n=l.yPositions,this.pt=l.xNumericDomain,this.bt=l.yNumericDomain,this.S=l.xNumericDomain?.min??0,this.F=l.yNumericDomain?.min??0}await this.requestRender(n)}Wt(n){this.t=n;let i=this.wt>0&&this.Mt>0,r=this.m.length>0;!i&&!r||tu(this,n)}destroyInternal(){this.O&&this.t&&this.t.gl.deleteBuffer(this.O),this.r=null,this.I=null,this.O=null,this.$t=[],this.jt=[],this.vr=[],this.nt=[],this.ki=[],this.He=null,this.m=[],this.d=null,this.jn=-1,this.Zt={mode:"category"},this.Zn={mode:"category"},this.Rt=null,this.$n=null,this.pt=null,this.bt=null}};pn();function Nn(){return{count:0,catIdx:new Int32Array(0),splitIdx:new Int32Array(0),seriesId:new Int32Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),open:new Float64Array(0),close:new Float64Array(0),high:new Float64Array(0),low:new Float64Array(0),isUp:new Uint8Array(0)}}function Dc(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),splitIdx:new Int32Array(t),seriesId:new Int32Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),open:new Float64Array(t),close:new Float64Array(t),high:new Float64Array(t),low:new Float64Array(t),isUp:new Uint8Array(t)}}var ou={splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:{mode:"category"},numericCategoryDomain:null,categoryPositions:null,series:[],yDomain:{min:0,max:1}};function su(e){let{columns:t,numRows:n,columnSlots:i,groupBy:r,splitBy:o,groupByTypes:s,bandInnerFrac:l,barInnerPad:a,scratchCandles:u}=e,m=qt(r,s),f=i[0]||"";if(!f)return{...ou,candles:Nn()};let c=i[1]||"",p=i[2]||"",b=i[3]||"",g=[];if(o.length>0){let U=[f];c&&U.push(c),p&&U.push(p),b&&U.push(b);for(let z of qe(t,[f],U))z.colNames.has(f)&&g.push(z.prefix);g.length===0&&g.push("")}else g.push("");let x=r.map(U=>s[U]??"string"),{rowPaths:h,numCategories:y,rowOffset:_}=Kt(t,n,r.length,x,m);if(y===0)return{...ou,axisMode:m,splitPrefixes:g,rowPaths:h,rowOffset:_,candles:Nn()};let C=g.length,v=[];for(let U=0;U<C;U++){let z=g[U];v.push({seriesId:U,splitIdx:U,splitKey:z,label:z===""?f:z})}let A=null,L=null,T=1;if(m.mode==="numeric"&&y>0){let U=t.get("__ROW_PATH_0__"),z=Lt(U?.values,y,_,r[0]??"",m.numericType==="date"||m.numericType==="datetime");z&&(A=z.categoryPositions,L=z.numericCategoryDomain,T=z.numericCategoryDomain.bandWidth)}let w=Ar(C,l,a),M=w.slotWidth*T,D=w.halfWidth*T,I=(C-1)/2,F=[];for(let U=0;U<C;U++){let z=g[U],q=st=>z===""?st:`${z}|${st}`,ae=t.get(q(f));if(!ae?.values){F.push({openCol:null,closeCol:null,highCol:null,lowCol:null,openValid:null,closeValid:null,highValid:null,lowValid:null});continue}let Be=c?t.get(q(c)):null,we=p?t.get(q(p)):null,Me=b?t.get(q(b)):null;F.push({openCol:ae.values,closeCol:Be?.values??null,highCol:we?.values??null,lowCol:Me?.values??null,openValid:ae.valid??null,closeValid:Be?.valid??null,highValid:we?.valid??null,lowValid:Me?.valid??null})}let B=y*C,N=Dc(u??null,B),k=0,Y=1/0,W=-1/0,H=y;for(let U=0;U<C;U++){let z=F[U],q=z.openCol;if(!q)continue;let ae=z.closeCol,Be=z.highCol,we=z.lowCol,Me=z.openValid,st=z.closeValid,sn=z.highValid,ln=z.lowValid,an=(U-I)*M;for(let ye=0;ye<H;ye++){let se=ye+_;if(Me&&!(Me[se>>3]>>(se&7)&1))continue;let Q=q[se];if(!isFinite(Q))continue;let re;if(ae&&(!st||(st[se>>3]>>(se&7)&1)!==0)){let K=ae[se];re=isFinite(K)?K:Q}else{let K=ye<H-1?ye+1+_:se;if(!Me||(Me[K>>3]>>(K&7)&1)!==0){let Mt=q[K];re=isFinite(Mt)?Mt:Q}else re=Q}let Ee;if(Be&&(!sn||(sn[se>>3]>>(se&7)&1)!==0)){let K=Be[se];Ee=isFinite(K)?K:Q>re?Q:re}else Ee=Q>re?Q:re;let Pe;if(we&&(!ln||(ln[se>>3]>>(se&7)&1)!==0)){let K=we[se];Pe=isFinite(K)?K:Q<re?Q:re}else Pe=Q<re?Q:re;let qr=(A?A[ye]:ye)+an,Ge=re>=Q?1:0;N.catIdx[k]=ye,N.splitIdx[k]=U,N.seriesId[k]=U,N.xCenter[k]=qr,N.halfWidth[k]=D,N.open[k]=Q,N.close[k]=re,N.high[k]=Ee,N.low[k]=Pe,N.isUp[k]=Ge,k++,Pe<Y&&(Y=Pe),Ee>W&&(W=Ee)}}if(N.count=k,!isFinite(Y)||!isFinite(W))Y=0,W=1;else if(Y===W){let U=Math.max(Math.abs(Y),1)*.05;Y-=U,W+=U}return{splitPrefixes:g,rowPaths:h,numCategories:y,rowOffset:_,axisMode:m,numericCategoryDomain:L,categoryPositions:A,series:v,candles:N,yDomain:{min:Y,max:W}}}Ke();de();xn();Bt();Ae();Vt();var Bc=3;function lu(e,t,n){let i=0,r=t;for(;i<r;){let o=i+r>>>1;e[o]<n?i=o+1:r=o}return i}function bs(e,t,n){if(e.Ar!==-1)return;let i=e.l;if(!i)return;let r=e.ve;if(r.count===0){e.Ae!==-1&&(e.Ae=-1,ot(e));return}let o=i.e,s=i.$,l=i.J,a=i.j,u=i.Q;if(t<o.x||t>o.x+o.width||n<o.y||n>o.y+o.height){e.Ae!==-1&&(e.Ae=-1,ot(e));return}let m=s+(t-o.x)/o.width*(l-s),f=u-(n-o.y)/o.height*(u-a),c=o.width/(l-s),p=Bc/c,b=r.xCenter,g=r.halfWidth,x=r.open,h=r.close,y=r.high,_=r.low,C=r.count>0?g[0]:0,v=Math.max(C,p),A=lu(b,r.count,m-v),L=lu(b,r.count,m+v+1e-12),T=-1;for(let w=L-1;w>=A;w--){let M=b[w],D=g[w],I=m>=M-D&&m<=M+D,F=Math.abs(m-M)<=p;if(!I&&!F)continue;let B=x[w],N=h[w],k=B<N?B:N,Y=B<N?N:B,W=I&&f>=k&&f<=Y,H=f>=_[w]&&f<=y[w];if(W||H){T=w;break}}T!==e.Ae&&(e.Ae=T,ot(e))}function au(e,t){e.L.dismiss(),e.Ar=t;let n=e.ve;if(t<0||t>=n.count||!e.l)return;let i=gs(e,t);if(i.length===0)return;let r=n.xCenter[t],o=(n.high[t]+n.low[t])/2,s=e.l.E(r,o),l=e.l.cssWidth,a=e.l.cssHeight;e.L.pin(i,s,{cssWidth:l,cssHeight:a}),e.Ae=-1,ot(e)}function gs(e,t){let n=[],i=e.ve;if(t<0||t>=i.count)return n;let r=i.catIdx[t],o=i.splitIdx[t],s=i.open[t],l=i.close[t],a=i.high[t],u=i.low[t];if(e.Ue==="numeric"&&e.G&&e.le){let b=e.le[r],g=e.C[0];n.push(e.getColumnFormatter(g,"value")(b))}else if(e.Ie.length>0){let b=[];for(let g of e.Ie){let x=g.labels[r]??"";x&&b.push(x)}b.length>0&&n.push(b.join(" \\u203A "))}else n.push(`Row ${r+e.dt}`);if(o>=0&&e.pe.length>1){let b=e.pe[o];b&&n.push(b)}let m=e.getColumnFormatter(e.M[0],"value"),f=e.getColumnFormatter(e.M[1],"value"),c=e.getColumnFormatter(e.M[2],"value"),p=e.getColumnFormatter(e.M[3],"value");return n.push(`Open: ${m(s)}`),n.push(`Close: ${f(l)}`),n.push(`High: ${c(a)}`),n.push(`Low: ${p(u)}`),n}function uu(e,t,n,i,r){let o=1/0,s=-1/0,l={cat:0,lo:0,hi:0,skip:!1};for(let u=0;u<e.length;u++)l.skip=!1,i(e[u],l),!l.skip&&(l.cat<t||l.cat>n||(l.lo<o&&(o=l.lo),l.hi>s&&(s=l.hi)));let a=isFinite(o)&&isFinite(s);if(a&&o===s){let u=Math.abs(o)||1;o-=u,s+=u}return r.min=o,r.max=s,r.hasFit=a,r}function hs(e){let n=e.T().k;if(e.Ni===n)return;let i=Re(n,1),r=Re(n,0);e.Oi=[i[0],i[1],i[2]],e.Ui=[r[0],r[1],r[2]],e.Ni=n}function mu(e){e.U.bodyWick.invalidateBuffers(e),e.U.ohlc.invalidateBuffers(e)}function fu(e,t){e.U.bodyWick.rebuildBuffers(e,t),e.U.ohlc.rebuildBuffers(e,t)}function cu(e,t){let n=t.gl,i=t.dpr,r=n.canvas.width/i,o=n.canvas.height/i;if(r<=0||o<=0||e.te===0)return;let s=e.T();hs(e);let l=e.Ue==="numeric",a=l?e.G.min:-.5,u=l?e.G.max:e.te-.5;e.h&&e.h.setBaseDomain(a,u,e.Kn.min,e.Kn.max);let m=e.h?e.h.getVisibleDomain():{xMin:a,xMax:u,yMin:e.Kn.min,yMax:e.Kn.max};if(e.xi&&e.h&&!e.h.isXDefault()){let _=Gc(e,m.xMin,m.xMax);_.hasFit&&(m.yMin=_.min,m.yMax=_.max)}let f=e.C.length>0,c={levels:e.Ie,numRows:e.te,levelLabels:e.C.slice()},p;if(l)p=new ie(r,o,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:24});else{let v=Math.max(1,r-71-16),A=Ue(c,v);p=new ie(r,o,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:A})}e.l=p,e.h&&e.h.updateLayout(p);let b=p.buildProjectionMatrix(m.xMin,m.xMax,m.yMin,m.yMax,"y",void 0,void 0,e.ae,0),g=ne(m.yMin,m.yMax,6),x=e.M[0]||"",h=c,y={min:m.yMin,max:m.yMax,label:x};e.K&&Br(e.K,p,g,s,t.dpr),Je(n,p,t.dpr,()=>{e.pi==="ohlc"?e.U.ohlc.draw(e,n,t,b):e.U.bodyWick.draw(e,n,t,b)}),e.ue=h,e.me=y,e.Fe=g,e.qe=l?ne(m.xMin,m.xMax,6):null,e.he(()=>ot(e))}function ot(e){Ec(e),e.presentOverlay()}function Ec(e){if(!e.u||!e.l||!e.me||!e.Fe)return;let t=e.T(),n;if(e.Ue==="numeric"&&e.G&&e.qe)n={mode:"numeric",domain:{min:e.G.min,max:e.G.max,isDate:e.G.isDate,label:e.G.label},ticks:e.qe};else if(e.ue)n={mode:"category",domain:e.ue};else return;let i=e.M[0]??e.M[1]??e.M[2]??e.M[3],r=e.C[0];Dr(e.u,n,{mode:"numeric",domain:e.me,ticks:e.Fe},e.l,t,e.t?.dpr??1,void 0,!1,{value:e.getColumnFormatter(i,"tick"),category:e.getColumnFormatter(r,"tick")}),e.Ae>=0&&e.Ae<e.ve.count&&Pc(e)}function Pc(e){if(!e.u||!e.l)return;let t=e.Ae,n=e.ve;if(t<0||t>=n.count)return;let i=e.l,r=n.xCenter[t],o=(n.high[t]+n.low[t])/2,s=i.E(r,o),l=gs(e,t),a=e.T();ke(e.u,s,l,i,a,e.t?.dpr??1,{crosshair:!1,highlightRadius:0})}function Gc(e,t,n){let i=e.Lt;if(i&&i.xMin===t&&i.xMax===n)return i;let r=i??Wc();r.xMin=t,r.xMax=n;let o=e.ve,s=1/0,l=-1/0,a=!1,u=o.xCenter,m=o.low,f=o.high;for(let c=0;c<o.count;c++){let p=u[c];p<t||p>n||(m[c]<s&&(s=m[c]),f[c]>l&&(l=f[c]),a=!0)}return r.min=a?s:0,r.max=a?l:1,r.hasFit=a,e.Lt=r,r}function Wc(){return{xMin:0,xMax:0,min:0,max:1,hasFit:!1}}De();fe();var Ur=class{constructor(){d(this,"r",null);d(this,"o",null)}ensureProgram(t){if(this.r)return this.r;let n=t.gl,i=qi(n),o={...j(t,"candlestick-body",Jn,Qn,["u_projection"],["a_corner","a_x_center","a_half_width","a_y0","a_y1","a_color"]),quadBuffer:i,instanceBuffer:n.createBuffer()},s=et(n),a={...j(t,"line-uniform",Xe,$e,["u_projection","u_color","u_resolution","u_line_width","u_interp_alpha"],["a_corner","a_start","a_end","a_real_start","a_real_end"]),cornerBuffer:s,segmentBuffer:n.createBuffer()};return this.r={body:o,wick:a},this.r}invalidateBuffers(t){let n=this.o;if(!n||!t.t){this.o=null;return}let i=t.t.gl;i.deleteBuffer(n.upWickBuffer),i.deleteBuffer(n.downWickBuffer),this.o=null}rebuildBuffers(t,n){let i=t.ve,r=this.ensureProgram(n),o=n.gl,s=t.ae;if(i.count===0){let M=o.createBuffer(),D=o.createBuffer();this.o={bodyCount:0,upWickCount:0,downWickCount:0,upWickBuffer:M,downWickBuffer:D};return}let l=new Float32Array(i.count*7),a=0,u=0,m=i.xCenter,f=i.halfWidth,c=i.open,p=i.close,b=i.isUp,g=t.Oi,x=t.Ui;for(let M=0;M<i.count;M++){let D=c[M],I=p[M],F=D<I?D:I,B=D<I?I:D,N=b[M]!==0,k=N?g:x,Y=M*7;l[Y+0]=m[M]-s,l[Y+1]=f[M]*.7,l[Y+2]=F,l[Y+3]=B,l[Y+4]=k[0],l[Y+5]=k[1],l[Y+6]=k[2],N?a++:u++}o.bindBuffer(o.ARRAY_BUFFER,r.body.instanceBuffer),o.bufferData(o.ARRAY_BUFFER,l,o.STATIC_DRAW);let h=new Float32Array(a*4),y=new Float32Array(u*4),_=0,C=0,v=i.low,A=i.high;for(let M=0;M<i.count;M++){let D=m[M]-s,I=v[M],F=A[M];b[M]!==0?(h[_+0]=D,h[_+1]=I,h[_+2]=D,h[_+3]=F,_+=4):(y[C+0]=D,y[C+1]=I,y[C+2]=D,y[C+3]=F,C+=4)}let L=this.o,T=L?.upWickBuffer??o.createBuffer(),w=L?.downWickBuffer??o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,T),o.bufferData(o.ARRAY_BUFFER,h,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,w),o.bufferData(o.ARRAY_BUFFER,y,o.STATIC_DRAW),this.o={bodyCount:i.count,upWickCount:a,downWickCount:u,upWickBuffer:T,downWickBuffer:w}}draw(t,n,i,r){let o=this.o;if(!o||o.bodyCount===0)return;let s=this.ensureProgram(i);kc(n,i,s.body,o.bodyCount,r),Nc(t,n,i,s.wick,o,r)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let i=this.r;i&&(n.deleteBuffer(i.body.quadBuffer),n.deleteBuffer(i.body.instanceBuffer),n.deleteBuffer(i.wick.cornerBuffer),n.deleteBuffer(i.wick.segmentBuffer))}this.r=null,this.o=null}};function kc(e,t,n,i,r){if(i===0)return;let o=7*Float32Array.BYTES_PER_ELEMENT;e.useProgram(n.program),e.uniformMatrix4fv(n.u_projection,!1,r);let s=J(t),{setDivisor:l}=s;e.bindBuffer(e.ARRAY_BUFFER,n.quadBuffer),e.enableVertexAttribArray(n.a_corner),e.vertexAttribPointer(n.a_corner,2,e.FLOAT,!1,0,0),l(n.a_corner,0),e.bindBuffer(e.ARRAY_BUFFER,n.instanceBuffer);let a=Float32Array.BYTES_PER_ELEMENT,u=(m,f,c)=>{e.enableVertexAttribArray(m),e.vertexAttribPointer(m,f,e.FLOAT,!1,o,c),l(m,1)};u(n.a_x_center,1,0),u(n.a_half_width,1,1*a),u(n.a_y0,1,2*a),u(n.a_y1,1,3*a),u(n.a_color,3,4*a),s.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,i),l(n.a_x_center,0),l(n.a_half_width,0),l(n.a_y0,0),l(n.a_y1,0),l(n.a_color,0)}function Nc(e,t,n,i,r,o){if(r.upWickCount===0&&r.downWickCount===0)return;let s=n.dpr;t.useProgram(i.program),t.uniformMatrix4fv(i.u_projection,!1,o),t.uniform2f(i.u_resolution,t.canvas.width,t.canvas.height),t.uniform1f(i.u_line_width,e.i.wick_width_px*s),t.disableVertexAttribArray(i.a_real_start),t.disableVertexAttribArray(i.a_real_end),t.vertexAttrib1f(i.a_real_start,1),t.vertexAttrib1f(i.a_real_end,1),t.uniform1f(i.u_interp_alpha,1);let l=J(n),{setDivisor:a}=l;t.bindBuffer(t.ARRAY_BUFFER,i.cornerBuffer),t.enableVertexAttribArray(i.a_corner),t.vertexAttribPointer(i.a_corner,1,t.FLOAT,!1,0,0),a(i.a_corner,0),du(t,l,i,r.upWickBuffer,r.upWickCount,e.Oi),du(t,l,i,r.downWickBuffer,r.downWickCount,e.Ui),a(i.a_start,0),a(i.a_end,0)}function du(e,t,n,i,r,o){if(r===0)return;let s=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:l}=t;e.uniform4f(n.u_color,o[0],o[1],o[2],1),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,2*s,0),l(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,2*s,s),l(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,r)}De();fe();var Hr=class{constructor(){d(this,"r",null);d(this,"o",null)}ensureProgram(t){if(this.r)return this.r;let n=t.gl,i=et(n),r=j(t,"line-uniform",Xe,$e,["u_projection","u_color","u_resolution","u_line_width","u_interp_alpha"],["a_corner","a_start","a_end","a_real_start","a_real_end"]);return this.r={...r,cornerBuffer:i,segmentBuffer:n.createBuffer()},this.r}invalidateBuffers(t){let n=this.o;if(!n||!t.t){this.o=null;return}let i=t.t.gl;i.deleteBuffer(n.upBuffer),i.deleteBuffer(n.downBuffer),this.o=null}rebuildBuffers(t,n){if(t.pi!=="ohlc")return;let i=t.ve,r=n.gl;this.ensureProgram(n);let o=t.ae,s=i.xCenter,l=i.halfWidth,a=i.open,u=i.close,m=i.high,f=i.low,c=i.isUp,p=0,b=0;for(let A=0;A<i.count;A++)c[A]!==0?p++:b++;let g=new Float32Array(p*3*4),x=new Float32Array(b*3*4),h=0,y=0;for(let A=0;A<i.count;A++){let L=s[A]-o,T=a[A],w=u[A],M=f[A],D=m[A],I=l[A],F=c[A]!==0?g:x,B=c[A]!==0?h:y;F[B++]=L,F[B++]=M,F[B++]=L,F[B++]=D,F[B++]=L-I,F[B++]=T,F[B++]=L,F[B++]=T,F[B++]=L,F[B++]=w,F[B++]=L+I,F[B++]=w,c[A]!==0?h=B:y=B}let _=this.o,C=_?.upBuffer??r.createBuffer(),v=_?.downBuffer??r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,C),r.bufferData(r.ARRAY_BUFFER,g,r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,v),r.bufferData(r.ARRAY_BUFFER,x,r.STATIC_DRAW),this.o={upBuffer:C,downBuffer:v,upInstanceCount:p*3,downInstanceCount:b*3}}draw(t,n,i,r){let o=this.o;if(!o||o.upInstanceCount===0&&o.downInstanceCount===0)return;let s=this.ensureProgram(i),l=i.dpr;n.useProgram(s.program),n.uniformMatrix4fv(s.u_projection,!1,r),n.uniform2f(s.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(s.u_line_width,t.i.ohlc_line_width_px*l),n.disableVertexAttribArray(s.a_real_start),n.disableVertexAttribArray(s.a_real_end),n.vertexAttrib1f(s.a_real_start,1),n.vertexAttrib1f(s.a_real_end,1),n.uniform1f(s.u_interp_alpha,1);let a=J(i),{setDivisor:u}=a;n.bindBuffer(n.ARRAY_BUFFER,s.cornerBuffer),n.enableVertexAttribArray(s.a_corner),n.vertexAttribPointer(s.a_corner,1,n.FLOAT,!1,0,0),u(s.a_corner,0),pu(n,a,s,o.upBuffer,o.upInstanceCount,t.Oi),pu(n,a,s,o.downBuffer,o.downInstanceCount,t.Ui),u(s.a_start,0),u(s.a_end,0)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let i=this.r;i&&(n.deleteBuffer(i.cornerBuffer),n.deleteBuffer(i.segmentBuffer))}this.r=null,this.o=null}};function pu(e,t,n,i,r,o){if(r===0)return;let s=4*Float32Array.BYTES_PER_ELEMENT,l=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:a}=t;e.uniform4f(n.u_color,o[0],o[1],o[2],1),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,s,0),a(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,s,l),a(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,r)}var On=class extends Qt{constructor(){super(...arguments);d(this,"I",null);d(this,"pe",[]);d(this,"f",[]);d(this,"ve",Nn());d(this,"Kn",{min:0,max:1});d(this,"Hi",null);d(this,"Ue","category");d(this,"G",null);d(this,"le",null);d(this,"qe",null);d(this,"ae",0);d(this,"Oi",[0,.8,.4]);d(this,"Ui",[.8,.2,.2]);d(this,"Ni",null);d(this,"Ae",-1);d(this,"Ar",-1);d(this,"U",{bodyWick:new Ur,ohlc:new Hr});d(this,"xi",!0);d(this,"Lt",null)}tooltipCallbacks(){return{onHover:(n,i)=>bs(this,n,i),onLeave:()=>{this.Ae!==-1&&(this.Ae=-1,ot(this))},onPin:(n,i)=>{if(bs(this,n,i),this.Ae>=0){let r=this.Ae;au(this,r),this.Do(r)}},onUnpin:()=>{this.emitUnselect()}}}async Do(n){if(n<0||n>=this.ve.count)return;let i=this.ve.catIdx[n],r=this.ve.splitIdx[n],o=this.Ue==="numeric"&&this.le?[this.le[i]??null]:this.Ie.map(u=>u.labels[i]??null),s=this.pe[r]??"",l=this.B.length>0&&s!==""?s.split("|"):[],a=this.M[1]||this.M.find(u=>!!u)||"";await this.emitClickAndSelect({rowIdx:i+this.dt,columnName:a,groupByValues:o,splitByValues:l})}invalidateTheme(){super.invalidateTheme(),this.Ni=null}async uploadAndRender(n,i,r,o){if(this.t=n,r!==0)return;let s=su({columns:i,numRows:o,columnSlots:this.M,groupBy:this.C,splitBy:this.B,groupByTypes:this.Ct,bandInnerFrac:this.i.band_inner_frac,barInnerPad:this.i.bar_inner_pad,scratchCandles:this.ve});this.i.domain_mode==="expand"?this.Hi=kn(this.Hi,s.yDomain):this.Hi=null,this.Ie=s.rowPaths,this.te=s.numCategories,this.dt=s.rowOffset,this.pe=s.splitPrefixes,this.f=s.series,this.ve=s.candles,this.Kn=s.yDomain,this.Ue=s.axisMode.mode,this.G=s.numericCategoryDomain,this.le=s.categoryPositions,this.ae=s.numericCategoryDomain?.min??0,this.Lt=null,hs(this),mu(this),fu(this,n),await this.requestRender(n)}Wt(n){this.t=n,cu(this,n)}resetExpandedDomain(){this.Hi=null}destroyInternal(){if(this.t){let n=this.t.gl;this.O&&n.deleteBuffer(this.O),this.U.bodyWick.destroy(this),this.U.ohlc.destroy(this)}this.r=null,this.I=null,this.O=null,this.ve=Nn(),this.f=[],this.Ie=[],this.te=0,this.Ni=null}};var xu={scatter:async()=>Ki,line:async()=>Ji,density:async()=>Qi,treemap:async()=>xr,sunburst:async()=>vr,heatmap:async()=>Or,"y-bar":async()=>rt,"y-line":async()=>rt,"y-scatter":async()=>rt,"y-area":async()=>rt,"x-bar":async()=>kr,candlestick:async()=>On,ohlc:async()=>On,"map-scatter":async()=>(await Promise.resolve().then(()=>($r(),Xr))).MapScatterChart,"map-line":async()=>(await Promise.resolve().then(()=>($r(),Xr))).MapLineChart,"map-density":async()=>(await Promise.resolve().then(()=>($r(),Xr))).MapDensityChart};async function yu(e,t,n){let i=new Map;await e.with_typed_arrays(n??{},async(r,o,s,l)=>{for(let u=0;u<r.length;u++){let m=r[u],f=o[u],c=s[u]??void 0,p=l[u];p!==null?i.set(m,{type:"string",indices:f,dictionary:p,valid:c}):f instanceof Float32Array?i.set(m,{type:"float32",values:f,valid:c}):f instanceof Int32Array?i.set(m,{type:"int32",values:f,valid:c}):f instanceof Float64Array?i.set(m,{type:"float64",values:f,valid:c}):i.set(m,{type:"float32",values:new Float32Array(f),valid:c})}let a=0;if(i.size>0){a=1/0;for(let u of i.values()){let m=u.indices?.length??u.values?.length??0;m<a&&(a=m)}}await t(i,a)})}gi();var Cu=new Map;async function _u(e){let t=[e.family,e.src,e.weight??"",e.style??""].join("|"),n=Cu.get(t);if(n){await n;return}n=(async()=>{try{let i={};e.style&&(i.style=e.style),e.weight&&(i.weight=e.weight),e.stretch&&(i.stretch=e.stretch);let r=new FontFace(e.family,e.src,i);await r.load(),self.fonts.add(r)}catch(i){console.warn(`Failed to load font ${e.family}:`,i)}})(),Cu.set(t,n),await n}function on(e,t){switch(t.kind){case"setViewByName":e.setViewByName(t.name);break;case"setColumnsConfig":e.chartImpl.setColumnsConfig?.(t.cfg);break;case"setPluginConfig":e.setPluginConfig(t.cfg,t.tileSource),e.redraw();break;case"setBufferMaxCapacity":e.glManager.v.maxCapacity=t.n;break;case"loadAndRender":e.loadAndRender(t);break;case"redraw":e.redraw();break;case"deselect":e.chartImpl.deselect?.();break;case"resize":e.resize(t.cssWidth,t.cssHeight,t.dpr),e.redrawAck(t.msgId);break;case"clear":e.clear();break;case"invalidateTheme":e.chartImpl.setTheme?.(t.themeVars),e.chartImpl.invalidateTheme?.(),e.resize(e.cssWidth,e.cssHeight,e.dpr);break;case"restoreZoom":e.restoreZoom(t.state);break;case"resetAllZooms":e.resetAllZooms(),e.redraw(),e.post({kind:"zoomChanged",isDefault:e.allZoomsDefault()});break;case"resetExpandedDomain":e.resetExpandedDomain();break;case"interaction":e.onInteraction(t.event);break;case"saveZoom":e.post({kind:"saveZoomReply",requestId:t.requestId,state:e.saveZoom()});break;case"destroy":e.destroy();break;case"init":break;case"snapshotPng":{let n=t.requestId;e.snapshotPng().then(i=>{e.post({kind:"snapshotPngReply",requestId:n,blob:i})}).catch(i=>{e.post({kind:"snapshotPngReply",requestId:n,error:String(i)})});break}}}var Un=new Map,_s=new Set;function vs(e,t,n){let i={sessionId:e,msg:t};n&&n.length>0?self.postMessage(i,n):self.postMessage(i)}function Oc(e){return{postMessage:(t,n)=>vs(e,t,n),addEventListener:()=>{},removeEventListener:()=>{},start:()=>{},close:()=>{},dispatchEvent:()=>!1,onmessage:null,onmessageerror:null}}function vu(e){self.addEventListener("message",function(t){let n=t.data,{sessionId:i,msg:r}=n;if(r.kind==="init"){if(Un.has(i)){vs(i,{kind:"error",message:`sessionId ${i} already initialized`});return}e(r,Oc(i)).then(s=>{if(_s.delete(i)){on(s,{kind:"destroy"});return}Un.set(i,s)}).catch(s=>{_s.delete(i),vs(i,{kind:"error",message:String(s)})});return}if(r.kind==="destroy"){let s=Un.get(i);s?(on(s,r),Un.delete(i)):_s.add(i);return}let o=Un.get(i);o&&on(o,r)})}yo();var jr=class extends Error{constructor(){super("StaleGenerationError")}};async function Lu(e){let t=xu[e];if(!t)throw new Error(`Unknown chart tag: ${e}`);return await t()}var As=null;function Uc(e){return As||(As=new ci(4,{precompile:e})),As}var Zr=class{constructor(t,n,i,r,o,s){d(this,"chartImpl");d(this,"glManager");d(this,"zoomController",null);d(this,"gridlines");d(this,"chrome");d(this,"cssWidth");d(this,"cssHeight");d(this,"dpr");d(this,"Vi",null);d(this,"Co",null);d(this,"Cn",null);d(this,"Lr",0);d(this,"Tr",!1);d(this,"client");d(this,"view");d(this,"table");d(this,"controlPort");d(this,"wr",0);d(this,"_n",null);d(this,"Mr",0);d(this,"Rr",0);if(this.client=n,this.view=i,this.table=r,this.controlPort=o,this.chartImpl=new s,t.tileSource&&je.register(t.tileSource),t.renderMode==="blit"&&!t.glCanvas&&!0)this.glManager=new fn(Uc(t.precompileShaders??!1).acquire());else{let m=t.glCanvas??new OffscreenCanvas(Math.max(1,Math.round(t.cssWidth*t.dpr)),Math.max(1,Math.round(t.cssHeight*t.dpr)));this.glManager=new fn(m,{precompile:t.precompileShaders??!1})}let a=Math.max(1,Math.round(t.cssWidth*t.dpr)),u=Math.max(1,Math.round(t.cssHeight*t.dpr));this.gridlines=t.gridlinesCanvas??new OffscreenCanvas(a,u),this.chrome=t.chromeCanvas??new OffscreenCanvas(a,u),t.renderMode==="blit"&&(this.glManager.setFrameCallback(m=>{this.Lr+=1;let f=this._o(m);this.post({kind:"frameBitmap",bitmap:f},[f])}),this.chartImpl.setOverlayPresenter?.(()=>this.Wo())),this.cssWidth=t.cssWidth,this.cssHeight=t.cssHeight,this.dpr=t.dpr,this.chartImpl.setGridlineCanvas?.(this.gridlines),this.chartImpl.setChromeCanvas?.(this.chrome),this.chartImpl.setTheme?.(t.themeVars),t.defaultChartType&&this.chartImpl.setDefaultChartType?.(t.defaultChartType),this.chartImpl.setFacetConfig?.(t.facetConfig),this.chartImpl.setPluginConfig?.(t.pluginConfig),t.columnsConfig&&this.chartImpl.setColumnsConfig?.(t.columnsConfig),this.chartImpl.setZoomController&&(this.zoomController=new It,this.chartImpl.setZoomController(this.zoomController)),this.chartImpl.setView?.(i),this.glManager.v.maxCapacity=t.bufferMaxCapacity,this.glManager.resize(t.cssWidth,t.cssHeight,t.dpr),this.chartImpl.attachTooltip?.(new pi(m=>this.post(m)))}setViewByName(t){this.view=this.client.__unsafe_open_view(t),this.chartImpl.setView?.(this.view)}setPluginConfig(t,n){n&&je.register(n),this.chartImpl.setPluginConfig?.(t)}async loadAndRender(t){let n=++this.wr,i;try{let[r,o,s,l]=await Promise.all([this.view.num_rows(),this.view.schema(),this.view.expression_schema(),this.table?.schema()??Promise.resolve({})]);if(this.wr!==n)return;this.chartImpl.setViewPivots?.(t.viewerConfig.group_by,t.viewerConfig.split_by),this.chartImpl.setColumnTypes?.(o),this.chartImpl.setGroupByTypes?.({...l,...s}),this.chartImpl.setColumnSlots?.(t.viewerConfig.columns);let a=Object.keys(o).length||1,u=Math.floor(this.glManager.v.maxCapacity/a),m=Math.min(r,u);this.glManager.ensureBufferCapacity(m);try{await yu(this.view,async(f,c)=>{if(this.wr!==n)throw new jr;await this.chartImpl.uploadAndRender(this.glManager,f,0,Math.min(m,c))},{end_row:m,float32:t.options.float32})}catch(f){if(!(f instanceof jr))throw f}}catch(r){(r+"").indexOf("View not found")===-1&&(console.error("loadAndRender failed",r),i=String(r))}finally{this.post({kind:"loadAndRenderAck",msgId:t.msgId,error:i})}}redraw(){this.chartImpl.requestRender(this.glManager)}redrawAck(t){this.chartImpl.requestRender(this.glManager).catch(()=>{}).finally(()=>this.post({kind:"resizeAck",msgId:t}))}resize(t,n,i){this.cssWidth=t,this.cssHeight=n,this.dpr=i,this.glManager.requestResize(t,n,i),this.chartImpl.requestRender(this.glManager)}clear(){al(this.glManager,()=>{this.glManager.clear(),this.gridlines.getContext("2d")?.clearRect(0,0,this.gridlines.width,this.gridlines.height)})}saveZoom(){return this.zoomController?.serialize()}restoreZoom(t){t&&this.zoomController?.restore(t)}allZoomsDefault(){if(this.zoomController&&!this.zoomController.isDefault())return!1;let t=this.chartImpl?.Mn;if(t){for(let n of t)if(n&&!n.isDefault())return!1}return!0}resetAllZooms(){this.zoomController?.reset();let t=this.chartImpl?.Mn;if(t)for(let n of t)n?.reset();this.resetExpandedDomain()}resetExpandedDomain(){this.chartImpl.resetExpandedDomain?.()}vo(t,n){let i=this.chartImpl,r=i?.d;if(r){for(let l=0;l<r.cells.length;l++){let a=r.cells[l],u=a.layout.e;if(t>=u.x&&t<=u.x+u.width&&n>=u.y&&n<=u.y+u.height){let m=i.getZoomControllerForFacet?.(l)??this.zoomController;return m?{controller:m,layout:a.layout}:null}}return null}if(!this.zoomController)return null;let o=i?.l;if(!o)return null;let s=o.e;return t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height?null:{controller:this.zoomController,layout:o}}ko(t){let n=this.chartImpl,i=n?.R,r=n?.i;return!i||!r?!1:i.handleEvent(t,{cfg:r,cssWidth:this.cssWidth,cssHeight:this.cssHeight,legendRects:n.xn??[],repaint:o=>{!o&&typeof n.repaintChrome=="function"?n.repaintChrome():this.chartImpl.requestRender(this.glManager)},postDelta:o=>this.post({kind:"pluginConfigDelta",fields:o}),setCursor:o=>n.bi?.setCursor?.(o),dispatchLeave:()=>this.L()?.dispatchLeave()})}onInteraction(t){try{this.No(t)}catch(n){this._n=null,this.chartImpl?.R?.cancelGesture?.(),console.error("interaction dispatch failed",n)}}No(t){if(!(!(this._n!==null&&(t.type==="pointermove"||t.type==="pointerup"))&&this.ko(t)))switch(t.type){case"wheel":{let i=this.vo(t.mx,t.my);if(!i)return;Bs(i,t.mx,t.my,t.deltaY),this.chartImpl.requestRender(this.glManager),this.post({kind:"zoomChanged",isDefault:this.allZoomsDefault()});break}case"pointerdown":{let i=this.vo(t.mx,t.my);if(!i)return;this._n=i,this.Mr=t.mx,this.Rr=t.my;break}case"pointermove":{if(this._n){let i=t.mx-this.Mr,r=t.my-this.Rr;this.Mr=t.mx,this.Rr=t.my,Es(this._n,i,r),this.chartImpl.requestRender(this.glManager),this.post({kind:"zoomChanged",isDefault:this.allZoomsDefault()})}else this.L()?.dispatchHover(t.mx,t.my);break}case"pointerup":{this._n=null;break}case"pointerleave":{this.L()?.dispatchLeave();break}case"click":{this.L()?.dispatchClick(t.mx,t.my);break}case"dblclick":{this.L()?.dispatchDblClick(t.mx,t.my);break}}}L(){return this.chartImpl?.L??null}_o(t){let n=t.width,i=t.height;this.Vi||(this.Vi=new OffscreenCanvas(n,i),this.Co=this.Vi.getContext("2d"));let r=this.Vi,o=this.Co;return o?(r.width!==n||r.height!==i?(r.width=n,r.height=i):o.clearRect(0,0,n,i),this.gridlines.width===n&&this.gridlines.height===i&&o.drawImage(this.gridlines,0,0),o.drawImage(t,0,0),this.Cn!==t&&(this.Cn?.close(),this.Cn=t),this.chrome.width===n&&this.chrome.height===i&&o.drawImage(this.chrome,0,0),r.transferToImageBitmap()):t}Wo(){if(this.Tr)return;this.Tr=!0;let t=this.Lr;queueMicrotask(()=>{this.Tr=!1;let n=this.Cn;if(this.Lr!==t||!n)return;let i=Math.max(1,Math.round(this.cssWidth*this.dpr)),r=Math.max(1,Math.round(this.cssHeight*this.dpr));if(n.width!==i||n.height!==r)return;let o=this._o(n);o!==n&&this.post({kind:"frameBitmap",bitmap:o},[o])})}async snapshotPng(){this.glManager.beginFrame(),this.chartImpl.renderFrameSync(this.glManager);let t=this.glManager.gl,n=t.canvas,i=n.width,r=n.height,o=new Uint8ClampedArray(i*r*4);t.readPixels(0,0,i,r,t.RGBA,t.UNSIGNED_BYTE,o);let s=new OffscreenCanvas(i,r),l=s.getContext("2d");if(!l)throw new Error("snapshotPng: 2D context unavailable");let u=this.chartImpl.T?.()?.backgroundColor??"transparent";u!=="transparent"&&(l.fillStyle=u,l.fillRect(0,0,i,r)),l.drawImage(this.gridlines,0,0);let m=new OffscreenCanvas(i,r),f=m.getContext("2d");if(!f)throw new Error("snapshotPng: 2D context unavailable for GL blit");return f.putImageData(new ImageData(o,i,r),0,0),l.save(),l.scale(1,-1),l.drawImage(m,0,-r),l.restore(),l.drawImage(this.chrome,0,0),await s.convertToBlob({type:"image/png"})}destroy(){ul(this.glManager),this.Cn?.close(),this.Cn=null,this.chartImpl.destroy(),this.glManager.destroy()}post(t,n){n&&n.length>0?this.controlPort.postMessage(t,n):this.controlPort.postMessage(t)}},Hc=typeof globalThis.importScripts=="function";async function Vc(e,t){if(!e.clientWorkerURL||!e.clientWasm||!e.proxyPort)throw new Error("Init error");let n=await import(e.clientWorkerURL.toString());await n.initSync({module:e.clientWasm}),e.fontFaces?.length&&await Promise.all(e.fontFaces.map(_u));let i=e.proxyPort,r=new n.Client(async u=>{let m=u.slice().buffer;i.postMessage(m,[m])},async()=>i.close());i.addEventListener("message",u=>{r.handle_response(new Uint8Array(u.data))}),i.start();let o=r.__unsafe_open_view(e.viewName),s=e.tableName?await r.open_table(e.tableName):null,l=await Lu(e.chartTag),a=new Zr(e,r,o,s,t,l);return a.post({kind:"ready"}),a}async function i0(e){let t=e.client.__unsafe_open_view(e.msg.viewName),n=e.msg.tableName?await e.client.open_table(e.msg.tableName):null,i=await Lu(e.msg.chartTag),r=new Zr(e.msg,e.client,t,n,e.controlPort,i);return e.controlPort.addEventListener("message",o=>{let s=o.data;s?.kind!=="init"&&on(r,s)}),e.controlPort.start(),r.post({kind:"ready"}),r}Hc&&vu(Vc);export{Zr as WorkerRenderer,i0 as bootstrapInProcess};\n',Ke=null;async function pl(){if(Ke)return Ke;let e=new Blob([hl],{type:"application/javascript"});return Ke=URL.createObjectURL(e),Ke}var hr=pl,Rt=null,Lt=new Map,fl=0;async function ml(){return Rt||(Rt=(async()=>{let e=await hr(),t=new Worker(e,{type:"module",name:"viewer-charts"});return t.addEventListener("message",i=>{let r=i.data;Lt.get(r.sessionId)?.(r.msg)}),t})(),Rt)}var gl=class{_handle=null;_destroyed=!1;_proxyChannel=null;_proxySession=null;_client;_view;_tableName;_panel;_clientWorkerURL;_clientWasm;_chartTag;_maxCells;_precompileShaders;_ready;_resolveReady;_rejectReady;_pending=new Map;_pendingCounter=0;_onZoomChanged=null;_onPluginConfigDelta=null;_allZoomsDefault=!0;_hostGlCanvas=null;_displayCtx=null;_lastPostedSize=null;_holdPresent=!1;_stagedFrame=null;_hostSink=null;_lastInsertConfig=void 0;constructor(e){this._client=e.client,this._view=e.view,this._tableName=e.tableName,this._panel=e.panel,this._clientWorkerURL=e.clientWorkerURL,this._clientWasm=e.clientWasm,this._chartTag=e.chartTag,this._maxCells=e.maxCells,this._precompileShaders=e.precompileShaders??!1,this._onZoomChanged=e.onZoomChanged??null,this._onPluginConfigDelta=e.onPluginConfigDelta??null,this._ready=new Promise((t,i)=>{this._resolveReady=t,this._rejectReady=i})}async init(e){this._hostGlCanvas=e.gl;let t=await hr();re==="worker"&&(this._proxyChannel=new MessageChannel,this._proxySession=this._client.new_proxy_session(p=>{let f=p.slice().buffer;this._proxyChannel.port1.postMessage(f,[f])}),this._proxyChannel.port1.addEventListener("message",p=>{this._proxySession.handle_request(new Uint8Array(p.data))}),this._proxyChannel.port1.start());let i,r,n;e.renderBlitMode==="blit"?this._displayCtx=e.gl.getContext("2d"):(i=e.gl.transferControlToOffscreen(),r=e.gridlines.transferControlToOffscreen(),n=e.chrome.transferControlToOffscreen());let s=e.gl.getBoundingClientRect(),o=window.devicePixelRatio||1,l=kt(e.gl),a=re==="worker"?ll():[],u=re==="worker"?this._clientWasm:void 0,c=re==="worker"?this._clientWorkerURL:void 0,d=re==="worker"?this._proxyChannel.port2:void 0,h={kind:"init",renderMode:e.renderBlitMode,glCanvas:i,gridlinesCanvas:r,chromeCanvas:n,proxyPort:d,clientWorkerURL:c,clientWasm:u,chartTag:this._chartTag,viewName:this._view.__unsafe_get_name(),tableName:this._tableName,facetConfig:e.facetConfig,pluginConfig:e.pluginConfig,columnsConfig:e.columnsConfig,defaultChartType:e.defaultChartType,tileSource:ge.specFor(e.pluginConfig.map_tile_provider),themeVars:l,fontFaces:a,cssWidth:s.width,cssHeight:s.height,dpr:o,bufferMaxCapacity:0,precompileShaders:this._precompileShaders};if(this._lastPostedSize={cssWidth:s.width,cssHeight:s.height,dpr:o},this._handle=await this._createHandle(t,h),this._handle.addMessageListener(p=>this._handleRendererMsg(p)),re==="worker"){let p=[this._proxyChannel.port2];n&&p.unshift(n),r&&p.unshift(r),i&&p.unshift(i),this._handle.post(h,p)}await this._ready}async _createHandle(e,t){if(re==="worker"){let n=await ml(),s=++fl;return{post:(o,l)=>n.postMessage({sessionId:s,msg:o},l),addMessageListener:o=>{Lt.set(s,o)},terminate:()=>{Lt.delete(s)}}}let i=await import(e),r=new MessageChannel;return await i.bootstrapInProcess({msg:t,client:this._client,controlPort:r.port2}),{post:(n,s)=>r.port1.postMessage(n,s),addMessageListener:n=>{r.port1.addEventListener("message",s=>n(s.data)),r.port1.start()},terminate:()=>{r.port1.close(),r.port2.close()}}}setView(e){this._view=e,this._post({kind:"setViewByName",name:this._view.__unsafe_get_name()})}setColumnsConfig(e){this._post({kind:"setColumnsConfig",cfg:e})}setPluginConfig(e){this._post({kind:"setPluginConfig",cfg:e,tileSource:ge.specFor(e.map_tile_provider)})}setBufferMaxCapacity(e){this._post({kind:"setBufferMaxCapacity",n:e})}loadAndRender(e){let{id:t,promise:i}=this._allocPending("loadAndRender"),r={kind:"loadAndRender",msgId:t,viewerConfig:e.viewerConfig,options:{float32:e.options?.float32??!0}};return this._post(r),i}redraw(){this._post({kind:"redraw"})}deselect(){this._post({kind:"deselect"})}resize(){if(!this._hostGlCanvas)return Promise.resolve();let e=this._hostGlCanvas.getBoundingClientRect(),t=window.devicePixelRatio||1,i=this._lastPostedSize;return i&&Math.abs(i.cssWidth-e.width)<=.5&&Math.abs(i.cssHeight-e.height)<=.5&&i.dpr===t?Promise.resolve():this._postResize(e.width,e.height)}presize(e,t){if(!this._hostGlCanvas)return Promise.resolve();let i=window.devicePixelRatio||1,r=this._lastPostedSize;return r&&Math.abs(r.cssWidth-e)<=.5&&Math.abs(r.cssHeight-t)<=.5&&r.dpr===i?Promise.resolve():(this._holdPresent=!0,this._postResize(e,t).then(()=>()=>this._presentStaged(),n=>{throw this._presentStaged(),n}))}_postResize(e,t){let i=window.devicePixelRatio||1,{id:r,promise:n}=this._allocPending("resize");return this._lastPostedSize={cssWidth:e,cssHeight:t,dpr:i},this._post({kind:"resize",msgId:r,cssWidth:e,cssHeight:t,dpr:i}),n}_presentStaged(){this._holdPresent=!1;let e=this._stagedFrame;this._stagedFrame=null,e&&this._drawFrameBitmap(e)}clear(){this._post({kind:"clear"})}invalidateTheme(){if(!this._hostGlCanvas)return;let e=kt(this._hostGlCanvas);this._post({kind:"invalidateTheme",themeVars:e})}async saveZoom(){let{id:e}=this._allocPending("saveZoom");this._post({kind:"saveZoom",requestId:e})}_allocPending(e){if(this._destroyed){if(e==="loadAndRender")return{id:-1,promise:Promise.resolve(void 0)};let r=Promise.reject(new Error("RendererTransport destroyed"));return r.catch(()=>{}),{id:-1,promise:r}}let t=++this._pendingCounter,i=new Promise((r,n)=>{this._pending.set(t,{kind:e,resolve:r,reject:n})});return{id:t,promise:i}}restoreZoom(e){this._post({kind:"restoreZoom",state:e})}allZoomsDefault(){return this._allZoomsDefault}resetAllZooms(){this._post({kind:"resetAllZooms"})}resetExpandedDomain(){this._post({kind:"resetExpandedDomain"})}snapshotPng(){let{id:e,promise:t}=this._allocPending("snapshotPng");return this._post({kind:"snapshotPng",requestId:e}),t}forwardInteraction(e){this._post({kind:"interaction",event:e})}destroy(){this._destroyed=!0,this._post({kind:"destroy"}),this._proxySession&&this._proxySession.close().catch(()=>{}),this._proxyChannel&&(this._proxyChannel.port1.close(),this._proxyChannel=null),this._handle&&(this._handle.terminate(),this._handle=null),this._hostSink?.dismiss(),this._hostSink=null,this._hostGlCanvas=null,this._displayCtx=null,this._holdPresent=!1,this._stagedFrame?.close(),this._stagedFrame=null;let e=new Error("RendererTransport destroyed");for(let t of this._pending.values())t.kind==="loadAndRender"?t.resolve(void 0):t.reject(e);this._pending.clear()}_post(e){this._postRaw(e,[])}_postRaw(e,t){this._handle&&this._handle.post(e,t)}_handleRendererMsg(e){switch(e.kind){case"ready":this._resolveReady();break;case"zoomChanged":this._allZoomsDefault=e.isDefault,this._onZoomChanged?.(e.isDefault);break;case"saveZoomReply":this._resolvePending(e.requestId,"saveZoom",e.state);break;case"pinTooltip":this._ensureHostSink()?.pin(e.lines,e.pos,e.bounds);break;case"dismissTooltip":this._hostSink?.dismiss();break;case"setCursor":this._ensureHostSink()?.setCursor(e.cursor);break;case"pluginConfigDelta":this._onPluginConfigDelta?.(e.fields);break;case"userClick":this._dispatchOnViewer(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{...e.detail,panel:this._panel}}));break;case"userSelect":{let t=this._lastInsertConfig?[this._lastInsertConfig]:[],i=e.selected?[e.insertConfig]:[];this._lastInsertConfig=e.selected?e.insertConfig:void 0;let r=new Q(e.selected,e.row,e.column_names,t,i);r.panel=this._panel,this._dispatchOnViewer(new CustomEvent("perspective-global-filter",{bubbles:!0,composed:!0,detail:r}));break}case"frameBitmap":this._holdPresent?(this._stagedFrame?.close(),this._stagedFrame=e.bitmap):this._drawFrameBitmap(e.bitmap);break;case"error":this._rejectReady(new Error(e.message));break;case"loadAndRenderAck":e.error!==void 0?this._rejectPending(e.msgId,"loadAndRender",new Error(e.error)):this._resolvePending(e.msgId,"loadAndRender",void 0);break;case"resizeAck":this._resolvePending(e.msgId,"resize",void 0);break;case"snapshotPngReply":e.error!==void 0?this._rejectPending(e.requestId,"snapshotPng",new Error(e.error)):this._resolvePending(e.requestId,"snapshotPng",e.blob);break}}_resolvePending(e,t,i){let r=this._pending.get(e);!r||r.kind!==t||(this._pending.delete(e),r.resolve(i))}_rejectPending(e,t,i){let r=this._pending.get(e);!r||r.kind!==t||(this._pending.delete(e),r.reject(i))}_drawFrameBitmap(e){if(this._displayCtx&&this._hostGlCanvas){let t=e.width,i=e.height;this._hostGlCanvas.width!==t&&(this._hostGlCanvas.width=t),this._hostGlCanvas.height!==i&&(this._hostGlCanvas.height=i),this._displayCtx.globalCompositeOperation="copy",this._displayCtx.drawImage(e,0,0)}e.close()}_dispatchOnViewer(e){if(!this._hostGlCanvas)return;let t=this._hostGlCanvas;for(;t;){if(t instanceof HTMLElement&&t.tagName==="PERSPECTIVE-VIEWER"){t.dispatchEvent(e);return}t=t.host??t.parentNode??null}}_ensureHostSink(){if(this._hostSink)return this._hostSink;let e=this._hostGlCanvas?.parentElement;return!e||!this._hostGlCanvas?null:(this._hostSink=new ul(this._hostGlCanvas,e),this._hostSink)}};function _l(e){return isFinite(e)?e<0?0:e>1?1:e:.5}function ar(e){return!isFinite(e)||e<0?1:e}function bl(e){let t=(s,o)=>e[s]||o,i=e["--psp-charts--gradient--background"]||e["--psp-charts--full-gradient--background"]||"linear-gradient(#0366d6 0%, #ff7f0e 100%)",r=jo(i),n=[];for(let s=1;;s++){let o=e[`--psp-charts--series-${s}--color`];if(!o)break;n.push(dr(o))}return{fontFamily:t("--psp-charts--font-family",t("font-family","monospace")),backgroundColor:t("--psp--background-color","rgba(255, 255, 255, 1)"),tickColor:t("--psp-charts--axis-ticks--color","rgba(160, 0, 0, 0.8)"),labelColor:t("--psp--color","rgba(180, 0, 0, 0.9)"),axisLineColor:t("--psp-charts--axis-lines--color","rgba(160, 0, 0, 0.4)"),gridlineColor:t("--psp-charts--gridline--color","rgba(255, 0, 0, 1)"),gradientStops:r,legendText:t("--psp-charts--legend--color","rgba(180, 180, 180, 0.9)"),legendBorder:t("--psp-charts--legend-border--color","rgba(128,128,128,0.3)"),tooltipBg:t("--psp-charts--tooltip--background","rgba(155,155,155,0.8)"),tooltipText:t("--psp-charts--tooltip--color","#161616"),tooltipBorder:t("--psp-charts--tooltip--border-color","#fff"),areaOpacity:_l(parseFloat(t("--psp-charts--area--opacity","0.85"))),heatmapGapPx:ar(parseFloat(t("--psp-charts--heatmap-gap--px","0"))),sunburstGapPx:ar(parseFloat(t("--psp-charts--sunburst-gap--px","1"))),seriesPalette:n}}function yl(e,t){if(t<=0)return[];let i=new Array(t);for(let r=0;r<t;r++){let n=t===1?.5:r/(t-1),s=Zo(e,n);i[r]=[s[0],s[1],s[2]]}return i}function cr(e,t,i){if(e.length>0){if(e.length>=i)return e.slice(0,i);let r=new Array(i);for(let n=0;n<i;n++)r[n]=e[n%e.length];return r}return yl(t,i)}var vl={...rl};function It(e){return ge.register(e)}var xl={auto_alt_y_axis:{kind:"Bool"},include_zero:{kind:"Bool"},domain_mode:{kind:"Enum",variants:[{value:"fit",label:"Fit"},{value:"expand",label:"Expand"}]},facet_mode:{kind:"Enum",variants:[{value:"grid",label:"Grid"},{value:"overlay",label:"Overlay"}]},facet_zoom_mode:{kind:"Enum",variants:[{value:"shared",label:"Shared"},{value:"independent",label:"Independent"}]},series_zoom_mode:{kind:"Enum",variants:[{value:"dynamic",label:"Dynamic"},{value:"fixed",label:"Fixed"}]},line_width_px:{kind:"Number",min:.5,step:.5,max:16},point_size_px:{kind:"Number",min:1,max:32},band_inner_frac:{kind:"Number",min:.1,max:1,step:.01},bar_inner_pad:{kind:"Number",min:0,max:.9,step:.01},wick_width_px:{kind:"Number",min:.5,step:.5,max:8},ohlc_line_width_px:{kind:"Number",min:.5,step:.5,max:8},gradient_radius_px:{kind:"Number",min:2,step:1,max:256},gradient_intensity:{kind:"Number",min:.05,step:.05,max:4},gradient_heat_max:{kind:"Number",min:.1,step:.1,max:64},gradient_color_mode:{kind:"Enum",variants:[{value:"mean",label:"Mean (density-weighted)"},{value:"density",label:"Density only"},{value:"extreme",label:"Extremes"},{value:"signed",label:"Signed sum"}]},map_tile_provider:()=>({kind:"Enum",variants:ge.list().map(e=>({value:e.id,label:e.label}))}),map_tile_alpha:{kind:"Number",min:0,max:1,step:.05},numeric_axes:{kind:"Bool"},legend_mode:{kind:"Enum",variants:[{value:"sidebar",label:"Sidebar"},{value:"none",label:"None"},{value:"floating",label:"Floating"}]},legend_width_px:{kind:"Number",min:0,max:512,step:1},legend_height_px:{kind:"Number",min:48,max:1024,step:1},legend_anchor:{kind:"Enum",variants:[{value:"top-right",label:"Top Right"},{value:"top-left",label:"Top Left"},{value:"bottom-right",label:"Bottom Right"},{value:"bottom-left",label:"Bottom Left"}]},legend_x:{kind:"Number",min:0,max:1,step:.01},legend_y:{kind:"Number",min:0,max:1,step:.01},legend_opacity:{kind:"Number",min:0,max:1,step:.05}};function wl(e,t){let i=xl[e];return{...typeof i=="function"?i():i,key:e,default:t[e]}}var El=(()=>{let e=new CSSStyleSheet;return e.replaceSync(Qo),[e]})(),ur=dl,Cl=class pr extends HTMLElement{_initialized=!1;_glCanvas;_gridlineCanvas;_chromeCanvas;_renderer=null;_rendererPromise=null;_rawEventForwarder=null;_resetClickAbort=null;_pluginConfigStore=null;_columnsConfig={};get _pluginConfig(){return this._pluginConfigStore||(this._pluginConfigStore=this._effectiveDefaults()),this._pluginConfigStore}set _pluginConfig(t){this._pluginConfigStore=t}_effectiveDefaults(){return{...nl,...this._chartType.plugin_field_defaults??{}}}connectedCallback(){if(!this._initialized){this.attachShadow({mode:"open"});for(let t of El)this.shadowRoot.adoptedStyleSheets.push(t);this.shadowRoot.innerHTML='<div class="webgl-container"><div class="zoom-controls"><button class="zoom-reset">Reset Zoom</button></div></div>',this._initialized=!0}this._glCanvas?.isConnected||this._buildCanvasStack()}_buildCanvasStack(){let t=this.shadowRoot.querySelector(".webgl-container");t.insertAdjacentHTML("afterbegin",'<canvas class="webgl-gridlines"></canvas><canvas class="webgl-canvas"></canvas><canvas class="webgl-chrome"></canvas>'),this._glCanvas=t.querySelector(".webgl-canvas"),this._gridlineCanvas=t.querySelector(".webgl-gridlines"),this._chromeCanvas=t.querySelector(".webgl-chrome")}_clearCanvasStack(){let t=this.shadowRoot?.querySelector(".webgl-container");if(t)for(let i of Array.from(t.querySelectorAll("canvas")))i.remove();this._glCanvas=null,this._gridlineCanvas=null,this._chromeCanvas=null}disconnectedCallback(){this.delete(),this._clearCanvasStack()}_ensureRenderer(t){if(this._initialized||this.connectedCallback(),this._rendererPromise)return this._rendererPromise;let i=this._buildRenderer(t).then(r=>{if(this._rendererPromise!==i)throw r.destroy(),new Error("renderer disposed during init");return this._renderer=r,this._setupInteraction(r),r});return i.catch(()=>{}),this._rendererPromise=i,i}_setupInteraction(t){if(this._rawEventForwarder)return;let i=this.shadowRoot.querySelector(".zoom-controls");this._rawEventForwarder=new sl,this._rawEventForwarder.attach(this._glCanvas,n=>{t.forwardInteraction(n)});let r=this.shadowRoot.querySelector(".zoom-reset");r&&(this._resetClickAbort=new AbortController,r.addEventListener("click",()=>{t.resetAllZooms(),i&&i.classList.remove("visible")},{signal:this._resetClickAbort.signal}))}async _buildRenderer(t){let i=this.parentElement,r=this.getAttribute("slot")??void 0,n=await i.getClient({panel:r}),s=customElements.get("perspective-viewer"),o=s.get_wasm_module(),l=s.get_worker_url(),a=await i?.getTable?.({panel:r}),u=a?await a.get_name():void 0,c=this.shadowRoot.querySelector(".zoom-controls"),d=new gl({client:n,view:t,tableName:u,panel:r,clientWorkerURL:l,clientWasm:o,chartTag:this._chartType.tag,maxCells:this._chartType.max_cells,precompileShaders:!0,onZoomChanged:h=>{c&&c.classList.toggle("visible",!h)},onPluginConfigDelta:h=>{this._pluginConfig={...this._pluginConfig,...h},this.parentElement?.restore({plugin_config:h},r?{panel:r}:void 0)?.catch(p=>{console.error("legend config persistence failed",p)})}});return await d.init({gl:this._glCanvas,gridlines:this._gridlineCanvas,chrome:this._chromeCanvas,facetConfig:{...vl,facet_mode:this._pluginConfig.facet_mode,zoom_mode:this._pluginConfig.facet_zoom_mode},pluginConfig:this._pluginConfig,columnsConfig:this._columnsConfig,defaultChartType:this._chartType.default_chart_type,renderBlitMode:ur}),d}static setBlitMode(t){ur=t}static registerTileSource(t){return It(t)}static tileSources(){return ge.list()}get_static_config(){return{name:this._chartType.name,category:this._chartType.category,select_mode:this._chartType.selectMode,min_config_columns:this._chartType.initial.count,config_column_names:this._chartType.initial.names,max_cells:this._chartType.max_cells,max_columns:this._chartType.max_columns,group_rollup_modes:["flat"],split_rollup_modes:["flat"],group_by_role:this._chartType.group_by_role,split_by_role:this._chartType.split_by_role,connects_row_order:!!this._chartType.connects_row_order,priority:0,can_render_column_styles:!!this._chartType.default_chart_type||this._chartType.category==="Cartesian Charts"||this._chartType.category==="Hierarchical Charts"||this._chartType.category==="Map Charts"}}column_config_schema(t,i,r,n,s){let o=[];i==="Color"&&((this._chartType.category==="Hierarchical Charts"?t==="integer"||t==="float"||t==="date"||t==="datetime":t!=="string")?o.push({kind:"GradientStops",key:"gradient",default:this._themeGradientStopsSpec()}):o.push({kind:"Palette",key:"palette",default:this._themeSeriesPaletteHex()}));let l=this._chartType.default_chart_type;if(l&&(t==="integer"||t==="float")){let a=l==="bar"||l==="line"||l==="scatter"||l==="area";if(a)if((s?.split_by?.length??0)>0)o.push({kind:"Palette",key:"palette",default:this._themeSeriesPaletteHex()});else{let d=(s?.columns??[]).filter(h=>!!h).indexOf(r);o.push({kind:"Color",key:"color",default:this._themeSeriesColorHex(Math.max(0,d))})}o.push({kind:"Enum",key:"chart_type",default:l,variants:[{value:"bar",label:"Bar"},{value:"line",label:"Line"},{value:"scatter",label:"Scatter"},{value:"area",label:"Area"}]});let u=n?.chart_type??l,c=u==="bar"||u==="area";if(c&&o.push({kind:"Bool",key:"stack",default:c}),a&&o.push({kind:"Bool",key:"alt_axis",default:!1}),u==="line"||u==="area"){let d=u==="area"?[{value:"skip",label:"Skip"},{value:"solid",label:"Solid"}]:[{value:"skip",label:"Skip"},{value:"solid",label:"Solid"},{value:"transparent",label:"Transparent"}];o.push({kind:"Enum",key:"interpolate",default:"solid",variants:d})}}return t==="integer"||t==="float"?o.push({kind:"NumberFormat"}):(t==="date"||t==="datetime")&&o.push({kind:"DatetimeFormat"}),{fields:o}}plugin_config_schema(t){let i=this._effectiveDefaults();return{fields:this._chartType.applicable_plugin_fields.map(r=>wl(r,i))}}_resolvedTheme(){return bl(kt(this))}static GRADIENT_PALETTE_FALLBACK_COUNT=6;_themeSeriesPaletteHex(){let t=this._resolvedTheme(),i=t.seriesPalette.length||pr.GRADIENT_PALETTE_FALLBACK_COUNT;return Ko(cr(t.seriesPalette,t.gradientStops,i))}_themeSeriesColorHex(t){let i=this._resolvedTheme(),r=Math.max(i.seriesPalette.length,t+1);return Dt(cr(i.seriesPalette,i.gradientStops,r)[t])}_themeGradientStopsSpec(){return qo(this._resolvedTheme().gradientStops)}async draw(t){return this._renderer?.resetExpandedDomain(),this._renderer?.resetAllZooms(),this._drawImpl(t)}async update(t){return this._drawImpl(t)}async _drawImpl(t){let i;try{i=await this._ensureRenderer(t)}catch{return}i.setView(t),i.setBufferMaxCapacity(this._chartType.max_cells);let r=this.getAttribute("slot")??void 0,n=this.parentElement;if(n===null)return;let s=await n.getViewConfig({panel:r});await i.loadAndRender({viewerConfig:{group_by:s?.group_by??[],split_by:s?.split_by??[],columns:s?.columns??[]},options:{float32:!0}})}async clear(){this._renderer?.clear()}async resize(){!this.isConnected||this.offsetParent==null||await this._renderer?.resize()}async presize(t,i){if(!this.isConnected||this.offsetParent==null||!this._renderer||!this._glCanvas)return;let r=this.getBoundingClientRect(),n=this._glCanvas.getBoundingClientRect();return await this._renderer.presize(Math.max(0,n.width+(t-r.width)),Math.max(0,n.height+(i-r.height)))}restyle(){this._renderer?.invalidateTheme()}async deselect(){this._renderer?.deselect()}async render(t){return await this._ensureRenderer(t),await this.draw(t),this._renderer.snapshotPng()}restore(t,i){t?.zoom&&this._renderer?.restoreZoom(t.zoom),this._pluginConfig={...this._effectiveDefaults(),...t},this._columnsConfig=i??{},this._renderer?.setPluginConfig(this._pluginConfig),this._renderer?.setColumnsConfig(this._columnsConfig)}delete(){this._rawEventForwarder&&(this._rawEventForwarder.detach(),this._rawEventForwarder=null),this._resetClickAbort&&(this._resetClickAbort.abort(),this._resetClickAbort=null),this._renderer&&(this._renderer.destroy(),this._renderer=null),this._rendererPromise=null}};function Sl(...e){let t=new Set(e.length>0?e:or.map(r=>r.name)),i=[];or.forEach(r=>{if(t.has(r.name)){let n=`perspective-viewer-charts-${r.tag}`;if(customElements.get(n)){i.push(n);return}customElements.define(n,class extends Cl{_chartType=r;static _chartType=r}),customElements.whenDefined("perspective-viewer").then(async()=>{await customElements.get("perspective-viewer").registerPlugin(n)})}}),i.length>0&&console.warn(`viewer-charts plugins already registered (${i.length}); skipping duplicate registration (Perspective was loaded more than once on this page).`)}Sl();function M(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function L(e){let t=document.createElement("template");return t.innerHTML=e.trim(),t.content.firstElementChild}function w(e,t){let i=e.querySelector(t);if(!i)throw new Error(`No element matches "${t}"`);return i}function N(e){return(Array.isArray(e)?e.map(i=>[i,i]):Object.entries(e)).map(([i,r])=>`<option value="${M(i)}">${M(r)}</option>`).join("")}function z(e){return String(e instanceof Error?e.message:e)}function Ze(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):void 0}catch{return}}function Qe(e,t){let i=w(e,"form"),r=w(e,".modal__status"),n=w(e,"[type=submit]");return document.body.appendChild(e),w(e,"[data-role=cancel]").addEventListener("click",()=>e.close()),i.addEventListener("submit",async s=>{if(s.preventDefault(),!!i.reportValidity()){n.disabled=!0,t.busy?.(!0),r.textContent=t.pending;try{await t.submit(r),r.textContent="",e.close()}catch(o){r.textContent=z(o)}finally{n.disabled=!1,t.busy?.(!1)}}}),t.trigger.addEventListener("click",()=>{r.textContent="",e.showModal()}),{status:r,submit:n}}var Al="/perspective-docs.json",Ft="perspective-agent-config",Le={Anthropic:{name:"anthropic",url:"https://api.anthropic.com/v1/chat/completions",headers:{"anthropic-dangerous-direct-browser-access":"true"},model:"claude-opus-5"},OpenAI:{name:"openai",url:"https://api.openai.com/v1/chat/completions",model:"gpt-5.2"},Gemini:{name:"gemini",url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",model:"gemini-2.5-flash"},OpenRouter:{name:"openrouter",url:"https://openrouter.ai/api/v1/chat/completions"},"LM Studio (local)":{name:"lmstudio",url:"http://localhost:1234/v1/chat/completions",note:"Enable CORS in LM Studio's settings."},"Ollama (local)":{name:"ollama",url:"http://localhost:11434/v1/chat/completions",note:"Set OLLAMA_ORIGINS for CORS."},"Custom (OpenAI-compatible)":{name:"custom",url:""}},Bt={"Full (default)":void 0,"Read-only":["read_view","read_docs"]},Tl=`<dialog class="modal">
<form method="dialog">
<h2>Configure Agent</h2>
<label class="field">
<span class="field__label">Provider</span>
<select name="provider">${N(Object.keys(Le))}</select>
</label>
<label class="field">
<span class="field__label">Model</span>
<input name="model" type="text" placeholder="provider default" />
</label>
<label class="field">
<span class="field__label">API key</span>
<input name="apiKey" type="password" placeholder="sk-\u2026" />
</label>
<label class="field">
<span class="field__label">Base URL</span>
<input name="baseUrl" type="url" required />
</label>
<label class="field">
<span class="field__label">Access</span>
<select name="access">${N(Object.keys(Bt))}</select>
<small class="field__hint">What the agent is allowed to do.</small>
</label>
<label class="field">
<span class="field__label">
Load documentation bundle (312 KB)
</span>
<input name="docs" type="checkbox" checked />
</label>
<p class="modal__note" data-role="note"></p>
<p class="modal__note">
Your key and settings are saved in this browser's localStorage on
this device (\u201CDisable\u201D erases them), and the key is sent from the
browser directly to the provider you choose.
</p>
<div class="modal__status" aria-live="polite"></div>
<div class="modal__actions">
<button type="button" class="btn" data-role="disable" hidden>
Disable
</button>
<button type="button" class="btn" data-role="cancel">
Cancel
</button>
<button type="submit" class="btn btn--primary">Enable</button>
</div>
</form>
</dialog>`;function Ml(e,t){return t.startsWith("http://")&&location.protocol==="https:"?`This page is served over HTTPS, so the browser blocks requests to ${t} as mixed content. Local providers work when the docs site is run over http://localhost.`:e.headers?`${e.note??""} This provider requires a special browser-access header, which is sent for you.`.trim():e.note??""}function fr(e,t){let i=L(Tl),r=w(i,"[name=provider]"),n=w(i,"[name=model]"),s=w(i,"[name=apiKey]"),o=w(i,"[name=baseUrl]"),l=w(i,"[name=access]"),a=w(i,"[name=docs]"),u=w(i,"[data-role=note]"),c=w(i,"[data-role=disable]"),{status:d,submit:h}=Qe(i,{trigger:t,pending:"Configuring\u2026",async submit(){await g(),localStorage.setItem(Ft,JSON.stringify({provider:r.value,model:n.value,apiKey:s.value,baseUrl:o.value,access:l.value,docs:a.checked}))}});function p(){u.textContent=Ml(Le[r.value],o.value)}function f(){let b=Le[r.value];o.value=b.url,n.value=b.model??"",p()}function _(b){t.textContent=b?`Agent: ${r.value}`:"Configure Agent"}async function g(){let b=Le[r.value],y;a.checked&&(d.textContent="Loading documentation bundle\u2026",y=await(await fetch(Al)).json()),e.agentConfig({name:b.name,url:o.value.trim(),headers:b.headers,apiKey:s.value||void 0,model:n.value.trim()||void 0,entitlements:Bt[l.value],docs:y}),c.hidden=!1,h.textContent="Update",_(!0)}function m(b){b.provider in Le&&(r.value=b.provider,f()),o.value=b.baseUrl??o.value,n.value=b.model??n.value,s.value=b.apiKey??"",b.access in Bt&&(l.value=b.access),a.checked=b.docs!==!1,p(),_(!0),(async()=>{try{await customElements.whenDefined("perspective-viewer"),await g(),d.textContent=""}catch(y){_(!1),console.warn("Stored agent config was not re-applied:",y)}})()}r.addEventListener("change",f),o.addEventListener("input",p),c.addEventListener("click",async()=>{await e.agentReset?.(),localStorage.removeItem(Ft),c.hidden=!0,h.textContent="Enable",_(!1),i.close()}),e.addEventListener("perspective-agent-tool",b=>{console.log("[agent tool]",b.detail)}),f();let v=Ze(Ft);v&&m(v)}function be(e){let t=e,i=new Set;return{get:()=>t,set(r){t=r;for(let n of i)n(r)},subscribe(r){return i.add(r),r(t),()=>{i.delete(r)}}}}var Je={"perspective-server":"perspective-server","duckdb-wasm":"DuckDB-WASM"},Ot={"perspective-server":{id:"perspective-server",label:Je["perspective-server"],status:"idle"},"duckdb-wasm":{id:"duckdb-wasm",label:Je["duckdb-wasm"],status:"idle"}};function mr(){return Object.values(Ot).map(e=>({...e}))}var gr=be(mr());function _r(e){return gr.subscribe(e)}function Nt(e,t,i){Ot[e].status=t,Ot[e].error=i,gr.set(mr())}function br(e,t){let i;return()=>(i??=(async()=>{Nt(e,"starting");try{let r=await t();return Nt(e,"ready"),r}catch(r){throw Nt(e,"failed",String(r)),i=void 0,r}})(),i)}var zt;function yr(e){zt=e}var Ht=(async()=>{let e=await import("./perspective-SCAINCJ6.js"),t=await import("./perspective-viewer-HIOGVWKY.js"),i=import("./perspective-viewer-KMMWY3SK.js");return await Promise.all([e.init_server({wasm64:()=>import("./perspective-server.memory64-VAR4TCPV.js").then(r=>r.default),wasm32:()=>import("./perspective-server-IL45GI6G.js").then(r=>r.default)}),t.init_client(i.then(r=>r.default))]),e})();async function vr(){return(await Ht).worker()}var ye=br("perspective-server",async()=>{let t=await(await Ht).worker();return await zt.load(t),{qualify:i=>i,client:()=>t,async drop(i){await(await t.open_table(i)).delete()}}}),ve=br("duckdb-wasm",async()=>{let e=await Ht,t=await import("./duckdb-browser-DLM4QKRI.js"),i=await t.selectBundle(t.getJsDelivrBundles()),r=URL.createObjectURL(new Blob([`importScripts("${i.mainWorker}");`],{type:"text/javascript"})),n=new Worker(r),s=new t.AsyncDuckDB(new t.VoidLogger,n);await s.instantiate(i.mainModule,i.pthreadWorker),URL.revokeObjectURL(r);let o=await s.connect();await o.query("SET default_null_order=NULLS_FIRST_ON_ASC_LAST_ON_DESC;");let{DuckDBHandler:l}=await import("./duckdb-7NPAJDPS.js"),a=new l(o),u=await e.worker(e.createMessageHandler(a));return await zt.load(u),{db:s,conn:o,qualify:c=>`memory.${c}`,client:()=>u,async drop(c){await o.query(`DROP TABLE IF EXISTS "${c}"`),await o.query(`DROP VIEW IF EXISTS "${c}"`)}}});function et(e){return e==="duckdb-wasm"?ve():ye()}var ne=be([]),Rl=0;function se(){return`source_${Rl++}`}function X(){return ne.get()}function oe(e){ne.set([...ne.get(),e])}function xr(e){let t=ne.get().filter(i=>i.id!==e);t.length<ne.get().length&&ne.set(t)}function tt(e){return ne.subscribe(e)}var Er="perspective-theme",Cr="(prefers-color-scheme: dark)",kl={light:"Pro Light",dark:"Pro Dark"},Pe=be(it()??Ll());function it(){let e=localStorage.getItem(Er);return e==="light"||e==="dark"?e:void 0}function Ll(){return matchMedia(Cr).matches?"dark":"light"}function Sr(e,t){t&&(document.documentElement.dataset.theme=e)}var wr=0;async function Pl(e,t){let i=++wr,r=kl[t],n=await e.getThemes();i!==wr||!n.includes(r)||(await e.resetThemes([r,...n.filter(s=>s!==r)]),e.getPanelNames().length>0&&await e.restore({theme:r}).catch(()=>{}))}function rt(){return Pe.get()}function De(e){return Pe.subscribe(e)}async function Ar(e){Sr(Pe.get(),it()!==void 0),matchMedia(Cr).addEventListener("change",t=>{it()===void 0&&Yt(t.matches?"dark":"light",!1)}),await customElements.whenDefined("perspective-viewer"),De(t=>void Pl(e,t))}function Yt(e,t=!0){e!==Pe.get()&&(t&&localStorage.setItem(Er,e),Sr(e,t||it()!==void 0),Pe.set(e))}function nt(e,t){e.addEventListener("pointerdown",i=>{e.setPointerCapture(i.pointerId);let r=s=>t.apply(t.toPx(s)),n=s=>{e.releasePointerCapture(s.pointerId),e.removeEventListener("pointermove",r),e.removeEventListener("pointerup",n)};e.addEventListener("pointermove",r),e.addEventListener("pointerup",n)}),e.addEventListener("keydown",i=>{let r=i.key===t.growKey?16:i.key===t.shrinkKey?-16:0;r&&(i.preventDefault(),t.apply(t.current()+r))})}var Wt="perspective-sidebar-width",Tr="perspective-sidebar-collapsed",Mr=180,Ut=350,Dl=24,Il=`<aside class="sidebar">
<button type="button" class="sidebar__gutter" aria-label="Expand sidebar">
<span class="sidebar__gutter-label">Sources</span>
</button>
<div class="sidebar__brand">
<a class="sidebar__logo" href="/">
<img alt="Perspective" src="/svg/perspective-logo-dark.svg" />
</a>
<div class="sidebar__brand-right">
<ul class="sidebar__links">
<li><a href="/guide/index.html">Docs</a></li>
<li>
<a href="https://github.com/perspective-dev/perspective">
GitHub
</a>
</li>
</ul>
<button type="button" class="sidebar__theme"></button>
<button
type="button"
class="sidebar__collapse"
aria-label="Collapse sidebar"
></button>
</div>
</div>
<button
type="button"
id="create_source"
class="sidebar__action sidebar__action--browse"
>Import Data</button>
<button
type="button"
id="browse_projects"
class="sidebar__action sidebar__action--browse"
>Browse Projects</button>
<div class="sidebar__tree"></div>
<div class="sidebar__footer">
<button
type="button"
id="configure_agent"
class="sidebar__action"
>Configure Agent</button>
</div>
</aside>`,Fl=`<div
class="sidebar__splitter"
role="separator"
aria-orientation="vertical"
tabindex="0"
></div>`;function Bl(e,t){switch(e.status){case"ready":return"ready";case"failed":return"failed";case"starting":return"starting\u2026";default:return"not started"}}function Nl(e,t,i){return`<li class="source${i?" source--active":""}"
data-source="${M(e.id)}">
<span class="source__label" title="${M(e.table)}"
>${M(e.label)}</span>
<span class="source__count" title="${t} panel(s)"
>${t||""}</span>
<button
type="button"
class="source__delete"
aria-label="Delete ${M(e.label)}"
>\xD7</button>
</li>`}function Ol(e,t,i){let r=`<div class="engine__status engine__status--${e.status}"
${e.error?`title="${M(e.error)}"`:""}
>${M(Bl(e,t.length))}</div>`,n=t.length?`<ul class="engine__sources">${t.join("")}</ul>`:'<div class="engine__empty">No sources loaded</div>',s=i?`<button
type="button"
class="engine__sql"
aria-label="Toggle the DuckDB SQL panel"
>SQL</button>`:"";return`<section class="engine">
<div class="engine__name">
<span>${M(e.label)}</span>
${s}
${r}
</div>
${n}
</section>`}function zl(e,t,i){let r=0;function n(o){}function s(o){let l=Math.max(Mr,e.clientWidth*.5),a=Math.min(Math.max(o,Mr),l);return e.style.setProperty("--sidebar-width",`${a}px`),localStorage.setItem(Wt,String(a)),a}return nt(i,{toPx:o=>o.clientX-e.getBoundingClientRect().left,current:()=>{let o=parseInt(getComputedStyle(e).getPropertyValue("--sidebar-width"),10);return Number.isNaN(o)?Ut:o},growKey:"ArrowRight",shrinkKey:"ArrowLeft",apply:o=>(s(o),void 0)}),s(Number(localStorage.getItem(Wt)??Ut)),n}function Hl(e){let t=w(e,".sidebar__theme"),i=w(e,".sidebar__logo img");De(r=>{let n=r==="dark",s=`Switch to the ${n?"light":"dark"} theme`;t.title=s,t.setAttribute("aria-label",s),i.src=`/svg/perspective-logo-${n?"dark":"light"}.svg`}),t.addEventListener("click",()=>Yt(rt()==="dark"?"light":"dark"))}function Yl(e,t,i){function r(n){e.dataset.sidebar=n?"collapsed":"expanded",localStorage.setItem(Tr,String(n)),i(n?Dl:Number(localStorage.getItem(Wt)??Ut))}w(t,".sidebar__collapse").addEventListener("click",()=>r(!0)),w(t,".sidebar__gutter").addEventListener("click",()=>r(!1)),r(localStorage.getItem(Tr)==="true")}function Rr(e,t,i={}){let r=L(Il),n=L(Fl),s=w(r,".sidebar__tree"),o=w(r,"#browse_projects");e.prepend(r,n);let l=new Map,a=null,u=[],c=X();function d(m){return[...l.entries()].filter(([,v])=>v===m.table).map(([v])=>v)}function h(){s.innerHTML=u.map(m=>Ol(m,c.filter(v=>v.engine===m.id).map(v=>{let b=d(v);return Nl(v,b.length,b.includes(a??""))}),m.id==="duckdb-wasm"&&!!i.openSql)).join("")}async function p(m){try{return(await t.save({panel:m}))?.table??void 0}catch{return}}async function f(m){let v=new Map;await Promise.all(m.map(async b=>{let y=await p(b);y&&v.set(b,y)})),l=v,h()}async function _(m){let v=t.getPanelNames();return(await Promise.all(v.map(async y=>await p(y)===m.table?y:void 0))).filter(y=>!!y)}async function g(m){let v=c.find(y=>y.id===m);if(!v)return;let b=await _(v);if(b.length>0){let y=b.length===1?"panel":"panels";if(!confirm(`Delete "${v.label}"? This closes ${b.length} ${y}.`))return}for(let y of b)await t.removePanel(y);try{await(await et(v.engine)).drop(v.table.replace(/^memory\./,""))}catch(y){console.error(`Could not drop ${v.table}`,y);return}xr(v.id)}return s.addEventListener("click",m=>{let v=m.target;if(v.closest(".engine__sql")){i.openSql?.();return}let b=v.closest(".source__delete")?.closest(".source")?.dataset.source;b&&g(b)}),t.addEventListener("perspective-layout-update",m=>{f(m.detail?.panels??[])}),t.addEventListener("perspective-active-panel-update",m=>{a=m.detail?.panel??null,h()}),_r(m=>{u=m,h()}),tt(m=>{c=m,o.disabled=m.length===0,o.title=o.disabled?"The project gallery is already showing":"",h()}),Hl(r),Yl(e,r,zl(e,t,n)),{createSource:w(r,"#create_source"),browseProjects:o,configureAgent:w(r,"#configure_agent")}}var kr=`
// Scene constants
var resolution := 100;
var fov := 30 * (pi / 180);
var camera[3] := {0, 0, -600};
var light[3] := {0.5, 1, 0};
// Torus constants
var radius := 1;
var tube := 0.4;
var radialSegments := 12;
var tubularSegments := 16;
var rotation := 40 * (pi / 180);
// Mesh
var arc := pi * 2;
var vs[663];
for (var j := 0; j <= radialSegments; j += 1) {
for (var i := 0; i <= tubularSegments; i += 1) {
// Vertex
var u := (i / tubularSegments) * arc;
var v := (j / radialSegments) * pi * 2;
var i0 := j * 3 * (tubularSegments + 1) + (i * 3);
vs[i0] := (radius + tube * cos(v)) * cos(u) * 100;
vs[i0 + 1] := (radius + tube * cos(v)) * sin(u) * 100;
vs[i0 + 2] := tube * sin(v) * 100;
// Rotate
var b := vs[i0 + 1];
var bcos := cos(rotation);
var bsin := sin(rotation);
vs[i0 + 1] := vs[i0 + 1] * bcos - vs[i0 + 2] * bsin;
vs[i0 + 2] := b * bsin + vs[i0 + 2] * bcos;
b := vs[i0];
vs[i0] := vs[i0] * bcos - vs[i0 + 2] * bsin;
vs[i0 + 2] := b * bsin + vs[i0 + 2] * bcos;
}
};
// Render scene
var scale := resolution / (tan(fov / 2) * 400);
var x := (floor(index() / resolution) - resolution / 2) / scale;
var y := (index() % resolution - resolution / 2) / scale;
var d[3] := {x, y, 200};
var color := 0;
var depth := inf;
var light_norm := norm3(light);
for (var j := 1; j <= radialSegments; j += 1) {
for (var i := 1; i <= tubularSegments; i += 1) {
// Index
var aa := (tubularSegments + 1) * j + i - 1;
var b := (tubularSegments + 1) * (j - 1) + i - 1;
var c := (tubularSegments + 1) * (j - 1) + i;
var dd := (tubularSegments + 1) * j + i;
var face[6] := {aa, b, dd, b, c, dd};
for (var ii:= 0; ii < 2; ii += 1) {
var i0 := face[ii * 3];
var i1 := face[ii * 3 + 1];
var i2 := face[ii * 3 + 2];
var v0[3] := {vs[i0 * 3], vs[i0 * 3 + 1], vs[i0 * 3 + 2]};
var v1[3] := {vs[i1 * 3], vs[i1 * 3 + 1], vs[i1 * 3 + 2]};
var v2[3] := {vs[i2 * 3], vs[i2 * 3 + 1], vs[i2 * 3 + 2]};
// Render triangle
var e1[3] := v1 - v0;
var e2[3] := v2 - v0;
var h[3];
cross_product3(d, e2, h);
var a := dot_product3(e1, h);
if (a != 0) {
var f := 1 / a;
var s[3] := camera - v0;
var u := f * dot_product3(s, h);
if (u > 0 and u < 1) {
var q[3];
cross_product3(s, e1, q);
var v := f * dot_product3(d, q);
if (v > 0 and u + v < 1) {
var t := f * dot_product3(e2, q);
if (t >= 0) {
var t2 := 1 - u - v;
var d1[3] := v0 * t2 + v1 * u + v2 * v;
var dist := norm3(d1 - camera);
if (dist < depth) {
depth := dist;
// Lighting
var n[3];
cross_product3(v0 - v1, v2 - v1, n);
color := acos(dot_product3(light, n) / (light_norm * norm3(n)))
}
}
}
}
}
}
}
};
color;
`,Lr=`// color
var resolution := 200;
var xmin := -0.4;
var xmax := -0.3;
var ymin := 0.6;
var ymax := 0.7;
var iterations := 100;
var x := floor("index" / resolution);
var y := "index" % resolution;
var c := iterations;
var cx := xmin + ((xmax - xmin) * x) / (resolution - 1);
var cy := ymin + ((ymax - ymin) * y) / (resolution - 1);
var vx := 0;
var vy := 0;
var vxx := 0;
var vyy := 0;
var vxy := 0;
for (var ii := 0; ii < iterations; ii += 1) {
if (vxx + vyy <= float(4)) {
vxy := vx * vy;
vxx := vx * vx;
vyy := vy * vy;
vx := vxx - vyy + cx;
vy := vxy + vxy + cy;
c -= 1;
}
};
c`;async function Pr(e,t,i){for(let r=0;r<e;r+=t)await i(r,Math.min(r+t,e)),await new Promise(n=>setTimeout(n,0))}var Dr=e=>e[Math.floor(Math.random()*e.length)],Ir=(e,t)=>Math.random()*(t-e)+e,Wl=()=>Math.random().toString(36).substring(7),Ul=["float","integer","string","datetime","boolean"];function $l(e){let t={};for(let i of Ul)for(let r=0;r<(e[`num_${i}`]??0);r++)t[`${i[0].toUpperCase()}${i.slice(1)} ${r}`]=i;return t}var O={dataset:{label:"Random dataset",description:"Random data with a configurable column mix \u2014 the shape used to benchmark the engine.",params:[{key:"num_rows",label:"Rows",min:25,max:1e6},{key:"num_float",label:"Float columns",min:0,max:50},{key:"num_integer",label:"Integer columns",min:0,max:50},{key:"num_string",label:"String columns",min:0,max:50},{key:"num_strings",label:"Unique strings",min:1,max:500,hint:"Dictionary size each string column draws from."},{key:"num_datetime",label:"Datetime columns",min:0,max:50},{key:"num_boolean",label:"Boolean columns",min:0,max:50}],defaults:{num_rows:1e5,num_float:5,num_integer:5,num_string:5,num_strings:50,num_datetime:5,num_boolean:1},async build(e,t,i){let r=$l(i);if(Object.keys(r).length===0)throw new Error("Choose at least one column.");let n=new Array(Math.max(1,i.num_strings)).fill(null).map(Wl),s=await e.table(r,{name:t}),o={float:()=>Ir(-10,10),integer:()=>Math.floor(Ir(-10,10)),string:()=>Dr(n),datetime:()=>new Date,boolean:()=>Dr([!0,!1,null])};await Pr(i.num_rows,25e3,async(l,a)=>{let u=new Array(a-l);for(let c=0;c<u.length;c++){let d={};for(let[h,p]of Object.entries(r))d[h]=o[p]();u[c]=d}await s.update(u)})},panel:()=>({plugin:"Datagrid"})},fractal:{label:"Mandelbrot",description:"A fractal computed entirely in ExprTK, one static frame.",params:[],defaults:{},async build(e,t){let i=await e.table({index:"integer"},{name:t});await Pr(200**2,5e4,async(r,n)=>{let s=new Array(n-r);for(let o=r;o<n;o++)s[o-r]={index:o};await i.update(s)})},panel:()=>({plugin:"Heatmap",group_by:[`floor("index" / ${200})`],split_by:[`"index" % ${200}`],columns:["color"],expressions:{color:Lr,[`floor("index" / ${200})`]:`floor("index" / ${200})`,[`"index" % ${200}`]:`"index" % ${200}`}})},raycasting:{label:"Raycasting",description:"A raytraced torus, rendered by an ExprTK expression.",params:[],defaults:{},async build(e,t){let i=new Array(100**2).fill(0);await e.table({index:i},{name:t})},panel:()=>({plugin:"Heatmap",group_by:["x"],split_by:["y"],columns:["color"],theme:null,expressions:{color:kr,x:`floor(index() / ${100}) - ${100} / 2`,y:`index() % ${100} - ${100} / 2`}})}};function Br(e){return e.replace(/'/g,"''")}function Nr(e){switch(e){case"csv":return"read_csv_auto";case"json":case"ndjson":return"read_json_auto";default:return"read_parquet"}}function Gl(e,t){return e instanceof TypeError?new Error(`Could not fetch ${t}. The browser reports no detail for this class of failure; the usual cause is a missing CORS header on the remote (this site is static, so there is no proxy to route around it).`):e instanceof Error?e:new Error(String(e))}async function Or(e){let t;try{t=await fetch(e)}catch(i){throw Gl(i,e)}if(!t.ok)throw new Error(`HTTP ${t.status} ${t.statusText}`);return t}async function zr(e){return new Uint8Array(await(await Or(e)).arrayBuffer())}async function Vl(e){return(await Or(e)).text()}async function Fr(e,t){return t==="arrow"?zr(e):Vl(e)}function Hr(e){if(e==="parquet")throw new Error("perspective-server cannot read parquet; choose the DuckDB-WASM engine for this source.")}async function jl(e){let t=await ye();return await new Function("api","return ("+e.code+")(api)")({client:t.client(),name:e.name,worker:vr}),{table:t.qualify(e.name),label:e.name}}async function Xl(e){let t=O[e.generator];if(!t)throw new Error(`Unknown generator "${e.generator}"`);let i={...t.defaults,...e.params??{}},r=await ye();return await t.build(r.client(),e.name,i),{table:r.qualify(e.name),label:e.name,panel:t.panel(i)}}async function $t(e,t,i,r){if(e==="duckdb-wasm"){let a=await ve();if(r==="arrow")for(let[u,c]of t.entries())await a.conn.insertArrowFromIPCStream(await zr(c),{name:i,create:u===0});else{let u=t.map(c=>`'${Br(c)}'`).join(", ");await a.conn.query(`CREATE OR REPLACE TABLE "${i}" AS SELECT * FROM ${Nr(r)}([${u}])`)}return{table:a.qualify(i),label:i}}Hr(r);let n=await ye(),[s,...o]=t,l=await n.client().table(await Fr(s,r),{name:i,format:r});for(let a of o)await l.update(await Fr(a,r));return{table:n.qualify(i),label:i}}async function Yr(e,t,i,r){if(e==="duckdb-wasm"){let o=await ve();if(r==="arrow")await o.conn.insertArrowFromIPCStream(new Uint8Array(await t.arrayBuffer()),{name:i,create:!0});else{let l=await import("./duckdb-browser-DLM4QKRI.js");await o.db.registerFileHandle(t.name,t,l.DuckDBDataProtocol.BROWSER_FILEREADER,!0),await o.conn.query(`CREATE OR REPLACE TABLE "${i}" AS SELECT * FROM ${Nr(r)}('${Br(t.name)}')`)}return{table:o.qualify(i),label:i}}Hr(r);let n=await ye(),s=r==="arrow"?new Uint8Array(await t.arrayBuffer()):await t.text();return await n.client().table(s,{name:i,format:r}),{table:n.qualify(i),label:i}}function Gt(e){return $t(e.engine,[e.url],e.name,e.format)}async function st(e){return e.kind==="eval"?jl(e):e.kind==="generated"?Xl(e):Gt(e)}function H(e){return{layout:{type:"tab-layout",tabs:["p0"],selected:0},panels:{p0:{table:"",...e}},active:"p0"}}function ot(e,t){let i={};for(let[r,n]of Object.entries(t))i[r]={table:"",...n};return{layout:e,panels:i,active:Object.keys(t)[0]}}function Y(...e){return{type:"tab-layout",tabs:e,selected:0}}function ae(e,t,i){return{type:"split-layout",orientation:e,sizes:t,children:i}}function Fe(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function Vt(e,t){return`/projects/${t}/${e}.png`}var lt={kind:"fetch",engine:"perspective-server",url:"/data/superstore.lz4.arrow",format:"arrow",name:"superstore"},ql={kind:"fetch",engine:"perspective-server",url:"/data/movies.arrow",format:"arrow",name:"movies"},Wr=[{id:"superstore",title:"Superstore",description:"Superstore data",source:lt,workspace:{active:"PERSPECTIVE_GENERATED_ID_0",layout:{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0},panels:{PERSPECTIVE_GENERATED_ID_0:{plugin:"Datagrid",title:"Superstore"}}}},{id:"superstore-overview",title:"Superstore (Workspace)",description:"Sales by sub-category, profit over time, and the grouped grid underneath.",source:lt,workspace:{active:"PERSPECTIVE_GENERATED_ID_1",layout:{type:"split-layout",children:[{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0}],sizes:[.5,.5],orientation:"horizontal"},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0}],sizes:[.55,.45],orientation:"vertical"},panels:{PERSPECTIVE_GENERATED_ID_0:{columns_config:{},plugin:"Y Bar",plugin_config:{},table:"superstore",title:"Y Bar",group_by:["Sub-Category"],split_by:["Segment"],sort:[["Sales","desc"]],filter:[],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{},columns:["Sales"],aggregates:{}},PERSPECTIVE_GENERATED_ID_1:{columns_config:{Profit:{number_fg_mode:"label-bar",fg_gradient:17320}},plugin:"Datagrid",plugin_config:{},table:"superstore",title:"Group By 2",group_by:["Region","State"],split_by:["Category","Sub-Category"],sort:[["Profit","asc"]],filter:[],group_rollup_mode:"rollup",split_rollup_mode:"rollup",expressions:{},columns:["Sales","Profit"],aggregates:{}},PERSPECTIVE_GENERATED_ID_2:{columns_config:{},plugin:"Treemap",plugin_config:{},table:"superstore",title:"Y Line - Datetime Axis",group_by:["Region","State"],split_by:[],sort:[["Profit","desc"]],filter:[],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{},columns:["Sales","Profit",null],aggregates:{}}}}}],Ur=[{id:"olympics",title:"Olympics",description:"120 years of Olympic athletes, from Kaggle.",source:{kind:"fetch",engine:"perspective-server",url:"/data/olympics.arrow",format:"arrow",name:"olympics"},workspace:{active:"PERSPECTIVE_GENERATED_ID_0",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0}],sizes:[.5,.5],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_0:{plugin:"Heatmap",table:"olympics",title:"Age Distribution by Sport",group_by:["Age"],split_by:["Sport"],sort:[["Event","col desc"]],columns:["Name"]},PERSPECTIVE_GENERATED_ID_1:{plugin:"X/Y Scatter",table:"olympics",title:"Avg Height vs Weight by Sport",group_by:["Sport"],columns:["Height","Weight",null,"City","Sport",null],aggregates:{Weight:"avg",Sport:"dominant",Height:"avg"}}}}}],$r=[{id:"nypd",title:"NYPD CCRB",description:"Civilian complaints against NYPD officers.",source:{kind:"fetch",engine:"perspective-server",url:"/data/nypdccrb.arrow",format:"arrow",name:"nypd"},workspace:H({title:"NYPD CCRB",plugin:"Datagrid",theme:null})},{id:"nypd-3",title:"NYPD CCRB",description:"Civilian complaints against NYPD officers.",source:{kind:"fetch",engine:"perspective-server",url:"/data/nypdccrb.arrow",format:"arrow",name:"nypd"},workspace:{active:"PERSPECTIVE_GENERATED_ID_4",layout:{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_4"],selected:0},panels:{PERSPECTIVE_GENERATED_ID_4:{plugin:"Heatmap",table:"ccrb",title:"Incidents",group_by:[`bucket("IncidentDate", '3M')`],split_by:["Allegation"],sort:[["IncidentDate","col asc"]],filter:[["IncidentDate",">","1985-01-01"],["IncidentDate","<","2025-01-01"]],expressions:{"bucket(\"IncidentDate\", '3M')":`bucket("IncidentDate", '3M')`},columns:["AllegationID"],aggregates:{IncidentDate:"median",AllegationID:"distinct count"}}}}},{id:"nypd-2",title:"NYPD CCRB",description:"Civilian complaints against NYPD officers.",source:{kind:"fetch",engine:"perspective-server",url:"/data/nypdccrb.arrow",format:"arrow",name:"nypd"},workspace:{active:"PERSPECTIVE_GENERATED_ID_1",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_3"],selected:0}],sizes:[.5,.5],orientation:"vertical"}],sizes:[.25,.75],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_1:{plugin:"Datagrid",table:"ccrb",title:"Filter",group_by:["FADOType","Allegation"],sort:[["ComplaintID","desc"]],columns:["ComplaintID"],aggregates:{ComplaintID:"distinct count"}},PERSPECTIVE_GENERATED_ID_2:{plugin:"Heatmap",table:"ccrb",title:"Year vs Month of Incident",group_by:[`bucket("IncidentDate", 'Y')`],split_by:['month_of_year("IncidentDate")'],filter:[["IncidentDate",">","1985-01-01"],["IncidentDate","<","2025-01-01"]],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{"bucket(\"IncidentDate\", 'Y')":`bucket("IncidentDate", 'Y')`,'month_of_year("IncidentDate")':'month_of_year("IncidentDate")'},columns:["ComplaintID"],aggregates:{ComplaintID:"distinct count"}},PERSPECTIVE_GENERATED_ID_3:{plugin:"Heatmap",table:"ccrb",title:"Month vs Weekday of Incident",group_by:['month_of_year("IncidentDate")'],split_by:['day_of_week("IncidentDate")'],filter:[["IncidentDate",">","1985-01-01"],["IncidentDate","<","2025-01-01"]],expressions:{'month_of_year("IncidentDate")':'month_of_year("IncidentDate")',"bucket(\"IncidentDate\", 'Y')":`bucket("IncidentDate", 'Y')`,'day_of_week("IncidentDate")':'day_of_week("IncidentDate")'},columns:["ComplaintID"],aggregates:{ComplaintID:"distinct count"}}}}},{id:"nypd-4",title:"NYPD CCRB",description:"Civilian complaints against NYPD officers.",source:{kind:"fetch",engine:"perspective-server",url:"/data/nypdccrb.arrow",format:"arrow",name:"nypd"},workspace:{active:"PERSPECTIVE_GENERATED_ID_9",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_9"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_10"],selected:0}],sizes:[.5,.5],orientation:"vertical"},panels:{PERSPECTIVE_GENERATED_ID_10:{plugin:"Y Area",table:"ccrb",title:"Incidents (area)",group_by:[`bucket("IncidentDate", 'M')`],split_by:["FADOType"],sort:[["AllegationID","col asc"]],filter:[["IncidentDate",">","1985-01-01"],["IncidentDate","<","2025-01-01"]],expressions:{"bucket(\"IncidentDate\", 'M')":`bucket("IncidentDate", 'M')`},columns:["AllegationID"],aggregates:{AllegationID:"distinct count"}},PERSPECTIVE_GENERATED_ID_9:{plugin:"Y Line",table:"ccrb",title:"Incidents (line)",group_by:[`bucket("IncidentDate", 'M')`],split_by:["FADOType"],sort:[["AllegationID","col asc"]],filter:[["IncidentDate",">","1985-01-01"],["IncidentDate","<","2025-01-01"]],expressions:{"bucket(\"IncidentDate\", 'M')":`bucket("IncidentDate", 'M')`},columns:["AllegationID"],aggregates:{AllegationID:"distinct count"}}}}}],Gr=[{id:"movies",title:"Movies",description:"Box office and ratings, from the Vega sample data.",source:ql,workspace:{active:"PERSPECTIVE_GENERATED_ID_2",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0},{type:"split-layout",children:[{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_3"],selected:0}],sizes:[.5,.5],orientation:"horizontal"},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0}],sizes:[.5,.5],orientation:"vertical"}],sizes:[.25,.75],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_0:{plugin:"Heatmap",table:"movies",group_by:['bucket("Rotten Tomatoes Rating", 2.5)'],split_by:['bucket("IMDB Rating", 0.25)'],filter:[['bucket("IMDB Rating", 0.25)',"is not null",null]],expressions:{'bucket("Rotten Tomatoes Rating", 2.5)':'bucket("Rotten Tomatoes Rating", 2.5)','bucket("IMDB Rating", 0.25)':'bucket("IMDB Rating", 0.25)'},columns:["US Gross"],aggregates:{'bucket("Rotten Tomatoes Rating", 2.5)':"avg"}},PERSPECTIVE_GENERATED_ID_1:{plugin:"Y Line",table:"movies",title:"Ratings vs Sales",group_by:[`bucket("Release Date", 'Y')`],expressions:{"bucket(\"Release Date\", 'Y')":`bucket("Release Date", 'Y')`},columns:["US Gross","Rotten Tomatoes Rating","Production Budget","Worldwide Gross","US DVD Sales"],aggregates:{"Rotten Tomatoes Rating":"avg"}},PERSPECTIVE_GENERATED_ID_2:{plugin:"Datagrid",plugin_config:{scroll_lock:!0,edit_mode:"SELECT_ROW_TREE"},table:"movies",group_by:["Distributor"],sort:[["US Gross","desc"]],columns:["US Gross"]},PERSPECTIVE_GENERATED_ID_3:{plugin:"Y Area",table:"movies",title:"US Gross by Genre",group_by:[`bucket("Release Date", 'Y')`],split_by:["Major Genre"],expressions:{"bucket(\"Release Date\", 'Y')":`bucket("Release Date", 'Y')`},columns:["US Gross"]}},masters:["PERSPECTIVE_GENERATED_ID_2"]}}],Vr=[{id:"evictions-2",title:"SF Evictions",description:"San Francisco eviction notices, from DataSF.",source:{kind:"fetch",engine:"perspective-server",url:"/data/evictions.arrow",format:"arrow",name:"evictions"},workspace:H({columns_config:{state:{gradient:"linear-gradient(to right, #000000 0%, #590d4f 24%, #dd6367 52.6%, #ffe894 70.1%, #ffffff 100%)"}},plugin:"Map Density",plugin_config:{gradient_radius_px:15,gradient_intensity:1},table:"evictions",group_by:["lat","lon"],filter:[["lon","is not null",null]],expressions:{lat:`var x[2];
indexof("shape", ' .+?( )', x);
var y := substring("shape", x[0], length("shape") - x[1]);
float(y)`,lon:`var x[2];
indexof("shape", ' .+?( )', x);
var y := substring("shape", 7, x[1] - 7);
float(y)`},columns:["lon","lat","state",null],aggregates:{lat:"any",lon:"any"}})},{id:"evictions-3",title:"SF Evictions",description:"San Francisco eviction notices, from DataSF.",source:{kind:"fetch",engine:"perspective-server",url:"/data/evictions.arrow",format:"arrow",name:"evictions"},workspace:H({columns_config:{},plugin:"Map Scatter",table:"evictions",theme:null,title:null,group_by:["lat","lon"],split_by:[],sort:[],filter:[["lon","is not null",null]],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{lat:`var x[2];
indexof("shape", ' .+?( )', x);
var y := substring("shape", x[0], length("shape") - x[1]);
float(y)`,lon:`var x[2];
indexof("shape", ' .+?( )', x);
var y := substring("shape", 7, x[1] - 7);
float(y)`},columns:["lon","lat","neighborhood",null,null,null],aggregates:{neighborhood:"dominant",lat:"any",lon:"any"}})}],jr=[{id:"fractal",title:"Mandelbrot",description:O.fractal.description,source:{kind:"generated",generator:"fractal",name:"raw_data"},workspace:H({title:"Mandelbrot",theme:null,columns_config:{color:{gradient:"linear-gradient(to right, #000000 50%, #4d0034 54.5%, #880f02 73.8%, #ca7f16 82.5%, #72991e 88.7%, #1a6b2a 94%, #175e59 97.5%, #3289c8 100%)"}},...O.fractal.panel(O.fractal.defaults)})},{id:"raycasting",title:"Raycasting",description:O.raycasting.description,source:{kind:"generated",generator:"raycasting",name:"raycasting"},workspace:H({title:"Raycasting",theme:null,columns_config:{color:{gradient:"linear-gradient(to right, #242526 50%, #071841 69.5%, #3289c8 87%, #7ae4ff 100%)"}},...O.raycasting.panel(O.raycasting.defaults)})}];var Xr=`async (api) => {
const MSG_BATCH_TIMEOUT = 50;
const MSG_PER_BATCH = 10;
const MSG_TIME_DELTA = 20 * (100 / MSG_PER_BATCH);
const MARKET_OPEN_PRICE = 20;
const MARKET_MAX_TRADES = 20000;
const TRADE_EXPIRATION = 10;
const SEED = 0x5eed;
const FAST = !!globalThis.__PERSPECTIVE_SCREENSHOT__;
function mulberry32(seed) {
let state = seed;
return () => {
state = (state + 0x6d2b79f5) | 0;
let t = Math.imul(state ^ (state >>> 15), 1 | state);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const random = FAST ? mulberry32(SEED) : Math.random;
const MARKET_OPEN = FAST ? 0 : performance.now();
const SCHEMA = {
id: "integer",
side: "string",
security: "string",
price: "float",
timestamp: "datetime",
status: "string",
};
async function query_columns(table, config) {
const view = await table.view(config);
const columns = await view.to_columns();
await view.delete();
return columns;
}
class OrderBook {
constructor(table, side) {
this._memo = undefined;
this._side = side;
this._table = table;
this._price_view = table.view({
columns: ["price"],
group_by: ["security"],
aggregates: { price: side === "buy" ? "max" : "min" },
filter: [
["side", "==", side],
["status", "==", "open"],
],
});
}
async best_open_price() {
if (this._memo === undefined) {
const view = await this._price_view;
const { price } = await view.to_columns({ leaves_only: true });
this._memo = price.length === 0 ? MARKET_OPEN_PRICE : price[0];
}
return this._memo;
}
async matched_orders(price) {
const sort_dir = this._side === "buy" ? "desc" : "asc";
const op = this._side === "buy" ? ">" : "<";
return await query_columns(this._table, {
columns: ["id"],
filter: [
["side", "==", this._side],
["status", "==", "open"],
["price", op, price],
],
sort: [
["price", sort_dir],
["timestamp", "asc"],
],
});
}
reset() {
this._memo = undefined;
}
}
let stopped = false;
class Market {
constructor(table, model) {
this._seq = 0;
this._table = table;
this._model = model;
this._buy_book = new OrderBook(table, "buy");
this._sell_book = new OrderBook(table, "sell");
}
async poll() {
if (stopped) {
return;
}
if (!FAST && document.hidden && this._seq >= MARKET_MAX_TRADES) {
setTimeout(() => void this.poll(), 1000);
return;
}
try {
// The first wake fills the ENTIRE ring in one uninterrupted
// pass; every later wake runs a single paced step.
await this._run_market_step();
while (this._seq < MARKET_MAX_TRADES && !stopped) {
await this._run_market_step();
}
} catch (e) {
stopped = true;
return;
}
// Runs forever, live; the thumbnail harness stops at the fill
// for byte-reproducible screenshots.
if (!FAST && !stopped) {
setTimeout(() => void this.poll(), MSG_BATCH_TIMEOUT);
}
}
async _run_market_step() {
if (await this._generate_trades()) {
await this._clear_trades();
await this._expire_trades();
}
this._buy_book.reset();
this._sell_book.reset();
}
async _generate_trades() {
const trades = [];
const timestamp = new Date(MARKET_OPEN + this._seq * MSG_TIME_DELTA);
for (let i = 0; i < MSG_PER_BATCH; i++) {
const { side, discount } = this._model();
const book = side === "buy" ? this._sell_book : this._buy_book;
const best_open_price = await book.best_open_price();
trades.push({
security: "Prospective Co",
status: "open",
// Ring allocation: the keyed write REPLACES the row from
// \`MARKET_MAX_TRADES\` trades ago, capping the table at
// exactly that size forever.
id: this._seq++ % MARKET_MAX_TRADES,
price: discount + best_open_price,
side,
timestamp,
});
}
if (trades.length > 0) {
await this._table.update(trades);
return true;
}
}
async _clear_trades() {
const sell_price = await this._sell_book.best_open_price();
const buy_price = await this._buy_book.best_open_price();
const { id: buys } = await this._buy_book.matched_orders(sell_price);
const { id: sells } = await this._sell_book.matched_orders(buy_price);
const num_clear = Math.min(buys.length, sells.length);
const status = Array(num_clear * 2).fill("closed");
const id = buys.slice(0, num_clear).concat(sells.slice(0, num_clear));
if (id.length > 0) {
await this._table.update({ status, id });
}
}
async _expire_trades() {
// By TIMESTAMP, not id \u2014 ids wrap (the ring), the clock doesn't.
const cutoff = new Date(
MARKET_OPEN +
(this._seq - MSG_PER_BATCH * TRADE_EXPIRATION) *
MSG_TIME_DELTA,
);
const expired = await query_columns(this._table, {
columns: ["id"],
filter: [
["status", "==", "open"],
["timestamp", "<", cutoff.toISOString()],
],
});
if (expired.id.length > 0) {
expired.status = Array(expired.id.length).fill("expired");
await this._table.update(expired);
}
}
}
const SKEW_MODEL_OFFSET = 2;
const SKEW_MODEL_STDDEV = 2;
const SKEW_MODEL_SKEW = 0;
function random_skew_normal(bias) {
const u3 = random(),
u2 = random();
const R = Math.sqrt(-2.0 * Math.log(u3));
const O = 2.0 * Math.PI * u2;
const u0 = R * Math.cos(O);
const v = R * Math.sin(O);
if (SKEW_MODEL_SKEW === 0) {
return bias * SKEW_MODEL_OFFSET + SKEW_MODEL_STDDEV * u0;
} else {
const n = -bias * SKEW_MODEL_SKEW;
const s = n / Math.sqrt(1 + Math.pow(SKEW_MODEL_SKEW, 2));
const u1 = s * u0 + Math.sqrt(1 - s * s) * v;
const z = u0 >= 0 ? u1 : -u1;
return bias * SKEW_MODEL_OFFSET + SKEW_MODEL_STDDEV * z;
}
}
function skew_model() {
const parts = random() > 0.5 ? ["buy", -1] : ["sell", 1];
const discount = random_skew_normal(parts[1]);
return { side: parts[0], discount };
}
const market_client = await api.worker();
const market_table = await market_client.table(SCHEMA, { index: "id" });
const market_view = await market_table.view();
const gui_table = await api.client.table(market_view, {
index: "id",
name: api.name,
});
await gui_table.on_delete(() => {
stopped = true;
market_table.delete().catch(() => {});
if (typeof market_client.terminate === "function") {
market_client.terminate();
}
});
const market = new Market(market_table, skew_model);
void market.poll();
await new Promise((resolve) => {
const check = async () => {
try {
if ((await gui_table.size()) > 0) {
resolve(undefined);
return;
}
} catch (e) {
resolve(undefined);
return;
}
setTimeout(() => void check(), 100);
};
void check();
});
}`;var qr=[{plugin:"Heatmap",plugin_config:{},title:"Heatmap",group_by:[`bucket("timestamp", 'm')`],split_by:['bucket("price", 0.5)'],columns:[`if("side"=='buy'){-1}else{1}`],filter:[],sort:[],expressions:{"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,'bucket("price", 0.5)':'bucket("price", 0.5)',"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`},aggregates:{}},{plugin:"Heatmap",plugin_config:{},title:"Heatmap (Closed)",group_by:[`bucket("timestamp", 'm')`],split_by:['bucket("price", 0.25)'],columns:[`if("side"=='buy'){-1}else{1}`],filter:[["status","==","closed"]],sort:[],expressions:{"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,'bucket("price", 0.25)':'bucket("price", 0.25)',"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`},aggregates:{}},{plugin:"Y Scatter",plugin_config:{},title:"Closed Orders ((s) bucket)",group_by:[`bucket("timestamp", 's')`],split_by:[`if("status"!='open'){"status"}else{"side"}`],columns:["price"],filter:[],sort:[],expressions:{"if(\"status\"=='closed'){1}else if(\"status\"=='expired'){2}else{0}":`if("status"=='closed'){1}else if("status"=='expired'){2}else{0}`,'if("status"!=\'open\'){"status"}else{"side"}':`if("status"!='open'){"status"}else{"side"}`,"bucket(\"timestamp\", 's')":`bucket("timestamp", 's')`},aggregates:{price:"avg",timestamp:"dominant"}},{plugin:"X/Y Scatter",plugin_config:{},title:"Closed Orders",group_by:[],split_by:[],columns:["timestamp","price",`if("status"!='open'){"status"}else{"side"}`],filter:[],sort:[],expressions:{'if("status"!=\'open\'){"status"}else{"side"}':`if("status"!='open'){"status"}else{"side"}`,"if(\"status\"=='closed'){1}else if(\"status\"=='expired'){2}else{0}":`if("status"=='closed'){1}else if("status"=='expired'){2}else{0}`},aggregates:{}},{plugin:"Y Line",plugin_config:{zoom:{k:1,x:1,y:-1}},title:"Mid Timeseries",group_by:[`bucket("timestamp", 's')`],split_by:["status","side"],columns:["price"],filter:[["status","==","closed"]],sort:[],expressions:{"bucket(\"timestamp\", 's')":`bucket("timestamp", 's')`},aggregates:{price:"avg"}},{plugin:"Y Bar",plugin_config:{},title:"Depth Timeseries",group_by:[`bucket("timestamp", 'm')`],split_by:["side","status"],columns:[`if("side"=='buy'){1}else{-1}`],filter:[],sort:[],expressions:{"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"if(\"side\"=='buy'){1}else{-1}":`if("side"=='buy'){1}else{-1}`,"if(\"side\"=='sell'){-1}else{integer(null)}":`if("side"=='sell'){-1}else{integer(null)}`},aggregates:{"bucket(\"timestamp\", 'm')":"dominant"}},{columns_config:{"Diff from market open":{number_fg_mode:"bar",fg_gradient:12.9},"if(\"side\"=='buy'){-1}else{1}":{number_fg_mode:"bar",fg_gradient:8,aggregate_depth:1},status:{string_color_mode:"series",color:"#94aa27"},side:{string_color_mode:"series"}},plugin:"Datagrid",plugin_config:{},settings:!0,title:"Blotter",group_by:[],split_by:[],sort:[["timestamp","desc"]],filter:[],expressions:{'bucket("price", 1)':'bucket("price", 1)',"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"Diff from market open":'"price" - 20'},columns:["timestamp","id","Diff from market open","price","status","side"],aggregates:{}},{columns_config:{"if(\"side\"=='buy'){-1}else{1}":{aggregate_depth:1,number_fg_mode:"bar",fg_gradient:8}},plugin:"Datagrid",plugin_config:{},settings:!0,title:"Order Book",group_by:['bucket("price", 0.5)'],split_by:["side"],sort:[['bucket("price", 0.5)',"desc"]],filter:[["status","==","open"]],expressions:{"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`,'bucket("price", 0.5)':'bucket("price", 0.5)'},columns:[`if("side"=='buy'){-1}else{1}`],aggregates:{}},{plugin:"X Bar",plugin_config:{},title:"Order Book (Chart)",group_by:['bucket("price", 0.5)'],split_by:["side"],columns:[`if("side"=='buy'){-1}else{1}`],filter:[["status","==","open"]],sort:[['bucket("price", 0.5)',"desc"]],expressions:{"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`,'bucket("price", 0.5)':'bucket("price", 0.5)'},aggregates:{}},{plugin:"Candlestick",plugin_config:{},title:"Candlestick",group_by:[`bucket("timestamp", 'm')`],split_by:[],columns:["price",null,"price 2","price 3"],filter:[["status","==","closed"]],sort:[],expressions:{"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"price 2":'"price"',"price 3":'"price"'},aggregates:{price:"avg","price 2":"high","price 3":"low"}},{plugin:"Candlestick",plugin_config:{},title:"Candlestick 2",group_by:[`bucket("timestamp", 'm')`],split_by:[],columns:["price",null,null,null],filter:[["status","==","closed"]],sort:[],expressions:{"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"price 2":'"price"',"price 3":'"price"'},aggregates:{price:"avg","price 2":"high","price 3":"low"}},{plugin:"X Bar",plugin_config:{},title:"Order Book (All Status)",group_by:['bucket("price", 0.5)'],split_by:[],columns:[`if("status"=='open' and "side"=='buy'){1}else{float(null)}`,`if("status"=='open' and "side"=='sell'){1}else{float(null)}`,`if("status"=='closed'){1}else{0}`],filter:[],sort:[['bucket("price", 0.5)',"desc"]],expressions:{"if(\"status\"=='open' and \"side\"=='buy'){1}else{float(null)}":`if("status"=='open' and "side"=='buy'){1}else{float(null)}`,"bucket(\"timestamp\", 's')":`bucket("timestamp", 's')`,'bucket("price", 0.5)':'bucket("price", 0.5)','if("status"==\'open\'){"price"}else{float(null)}':`if("status"=='open'){"price"}else{float(null)}`,"if(\"status\"=='closed'){1}else{0}":`if("status"=='closed'){1}else{0}`,"if(\"status\"=='open' and \"side\"=='sell'){1}else{float(null)}":`if("status"=='open' and "side"=='sell'){1}else{float(null)}`},aggregates:{}},{plugin:"Y Scatter",plugin_config:{},title:"Order Book (Scatter All Status)",group_by:['bucket("price", 0.5)'],split_by:[],columns:[`if("status"=='open' and "side"=='buy'){1}else{float(null)}`,`if("status"=='open' and "side"=='sell'){1}else{float(null)}`,`if("status"=='closed'){1}else{0}`],filter:[],sort:[],expressions:{"if(\"status\"=='open' and \"side\"=='buy'){1}else{float(null)}":`if("status"=='open' and "side"=='buy'){1}else{float(null)}`,"bucket(\"timestamp\", 's')":`bucket("timestamp", 's')`,'bucket("price", 0.5)':'bucket("price", 0.5)','if("status"==\'open\'){"price"}else{float(null)}':`if("status"=='open'){"price"}else{float(null)}`,"if(\"status\"=='closed'){1}else{0}":`if("status"=='closed'){1}else{0}`,"if(\"status\"=='open' and \"side\"=='sell'){1}else{float(null)}":`if("status"=='open' and "side"=='sell'){1}else{float(null)}`},aggregates:{}},{plugin:"X Bar",plugin_config:{},title:"Order Book (Stack All Status)",group_by:['bucket("price", 0.5)'],split_by:[`if("status"=='closed'){'closed'}else{"side"}`],columns:["price"],filter:[["status","!=","expired"]],sort:[['bucket("price", 0.5)',"desc"],["status","col asc"]],expressions:{"if(\"status\"=='open' and \"side\"=='buy'){1}else{float(null)}":`if("status"=='open' and "side"=='buy'){1}else{float(null)}`,"bucket(\"timestamp\", 's')":`bucket("timestamp", 's')`,'bucket("price", 0.5)':'bucket("price", 0.5)','if("status"==\'open\'){"price"}else{float(null)}':`if("status"=='open'){"price"}else{float(null)}`,"if(\"status\"=='closed'){1}else{0}":`if("status"=='closed'){1}else{0}`,"if(\"status\"=='open' and \"side\"=='sell'){1}else{float(null)}":`if("status"=='open' and "side"=='sell'){1}else{float(null)}`,"if(\"status\"=='closed'){'closed'}else{\"side\"}":`if("status"=='closed'){'closed'}else{"side"}`},aggregates:{}},{columns_config:{},plugin:"Candlestick",plugin_config:{},table:"market",title:"Candlestick 3 Son Of Candllestick",group_by:[`bucket("timestamp", 'm')`],split_by:[],sort:[],filter:[["status","==","closed"]],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{"price 3":'"price"',"price 2":'"price"',"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`},windows:{"New Column 3":{column:"price",aggregate:"avg",rows:100},"New Column 4":{column:"price",aggregate:"avg",rows:100},"New Column 1":{column:"price",aggregate:"avg",rows:100},"New Column 2":{column:"price",aggregate:"avg",rows:100}},columns:["New Column 1","New Column 2","New Column 3","New Column 4",null],aggregates:{"New Column 3":"high","New Column 2":"last","New Column 4":"low","New Column 1":"first"}}];var Kr=`async (api) => {
const WIDTH = 80;
const HEIGHT = 60;
const FRAME_TIMEOUT = 50;
const SCREENSHOT = !!globalThis.__PERSPECTIVE_SCREENSHOT__;
let stopped = false;
let stream = null;
const canvas = document.createElement("canvas");
canvas.width = WIDTH;
canvas.height = HEIGHT;
const context = canvas.getContext("2d", { willReadFrequently: true });
const video = document.createElement("video");
video.width = WIDTH;
video.height = HEIGHT;
video.muted = true;
video.setAttribute("playsinline", "");
function sample(tdata) {
const data = context.getImageData(0, 0, WIDTH, HEIGHT);
for (let i = 0; i < data.data.byteLength / 4; i++) {
const r = data.data[i * 4];
const g = data.data[i * 4 + 1];
const b = data.data[i * 4 + 2];
tdata.color[i] = 255 - (0.21 * r + 0.72 * g + 0.07 * b);
}
}
async function draw_placeholder() {
await new Promise((resolve) => {
const img = new Image();
img.onload = () => {
context.drawImage(img, 0, 0, WIDTH, HEIGHT);
resolve(undefined);
};
img.onerror = () => {
context.fillStyle = "#808080";
context.fillRect(0, 0, WIDTH, HEIGHT);
resolve(undefined);
};
img.src = "/img/dogs-playing-poker.png";
});
}
const tdata = { index: [], color: [] };
for (let i = 0; i < WIDTH * HEIGHT; i++) {
tdata.index[i] = i;
tdata.color[i] = 0;
}
const table = await api.client.table(tdata, {
index: "index",
name: api.name,
});
await table.on_delete(() => {
stopped = true;
if (stream) {
for (const track of stream.getTracks()) {
track.stop();
}
}
});
let live = false;
if (
!SCREENSHOT &&
navigator.mediaDevices &&
navigator.mediaDevices.getUserMedia
) {
try {
stream = await navigator.mediaDevices.getUserMedia({
video: true,
});
video.srcObject = stream;
await video.play();
live = true;
} catch (e) {
live = false;
}
}
if (!live) {
await draw_placeholder();
}
async function frame() {
if (stopped) {
return;
}
try {
if (live) {
context.drawImage(video, 0, 0, WIDTH, HEIGHT);
}
sample(tdata);
await table.update(tdata);
} catch (e) {
stopped = true;
return;
}
if (live) {
schedule();
}
}
function schedule() {
setTimeout(
() => {
if (stopped) {
return;
}
if (document.hidden) {
schedule();
return;
}
void frame();
},
document.hidden ? 1000 : FRAME_TIMEOUT,
);
}
await frame();
}`;var Zr=[{plugin:"Datagrid",columns_config:{color:{bg_gradient:251.04,neg_bg_color:"#ffa38f",number_bg_mode:"gradient",number_fg_mode:"disabled",pos_bg_color:"#346ead"}},plugin_config:{editable:!1,scroll_lock:!1},title:"Spreadsheet Cam",group_rollup_mode:"flat",group_by:["y"],split_by:["x"],columns:["color"],filter:[],sort:[],expressions:{"New Column 1":'bucket("color", 5)',y:'floor("index" / 80)',x:'-"index" % 80'},aggregates:{}},{plugin:"Heatmap",title:"Heatmap Cam",group_by:["x"],split_by:["y"],columns:["color"],expressions:{y:'-floor("index" / 80)',x:'-"index" % 80'},aggregates:{"New Column 1":"any"}},{plugin:"Heatmap",plugin_config:{},settings:!0,title:"Downsampled Heatmap Cam",group_by:["x"],split_by:["y"],columns:["color"],filter:[],sort:[],expressions:{y:'bucket(-floor("index" / 80), 3)',x:'bucket(-"index" % 80, 3)'},aggregates:{}},{plugin:"Y Bar",plugin_config:{},title:"Luminosity Histogram",group_by:['bucket("color", 5)'],split_by:[],columns:["color"],filter:[],sort:[],expressions:{'bucket("color", 5)':'bucket("color", 5)',y:'-floor("index" / 80)',x:'-"index" % 80'},aggregates:{}},{plugin:"Datagrid",columns_config:{color:{bg_gradient:2463.68,neg_bg_color:"#ffa38f",number_bg_mode:"gradient",number_fg_mode:"disabled",pos_bg_color:"#307bb0"}},group_rollup_mode:"flat",plugin_config:{editable:!1,scroll_lock:!1},title:"Small Spreadsheet Cam",group_by:["bucket(y, 5)"],split_by:["bucket(x, 5)"],columns:["color"],filter:[["bucket(x, 5)","<",0]],sort:[],expressions:{"bucket(y, 5)":'bucket(floor("index" / 80), 2)',"New Column 1":'bucket("color", 5)',"bucket(x, 5)":'bucket(-"index" % 80, 5)'},aggregates:{}},{plugin:"Y Line",plugin_config:{},title:"Max Headroom",group_by:["x"],split_by:["y"],columns:["New Column 2"],filter:[["x","<",0]],sort:[],expressions:{x:'-"index" % 80',y:'floor("index" / 80)',"New Column 2":'-floor("index" / 80) * 20 - "color"'},aggregates:{"New Column 2":"avg"}},{plugin:"X/Y Scatter",plugin_config:{},title:"Scatter Cam",group_by:["x","y"],split_by:[],columns:["x","New Column 2","color",null,null,null,null],filter:[["x","<",0]],sort:[],expressions:{"New Column 2":'-floor("index" / 80) * 50 - "color"',x:'-"index" % 80',y:'floor("index" / 80)'},aggregates:{x:"avg","New Column 2":"avg"}},{plugin:"Datagrid",plugin_config:{editable:!1,scroll_lock:!1},title:"Raw Stream",group_by:[],split_by:[],columns:["index","color"],filter:[],sort:[],expressions:{},aggregates:{}},{plugin:"Density",plugin_config:{gradient_intensity:1,gradient_radius_px:42},title:"Density Cam",expressions:{y:'-floor("index" / 80)',x:'-"index" % 80'},columns:["x","y","color",null],aggregates:{y:"any",x:"any"}}];var jt=qr,Xt=Zr,xe={kind:"eval",name:"market",code:Xr},at={kind:"eval",name:"webcam",code:Kr};function qt(e,t){let i=e.find(r=>r.title===t);if(!i)throw new Error(`Unknown layout "${t}"`);return i}var Qr=jt.map(e=>({id:`market-${Fe(e.title)}`,title:`Market \u2014 ${e.title}`,description:"Simulated real-time order flow: a stateful matching engine on a private worker, view-mirrored to the UI.",source:xe,workspace:H({theme:null,...e})})),Jr=Xt.map(e=>({id:`webcam-${Fe(e.title)}`,title:`Webcam \u2014 ${e.title}`,description:"Live webcam luminance sampled into a Perspective table at 20fps (falls back to a placeholder image without a camera).",source:at,workspace:H(e)}));var we=(e,t)=>({theme:t,...qt(jt,e)}),Kt=e=>qt(Xt,e),du=ae("horizontal",[.6,.4],[Y("candle"),ae("vertical",[.5,.5],[Y("book"),Y("blotter")])]),en=ae("vertical",[.5,.5],[Y("depth"),ae("horizontal",[.5,.5],[Y("heat"),Y("closed")])]),Ql=ae("horizontal",[.55,.45],[Y("heat"),ae("vertical",[.5,.5],[Y("histo"),Y("scatter")])]),tn="Candlestick, live order book and blotter over one simulated feed.",rn="Depth over time, price-level heatmap and closed orders from the same feed.",nn="One camera, three readings: heatmap, luminosity histogram and scatter.",sn=[{id:"market-trading-desk",title:"Market",description:tn,source:xe,workspace:{active:"PERSPECTIVE_GENERATED_ID_0",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0},{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0}],sizes:[.5,.5],orientation:"vertical"}],sizes:[.5,.5],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_0:{columns_config:{price:{number_fg_mode:"label-bar",fg_gradient:20}},plugin:"Datagrid",table:"market",title:"Blotter",sort:[["timestamp","desc"]],columns:["id","side","security","price","timestamp","status"]},PERSPECTIVE_GENERATED_ID_1:{plugin:"X Bar",table:"market",title:"Order Book (Chart)",group_by:['bucket("price", 0.5)'],split_by:["side"],sort:[['bucket("price", 0.5)',"desc"]],filter:[["status","==","open"]],expressions:{"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`,'bucket("price", 0.5)':'bucket("price", 0.5)'},columns:[`if("side"=='buy'){-1}else{1}`]},PERSPECTIVE_GENERATED_ID_2:{plugin:"Candlestick",table:"market",title:"Candlestick",group_by:[`bucket("timestamp", 'm')`],filter:[["status","==","closed"]],expressions:{"price 3":'"price"',"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"price 2":'"price"'},columns:["price",null,"price 2","price 3"],aggregates:{price:"avg","price 3":"low","price 2":"high"}}}}},{id:"market-trading-desk-2",title:"Market \u2014 Themed",description:tn,source:xe,workspace:{active:"PERSPECTIVE_GENERATED_ID_2",layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0},{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0}],sizes:[.5,.5],orientation:"vertical"}],sizes:[.5,.5],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_0:{columns_config:{price:{number_fg_mode:"label-bar",fg_gradient:20}},plugin:"Datagrid",theme:"Solarized Dark",table:"market",title:"Blotter",sort:[["timestamp","desc"]],columns:["id","side","security","price","timestamp","status"]},PERSPECTIVE_GENERATED_ID_1:{plugin:"X Bar",theme:"Phosphor",table:"market",title:"Order Book (Chart)",group_by:['bucket("price", 0.5)'],split_by:["side"],sort:[['bucket("price", 0.5)',"desc"]],filter:[["status","==","open"]],expressions:{"if(\"side\"=='buy'){-1}else{1}":`if("side"=='buy'){-1}else{1}`,'bucket("price", 0.5)':'bucket("price", 0.5)'},columns:[`if("side"=='buy'){-1}else{1}`]},PERSPECTIVE_GENERATED_ID_2:{plugin:"Candlestick",theme:"Dracula",table:"market",title:"Candlestick",group_by:[`bucket("timestamp", 'm')`],filter:[["status","==","closed"]],expressions:{"price 3":'"price"',"bucket(\"timestamp\", 'm')":`bucket("timestamp", 'm')`,"price 2":'"price"'},columns:["price",null,"price 2","price 3"],aggregates:{price:"avg","price 3":"low","price 2":"high"}}}}},{id:"market-order-flow",title:"Market \u2014 Orders",description:rn,source:xe,workspace:ot(en,{depth:we("Depth Timeseries"),heat:we("Heatmap"),closed:we("Closed Orders")})},{id:"market-order-flow-themed",title:"Market \u2014 Orders Themed",description:rn,source:xe,workspace:ot(en,{depth:we("Depth Timeseries","Vaporwave"),heat:we("Heatmap","Solarized Dark"),closed:we("Closed Orders","Solarized Light")})},{id:"webcam-video-wall",title:"Webcam \u2014 Video Wall",description:nn,source:at,workspace:ot(Ql,{heat:Kt("Heatmap Cam"),histo:Kt("Luminosity Histogram"),scatter:Kt("Scatter Cam")})},{id:"webcam-video-wall-2",title:"Webcam \u2014 Video Wall Themed",description:nn,source:at,workspace:{layout:{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_0"],selected:0},{type:"split-layout",children:[{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_1"],selected:0},{type:"tab-layout",tabs:["PERSPECTIVE_GENERATED_ID_2"],selected:0}],sizes:[.5,.5],orientation:"vertical"}],sizes:[.55,.45],orientation:"horizontal"},panels:{PERSPECTIVE_GENERATED_ID_0:{columns_config:{},plugin:"Heatmap",plugin_config:{},table:"webcam",theme:"Phosphor",title:"Heatmap Cam",group_by:["x"],split_by:["y"],sort:[],filter:[],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{y:'-floor("index" / 80)',x:'-"index" % 80'},columns:["color"],aggregates:{}},PERSPECTIVE_GENERATED_ID_1:{columns_config:{},plugin:"Y Bar",plugin_config:{},table:"webcam",theme:"Dracula",title:"Luminosity Histogram",group_by:['bucket("color", 5)'],split_by:[],sort:[],filter:[],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{'bucket("color", 5)':'bucket("color", 5)',y:'-floor("index" / 80)',x:'-"index" % 80'},columns:["color"],aggregates:{}},PERSPECTIVE_GENERATED_ID_2:{columns_config:{},plugin:"X/Y Scatter",plugin_config:{},table:"webcam",theme:"Vaporwave",title:"Scatter Cam",group_by:["x","y"],split_by:[],sort:[],filter:[["x","<",0]],group_rollup_mode:"flat",split_rollup_mode:"flat",expressions:{y:'floor("index" / 80)',"New Column 2":'-floor("index" / 80) * 50 - "color"',x:'-"index" % 80'},columns:["x","New Column 2","color",null,null,null,null],aggregates:{"New Column 2":"avg",x:"avg"}}},active:"PERSPECTIVE_GENERATED_ID_0"}}];var on=[{name:"Group By 1",description:"Data grid with 1 level of groups for rows",config:{plugin:"Datagrid",title:"Group By 1",group_by:["Sub-Category"]},aggregates:"dominant"},{name:"Group By 2",description:"Data grid with 2 levels of groups for rows",config:{plugin:"Datagrid",title:"Group By 2",group_by:["Category","Sub-Category"]}},{name:"Split By",description:"Data grid with 1 level of categories for columns",config:{plugin:"Datagrid",title:"Split By",split_by:["Category"],columns:["Sales","Quantity","Discount","Profit"]}},{name:"Split By 2",description:"Data grid with 2 levels of categories and columns",config:{plugin:"Datagrid",title:"Split By 2",split_by:["Category","Sub-Category"],columns:["Sales","Quantity","Discount","Profit"]}},{name:"Both",description:"Data grid with grouped rows and categorized columns",config:{plugin:"Datagrid",title:"Both",group_by:["Region"],split_by:["Category"],columns:["Sales","Quantity","Discount","Profit"]}},{name:"Both 2",description:"Data grid with 2 levels of groups and 2 levels of categories",config:{plugin:"Datagrid",title:"Both 2",group_by:["Region","State"],split_by:["Category","Sub-Category"],columns:["Sales","Quantity","Discount","Profit"]}},{name:"Flat Group By 1",description:"Flat data grid with 1 level of groups for rows, no rollup rows",config:{title:"Flat Group By 1",group_by:["Sub-Category"],group_rollup_mode:"flat"}},{name:"Flat Group By 2",description:"Flat data grid with 2 levels of groups for rows, no rollup rows",config:{title:"Flat Group By 2",group_by:["Category","Sub-Category"],group_rollup_mode:"flat"}},{name:"Flat Both",description:"Flat data grid with grouped rows and categorized columns, no rollup rows",config:{title:"Flat Both",group_by:["Region"],split_by:["Category"],columns:["Sales","Quantity","Discount","Profit"],group_rollup_mode:"flat"}},{name:"Flat Both 2",description:"Flat data grid with 2 levels of groups and 2 levels of categories, no rollup rows",config:{title:"Flat Both 2",group_by:["Region","State"],split_by:["Category","Sub-Category"],columns:["Sales","Quantity","Discount","Profit"],group_rollup_mode:"flat"}},{name:"Background Row And Split By",description:"Data grid with groups, categories, and solid color conditional highlighting",config:{title:"Background Row And Split By",group_by:["State"],split_by:["Sub-Category"],columns:["Profit"],sort:[["Profit","col asc"]],columns_config:{Profit:{number_bg_mode:"color"}}}},{name:"Gradient Row And Split By",description:"Data grid with groups, categories, and gradient conditional highlighting",config:{title:"Gradient Row And Split By",group_by:["State"],split_by:["Sub-Category"],columns:["Profit"],sort:[["Profit","col asc"]],columns_config:{Profit:{number_bg_mode:"gradient",bg_gradient:1600}}}},{name:"Background Row And Split By",description:"Data grid with groups, categories, and a bar chart",config:{title:"Background Row And Split By",group_by:["State"],split_by:["Sub-Category"],columns:["Sales"],aggregates:{Sales:"avg"},columns_config:{Sales:{number_fg_mode:"bar",fg_gradient:600}}}},{name:"Foreground Colors",description:"Data grid with 6 categories. 3 categories have conditional formatting using foreground colors.",config:{title:"Foreground Colors",columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],columns_config:{Profit:{pos_fg_color:"#32cd82",neg_fg_color:"#f50fed"},Sales:{pos_fg_color:"#780aff",neg_fg_color:"#f5ac0f"},Discount:{pos_fg_color:"#f5ac0f",neg_fg_color:"#780aff"}},sort:[["Sub-Category","desc"]]}},{name:"Background Colors",description:"Data grid with 6 categories. 3 categories have custom, solid color conditional formatting.",config:{title:"Background Colors",plugin:"Datagrid",columns_config:{Discount:{neg_bg_color:"#780aff",number_bg_mode:"color",number_fg_mode:"disabled",pos_bg_color:"#f5ac0f"},Profit:{neg_bg_color:"#f50fed",number_bg_mode:"color",number_fg_mode:"disabled",pos_bg_color:"#32cd82"},Sales:{neg_bg_color:"#f5ac0f",number_bg_mode:"color",number_fg_mode:"disabled",pos_bg_color:"#780aff"}},plugin_config:{scroll_lock:!0},columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],sort:[["Sub-Category","desc"]]}},{name:"Gradient Colors",description:"Data grid with 6 categories. 3 categories have custom, gradient color conditional formatting.",config:{title:"Gradient Colors",columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],columns_config:{Profit:{number_bg_mode:"gradient",bg_gradient:600,pos_bg_color:"#32cd82",neg_bg_color:"#f50fed"},Sales:{number_bg_mode:"gradient",bg_gradient:2268,pos_bg_color:"#780aff",neg_bg_color:"#f5ac0f"},Discount:{number_bg_mode:"gradient",bg_gradient:.8,pos_bg_color:"#f5ac0f",neg_bg_color:"#780aff"}},sort:[["Sub-Category","desc"]]}},{name:"Bar Colors",description:"Data grid with 6 categories. 3 categories have custom colored bars.",config:{title:"Bar Colors",columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],columns_config:{Profit:{number_fg_mode:"bar",fg_gradient:600,pos_fg_color:"#32cd82",neg_fg_color:"#f50fed"},Sales:{number_fg_mode:"bar",fg_gradient:2268,pos_fg_color:"#780aff",neg_fg_color:"#f5ac0f"},Discount:{number_fg_mode:"bar",fg_gradient:.8,pos_fg_color:"#f5ac0f",neg_fg_color:"#780aff"}},sort:[["Sub-Category","desc"]]}},{name:"Label Bar",description:"Data grid with 6 categories. 3 categories have label bars showing the value overlaid on the bar.",config:{title:"Label Bar",columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],columns_config:{Profit:{number_fg_mode:"label-bar",fg_gradient:600},Sales:{number_fg_mode:"label-bar",fg_gradient:2268},Discount:{number_fg_mode:"label-bar",fg_gradient:.8}},sort:[["Sub-Category","desc"]]}},{name:"Label Bar Colors",description:"Data grid with 6 categories. 3 categories have custom colored label bars.",config:{title:"Label Bar Colors",columns:["Category","Sales","Discount","Profit","Sub-Category","Order Date"],columns_config:{Profit:{number_fg_mode:"label-bar",fg_gradient:600,pos_fg_color:"#32cd82",neg_fg_color:"#f50fed"},Sales:{number_fg_mode:"label-bar",fg_gradient:2268,pos_fg_color:"#780aff",neg_fg_color:"#f5ac0f"},Discount:{number_fg_mode:"label-bar",fg_gradient:.8,pos_fg_color:"#f5ac0f",neg_fg_color:"#780aff"}},sort:[["Sub-Category","desc"]]}},{name:"Thermometer",description:"Data grid with 1 group and 3 columns. 2 columns use bars and 1 column uses gradient conditional highlighting.",config:{title:"Thermometer",group_by:["State"],columns:["Profit (-)","Profit","Profit (+)"],columns_config:{"Profit (-)":{number_fg_mode:"bar",fg_gradient:1e4},Profit:{number_bg_mode:"gradient",bg_gradient:1e4},"Profit (+)":{number_fg_mode:"bar",fg_gradient:1e4}},expressions:{"Profit (-)":'if("Profit"<0){"Profit"}else{0}',"Profit (+)":'if("Profit">0){"Profit"}else{0}'}}},{name:"Y Bar",description:"Bar chart with 17 bars. X is 'Sub-Category', and Y is 'Sales'.",config:{title:"Y Bar",plugin:"Y Bar",group_by:["Sub-Category"],columns:["Sales"]}},{name:"Y Bar, Sorted Desc By Y-Axis",description:"Bar chart with 17 bars sorted descending. X is 'Sub-Category', and Y is 'Sales'.",config:{title:"Y Bar, Sorted Desc By Y-Axis",plugin:"Y Bar",group_by:["Sub-Category"],columns:["Sales"],sort:[["Sales","desc"]]}},{name:"Y Bar - Row And Split By",description:"Stacked bar chart with 17 bars. X is 'Sub-Category', Y is 'Sales', and subgroup is 'Ship Mode'",config:{title:"Y Bar - Row And Split By",plugin:"Y Bar",group_by:["Sub-Category"],split_by:["Ship Mode"],columns:["Sales"]}},{name:"Y Bar - Group By 2 Sorted",description:"Bar chart with 3 categories and 17 total subcategories, sorted descending within each category.",config:{title:"Y Bar - Group By 2 Sorted",plugin:"Y Bar",group_by:["Category","Sub-Category"],columns:["Sales"],sort:[["Sales","desc"]]}},{name:"Y Bar - Group By 2 And Split By Sorted",description:"Bar chart with 3 colored categories and 17 total subcategories, sorted descending within each category.",config:{title:"Y Bar - Group By 2 And Split By Sorted",plugin:"Y Bar",group_by:["Category","Sub-Category"],split_by:["Category"],columns:["Sales"],sort:[["Sales","desc"]]}},{name:"Y Bar - Group By 2 And 2 Split By Sorted",description:"Stacked bar chart with 3 categories and 17 total subcategories, sorted descending within each category. X is 'Category, Sub-Category', y is 'Sales', subgroup is 'Region'",config:{title:"Y Bar - Group By 2 And 2 Split By Sorted",plugin:"Y Bar",group_by:["Category","Sub-Category"],split_by:["Category","Region"],columns:["Sales"],sort:[["Sales","desc"]]}},{name:"Y Bar - Group By 2 And 2 Split By Sorted 2",description:"Bar chart. X is 'State', Y is 'Profit'. Each state has, when applicable, 2 bars: Profit and Loss. States are sorted by Net.",config:{title:"Y Bar - Group By 2 And 2 Split By Sorted 2",plugin:"Y Bar",group_by:["State"],split_by:["Profit (-/+)"],columns:["Profit"],expressions:{"Profit (-/+)":'if("Profit"<0){1}else{0}'},sort:[["Profit","desc"]]},viewport:{width:600,height:450}},{name:"Y Bar Multi Axis",description:"Groupd bar chart. X is 'Sub-Category', Y is 'Quantity' and 'Sales'. Each X value has 2 bars.",config:{title:"Y Bar Multi Axis",plugin:"Y Bar",group_by:["Sub-Category"],columns:["Quantity","Sales"],aggregates:{Sales:"avg"},sort:[["Sales","desc"]]}},{name:"Y Bar Multi Axis - SPlit",description:"Groupd bar chart. X is 'Sub-Category', Y is 'Quantity', and the second Y is 'Sales'. Each X value has 2 bars.",config:{title:"Y Bar Multi Axis - SPlit",plugin:"Y Bar",group_by:["Sub-Category"],columns:["Quantity","Sales"],sort:[["Sales","desc"]],aggregates:{Sales:"avg"},plugin_config:{splitMainValues:["Sales"]}}},{name:"X Bar",description:"Horizontal bar chart with 17 bars. X is 'Sub-Category' and Y is 'Sales'.",config:{title:"X Bar",plugin:"X Bar",group_by:["Sub-Category"],columns:["Sales"]}},{name:"X Bar",description:"Grouped horizontal bar chart. X is 'Sub-Category' and Y is 'Quantity, Profit'.",config:{title:"X Bar",plugin:"X Bar",group_by:["Sub-Category"],columns:["Quantity","Profit"]}},{name:"X Bar, Sorted Desc By X-Axis",description:"Sorted horizontal bar chart. X is 'Sub-Category' and Y is 'Sales'.",config:{title:"X Bar, Sorted Desc By X-Axis",plugin:"X Bar",group_by:["Sub-Category"],columns:["Sales"],sort:[["Sales","asc"]]}},{name:"X Bar - Row And Split By",description:"Stacked horizontal bar chart. X is 'Sub-Category', Y is 'Sales', and subgroup is 'Region'",config:{title:"X Bar - Row And Split By",plugin:"X Bar",group_by:["Sub-Category"],split_by:["Region"],columns:["Sales"]}},{name:"X Bar - Row And Split By",description:"Sorted stacked horizontal bar chart. X is 'Sub-Category', Y is 'Sales', and subgroup is 'Region'",config:{title:"X Bar - Row And Split By",plugin:"X Bar",group_by:["Sub-Category"],split_by:["Region"],columns:["Sales"],sort:[["Sales","asc"]]}},{name:"Y Line - Datetime Axis",description:"Line chart. X is Order Date from January 2014 to December 2017. Y is 'Sales'.",config:{title:"Y Line - Datetime Axis",plugin:"Y Line",group_by:["Order Date"],columns:["Sales"]}},{name:"Y Line - Datetime Axis",description:"Line chart with 3 lines. X is Order Date, Y is Sales, and the lines are 'Consumer', 'Corporate', and 'Home Office'.",config:{title:"Y Line - Datetime Axis",plugin:"Y Line",group_by:["Order Date"],split_by:["Segment"],columns:["Sales"]}},{name:"Y Line - Datetime Axis Computed",description:"Line Chart. X is 'Order Date', summarized by month. Y is 'Sales'",config:{title:"Y Line - Datetime Axis Computed",plugin:"Y Line",group_by:[`bucket("Order Date", 'M')`],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},columns:["Sales"]}},{name:"Y Line - Datetime Axis",description:"Line Chart with 4 lines. X is 'Order Date' from January 2014 to December 2017. Y is 'Sales'. Each line is for each year.",config:{title:"Y Line - Datetime Axis",plugin:"Y Line",group_by:[`bucket("Order Date", 'M')`],split_by:[`bucket("Order Date", 'Y')`],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`,"bucket(\"Order Date\", 'Y')":`bucket("Order Date", 'Y')`},columns:["Sales"]}},{name:"Y Line - Datetime Axis And Split By",description:"Line Chart with 4 lines. X is Order Date, Y is Sales, and the lines track different regions.",config:{title:"Y Line - Datetime Axis And Split By",plugin:"Y Line",group_by:[`bucket("Order Date", 'M')`],split_by:["Region"],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},columns:["Sales"]}},{name:"Y Line - Category Axis",description:"Line Chart. X is State and Y is Sales.",config:{title:"Y Line - Category Axis",plugin:"Y Line",group_by:["State"],columns:["Sales"]},viewport:{width:600,height:450}},{name:"Y Line - Category Axis",description:"Line Chart. X is State and Y is Sales. Sorted descending.",config:{title:"Y Line - Category Axis",plugin:"Y Line",group_by:["State"],columns:["Sales"],sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Line - Row and Split By",description:"Line chart with 3 lines. X is State, Y is Sales, and each line tracks a customer segment. States are sorted descending by total sales.",config:{title:"Y Line - Row and Split By",plugin:"Y Line",group_by:["State"],split_by:["Segment"],columns:["Sales"],sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Line - Multi Axis Split",description:"Line chart with 2 lines. X is State, Y is Profit, and second Y is Sales. States are sorted descending by Sales.",config:{title:"Y Line - Multi Axis Split",plugin:"Y Line",group_by:["State"],columns:["Sales","Profit"],plugin_config:{splitMainValues:["Sales"]},sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Line - Multi Axis Split",description:"Line chart with 2 lines. X is State, Y is Profit, second Y is Sales, and each line is profit/sales for each customer segment. States are sorted descending by total Sales.",config:{title:"Y Line - Multi Axis Split",plugin:"Y Line",group_by:["State"],split_by:["Segment"],columns:["Sales","Profit"],plugin_config:{splitMainValues:["Sales"]},sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Area - Datetime Axis Computed",description:"Area chart. X is 'Order Date', bucketed by month. Y is Sales.",config:{title:"Y Area - Datetime Axis Computed",plugin:"Y Area",group_by:[`bucket("Order Date", 'M')`],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},columns:["Sales"]}},{name:"Y Area - Datetime Axis",description:"Area chart. X is 'Order Date', bucketed by month. Y is sales. Each year is its own color and area.",config:{title:"Y Area - Datetime Axis",plugin:"Y Area",group_by:[`bucket("Order Date", 'M')`],split_by:[`bucket("Order Date", 'Y')`],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`,"bucket(\"Order Date\", 'Y')":`bucket("Order Date", 'Y')`},columns:["Sales"]}},{name:"Y Area - Datetime Axis And Split By",description:"Stacked area chart. X is 'Order Date', bucketed by month. Y is sales. Subgroup is Region.",config:{title:"Y Area - Datetime Axis And Split By",plugin:"Y Area",group_by:[`bucket("Order Date", 'M')`],split_by:["Region"],expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},columns:["Sales"]}},{name:"Y Area - Category Axis",description:"Area chart. X is 'State'. Y is Sales.",config:{title:"Y Area - Category Axis",plugin:"Y Area",group_by:["State"],columns:["Sales"]},viewport:{width:600,height:450}},{name:"Y Area - Row and Split By",description:"Stacked area chart. X is 'State'. Y is 'Sales'. Subgroup is customer segment.",config:{title:"Y Area - Row and Split By",plugin:"Y Area",group_by:["State"],split_by:["Ship Mode"],columns:["Sales"]},viewport:{width:600,height:450}},{name:"Y Area - 2 Group By",description:"Grouped area chart. X is State, grouped by Region. Y is sales. Sorted descending by Sales for each region.",config:{title:"Y Area - 2 Group By",plugin:"Y Area",group_by:["Region","State"],columns:["Sales"],sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Area - Row and Split By",description:"Grouped area chart. X is State, grouped by Region. Y is sales. Sorted descending by Sales for each region. Each group is a different color.",config:{title:"Y Area - Row and Split By",plugin:"Y Area",group_by:["Region","State"],split_by:["Region"],columns:["Sales"],sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"Y Area - Row and Split By 2",description:"Stacked grouped area chart. X is State, grouped by Region. Y is sales. Subgroup is customer segment. Sorted descending by total sales.",config:{title:"Y Area - Row and Split By 2",plugin:"Y Area",group_by:["Region","State"],split_by:["Ship Mode"],columns:["Sales"],sort:[["Sales","desc"]]},viewport:{width:600,height:450}},{name:"X/Y Scatter",description:"Scatter plot. X is Sales. Y is Quantity.",config:{title:"X/Y Scatter",plugin:"X/Y Scatter",group_by:["City"],columns:["Sales","Quantity"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg"}}},{name:"X/Y Scatter - Split By",description:"Grouped Scatter plot. X is Sales. Y is Quantity. Group is Region.",config:{title:"X/Y Scatter - Split By",plugin:"X/Y Scatter",group_by:["City"],split_by:["Region"],columns:["Sales","Quantity"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg"}}},{name:"X/Y Scatter - Color By Float",description:"Scatter plot. X is Sales. Y is Quantity. Each dot is colored by Profit.",config:{title:"X/Y Scatter - Color By Float",plugin:"X/Y Scatter",group_by:["State"],columns:["Sales","Quantity","Profit"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg"},sort:[["Profit","desc"]]}},{name:"X/Y Scatter - Bubble",description:"Bubble plot. X is Sales. Y is Quantity. Size is Profit.",config:{title:"X/Y Scatter - Bubble",plugin:"X/Y Scatter",group_by:["Sub-Category"],columns:["Sales","Quantity",null,"Profit"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Bubble",description:"Grouped bubble plot. X is Sales. Y is Quantity. Size is Profit. Group is Product Sub-Category.",config:{title:"X/Y Scatter - Bubble",plugin:"X/Y Scatter",group_by:["Sub-Category"],split_by:["Category"],columns:["Sales","Quantity",null,"Profit"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Bubble",description:"Colored bubble plot. X is Sales. Y is Quantity. Size is Row ID. Color is Profit.",config:{title:"X/Y Scatter - Bubble",plugin:"X/Y Scatter",group_by:["Sub-Category"],columns:["Sales","Quantity","Profit","Row ID"],sort:[["Profit","desc"]],aggregates:{Sales:"avg",Profit:"sum",Quantity:"avg","Row ID":"avg"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Category Y Axis",description:"Horizontal Bubble plot. X is State. Y is Profit. Size is Quantity.",config:{title:"X/Y Scatter - Category Y Axis",plugin:"X/Y Scatter",columns:["Profit","State",null,"Quantity"],group_by:["City"],aggregates:{State:"dominant"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Category Y Axis And Size And Color",description:"Colored Bubble plot. X is State. Y is product sub-category. Size is Sales. Color is Quantity.",config:{title:"X/Y Scatter - Category Y Axis And Size And Color",plugin:"X/Y Scatter",columns:["State","Sub-Category","Quantity","Sales",null],group_by:["State","Sub-Category"],aggregates:{State:"dominant","Sub-Category":"dominant",Profit:"low"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Label",description:"Labeled scatter plot. X is Sales. Y is Quantity. Each dot is labeled by Sub-Category.",config:{title:"X/Y Scatter - Label",plugin:"X/Y Scatter",group_by:["Sub-Category"],columns:["Sales","Quantity",null,null,null,"Sub-Category"],aggregates:{Sales:"avg",Quantity:"avg","Sub-Category":"dominant"}},viewport:{width:600,height:450}},{name:"X/Y Scatter - Label And Color",description:"Labeled colored scatter plot. X is Sales. Y is Quantity. Color is Profit. Each dot is labeled by State.",config:{title:"X/Y Scatter - Label And Color",plugin:"X/Y Scatter",group_by:["State"],columns:["Sales","Quantity","Profit",null,null,"State"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg",State:"dominant"},sort:[["Profit","desc"]]},viewport:{width:600,height:450}},{name:"X/Y Scatter - Label And Size",description:"Labeled bubble plot. X is Sales. Y is Quantity. Size is Profit. Each bubble is labeled by Sub-Category.",config:{title:"X/Y Scatter - Label And Size",plugin:"X/Y Scatter",group_by:["Sub-Category"],columns:["Sales","Quantity",null,"Profit",null,"Sub-Category"],aggregates:{Sales:"avg",Profit:"avg",Quantity:"avg","Sub-Category":"dominant"}},viewport:{width:600,height:450}},{name:"X/Y Line",description:"Line chart with 4 lines. X is Sales. Y is Profit. Each line represents a region.",config:{title:"X/Y Line",columns:["Sales","Profit"],plugin:"X/Y Line",aggregates:{"Order Date":"dominant",Sales:"avg",Profit:"avg"},group_by:["State"],sort:[["Profit","desc"],["Sales","desc"]],split_by:["Region"]}},{name:"Treemap",description:"Treemap with 1-level hierarchy and 17 tiles. Each tile is a product sub-category, and the tile's size represents sales",config:{title:"Treemap",plugin:"Treemap",group_by:["Sub-Category"],columns:["Sales"]}},{name:"Treemap - 2 Group By",description:"Treemap with 2-level hierarchies for Category and Sub-Category. Size is Sales.",config:{title:"Treemap - 2 Group By",plugin:"Treemap",group_by:["Category","Sub-Category","Segment"],columns:["Sales"]}},{name:"Treemap - Float Color",description:"Colored treemap with 2-level hierarchies for Category and Sub-Category. Size is Sales. Color is Quantity.",config:{title:"Treemap - Float Color",plugin:"Treemap",group_by:["Category","Sub-Category"],columns:["Sales","Quantity"],sort:[["Quantity","desc"]]}},{name:"Treemap - Category Color",description:"Treemap with 2-level hierarchies for Category and Sub-Category, with each Category colored differently. Size is Sales.",config:{title:"Treemap - Category Color",plugin:"Treemap",group_by:["Category","Sub-Category"],columns:["Sales","Category"],aggregates:{Category:"dominant"}}},{name:"Treemap - Row And Split By Float Color",description:"Colored treemap with 3-level hierarchies for Region, Category, and Sub-Category. Size is Sales. Color is Quantity.",config:{title:"Treemap - Row And Split By Float Color",plugin:"Treemap",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Quantity"],sort:[["Quantity","desc"]]},viewport:{width:800,height:600}},{name:"Treemap - Row And Split By Category Color",description:"Treemap with 3-level hierarchies for Region, Category, and Sub-Category, with each Region colored differently. Size is Sales.",config:{title:"Treemap - Row And Split By Category Color",plugin:"Treemap",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Region"],aggregates:{Region:"dominant"}},viewport:{width:800,height:600}},{name:"Treemap - Row And Split By Category Color 2",description:"Treemap with 3-level hierarchies for Region, Category, and Sub-Category, with each Category colored differently. Size is Sales.",config:{title:"Treemap - Row And Split By Category Color 2",plugin:"Treemap",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Category"],aggregates:{Category:"dominant"}},viewport:{width:800,height:600}},{name:"Treemap - Row And Split By Category Color 2",description:"Treemap with 3-level hierarchies for Region, Category, and Sub-Category, with each Category colored differently. Size is Sales.",config:{plugin:"Treemap",theme:null,title:"Treemap - Category Color 2",group_by:["State","City"],columns:["Sales","State",null],aggregates:{State:"dominant"}},viewport:{width:800,height:600}},{name:"Sunburst",description:"Sunburst with 1-level hierarchy. Hierarchy is Category. Size is Sales.",config:{title:"Sunburst",plugin:"Sunburst",group_by:["Sub-Category"],columns:["Sales"]}},{name:"Sunburst - 2 Group By",description:"Sunburst with 3-level hierarchy. Hierarchies are Category, Sub-category, and Customer Segment.",config:{title:"Sunburst - 2 Group By",plugin:"Sunburst",group_by:["Category","Sub-Category","Segment"],columns:["Sales"]}},{name:"Sunburst - Float Color",description:"Colored sunburst with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Quantity. Color is Sales.",config:{title:"Sunburst - Float Color",plugin:"Sunburst",group_by:["Category","Sub-Category"],columns:["Quantity","Sales"],sort:[["Quantity","desc"]]}},{name:"Sunburst - Category Color",description:"Colored sunburst with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Sales. Color is also Category.",config:{title:"Sunburst - Category Color",plugin:"Sunburst",group_by:["Category","Sub-Category"],columns:["Sales","Category"],aggregates:{Category:"dominant"}}},{name:"Sunburst - Row And Split By",description:"Grouped sunbursts with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Sales. Each sunburst is a different region.",config:{title:"Sunburst - Row And Split By",plugin:"Sunburst",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales"]},viewport:{width:600,height:450}},{name:"Sunburst - Row And Split By Float Color",description:"Grouped colored sunbursts with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Sales. Color is Quantity. Each sunburst is a different region.",config:{title:"Sunburst - Row And Split By Float Color",plugin:"Sunburst",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Quantity"]},viewport:{width:600,height:450}},{name:"Sunburst - Row And Split By Category Color",description:"Grouped sunbursts with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Sales. Each sunburst is a different region and color.",config:{title:"Sunburst - Row And Split By Category Color",plugin:"Sunburst",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Region"],aggregates:{Region:"dominant"}},viewport:{width:600,height:450}},{name:"Sunburst - Row And Split By Category Color 2",description:"Grouped sunbursts with 2-level hierarchy. Hierarchies are Category and Sub-category. Size is Sales. Each sunburst is a different region, and each category is colored.",config:{title:"Sunburst - Row And Split By Category Color 2",plugin:"Sunburst",group_by:["Category","Sub-Category"],split_by:["Region"],columns:["Sales","Category"],aggregates:{Category:"dominant"}},viewport:{width:600,height:450}},{name:"Heatmap",description:"Heatmap. Columns are Sub-Category. Rows are Region. Color is Profit.",config:{title:"Heatmap",plugin:"Heatmap",group_by:["Sub-Category"],split_by:["Region"],columns:["Profit"],sort:[["Profit","desc"],["Profit","col desc"]]}},{name:"Heatmap 2",description:"Heatmap. Columns are State. Rows are Sub-Category. Color is Profit.",config:{title:"Heatmap 2",plugin:"Heatmap",group_by:["State"],split_by:["Sub-Category"],columns:["Profit"],sort:[["Profit","desc"],["Profit","col desc"]]},viewport:{width:600,height:450}},{name:"Heatmap 3",description:"Heatmaps. Columns are order date, bucketed by month. Rows are Sub-Category. Color is Discount.",config:{title:"Heatmap 3",columns:["Discount"],plugin:"Heatmap",expressions:{"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},aggregates:{"Order Date":"dominant",Sales:"avg"},split_by:["Sub-Category"],group_by:[`bucket("Order Date", 'M')`],sort:[["Discount","col asc"]]},viewport:{width:600,height:450}},{name:"Heatmap 4",description:"Heatmap. Columns are order date, bucketed by month. Rows are Profit, bucketed by 100. Color is Profit.",config:{title:"Heatmap 4",plugin:"Heatmap",columns:["Profit"],expressions:{'bucket("Profit", 100)':'bucket("Profit", 100)',"bucket(\"Order Date\", 'M')":`bucket("Order Date", 'M')`},group_by:[`bucket("Order Date", 'M')`],split_by:['bucket("Profit", 100)']},viewport:{width:600,height:450}}];var Jl=on;var ln=Jl.map((e,t)=>({id:`feature-${String(t).padStart(2,"0")}-${Fe(e.name)}`,title:e.name,description:e.description,source:lt,workspace:H({...e.config,theme:null})}));var ct=[...Wr,...jr,...$r,...Vr,...Gr,...Ur,...sn,...Qr,...Jr,...ln];function an(e){return ct.find(t=>t.id===e)}var Zt="project",cn=document.title,ea=`<div class="projects">
<button
type="button"
class="projects__close"
aria-label="Close project gallery"
>\xD7</button>
<div class="projects__grid"></div>
<div class="projects__status" aria-live="polite"></div>
</div>`;function ut(){return new URLSearchParams(location.search).get(Zt)}function dt(e,t){if(t==="none")return;document.title=e?`${e.title} \u2014 ${cn}`:cn;let i=new URL(location.href);e?i.searchParams.set(Zt,e.id):i.searchParams.delete(Zt),i.href!==location.href&&(t==="push"?history.pushState(null,"",i):history.replaceState(null,"",i))}function ta(e,t){let i={};for(let[r,n]of Object.entries(e.panels??{}))i[r]={...n,table:t};return{...e,panels:i}}function ia(e){let t=e.description?` title="${M(e.description)}"`:"";return`<button
type="button"
class="projects__card"
data-project="${M(e.id)}"${t}
>
<img
class="projects__thumb"
loading="lazy"
decoding="async"
alt=""
src="${M(Vt(e.id,rt()))}"
/>
<span class="projects__title">${M(e.title)}</span>
</button>`}async function ra(e,t){let i=t.source,r=i.kind==="generated"||i.kind==="eval"?"perspective-server":i.engine,n=X().find(o=>o.engine===r&&o.label===i.name),s=n??await st(i);await e.restoreWorkspace(ta(t.workspace,s.table)),n||oe({id:se(),engine:r,table:s.table,label:s.label,kind:i.kind})}function un(e,t){let i=ut(),r=L(ea),n=w(r,".projects__grid"),s=w(r,".projects__status"),o=L('<dialog class="modal modal--projects"></dialog>');e.appendChild(r),document.body.appendChild(o);let l=!1,a=!0,u=!1;function c(){let _=u||!a;e.dataset.stage=_?"viewer":"projects",r.hidden=l?!1:_}function d(){l||(l=!0,r.classList.add("projects--modal"),o.appendChild(r),c(),o.showModal())}function h(){l&&(l=!1,r.classList.remove("projects--modal"),e.appendChild(r),o.close(),c())}async function p(_,g="push"){let m=an(_);if(!m){ut()!==null&&dt(null,"replace");return}let v=l;r.classList.add("projects--busy"),s.textContent=`Loading ${m.title}\u2026`,u=!0,h(),c();try{await ra(t,m),s.textContent="",dt(m,g)}catch(b){s.textContent=z(b),v&&d()}finally{u=!1,r.classList.remove("projects--busy"),c()}}o.addEventListener("close",h),o.addEventListener("click",_=>{_.target===o&&o.close()}),w(r,".projects__close").addEventListener("click",()=>o.close()),n.addEventListener("click",_=>{let g=_.target.closest(".projects__card")?.dataset.project;g&&p(g)}),n.addEventListener("load",_=>{_.target.classList.add("projects__thumb--ready")},!0),n.addEventListener("error",_=>{let g=_.target;g.closest(".projects__card")?.classList.add("projects__card--untitled"),g.remove()},!0);let f=!1;return tt(_=>{a=_.length===0,a&&f&&ut()!==null&&dt(null,"replace"),f=f||!a,c()}),window.addEventListener("popstate",()=>{let _=ut();if(_){p(_,"replace");return}dt(null,"replace"),a||d()}),n.innerHTML=ct.map(ia).join(""),De(_=>{for(let g of n.querySelectorAll(".projects__thumb")){let m=g.closest(".projects__card")?.dataset.project;m&&(g.src=Vt(m,_))}}),window.__loadProject=_=>p(_,"none"),window.__projectIds=()=>ct.map(_=>_.id),a=X().length===0,c(),i&&p(i,"replace"),{openModal:d}}var na=["arrow","csv","json","ndjson"],sa=["parquet","arrow","csv","json"];function Qt(e){return e==="duckdb-wasm"?sa:na}function Jt(e){return e==="duckdb-wasm"?".parquet,.arrow,.feather,.csv,.json,.ndjson":".arrow,.feather,.csv,.json,.ndjson"}function Ee(e){switch(e.split("?")[0].split("#")[0].split(".").pop()?.toLowerCase()){case"parquet":return"parquet";case"arrow":case"feather":case"lz4":return"arrow";case"csv":return"csv";case"json":return"json";case"ndjson":case"jsonl":return"ndjson";default:return}}function U(e){let i=(e.split("?")[0].split("#")[0].split("/").filter(Boolean).pop()??"source").replace(/\.[^.]+$/,"").replace(/[^A-Za-z0-9_]/g,"_");return/^[A-Za-z_]/.test(i)?i:`t_${i}`}function dn(e,t){let i=e.value;e.innerHTML=N(t),t.includes(i)&&(e.value=i)}var oa=`<div>
<label class="field">
<span class="field__label">URL</span>
<input
name="url"
type="url"
required
placeholder="https://example.com/data.arrow"
/>
<small class="field__hint">Must be readable cross-origin (CORS).</small>
</label>
<label class="field">
<span class="field__label">Format</span>
<select name="format">${N(["auto",...Qt("perspective-server")])}</select>
</label>
<label class="field">
<span class="field__label">Table name</span>
<input name="name" type="text" placeholder="derived from the URL" />
</label>
</div>`;function hn(){let e=L(oa),t=w(e,"[name=url]"),i=w(e,"[name=format]"),r=w(e,"[name=name]");return t.addEventListener("input",()=>{r.value||(r.placeholder=U(t.value)||"derived from the URL")}),{render(n){n.replaceChildren(...e.children)},onEngineChange(n){dn(i,["auto",...Qt(n)])},async create(n){let s=t.value.trim(),o=i.value==="auto"?Ee(s)??"arrow":i.value;return Gt({kind:"fetch",engine:n,url:s,format:o,name:r.value.trim()||U(s)})}}}var la=`<div>
<label class="field">
<span class="field__label">File</span>
<input name="file" type="file" required />
<small class="field__hint">
Read in the browser; never uploaded anywhere.
</small>
</label>
<label class="field">
<span class="field__label">Table name</span>
<input
name="name"
type="text"
placeholder="derived from the file name"
/>
</label>
</div>`;function pn(){let e=L(la),t=w(e,"[name=file]"),i=w(e,"[name=name]");return t.accept=Jt("perspective-server"),t.addEventListener("change",()=>{let r=t.files?.[0];r&&!i.value&&(i.placeholder=U(r.name))}),{render(r){r.replaceChildren(...e.children)},onEngineChange(r){t.accept=Jt(r)},async create(r){let n=t.files?.[0];if(!n)throw new Error("Choose a file first.");let s=i.value.trim()||U(n.name),o=Ee(n.name)??"arrow";return Yr(r,n,s,o)}}}var ei=Object.keys(O),aa=`<div>
<label class="field">
<span class="field__label">Generator</span>
<select name="generator">${N(ei.map(e=>O[e].label))}</select>
</label>
<p class="modal__note" data-role="description"></p>
<div data-role="params"></div>
<label class="field">
<span class="field__label">Table name</span>
<input
name="name"
type="text"
placeholder="derived from the generator"
/>
</label>
</div>`;function ca(e,t){let i=[e.min!==void 0?`min="${e.min}"`:"",e.max!==void 0?`max="${e.max}"`:"",`step="${e.step??1}"`].join(" ");return`<label class="field">
<span class="field__label">${M(e.label)}</span>
<input
name="${M(e.key)}"
type="number"
required
value="${t}"
${i}
/>
${e.hint?`<small class="field__hint">${M(e.hint)}</small>`:""}
</label>`}function fn(){let e=L(aa),t=w(e,"[name=generator]"),i=w(e,"[data-role=description]"),r=w(e,"[data-role=params]"),n=w(e,"[name=name]");function s(){return ei[t.selectedIndex]??ei[0]}function o(){let l=O[s()];i.textContent=l.description,r.innerHTML=l.params.map(a=>ca(a,Number(l.defaults[a.key]??0))).join(""),n.placeholder=s()}return t.addEventListener("change",o),o(),{render(l){l.replaceChildren(...e.children)},async create(l){let a=s(),u={};for(let c of r.querySelectorAll("input")){let d=Number(c.value);if(!Number.isFinite(d))throw new Error(`"${c.name}" must be a number.`);u[c.name]=d}return st({kind:"generated",generator:a,name:n.value.trim()||a,params:u})}}}var mn="AWS4-HMAC-SHA256";function ti(e){return encodeURIComponent(e).replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}function ua(e){return e===""||e==="/"?"/":e.split("/").map(ti).join("/")}function da(e){return e.map(([t,i])=>[ti(t),ti(i)]).sort(([t,i],[r,n])=>t<r?-1:t>r?1:i<n?-1:i>n?1:0).map(([t,i])=>`${t}=${i}`).join("&")}function gn(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}async function ha(e){let t=new TextEncoder().encode(e);return gn(await crypto.subtle.digest("SHA-256",t))}async function Be(e,t){let i=e instanceof Uint8Array?new Uint8Array(e):e,r=await crypto.subtle.importKey("raw",i,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return crypto.subtle.sign("HMAC",r,new TextEncoder().encode(t))}async function pa(e,t,i,r){let n=new TextEncoder().encode(`AWS4${e}`),s=await Be(n,t),o=await Be(s,i),l=await Be(o,r);return Be(l,"aws4_request")}function fa(e){let t=e.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,"");return{long:t,short:t.slice(0,8)}}function ii(){return typeof crypto<"u"&&!!crypto.subtle}async function ri(e,t){if(!ii())throw new Error("WebCrypto is unavailable \u2014 S3 request signing requires a secure context (https:, or localhost during development).");let i="s3",r=e.expires??900,{long:n,short:s}=fa(new Date),o=`${s}/${e.region}/${i}/aws4_request`,l=[];e.url.searchParams.forEach((f,_)=>l.push([_,f])),l.push(["X-Amz-Algorithm",mn],["X-Amz-Credential",`${t.accessKeyId}/${o}`],["X-Amz-Date",n],["X-Amz-Expires",String(r)],["X-Amz-SignedHeaders","host"]),t.sessionToken&&l.push(["X-Amz-Security-Token",t.sessionToken]);let a=da(l),u=e.url.host,c=[e.method,ua(e.url.pathname),a,`host:${u}
`,"host","UNSIGNED-PAYLOAD"].join(`
`),d=[mn,n,o,await ha(c)].join(`
`),h=await pa(t.secretAccessKey,s,e.region,i),p=gn(await Be(h,d));return`${e.url.origin}${e.url.pathname}?${a}&X-Amz-Signature=${p}`}function si(e){if(!e)return;let t;try{t=new URL(e)}catch{throw new Error(`Endpoint is not a valid URL: ${e}`)}if(t.protocol==="http:"&&location.protocol==="https:")throw new Error(`This page is served over HTTPS, so the browser blocks requests to the plain-HTTP endpoint ${t.origin} as mixed content. The endpoint needs TLS, or a TLS-terminating proxy.`)}function yn(e){return e?"path":"virtual-hosted"}function ma(e){return e.endpoint?new URL(e.endpoint).origin:`https://s3.${e.region}.amazonaws.com`}function vn(e,t){let i=t?`/${t}`:"";return e.style==="virtual-hosted"&&!e.endpoint?new URL(`https://${e.bucket}.s3.${e.region}.amazonaws.com${i}`):new URL(`${ma(e)}/${e.bucket}${i}`)}function xn(e,t,i){return ri({method:"GET",url:vn(e,t),region:e.region,expires:i},e.credentials)}async function ga(e){let t=await fetch(e),i=await t.text(),r=new DOMParser().parseFromString(i,"text/xml");if(!t.ok){let n=q(r,"Message")??t.statusText;throw new Error(`S3 error ${t.status}: ${n}`)}return r}function q(e,t){return e.getElementsByTagName(t)[0]?.textContent??void 0}function _n(e,t){return Array.from(e.getElementsByTagName(t))}function _a(e){let t=_n(e,"CommonPrefixes").map(r=>q(r,"Prefix")).filter(r=>!!r),i=_n(e,"Contents").map(r=>({key:q(r,"Key")??"",size:Number(q(r,"Size")??0),lastModified:q(r,"LastModified")??""}));return{prefixes:t,objects:i}}var ni=new WeakMap;async function oi(e,t){si(e.endpoint);let i=ni.get(e)??2;try{let r=await bn(e,t,i);return ni.set(e,i),r}catch(r){if(i===2)return ni.set(e,1),bn(e,t,1);throw r}}async function bn(e,t,i){let r={prefixes:[],objects:[]},n;do{let s=vn(e,"");s.searchParams.set("delimiter","/"),s.searchParams.set("max-keys","1000"),t&&s.searchParams.set("prefix",t),i===2?(s.searchParams.set("list-type","2"),n&&s.searchParams.set("continuation-token",n)):n&&s.searchParams.set("marker",n);let o=await ga(await ri({method:"GET",url:s,region:e.region},e.credentials)),l=_a(o);r.prefixes.push(...l.prefixes),r.objects.push(...l.objects),q(o,"IsTruncated")==="true"?i===2?n=q(o,"NextContinuationToken"):n=q(o,"NextMarker")??l.objects[l.objects.length-1]?.key:n=void 0}while(n);return r}var En={AWS:{endpoint:"",region:"us-east-1",style:"virtual-hosted"},"Cloudflare R2":{endpoint:"",region:"auto",style:"path"},"Backblaze B2":{endpoint:"",region:"us-west-004",style:"path"},"MinIO / other S3-compatible":{endpoint:"http://localhost:9000",region:"us-east-1",style:"path"}},wn=100,ba=`<div>
<label class="field">
<span class="field__label">Provider</span>
<select name="provider">${N(Object.keys(En))}</select>
</label>
<label class="field">
<span class="field__label">Endpoint</span>
<input name="endpoint" type="text" placeholder="blank for AWS" />
<small class="field__hint">Blank for AWS.</small>
</label>
<label class="field">
<span class="field__label">Region</span>
<input name="region" type="text" required placeholder="us-east-1" />
<small class="field__hint">R2 uses the literal \`auto\`.</small>
</label>
<label class="field">
<span class="field__label">URL style</span>
<select name="style">${N(["path","virtual-hosted"])}</select>
</label>
<label class="field">
<span class="field__label">Bucket</span>
<input name="bucket" type="text" required />
</label>
<label class="field">
<span class="field__label">Access key ID</span>
<input name="keyId" type="text" required />
</label>
<label class="field">
<span class="field__label">Secret access key</span>
<input name="secret" type="password" required />
</label>
<label class="field">
<span class="field__label">Session token</span>
<input
name="token"
type="password"
placeholder="temporary credentials only"
/>
</label>
<button type="button" class="btn" data-role="connect">Connect</button>
<div class="s3__status" aria-live="polite"></div>
<div class="s3__browser" hidden></div>
<label class="field">
<span class="field__label">Table name</span>
<input name="name" type="text" placeholder="derived from the key" />
</label>
</div>`;function ya(e){let t=["B","KB","MB","GB","TB"],i=e,r=0;for(;i>=1024&&r<t.length-1;)i/=1024,r++;return`${i.toFixed(r===0?0:1)} ${t[r]}`}function va(e,t){let i="",r=t.split("/").filter(Boolean).map(n=>(i+=`${n}/`,`<button type="button" class="s3__crumb"
data-browse="${M(i)}">${M(n)}</button>`));return`<div class="s3__crumbs">
<button type="button" class="s3__crumb" data-browse=""
>${M(e||"/")}</button>
${r.join("")}
</div>`}function xa(e,t,i){let r=e?`<li><button
type="button"
class="s3__entry s3__entry--prefix"
data-select-prefix
>Use this whole prefix (${M(e)})</button></li>`:"",n=t.map(o=>`<li><button
type="button"
class="s3__entry s3__entry--folder"
data-browse="${M(o)}"
>${M(o.slice(e.length).replace(/\/$/,""))}</button></li>`),s=i.map(o=>`<li><button
type="button"
class="s3__entry s3__entry--object"
data-key="${M(o.key)}"
>${M(o.key.slice(e.length))} (${ya(o.size)})</button></li>`);return`<ul class="s3__list">${r}${n.join("")}${s.join("")}</ul>`}function Cn(){let e=L(ba),t=w(e,"[name=provider]"),i=w(e,"[name=endpoint]"),r=w(e,"[name=region]"),n=w(e,"[name=style]"),s=w(e,"[name=bucket]"),o=w(e,"[name=keyId]"),l=w(e,"[name=secret]"),a=w(e,"[name=token]"),u=w(e,"[name=name]"),c=w(e,".s3__status"),d=w(e,".s3__browser"),h,p="",f;function _(){let b=En[t.value];b&&(i.value=b.endpoint,r.value=b.region,n.value=b.style,t.value.startsWith("MinIO")&&location.hostname==="localhost"&&(o.value||="perspective",l.value||="perspective",s.value||="perspective"))}function g(){let b=i.value.trim()||void 0;return si(b),{endpoint:b,region:r.value.trim(),bucket:s.value.trim(),style:n.value,credentials:{accessKeyId:o.value.trim(),secretAccessKey:l.value,sessionToken:a.value.trim()||void 0}}}async function m(b){if(h){p=b,c.textContent=`Listing ${p||"/"}\u2026`;try{let y=await oi(h,p);d.hidden=!1,d.innerHTML=va(s.value.trim(),p)+xa(p,y.prefixes,y.objects),c.textContent=""}catch(y){c.textContent=z(y)}}}async function v(){if(!h)return;c.textContent="Enumerating prefix\u2026",f={keys:(await oi(h,p)).objects.map(y=>y.key),label:U(p)},c.textContent=`Selected ${f.keys.length} object(s) under ${p}.`}return t.addEventListener("change",_),i.addEventListener("input",()=>{n.value=yn(i.value.trim()||void 0)}),d.addEventListener("click",b=>{let y=b.target.closest("button");y&&(y.dataset.browse!==void 0?m(y.dataset.browse):y.dataset.selectPrefix!==void 0?v():y.dataset.key&&(f={keys:[y.dataset.key],label:U(y.dataset.key)},c.textContent=`Selected ${y.dataset.key}.`))}),w(e,"[data-role=connect]").addEventListener("click",async()=>{if(!ii()){c.textContent="WebCrypto is unavailable \u2014 signing requires a secure context (https:, or localhost).";return}try{h=g()}catch(b){c.textContent=z(b);return}await m("")}),_(),{render(b){b.replaceChildren(...e.children)},async create(b){if(!h)throw new Error("Connect first, then choose an object.");if(!f||f.keys.length===0)throw new Error("Choose an object or a prefix.");let y=u.value.trim()||f.label;if(f.keys.length>wn)throw new Error(`${f.keys.length} objects exceeds the ${wn}-object presigned-list cap. Narrow the prefix, or use a DuckDB \`CREATE SECRET\` glob.`);let A=await Promise.all(f.keys.map(x=>xn(h,x))),T=Ee(f.keys[0])??"parquet";return $t(b,A,y,T)}}}var wa={fetch:"Fetch",file:"File",s3:"S3",generated:"Generated"},Ea={generated:"perspective-server"},Ca=`<dialog id="source_modal" class="modal">
<form method="dialog">
<h2>Create Data Source</h2>
<div class="modal__selects">
<label class="field">
<span class="field__label">Source</span>
<select name="kind">${N(wa)}</select>
</label>
<label class="field">
<span class="field__label">Engine</span>
<select name="engine">${N(Je)}</select>
</label>
</div>
<div class="modal__body"></div>
<div class="modal__status" aria-live="polite"></div>
<div class="modal__actions">
<button type="button" class="btn" data-role="cancel">
Cancel
</button>
<button type="submit" class="btn btn--primary">Create</button>
</div>
</form>
</dialog>`;function Sn(e,t){let i=L(Ca),r=w(i,"[name=kind]"),n=w(i,"[name=engine]"),s=w(i,".modal__body"),o=w(i,"[data-role=cancel]"),l={fetch:hn(),file:pn(),s3:Cn(),generated:fn()},a={};for(let d of Object.keys(l)){let h=L('<fieldset class="modal__fieldset"></fieldset>');l[d].render(h),a[d]=h,s.appendChild(h)}function u(){let d=r.value;for(let p of Object.keys(a)){let f=p===d;a[p].hidden=!f,a[p].disabled=!f}let h=Ea[d];n.disabled=h!==void 0,h&&(n.value=h)}async function c(d,h){try{await(await et(d)).drop(h.replace(/^memory\./,""))}catch{return}}Qe(i,{trigger:t,pending:"Connecting\u2026",busy(d){o.disabled=d,r.disabled=d,n.disabled=d},async submit(d){let h=r.value,p=n.value,f;try{f=await l[h].create(p),d.textContent="Creating panel\u2026",await e.addPanel({table:f.table,title:f.label,...f.panel??{}}),oe({id:se(),engine:p,table:f.table,label:f.label,kind:h})}catch(_){throw f&&await c(p,f.table),_}}}),r.addEventListener("change",u),n.addEventListener("change",()=>{for(let d of Object.values(l))d.onEngineChange?.(n.value)}),u()}var Sa=1e3;function Aa(e){return e==null?"NULL":String(e)}function Ta(e,t){let i=e.schema.fields,r=i.map(s=>`<th>${M(s.name)}</th>`).join(""),n=e.slice(0,t).toArray().map(s=>{let o=s.toJSON();return`<tr>${i.map(a=>`<td>${M(Aa(o[a.name]))}</td>`).join("")}</tr>`}).join("");return`<div class="sqldrawer__grid">
<table>
<thead><tr>${r}</tr></thead>
<tbody>${n}</tbody>
</table>
</div>`}function Ma(e,t){let i=L(`<div class="sqldrawer__entry">
${t?'<div class="sqldrawer__query"></div>':""}
</div>`);t&&(w(i,".sqldrawer__query").textContent=t),e.appendChild(i);function r(n,s){let o=L(`<div class="${n}"></div>`);return o.textContent=s,i.appendChild(o),o}return{ok(n){r("sqldrawer__ok",n)},error(n){r("sqldrawer__error",n)},pending(n){let s=r("sqldrawer__ok",n);return()=>s.remove()},preview(n){let s=n.numRows,o=Math.min(s,Sa);i.appendChild(L(Ta(n,o))),s>o&&r("sqldrawer__ok",`\u2026 ${(s-o).toLocaleString()} more rows not shown \u2014 open as a panel to explore all of them.`)},action(n,s,o){let l=L(`<div class="sqldrawer__actions">
${n?`<span class="sqldrawer__ok">${M(n)}</span>`:""}
<button type="button" class="btn">${M(s)}</button>
</div>`),a=w(l,"button");a.addEventListener("click",async()=>{a.disabled=!0;try{a.textContent=await o()}catch(u){a.disabled=!1,r("sqldrawer__error",z(u))}}),i.appendChild(l)}}}function An(e){return{entry:t=>Ma(e,t),scrollToEnd(){e.scrollTop=e.scrollHeight}}}var Tn="perspective-sql-open",Mn="perspective-sql-height",Ln="perspective-sql-history",Rn=120,Ra=280,ka=100,La=`<section class="sqldrawer">
<div
class="sqldrawer__splitter"
role="separator"
aria-orientation="horizontal"
tabindex="0"
></div>
<div class="sqldrawer__header">
<span>DuckDB SQL</span>
<button
type="button"
class="sqldrawer__close"
aria-label="Close SQL panel"
>\xD7</button>
</div>
<div class="sqldrawer__scrollback" aria-live="polite"></div>
<form class="sqldrawer__input">
<label class="sqldrawer__editor" data-value="">
<textarea
rows="1"
spellcheck="false"
aria-label="SQL query"
placeholder="SELECT \u2026 \u2014 \u2318\u23CE to run"
></textarea>
</label>
<button type="submit" class="btn btn--primary">Run</button>
</form>
</section>`;function Pa(){let e;return async()=>{let t=await ve();return e??=await t.db.connect(),{duck:t,conn:e}}}function ht(e){e.parentElement.dataset.value=e.value}function Da(){let e=Ze(Ln);return Array.isArray(e)?e:[]}function Ia(e){let t=Da(),i=t.length,r="";return e.addEventListener("keydown",n=>{let s=e.selectionStart===0&&e.selectionEnd===0;n.key==="ArrowUp"&&s&&i>0?(i===t.length&&(r=e.value),i-=1,e.value=t[i],ht(e),n.preventDefault()):n.key==="ArrowDown"&&e.selectionStart===e.value.length&&i<t.length&&(i+=1,e.value=i===t.length?r:t[i],ht(e),n.preventDefault())}),n=>{t=[...t.filter(s=>s!==n),n].slice(-ka),localStorage.setItem(Ln,JSON.stringify(t)),i=t.length,r=""}}function Fa(e,t){function i(){return Number(localStorage.getItem(Mn)??Ra)}function r(n){let s=Math.max(Rn,e.clientHeight*.6),o=Math.min(Math.max(n,Rn),s);e.style.setProperty("--sql-height",`${o}px`),localStorage.setItem(Mn,String(o))}nt(t,{toPx:n=>e.getBoundingClientRect().bottom-n.clientY,current:i,growKey:"ArrowUp",shrinkKey:"ArrowDown",apply:r}),r(i())}function Ba(e){return e.replace(/[\s;]+$/g,"")}function Na(){let e=X().map(t=>/^memory\.sql_result_(\d+)$/.exec(t.table)?.[1]).filter(t=>!!t).map(Number);return e.length?Math.max(...e)+1:1}async function kn(e){try{return new Set(await e.get_hosted_table_names())}catch{return new Set}}function Oa(e,t){let i=new Set(X().map(r=>r.table));return[...t].filter(r=>!e.has(r)&&!i.has(r)&&r.startsWith("memory.")&&!/^memory\.(sql_result_|__sql_preview)/.test(r))}function za(e,t,i){async function r(s){let{duck:o,conn:l}=await i(),a=`sql_result_${Na()}`;await l.query(`CREATE OR REPLACE TABLE memory.main."${a}" AS (
${Ba(s)}
)`);let u=o.qualify(a);return await e.addPanel({table:u,title:a}),oe({id:se(),engine:"duckdb-wasm",table:u,label:a,kind:"sql"}),`Opened as "${a}"`}async function n(s){let o=s.replace(/^memory\./,"");return await e.addPanel({table:s,title:o}),oe({id:se(),engine:"duckdb-wasm",table:s,label:o,kind:"sql"}),"Registered"}return async function(o){let l=t.entry(o),a=l.pending("Running\u2026");try{let{duck:u,conn:c}=await i(),d=await kn(u.client()),h=performance.now(),p=await c.query(o),f=Math.round(performance.now()-h);a(),p.numRows>0?(l.ok(`${p.numRows.toLocaleString()} row(s) in ${f}ms`),l.preview(p),l.action("","Open as panel",()=>r(o))):l.ok(`OK in ${f}ms`);let _=await kn(u.client());for(let g of Oa(d,_))l.action(`Created ${g} \u2014 `,"Register as source",()=>n(g));return!0}catch(u){return a(),l.error(z(u)),!1}finally{t.scrollToEnd()}}}function Pn(e,t){let i=L(La),r=w(i,"textarea"),n=w(i,"form"),s=w(i,"button[type=submit]");e.appendChild(i);let o=An(w(i,".sqldrawer__scrollback")),l=Pa(),a=Ia(r),u=za(t,o,l);Fa(e,w(i,".sqldrawer__splitter"));let c=!1;async function d(p){if(!(c||!p.trim())){c=!0,s.disabled=!0;try{await u(p)&&(a(p),r.value="",ht(r))}finally{c=!1,s.disabled=!1}}}function h(p){e.dataset.sql=p?"open":"closed",localStorage.setItem(Tn,String(p)),p&&(l().catch(f=>{o.entry("").error(`DuckDB engine failed to start: ${z(f)}`)}),r.focus())}return n.addEventListener("submit",p=>{p.preventDefault(),d(r.value)}),r.addEventListener("input",()=>ht(r)),r.addEventListener("keydown",p=>{(p.metaKey||p.ctrlKey)&&p.key==="Enter"&&(p.preventDefault(),d(r.value))}),w(i,".sqldrawer__close").addEventListener("click",()=>h(!1)),localStorage.getItem(Tn)==="true"?h(!0):e.dataset.sql="closed",{toggle(){h(e.dataset.sql!=="open")}}}var Ha=[{id:"carto-positron",label:"Light (Positron)",template:"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",subdomains:["a","b","c","d"],attribution:"\xA9 OpenStreetMap contributors \xA9 CARTO",tile_size:256,max_zoom:19},{id:"carto-dark-matter",label:"Dark Matter",template:"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png",subdomains:["a","b","c","d"],attribution:"\xA9 OpenStreetMap contributors \xA9 CARTO",tile_size:256,max_zoom:19},{id:"carto-voyager",label:"Voyager",template:"https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png",subdomains:["a","b","c","d"],attribution:"\xA9 OpenStreetMap contributors \xA9 CARTO",tile_size:256,max_zoom:19}];function Dn(){for(let e of Ha)It(e)}var li=document.getElementById("app"),ce=document.getElementById("viewer");Dn();yr(ce);Ar(ce);var Ya=Pn(li,ce),{createSource:Wa,browseProjects:Ua,configureAgent:$a}=Rr(li,ce,{openSql:()=>Ya.toggle()}),Ga=un(li,ce);Ua.addEventListener("click",()=>Ga.openModal());Sn(ce,Wa);fr(ce,$a);
//# sourceMappingURL=index.js.map