@perspective-dev/viewer-datagrid 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,193 @@
1
+ # Apache License
2
+
3
+ _Version 2.0, January 2004_
4
+ _&lt;<http://www.apache.org/licenses/>&gt;_
5
+
6
+ ### Terms and Conditions for use, reproduction, and distribution
7
+
8
+ #### 1. Definitions
9
+
10
+ “License” shall mean the terms and conditions for use, reproduction, and
11
+ distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ “Licensor” shall mean the copyright owner or entity authorized by the copyright
14
+ owner that is granting the License.
15
+
16
+ “Legal Entity” shall mean the union of the acting entity and all other entities
17
+ that control, are controlled by, or are under common control with that entity.
18
+ For the purposes of this definition, “control” means **(i)** the power, direct or
19
+ indirect, to cause the direction or management of such entity, whether by
20
+ contract or otherwise, or **(ii)** ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or **(iii)** beneficial ownership of such entity.
22
+
23
+ “You” (or “Your”) shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ “Source” form shall mean the preferred form for making modifications, including
27
+ but not limited to software source code, documentation source, and configuration
28
+ files.
29
+
30
+ “Object” form shall mean any form resulting from mechanical transformation or
31
+ translation of a Source form, including but not limited to compiled object code,
32
+ generated documentation, and conversions to other media types.
33
+
34
+ “Work” shall mean the work of authorship, whether in Source or Object form, made
35
+ available under the License, as indicated by a copyright notice that is included
36
+ in or attached to the work (an example is provided in the Appendix below).
37
+
38
+ “Derivative Works” shall mean any work, whether in Source or Object form, that
39
+ is based on (or derived from) the Work and for which the editorial revisions,
40
+ annotations, elaborations, or other modifications represent, as a whole, an
41
+ original work of authorship. For the purposes of this License, Derivative Works
42
+ shall not include works that remain separable from, or merely link (or bind by
43
+ name) to the interfaces of, the Work and Derivative Works thereof.
44
+
45
+ “Contribution” shall mean any work of authorship, including the original version
46
+ of the Work and any modifications or additions to that Work or Derivative Works
47
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
48
+ by the copyright owner or by an individual or Legal Entity authorized to submit
49
+ on behalf of the copyright owner. For the purposes of this definition,
50
+ “submitted” means any form of electronic, verbal, or written communication sent
51
+ to the Licensor or its representatives, including but not limited to
52
+ communication on electronic mailing lists, source code control systems, and
53
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
54
+ the purpose of discussing and improving the Work, but excluding communication
55
+ that is conspicuously marked or otherwise designated in writing by the copyright
56
+ owner as “Not a Contribution.”
57
+
58
+ “Contributor” shall mean Licensor and any individual or Legal Entity on behalf
59
+ of whom a Contribution has been received by Licensor and subsequently
60
+ incorporated within the Work.
61
+
62
+ #### 2. Grant of Copyright License
63
+
64
+ Subject to the terms and conditions of this License, each Contributor hereby
65
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
66
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the Work and such
68
+ Derivative Works in Source or Object form.
69
+
70
+ #### 3. Grant of Patent License
71
+
72
+ Subject to the terms and conditions of this License, each Contributor hereby
73
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
74
+ irrevocable (except as stated in this section) patent license to make, have
75
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
76
+ such license applies only to those patent claims licensable by such Contributor
77
+ that are necessarily infringed by their Contribution(s) alone or by combination
78
+ of their Contribution(s) with the Work to which such Contribution(s) was
79
+ submitted. If You institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
81
+ Contribution incorporated within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under this License
83
+ for that Work shall terminate as of the date such litigation is filed.
84
+
85
+ #### 4. Redistribution
86
+
87
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
88
+ in any medium, with or without modifications, and in Source or Object form,
89
+ provided that You meet the following conditions:
90
+
91
+ - **(a)** You must give any other recipients of the Work or Derivative Works a copy of
92
+ this License; and
93
+ - **(b)** You must cause any modified files to carry prominent notices stating that You
94
+ changed the files; and
95
+ - **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
96
+ all copyright, patent, trademark, and attribution notices from the Source form
97
+ of the Work, excluding those notices that do not pertain to any part of the
98
+ Derivative Works; and
99
+ - **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
100
+ Derivative Works that You distribute must include a readable copy of the
101
+ attribution notices contained within such NOTICE file, excluding those notices
102
+ that do not pertain to any part of the Derivative Works, in at least one of the
103
+ following places: within a NOTICE text file distributed as part of the
104
+ Derivative Works; within the Source form or documentation, if provided along
105
+ with the Derivative Works; or, within a display generated by the Derivative
106
+ Works, if and wherever such third-party notices normally appear. The contents of
107
+ the NOTICE file are for informational purposes only and do not modify the
108
+ License. You may add Your own attribution notices within Derivative Works that
109
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
110
+ provided that such additional attribution notices cannot be construed as
111
+ modifying the License.
112
+
113
+ You may add Your own copyright statement to Your modifications and may provide
114
+ additional or different license terms and conditions for use, reproduction, or
115
+ distribution of Your modifications, or for any such Derivative Works as a whole,
116
+ provided Your use, reproduction, and distribution of the Work otherwise complies
117
+ with the conditions stated in this License.
118
+
119
+ #### 5. Submission of Contributions
120
+
121
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
122
+ for inclusion in the Work by You to the Licensor shall be under the terms and
123
+ conditions of this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
125
+ any separate license agreement you may have executed with Licensor regarding
126
+ such Contributions.
127
+
128
+ #### 6. Trademarks
129
+
130
+ This License does not grant permission to use the trade names, trademarks,
131
+ service marks, or product names of the Licensor, except as required for
132
+ reasonable and customary use in describing the origin of the Work and
133
+ reproducing the content of the NOTICE file.
134
+
135
+ #### 7. Disclaimer of Warranty
136
+
137
+ Unless required by applicable law or agreed to in writing, Licensor provides the
138
+ Work (and each Contributor provides its Contributions) on an “AS IS” BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
140
+ including, without limitation, any warranties or conditions of TITLE,
141
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
142
+ solely responsible for determining the appropriateness of using or
143
+ redistributing the Work and assume any risks associated with Your exercise of
144
+ permissions under this License.
145
+
146
+ #### 8. Limitation of Liability
147
+
148
+ In no event and under no legal theory, whether in tort (including negligence),
149
+ contract, or otherwise, unless required by applicable law (such as deliberate
150
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special, incidental,
152
+ or consequential damages of any character arising as a result of this License or
153
+ out of the use or inability to use the Work (including but not limited to
154
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
155
+ any and all other commercial damages or losses), even if such Contributor has
156
+ been advised of the possibility of such damages.
157
+
158
+ #### 9. Accepting Warranty or Additional Liability
159
+
160
+ While redistributing the Work or Derivative Works thereof, You may choose to
161
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
162
+ other liability obligations and/or rights consistent with this License. However,
163
+ in accepting such obligations, You may act only on Your own behalf and on Your
164
+ sole responsibility, not on behalf of any other Contributor, and only if You
165
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ _END OF TERMS AND CONDITIONS_
170
+
171
+ ### APPENDIX: How to apply the Apache License to your work
172
+
173
+ To apply the Apache License to your work, attach the following boilerplate
174
+ notice, with the fields enclosed by brackets `[]` replaced with your own
175
+ identifying information. (Don't include the brackets!) The text should be
176
+ enclosed in the appropriate comment syntax for the file format. We also
177
+ recommend that a file or class name and description of purpose be included on
178
+ the same “printed page” as the copyright notice for easier identification within
179
+ third-party archives.
180
+
181
+ Copyright 2019 The Perspective Authors
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
@@ -0,0 +1,47 @@
1
+ var xe=new WeakMap,Xt=!0,Qr=navigator.userAgent.toLowerCase().indexOf("firefox")>-1,es=Qr?5e6:1e7,Xe=0,Me=0,qt=performance.now();function ts(){let e=performance.now(),t=e-qt,o=Xe,s=Me*1e3/t,r=1e3/o,l=Me;return Xe=0,Me=0,qt=e,{avg:o,real_fps:s,virtual_fps:r,num_frames:l,elapsed:t}}function os(e){Xe=(Xe*Me+e)/(Me+1),Me+=1}var Kt=(e,...t)=>e.map((o,s)=>[o,t[s]]).flat().filter(o=>!!o).join(""),rs=()=>{let e,t=new Promise(o=>{e=o});return t.resolve=e,t},de=new Map;async function ss(e){return await new Promise(requestAnimationFrame),await de.get(e)}async function Vt(e,t){if(de.has(e)&&(await de.get(e),de.has(e))){await de.get(e);return}de.set(e,rs());try{return await t()}finally{let o=de.get(e);de.delete(e),o.resolve()}}var ls=":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%;}div.rt-tree-container{display:flex;align-items:center;height:100%;}slot{position:absolute;overflow:hidden;overflow-anchor:none;}",is=":host ::slotted(table){--regular-table--transform-x:0px;--regular-table--transform-y:0px;--regular-table--clip-x:0px;--regular-table--clip-y:0px;}",ns=class extends HTMLElement{create_shadow_dom(){this.attachShadow({mode:"open"});let e="<slot></slot>";this.shadowRoot.innerHTML=Kt`
2
+ <style>
3
+ ${ls}
4
+ </style>
5
+ <style>
6
+ ${is}
7
+ </style>
8
+ <div class="rt-virtual-panel"></div>
9
+ <div class="rt-scroll-table-clip">${e}</div>
10
+ `;let[,t,o,s]=this.shadowRoot.children;this._sub_cell_style=t,this._table_clip=s,this._virtual_panel=o,this._setup_virtual_scroll()}_setup_virtual_scroll(){this._table_clip&&(this._virtual_mode==="both"||this._virtual_mode==="vertical"?this._table_clip.style.top="0px":this._table_clip.style.removeProperty("top"),this._virtual_mode==="both"||this._virtual_mode==="horizontal"?this._table_clip.style.left="0px":this._table_clip.style.removeProperty("left"),this._virtual_mode!=="both"?this._table_clip.style.contain="none":this._table_clip.style.removeProperty("contain"))}_calculate_viewport(e,t){let{start_row:o,end_row:s}=this._calculate_row_range(e),{start_col:r,end_col:l}=this._calculate_column_range(t);return this._nrows=e,{start_col:r,end_col:l,start_row:o,end_row:s}}_calculate_row_range(e){let{height:t}=this._container_size,o=this._column_sizes.row_height||19,s=this._view_cache.config.column_pivots.length,r=Math.max(1,this._virtual_panel.offsetHeight-t),l=Math.max(Math.ceil(this.scrollTop),0)/r,i=t/o-s,n=Math.max(0,(e||0)-i)*l,a=Math.max(0,Math.min(n+i,e));return{start_row:n,end_row:a}}_calc_start_column(){let e=this._view_cache.config.row_pivots.length,t=0,o=0,s=0;for(;o<this.scrollLeft;){let r=this._column_sizes.indices[t+e];s=this.scrollLeft-o,t+=1,o+=r!==void 0?r:60}return t+=s/(this._column_sizes.indices[t+e-1]||60),Math.max(0,t-1)}_calculate_column_range(e){if(this._virtual_mode==="none"||this._virtual_mode==="vertical")return{start_col:0,end_col:1/0};{let t=this._calc_start_column(),o=this.table_model.num_columns()||Math.min(e,Math.ceil(this._container_size.width/60)),s=t+o+1;return{start_col:t,end_col:s}}}_max_scroll_column(e){let t=0;if(this._view_cache.config.row_pivots.length>0)for(let r of this._column_sizes.indices.slice(0,this._view_cache.config.row_pivots.length))t+=r;let o=this._view_cache.config.row_pivots.length,s=e;for(;t<this._container_size.width&&s>=0;)s--,t+=this._column_sizes.indices[s+o]||60;return Math.min(e-1,s+1)}_validate_viewport({start_col:e,end_col:t,start_row:o,end_row:s}){o=Math.floor(o),s=Math.ceil(s),e=Math.floor(e),t=Math.ceil(t);let r=this._start_col!==e,l=this._start_row!==o||this._end_row!==s||this._end_col!==t;return this._start_col=e,this._end_col=t,this._start_row=o,this._end_row=s,{invalid_column:r,invalid_row:l}}_calc_scrollable_column_width(e){let t=this._view_cache.config.row_pivots.length,o=this._max_scroll_column(e),s=t,r=0;for(;s<o+t;)r+=this._column_sizes.indices[s]||60,s++;if(s<this._column_sizes.indices.length){let l=this._column_sizes.indices.slice(0,this._view_cache.config.row_pivots.length).reduce((i,n)=>i+n,0);r+=Math.max(0,this._column_sizes.indices[s]-(this._container_size.width-l)||0)}return r}_update_virtual_panel_width(e,t){if(e)if(this._virtual_mode==="vertical"||this._virtual_mode==="none")this._virtual_panel.style.width=this._column_sizes.indices.reduce((o,s)=>o+s,0)+"px";else{let o=this._calc_scrollable_column_width(t);if(o!==0){let s=this._container_size.width+o+2;this._virtual_panel.style.width=s+"px"}else this._virtual_panel.style.width="1px"}}_update_virtual_panel_height(e){let{row_height:t=19}=this._column_sizes,o=this._view_cache.config.column_pivots.length*t,s;s=Math.min(es,e*t+o),this._virtual_panel.style.height=`${s}px`}async draw(e={}){return typeof e.throttle<"u"&&!e.throttle?await Ft.call(this,e):await Vt(this,()=>Ft.call(this,e))}async _draw_flush(){await ss(this)}update_sub_cell_offset(e){let t=this._column_sizes.row_height*(e.start_row%1)||0,o=this._column_sizes.indices[(this.table_model._row_headers_length||0)+Math.floor(e.start_col)]*(e.start_col%1)||0,s=this._sub_cell_style.sheet?.cssRules[0].style;s&&(s.setProperty("--regular-table--clip-x",`${o}px`),s.setProperty("--regular-table--clip-y",`${t}px`),s.setProperty("--regular-table--transform-x",`-${o}px`),s.setProperty("--regular-table--transform-y",`-${t}px`))}};async function Ft(e){let t=Xt&&performance.now(),{invalid_viewport:o=!0,preserve_width:s=!1}=e,{num_columns:r,num_rows:l,num_row_headers:i,num_column_headers:n,row_height:a}=await this._view_cache.view(0,0,0,0);i!==void 0&&(this._view_cache.row_pivots=Array(i).fill(0)),n!==void 0&&(this._view_cache.column_pivots=Array(n).fill(0)),this._container_size={width:this._virtual_mode==="none"||this._virtual_mode==="vertical"?1/0:this._table_clip.clientWidth,height:this._virtual_mode==="none"||this._virtual_mode==="horizontal"?1/0:this._table_clip.clientHeight},this._update_virtual_panel_height(l),s||this._update_virtual_panel_width(o,r);let c=this._calculate_viewport(l,r),{invalid_row:d,invalid_column:h}=this._validate_viewport(c);if(this._invalid_schema||d||h||o){let p=[],u=!0;for await(let m of this.table_model.draw(this._container_size,this._view_cache,this._selected_id,s,c,r)){m!==void 0&&(p=p.concat(m)),u&&(this.update_sub_cell_offset(c),u=!1),this._is_styling=!0;let E=this._style_callbacks;for(let b of E)await b({detail:this});if(this._is_styling=!1,!this._invalidated&&m!==void 0)break;this._invalidated=!1}this.table_model.autosize_cells(p,a),this.table_model.header.reset_header_cache(),s||this._update_virtual_panel_width(this._invalid_schema||h,r),this._invalid_schema=!1}else this.update_sub_cell_offset(c);Xt&&os(performance.now()-t)}var as=!1,cs=class extends ns{register_listeners(){this.addEventListener("mousedown",this._on_click_or_dblclick.bind(this)),this.addEventListener("scroll",this._on_scroll.bind(this),{passive:!0}),this._register_glitch_scroll_listeners()}async _on_scroll(e){e.stopPropagation(),await this.draw({invalid_viewport:!1}),this.dispatchEvent(new CustomEvent("regular-table-scroll"))}_register_glitch_scroll_listeners(){this.addEventListener("mousewheel",this._on_mousewheel.bind(this),{passive:!0}),as&&(this.addEventListener("touchmove",this._on_touchmove.bind(this)),this.addEventListener("touchstart",this._on_touchstart.bind(this),{passive:!0}))}_on_mousewheel(e){if(!window.safari)return;let{clientWidth:t,clientHeight:o,scrollTop:s,scrollLeft:r}=this;e.preventDefault(),e.returnValue=!1;let l=Math.max(1,this._virtual_panel.offsetHeight-o),i=Math.max(1,this._virtual_panel.offsetWidth-t);this.scrollTop=Math.max(0,Math.min(l,s+e.deltaY)),this.scrollLeft=Math.max(0,Math.min(i,r+e.deltaX)),this._on_scroll(e)}_on_touchmove(e){e.stopPropagation(),e.preventDefault(),e.returnValue=!1;let{clientWidth:t,clientHeight:o}=this,s=Math.max(1,this._virtual_panel.offsetHeight-o),r=Math.max(1,this._virtual_panel.offsetWidth-t);this.scrollTop=Math.min(s,this._memo_scroll_top+(this._memo_touch_startY-e.touches[0].pageY)),this.scrollLeft=Math.min(r,this._memo_scroll_left+(this._memo_touch_startX-e.touches[0].pageX)),this._on_scroll(e)}_on_touchstart(e){this._memo_touch_startY=e.touches[0].pageY,this._memo_touch_startX=e.touches[0].pageX,this._memo_scroll_top=this.scrollTop,this._memo_scroll_left=this.scrollLeft}async _on_dblclick(e){let t=e.target;for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let o=e.target.classList.contains("rt-column-resize"),s=xe.get(t);if(o){e.stopImmediatePropagation(),t.style.minWidth="",t.style.maxWidth="",e.shiftKey?(this._column_sizes.override=[],this._column_sizes.auto=[],this._column_sizes.indices=[]):(this._column_sizes.override[s.size_key]=void 0,this._column_sizes.auto[s.size_key]=void 0,this._column_sizes.indices[s.size_key]=void 0);for(let r 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 l of e.shiftKey?r:[r[s._virtual_x]])l&&(l.style.minWidth="",l.style.maxWidth="",l.classList.remove("rt-cell-clip"));await this.draw()}}async _on_click(e){if(e.button!==0)return;let t=e.target;for(;t.tagName!=="TD"&&t.tagName!=="TH";)if(t=t.parentElement,!this.contains(t))return;let o=e.target.classList.contains("rt-column-resize"),s=xe.get(t);o&&(this._on_resize_column(e,t,s),e.stopImmediatePropagation())}async _on_click_or_dblclick(e){let t=performance.now();this._last_clicked_time&&t-this._last_clicked_time<500?(this._last_clicked_time=t,await this._on_dblclick(e)):(this._last_clicked_time=t,await this._on_click(e))}_on_resize_column(e,t,o){let{_virtual_x:s,size_key:r}=o,l=e.pageX,i=s+t.colSpan-1,n=this.table_model.header.get_column_header(i),a=this._column_sizes.indices[r],c=h=>Vt(this,async()=>await this._on_resize_column_move(h,n,l,a,r,i)),d=()=>{document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",d);let h=this._column_sizes.override[r],p=this._column_sizes.indices[r]!==h;this._column_sizes.indices[r]=h,p&&this.draw()};document.addEventListener("mousemove",c),document.addEventListener("mouseup",d)}async _on_resize_column_move(e,t,o,s,r,l){await new Promise(requestAnimationFrame);let i=e.pageX-o,n=Math.max(1,s+i);if(this._column_sizes.override[r]=n,i<0)await this.draw({preserve_width:!0,throttle:!1});else{t.style.minWidth=n+"px",t.style.maxWidth=n+"px";let a=this._column_sizes.auto[r];for(let c of this.table_model.body.cells){let d=c[l];d&&(d.style.maxWidth=d.style.minWidth=n+"px",d.classList.toggle("rt-cell-clip",a>n))}}}},ds=class{constructor(e){this._name=e,this._elements=[],this._index=0}reset(){this._index=0}get(){this._elements[this._index]||(this._elements[this._index]=document.createElement(this._name));let e=this._elements[this._index];return this._index+=1,e}},Jt=class{constructor(e,t,o){this._column_sizes=e,this._container=t,this._span_factory=new ds("span"),this.table=o,this.cells=[],this.rows=[]}num_columns(){return this._get_row(Math.max(0,this.rows.length-1)).row_container.length}num_rows(){return this.cells.length}_set_metadata(e,t){xe.set(e,t)}_get_or_create_metadata(e){if(e===void 0)return{};if(xe.has(e))return xe.get(e);{let t={};return xe.set(e,t),t}}_replace_cell(e,t){let{tr:o,row_container:s}=this._get_row(e),r=s[t];return r&&(o.removeChild(r),s.splice(t,1,void 0)),r}_fetch_cell(e,t){if(!(e<0||t<0))return this.cells[e]?.[t]}_get_row(e){let t=this.rows[e];t||(t=this.rows[e]=document.createElement("tr"),this.table.appendChild(t));let o=this.cells[e];return o||(o=this.cells[e]=[]),{tr:t,row_container:o}}_get_cell(e="TD",t,o){let{tr:s,row_container:r}=this._get_row(t),l=r[o];if(l||(o<r.length?(l=r[o]=document.createElement(e),s.insertBefore(l,r.slice(o+1).find(i=>i))):(l=r[o]=document.createElement(e),s.appendChild(l))),l.tagName!==e){let i=document.createElement(e);s.replaceChild(i,l),this.cells[t].splice(o,1,i),l=i}return l}_clean_columns(e){for(let t=0;t<this.rows.length;t++){let o=this.rows[t],s=this.cells[t];this.cells[t]=s.slice(0,e[t]||e);let r=this.cells[t].filter(l=>l!==void 0).length;for(;o.children[r];)o.removeChild(o.children[r])}}_clean_rows(e){for(;this.table.children[e];)this.table.removeChild(this.table.children[e]);this.rows=this.rows.slice(0,e),this.cells=this.cells.slice(0,e)}},hs=class extends Jt{constructor(...e){super(...e),this._group_header_cache=[],this._offset_cache=[]}_draw_group_th(e,t,o){let s=this._get_cell("TH",t,e[t]||0);if(e[t]+=1,s.removeAttribute("colspan"),s.style.minWidth="0",s.textContent="",o instanceof HTMLElement)s.appendChild(o);else{let l=this._span_factory.get("span");l.textContent=o,s.appendChild(l)}let r=this._span_factory.get("span");return r.className="rt-column-resize",s.appendChild(r),s}_draw_group(e,t,o){let s=this._get_or_create_metadata(o);return s.column_header=e,s.value=t,s.value=t,s}_draw_th(e,t,o,s,r){let l=this._get_or_create_metadata(o);if(l.column_header=e,l.value=t,l.size_key=r.length?r[0]:r,!(r.length>1)){let i=this._column_sizes.override[l.size_key],n=this._column_sizes.auto[l.size_key];i?(o.classList.toggle("rt-cell-clip",n>i),o.style.minWidth=i+"px",o.style.maxWidth=i+"px"):n?(o.classList.remove("rt-cell-clip"),o.style.maxWidth="",o.style.minWidth=n+"px"):(o.style.maxWidth="",o.style.maxWidth="")}return l}get_column_header(e){return this._get_cell("TH",this.num_rows()-1,e)}draw(e,t,o,s,r,l,i,n,a){let c=t?.length;if(c===0)return;let d,h,p,u;n=typeof n>"u"?c-1:n;for(let m=0;m<c;m++){if(p=t[m]?t[m]:"",this._offset_cache[m]=this._offset_cache[m]||0,m<n)a&&this._group_header_cache?.[m]?.[0]?.value===p?(d=this._group_header_cache[m][1],this._group_header_cache[m][2]+=1,o===1&&(this._group_header_cache[m][0].row_header_x=r),d.setAttribute("colspan",this._group_header_cache[m][2])):(d=this._draw_group_th(this._offset_cache,m,p),h=this._draw_group(t,p,d),this._group_header_cache[m]=[h,d,1]);else{d=this._draw_group_th(this._offset_cache,m,p),h=this._draw_th(e||t,p,d,s,r),typeof u>"u"&&(u={th:d,metadata:h});for(let[E]of this._group_header_cache)E.size_key=h.size_key;d.removeAttribute("colspan")}this._get_row(m).tr.classList.toggle("rt-autosize",m===n),d.classList.toggle("rt-group-corner",s===void 0),h&&(h.x=typeof s>"u"?s:Math.floor(s),h.column_header_y=m,h.x0=Math.floor(l),h._virtual_x=i,o===1&&(h.row_header_x=r))}return this._clean_rows(this._offset_cache.length),u=u||{th:d,metadata:h},u}clean(){this._clean_columns(this._offset_cache)}reset_header_cache(){this._offset_cache=[],this._group_header_cache=[]}},fs=class extends Jt{_draw_td(e,t,o,s,{column_name:r},{ridx_offset:l},i){let n=this._get_cell(e,t,s),a=this._get_or_create_metadata(n);a.y=t+Math.floor(l),a.size_key=i,e==="TD"&&(a.column_header=r);let c=this._column_sizes.override[a.size_key];if(c){let d=this._column_sizes.auto[a.size_key];n.classList.toggle("rt-cell-clip",d>c),n.style.minWidth=c+"px",n.style.maxWidth=c+"px"}else n.classList.remove("rt-cell-clip"),n.style.minWidth="",n.style.maxWidth="";return a.value!==o&&(o instanceof HTMLElement?(n.textContent="",n.appendChild(o)):n.textContent=o),a.value=o,{td:n,metadata:a}}draw(e,t,o,s=!1,r,l,i,n){let{cidx:a,column_data:c,row_headers:d,column_data_listener_metadata:h}=t,{row_height:p}=o,u,m=[],E=[],b=0,y=[];for(let S=0;S<(s?o.row_headers_length:1);S++){b=0;for(let T of c){let P=d?.[b],k;if(s){let R=T[S],_=this._fetch_cell(b-(m[S]||1),a+S),v=this._get_or_create_metadata(_),w=this._fetch_cell(b,a+S-(y[b]||1)),x=this._get_or_create_metadata(w);n&&w&&(x.value===R||R===void 0)&&!w.hasAttribute("rowspan")?(y[b]=y[b]?y[b]+1:2,w.setAttribute("colspan",y[b]),this._replace_cell(b,a+S)):n&&_&&v.value===R&&!_.hasAttribute("colspan")?(m[S]=m[S]?m[S]+1:2,_.setAttribute("rowspan",m[S]),this._replace_cell(b,a+S)):(k=this._draw_td("TH",b,R,a+S,t,o,S),k.td.style.display="",k.td.removeAttribute("rowspan"),k.td.removeAttribute("colspan"),k.metadata.row_header=T,k.metadata.row_header_x=S,k.metadata.y0=Math.floor(o.ridx_offset),k.metadata.y1=Math.ceil(o.y1),k.metadata._virtual_x=S,typeof l<"u"&&(k.metadata.x0=Math.floor(l)),m[S]=1,y[b]=1,E[S]=k)}else k=this._draw_td("TD",b,T,a,t,o,i),h&&(k.metadata.user=h[b]),k.metadata.x=typeof r>"u"?r:Math.floor(r),k.metadata.x1=Math.ceil(o.x1),k.metadata.row_header=P||[],k.metadata.y0=Math.floor(o.ridx_offset),k.metadata.y1=Math.ceil(o.y1),k.metadata.dx=Math.floor(r-l),k.metadata.dy=k.metadata.y-Math.floor(k.metadata.y0),k.metadata._virtual_x=a,typeof l<"u"&&(k.metadata.x0=Math.floor(l)),E[0]=k;if(b++,u=k?k.metadata:u,p=p||k?.td.offsetHeight,b*p>e)break}}return this._clean_rows(b),{tds:E,ridx:b,metadata:u,row_height:p}}clean({ridx:e,cidx:t}){this._clean_rows(e),this._clean_columns(t)}},Zt=class{constructor(e,t,o){this.clear(o);let[s]=o.children,[r,l]=s.children;this.table=s,this._column_sizes=t,this.header=new hs(t,e,r),this.body=new fs(t,e,l),this.fragment=document.createDocumentFragment()}num_columns(){return this.header.num_columns()}clear(e){e.innerHTML=Kt`
11
+ <table cellspacing="0">
12
+ <thead></thead>
13
+ <tbody></tbody>
14
+ </table>
15
+ `}autosize_cells(e,t){for(;e.length>0;){let[o,s]=e.pop(),r=o.getBoundingClientRect();if(!r||(this._column_sizes.row_height=t||Math.max(10,Math.min(this._column_sizes.row_height||r.height,r.height)),!s))continue;this._column_sizes.indices[s.size_key]=r.width;let l=this._column_sizes.override[s.size_key]!==void 0;r.width&&!l&&(this._column_sizes.auto[s.size_key]=r.width),o.style.minWidth==="0px"&&(o.style.minWidth=`${r.width}px`)}}async*draw(e,t,o,s,r,l){let{width:i,height:n}=e,{view:a,config:c}=t,{data:d,row_headers:h,column_headers:p,metadata:u,num_row_headers:m,num_column_headers:E,column_header_merge_depth:b,merge_headers:y="both"}=await a(Math.floor(r.start_col),Math.floor(r.start_row),Math.ceil(r.end_col),Math.ceil(r.end_row)),S=y==="both"||y==="row",T=y==="both"||y==="column",{start_row:P=0,start_col:k=0,end_col:R=0,end_row:_=0}=r;h&&(this._row_headers_length=h.reduce((z,W)=>Math.max(z,W.length),0),h=h.map(z=>(z.length=this._row_headers_length,z))),m!==void 0?t.config.row_pivots=Array(m).fill(0):t.config.row_pivots=Array(h?.[0]?.length||0).fill(0),E!==void 0?t.config.column_pivots=Array(E).fill(0):t.config.column_pivots=Array(p?.[0]?.length||0).fill(0);let v=this._column_sizes.indices[(this._row_headers_length||0)+Math.floor(r.start_col)]||0,w={viewport_width:0,selected_id:o,ridx_offset:P,sub_cell_offset:v,x0:k,x1:R,y1:_,row_height:this._column_sizes.row_height,row_headers_length:this._row_headers_length},x,C=0,A=[],N=!0;if(h?.length>0){let z=c.row_pivots.join(","),W={column_name:z,cidx:0,column_data:h,row_headers:h,first_col:N},oe=C+Math.floor(k);x=this.body.draw(n,W,{...w,x0:0},!0,void 0,void 0,oe,S);let H=[];for(let U=0;U<t.config.row_pivots.length;U++){let J=this.header.draw(z,Array(t.config.column_pivots.length).fill(""),1,void 0,U,k,U,b,T);J&&H.push(J)}if(N=!1,w.viewport_width+=H.reduce((U,{th:J},ge)=>U+(this._column_sizes.indices[ge]||J.offsetWidth),0),w.row_height=w.row_height||x.row_height,C=h[0].length,!s)for(let U=0;U<t.config.row_pivots.length;U++){let{td:J,metadata:ge}=x.tds[U]||{},{th:ye,metadata:we}=H[U]||{};(J||ye)&&A.push([ye||J,we||ge])}}try{let z=0,W=l-r.start_col;for(;z<W;){if(!d[z]){let ie=Math.max(r.end_col,0);r.start_col=ie;let ce=0,vt=0;for(;this._column_sizes.indices.length>C+k+ce+1&&vt+w.viewport_width<i;)ce++,vt+=this._column_sizes.indices[C+k+ce];if(vt+w.viewport_width<i){let re=Math.min(l,ie+5);r.end_col=Math.max(1,Math.min(l,re))}else r.end_col=Math.max(1,Math.min(l,ie+ce));let Jr=a(Math.floor(r.start_col),Math.floor(r.start_row),Math.ceil(r.end_col),Math.ceil(r.end_row));yield void 0;let Q=await Jr;if(typeof Q.column_header_merge_depth<"u"&&(b=Q.column_header_merge_depth),typeof Q.merge_headers<"u"&&(y=Q.merge_headers),Q.data.length===0){yield A;return}r.end_col=r.start_col+Q.data.length;for(let re=0;re<Q.data.length;re++)d[z+re]=Q.data[re],Q.metadata&&(u[z+re]=Q.metadata[re]),p&&(p[z+re]=Q.column_headers?.[re])}let oe=p?.[z]||"",H=d[z],U=u?.[z],J={column_name:oe,cidx:C,column_data:H,column_data_listener_metadata:U,row_headers:h,first_col:N},ge=z+k,ye=C+Math.floor(k),we=this.header.draw(void 0,oe,void 0,ge,ye,k,C,b,T);if(x=this.body.draw(n,J,w,!1,ge,k,ye,S),N=!1,!s)for(let{td:ie,metadata:ce}of x.tds)A.push([we?.th||ie,we?.metadata||ce]);let Le=this._column_sizes.indices[C+Math.floor(k)];if(Le?w.viewport_width+=Le:w.viewport_width+=we?.th?.offsetWidth||x.tds.reduce((ie,ce)=>ie+ce.td?.offsetWidth,0),w.row_height=w.row_height||x.row_height,C++,z++,w.viewport_width-w.sub_cell_offset>i){this.body.clean({ridx:x?.ridx||0,cidx:C}),this.header.clean(),yield A,w.viewport_width=0;for(let[ie]of A)w.viewport_width+=ie.offsetWidth;if(w.viewport_width-w.sub_cell_offset>i)return}}this.body.clean({ridx:x?.ridx||0,cidx:C}),this.header.clean(),yield A}finally{this.body.clean({ridx:x?.ridx||0,cidx:C}),this.header.clean(),this.body._span_factory.reset(),this.header._span_factory.reset()}}},ps=["both","horizontal","vertical","none"],_s=class extends cs{constructor(){super(),this._column_sizes={auto:[],override:[],indices:[]},this._style_callbacks=[],this._initialized=!1}connectedCallback(){this._initialized||(this.create_shadow_dom(),this.register_listeners(),this.setAttribute("tabindex","0"),this._initialized=!0,this.table_model=new Zt(this._table_clip,this._column_sizes,this))}_reset_viewport(){this._start_row=void 0,this._end_row=void 0,this._start_col=void 0,this._end_col=void 0}_reset_scroll(){this._column_sizes.indices=[],this.scrollTop=0,this.scrollLeft=0,this._reset_viewport()}_resetAutoSize(){this._column_sizes.auto=[],this._column_sizes.override=[],this._column_sizes.indices=[];for(let e=0;e<this.table_model.header.num_columns();e++){let t=this.table_model.header.get_column_header(e);t.style.minWidth="",t.style.maxWidth=""}}clear(){this.table_model=new Zt(this._table_clip,this._column_sizes,this)}addStyleListener(e){this._style_callbacks=this._style_callbacks.concat(e);let t=!0;return()=>{if(!t)return;t=!1;let o=this._style_callbacks=this._style_callbacks.slice(),s=o.indexOf(e);o.splice(s,1)}}removeStyleListener(e){let t=this._style_callbacks.length;this._style_callbacks=this._style_callbacks.filter(o=>o!==e),console.assert(this._style_callbacks.length===t-1,"No listener found")}invalidate(){if(!this._is_styling)throw new Error("Cannot call `invalidate()` outside of a `StyleListener`");this._invalidated=!0}getMeta(e){if(!(typeof e>"u")){if(e instanceof HTMLElement)return xe.get(e);if(e.row_header_x>=0){if(e.row_header_x<this._view_cache.config.row_pivots.length){let t=this.table_model.body._fetch_cell(e.y,e.row_header_x);return this.getMeta(t)}}else if(e.column_header_y>=0){if(e.column_header_y<this._view_cache.config.column_pivots.length){let t=this.table_model.body._fetch_cell(e.column_header_y,e.y);return this.getMeta(t)}}else return this.getMeta(this.table_model.body._fetch_cell(e.dy,e.dx+this.table_model._row_headers_length))}}getDrawFPS(){return ts()}async scrollToCell(e,t){if(!this._view_cache){console.warn("data listener not configured");return}let o=this._column_sizes.row_height||19,s=this._view_cache.config.column_pivots.length*o,r=(this._table_clip.offsetHeight-s)%o,l=(this._virtual_panel.offsetHeight-r)/this._nrows;this.scrollTop=Math.ceil(l*t);let i=0;for(;e>0;)e--,i+=this._column_sizes.indices[e+this._view_cache.config.row_pivots.length]||60;this.scrollLeft=Math.ceil(i),await new Promise(requestAnimationFrame),await this._draw_flush()}setDataListener(e,{virtual_mode:t="both",preserve_state:o=!1}={}){console.assert(ps.indexOf(t)>-1,`Unknown virtual_mode ${t}; valid options are "both" (default), "horizontal", "vertical" or "none"`);let s=this._virtual_mode!==t;if(o)console.assert(!s,"preserve_state called with modified virtual_mode"),this._view_cache.view=e;else{let r={row_pivots:[],column_pivots:[]};this._virtual_mode=t,this._invalid_schema=!0,this._view_cache={view:e,config:r},s&&this._setup_virtual_scroll()}}__noop_jsdoc_hints(){}};document.createElement("regular-table").constructor===HTMLElement&&window.customElements.define("regular-table",_s);var Y=Symbol("Plugin Symbol");function ms(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}function kt(e,t,o){let s=Array.from(e.children[0].children[0].children),r=s.length,l=t.hasAttribute("settings");if(r<=1?s[0]?.removeAttribute("id"):s.forEach((i,n)=>{let a=l?1:0,c=n===r-(a+1)?"psp-column-titles":n===r-a?"psp-column-edit-buttons":null;c?i.setAttribute("id",c):i.removeAttribute("id")}),t.classList.toggle("psp-menu-open",!!o),l&&r>=2){let i=Array.from(s[r-2].children),n=Array.from(s[r-1].children);if(i&&n){s.slice(0,r-2).forEach(a=>{Array.from(a.children).forEach(c=>{c.classList.toggle("psp-menu-open",!1)})});for(let a=0;a<i.length;a++){let c=i[a],d=n[a],h=c.textContent===o;if(c.classList.toggle("psp-menu-open",h),d.classList.toggle("psp-menu-open",h),this._config.columns.length>1)for(let p of e.querySelectorAll("td")){let u=e.getMeta(p),m=u.column_header[u.column_header.length-2]===o;p.classList.toggle("psp-menu-open",m)}}}}}function eo(e,t){let o=Array.from(e.children[0].children[0].children);if(o.length>0){kt.call(this,e,t,this._column_settings_selected_column);let[s]=o.splice(this._config.split_by.length,1);s&&Qt.call(this,e,s,!1);let[r]=o.splice(this._config.split_by.length,1);r&&Qt.call(this,e,r,!0)}}function Qt(e,t,o){let s=e._view_cache.config.row_pivots.length-1;for(let r of t.children){let l=e.getMeta(r),i=l.column_header?.[this._config.split_by.length],n=this._config.sort.find(E=>E[0]===i),a=l.row_header_x===s,c=typeof l.x>"u";a=a||(l.x+1)%this._config.columns.length===0,r.classList.toggle("psp-header-border",a),r.classList.toggle("psp-header-group",!1),r.classList.toggle("psp-header-leaf",!0),r.classList.toggle("psp-is-top",!1),r.classList.toggle("psp-header-corner",c),r.classList.toggle("psp-header-sort-asc",!o&&!!n&&n[1]==="asc"),r.classList.toggle("psp-header-sort-desc",!o&&!!n&&n[1]==="desc"),r.classList.toggle("psp-header-sort-col-asc",!o&&!!n&&n[1]==="col asc"),r.classList.toggle("psp-header-sort-col-desc",!o&&!!n&&n[1]==="col desc"),r.classList.toggle("psp-header-sort-abs-asc",!o&&!!n&&n[1]==="asc abs"),r.classList.toggle("psp-header-sort-abs-desc",!o&&!!n&&n[1]==="desc abs"),r.classList.toggle("psp-header-sort-abs-col-asc",!o&&!!n&&n[1]==="col asc abs"),r.classList.toggle("psp-header-sort-abs-col-desc",!o&&!!n&&n[1]==="col desc abs");let d=ms.call(this,l),h=d==="integer"||d==="float",p=d==="string",u=d==="date",m=d==="datetime";r.classList.toggle("psp-align-right",h),r.classList.toggle("psp-align-left",!h),r.classList.toggle("psp-menu-enabled",(p||h||u||m)&&!c&&l.column_header_y==this._config.split_by.length+1),r.classList.toggle("psp-sort-enabled",(p||h||u||m)&&!c&&l.column_header_y===this._config.split_by.length),r.classList.toggle("psp-is-width-override",e._column_sizes?.override[l.size_key]!==void 0)}}function to(e){let t=e._view_cache.config.row_pivots.length-1,o=Array.from(e.children[0].children[0].children),s=[],r=new Set,l=e.children[0];for(let i=0;i<o.length;i++){let n=l.rows[i],a=new Set;for(let c=0;c<n.cells.length;c++){let d=n.cells[c];d.style.backgroundColor="";let h=e.getMeta(d),p=t>0&&h.row_header_x===t||h.x>=0;d.classList.toggle("psp-align-right",!1),d.classList.toggle("psp-align-left",!1),d.classList.toggle("psp-header-group",!0),d.classList.toggle("psp-header-leaf",!1),d.classList.toggle("psp-header-border",p),d.classList.toggle("psp-header-group-corner",typeof h.x>"u"),d.classList.toggle("psp-color-mode-bar",!1),d.classList.toggle("psp-header-sort-asc",!1),d.classList.toggle("psp-header-sort-desc",!1),d.classList.toggle("psp-header-sort-col-asc",!1),d.classList.toggle("psp-header-sort-col-desc",!1),d.classList.toggle("psp-sort-enabled",!1);let u=n.cells[c],m=c,E,b;for(;s[i]&&s[i][m];++m);for(a.add(m),E=m;E<m+u.colSpan;++E)for(b=i;b<i+u.rowSpan;++b)s[b]||(s[b]=[]),s[b][E]=!0;u.classList.toggle("psp-is-top",i===0||!r.has(E))}r=a}}function oo(e,t,[,,,,,o,s],[,,,,,r,l],i){let n=this._ids?.[e.dy]?.join("|"),a=(i?e.column_header.slice(0,-1):e.column_header).join("|");if(this.last_reverse_columns?.has(a)&&this.last_reverse_ids?.has(n)){let c=this.last_reverse_ids?.get(n),d=this.last_reverse_columns.get(a);this._is_old_viewport?this.last_meta?.[d]?.[c]>e.user?(t.style.setProperty("--pulse--background-color-start",r),t.style.setProperty("--pulse--background-color-end",l),t.style.animationName==="pulse_neg"?t.style.animation="pulse_neg2 0.5s linear":t.style.animation="pulse_neg 0.5s linear"):this.last_meta?.[d]?.[c]<e.user?(t.style.setProperty("--pulse--background-color-start",o),t.style.setProperty("--pulse--background-color-end",s),t.style.animationName==="pulse_pos"?t.style.animation="pulse_pos2 0.5s linear":t.style.animation="pulse_pos 0.5s linear"):c!==e.dy&&(t.style.animation=""):t.style.animation=""}else t.style.animation=""}var{min:us,max:bs}=Math,X=(e,t=0,o=1)=>us(bs(t,e),o);var ve=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=X(e[t],0,255)):t===3&&(e[t]=X(e[t],0,1));return e};var ro={};for(let e of["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"])ro[`[object ${e}]`]=e.toLowerCase();function L(e){return ro[Object.prototype.toString.call(e)]||"object"}var g=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):L(e[0])=="object"&&t?t.split("").filter(o=>e[0][o]!==void 0).map(o=>e[0][o]):e[0].slice(0);var B=e=>{if(e.length<2)return null;let t=e.length-1;return L(e[t])=="string"?e[t].toLowerCase():null};var{PI:qe,min:Fe,max:Ze}=Math,j=e=>Math.round(e*100)/100,Ie=e=>Math.round(e*100)/100,q=qe*2,Ke=qe/3,so=qe/180,lo=180/qe;function Ve(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var M={format:{},autodetect:[]};var Et=class{constructor(...t){let o=this;if(L(t[0])==="object"&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];let s=B(t),r=!1;if(!s){r=!0,M.sorted||(M.autodetect=M.autodetect.sort((l,i)=>i.p-l.p),M.sorted=!0);for(let l of M.autodetect)if(s=l.test(...t),s)break}if(M.format[s]){let l=M.format[s].apply(null,r?t:t.slice(0,-1));o._rgb=ve(l)}else throw new Error("unknown format: "+t);o._rgb.length===3&&o._rgb.push(1)}toString(){return L(this.hex)=="function"?this.hex():`[${this._rgb.join(",")}]`}},f=Et;var io="3.1.2";var no=(...e)=>new f(...e);no.version=io;var O=no;var gs={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},he=gs;var ys=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ws=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,xs=e=>{if(e.match(ys)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16),o=t>>16,s=t>>8&255,r=t&255;return[o,s,r,1]}if(e.match(ws)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(""),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16),o=t>>24&255,s=t>>16&255,r=t>>8&255,l=Math.round((t&255)/255*100)/100;return[o,s,r,l]}throw new Error(`unknown hex color: ${e}`)},Je=xs;var{round:Qe}=Math,vs=(...e)=>{let[t,o,s,r]=g(e,"rgba"),l=B(e)||"auto";r===void 0&&(r=1),l==="auto"&&(l=r<1?"rgba":"rgb"),t=Qe(t),o=Qe(o),s=Qe(s);let n="000000"+(t<<16|o<<8|s).toString(16);n=n.substr(n.length-6);let a="0"+Qe(r*255).toString(16);switch(a=a.substr(a.length-2),l.toLowerCase()){case"rgba":return`#${n}${a}`;case"argb":return`#${a}${n}`;default:return`#${n}`}},et=vs;f.prototype.name=function(){let e=et(this._rgb,"rgb");for(let t of Object.keys(he))if(he[t]===e)return t.toLowerCase();return e};M.format.named=e=>{if(e=e.toLowerCase(),he[e])return Je(he[e]);throw new Error("unknown color name: "+e)};M.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&L(e)==="string"&&he[e.toLowerCase()])return"named"}});f.prototype.alpha=function(e,t=!1){return e!==void 0&&L(e)==="number"?t?(this._rgb[3]=e,this):new f([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]};f.prototype.clipped=function(){return this._rgb._clipped||!1};var $e={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:.008856451679035631,kKE:8,kK:903.2962962962963,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},se=$e,ks=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function F(e){let t=ks.get(String(e).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+e);$e.labWhitePoint=e,$e.Xn=t[0],$e.Zn=t[1]}function fe(){return $e.labWhitePoint}var Es=(...e)=>{e=g(e,"lab");let[t,o,s]=e,[r,l,i]=Ls(t,o,s),[n,a,c]=Mt(r,l,i);return[n,a,c,e.length>3?e[3]:1]},Ls=(e,t,o)=>{let{kE:s,kK:r,kKE:l,Xn:i,Yn:n,Zn:a}=se,c=(e+16)/116,d=.002*t+c,h=c-.005*o,p=d*d*d,u=h*h*h,m=p>s?p:(116*d-16)/r,E=e>l?Math.pow((e+16)/116,3):e/r,b=u>s?u:(116*h-16)/r,y=m*i,S=E*n,T=b*a;return[y,S,T]},Lt=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055)*t},Mt=(e,t,o)=>{let{MtxAdaptMa:s,MtxAdaptMaI:r,MtxXYZ2RGB:l,RefWhiteRGB:i,Xn:n,Yn:a,Zn:c}=se,d=n*s.m00+a*s.m10+c*s.m20,h=n*s.m01+a*s.m11+c*s.m21,p=n*s.m02+a*s.m12+c*s.m22,u=i.X*s.m00+i.Y*s.m10+i.Z*s.m20,m=i.X*s.m01+i.Y*s.m11+i.Z*s.m21,E=i.X*s.m02+i.Y*s.m12+i.Z*s.m22,b=(e*s.m00+t*s.m10+o*s.m20)*(u/d),y=(e*s.m01+t*s.m11+o*s.m21)*(m/h),S=(e*s.m02+t*s.m12+o*s.m22)*(E/p),T=b*r.m00+y*r.m10+S*r.m20,P=b*r.m01+y*r.m11+S*r.m21,k=b*r.m02+y*r.m12+S*r.m22,R=Lt(T*l.m00+P*l.m10+k*l.m20),_=Lt(T*l.m01+P*l.m11+k*l.m21),v=Lt(T*l.m02+P*l.m12+k*l.m22);return[R*255,_*255,v*255]},Ce=Es;var Ms=(...e)=>{let[t,o,s,...r]=g(e,"rgb"),[l,i,n]=St(t,o,s),[a,c,d]=Cs(l,i,n);return[a,c,d,...r.length>0&&r[0]<1?[r[0]]:[]]};function Cs(e,t,o){let{Xn:s,Yn:r,Zn:l,kE:i,kK:n}=se,a=e/s,c=t/r,d=o/l,h=a>i?Math.pow(a,1/3):(n*a+16)/116,p=c>i?Math.pow(c,1/3):(n*c+16)/116,u=d>i?Math.pow(d,1/3):(n*d+16)/116;return[116*p-16,500*(h-p),200*(p-u)]}function Ct(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))*t}var St=(e,t,o)=>{e=Ct(e/255),t=Ct(t/255),o=Ct(o/255);let{MtxRGB2XYZ:s,MtxAdaptMa:r,MtxAdaptMaI:l,Xn:i,Yn:n,Zn:a,As:c,Bs:d,Cs:h}=se,p=e*s.m00+t*s.m10+o*s.m20,u=e*s.m01+t*s.m11+o*s.m21,m=e*s.m02+t*s.m12+o*s.m22,E=i*r.m00+n*r.m10+a*r.m20,b=i*r.m01+n*r.m11+a*r.m21,y=i*r.m02+n*r.m12+a*r.m22,S=p*r.m00+u*r.m10+m*r.m20,T=p*r.m01+u*r.m11+m*r.m21,P=p*r.m02+u*r.m12+m*r.m22;return S*=E/c,T*=b/d,P*=y/h,p=S*l.m00+T*l.m10+P*l.m20,u=S*l.m01+T*l.m11+P*l.m21,m=S*l.m02+T*l.m12+P*l.m22,[p,u,m]},Se=Ms;f.prototype.lab=function(){return Se(this._rgb)};var Ss=(...e)=>new f(...e,"lab");Object.assign(O,{lab:Ss,getLabWhitePoint:fe,setLabWhitePoint:F});M.format.lab=Ce;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"lab"),L(e)==="array"&&e.length===3)return"lab"}});f.prototype.darken=function(e=1){let t=this,o=t.lab();return o[0]-=se.Kn*e,new f(o,"lab").alpha(t.alpha(),!0)};f.prototype.brighten=function(e=1){return this.darken(-e)};f.prototype.darker=f.prototype.darken;f.prototype.brighter=f.prototype.brighten;f.prototype.get=function(e){let[t,o]=e.split("."),s=this[t]();if(o){let r=t.indexOf(o)-(t.substr(0,2)==="ok"?2:0);if(r>-1)return s[r];throw new Error(`unknown channel ${o} in mode ${t}`)}else return s};var{pow:Os}=Math,zs=1e-7,As=20;f.prototype.luminance=function(e,t="rgb"){if(e!==void 0&&L(e)==="number"){if(e===0)return new f([0,0,0,this._rgb[3]],"rgb");if(e===1)return new f([255,255,255,this._rgb[3]],"rgb");let o=this.luminance(),s=As,r=(i,n)=>{let a=i.interpolate(n,.5,t),c=a.luminance();return Math.abs(e-c)<zs||!s--?a:c>e?r(i,a):r(a,n)},l=(o>e?r(new f([0,0,0]),this):r(this,new f([255,255,255]))).rgb();return new f([...l,this._rgb[3]])}return Rs(...this._rgb.slice(0,3))};var Rs=(e,t,o)=>(e=Ot(e),t=Ot(t),o=Ot(o),.2126*e+.7152*t+.0722*o),Ot=e=>(e/=255,e<=.03928?e/12.92:Os((e+.055)/1.055,2.4));var D={};var le=(e,t,o=.5,...s)=>{let r=s[0]||"lrgb";if(!D[r]&&!s.length&&(r=Object.keys(D)[0]),!D[r])throw new Error(`interpolation mode ${r} is not defined`);return L(e)!=="object"&&(e=new f(e)),L(t)!=="object"&&(t=new f(t)),D[r](e,t,o).alpha(e.alpha()+o*(t.alpha()-e.alpha()))};f.prototype.mix=f.prototype.interpolate=function(e,t=.5,...o){return le(this,e,t,...o)};f.prototype.premultiply=function(e=!1){let t=this._rgb,o=t[3];return e?(this._rgb=[t[0]*o,t[1]*o,t[2]*o,o],this):new f([t[0]*o,t[1]*o,t[2]*o,o],"rgb")};var{sin:Ns,cos:Ts}=Math,Ps=(...e)=>{let[t,o,s]=g(e,"lch");return isNaN(s)&&(s=0),s=s*so,[t,Ts(s)*o,Ns(s)*o]},tt=Ps;var Ds=(...e)=>{e=g(e,"lch");let[t,o,s]=e,[r,l,i]=tt(t,o,s),[n,a,c]=Ce(r,l,i);return[n,a,c,e.length>3?e[3]:1]},Oe=Ds;var Ws=(...e)=>{let t=Ve(g(e,"hcl"));return Oe(...t)},ao=Ws;var{sqrt:Is,atan2:$s,round:js}=Math,Us=(...e)=>{let[t,o,s]=g(e,"lab"),r=Is(o*o+s*s),l=($s(s,o)*lo+360)%360;return js(r*1e4)===0&&(l=Number.NaN),[t,r,l]},ot=Us;var Gs=(...e)=>{let[t,o,s,...r]=g(e,"rgb"),[l,i,n]=Se(t,o,s),[a,c,d]=ot(l,i,n);return[a,c,d,...r.length>0&&r[0]<1?[r[0]]:[]]},je=Gs;f.prototype.lch=function(){return je(this._rgb)};f.prototype.hcl=function(){return Ve(je(this._rgb))};var Ys=(...e)=>new f(...e,"lch"),Hs=(...e)=>new f(...e,"hcl");Object.assign(O,{lch:Ys,hcl:Hs});M.format.lch=Oe;M.format.hcl=ao;["lch","hcl"].forEach(e=>M.autodetect.push({p:2,test:(...t)=>{if(t=g(t,e),L(t)==="array"&&t.length===3)return e}}));f.prototype.saturate=function(e=1){let t=this,o=t.lch();return o[1]+=se.Kn*e,o[1]<0&&(o[1]=0),new f(o,"lch").alpha(t.alpha(),!0)};f.prototype.desaturate=function(e=1){return this.saturate(-e)};f.prototype.set=function(e,t,o=!1){let[s,r]=e.split("."),l=this[s]();if(r){let i=s.indexOf(r)-(s.substr(0,2)==="ok"?2:0);if(i>-1){if(L(t)=="string")switch(t.charAt(0)){case"+":l[i]+=+t;break;case"-":l[i]+=+t;break;case"*":l[i]*=+t.substr(1);break;case"/":l[i]/=+t.substr(1);break;default:l[i]=+t}else if(L(t)==="number")l[i]=t;else throw new Error("unsupported value for Color.set");let n=new f(l,s);return o?(this._rgb=n._rgb,this):n}throw new Error(`unknown channel ${r} in mode ${s}`)}else return l};f.prototype.tint=function(e=.5,...t){return le(this,"white",e,...t)};f.prototype.shade=function(e=.5,...t){return le(this,"black",e,...t)};var Bs=(e,t,o)=>{let s=e._rgb,r=t._rgb;return new f(s[0]+o*(r[0]-s[0]),s[1]+o*(r[1]-s[1]),s[2]+o*(r[2]-s[2]),"rgb")};D.rgb=Bs;var{sqrt:zt,pow:ze}=Math,Xs=(e,t,o)=>{let[s,r,l]=e._rgb,[i,n,a]=t._rgb;return new f(zt(ze(s,2)*(1-o)+ze(i,2)*o),zt(ze(r,2)*(1-o)+ze(n,2)*o),zt(ze(l,2)*(1-o)+ze(a,2)*o),"rgb")};D.lrgb=Xs;var qs=(e,t,o)=>{let s=e.lab(),r=t.lab();return new f(s[0]+o*(r[0]-s[0]),s[1]+o*(r[1]-s[1]),s[2]+o*(r[2]-s[2]),"lab")};D.lab=qs;var Z=(e,t,o,s)=>{let r,l;s==="hsl"?(r=e.hsl(),l=t.hsl()):s==="hsv"?(r=e.hsv(),l=t.hsv()):s==="hcg"?(r=e.hcg(),l=t.hcg()):s==="hsi"?(r=e.hsi(),l=t.hsi()):s==="lch"||s==="hcl"?(s="hcl",r=e.hcl(),l=t.hcl()):s==="oklch"&&(r=e.oklch().reverse(),l=t.oklch().reverse());let i,n,a,c,d,h;(s.substr(0,1)==="h"||s==="oklch")&&([i,a,d]=r,[n,c,h]=l);let p,u,m,E;return!isNaN(i)&&!isNaN(n)?(n>i&&n-i>180?E=n-(i+360):n<i&&i-n>180?E=n+360-i:E=n-i,u=i+o*E):isNaN(i)?isNaN(n)?u=Number.NaN:(u=n,(d==1||d==0)&&s!="hsv"&&(p=c)):(u=i,(h==1||h==0)&&s!="hsv"&&(p=a)),p===void 0&&(p=a+o*(c-a)),m=d+o*(h-d),s==="oklch"?new f([m,p,u],s):new f([u,p,m],s)};var co=(e,t,o)=>Z(e,t,o,"lch");D.lch=co;D.hcl=co;var Fs=e=>{if(L(e)=="number"&&e>=0&&e<=16777215){let t=e>>16,o=e>>8&255,s=e&255;return[t,o,s,1]}throw new Error("unknown num color: "+e)},ho=Fs;var Zs=(...e)=>{let[t,o,s]=g(e,"rgb");return(t<<16)+(o<<8)+s},fo=Zs;f.prototype.num=function(){return fo(this._rgb)};var Ks=(...e)=>new f(...e,"num");Object.assign(O,{num:Ks});M.format.num=ho;M.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&L(e[0])==="number"&&e[0]>=0&&e[0]<=16777215)return"num"}});var Vs=(e,t,o)=>{let s=e.num(),r=t.num();return new f(s+o*(r-s),"num")};D.num=Vs;var{floor:Js}=Math,Qs=(...e)=>{e=g(e,"hcg");let[t,o,s]=e,r,l,i;s=s*255;let n=o*255;if(o===0)r=l=i=s;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let a=Js(t),c=t-a,d=s*(1-o),h=d+n*(1-c),p=d+n*c,u=d+n;switch(a){case 0:[r,l,i]=[u,p,d];break;case 1:[r,l,i]=[h,u,d];break;case 2:[r,l,i]=[d,u,p];break;case 3:[r,l,i]=[d,h,u];break;case 4:[r,l,i]=[p,d,u];break;case 5:[r,l,i]=[u,d,h];break}}return[r,l,i,e.length>3?e[3]:1]},po=Qs;var el=(...e)=>{let[t,o,s]=g(e,"rgb"),r=Fe(t,o,s),l=Ze(t,o,s),i=l-r,n=i*100/255,a=r/(255-i)*100,c;return i===0?c=Number.NaN:(t===l&&(c=(o-s)/i),o===l&&(c=2+(s-t)/i),s===l&&(c=4+(t-o)/i),c*=60,c<0&&(c+=360)),[c,n,a]},_o=el;f.prototype.hcg=function(){return _o(this._rgb)};var tl=(...e)=>new f(...e,"hcg");O.hcg=tl;M.format.hcg=po;M.autodetect.push({p:1,test:(...e)=>{if(e=g(e,"hcg"),L(e)==="array"&&e.length===3)return"hcg"}});var ol=(e,t,o)=>Z(e,t,o,"hcg");D.hcg=ol;var{cos:Ae}=Math,rl=(...e)=>{e=g(e,"hsi");let[t,o,s]=e,r,l,i;return isNaN(t)&&(t=0),isNaN(o)&&(o=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(i=(1-o)/3,r=(1+o*Ae(q*t)/Ae(Ke-q*t))/3,l=1-(i+r)):t<2/3?(t-=1/3,r=(1-o)/3,l=(1+o*Ae(q*t)/Ae(Ke-q*t))/3,i=1-(r+l)):(t-=2/3,l=(1-o)/3,i=(1+o*Ae(q*t)/Ae(Ke-q*t))/3,r=1-(l+i)),r=X(s*r*3),l=X(s*l*3),i=X(s*i*3),[r*255,l*255,i*255,e.length>3?e[3]:1]},mo=rl;var{min:sl,sqrt:ll,acos:il}=Math,nl=(...e)=>{let[t,o,s]=g(e,"rgb");t/=255,o/=255,s/=255;let r,l=sl(t,o,s),i=(t+o+s)/3,n=i>0?1-l/i:0;return n===0?r=NaN:(r=(t-o+(t-s))/2,r/=ll((t-o)*(t-o)+(t-s)*(o-s)),r=il(r),s>o&&(r=q-r),r/=q),[r*360,n,i]},uo=nl;f.prototype.hsi=function(){return uo(this._rgb)};var al=(...e)=>new f(...e,"hsi");O.hsi=al;M.format.hsi=mo;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"hsi"),L(e)==="array"&&e.length===3)return"hsi"}});var cl=(e,t,o)=>Z(e,t,o,"hsi");D.hsi=cl;var dl=(...e)=>{e=g(e,"hsl");let[t,o,s]=e,r,l,i;if(o===0)r=l=i=s*255;else{let n=[0,0,0],a=[0,0,0],c=s<.5?s*(1+o):s+o-s*o,d=2*s-c,h=t/360;n[0]=h+1/3,n[1]=h,n[2]=h-1/3;for(let p=0;p<3;p++)n[p]<0&&(n[p]+=1),n[p]>1&&(n[p]-=1),6*n[p]<1?a[p]=d+(c-d)*6*n[p]:2*n[p]<1?a[p]=c:3*n[p]<2?a[p]=d+(c-d)*(2/3-n[p])*6:a[p]=d;[r,l,i]=[a[0]*255,a[1]*255,a[2]*255]}return e.length>3?[r,l,i,e[3]]:[r,l,i,1]},Ue=dl;var hl=(...e)=>{e=g(e,"rgba");let[t,o,s]=e;t/=255,o/=255,s/=255;let r=Fe(t,o,s),l=Ze(t,o,s),i=(l+r)/2,n,a;return l===r?(n=0,a=Number.NaN):n=i<.5?(l-r)/(l+r):(l-r)/(2-l-r),t==l?a=(o-s)/(l-r):o==l?a=2+(s-t)/(l-r):s==l&&(a=4+(t-o)/(l-r)),a*=60,a<0&&(a+=360),e.length>3&&e[3]!==void 0?[a,n,i,e[3]]:[a,n,i]},rt=hl;f.prototype.hsl=function(){return rt(this._rgb)};var fl=(...e)=>new f(...e,"hsl");O.hsl=fl;M.format.hsl=Ue;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"hsl"),L(e)==="array"&&e.length===3)return"hsl"}});var pl=(e,t,o)=>Z(e,t,o,"hsl");D.hsl=pl;var{floor:_l}=Math,ml=(...e)=>{e=g(e,"hsv");let[t,o,s]=e,r,l,i;if(s*=255,o===0)r=l=i=s;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let n=_l(t),a=t-n,c=s*(1-o),d=s*(1-o*a),h=s*(1-o*(1-a));switch(n){case 0:[r,l,i]=[s,h,c];break;case 1:[r,l,i]=[d,s,c];break;case 2:[r,l,i]=[c,s,h];break;case 3:[r,l,i]=[c,d,s];break;case 4:[r,l,i]=[h,c,s];break;case 5:[r,l,i]=[s,c,d];break}}return[r,l,i,e.length>3?e[3]:1]},bo=ml;var{min:ul,max:bl}=Math,gl=(...e)=>{e=g(e,"rgb");let[t,o,s]=e,r=ul(t,o,s),l=bl(t,o,s),i=l-r,n,a,c;return c=l/255,l===0?(n=Number.NaN,a=0):(a=i/l,t===l&&(n=(o-s)/i),o===l&&(n=2+(s-t)/i),s===l&&(n=4+(t-o)/i),n*=60,n<0&&(n+=360)),[n,a,c]},go=gl;f.prototype.hsv=function(){return go(this._rgb)};var yl=(...e)=>new f(...e,"hsv");O.hsv=yl;M.format.hsv=bo;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"hsv"),L(e)==="array"&&e.length===3)return"hsv"}});var wl=(e,t,o)=>Z(e,t,o,"hsv");D.hsv=wl;function ke(e,t){let o=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(i=>[i]));let s=t[0].length,r=t[0].map((i,n)=>t.map(a=>a[n])),l=e.map(i=>r.map(n=>Array.isArray(i)?i.reduce((a,c,d)=>a+c*(n[d]||0),0):n.reduce((a,c)=>a+c*i,0)));return o===1&&(l=l[0]),s===1?l.map(i=>i[0]):l}var xl=(...e)=>{e=g(e,"lab");let[t,o,s,...r]=e,[l,i,n]=vl([t,o,s]),[a,c,d]=Mt(l,i,n);return[a,c,d,...r.length>0&&r[0]<1?[r[0]]:[]]};function vl(e){var t=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],o=[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],s=ke(o,e);return ke(t,s.map(r=>r**3))}var Re=xl;var kl=(...e)=>{let[t,o,s,...r]=g(e,"rgb"),l=St(t,o,s);return[...El(l),...r.length>0&&r[0]<1?[r[0]]:[]]};function El(e){let t=[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],o=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],s=ke(t,e);return ke(o,s.map(r=>Math.cbrt(r)))}var Ne=kl;f.prototype.oklab=function(){return Ne(this._rgb)};var Ll=(...e)=>new f(...e,"oklab");Object.assign(O,{oklab:Ll});M.format.oklab=Re;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"oklab"),L(e)==="array"&&e.length===3)return"oklab"}});var Ml=(e,t,o)=>{let s=e.oklab(),r=t.oklab();return new f(s[0]+o*(r[0]-s[0]),s[1]+o*(r[1]-s[1]),s[2]+o*(r[2]-s[2]),"oklab")};D.oklab=Ml;var Cl=(e,t,o)=>Z(e,t,o,"oklch");D.oklch=Cl;var{pow:At,sqrt:Rt,PI:Nt,cos:yo,sin:wo,atan2:Sl}=Math,xo=(e,t="lrgb",o=null)=>{let s=e.length;o||(o=Array.from(new Array(s)).map(()=>1));let r=s/o.reduce(function(h,p){return h+p});if(o.forEach((h,p)=>{o[p]*=r}),e=e.map(h=>new f(h)),t==="lrgb")return Ol(e,o);let l=e.shift(),i=l.get(t),n=[],a=0,c=0;for(let h=0;h<i.length;h++)if(i[h]=(i[h]||0)*o[0],n.push(isNaN(i[h])?0:o[0]),t.charAt(h)==="h"&&!isNaN(i[h])){let p=i[h]/180*Nt;a+=yo(p)*o[0],c+=wo(p)*o[0]}let d=l.alpha()*o[0];e.forEach((h,p)=>{let u=h.get(t);d+=h.alpha()*o[p+1];for(let m=0;m<i.length;m++)if(!isNaN(u[m]))if(n[m]+=o[p+1],t.charAt(m)==="h"){let E=u[m]/180*Nt;a+=yo(E)*o[p+1],c+=wo(E)*o[p+1]}else i[m]+=u[m]*o[p+1]});for(let h=0;h<i.length;h++)if(t.charAt(h)==="h"){let p=Sl(c/n[h],a/n[h])/Nt*180;for(;p<0;)p+=360;for(;p>=360;)p-=360;i[h]=p}else i[h]=i[h]/n[h];return d/=s,new f(i,t).alpha(d>.99999?1:d,!0)},Ol=(e,t)=>{let o=e.length,s=[0,0,0,0];for(let r=0;r<e.length;r++){let l=e[r],i=t[r]/o,n=l._rgb;s[0]+=At(n[0],2)*i,s[1]+=At(n[1],2)*i,s[2]+=At(n[2],2)*i,s[3]+=n[3]*i}return s[0]=Rt(s[0]),s[1]=Rt(s[1]),s[2]=Rt(s[2]),s[3]>.9999999&&(s[3]=1),new f(ve(s))};var{pow:zl}=Math;function Ee(e){let t="rgb",o=O("#ccc"),s=0,r=[0,1],l=[],i=[0,0],n=!1,a=[],c=!1,d=0,h=1,p=!1,u={},m=!0,E=1,b=function(_){if(_=_||["#fff","#000"],_&&L(_)==="string"&&O.brewer&&O.brewer[_.toLowerCase()]&&(_=O.brewer[_.toLowerCase()]),L(_)==="array"){_.length===1&&(_=[_[0],_[0]]),_=_.slice(0);for(let v=0;v<_.length;v++)_[v]=O(_[v]);l.length=0;for(let v=0;v<_.length;v++)l.push(v/(_.length-1))}return k(),a=_},y=function(_){if(n!=null){let v=n.length-1,w=0;for(;w<v&&_>=n[w];)w++;return w-1}return 0},S=_=>_,T=_=>_,P=function(_,v){let w,x;if(v==null&&(v=!1),isNaN(_)||_===null)return o;v?x=_:n&&n.length>2?x=y(_)/(n.length-2):h!==d?x=(_-d)/(h-d):x=1,x=T(x),v||(x=S(x)),E!==1&&(x=zl(x,E)),x=i[0]+x*(1-i[0]-i[1]),x=X(x,0,1);let C=Math.floor(x*1e4);if(m&&u[C])w=u[C];else{if(L(a)==="array")for(let A=0;A<l.length;A++){let N=l[A];if(x<=N){w=a[A];break}if(x>=N&&A===l.length-1){w=a[A];break}if(x>N&&x<l[A+1]){x=(x-N)/(l[A+1]-N),w=O.interpolate(a[A],a[A+1],x,t);break}}else L(a)==="function"&&(w=a(x));m&&(u[C]=w)}return w};var k=()=>u={};b(e);let R=function(_){let v=O(P(_));return c&&v[c]?v[c]():v};return R.classes=function(_){if(_!=null){if(L(_)==="array")n=_,r=[_[0],_[_.length-1]];else{let v=O.analyze(r);_===0?n=[v.min,v.max]:n=O.limits(v,"e",_)}return R}return n},R.domain=function(_){if(!arguments.length)return r;d=_[0],h=_[_.length-1],l=[];let v=a.length;if(_.length===v&&d!==h)for(let w of Array.from(_))l.push((w-d)/(h-d));else{for(let w=0;w<v;w++)l.push(w/(v-1));if(_.length>2){let w=_.map((C,A)=>A/(_.length-1)),x=_.map(C=>(C-d)/(h-d));x.every((C,A)=>w[A]===C)||(T=C=>{if(C<=0||C>=1)return C;let A=0;for(;C>=x[A+1];)A++;let N=(C-x[A])/(x[A+1]-x[A]);return w[A]+N*(w[A+1]-w[A])})}}return r=[d,h],R},R.mode=function(_){return arguments.length?(t=_,k(),R):t},R.range=function(_,v){return b(_,v),R},R.out=function(_){return c=_,R},R.spread=function(_){return arguments.length?(s=_,R):s},R.correctLightness=function(_){return _==null&&(_=!0),p=_,k(),p?S=function(v){let w=P(0,!0).lab()[0],x=P(1,!0).lab()[0],C=w>x,A=P(v,!0).lab()[0],N=w+(x-w)*v,z=A-N,W=0,oe=1,H=20;for(;Math.abs(z)>.01&&H-- >0;)(function(){return C&&(z*=-1),z<0?(W=v,v+=(oe-v)*.5):(oe=v,v+=(W-v)*.5),A=P(v,!0).lab()[0],z=A-N})();return v}:S=v=>v,R},R.padding=function(_){return _!=null?(L(_)==="number"&&(_=[_,_]),i=_,R):i},R.colors=function(_,v){arguments.length<2&&(v="hex");let w=[];if(arguments.length===0)w=a.slice(0);else if(_===1)w=[R(.5)];else if(_>1){let x=r[0],C=r[1]-x;w=Al(0,_,!1).map(A=>R(x+A/(_-1)*C))}else{e=[];let x=[];if(n&&n.length>2)for(let C=1,A=n.length,N=1<=A;N?C<A:C>A;N?C++:C--)x.push((n[C-1]+n[C])*.5);else x=r;w=x.map(C=>R(C))}return O[v]&&(w=w.map(x=>x[v]())),w},R.cache=function(_){return _!=null?(m=_,R):m},R.gamma=function(_){return _!=null?(E=_,R):E},R.nodata=function(_){return _!=null?(o=O(_),R):o},R}function Al(e,t,o){let s=[],r=e<t,l=o?r?t+1:t-1:t;for(let i=e;r?i<l:i>l;r?i++:i--)s.push(i);return s}var Rl=function(e){let t=[1,1];for(let o=1;o<e;o++){let s=[1];for(let r=1;r<=t.length;r++)s[r]=(t[r]||0)+t[r-1];t=s}return t},Nl=function(e){let t,o,s,r;if(e=e.map(l=>new f(l)),e.length===2)[o,s]=e.map(l=>l.lab()),t=function(l){let i=[0,1,2].map(n=>o[n]+l*(s[n]-o[n]));return new f(i,"lab")};else if(e.length===3)[o,s,r]=e.map(l=>l.lab()),t=function(l){let i=[0,1,2].map(n=>(1-l)*(1-l)*o[n]+2*(1-l)*l*s[n]+l*l*r[n]);return new f(i,"lab")};else if(e.length===4){let l;[o,s,r,l]=e.map(i=>i.lab()),t=function(i){let n=[0,1,2].map(a=>(1-i)*(1-i)*(1-i)*o[a]+3*(1-i)*(1-i)*i*s[a]+3*(1-i)*i*i*r[a]+i*i*i*l[a]);return new f(n,"lab")}}else if(e.length>=5){let l,i,n;l=e.map(a=>a.lab()),n=e.length-1,i=Rl(n),t=function(a){let c=1-a,d=[0,1,2].map(h=>l.reduce((p,u,m)=>p+i[m]*c**(n-m)*a**m*u[h],0));return new f(d,"lab")}}else throw new RangeError("No point in running bezier with only one color.");return t},vo=e=>{let t=Nl(e);return t.scale=()=>Ee(t),t};var{round:ko}=Math;f.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(ko)};f.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,o)=>o<3?e===!1?t:ko(t):t)};var Tl=(...e)=>new f(...e,"rgb");Object.assign(O,{rgb:Tl});M.format.rgb=(...e)=>{let t=g(e,"rgba");return t[3]===void 0&&(t[3]=1),t};M.autodetect.push({p:3,test:(...e)=>{if(e=g(e,"rgba"),L(e)==="array"&&(e.length===3||e.length===4&&L(e[3])=="number"&&e[3]>=0&&e[3]<=1))return"rgb"}});var ee=(e,t,o)=>{if(!ee[o])throw new Error("unknown blend mode "+o);return ee[o](e,t)},pe=e=>(t,o)=>{let s=O(o).rgb(),r=O(t).rgb();return O.rgb(e(s,r))},_e=e=>(t,o)=>{let s=[];return s[0]=e(t[0],o[0]),s[1]=e(t[1],o[1]),s[2]=e(t[2],o[2]),s},Pl=e=>e,Dl=(e,t)=>e*t/255,Wl=(e,t)=>e>t?t:e,Il=(e,t)=>e>t?e:t,$l=(e,t)=>255*(1-(1-e/255)*(1-t/255)),jl=(e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)),Ul=(e,t)=>255*(1-(1-t/255)/(e/255)),Gl=(e,t)=>e===255?255:(e=255*(t/255)/(1-e/255),e>255?255:e);ee.normal=pe(_e(Pl));ee.multiply=pe(_e(Dl));ee.screen=pe(_e($l));ee.overlay=pe(_e(jl));ee.darken=pe(_e(Wl));ee.lighten=pe(_e(Il));ee.dodge=pe(_e(Gl));ee.burn=pe(_e(Ul));var Eo=ee;var{pow:Yl,sin:Hl,cos:Bl}=Math;function Lo(e=300,t=-1.5,o=1,s=1,r=[0,1]){let l=0,i;L(r)==="array"?i=r[1]-r[0]:(i=0,r=[r,r]);let n=function(a){let c=q*((e+120)/360+t*a),d=Yl(r[0]+i*a,s),p=(l!==0?o[0]+a*l:o)*d*(1-d)/2,u=Bl(c),m=Hl(c),E=d+p*(-.14861*u+1.78277*m),b=d+p*(-.29227*u-.90649*m),y=d+p*(1.97294*u);return O(ve([E*255,b*255,y*255,1]))};return n.start=function(a){return a==null?e:(e=a,n)},n.rotations=function(a){return a==null?t:(t=a,n)},n.gamma=function(a){return a==null?s:(s=a,n)},n.hue=function(a){return a==null?o:(o=a,L(o)==="array"?(l=o[1]-o[0],l===0&&(o=o[1])):l=0,n)},n.lightness=function(a){return a==null?r:(L(a)==="array"?(r=a,i=a[1]-a[0]):(r=[a,a],i=0),n)},n.scale=()=>O.scale(n),n.hue(o),n}var Xl="0123456789abcdef",{floor:ql,random:Fl}=Math,Mo=()=>{let e="#";for(let t=0;t<6;t++)e+=Xl.charAt(ql(Fl()*16));return new f(e,"hex")};var{log:Co,pow:Zl,floor:Kl,abs:Vl}=Math;function Tt(e,t=null){let o={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return L(e)==="object"&&(e=Object.values(e)),e.forEach(s=>{t&&L(s)==="object"&&(s=s[t]),s!=null&&!isNaN(s)&&(o.values.push(s),o.sum+=s,s<o.min&&(o.min=s),s>o.max&&(o.max=s),o.count+=1)}),o.domain=[o.min,o.max],o.limits=(s,r)=>Pt(o,s,r),o}function Pt(e,t="equal",o=7){L(e)=="array"&&(e=Tt(e));let{min:s,max:r}=e,l=e.values.sort((n,a)=>n-a);if(o===1)return[s,r];let i=[];if(t.substr(0,1)==="c"&&(i.push(s),i.push(r)),t.substr(0,1)==="e"){i.push(s);for(let n=1;n<o;n++)i.push(s+n/o*(r-s));i.push(r)}else if(t.substr(0,1)==="l"){if(s<=0)throw new Error("Logarithmic scales are only possible for values > 0");let n=Math.LOG10E*Co(s),a=Math.LOG10E*Co(r);i.push(s);for(let c=1;c<o;c++)i.push(Zl(10,n+c/o*(a-n)));i.push(r)}else if(t.substr(0,1)==="q"){i.push(s);for(let n=1;n<o;n++){let a=(l.length-1)*n/o,c=Kl(a);if(c===a)i.push(l[c]);else{let d=a-c;i.push(l[c]*(1-d)+l[c+1]*d)}}i.push(r)}else if(t.substr(0,1)==="k"){let n,a=l.length,c=new Array(a),d=new Array(o),h=!0,p=0,u=null;u=[],u.push(s);for(let b=1;b<o;b++)u.push(s+b/o*(r-s));for(u.push(r);h;){for(let y=0;y<o;y++)d[y]=0;for(let y=0;y<a;y++){let S=l[y],T=Number.MAX_VALUE,P;for(let k=0;k<o;k++){let R=Vl(u[k]-S);R<T&&(T=R,P=k),d[P]++,c[y]=P}}let b=new Array(o);for(let y=0;y<o;y++)b[y]=null;for(let y=0;y<a;y++)n=c[y],b[n]===null?b[n]=l[y]:b[n]+=l[y];for(let y=0;y<o;y++)b[y]*=1/d[y];h=!1;for(let y=0;y<o;y++)if(b[y]!==u[y]){h=!0;break}u=b,p++,p>200&&(h=!1)}let m={};for(let b=0;b<o;b++)m[b]=[];for(let b=0;b<a;b++)n=c[b],m[n].push(l[b]);let E=[];for(let b=0;b<o;b++)E.push(m[b][0]),E.push(m[b][m[b].length-1]);E=E.sort((b,y)=>b-y),i.push(E[0]);for(let b=1;b<E.length;b+=2){let y=E[b];!isNaN(y)&&i.indexOf(y)===-1&&i.push(y)}}return i}var So=(e,t)=>{e=new f(e),t=new f(t);let o=e.luminance(),s=t.luminance();return o>s?(o+.05)/(s+.05):(s+.05)/(o+.05)};var Oo=.027,Jl=5e-4,Ql=.1,zo=1.14,st=.022,Ao=1.414,No=(e,t)=>{e=new f(e),t=new f(t),e.alpha()<1&&(e=le(t,e,e.alpha(),"rgb"));let o=Ro(...e.rgb()),s=Ro(...t.rgb()),r=o>=st?o:o+Math.pow(st-o,Ao),l=s>=st?s:s+Math.pow(st-s,Ao),i=Math.pow(l,.56)-Math.pow(r,.57),n=Math.pow(l,.65)-Math.pow(r,.62),a=Math.abs(l-r)<Jl?0:r<l?i*zo:n*zo;return(Math.abs(a)<Ql?0:a>0?a-Oo:a+Oo)*100};function Ro(e,t,o){return .2126729*Math.pow(e/255,2.4)+.7151522*Math.pow(t/255,2.4)+.072175*Math.pow(o/255,2.4)}var{sqrt:ne,pow:I,min:ei,max:ti,atan2:To,abs:Po,cos:lt,sin:Do,exp:oi,PI:Wo}=Math;function Io(e,t,o=1,s=1,r=1){var l=function(Le){return 360*Le/(2*Wo)},i=function(Le){return 2*Wo*Le/360};e=new f(e),t=new f(t);let[n,a,c]=Array.from(e.lab()),[d,h,p]=Array.from(t.lab()),u=(n+d)/2,m=ne(I(a,2)+I(c,2)),E=ne(I(h,2)+I(p,2)),b=(m+E)/2,y=.5*(1-ne(I(b,7)/(I(b,7)+I(25,7)))),S=a*(1+y),T=h*(1+y),P=ne(I(S,2)+I(c,2)),k=ne(I(T,2)+I(p,2)),R=(P+k)/2,_=l(To(c,S)),v=l(To(p,T)),w=_>=0?_:_+360,x=v>=0?v:v+360,C=Po(w-x)>180?(w+x+360)/2:(w+x)/2,A=1-.17*lt(i(C-30))+.24*lt(i(2*C))+.32*lt(i(3*C+6))-.2*lt(i(4*C-63)),N=x-w;N=Po(N)<=180?N:x<=w?N+360:N-360,N=2*ne(P*k)*Do(i(N)/2);let z=d-n,W=k-P,oe=1+.015*I(u-50,2)/ne(20+I(u-50,2)),H=1+.045*R,U=1+.015*R*A,J=30*oi(-I((C-275)/25,2)),ye=-(2*ne(I(R,7)/(I(R,7)+I(25,7))))*Do(2*i(J)),we=ne(I(z/(o*oe),2)+I(W/(s*H),2)+I(N/(r*U),2)+ye*(W/(s*H))*(N/(r*U)));return ti(0,ei(100,we))}function $o(e,t,o="lab"){e=new f(e),t=new f(t);let s=e.get(o),r=t.get(o),l=0;for(let i in s){let n=(s[i]||0)-(r[i]||0);l+=n*n}return Math.sqrt(l)}var jo=(...e)=>{try{return new f(...e),!0}catch{return!1}};var Uo={cool(){return Ee([O.hsl(180,1,.9),O.hsl(250,.7,.4)])},hot(){return Ee(["#000","#f00","#ff0","#fff"],[0,.25,.75,1]).mode("rgb")}};var Dt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Yo=Object.keys(Dt),Go=new Map(Yo.map(e=>[e.toLowerCase(),e])),ri=typeof Proxy=="function"?new Proxy(Dt,{get(e,t){let o=t.toLowerCase();if(Go.has(o))return e[Go.get(o)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Yo)}}):Dt,Ho=ri;var si=(...e)=>{e=g(e,"cmyk");let[t,o,s,r]=e,l=e.length>4?e[4]:1;return r===1?[0,0,0,l]:[t>=1?0:255*(1-t)*(1-r),o>=1?0:255*(1-o)*(1-r),s>=1?0:255*(1-s)*(1-r),l]},Bo=si;var{max:Xo}=Math,li=(...e)=>{let[t,o,s]=g(e,"rgb");t=t/255,o=o/255,s=s/255;let r=1-Xo(t,Xo(o,s)),l=r<1?1/(1-r):0,i=(1-t-r)*l,n=(1-o-r)*l,a=(1-s-r)*l;return[i,n,a,r]},qo=li;f.prototype.cmyk=function(){return qo(this._rgb)};var ii=(...e)=>new f(...e,"cmyk");Object.assign(O,{cmyk:ii});M.format.cmyk=Bo;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"cmyk"),L(e)==="array"&&e.length===4)return"cmyk"}});var ni=(...e)=>{let t=g(e,"hsla"),o=B(e)||"lsa";return t[0]=j(t[0]||0)+"deg",t[1]=j(t[1]*100)+"%",t[2]=j(t[2]*100)+"%",o==="hsla"||t.length>3&&t[3]<1?(t[3]="/ "+(t.length>3?t[3]:1),o="hsla"):t.length=3,`${o.substr(0,3)}(${t.join(" ")})`},Fo=ni;var ai=(...e)=>{let t=g(e,"lab"),o=B(e)||"lab";return t[0]=j(t[0])+"%",t[1]=j(t[1]),t[2]=j(t[2]),o==="laba"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(" ")})`},Zo=ai;var ci=(...e)=>{let t=g(e,"lch"),o=B(e)||"lab";return t[0]=j(t[0])+"%",t[1]=j(t[1]),t[2]=isNaN(t[2])?"none":j(t[2])+"deg",o==="lcha"||t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(" ")})`},Ko=ci;var di=(...e)=>{let t=g(e,"lab");return t[0]=j(t[0]*100)+"%",t[1]=Ie(t[1]),t[2]=Ie(t[2]),t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(" ")})`},Vo=di;var hi=(...e)=>{let[t,o,s,...r]=g(e,"rgb"),[l,i,n]=Ne(t,o,s),[a,c,d]=ot(l,i,n);return[a,c,d,...r.length>0&&r[0]<1?[r[0]]:[]]},it=hi;var fi=(...e)=>{let t=g(e,"lch");return t[0]=j(t[0]*100)+"%",t[1]=Ie(t[1]),t[2]=isNaN(t[2])?"none":j(t[2])+"deg",t.length>3&&t[3]<1?t[3]="/ "+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(" ")})`},Jo=fi;var{round:Wt}=Math,pi=(...e)=>{let t=g(e,"rgba"),o=B(e)||"rgb";if(o.substr(0,3)==="hsl")return Fo(rt(t),o);if(o.substr(0,3)==="lab"){let s=fe();F("d50");let r=Zo(Se(t),o);return F(s),r}if(o.substr(0,3)==="lch"){let s=fe();F("d50");let r=Ko(je(t),o);return F(s),r}return o.substr(0,5)==="oklab"?Vo(Ne(t)):o.substr(0,5)==="oklch"?Jo(it(t)):(t[0]=Wt(t[0]),t[1]=Wt(t[1]),t[2]=Wt(t[2]),(o==="rgba"||t.length>3&&t[3]<1)&&(t[3]="/ "+(t.length>3?t[3]:1),o="rgba"),`${o.substr(0,3)}(${t.slice(0,o==="rgb"?3:4).join(" ")})`)},Qo=pi;var _i=(...e)=>{e=g(e,"lch");let[t,o,s,...r]=e,[l,i,n]=tt(t,o,s),[a,c,d]=Re(l,i,n);return[a,c,d,...r.length>0&&r[0]<1?[r[0]]:[]]},nt=_i;var ae=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,te=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,at=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,K=/\s*/.source,Pe=/\s+/.source,It=/\s*,\s*/.source,ct=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,De=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,er=new RegExp("^rgba?\\("+K+[ae,ae,ae].join(Pe)+De+"\\)$"),tr=new RegExp("^rgb\\("+K+[ae,ae,ae].join(It)+K+"\\)$"),or=new RegExp("^rgba\\("+K+[ae,ae,ae,te].join(It)+K+"\\)$"),rr=new RegExp("^hsla?\\("+K+[ct,at,at].join(Pe)+De+"\\)$"),sr=new RegExp("^hsl?\\("+K+[ct,at,at].join(It)+K+"\\)$"),lr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ir=new RegExp("^lab\\("+K+[te,te,te].join(Pe)+De+"\\)$"),nr=new RegExp("^lch\\("+K+[te,te,ct].join(Pe)+De+"\\)$"),ar=new RegExp("^oklab\\("+K+[te,te,te].join(Pe)+De+"\\)$"),cr=new RegExp("^oklch\\("+K+[te,te,ct].join(Pe)+De+"\\)$"),{round:dr}=Math,Te=e=>e.map((t,o)=>o<=2?X(dr(t),0,255):t),$=(e,t=0,o=100,s=!1)=>(typeof e=="string"&&e.endsWith("%")&&(e=parseFloat(e.substring(0,e.length-1))/100,s?e=t+(e+1)*.5*(o-t):e=t+e*(o-t)),+e),G=(e,t)=>e==="none"?t:e,hr=e=>{if(e=e.toLowerCase().trim(),e==="transparent")return[0,0,0,0];let t;if(M.format.named)try{return M.format.named(e)}catch{}if((t=e.match(er))||(t=e.match(tr))){let o=t.slice(1,4);for(let r=0;r<3;r++)o[r]=+$(G(o[r],0),0,255);o=Te(o);let s=t[4]!==void 0?+$(t[4],0,1):1;return o[3]=s,o}if(t=e.match(or)){let o=t.slice(1,5);for(let s=0;s<4;s++)o[s]=+$(o[s],0,255);return o}if((t=e.match(rr))||(t=e.match(sr))){let o=t.slice(1,4);o[0]=+G(o[0].replace("deg",""),0),o[1]=+$(G(o[1],0),0,100)*.01,o[2]=+$(G(o[2],0),0,100)*.01;let s=Te(Ue(o)),r=t[4]!==void 0?+$(t[4],0,1):1;return s[3]=r,s}if(t=e.match(lr)){let o=t.slice(1,4);o[1]*=.01,o[2]*=.01;let s=Ue(o);for(let r=0;r<3;r++)s[r]=dr(s[r]);return s[3]=+t[4],s}if(t=e.match(ir)){let o=t.slice(1,4);o[0]=$(G(o[0],0),0,100),o[1]=$(G(o[1],0),-125,125,!0),o[2]=$(G(o[2],0),-125,125,!0);let s=fe();F("d50");let r=Te(Ce(o));F(s);let l=t[4]!==void 0?+$(t[4],0,1):1;return r[3]=l,r}if(t=e.match(nr)){let o=t.slice(1,4);o[0]=$(o[0],0,100),o[1]=$(G(o[1],0),0,150,!1),o[2]=+G(o[2].replace("deg",""),0);let s=fe();F("d50");let r=Te(Oe(o));F(s);let l=t[4]!==void 0?+$(t[4],0,1):1;return r[3]=l,r}if(t=e.match(ar)){let o=t.slice(1,4);o[0]=$(G(o[0],0),0,1),o[1]=$(G(o[1],0),-.4,.4,!0),o[2]=$(G(o[2],0),-.4,.4,!0);let s=Te(Re(o)),r=t[4]!==void 0?+$(t[4],0,1):1;return s[3]=r,s}if(t=e.match(cr)){let o=t.slice(1,4);o[0]=$(G(o[0],0),0,1),o[1]=$(G(o[1],0),0,.4,!1),o[2]=+G(o[2].replace("deg",""),0);let s=Te(nt(o)),r=t[4]!==void 0?+$(t[4],0,1):1;return s[3]=r,s}};hr.test=e=>er.test(e)||rr.test(e)||ir.test(e)||nr.test(e)||ar.test(e)||cr.test(e)||tr.test(e)||or.test(e)||sr.test(e)||lr.test(e)||e==="transparent";var $t=hr;f.prototype.css=function(e){return Qo(this._rgb,e)};var mi=(...e)=>new f(...e,"css");O.css=mi;M.format.css=$t;M.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&L(e)==="string"&&$t.test(e))return"css"}});M.format.gl=(...e)=>{let t=g(e,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t};var ui=(...e)=>new f(...e,"gl");O.gl=ui;f.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};f.prototype.hex=function(e){return et(this._rgb,e)};var bi=(...e)=>new f(...e,"hex");O.hex=bi;M.format.hex=Je;M.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&L(e)==="string"&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return"hex"}});var{log:dt}=Math,gi=e=>{let t=e/100,o,s,r;return t<66?(o=255,s=t<6?0:-155.25485562709179-.44596950469579133*(s=t-2)+104.49216199393888*dt(s),r=t<20?0:-254.76935184120902+.8274096064007395*(r=t-10)+115.67994401066147*dt(r)):(o=351.97690566805693+.114206453784165*(o=t-55)-40.25366309332127*dt(o),s=325.4494125711974+.07943456536662342*(s=t-50)-28.0852963507957*dt(s),r=255),[o,s,r,1]},ht=gi;var{round:yi}=Math,wi=(...e)=>{let t=g(e,"rgb"),o=t[0],s=t[2],r=1e3,l=4e4,i=.4,n;for(;l-r>i;){n=(l+r)*.5;let a=ht(n);a[2]/a[0]>=s/o?l=n:r=n}return yi(n)},fr=wi;f.prototype.temp=f.prototype.kelvin=f.prototype.temperature=function(){return fr(this._rgb)};var jt=(...e)=>new f(...e,"temp");Object.assign(O,{temp:jt,kelvin:jt,temperature:jt});M.format.temp=M.format.kelvin=M.format.temperature=ht;f.prototype.oklch=function(){return it(this._rgb)};var xi=(...e)=>new f(...e,"oklch");Object.assign(O,{oklch:xi});M.format.oklch=nt;M.autodetect.push({p:2,test:(...e)=>{if(e=g(e,"oklch"),L(e)==="array"&&e.length===3)return"oklch"}});Object.assign(O,{analyze:Tt,average:xo,bezier:vo,blend:Eo,brewer:Ho,Color:f,colors:he,contrast:So,contrastAPCA:No,cubehelix:Lo,deltaE:Io,distance:$o,input:M,interpolate:le,limits:Pt,mix:le,random:Mo,scale:Ee,scales:Uo,valid:jo});var me=O;function Ut(e,t){return me.mix(e,`rgb(${t[0]},${t[1]},${t[2]})`,.5).hex()}function ue([e,t,o,s],r=[255,255,255]){function l(i,n){return((1-s)*(r[i]/255)+s*(n/255))*255}return[l(0,e),l(1,t),l(2,o)]}function be([e,t,o]){return Math.sqrt(e*e*.299+t*t*.587+o*o*.114)>130?"#161616":"#ffffff"}function vi(e){let[t,o,s]=e.rgb(),[r,l,i]=e.set("hsl.h",(e.get("hsl.h")-15)%360).rgb(),[n,a,c]=e.set("hsl.h",(e.get("hsl.h")+15)%360).rgb();return`linear-gradient(to right top,rgb(${r},${l},${i}),rgb(${t},${o},${s}) 50%,rgb(${n},${a},${c}))`}function V(e){let t=me(e),o=vi(t),s=t.rgb();return[e,...s,o,`rgba(${s[0]},${s[1]},${s[2]},1)`,`rgba(${s[0]},${s[1]},${s[2]},0)`]}function pr(e,t,o,s){let r=o.user>0,l=o.user<0,i;e?.pos_bg_color!==void 0?i=e.pos_bg_color:i=this._pos_bg_color;let n;e?.neg_bg_color!==void 0?n=e.neg_bg_color:n=this._neg_bg_color;let a=r?i:l?n:["",...this._plugin_background,""];{let[m,E,b,y,S]=a;if(t.style.position="",o._is_hidden_by_aggregate_depth)t.style.animation="",t.style.backgroundColor="";else if(e?.number_bg_mode==="color")t.style.animation="",t.style.backgroundColor=m;else if(e?.number_bg_mode==="gradient"){let T=Math.max(0,Math.min(1,Math.abs(o.user/e.bg_gradient))),P=this._plugin_background,k=be(ue([E,b,y,T],P));t.style.animation="",t.style.color=k,t.style.backgroundColor=`rgba(${E},${b},${y},${T})`}else e?.number_bg_mode==="pulse"?(oo.call(this,o,t,i,n,s),t.style.backgroundColor=""):(e?.number_bg_mode==="disabled"||e?.number_bg_mode,t.style.animation="",t.style.backgroundColor="")}let[c,d,h,p,u]=e?.pos_fg_color!==void 0?r?e.pos_fg_color:l?e.neg_fg_color:["",...this._plugin_background,""]:r?this._pos_fg_color:l?this._neg_fg_color:["",...this._plugin_background,""];if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.number_fg_mode==="disabled")if(e?.number_bg_mode==="color"){let m=this._plugin_background,E=be(ue([a[1],a[2],a[3],1],m));t.style.color=E}else e?.number_bg_mode==="gradient"||(t.style.color="");else e?.number_fg_mode==="bar"?(t.style.color="",t.style.position="relative",u!==""&&t.children.length>0&&t.children[0].nodeType===Node.ELEMENT_NODE&&(t.children[0].style.background=u)):(e?.number_fg_mode==="color"||!e?.number_fg_mode)&&(t.style.color=c)}function _r(e,t,o){let s=o.column_header?.[this._config.split_by.length],[r,l,i,n,a]=e?.color!==void 0?e.color:this._color;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.string_color_mode==="foreground"&&o.user!==null)t.style.color=r,t.style.backgroundColor="",e?.format==="link"&&(t.children[0].style.color=r);else if(e?.string_color_mode==="background"&&o.user!==null){let c=this._plugin_background,d=be(ue([l,i,n,1],c));t.style.color=d,t.style.backgroundColor=r}else if(e?.string_color_mode==="series"&&o.user!==null){this._series_color_map.has(s)||(this._series_color_map.set(s,new Map),this._series_color_seed.set(s,0));let c=this._series_color_map.get(s);if(!c.has(o.user)){let k=this._series_color_seed.get(s);c.set(o.user,k),this._series_color_seed.set(s,k+1)}let d=c.get(o.user),[h,p,u]=me(r).hsl();h=h+d*150%360;let m=me(h,p,u,"hsl"),[E,b,y]=m.rgb(),S=m.hex(),T=this._plugin_background,P=be(ue([E,b,y,1],T));t.style.color=P,t.style.backgroundColor=S}else t.style.backgroundColor="",t.style.color=""}function mr(e,t,o){let s=o.column_header?.[this._config.split_by.length],[r,l,i,n,a]=e?.color!==void 0?e.color:this._color;if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else if(e?.datetime_color_mode==="foreground"&&o.user!==null)t.style.color=r,t.style.backgroundColor="";else if(e?.datetime_color_mode==="background"&&o.user!==null){let c=this._plugin_background,d=be(ue([l,i,n,1],c));t.style.color=d,t.style.backgroundColor=r}else t.style.backgroundColor="",t.style.color=""}function ur(e,t,o){if(o._is_hidden_by_aggregate_depth)t.style.backgroundColor="",t.style.color="";else{let[s]=o.user===!0?this._pos_fg_color:o.user===!1?this._neg_fg_color:["",0,0,0,""];t.style.backgroundColor="",t.style.color=s}}function br(e,t,o){let s=typeof o.value!=null&&typeof o.value!=null&&o.value?.toString()?.trim().length>0,r=o.row_header_x>=this._config.group_by.length,l=e.getMeta({dx:0,dy:o.y-o.y0+1}),i=l&&l.row_header&&typeof l.row_header[o.row_header_x+1]<"u";t.classList.toggle("psp-tree-label",s&&!r),t.classList.toggle("psp-tree-label-expand",s&&!r&&!i),t.classList.toggle("psp-tree-label-collapse",s&&!r&&i),t.classList.toggle("psp-tree-leaf",s&&r)}function ki(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}function gr(e,t){let o=e[Y]||{},s=t.hasAttribute("settings");for(let r of e.children[0].children[1].children)for(let l of r.children){let i=e.getMeta(l),n=i.column_header?.[this._config.split_by.length],a=ki.call(this,i),c=o[n],d=a==="integer"||a==="float";i._is_hidden_by_aggregate_depth=(p=>p===0?!1:p-1<Math.min(this._config.group_by.length,c?.aggregate_depth))(i.row_header?.filter(p=>p!==void 0)?.length),d?pr.call(this,c,l,i,s):a==="boolean"?ur.call(this,c,l,i):a==="string"?_r.call(this,c,l,i):a==="date"||a==="datetime"?mr.call(this,c,l,i):(l.style.backgroundColor="",l.style.color=""),l.classList.toggle("psp-bool-type",a==="boolean"&&i.user!==null);let h=l.tagName==="TH";h&&br.call(this,e,l,i),r.dataset.y=i.y,i.row_header_x===void 0||i.row_header_x===i.row_header.length-1||i.row_header[i.row_header_x+1]===void 0?(l.dataset.y=i.y,l.dataset.x=i.x):(delete l.dataset.y,delete l.dataset.x),l.classList.toggle("psp-null",i.value===null),l.classList.toggle("psp-align-right",!h&&d),l.classList.toggle("psp-align-left",h||!d),l.classList.toggle("psp-color-mode-bar",c?.number_fg_mode==="bar"&&d)}}async function yr(e,t,o,s){let l=e.getMeta(s).column_header[this._config.split_by.length],i=o.ctrlKey||o.metaKet||o.altKey?Ei:Li,n=o.shiftKey,a=i.call(this,l,n);await t.restore({sort:a})}function Ei(e,t){let o=[],s=!1;for(let r of this._config.sort){let[l,i]=r;if(l===e){s=!0;let n=wr.call(this,e,i,t);n&&o.push(n)}else o.push(r)}return s||o.push([e,t?"desc abs":"desc"]),o}function Li(e,t){for(let[o,s]of this._config.sort)if(o===e){let r=wr.call(this,e,s,t);return r?[r]:[]}return[[e,t?"desc abs":"desc"]]}function wr(e,t,o){let r=this._config.split_by.length>0?Ci:Mi,l=t?r[t]:"desc";if(l)return[e,l]}var Mi={desc:"asc",asc:void 0,"desc abs":"asc abs","asc abs":void 0},Ci={desc:"asc",asc:"col desc","desc abs":"asc abs","asc abs":"col desc abs","col desc":"col asc","col asc":void 0,"col desc abs":"col asc abs","col asc abs":void 0};async function xr(e,t){let o=e.getMeta(t.target),s=t.target.classList.contains("psp-tree-label-collapse");t.shiftKey&&s?this._view.set_depth(o.row_header.filter(r=>r!==void 0).length-2):t.shiftKey?this._view.set_depth(o.row_header.filter(r=>r!==void 0).length-1):s?this._view.collapse(o.y):this._view.expand(o.y),this._num_rows=await this._view.num_rows(),this._num_columns=await this._view.num_columns(),e.draw()}async function vr(e,t,o){if(o.which!==1)return;let s=o.target;if(s.tagName!=="A"){for(;s.tagName!=="TD"&&s.tagName!=="TH";)if(s=s.parentElement,!e.contains(s))return;if(s.classList.contains("psp-tree-label")){xr.call(this,e,o);return}if(s.classList.contains("psp-menu-enabled")){let l=e.getMeta(s).column_header?.[this._config.split_by.length];await t.toggleColumnSettings(l)}else s.classList.contains("psp-sort-enabled")&&yr.call(this,e,t,o,s)}}function kr(e,t){if(t.which!==1)return;let o=t.target;for(;o.tagName!=="TD"&&o.tagName!=="TH";)if(o=o.parentElement,!e.contains(o))return;(o.classList.contains("psp-tree-label")&&t.offsetX<26||o.classList.contains("psp-header-leaf")&&!o.classList.contains("psp-header-corner"))&&t.stopImmediatePropagation()}function Er(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,s=e.hasAttribute("selectable"),r=t||e.children[0]?.dataset?.editMode==="EDIT";return o&&!s&&r}function Lr(e,t,o){let s=e[Y]||{},r=Er.call(this,t);o.classList.toggle("edit-mode-allowed",Er.call(this,t,!0));for(let l of e.querySelectorAll("td")){let i=e.getMeta(l),n=this.get_psp_type(i);if(r&&this._is_editable[i.x]){let a=i.column_header[this._config.split_by.length];n==="string"&&s[a]?.format==="link"?(l.toggleAttribute("contenteditable",!1),l.classList.toggle("boolean-editable",!1)):n==="boolean"?(l.toggleAttribute("contenteditable",!1),l.classList.toggle("boolean-editable",i.user!==null)):(r!==l.hasAttribute("contenteditable")&&l.toggleAttribute("contenteditable",r),l.classList.toggle("boolean-editable",!1))}else l.toggleAttribute("contenteditable",!1),l.classList.toggle("boolean-editable",!1)}}var ft=(e,t,o)=>{let s=e.querySelectorAll("td"),r=o.get(e),l=e.getRootNode();if(r){for(let i of s){let n=e.getMeta(i);if(n.x===r.x&&n.y===r.y)return l.activeElement!==i&&i.focus({preventScroll:!0}),!0}document.activeElement!==document.body&&e.contains(l.activeElement)&&l.activeElement.blur()}};function Gt(e,t,o){let s=e.getMeta(o),r=t._schema[t._column_paths[s.x]];if(s){let l=o.textContent,i=t._ids[s.y-s.y0][0];if(r==="float"||r==="integer"){if(l=parseFloat(l.replace(/,/g,"")),isNaN(l))return!1}else if(r==="date"||r==="datetime"){if(l=Date.parse(l),isNaN(l))return!1}else r==="boolean"&&(l=l==="true"?!1:l==="false"?!0:null);let n={__INDEX__:i,[t._column_paths[s.x]]:l};return t._table.update([n],{port_id:t._edit_port}),!0}}function Mr(e,t,o){let s=e.getMeta(o.target);if(typeof s?.x<"u"){let r=this._is_editable[s.x],l=this.get_psp_type(s)==="boolean",i=o.target.classList.contains("psp-null");r&&l&&!i&&Gt(e,this,o.target)}}function Oi(e){let t;return async function(...o){if(t&&await t&&t)return;let s;t=new Promise(r=>s=r),await e.apply(this,o),t=void 0,s()}}function Cr(){if(this.isContentEditable){let e=this.getRootNode().getSelection().getRangeAt(0),t=e.cloneRange();return t.selectNodeContents(this),t.setEnd(e.endContainer,e.endOffset),t.toString().length}else return this.target.selectionStart}var We=Oi(async function(e,t,o,s,r){let l=e.getMeta(o),i=this._column_paths.length,n=this._num_rows,a=t.get(e);if(!a)return;l.x+s<i&&0<=l.x+s&&(a.x=l.x+s),l.y+r<n&&0<=l.y+r&&(a.y=l.y+r);let c=Math.max(l.x0-10,0),d=Math.min(l.x0+10,i),h=Math.max(l.y0-5,0),p=Math.min(l.y0+10,n),u=l.x0+s,m=l.y0+r;for(;!ft(e,void 0,t)&&u>=c&&u<d&&m>=h&&m<p;)await e.scrollToCell(u,m,i,n),t.set(e,a),u+=s,m+=r});function zi(e,t,o){return t.getMeta(o).y===e._num_rows-1}function Sr(e,t,o,s){let r=e.getRootNode().activeElement;switch(s.target.classList.remove("psp-error"),s.key){case"Enter":s.preventDefault(),zi(this,e,r)?(r.blur(),o.delete(e)):s.shiftKey?We.call(this,e,o,r,0,-1):We.call(this,e,o,r,0,1);break;case"ArrowLeft":Cr.call(r)==0&&(s.preventDefault(),We.call(this,e,o,r,-1,0));break;case"ArrowUp":s.preventDefault(),We.call(this,e,o,r,0,-1);break;case"ArrowRight":Cr.call(r)==r.textContent.length&&(s.preventDefault(),We.call(this,e,o,r,1,0));break;case"ArrowDown":s.preventDefault(),We.call(this,e,o,r,0,1);break;default:}}function pt(e,t=!1){let o=this._config.group_by.length===0&&this._config.split_by.length===0,s=e.hasAttribute("selectable"),r=t||e.children[0]._edit_mode==="EDIT";return o&&!s&&r}function Or(e,t,o,s){if(this._edit_mode==="EDIT"){if(!pt.call(this,t))return;Sr.call(this,e,t,o,s)}else console.debug(`Mode ${this._edit_mode} for "keydown" event not yet implemented`)}function zr(e,t,o){if(this._edit_mode==="EDIT"){if(!pt.call(this,t))return;Mr.call(this,e,t,o)}else this._edit_mode==="READ_ONLY"||this._edit_mode==="SELECT_COLUMN"||this._edit_mode==="SELECT_ROW"||this._edit_mode==="SELECT_REGION"||console.debug(`Mode ${this._edit_mode} for "click" event not yet implemented`)}function Ar(e,t,o,s){if(pt.call(this,t)&&o.has(e)){s.target.classList.remove("psp-error");let r=o.get(e);o.delete(e),r.content!==s.target.textContent&&(Gt(e,this,s.target)||(s.target.textContent=r.content,s.target.classList.add("psp-error"),s.target.focus()))}}function Rr(e,t,o,s){let r=e.getMeta(s.target);if(r){let l={x:r.x,y:r.y,content:s.target.textContent};o.set(e,l)}}async function Ge({_view:e,_config:t},o,s){let r=t.group_by,l=t.split_by,i=o>=0?o:0,n=i+1,a=await e.to_json({start_row:i,end_row:n}),d=a.map(y=>y.__ROW_PATH__)[0]||[],h=r.map((y,S)=>{let T=d[S];return T?[y,"==",T]:void 0}).filter(y=>y),p=r.length>0?s+1:s,u=Object.keys(a[0])[p],m={row:a[0]},E=[];if(u){let y=u.split("|");m.column_names=[y[l.length]],E=l.map((S,T)=>{let P=y[T];return P?[S,"==",P]:void 0}).filter(S=>S).filter(([,,S])=>S!=="__ROW_PATH__")}let b=t.filter.concat(h).concat(E);return m.config={filter:b},m}async function Nr(e,t,o,s){let r=e.getMeta(s.target);if(!t.hasAttribute("selectable")||s.handled||s.which!==1||!r)return;let l=this._ids?.[r.y-r.y0];if(r&&r.y>=0){let i=o.get(e),n=!!i&&i.reduce((u,m,E)=>u&&m===l[E],!0),a=!!i&&l.length===i.length&&n,c={selected:!a},{row:d,column_names:h,config:p}=await Ge(this,r.y,r.x);a?(o.delete(e),c={...c,row:d,config:{filter:structuredClone(this._config.filter)}}):(o.set(e,l),c={...c,row:d,column_names:h,config:p}),await e.draw({preserve_width:!0}),s.handled=!0,t.dispatchEvent(new CustomEvent("perspective-select",{bubbles:!0,composed:!0,detail:c}))}}function Tr(e,t,o){if(!t.hasAttribute("selectable"))return;let s=o.has(e),r=o.get(e);for(let l of e.querySelectorAll("td"))if(!s)l.classList.toggle("psp-row-selected",!1),l.classList.toggle("psp-row-subselected",!1);else{let i=e.getMeta(l),n=this._ids[i.y-i.y0],a=r.reduce((c,d,h)=>c&&d===n[h],!0);l.classList.toggle("psp-row-selected",n.length===r.length&&a),l.classList.toggle("psp-row-subselected",n.length!==r.length&&a)}for(let l of e.querySelectorAll("tbody th")){let i=e.getMeta(l),n=this._ids[i.y-i.y0];if(!s||n[i.row_header_x])l.classList.toggle("psp-row-selected",!1),l.classList.toggle("psp-row-subselected",!1);else{let a=r.reduce((c,d,h)=>c&&d===n[h],!0);l.classList.toggle("psp-row-selected",n.length===r.length&&a),l.classList.toggle("psp-row-subselected",n.length!==r.length&&a)}}}async function Pr(e,t,o){o.delete(e);for(let s of e.querySelectorAll("td,th"))s.classList.toggle("psp-row-selected",!1),s.classList.toggle("psp-row-subselected",!1)}var Dr={datetime:Intl.DateTimeFormat,date:Intl.DateTimeFormat,integer:Intl.NumberFormat,float:Intl.NumberFormat,boolean:class{format(e){return e?"true":"false"}}},Ri={types:{float:{format:{style:"decimal",minimumFractionDigits:2,maximumFractionDigits:2}},datetime:{format:{dateStyle:"short",timeStyle:"medium"}},date:{format:{dateStyle:"short"}}}},_t=class{constructor(){this._formatters=new Map}create_datetime_formatter(t,o){let s={dateStyle:"short",timeStyle:"medium"};if(o.date_format?.format!=="custom"){let r={...s,timeZone:o.date_format?.timeZone,dateStyle:o.date_format?.dateStyle,timeStyle:o.date_format?.timeStyle};return r.dateStyle==="disabled"?r.dateStyle=void 0:r.dateStyle===void 0&&(r.dateStyle="short"),r.timeStyle==="disabled"?r.timeStyle=void 0:r.timeStyle===void 0&&(r.timeStyle="medium"),new Intl.DateTimeFormat(navigator.languages,r)}else{let r={timeZone:o.date_format?.timeZone,second:o.date_format?.second,minute:o.date_format?.minute,hour:o.date_format?.hour,day:o.date_format?.day,weekday:o.date_format?.weekday,month:o.date_format?.month,year:o.date_format?.year,hour12:o.date_format?.hour12,fractionalSecondDigits:o.date_format?.fractionalSecondDigits};return r.year==="disabled"?r.year=void 0:r.year===void 0&&(r.year="2-digit"),r.month==="disabled"?r.month=void 0:r.month===void 0&&(r.month="numeric"),r.day==="disabled"?r.day=void 0:r.day===void 0&&(r.day="numeric"),r.weekday==="disabled"&&(r.weekday=void 0),r.hour==="disabled"?r.hour=void 0:r.hour===void 0&&(r.hour="numeric"),r.minute==="disabled"?r.minute=void 0:r.minute===void 0&&(r.minute="numeric"),r.second==="disabled"?r.second=void 0:r.second===void 0&&(r.second="numeric"),r.hour12===void 0&&(r.hour12=!0),new Intl.DateTimeFormat(navigator.languages,r)}}create_date_formatter(t,o){let s={dateStyle:o.date_format?.dateStyle,timeZone:"utc"};return s.dateStyle==="disabled"?s.dateStyle=void 0:s.dateStyle===void 0&&(s.dateStyle="short"),new Intl.DateTimeFormat(navigator.languages,s)}create_number_formatter(t,o){let s=Ri.types[t]?.format;return o.number_format!==void 0&&(s=o.number_format),new Dr[t](navigator.languages,s)}create_boolean_formatter(t,o){return new Dr[t](navigator.languages,{})}get(t,o){let s=[t,...Object.values(o.date_format??{}),...Object.values(o.number_format??{})].join("-");return this._formatters.has(s)||(t==="date"?this._formatters.set(s,this.create_date_formatter(t,o)):t==="datetime"?this._formatters.set(s,this.create_datetime_formatter(t,o)):t==="integer"||t==="float"?this._formatters.set(s,this.create_number_formatter(t,o)):t==="boolean"?this._formatters.set(s,this.create_boolean_formatter(t,o)):this._formatters.set(s,!1)),this._formatters.get(s)}};var Ir=new _t,Wr=1;function $r(e,t){return Ir.get(e,t)}function Ye(e,t,o={},s=!1){if(t===null)return null;let r=s&&this._table_schema[e]||this._schema[e]||"string",l=o[e]||{};if((r==="integer"||r==="float")&&l?.number_fg_mode==="bar"){let n=Math.max(0,Math.min(Wr,Math.abs(t/l.fg_gradient)*Wr)),a=this._div_factory.get(),c=t>=0?"left":"right",d=(n*100).toFixed(2);return a.setAttribute("style",`width:calc(${d}% - 4px);position:absolute;${c}:2px;height:80%;top:10%;pointer-events:none;`),a}else if(l?.format==="link"&&r==="string"){let n=document.createElement("a");return n.setAttribute("href",t),n.setAttribute("target","_blank"),n.textContent=t,n}else if(l?.format==="bold"&&r==="string"){let n=document.createElement("b");return n.textContent=t,n}else if(l?.format==="italics"&&r==="string"){let n=document.createElement("i");return n.textContent=t,n}else{let n=Ir.get(r,l);return n?n.format(t):t}}function*jr(e=[],t,o){let s=o[Y];for(let r of e){r=["TOTAL",...r];let l=r[r.length-1];r=r.slice(0,r.length-1).fill("");let i=Ye.call(this,t[r.length-1],l,s,!0);i instanceof HTMLElement?r=r.concat(i):r=r.concat({toString:()=>i}),r.length=t.length+1,yield r}}function*Ur(e=[],t,o){let s=o[Y];for(let r of e){let l=[""];for(let i in r)l.push(Ye.call(this,t[i],r[i],s,!0));yield r}}function Gr(e){let t,o,s,r,l;return async function(n,a,c,d,h){let p={},u={start_row:c,start_col:a,end_row:h,end_col:d,id:!0},m=null;if(d-a>0&&h-c>0){this._is_old_viewport=this._last_window?.start_row===c&&this._last_window?.end_row===h&&this._last_window?.start_col===a&&this._last_window?.end_col===d;let[v,w]=await Promise.all([this._view.to_columns_string(u),this._view.num_columns()]);m=w,p=JSON.parse(v);let C=Object.keys(p).filter(N=>N!=="__ROW_PATH__"&&N!=="__ID__"),A=this._column_paths.length;if(this._column_paths.splice(u.start_col,C.length,...C),this._column_paths.length!==A||A===0){let[N,z]=await Promise.all([this._view.schema(),this._view.expression_schema()]);this._schema={...N,...z};for(let W=0;W<C.length;W++){let H=C[W].split("|")[this._config.split_by.length];this._is_editable[W+u.start_col]=!!this._table_schema[H],this._column_types[W+u.start_col]=this._schema[H]}}this._last_window=u,this._ids=p.__ID__||Array(h-c).fill().map((N,z)=>[z+c]),this._reverse_columns=this._column_paths.slice(a,d).reduce((N,z,W)=>(N.set(z,W),N),new Map),this._reverse_ids=this._ids?.reduce((N,z,W)=>(N.set(z?.join("|"),W),N),new Map)}else this._div_factory.clear(),m=await this._view.num_columns();let E=[],b=[],y=[],S=[],T=e.hasAttribute("settings");for(let v=a;v<Math.min(d,this._column_paths.length);++v){let w=this._column_paths[v],x=w.split("|"),C=p[w]||new Array(h-c).fill(null),A=Math.min(n[Y]?.[x[this._config.split_by.length]]?.aggregate_depth||0,this._config.group_by.length);E.push(C.map((N,z)=>p?.__ROW_PATH__?.[z]?.length<A?"":Ye.call(this,x[this._config.split_by.length],N,n[Y]))),b.push(C),T&&x.push(""),y.push(x),S.push(w)}d-a>0&&h-c>0&&(this.last_column_paths=o,this.last_meta=t,this.last_ids=s,this.last_reverse_ids=r,this.last_reverse_columns=l,o=S,t=b,s=this._ids,r=this._reverse_ids,l=this._reverse_columns);let P=p.__ROW_PATH__!==void 0,k=Array.from((P?jr:Ur).call(this,p.__ROW_PATH__,this._config.group_by,n)),R=k[0]?.length;return{num_column_headers:y[0]?.length||1,num_row_headers:R,num_rows:this._num_rows,num_columns:m,row_headers:k,column_headers:y,data:E,metadata:b,column_header_merge_depth:Math.max(0,this._config.split_by.length)}}}function mt(e,t,o){let s=window.getComputedStyle(e).getPropertyValue(t).trim();return s.length>0?s:o}var Yt=class{constructor(t){this._name=t,this._elements=[],this._index=0}clear(){this._index=0}get(){this._elements[this._index]||(this._elements[this._index]=document.createElement(this._name));let t=this._elements[this._index];return this._index+=1,t}};function Ni(e){return e.x>=0?this._column_types[e.x]:this._row_header_types[e.row_header_x-1]}async function Ht(e,t,o,s={}){let r=await o.get_config();if(this?.model?._config){let _=this.model._config,v=_.group_by.length!==r.group_by.length,w=(_.group_by.length===0||r.group_by.length===0)&&v;if(!v)for(let z in _.group_by)v||=r.group_by[z]!==_.group_by[z];let x=_.split_by.length!==r.split_by.length;if(x)for(let z in _.split_by)x||=r.split_by[z]!==_.split_by[z];let C=_.columns.length!==r.columns.length;if(C)for(let z in _.columns)C||=r.columns[z]!==_.columns[z];let A=_.filter.length!==r.filter.length;if(A)for(let z in _.filter)for(let W in r.filter[z])A||=r.filter[z][W]!==_.filter[z][W];let N=_.sort.length!==r.sort.length;if(N)for(let z in _.sort)for(let W in r.sort[z])N||=r.sort[z][W]!==_.sort[z][W];this._reset_scroll_top=v,this._reset_scroll_left=x,this._reset_select=v||x||A||N||C,this._reset_column_size=x||v||C||w}let[l,i,n,a,c]=await Promise.all([t.schema(),o.num_rows(),o.schema(),o.expression_schema(),this.parentElement.getEditPort()]),d=me(mt(e,"--plugin--background","#FFFFFF")).rgb(),h=V(mt(e,"--rt-pos-cell--color","#338DCD")),p=V(mt(e,"--rt-neg-cell--color","#FF5942")),u=V(Ut(h[0],d)),m=V(Ut(p[0],d)),E=V(mt(e,"--active--color","#ff0000")),b={...n,...a},y={...l,...a},S=[],T=[],P=[],k=this._edit_mode||"READ_ONLY";this._edit_button.dataset.editMode=k;let R=Object.assign(s,{_edit_port:c,_view:o,_table:t,_table_schema:y,_config:r,_num_rows:i,_schema:b,_ids:[],_plugin_background:d,_color:E,_pos_fg_color:h,_neg_fg_color:p,_pos_bg_color:u,_neg_bg_color:m,_column_paths:S,_column_types:P,_is_editable:T,_edit_mode:k,_selection_state:{selected_areas:[],dirty:!1},_row_header_types:r.group_by.map(_=>y[_]),_series_color_map:new Map,_series_color_seed:new Map,get_psp_type:Ni});return R._div_factory=R._div_factory||new Yt("div"),e.setDataListener(Gr(this.parentElement).bind(R,e),{virtual_mode:window.getComputedStyle(e).getPropertyValue("--datagrid-virtual-mode")?.trim()||"both"}),R}async function Yr(e,t,o){let s=e.getMeta(o.target);if(!s)return;let{x:r,y:l}=s,{row:i,column_names:n,config:a}=await Ge(this,l,r);t.dispatchEvent(new CustomEvent("perspective-click",{bubbles:!0,composed:!0,detail:{row:i,column_names:n,config:a}}))}var Ti="mouse-selected-area",Hr=(e,t,{className:o=Ti,selected:s=[]}={})=>(e.model._selection_state={selected_areas:s,dirty:!0},t.addEventListener("mousedown",Pi(e,t,o)),t.addEventListener("mouseover",Di(e,t,o)),t.addEventListener("mouseup",Wi(e,t,o)),t.addStyleListener(()=>He(e,t,o)),t),Pi=(e,t,o)=>s=>{if(s.button===0&&(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={};let r=t.getMeta(s.target);if(r&&r.x!==void 0&&r.y!==void 0){e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={x:r.x,y:r.y},e.model._selection_state.old_selected_areas=e.model._selection_state.selected_areas,e.model._selection_state.selected_areas=[];let l={x0:r.x,x1:r.x,y0:r.y,y1:r.y};e.model._selection_state.potential_selection=l,He(e,t,o,e.model._selection_state.selected_areas.concat([l]));return}}e.model._selection_state.selected_areas=[]},Di=(e,t,o)=>s=>{if((e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN")&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES&&e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x!==void 0){let r=t.getMeta(s.target);if(r&&r.x!==void 0&&r.y!==void 0){let l={x0:Math.min(r.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(r.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(r.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(r.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.potential_selection=l,He(e,t,o,e.model._selection_state.selected_areas.concat([l]))}}},Wi=(e,t,o)=>s=>{if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){let r=t.getMeta(s.target);if(e.model._selection_state.old_selected_areas?.length>0){let l=e.model._selection_state.old_selected_areas[0];if(l.x0===l.x1&&l.y0===l.y1&&l.x0===r.x&&l.y0===r.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,He(e,t,o,[]);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&&r.x!==void 0&&r.y!==void 0){let l={x0:Math.min(r.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),x1:Math.max(r.x,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.x),y0:Math.min(r.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y),y1:Math.max(r.y,e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES.y)};e.model._selection_state.selected_areas.push(l),He(e,t,o)}e.model._selection_state.CURRENT_MOUSEDOWN_COORDINATES={},e.model._selection_state.potential_selection=void 0}};function Ii(e,t,{x0:o,x1:s,y0:r,y1:l}){let i={},n=t.model._edit_mode;o!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(n)>-1&&(i.start_col=o),s!==void 0&&["SELECT_COLUMN","SELECT_REGION"].indexOf(n)>-1&&(i.end_col=s+1),r!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(n)>-1&&(i.start_row=r),l!==void 0&&["SELECT_ROW","SELECT_REGION"].indexOf(n)>-1&&(i.end_row=l+1),e.setSelection(i)}var He=(e,t,o,s)=>{if(e.model._edit_mode==="SELECT_REGION"||e.model._edit_mode==="SELECT_ROW"||e.model._edit_mode==="SELECT_COLUMN"){s=e.model._selection_state.selected_areas.slice(0),e.model._selection_state.potential_selection&&s.push(e.model._selection_state.potential_selection);let r=t.querySelectorAll("tbody td");if(s.length>0)Ii(e.parentElement,e,s[0]),$i(e,t,s,o);else{e.parentElement.setSelection();for(let l of r)l.classList.remove(o)}}else if(e.model._selection_state.dirty){e.model._selection_state.dirty=!1;let r=t.querySelectorAll("tbody td");for(let l of r)l.classList.remove(o)}},$i=(e,t,o,s)=>{if(e.model._edit_mode==="SELECT_REGION"&&o.length>0){let r=t.querySelectorAll("tbody td");for(let l of r){let i=t.getMeta(l),n=!1;for(let{x0:a,x1:c,y0:d,y1:h}of o)a!==void 0&&d!==void 0&&c!==void 0&&h!==void 0&&a<=i.x&&i.x<=c&&d<=i.y&&i.y<=h&&(n=!0,e.model._selection_state.dirty=!0,l.classList.add(s));n||l.classList.remove(s)}}else if(e.model._edit_mode==="SELECT_ROW"&&o.length>0){let r=t.querySelectorAll("tbody td");for(let l of r){let i=t.getMeta(l),n=!1;for(let{x0:a,x1:c,y0:d,y1:h}of o)a!==void 0&&d!==void 0&&c!==void 0&&h!==void 0&&d<=i.y&&i.y<=h&&(e.model._selection_state.dirty=!0,n=!0,l.classList.add(s));n||l.classList.remove(s)}}else if(e.model._edit_mode==="SELECT_COLUMN"&&o.length>0){let r=t.querySelectorAll("tbody td");for(let l of r){let i=t.getMeta(l),n=!1;for(let{x0:a,x1:c,y0:d,y1:h}of o)a!==void 0&&d!==void 0&&c!==void 0&&h!==void 0&&a<=i.x&&i.x<=c&&(e.model._selection_state.dirty=!0,n=!0,l.classList.add(s));n||l.classList.remove(s)}}};async function Br(e){let t=this.parentElement,o=await t.getTable(!0);if(this._initialized)await Ht.call(this,this.regular_table,o,e,this.model);else{if(this.innerHTML="",this.shadowRoot?this.shadowRoot.appendChild(this.regular_table):this.appendChild(this.regular_table),this.model=await Ht.call(this,this.regular_table,o,e),!this.model)return;Hr(this,this.regular_table,{className:"psp-select-region"}),this.regular_table.addStyleListener(gr.bind(this.model,this.regular_table,t)),this.regular_table.addStyleListener(to.bind(this.model,this.regular_table)),this.regular_table.addStyleListener(eo.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("click",kr.bind(this.model,this.regular_table)),this.regular_table.addEventListener("mousedown",vr.bind(this.model,this.regular_table,t));let s=new WeakMap;this.regular_table.addStyleListener(Tr.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("mousedown",Nr.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("psp-deselect-all",Pr.bind(this.model,this.regular_table,t,s)),this.regular_table.addEventListener("click",Yr.bind(this.model,this.regular_table,t));let r=new WeakMap;this.regular_table.addStyleListener(Lr.bind(this.model,this.regular_table,t,this)),this.regular_table.addStyleListener(ft.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("click",zr.bind(this.model,this.regular_table,t)),this.regular_table.addEventListener("focusin",Rr.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("focusout",Ar.bind(this.model,this.regular_table,t,r)),this.regular_table.addEventListener("keydown",Or.bind(this.model,this.regular_table,t,r)),t.addEventListener("perspective-toggle-column-settings",l=>{if(this.isConnected){if(kt.call(this.model,this.regular_table,t,l.detail.column_name),!l.detail.open){this.model._column_settings_selected_column=null;return}this.model._column_settings_selected_column=l.detail.column_name}}),this._initialized=!0}}function ut(e,t=!1){if(!this._initialized)return;t&&(this._cached_column_sizes=e);let o={},{group_by:s,columns:r}=this.model._config,l=s?.length>0?s.length+1:0;for(let i of Object.keys(e))if(i==="__ROW_PATH__")o[l-1]=e[i];else{let n=this.model._column_paths.indexOf(i);o[n+l]=e[i]}this.regular_table._column_sizes.override=o}function bt(){if(!this._initialized)return[];if(this._cached_column_sizes){let l=this._cached_column_sizes;return this._cached_column_sizes=void 0,l}let e=this.regular_table._column_sizes.override,{group_by:t,columns:o}=this.model._config,s=t?.length>0?t.length+1:0,r={};for(let l of Object.keys(e))if(e[l]!==void 0){let i=l-s;i>-1?r[this.model._column_paths[i]]=e[l]:i===-1&&(r.__ROW_PATH__=e[l])}return r}var Be=["READ_ONLY","EDIT","SELECT_ROW","SELECT_COLUMN","SELECT_REGION"];function gt(e=void 0){typeof e>"u"&&(e=Be[(Be.indexOf(this._edit_mode)+1)%Be.length]),this.parentElement?.setSelection(),this._edit_mode=e,this.model&&(this.model._edit_mode=e,this.model._selection_state={selected_areas:[],dirty:!0}),this._edit_button!==void 0&&(this._edit_button.dataset.editMode=e),this.dataset.editMode=e}function yt(e=void 0){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 Xr(e,t){e=JSON.parse(JSON.stringify(e)),t=JSON.parse(JSON.stringify(t));let o={};if(e.columns)for(let[l,i]of Object.entries(e.columns))i.column_size_override!==void 0&&(o[l]=i.column_size_override,delete i.column_size_override);let s={};if(t)for(let[l,i]of Object.entries(t))s[l]={...i,pos_fg_color:i.pos_fg_color?V(i.pos_fg_color):void 0,neg_fg_color:i.neg_fg_color?V(i.neg_fg_color):void 0,pos_bg_color:i.pos_bg_color?V(i.pos_bg_color):void 0,neg_bg_color:i.neg_bg_color?V(i.neg_bg_color):void 0,color:i.color?V(i.color):void 0};"edit_mode"in e&&(Be.indexOf(e.edit_mode)!==-1?gt.call(this,e.edit_mode):console.error("Unknown edit mode "+e.edit_mode)),"scroll_lock"in e&&yt.call(this,e.scroll_lock);let r=this.regular_table;ut.call(this,o,!0),r[Y]=s}function qr(){if(this.regular_table){let e={columns:{},scroll_lock:!!this._is_scroll_lock,edit_mode:this._edit_mode},t=bt.call(this);for(let o of Object.keys(t||{}))e.columns[o]||(e.columns[o]={}),e.columns[o].column_size_override=t[o];return JSON.parse(JSON.stringify(e))}return{}}async function Fr(e){if(this.parentElement&&await this.activate(e),!this.isConnected||this.offsetParent==null||!this.model)return;let t=bt.call(this),o=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),ut.call(this,t),await o,this._toolbar.classList.toggle("aggregated",this.model._config.group_by.length>0||this.model._config.split_by.length>0)}function Bt(e,t){return e==="integer"||e==="float"?{datagrid_number_style:{fg_gradient:0,pos_fg_color:this.model._pos_fg_color[0],neg_fg_color:this.model._neg_fg_color[0],number_fg_mode:"color",bg_gradient:0,pos_bg_color:this.model._pos_bg_color[0],neg_bg_color:this.model._neg_bg_color[0],number_bg_mode:"disabled"},number_string_format:!0}:e==="date"||e==="datetime"||e==="string"?{[e==="date"||e==="datetime"?"datagrid_datetime_style":"datagrid_string_style"]:{color:this.model._color[0],bg_color:this.model._color[0]}}:null}var Zr='regular-table{padding:0;margin:12px 0 0 12px;font-family:inherit;--rt-hover--border-color:var(--inactive--color,#c5c9d080);}regular-table div[tabindex]{outline:none;}regular-table>div{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;}regular-table th{text-align:center;}regular-table thead tr:not(.rt-autosize) th{overflow:hidden;max-width:0px;}regular-table thead tr:last-child .rt-float,regular-table tbody .rt-float{text-align:right;}regular-table thead .rt-integer,regular-table tbody .rt-integer{text-align:right;}regular-table tbody th{text-align:left;}regular-table span.rt-tree-container{display:flex;align-items:center;height:100%;}regular-table thead .rt-string,regular-table tbody .rt-string,regular-table thead .rt-date,regular-table tbody .rt-date,regular-table thead .rt-datetime,regular-table tbody .rt-datetime{text-align:left;}regular-table thead tr:last-child th{border-bottom:1px solid#8b868045;}regular-table tbody tr:first-child td,regular-table tbody tr:first-child th{border-top:1px solid transparent!important;}regular-table th{position:relative;}regular-table tr th span.rt-tree-group{margin-left:5px;margin-right:15px;border-left:1px solid#eee;height:100%;}regular-table td,regular-table th{white-space:nowrap;font-size:12px;padding-right:5px;padding-left:5px;padding-top:0px;padding-bottom:0px;height:19px;}regular-table table *{box-sizing:border-box;}regular-table table{position:absolute;color:#666;outline:none;}regular-table span.rt-row-header-icon{color:#aaa;padding-right:4px;font-family:var(--button--font-family);}regular-table span.rt-column-header-icon{font-size:10px;padding-left:3px;display:inline-block;width:10px;font-family:var(--button--font-family);}regular-table span.rt-row-header-icon:hover{color:#1a7da1;text-shadow:0px 0px 3px#1a7da1;}regular-table .rt-selected td{background-color:#eee;}regular-table .rt-cell-clip{overflow:hidden;text-overflow:ellipsis;}regular-table td span.rt-group-name,regular-table th span.rt-group-name{margin-right:-5px;padding-right:5px;padding-left:8px;flex:1;height:100%;}regular-table th span.rt-group-name{text-align:left;}regular-table td th span.rt-group-leaf,regular-table th span.rt-group-leaf{margin-left:16px;height:100%;}regular-table .rt-column-resize{height:100%;width:10px;position:absolute;top:0;right:0;cursor:col-resize;}regular-table a{color:var(--rt-pos-cell--color);}regular-table a:visited{color:var(--active--color);}regular-table td.psp-null:after,regular-table th.psp-null:after{content:var(--null--content,"-");}.psp-header-border:not(.psp-is-top):not(.psp-header-leaf){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-group{box-shadow:0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-is-top{box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045);}.psp-is-top.psp-header-group:not(.psp-header-group-corner){box-shadow:5px 4px 0px -4px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}.psp-header-border.psp-header-group:not(.psp-is-top):not(.psp-header-group-corner){box-shadow:1px 0px var(--inactive--border-color,#8b868045),0px 10px 0 -9px var(--inactive--border-color,#8b868045);}perspective-viewer[settings] tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer[settings]) tr.rt-autosize .psp-header-leaf.psp-header-border:not(.psp-menu-enabled){box-shadow:1px 0px var(--inactive--border-color,#8b868045);}.psp-header-leaf.psp-header-border{box-shadow:5px -4px 0px -4px var(--inactive--border-color,#8b868045);}tr:only-child th{box-shadow:none!important;}regular-table tbody tr:hover th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover:after{border-color:var(--rt-hover--border-color,#c5c9d080)!important;box-shadow:0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover th.psp-tree-leaf.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover th.psp-tree-label.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr.psp-menu-open:hover:after{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:last-child:hover td.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color),0px 1px 0px var(--rt-hover--border-color,#c5c9d080);}regular-table tbody tr:hover+tr th.psp-tree-leaf:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr th.psp-tree-label:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td:not(.psp-row-selected):not(.psp-row-subselected){border-top-color:transparent;}regular-table tbody tr th:first-child:not(:empty),regular-table tbody tr th:first-child:empty+th:not(:empty),regular-table tbody tr th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr td:first-child{border-left-width:1px;border-left-color:transparent;}regular-table tbody tr th:last-child,regular-table tbody tr td:last-child{border-right-width:0px;border-right-color:transparent;}regular-table tbody tr:hover{color:inherit;}regular-table tbody tr:hover th:first-child:not(:empty),regular-table tbody tr:hover th:first-child:empty+th:not(:empty),regular-table tbody tr:hover th:first-child:empty~th:empty+th:not(:empty),regular-table tbody tr:hover td:first-child{border-left-color:var(--rt-hover--border-color,#c5c9d080)!important;}regular-table tbody tr:hover th:last-child,regular-table tbody tr:hover td:last-child{border-right-color:var(--rt-hover--border-color,#c5c9d080)!important;}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody td,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead th:not(.rt-group-corner){transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody{transform:translate(0,var(--regular-table--transform-y,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child th,perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child td,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child th,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:first-child:after{clip-path:polygon(0 var(--regular-table--clip-y,0),0 200%,200% 200%,200% var(--regular-table--clip-y,0));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table 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);}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:first-child td:first-of-type,:host(:not(.sub-cell-scroll-disabled)) regular-table table 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));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr:last-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table thead tr:last-child:after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:not(:first-child):after,:host(:not(.sub-cell-scroll-disabled)) regular-table table tbody tr:not(:first-child):after{transform:translate(var(--regular-table--transform-x,0px));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table tbody tr:hover:first-child:after,:host(:not(.sub-cell-scroll-disabled)) regular-table table 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));}perspective-viewer-datagrid:not(.sub-cell-scroll-disabled) regular-table table thead tr th.rt-group-corner+th:not(.rt-group-corner),:host(:not(.sub-cell-scroll-disabled)) regular-table table 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;}regular-table::-webkit-scrollbar,regular-table::-webkit-scrollbar-corner{background-color:transparent;height:12px;width:12px;}regular-table::-webkit-scrollbar-thumb{background-clip:content-box;background:var(--icon--color);border:5.5px solid var(--plugin--background);max-height:50%;max-width:50%;min-width:10%;min-height:10%;}perspective-viewer:not([settings]) regular-table table tr.rt-autosize+tr th{height:0px;}perspective-viewer:not([settings]) regular-table table tr.rt-autosize+tr th span{display:none;}:host-context(perspective-viewer:not([settings])) regular-table table tr.rt-autosize+tr th{height:0px;}:host-context(perspective-viewer:not([settings])) regular-table table tr.rt-autosize+tr th span{display:none;}perspective-viewer[settings] .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}perspective-viewer[settings] .psp-menu-enabled:hover,perspective-viewer[settings] tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}perspective-viewer[settings] tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}perspective-viewer[settings] td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}perspective-viewer[settings] tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}perspective-viewer[settings] tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}:host-context(perspective-viewer[settings]) .psp-menu-enabled{padding:0 6px;font-size:8px;border-radius:3px 3px 0 0;}:host-context(perspective-viewer[settings]) .psp-menu-enabled:hover,:host-context(perspective-viewer[settings]) tr:not(.rt-autosize) th.psp-menu-open{color:var(--plugin--background);background-color:var(--icon--color);border-bottom-color:var(--icon--color);cursor:pointer;}:host-context(perspective-viewer[settings]) tr:not(.rt-autosize) th.psp-menu-open:before{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;height:8px;width:10px;-webkit-mask-image:var(--column-settings-icon--mask-image);mask-image:var(--column-settings-icon--mask-image);margin-right:4px;background-color:var(--plugin--background);}:host-context(perspective-viewer[settings]) td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color);}:host-context(perspective-viewer[settings]) tr:first-child td.psp-menu-open{border-top-color:var(--icon--color)!important;}:host-context(perspective-viewer[settings]) tr:last-child td.psp-menu-open{box-shadow:inset -2px 0px 0px var(--icon--color),inset 2px 0px 0px var(--icon--color),inset 0px -2px 0px var(--icon--color);}perspective-viewer regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}:host-context(perspective-viewer) regular-table table thead tr:last-child th{border-bottom-width:1px;border-bottom-color:var(--inactive--border-color,#8b868045);}.psp-sort-enabled:hover{cursor:pointer;}.psp-row-selected,:hover .psp-row-selected,:hover th.psp-tree-leaf.psp-row-selected,:hover th.psp-tree-label.psp-row-selected{color:white!important;background-color:var(--selected-row--background-color,#ea7319)!important;border-color:var(--selected-row--background-color,#ea7319)!important;}.psp-row-selected.psp-tree-label:not(:hover):before{color:white;}.psp-row-subselected,:hover .psp-row-subselected,:hover th.psp-tree-leaf.psp-row-subselected,:hover th.psp-tree-label.psp-row-subselected{background:rgba(234,115,25,0.2)!important;}.psp-error{color:red;}td:focus{outline:#666;outline-style:dotted;outline-width:1px;}perspective-viewer.dragging regular-table{pointer-events:none;}:host-context(perspective-viewer.dragging) regular-table{pointer-events:none;}.psp-header-border:last-child{border-right-width:0px;}.psp-header-sort-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-desc-icon--mask-image);mask-image:var(--sort-desc-icon--mask-image);}.psp-header-sort-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-asc-icon--mask-image);mask-image:var(--sort-asc-icon--mask-image);}.psp-header-sort-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-desc-icon--mask-image);mask-image:var(--sort-col-desc-icon--mask-image);}.psp-header-sort-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-col-asc-icon--mask-image);mask-image:var(--sort-col-asc-icon--mask-image);}.psp-header-sort-abs-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-desc-icon--mask-image);mask-image:var(--sort-abs-desc-icon--mask-image);}.psp-header-sort-abs-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-asc-icon--mask-image);mask-image:var(--sort-abs-asc-icon--mask-image);}.psp-header-sort-abs-col-desc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-desc-icon--mask-image);mask-image:var(--sort-abs-col-desc-icon--mask-image);}.psp-header-sort-abs-col-asc:after{background-repeat:no-repeat;background-color:var(--icon--color);content:"";display:inline-block;-webkit-mask-size:cover;mask-size:cover;width:14px;height:11px;margin-left:4px;-webkit-mask-image:var(--sort-abs-col-asc-icon--mask-image);mask-image:var(--sort-abs-col-asc-icon--mask-image);}tbody th:last-of-type{border-right:1px solid var(--inactive--border-color,#8b868045);overflow:hidden;text-overflow:ellipsis;}tbody th:empty{background-image:linear-gradient(to right,transparent 9px,var(--inactive--border-color,#eee) 10px,transparent 11px);background-repeat:no-repeat;min-width:20px;max-width:20px;pointer-events:none;}.psp-tree-label{max-width:0px;min-width:0px;}.psp-tree-label:before{color:var(--icon--color);font-family:var(--button--font-family,inherit);padding-right:11px;}.psp-tree-label-expand:before{content:var(--tree-label-expand--content,"+");}.psp-tree-label-collapse:before{content:var(--tree-label-collapse--content,"-");}.psp-tree-label-expand,.psp-tree-label-collapse{cursor:pointer;}.psp-tree-label:hover:before{color:var(--active--color);text-shadow:0px 0px 5px var(--active--color);}.psp-tree-leaf{padding-left:24px;}.psp-align-right{text-align:right;}.psp-align-left{text-align:left;}.psp-positive:not(:focus){color:var(--rt-pos-cell--color);}.psp-negative:not(:focus){color:var(--rt-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-bottom-width:0px;border-left-width:0px;}.boolean-editable{cursor:pointer;}regular-table table{user-select:none;color:inherit;border-collapse:separate;}regular-table table th{font-weight:400;}regular-table table td,regular-table table th{border-color:var(--inactive--border-color,#8b868045);height:23px;}regular-table table .psp-header-group{text-overflow:ellipsis;}regular-table table th.psp-header-leaf{border-bottom-width:0px;}regular-table table th.psp-header-leaf span{height:23px;min-height:23px;}regular-table table td,regular-table table th.psp-tree-label,regular-table table th.psp-tree-label,regular-table table th.psp-tree-leaf,regular-table table tbody tr:first-child th{border-style:solid;border-width:0px;border-top-width:1px;}regular-table table tbody th:empty{background-position:0px -10px;}regular-table table td.psp-select-region,regular-table table th.psp-select-region{background-color:var(--icon--color)!important;color:var(--plugin--background)!important;border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected),regular-table tbody tr:hover+tr td.psp-select-region:not(.psp-row-selected):not(.psp-row-subselected){border-color:var(--plugin--background)!important;}regular-table tbody tr:hover td.psp-select-region.psp-menu-open:not(.psp-row-selected):not(.psp-row-subselected){box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}:host-context(perspective-viewer[settings]) td.psp-select-region.psp-menu-open{box-shadow:inset -2px 0px 0px var(--plugin--background),inset 2px 0px 0px var(--plugin--background);}regular-table #psp-column-edit-buttons th:not(.rt-group-corner) span:not(.rt-column-resize):before{content:var(--datagrid-column-edit-button--content,"Edit");}perspective-viewer:not([settings]) regular-table #psp-column-edit-buttons:after{content:none;}:host-context(perspective-viewer:not([settings])) regular-table #psp-column-edit-buttons:after{content:none;}regular-table table thead tr:last-child:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-bottom:1px solid var(--inactive--border-color);}regular-table table tbody tr:after{width:10000px;box-sizing:border-box;display:block;height:23px;content:" ";border-top:1px solid transparent;}regular-table table tbody tr:not(:first-child):after{border-top:1px solid var(--inactive--border-color);}regular-table table tbody tr:hover:not(:first-child):after{border-top:1px solid var(--rt-hover--border-color);}regular-table table tbody tr:hover+tr:after{border-top:1px solid var(--rt-hover--border-color);}@keyframes pulse_pos{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_pos2{0%{background-color:var(--pulse--background-color-start,rgba(0,128,255,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(0,128,255,0));}}@keyframes pulse_neg{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}@keyframes pulse_neg2{0%{background-color:var(--pulse--background-color-start,rgba(255,25,0,0.5));}100%{background-color:var(--pulse--background-color-end,rgba(255,25,0,0));}}';var wt=class e extends HTMLElement{static#t=!1;static#e;static renderTarget=window.CSS?.supports&&window.CSS?.supports("selector(:host-context(foo))")?"shadow":"light";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=e;t.#e||(t.#e=new CSSStyleSheet,t.#e.replaceSync(Zr)),t.renderTarget==="shadow"?this.attachShadow({mode:"open"}).adoptedStyleSheets.push(t.#e):t.renderTarget==="light"&&!t.#t&&(t.#t=!0,document.adoptedStyleSheets.push(t.#e))}connectedCallback(){this._toolbar||(this._toolbar=document.createElement("perspective-viewer-datagrid-toolbar"));let t=this.parentElement;t&&t.appendChild(this._toolbar)}disconnectedCallback(){this._toolbar?.parentElement?.removeChild?.(this._toolbar)}async activate(t){return await Br.call(this,t)}get name(){return"Datagrid"}get category(){return"Basic"}get select_mode(){return"toggle"}get min_config_columns(){}get config_column_names(){return["Columns"]}get priority(){return 1}can_render_column_styles(t,o){return t!=="boolean"}column_style_controls(t,o){return Bt.call(this,t,o)}async draw(t){return await Fr.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 o=await t.dimensions();this.model._num_rows=o.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){let o=await this.parentElement.getView(),s=await o.to_columns(t),r=await o.column_paths(t),l=t.end_row-t.start_row,i="";for(let n=0;n<l;n++){for(let a of r){let c=s[a],d=this.model._schema[a],h=$r(d,this.regular_table[Y][a.split("|").at(-1)]||{});h?i+=h.format(c[n])+" ":i+=c[n]+" "}i+=`
16
+ `}return i.trim()}async resize(){!this.isConnected||this.offsetParent==null||this._initialized&&await this.regular_table.draw()}async clear(){this.regular_table._resetAutoSize(),this.regular_table.clear()}save(){return qr.call(this)}restore(t,o){return Xr.call(this,t,o)}async restyle(t){await this.draw(t)}delete(){this._toolbar=void 0,this.regular_table.table_model&&this.regular_table._resetAutoSize(),this.regular_table.clear()}};var Kr=':host{position:relative;display:block;height:100%;}:host #container{position:absolute;display:flex;flex-direction:column;justify-content:stretch;align-items:stretch;top:0;left:0;right:0;bottom:0;}:host #toolbar{display:flex;align-items:stretch;height:100%;}:host #toolbar .hover-target{margin:0;display:inline-flex;align-items:center;cursor:pointer;}:host #toolbar .hover-target:hover{box-shadow:-4px 0 0 var(--icon--color),4px 0 0 var(--icon--color);background-color:var(--icon--color);}:host #slot-container{flex:1;position:relative;}#scroll_lock.lock-scroll:before{-webkit-mask-image:var(--toolbar-scroll-lock-active--content);}#scroll_lock:before{-webkit-mask-image:var(--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(--toolbar-edit-mode--read-only--content);}#edit_mode[data-edit-mode="EDIT"]:before{-webkit-mask-image:var(--toolbar-edit-mode--edit--content);}:host(.aggregated) #toolbar #edit_mode[data-edit-mode="EDIT"]:before{-webkit-mask-image:var(--toolbar-edit-mode--read-only--content);}#edit_mode[data-edit-mode="SELECT_ROW"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-row--content);}#edit_mode[data-edit-mode="SELECT_COLUMN"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-column--content);}#edit_mode[data-edit-mode="SELECT_REGION"]:before{-webkit-mask-image:var(--toolbar-edit-mode--select-region--content);}#edit_mode[data-edit-mode="READ_ONLY"] span:before{content:var(--edit-mode--read-only--content,"Read Only");}#edit_mode[data-edit-mode="EDIT"] span:before{content:var(--edit-mode--edit--content,"Editable");}#edit_mode[data-edit-mode="SELECT_ROW"] span:before{content:var(--edit-mode--select-row--content,"Row Select");}#edit_mode[data-edit-mode="SELECT_COLUMN"] span:before{content:var(--edit-mode--select-column--content,"Column Select");}#edit_mode[data-edit-mode="SELECT_REGION"] span:before{content:var(--edit-mode--select-region--content,"Region Select");}#scroll_lock span:before{content:var(--scroll-lock-toggle--content,"Free Scroll");}#scroll_lock.lock-scroll span:before{content:var(--scroll-lock-alt-toggle--content,"Align Scroll");}.button:before{width:21px;height:21px;content:"";-webkit-mask-size:cover;mask-size:cover;background-color:var(--icon--color);}.button.editable:before,.button.lock-scroll:before{color:inherit;}.button{display:inline-flex;justify-content:center;align-items:center;user-select:none;padding:0 5px;border:1px solid transparent;border-radius:3px;border:1px solid transparent;box-sizing:border-box;display:inline-flex;font-size:var(--label--font-size,0.75em);height:22px;user-select:none;white-space:nowrap;width:37px;}.button>span{display:none;margin:0;padding:0;}.hover-target:focus-within .button,.hover-target:hover .button{position:relative;background-color:var(--icon--color);color:var(--plugin--background);opacity:1;display:flex;align-items:center;cursor:pointer;}.hover-target:focus-within .button:before,.hover-target:hover .button:before{background-color:var(--plugin--background);}.hover-target:focus-within .button>span,.hover-target:hover .button>span{display:block;position:absolute;top:calc(100% + 3px);left:50%;translate:-50%;margin:0;padding:5px;height:auto;white-space:pre-wrap;line-height:1;font-size:9px;background-color:var(--icon--color);width:35px;text-align:center;border-radius:0 0 3px 3px;}';var Vr=new CSSStyleSheet;Vr.replaceSync(Kr);var xt=class extends HTMLElement{connectedCallback(){if(this._initialized)return;this._initialized=!0,this.setAttribute("slot","plugin-settings"),this.attachShadow({mode:"open"}),this.shadowRoot.adoptedStyleSheets.push(Vr),this.shadowRoot.innerHTML=`
17
+ <div id="toolbar">
18
+ <span class="hover-target">
19
+ <span id="scroll_lock" class="button">
20
+ <span></span>
21
+ </span>
22
+ </span>
23
+ <span class="hover-target">
24
+ <span id="edit_mode" class="button" data-edit-mode="READ_ONLY">
25
+ <span></span>
26
+ </span>
27
+ </span>
28
+ </div>
29
+ `;let t=this.parentElement,o=this.previousElementSibling;o._scroll_lock=this.shadowRoot.querySelector("#scroll_lock"),o._scroll_lock.addEventListener("click",()=>yt.call(o)),o._edit_button=this.shadowRoot.querySelector("#edit_mode"),o._edit_button.addEventListener("click",()=>{gt.call(o),o.regular_table.draw(),t.dispatchEvent(new Event("perspective-config-update"))})}};async function Gi(){customElements.define("perspective-viewer-datagrid-toolbar",xt),customElements.define("perspective-viewer-datagrid",wt),await customElements.whenDefined("perspective-viewer"),customElements.get("perspective-viewer").registerPlugin("perspective-viewer-datagrid")}Gi();
30
+ /*! Bundled license information:
31
+
32
+ chroma-js/src/utils/contrastAPCA.js:
33
+ (**
34
+ * @license
35
+ *
36
+ * The APCA contrast prediction algorithm is based of the formulas published
37
+ * in the APCA-1.0.98G specification by Myndex. The specification is available at:
38
+ * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
39
+ *
40
+ * Note that the APCA implementation is still beta, so please update to
41
+ * future versions of chroma.js when they become available.
42
+ *
43
+ * You can read more about the APCA Readability Criterion at
44
+ * https://readtech.org/ARC/
45
+ *)
46
+ */
47
+ //# sourceMappingURL=perspective-viewer-datagrid.js.map