precision-dashwidgets 0.4.1 → 0.5.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.
@@ -1,17 +1,17 @@
1
- (function(Ii,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("element-plus"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia"],c):(Ii=typeof globalThis<"u"?globalThis:Ii||self,c(Ii["precision-dashwidgets"]={},Ii.Vue,Ii.ElementPlus,Ii.Pinia))})(this,(function(Ii,c,PI,Ag){"use strict";/*! Element Plus Icons Vue v2.3.2 */var $I=c.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(c.openBlock(),c.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[c.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.99 12.99 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"})]))}}),VI=$I;function er(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Za(e){return function t(n){return arguments.length===0||er(n)?t:e.apply(this,arguments)}}function to(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return er(n)?t:Za(function(i){return e(n,i)});default:return er(n)&&er(r)?t:er(n)?Za(function(i){return e(i,r)}):er(r)?Za(function(i){return e(n,i)}):e(n,r)}}}function zI(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return er(n)?t:to(function(s,a){return e(n,s,a)});case 2:return er(n)&&er(r)?t:er(n)?to(function(s,a){return e(s,r,a)}):er(r)?to(function(s,a){return e(n,s,a)}):Za(function(s){return e(n,r,s)});default:return er(n)&&er(r)&&er(i)?t:er(n)&&er(r)?to(function(s,a){return e(s,a,i)}):er(n)&&er(i)?to(function(s,a){return e(s,r,a)}):er(r)&&er(i)?to(function(s,a){return e(n,s,a)}):er(n)?Za(function(s){return e(s,r,i)}):er(r)?Za(function(s){return e(n,s,i)}):er(i)?Za(function(s){return e(n,r,s)}):e(n,r,i)}}}const GI=Number.isInteger||function(e){return e<<0===e};function jI(e,t){var n=e<0?t.length+e:e;return t[n]}var YI=to(function(e,t){return t==null||t!==t?e:t});function WI(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];GI(i)?n=jI(i,n):n=n[i]}return n}var HI=zI(function(e,t,n){return YI(e,WI(t,n))});const Lh=Ag.defineStore("duckdb",()=>{const e=c.ref(null),t=c.ref(!1),n=c.ref(!1),r=c.ref(""),i=c.ref(new Map),s=c.ref(new Map),a=c.ref(new Map);let o=null;const l=c.computed(()=>t.value&&!r.value),u=c.computed(()=>at=>i.value.get(at)),f=c.computed(()=>at=>{const ct=i.value.get(at);return ct&&!ct.isLoading&&!ct.error}),p=c.computed(()=>s.value.size),E=c.computed(()=>s.value.size>0),T=async()=>{if(typeof window>"u"||typeof Worker>"u"){const at="DuckDB can only be initialized in the browser.";throw r.value=at,new Error(at)}return e.value?e.value:o?(await o,e.value):(n.value=!0,r.value="",o=(async()=>{try{const at=await Promise.resolve().then(()=>GP),ct={mvp:{mainModule:"/static/duckdb/duckdb-mvp.wasm",mainWorker:"/static/duckdb/duckdb-browser-mvp.worker.js"},eh:{mainModule:"/static/duckdb/duckdb-eh.wasm",mainWorker:"/static/duckdb/duckdb-browser-eh.worker.js"}},m=await at.selectBundle(ct),F=new Worker(m.mainWorker),h=new at.ConsoleLogger(at.LogLevel.WARNING);return e.value=new at.AsyncDuckDB(h,F),await e.value.instantiate(m.mainModule),t.value=!0,e.value}catch(at){throw r.value=`Failed to initialize DuckDB: ${(at==null?void 0:at.message)||at}`,e.value=null,at}finally{n.value=!1,o=null}})(),await o,e.value)},U=async at=>{e.value||await T();const ct=await e.value.connect(),m=at||`conn_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;return s.value.set(m,{connection:ct,viewerId:m,createdAt:new Date}),{connection:ct,connectionId:m}},J=async at=>{const ct=s.value.get(at);ct&&(await ct.connection.close(),s.value.delete(at),lt(at),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},lt=at=>{for(const[ct,m]of a.value)m.delete(at),m.size===0&&console.log(`File ${ct} is no longer used by any viewers`)},X=(at,ct)=>{a.value.has(at)||a.value.set(at,new Set),a.value.get(at).add(ct)},Kt=async at=>{const ct=i.value.get(at);if(ct&&ct.tableName)try{const m=await e.value.connect();await m.query(`DROP TABLE IF EXISTS ${ct.tableName};`),await m.close()}catch(m){console.warn(`Failed to drop table ${ct.tableName}:`,m)}i.value.delete(at),a.value.delete(at)},Jt=async(at,ct,m="my_data",F={},h=null,L=null)=>{const $=L||at,D=i.value.get($);if(D&&!D.isLoading&&!D.error)return h&&X($,h),D.tableName;l.value||await T(),i.value.set($,{tableName:m,fileType:ct,fileUrl:at,isLoading:!0,error:null});try{const z=await fetch(at);if(!z.ok)throw new Error(`Failed to fetch file: ${z.status} ${z.statusText}`);let Z;if(ct==="csv"){const st=await z.text(),qt=await new Blob([st],{type:"text/csv"}).arrayBuffer();Z=new Uint8Array(qt)}else{const st=await z.arrayBuffer();Z=new Uint8Array(st)}const _t=`${L||m}.${ct}`;await e.value.registerFileBuffer(_t,Z);const wt=await e.value.connect();try{let st;if(ct==="csv"){const ne={header:!0,delimiter:",",...F};st=`
1
+ (function(pi,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue"),require("element-plus"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia"],c):(pi=typeof globalThis<"u"?globalThis:pi||self,c(pi["precision-dashwidgets"]={},pi.Vue,pi.ElementPlus,pi.Pinia))})(this,(function(pi,c,mT,jg){"use strict";/*! Element Plus Icons Vue v2.3.2 */var yT=c.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(c.openBlock(),c.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[c.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.99 12.99 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"})]))}}),gT=yT;function cr(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function eo(e){return function t(n){return arguments.length===0||cr(n)?t:e.apply(this,arguments)}}function no(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return cr(n)?t:eo(function(i){return e(n,i)});default:return cr(n)&&cr(r)?t:cr(n)?eo(function(i){return e(i,r)}):cr(r)?eo(function(i){return e(n,i)}):e(n,r)}}}function _T(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return cr(n)?t:no(function(s,a){return e(n,s,a)});case 2:return cr(n)&&cr(r)?t:cr(n)?no(function(s,a){return e(s,r,a)}):cr(r)?no(function(s,a){return e(n,s,a)}):eo(function(s){return e(n,r,s)});default:return cr(n)&&cr(r)&&cr(i)?t:cr(n)&&cr(r)?no(function(s,a){return e(s,a,i)}):cr(n)&&cr(i)?no(function(s,a){return e(s,r,a)}):cr(r)&&cr(i)?no(function(s,a){return e(n,s,a)}):cr(n)?eo(function(s){return e(s,r,i)}):cr(r)?eo(function(s){return e(n,s,i)}):cr(i)?eo(function(s){return e(n,r,s)}):e(n,r,i)}}}const vT=Number.isInteger||function(e){return e<<0===e};function bT(e,t){var n=e<0?t.length+e:e;return t[n]}var wT=no(function(e,t){return t==null||t!==t?e:t});function ST(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];vT(i)?n=bT(i,n):n=n[i]}return n}var ET=_T(function(e,t,n){return wT(e,ST(t,n))});const $h=jg.defineStore("duckdb",()=>{const e=c.ref(null),t=c.ref(!1),n=c.ref(!1),r=c.ref(""),i=c.ref(new Map),s=c.ref(new Map),a=c.ref(new Map);let o=null;const l=c.computed(()=>t.value&&!r.value),u=c.computed(()=>rt=>i.value.get(rt)),d=c.computed(()=>rt=>{const ot=i.value.get(rt);return ot&&!ot.isLoading&&!ot.error}),h=c.computed(()=>s.value.size),y=c.computed(()=>s.value.size>0),S=async()=>{if(typeof window>"u"||typeof Worker>"u"){const rt="DuckDB can only be initialized in the browser.";throw r.value=rt,new Error(rt)}return e.value?e.value:o?(await o,e.value):(n.value=!0,r.value="",o=(async()=>{try{const rt=await Promise.resolve().then(()=>o8),ot={mvp:{mainModule:"/static/duckdb/duckdb-mvp.wasm",mainWorker:"/static/duckdb/duckdb-browser-mvp.worker.js"},eh:{mainModule:"/static/duckdb/duckdb-eh.wasm",mainWorker:"/static/duckdb/duckdb-browser-eh.worker.js"}},m=await rt.selectBundle(ot),T=new Worker(m.mainWorker),p=new rt.ConsoleLogger(rt.LogLevel.WARNING);return e.value=new rt.AsyncDuckDB(p,T),await e.value.instantiate(m.mainModule),t.value=!0,e.value}catch(rt){throw r.value=`Failed to initialize DuckDB: ${(rt==null?void 0:rt.message)||rt}`,e.value=null,rt}finally{n.value=!1,o=null}})(),await o,e.value)},M=async rt=>{e.value||await S();const ot=await e.value.connect(),m=rt||`conn_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;return s.value.set(m,{connection:ot,viewerId:m,createdAt:new Date}),{connection:ot,connectionId:m}},H=async rt=>{const ot=s.value.get(rt);ot&&(await ot.connection.close(),s.value.delete(rt),nt(rt),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},nt=rt=>{for(const[ot,m]of a.value)m.delete(rt),m.size===0&&console.log(`File ${ot} is no longer used by any viewers`)},j=(rt,ot)=>{a.value.has(rt)||a.value.set(rt,new Set),a.value.get(rt).add(ot)},$t=async rt=>{const ot=i.value.get(rt);if(ot&&ot.tableName)try{const m=await e.value.connect();await m.query(`DROP TABLE IF EXISTS ${ot.tableName};`),await m.close()}catch(m){console.warn(`Failed to drop table ${ot.tableName}:`,m)}i.value.delete(rt),a.value.delete(rt)},Ct=async(rt,ot,m="my_data",T={},p=null,L=null)=>{const C=L||rt,R=i.value.get(C);if(R&&!R.isLoading&&!R.error)return p&&j(C,p),R.tableName;l.value||await S(),i.value.set(C,{tableName:m,fileType:ot,fileUrl:rt,isLoading:!0,error:null});try{const U=await fetch(rt);if(!U.ok)throw new Error(`Failed to fetch file: ${U.status} ${U.statusText}`);let tt;if(ot==="csv"){const J=await U.text(),Jt=await new Blob([J],{type:"text/csv"}).arrayBuffer();tt=new Uint8Array(Jt)}else{const J=await U.arrayBuffer();tt=new Uint8Array(J)}const ht=`${L||m}.${ot}`;await e.value.registerFileBuffer(ht,tt);const ut=await e.value.connect();try{let J;if(ot==="csv"){const re={header:!0,delimiter:",",...T};J=`
2
2
  CREATE OR REPLACE TABLE ${m} AS
3
- SELECT * FROM read_csv('${_t}', header=${ne.header}, delim='${ne.delimiter}');
4
- `}else if(ct==="parquet")st=`
3
+ SELECT * FROM read_csv('${ht}', header=${re.header}, delim='${re.delimiter}');
4
+ `}else if(ot==="parquet")J=`
5
5
  CREATE OR REPLACE TABLE ${m} AS
6
- SELECT * FROM read_parquet('${_t}');
7
- `;else throw new Error(`Unsupported file type: ${ct}`);await wt.query(st);const qt=(await wt.query(`SELECT COUNT(*) as count FROM ${m};`)).toArray()[0].count;return i.value.set($,{tableName:m,fileType:ct,fileUrl:at,isLoading:!1,error:null,rowCount:qt,loadedAt:new Date}),h&&X($,h),m}finally{await wt.close()}}catch(z){throw i.value.set($,{tableName:m,fileType:ct,fileUrl:at,isLoading:!1,error:z.message}),z}},ue=async(at,ct)=>{const m=s.value.get(ct);if(!m)throw new Error(`Connection not found: ${ct}`);return(await m.connection.query(at)).toArray().map(F=>{const h={};for(const[L,$]of Object.entries(F))h[L]=$;return h})},Wt=async()=>{for(const[at,ct]of s.value)try{await ct.connection.close(),console.log(`Closed connection: ${at}`)}catch(m){console.warn(`Error closing connection ${at}:`,m)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(at){console.warn("Error terminating DuckDB:",at)}e.value=null}t.value=!1,i.value.clear(),a.value.clear(),r.value=""},le=async(at=!1)=>{at||s.value.size===0?await Wt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},$t=()=>{const at=[];for(const[ct,m]of s.value)at.push({connectionId:ct,viewerId:m.viewerId,createdAt:m.createdAt});return at},yn=()=>{const at=[];for(const[ct,m]of a.value){const F=i.value.get(ct);at.push({fileId:ct,tableName:F==null?void 0:F.tableName,fileType:F==null?void 0:F.fileType,fileUrl:F==null?void 0:F.fileUrl,rowCount:F==null?void 0:F.rowCount,loadedAt:F==null?void 0:F.loadedAt,usedByViewers:Array.from(m)})}return at},Ge=c.ref(null),ce=c.ref(0);function Qt(at){return`"${String(at).replace(/"/g,'""')}"`}return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:a,sharedResultName:Ge,sharedVersion:ce,isReady:l,getLoadedFile:u,isFileLoaded:f,activeConnectionCount:p,hasActiveConnections:E,initDuckDB:T,createConnection:U,closeConnection:J,cleanupViewerFileUsage:lt,trackFileUsage:X,unloadFile:Kt,loadFile:Jt,executeQuery:ue,cleanup:le,performGlobalCleanup:Wt,getConnectionInfo:$t,getFileUsageInfo:yn,publishViewFromQuery:async(at,ct,m)=>{var F;const h=(F=s.value.get(m))==null?void 0:F.connection;if(!h)throw new Error(`Connection not found: ${m}`);await h.query(`CREATE OR REPLACE VIEW ${Qt(at)} AS ${ct}`),Ge.value=at,ce.value++},publishTableFromQuery:async(at,ct,m)=>{var F;const h=(F=s.value.get(m))==null?void 0:F.connection;if(!h)throw new Error(`Connection not found: ${m}`);await h.query(`CREATE OR REPLACE TABLE ${Qt(at)} AS ${ct}`),Ge.value=at,ce.value++},formatIdFromUrl:at=>"url_"+btoa(at).replace(/=+$/,"").replace(/[+/]/g,"_")}}),Lo=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},qI={class:"dashboard-container"},XI={class:"dashboard-header"},KI={class:"dashboard-content"},QI={key:0,class:"query-panel"},JI={class:"query-examples"},ZI=["onClick"],tT={key:1,class:"results-panel"},eT={class:"results-controls"},nT={class:"left-controls"},rT={class:"right-controls"},iT={key:0,class:"table-container"},sT={class:"results-table"},aT={key:0,class:"bottom-pagination"},oT={key:1,class:"json-container"},lT={key:2,class:"error-panel"},cT={__name:"DataExplorer",props:{url:{type:String,default:""},fileType:{type:String,default:"parquet",validator:e=>["parquet","csv"].includes(e)},viewerId:{type:String,default:()=>`viewer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`},fileId:{type:String,default:null}},emits:["query-results"],setup(e,{emit:t}){const n=e,r=t,i=Lh(),s=c.ref({header:!0,dynamicTyping:!0,delimiter:","}),a=c.ref(!1),o=c.ref(!1),l=c.ref(n.url),u=c.ref("my_data"),f=c.ref(""),p=c.ref(null),E=c.ref(""),T=c.ref("table"),U=c.ref(1),J=c.ref(50),lt=c.ref(null);c.watch(()=>n.url,async D=>{if(l.value=D,D)try{await ce()}catch{console.error("file can not be loaded")}},{immediate:!0});const X=c.computed(()=>i.isReady&&lt.value&&!a.value),Kt=c.computed(()=>i.formatIdFromUrl(n.url)),Jt=c.computed(()=>a.value?"Loading...":i.isInitializing?"Initializing...":i.isReady?X.value?"Connected":"Not Connected":"Not Ready"),ue=c.computed(()=>!p.value||!Array.isArray(p.value)||p.value.length===0?[]:Object.keys(p.value[0]||{})),Wt=c.computed(()=>!p.value||!Array.isArray(p.value)?0:Math.ceil(p.value.length/J.value)),le=c.computed(()=>{if(!p.value||!Array.isArray(p.value))return[];const D=(U.value-1)*J.value,z=D+J.value;return p.value.slice(D,z)}),$t=c.computed(()=>[{name:"Show All",query:"SELECT * FROM data;"},{name:"Count Rows",query:"SELECT COUNT(*) as row_count FROM data;"},{name:"Group By",query:`SELECT
6
+ SELECT * FROM read_parquet('${ht}');
7
+ `;else throw new Error(`Unsupported file type: ${ot}`);await ut.query(J);const Jt=(await ut.query(`SELECT COUNT(*) as count FROM ${m};`)).toArray()[0].count;return i.value.set(C,{tableName:m,fileType:ot,fileUrl:rt,isLoading:!1,error:null,rowCount:Jt,loadedAt:new Date}),p&&j(C,p),m}finally{await ut.close()}}catch(U){throw i.value.set(C,{tableName:m,fileType:ot,fileUrl:rt,isLoading:!1,error:U.message}),U}},Zt=async(rt,ot)=>{const m=s.value.get(ot);if(!m)throw new Error(`Connection not found: ${ot}`);return(await m.connection.query(rt)).toArray().map(T=>{const p={};for(const[L,C]of Object.entries(T))p[L]=C;return p})},Lt=async()=>{for(const[rt,ot]of s.value)try{await ot.connection.close(),console.log(`Closed connection: ${rt}`)}catch(m){console.warn(`Error closing connection ${rt}:`,m)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(rt){console.warn("Error terminating DuckDB:",rt)}e.value=null}t.value=!1,i.value.clear(),a.value.clear(),r.value=""},ie=async(rt=!1)=>{rt||s.value.size===0?await Lt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},xt=()=>{const rt=[];for(const[ot,m]of s.value)rt.push({connectionId:ot,viewerId:m.viewerId,createdAt:m.createdAt});return rt},on=()=>{const rt=[];for(const[ot,m]of a.value){const T=i.value.get(ot);rt.push({fileId:ot,tableName:T==null?void 0:T.tableName,fileType:T==null?void 0:T.fileType,fileUrl:T==null?void 0:T.fileUrl,rowCount:T==null?void 0:T.rowCount,loadedAt:T==null?void 0:T.loadedAt,usedByViewers:Array.from(m)})}return rt},ge=c.ref(null),ne=c.ref(0);function Qt(rt){return`"${String(rt).replace(/"/g,'""')}"`}return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:a,sharedResultName:ge,sharedVersion:ne,isReady:l,getLoadedFile:u,isFileLoaded:d,activeConnectionCount:h,hasActiveConnections:y,initDuckDB:S,createConnection:M,closeConnection:H,cleanupViewerFileUsage:nt,trackFileUsage:j,unloadFile:$t,loadFile:Ct,executeQuery:Zt,cleanup:ie,performGlobalCleanup:Lt,getConnectionInfo:xt,getFileUsageInfo:on,publishViewFromQuery:async(rt,ot,m)=>{var T;const p=(T=s.value.get(m))==null?void 0:T.connection;if(!p)throw new Error(`Connection not found: ${m}`);await p.query(`CREATE OR REPLACE VIEW ${Qt(rt)} AS ${ot}`),ge.value=rt,ne.value++},publishTableFromQuery:async(rt,ot,m)=>{var T;const p=(T=s.value.get(m))==null?void 0:T.connection;if(!p)throw new Error(`Connection not found: ${m}`);await p.query(`CREATE OR REPLACE TABLE ${Qt(rt)} AS ${ot}`),ge.value=rt,ne.value++},formatIdFromUrl:rt=>"url_"+btoa(rt).replace(/=+$/,"").replace(/[+/]/g,"_")}}),ko=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},IT={class:"dashboard-container"},TT={class:"dashboard-header"},AT={class:"dashboard-content"},xT={key:0,class:"query-panel"},NT={class:"query-examples"},RT=["onClick"],BT={key:1,class:"results-panel"},OT={class:"results-controls"},DT={class:"left-controls"},FT={class:"right-controls"},LT={key:0,class:"table-container"},MT={class:"results-table"},CT={key:0,class:"bottom-pagination"},kT={key:1,class:"json-container"},UT={key:2,class:"error-panel"},PT={__name:"DataExplorer",props:{url:{type:String,default:""},fileType:{type:String,default:"parquet",validator:e=>["parquet","csv"].includes(e)},viewerId:{type:String,default:()=>`viewer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`},fileId:{type:String,default:null}},emits:["query-results"],setup(e,{emit:t}){const n=e,r=t,i=$h(),s=c.ref({header:!0,dynamicTyping:!0,delimiter:","}),a=c.ref(!1),o=c.ref(!1),l=c.ref(n.url),u=c.ref("my_data"),d=c.ref(""),h=c.ref(null),y=c.ref(""),S=c.ref("table"),M=c.ref(1),H=c.ref(50),nt=c.ref(null);c.watch(()=>n.url,async R=>{if(l.value=R,R)try{await ne()}catch{console.error("file can not be loaded")}},{immediate:!0});const j=c.computed(()=>i.isReady&&nt.value&&!a.value),$t=c.computed(()=>i.formatIdFromUrl(n.url)),Ct=c.computed(()=>a.value?"Loading...":i.isInitializing?"Initializing...":i.isReady?j.value?"Connected":"Not Connected":"Not Ready"),Zt=c.computed(()=>!h.value||!Array.isArray(h.value)||h.value.length===0?[]:Object.keys(h.value[0]||{})),Lt=c.computed(()=>!h.value||!Array.isArray(h.value)?0:Math.ceil(h.value.length/H.value)),ie=c.computed(()=>{if(!h.value||!Array.isArray(h.value))return[];const R=(M.value-1)*H.value,U=R+H.value;return h.value.slice(R,U)}),xt=c.computed(()=>[{name:"Show All",query:"SELECT * FROM data;"},{name:"Count Rows",query:"SELECT COUNT(*) as row_count FROM data;"},{name:"Group By",query:`SELECT
8
8
  column1, column2,
9
9
  COUNT(*) as count
10
10
  FROM data
11
11
  GROUP BY column1, column2
12
12
  ORDER BY column1, column2
13
- LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);c.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:lt.value,tableName:u.value,isConnected:X.value,activeConnections:i.activeConnectionCount,hasActiveConnections:i.hasActiveConnections}));async function yn(){if(lt.value)return;const{connectionId:D}=await i.createConnection(n.viewerId);lt.value=D}const Ge=async()=>{try{lt.value||await yn(),l.value&&await ce()}catch(D){console.error("Failed to initialize viewer:",D),E.value=`Failed to initialize: ${D.message}`}},ce=async()=>{if(!l.value){E.value="Please provide a valid S3 URL";return}a.value=!0,E.value="";try{const D=n.fileId?`file_${n.fileId}`:`data_${Date.now()}`,z=await i.loadFile(l.value,n.fileType,D,s.value,n.viewerId,Kt.value);u.value=z,F("SELECT * FROM data;")}catch{}finally{a.value=!1}},Qt=D=>!u.value||!D?D:D.replace(/\bFROM\s+data\b/gi,`FROM ${u.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${u.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${u.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${u.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${u.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${u.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${u.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${u.value})`),at=async()=>{if(!f.value||!lt.value){E.value="Please provide a valid SQL query";return}if(!u.value){E.value="No data table loaded";return}o.value=!0,E.value="",U.value=1;try{const D=Qt(f.value.trim());p.value=await i.executeQuery(D,lt.value),await i.publishViewFromQuery("umap_result",D,lt.value),r("query-results",{results:p.value,query:D})}catch(D){console.error("Query execution failed:",D),E.value=`Query execution failed: ${D.message}`,p.value=null}finally{o.value=!1}},ct=D=>{U.value=D},m=D=>{J.value=D,U.value=1},F=D=>{f.value=D},h=D=>D==null?"NULL":typeof D=="number"?Number.isInteger(D)?D.toString():D.toFixed(4):typeof D=="string"&&D.length>100?D.substring(0,100)+"...":D.toString(),L=()=>{if(!p.value||p.value.length===0)return;const D=Object.keys(p.value[0]),z=[D.join(","),...p.value.map(st=>D.map(qt=>{const ne=st[qt],Zt=ne==null?"":ne.toString();return Zt.includes(",")?`"${Zt}"`:Zt}).join(","))].join(`
14
- `),Z=new Blob([z],{type:"text/csv"}),_t=URL.createObjectURL(Z),wt=document.createElement("a");wt.href=_t,wt.download="query-results.csv",wt.click(),URL.revokeObjectURL(_t)},$=()=>{E.value=""};return c.onMounted(async()=>{await Ge()}),c.onUnmounted(async()=>{lt.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(lt.value),i.activeConnectionCount,i.loadedFiles.size)}),(D,z)=>{const Z=c.resolveComponent("bf-button"),_t=c.resolveComponent("el-pagination");return c.openBlock(),c.createElementBlock("div",qI,[c.createElementVNode("header",XI,[z[3]||(z[3]=c.createElementVNode("h1",null,"Data Explorer",-1)),c.createElementVNode("div",{class:c.normalizeClass(["status-indicator",{connected:X.value,loading:a.value}])},c.toDisplayString(Jt.value),3)]),c.createElementVNode("div",KI,[X.value?(c.openBlock(),c.createElementBlock("div",QI,[z[5]||(z[5]=c.createElementVNode("h3",null,"SQL Query",-1)),c.createElementVNode("div",JI,[z[4]||(z[4]=c.createElementVNode("span",null,"Quick queries:",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList($t.value,wt=>(c.openBlock(),c.createElementBlock("button",{key:wt.name,onClick:st=>F(wt.query),class:"example-btn"},c.toDisplayString(wt.name),9,ZI))),128))]),c.withDirectives(c.createElementVNode("textarea",{"onUpdate:modelValue":z[0]||(z[0]=wt=>f.value=wt),placeholder:"SELECT * FROM data;",class:"query-textarea",rows:"4"},null,512),[[c.vModelText,f.value]]),c.createVNode(Z,{class:"execute-query-button",onClick:at,disabled:o.value||!f.value},{default:c.withCtx(()=>[c.createTextVNode(c.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):c.createCommentVNode("",!0),p.value?(c.openBlock(),c.createElementBlock("div",tT,[c.createElementVNode("h3",null,"Results ("+c.toDisplayString(p.value.length)+" rows)",1),c.createElementVNode("div",eT,[c.createElementVNode("div",nT,[c.createVNode(Z,{class:"secondary",onClick:L},{default:c.withCtx(()=>[...z[6]||(z[6]=[c.createTextVNode("Export to CSV",-1)])]),_:1})]),c.createElementVNode("div",rT,[T.value==="table"&&Wt.value>1?(c.openBlock(),c.createBlock(_t,{key:0,"current-page":U.value,"onUpdate:currentPage":z[1]||(z[1]=wt=>U.value=wt),"page-size":J.value,total:p.value.length,layout:"prev, pager, next",onCurrentChange:ct,class:"results-pagination"},null,8,["current-page","page-size","total"])):c.createCommentVNode("",!0)])]),z[7]||(z[7]=c.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),T.value==="table"?(c.openBlock(),c.createElementBlock("div",iT,[c.createElementVNode("table",sT,[c.createElementVNode("thead",null,[c.createElementVNode("tr",null,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(ue.value,wt=>(c.openBlock(),c.createElementBlock("th",{key:wt},c.toDisplayString(wt),1))),128))])]),c.createElementVNode("tbody",null,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(le.value,(wt,st)=>(c.openBlock(),c.createElementBlock("tr",{key:st},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(ue.value,qt=>(c.openBlock(),c.createElementBlock("td",{key:qt},c.toDisplayString(h(wt[qt])),1))),128))]))),128))])]),Wt.value>1?(c.openBlock(),c.createElementBlock("div",aT,[c.createVNode(_t,{"current-page":U.value,"onUpdate:currentPage":z[2]||(z[2]=wt=>U.value=wt),"page-size":J.value,total:p.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:ct,onSizeChange:m},null,8,["current-page","page-size","total"])])):c.createCommentVNode("",!0)])):(c.openBlock(),c.createElementBlock("div",oT,[c.createElementVNode("pre",null,c.toDisplayString(JSON.stringify(p.value.slice(0,100),null,2)),1)]))])):c.createCommentVNode("",!0),E.value?(c.openBlock(),c.createElementBlock("div",lT,[z[8]||(z[8]=c.createElementVNode("h3",null,"Error",-1)),c.createElementVNode("p",null,c.toDisplayString(E.value),1),c.createElementVNode("button",{onClick:$,class:"clear-error-btn"},"Clear")])):c.createCommentVNode("",!0)])])}}},uT=Lo(cT,[["__scopeId","data-v-b5de149e"]]),dT={class:"app-container"},fT=c.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=c.ref([]),s=c.ref(""),a=c.ref("parquet"),o=c.ref("");c.onMounted(async()=>{var E,T,U,J,lt;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet");return}const X=HI("",["content","id"],n.pkg);if(!X||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await f(X);const Kt=(U=(T=(E=i.value)==null?void 0:E[0])==null?void 0:T.content)==null?void 0:U.id;if(!Kt){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=Kt,s.value=await p(X,Kt);const Jt=(lt=(J=n.pkg)==null?void 0:J.content)==null?void 0:lt.packageType;a.value=Jt==="CSV"?"csv":"parquet"}catch(Kt){console.error(Kt)}});function l(E){r("queryResults",E)}async function u(){const{useGetToken:E}=await Promise.resolve().then(()=>jS);return E()}async function f(E){const T=await u(),U=`${n.apiUrl}/packages/${E}/view?api_key=${T}`,J=await fetch(U);if(!J.ok)throw new Error(`view failed: ${J.status}`);i.value=await J.json()}async function p(E,T){const U=await u(),J=`${n.apiUrl}/packages/${E}/files/${T}?api_key=${U}`,lt=await fetch(J);if(!lt.ok)throw new Error(`file url failed: ${lt.status}`);return(await lt.json()).url}return(E,T)=>(c.openBlock(),c.createElementBlock("div",dT,[c.createVNode(uT,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:T[0]||(T[0]=U=>l(U))},null,8,["url","file-type","file-id"])]))}}),hT=Lo(fT,[["__scopeId","data-v-7298e5bf"]]);var pT={value:()=>{}};function Mh(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new wu(n)}function wu(e){this._=e}function mT(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}wu.prototype=Mh.prototype={constructor:wu,on:function(e,t){var n=this._,r=mT(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=yT(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=xg(n[i],e.name,t);else if(t==null)for(i in n)n[i]=xg(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new wu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function yT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function xg(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=pT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Ch="http://www.w3.org/1999/xhtml";const Rg={svg:"http://www.w3.org/2000/svg",xhtml:Ch,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Su(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Rg.hasOwnProperty(t)?{space:Rg[t],local:e}:e}function gT(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Ch&&t.documentElement.namespaceURI===Ch?t.createElement(e):t.createElementNS(n,e)}}function _T(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ng(e){var t=Su(e);return(t.local?_T:gT)(t)}function vT(){}function kh(e){return e==null?vT:function(){return this.querySelector(e)}}function bT(e){typeof e!="function"&&(e=kh(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,f=0;f<a;++f)(l=s[f])&&(u=e.call(l,l.__data__,f,s))&&("__data__"in l&&(u.__data__=l.__data__),o[f]=u);return new Ti(r,this._parents)}function wT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ST(){return[]}function Bg(e){return e==null?ST:function(){return this.querySelectorAll(e)}}function ET(e){return function(){return wT(e.apply(this,arguments))}}function IT(e){typeof e=="function"?e=ET(e):e=Bg(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new Ti(r,i)}function Og(e){return function(){return this.matches(e)}}function Dg(e){return function(t){return t.matches(e)}}var TT=Array.prototype.find;function AT(e){return function(){return TT.call(this.children,e)}}function xT(){return this.firstElementChild}function RT(e){return this.select(e==null?xT:AT(typeof e=="function"?e:Dg(e)))}var NT=Array.prototype.filter;function BT(){return Array.from(this.children)}function OT(e){return function(){return NT.call(this.children,e)}}function DT(e){return this.selectAll(e==null?BT:OT(typeof e=="function"?e:Dg(e)))}function FT(e){typeof e!="function"&&(e=Og(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Ti(r,this._parents)}function Fg(e){return new Array(e.length)}function LT(){return new Ti(this._enter||this._groups.map(Fg),this._parents)}function Eu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Eu.prototype={constructor:Eu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function MT(e){return function(){return e}}function CT(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new Eu(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function kT(e,t,n,r,i,s,a){var o,l,u=new Map,f=t.length,p=s.length,E=new Array(f),T;for(o=0;o<f;++o)(l=t[o])&&(E[o]=T=a.call(l,l.__data__,o,t)+"",u.has(T)?i[o]=l:u.set(T,l));for(o=0;o<p;++o)T=a.call(e,s[o],o,s)+"",(l=u.get(T))?(r[o]=l,l.__data__=s[o],u.delete(T)):n[o]=new Eu(e,s[o]);for(o=0;o<f;++o)(l=t[o])&&u.get(E[o])===l&&(i[o]=l)}function UT(e){return e.__data__}function PT(e,t){if(!arguments.length)return Array.from(this,UT);var n=t?kT:CT,r=this._parents,i=this._groups;typeof e!="function"&&(e=MT(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var f=r[u],p=i[u],E=p.length,T=$T(e.call(f,f&&f.__data__,u,r)),U=T.length,J=o[u]=new Array(U),lt=a[u]=new Array(U),X=l[u]=new Array(E);n(f,p,J,lt,X,T,t);for(var Kt=0,Jt=0,ue,Wt;Kt<U;++Kt)if(ue=J[Kt]){for(Kt>=Jt&&(Jt=Kt+1);!(Wt=lt[Jt])&&++Jt<U;);ue._next=Wt||null}}return a=new Ti(a,r),a._enter=o,a._exit=l,a}function $T(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function VT(){return new Ti(this._exit||this._groups.map(Fg),this._parents)}function zT(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function GT(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],f=r[l],p=u.length,E=o[l]=new Array(p),T,U=0;U<p;++U)(T=u[U]||f[U])&&(E[U]=T);for(;l<i;++l)o[l]=n[l];return new Ti(o,this._parents)}function jT(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function YT(e){e||(e=WT);function t(p,E){return p&&E?e(p.__data__,E.__data__):!p-!E}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,f=0;f<o;++f)(u=a[f])&&(l[f]=u);l.sort(t)}return new Ti(i,this._parents).order()}function WT(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function HT(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function qT(){return Array.from(this)}function XT(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function KT(){let e=0;for(const t of this)++e;return e}function QT(){return!this.node()}function JT(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function ZT(e){return function(){this.removeAttribute(e)}}function tA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function eA(e,t){return function(){this.setAttribute(e,t)}}function nA(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function rA(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function iA(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function sA(e,t){var n=Su(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?tA:ZT:typeof t=="function"?n.local?iA:rA:n.local?nA:eA)(n,t))}function Lg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function aA(e){return function(){this.style.removeProperty(e)}}function oA(e,t,n){return function(){this.style.setProperty(e,t,n)}}function lA(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function cA(e,t,n){return arguments.length>1?this.each((t==null?aA:typeof t=="function"?lA:oA)(e,t,n??"")):Mo(this.node(),e)}function Mo(e,t){return e.style.getPropertyValue(t)||Lg(e).getComputedStyle(e,null).getPropertyValue(t)}function uA(e){return function(){delete this[e]}}function dA(e,t){return function(){this[e]=t}}function fA(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function hA(e,t){return arguments.length>1?this.each((t==null?uA:typeof t=="function"?fA:dA)(e,t)):this.node()[e]}function Mg(e){return e.trim().split(/^|\s+/)}function Uh(e){return e.classList||new Cg(e)}function Cg(e){this._node=e,this._names=Mg(e.getAttribute("class")||"")}Cg.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function kg(e,t){for(var n=Uh(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Ug(e,t){for(var n=Uh(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function pA(e){return function(){kg(this,e)}}function mA(e){return function(){Ug(this,e)}}function yA(e,t){return function(){(t.apply(this,arguments)?kg:Ug)(this,e)}}function gA(e,t){var n=Mg(e+"");if(arguments.length<2){for(var r=Uh(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?yA:t?pA:mA)(n,t))}function _A(){this.textContent=""}function vA(e){return function(){this.textContent=e}}function bA(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function wA(e){return arguments.length?this.each(e==null?_A:(typeof e=="function"?bA:vA)(e)):this.node().textContent}function SA(){this.innerHTML=""}function EA(e){return function(){this.innerHTML=e}}function IA(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function TA(e){return arguments.length?this.each(e==null?SA:(typeof e=="function"?IA:EA)(e)):this.node().innerHTML}function AA(){this.nextSibling&&this.parentNode.appendChild(this)}function xA(){return this.each(AA)}function RA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function NA(){return this.each(RA)}function BA(e){var t=typeof e=="function"?e:Ng(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function OA(){return null}function DA(e,t){var n=typeof e=="function"?e:Ng(e),r=t==null?OA:typeof t=="function"?t:kh(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function FA(){var e=this.parentNode;e&&e.removeChild(this)}function LA(){return this.each(FA)}function MA(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function CA(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kA(e){return this.select(e?CA:MA)}function UA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PA(e){return function(t){e.call(this,t,this.__data__)}}function $A(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function VA(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function zA(e,t,n){return function(){var r=this.__on,i,s=PA(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function GA(e,t,n){var r=$A(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,f;l<u;++l)for(i=0,f=o[l];i<s;++i)if((a=r[i]).type===f.type&&a.name===f.name)return f.value}return}for(o=t?zA:VA,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function Pg(e,t,n){var r=Lg(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function jA(e,t){return function(){return Pg(this,e,t)}}function YA(e,t){return function(){return Pg(this,e,t.apply(this,arguments))}}function WA(e,t){return this.each((typeof t=="function"?YA:jA)(e,t))}function*HA(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var $g=[null];function Ti(e,t){this._groups=e,this._parents=t}function Kl(){return new Ti([[document.documentElement]],$g)}function qA(){return this}Ti.prototype=Kl.prototype={constructor:Ti,select:bT,selectAll:IT,selectChild:RT,selectChildren:DT,filter:FT,data:PT,enter:LT,exit:VT,join:zT,merge:GT,selection:qA,order:jT,sort:YT,call:HT,nodes:qT,node:XT,size:KT,empty:QT,each:JT,attr:sA,style:cA,property:hA,classed:gA,text:wA,html:TA,raise:xA,lower:NA,append:BA,insert:DA,remove:LA,clone:kA,datum:UA,on:GA,dispatch:WA,[Symbol.iterator]:HA};function Xs(e){return typeof e=="string"?new Ti([[document.querySelector(e)]],[document.documentElement]):new Ti([[e]],$g)}function XA(e){let t;for(;t=e.sourceEvent;)e=t;return e}function eo(e,t){if(e=XA(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ph={capture:!0,passive:!1};function $h(e){e.preventDefault(),e.stopImmediatePropagation()}function KA(e){var t=e.document.documentElement,n=Xs(e).on("dragstart.drag",$h,Ph);"onselectstart"in t?n.on("selectstart.drag",$h,Ph):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function QA(e,t){var n=e.document.documentElement,r=Xs(e).on("dragstart.drag",null);t&&(r.on("click.drag",$h,Ph),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Vh(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vg(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Ql(){}var Jl=.7,Iu=1/Jl,Co="\\s*([+-]?\\d+)\\s*",Zl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_s="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",JA=/^#([0-9a-f]{3,8})$/,ZA=new RegExp(`^rgb\\(${Co},${Co},${Co}\\)$`),tx=new RegExp(`^rgb\\(${_s},${_s},${_s}\\)$`),ex=new RegExp(`^rgba\\(${Co},${Co},${Co},${Zl}\\)$`),nx=new RegExp(`^rgba\\(${_s},${_s},${_s},${Zl}\\)$`),rx=new RegExp(`^hsl\\(${Zl},${_s},${_s}\\)$`),ix=new RegExp(`^hsla\\(${Zl},${_s},${_s},${Zl}\\)$`),zg={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Vh(Ql,tc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Gg,formatHex:Gg,formatHex8:sx,formatHsl:ax,formatRgb:jg,toString:jg});function Gg(){return this.rgb().formatHex()}function sx(){return this.rgb().formatHex8()}function ax(){return Xg(this).formatHsl()}function jg(){return this.rgb().formatRgb()}function tc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=JA.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Yg(t):n===3?new di(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Tu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Tu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ZA.exec(e))?new di(t[1],t[2],t[3],1):(t=tx.exec(e))?new di(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ex.exec(e))?Tu(t[1],t[2],t[3],t[4]):(t=nx.exec(e))?Tu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=rx.exec(e))?qg(t[1],t[2]/100,t[3]/100,1):(t=ix.exec(e))?qg(t[1],t[2]/100,t[3]/100,t[4]):zg.hasOwnProperty(e)?Yg(zg[e]):e==="transparent"?new di(NaN,NaN,NaN,0):null}function Yg(e){return new di(e>>16&255,e>>8&255,e&255,1)}function Tu(e,t,n,r){return r<=0&&(e=t=n=NaN),new di(e,t,n,r)}function ox(e){return e instanceof Ql||(e=tc(e)),e?(e=e.rgb(),new di(e.r,e.g,e.b,e.opacity)):new di}function zh(e,t,n,r){return arguments.length===1?ox(e):new di(e,t,n,r??1)}function di(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Vh(di,zh,Vg(Ql,{brighter(e){return e=e==null?Iu:Math.pow(Iu,e),new di(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Jl:Math.pow(Jl,e),new di(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new di(no(this.r),no(this.g),no(this.b),Au(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Wg,formatHex:Wg,formatHex8:lx,formatRgb:Hg,toString:Hg}));function Wg(){return`#${ro(this.r)}${ro(this.g)}${ro(this.b)}`}function lx(){return`#${ro(this.r)}${ro(this.g)}${ro(this.b)}${ro((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hg(){const e=Au(this.opacity);return`${e===1?"rgb(":"rgba("}${no(this.r)}, ${no(this.g)}, ${no(this.b)}${e===1?")":`, ${e})`}`}function Au(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function no(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ro(e){return e=no(e),(e<16?"0":"")+e.toString(16)}function qg(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new es(e,t,n,r)}function Xg(e){if(e instanceof es)return new es(e.h,e.s,e.l,e.opacity);if(e instanceof Ql||(e=tc(e)),!e)return new es;if(e instanceof es)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new es(a,o,l,e.opacity)}function cx(e,t,n,r){return arguments.length===1?Xg(e):new es(e,t,n,r??1)}function es(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Vh(es,cx,Vg(Ql,{brighter(e){return e=e==null?Iu:Math.pow(Iu,e),new es(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Jl:Math.pow(Jl,e),new es(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new di(Gh(e>=240?e-240:e+120,i,r),Gh(e,i,r),Gh(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new es(Kg(this.h),xu(this.s),xu(this.l),Au(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Au(this.opacity);return`${e===1?"hsl(":"hsla("}${Kg(this.h)}, ${xu(this.s)*100}%, ${xu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Kg(e){return e=(e||0)%360,e<0?e+360:e}function xu(e){return Math.max(0,Math.min(1,e||0))}function Gh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Qg=e=>()=>e;function ux(e,t){return function(n){return e+n*t}}function dx(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function fx(e){return(e=+e)==1?Jg:function(t,n){return n-t?dx(t,n,e):Qg(isNaN(t)?n:t)}}function Jg(e,t){var n=t-e;return n?ux(e,n):Qg(isNaN(e)?t:e)}const Zg=(function e(t){var n=fx(t);function r(i,s){var a=n((i=zh(i)).r,(s=zh(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=Jg(i.opacity,s.opacity);return function(f){return i.r=a(f),i.g=o(f),i.b=l(f),i.opacity=u(f),i+""}}return r.gamma=e,r})(1);function xa(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var jh=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Yh=new RegExp(jh.source,"g");function hx(e){return function(){return e}}function px(e){return function(t){return e(t)+""}}function mx(e,t){var n=jh.lastIndex=Yh.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=jh.exec(e))&&(i=Yh.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:xa(r,i)})),n=Yh.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?px(l[0].x):hx(t):(t=l.length,function(u){for(var f=0,p;f<t;++f)o[(p=l[f]).i]=p.x(u);return o.join("")})}var t_=180/Math.PI,e_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function n_(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*t_,skewX:Math.atan(l)*t_,scaleX:a,scaleY:o}}var Ru;function yx(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?e_:n_(t.a,t.b,t.c,t.d,t.e,t.f)}function gx(e){return e==null||(Ru||(Ru=document.createElementNS("http://www.w3.org/2000/svg","g")),Ru.setAttribute("transform",e),!(e=Ru.transform.baseVal.consolidate()))?e_:(e=e.matrix,n_(e.a,e.b,e.c,e.d,e.e,e.f))}function r_(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,f,p,E,T,U){if(u!==p||f!==E){var J=T.push("translate(",null,t,null,n);U.push({i:J-4,x:xa(u,p)},{i:J-2,x:xa(f,E)})}else(p||E)&&T.push("translate("+p+t+E+n)}function a(u,f,p,E){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),E.push({i:p.push(i(p)+"rotate(",null,r)-2,x:xa(u,f)})):f&&p.push(i(p)+"rotate("+f+r)}function o(u,f,p,E){u!==f?E.push({i:p.push(i(p)+"skewX(",null,r)-2,x:xa(u,f)}):f&&p.push(i(p)+"skewX("+f+r)}function l(u,f,p,E,T,U){if(u!==p||f!==E){var J=T.push(i(T)+"scale(",null,",",null,")");U.push({i:J-4,x:xa(u,p)},{i:J-2,x:xa(f,E)})}else(p!==1||E!==1)&&T.push(i(T)+"scale("+p+","+E+")")}return function(u,f){var p=[],E=[];return u=e(u),f=e(f),s(u.translateX,u.translateY,f.translateX,f.translateY,p,E),a(u.rotate,f.rotate,p,E),o(u.skewX,f.skewX,p,E),l(u.scaleX,u.scaleY,f.scaleX,f.scaleY,p,E),u=f=null,function(T){for(var U=-1,J=E.length,lt;++U<J;)p[(lt=E[U]).i]=lt.x(T);return p.join("")}}}var _x=r_(yx,"px, ","px)","deg)"),vx=r_(gx,", ",")",")"),bx=1e-12;function i_(e){return((e=Math.exp(e))+1/e)/2}function wx(e){return((e=Math.exp(e))-1/e)/2}function Sx(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ex=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],f=a[0],p=a[1],E=a[2],T=f-o,U=p-l,J=T*T+U*U,lt,X;if(J<bx)X=Math.log(E/u)/t,lt=function($t){return[o+$t*T,l+$t*U,u*Math.exp(t*$t*X)]};else{var Kt=Math.sqrt(J),Jt=(E*E-u*u+r*J)/(2*u*n*Kt),ue=(E*E-u*u-r*J)/(2*E*n*Kt),Wt=Math.log(Math.sqrt(Jt*Jt+1)-Jt),le=Math.log(Math.sqrt(ue*ue+1)-ue);X=(le-Wt)/t,lt=function($t){var yn=$t*X,Ge=i_(Wt),ce=u/(n*Kt)*(Ge*Sx(t*yn+Wt)-wx(Wt));return[o+ce*T,l+ce*U,u*Ge/i_(t*yn+Wt)]}}return lt.duration=X*1e3*t/Math.SQRT2,lt}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);var ko=0,ec=0,nc=0,s_=1e3,Nu,rc,Bu=0,io=0,Ou=0,ic=typeof performance=="object"&&performance.now?performance:Date,a_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wh(){return io||(a_(Ix),io=ic.now()+Ou)}function Ix(){io=0}function Du(){this._call=this._time=this._next=null}Du.prototype=o_.prototype={constructor:Du,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Wh():+n)+(t==null?0:+t),!this._next&&rc!==this&&(rc?rc._next=this:Nu=this,rc=this),this._call=e,this._time=n,Hh()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hh())}};function o_(e,t,n){var r=new Du;return r.restart(e,t,n),r}function Tx(){Wh(),++ko;for(var e=Nu,t;e;)(t=io-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ko}function l_(){io=(Bu=ic.now())+Ou,ko=ec=0;try{Tx()}finally{ko=0,xx(),io=0}}function Ax(){var e=ic.now(),t=e-Bu;t>s_&&(Ou-=t,Bu=e)}function xx(){for(var e,t=Nu,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Nu=n);rc=e,Hh(r)}function Hh(e){if(!ko){ec&&(ec=clearTimeout(ec));var t=e-io;t>24?(e<1/0&&(ec=setTimeout(l_,e-ic.now()-Ou)),nc&&(nc=clearInterval(nc))):(nc||(Bu=ic.now(),nc=setInterval(Ax,s_)),ko=1,a_(l_))}}function c_(e,t,n){var r=new Du;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Rx=Mh("start","end","cancel","interrupt"),Nx=[],u_=0,d_=1,qh=2,Fu=3,f_=4,Xh=5,Lu=6;function Mu(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Bx(e,n,{name:t,index:r,group:i,on:Rx,tween:Nx,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:u_})}function Kh(e,t){var n=ns(e,t);if(n.state>u_)throw new Error("too late; already scheduled");return n}function vs(e,t){var n=ns(e,t);if(n.state>Fu)throw new Error("too late; already running");return n}function ns(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bx(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=o_(s,0,n.time);function s(u){n.state=d_,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,p,E,T;if(n.state!==d_)return l();for(f in r)if(T=r[f],T.name===n.name){if(T.state===Fu)return c_(a);T.state===f_?(T.state=Lu,T.timer.stop(),T.on.call("interrupt",e,e.__data__,T.index,T.group),delete r[f]):+f<t&&(T.state=Lu,T.timer.stop(),T.on.call("cancel",e,e.__data__,T.index,T.group),delete r[f])}if(c_(function(){n.state===Fu&&(n.state=f_,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=qh,n.on.call("start",e,e.__data__,n.index,n.group),n.state===qh){for(n.state=Fu,i=new Array(E=n.tween.length),f=0,p=-1;f<E;++f)(T=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(i[++p]=T);i.length=p+1}}function o(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=Xh,1),p=-1,E=i.length;++p<E;)i[p].call(e,f);n.state===Xh&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Lu,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Cu(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>qh&&r.state<Xh,r.state=Lu,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Ox(e){return this.each(function(){Cu(this,e)})}function Dx(e,t){var n,r;return function(){var i=vs(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function Fx(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=vs(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function Lx(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ns(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?Dx:Fx)(n,e,t))}function Qh(e,t,n){var r=e._id;return e.each(function(){var i=vs(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return ns(i,r).value[t]}}function h_(e,t){var n;return(typeof t=="number"?xa:t instanceof tc?Zg:(n=tc(t))?(t=n,Zg):mx)(e,t)}function Mx(e){return function(){this.removeAttribute(e)}}function Cx(e){return function(){this.removeAttributeNS(e.space,e.local)}}function kx(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function Ux(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function Px(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function $x(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function Vx(e,t){var n=Su(e),r=n==="transform"?vx:h_;return this.attrTween(e,typeof t=="function"?(n.local?$x:Px)(n,r,Qh(this,"attr."+e,t)):t==null?(n.local?Cx:Mx)(n):(n.local?Ux:kx)(n,r,t))}function zx(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Gx(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function jx(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Gx(e,s)),n}return i._value=t,i}function Yx(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&zx(e,s)),n}return i._value=t,i}function Wx(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Su(e);return this.tween(n,(r.local?jx:Yx)(r,t))}function Hx(e,t){return function(){Kh(this,e).delay=+t.apply(this,arguments)}}function qx(e,t){return t=+t,function(){Kh(this,e).delay=t}}function Xx(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hx:qx)(t,e)):ns(this.node(),t).delay}function Kx(e,t){return function(){vs(this,e).duration=+t.apply(this,arguments)}}function Qx(e,t){return t=+t,function(){vs(this,e).duration=t}}function Jx(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kx:Qx)(t,e)):ns(this.node(),t).duration}function Zx(e,t){if(typeof t!="function")throw new Error;return function(){vs(this,e).ease=t}}function t2(e){var t=this._id;return arguments.length?this.each(Zx(t,e)):ns(this.node(),t).ease}function e2(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;vs(this,e).ease=n}}function n2(e){if(typeof e!="function")throw new Error;return this.each(e2(this._id,e))}function r2(e){typeof e!="function"&&(e=Og(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Ks(r,this._parents,this._name,this._id)}function i2(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],f=l.length,p=a[o]=new Array(f),E,T=0;T<f;++T)(E=l[T]||u[T])&&(p[T]=E);for(;o<r;++o)a[o]=t[o];return new Ks(a,this._parents,this._name,this._id)}function s2(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function a2(e,t,n){var r,i,s=s2(t)?Kh:vs;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function o2(e,t){var n=this._id;return arguments.length<2?ns(this.node(),n).on.on(e):this.each(a2(n,e,t))}function l2(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function c2(){return this.on("end.remove",l2(this._id))}function u2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=kh(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),f,p,E=0;E<l;++E)(f=o[E])&&(p=e.call(f,f.__data__,E,o))&&("__data__"in f&&(p.__data__=f.__data__),u[E]=p,Mu(u[E],t,n,E,u,ns(f,n)));return new Ks(s,this._parents,t,n)}function d2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bg(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,f,p=0;p<u;++p)if(f=l[p]){for(var E=e.call(f,f.__data__,p,l),T,U=ns(f,n),J=0,lt=E.length;J<lt;++J)(T=E[J])&&Mu(T,t,n,J,E,U);s.push(E),a.push(f)}return new Ks(s,a,t,n)}var f2=Kl.prototype.constructor;function h2(){return new f2(this._groups,this._parents)}function p2(e,t){var n,r,i;return function(){var s=Mo(this,e),a=(this.style.removeProperty(e),Mo(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function p_(e){return function(){this.style.removeProperty(e)}}function m2(e,t,n){var r,i=n+"",s;return function(){var a=Mo(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function y2(e,t,n){var r,i,s;return function(){var a=Mo(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Mo(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function g2(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=vs(this,e),u=l.on,f=l.value[s]==null?o||(o=p_(t)):void 0;(u!==n||i!==f)&&(r=(n=u).copy()).on(a,i=f),l.on=r}}function _2(e,t,n){var r=(e+="")=="transform"?_x:h_;return t==null?this.styleTween(e,p2(e,r)).on("end.style."+e,p_(e)):typeof t=="function"?this.styleTween(e,y2(e,r,Qh(this,"style."+e,t))).each(g2(this._id,e)):this.styleTween(e,m2(e,r,t),n).on("end.style."+e,null)}function v2(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function b2(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&v2(e,a,n)),r}return s._value=t,s}function w2(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,b2(e,t,n??""))}function S2(e){return function(){this.textContent=e}}function E2(e){return function(){var t=e(this);this.textContent=t??""}}function I2(e){return this.tween("text",typeof e=="function"?E2(Qh(this,"text",e)):S2(e==null?"":e+""))}function T2(e){return function(t){this.textContent=e.call(this,t)}}function A2(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&T2(i)),t}return r._value=e,r}function x2(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,A2(e))}function R2(){for(var e=this._name,t=this._id,n=m_(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var f=ns(l,t);Mu(l,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ks(r,this._parents,e,n)}function N2(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=vs(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var B2=0;function Ks(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function m_(){return++B2}var Qs=Kl.prototype;Ks.prototype={constructor:Ks,select:u2,selectAll:d2,selectChild:Qs.selectChild,selectChildren:Qs.selectChildren,filter:r2,merge:i2,selection:h2,transition:R2,call:Qs.call,nodes:Qs.nodes,node:Qs.node,size:Qs.size,empty:Qs.empty,each:Qs.each,on:o2,attr:Vx,attrTween:Wx,style:_2,styleTween:w2,text:I2,textTween:x2,remove:c2,tween:Lx,delay:Xx,duration:Jx,ease:t2,easeVarying:n2,end:N2,[Symbol.iterator]:Qs[Symbol.iterator]};function O2(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var D2={time:null,delay:0,duration:250,ease:O2};function F2(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function L2(e){var t,n;e instanceof Ks?(t=e._id,e=e._name):(t=m_(),(n=D2).time=Wh(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&Mu(l,e,t,u,a,n||F2(l,t));return new Ks(r,this._parents,e,t)}Kl.prototype.interrupt=Ox,Kl.prototype.transition=L2;const ku=e=>()=>e;function M2(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Js(e,t,n){this.k=e,this.x=t,this.y=n}Js.prototype={constructor:Js,scale:function(e){return e===1?this:new Js(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Js(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Uu=new Js(1,0,0);Js.prototype;function Jh(e){e.stopImmediatePropagation()}function sc(e){e.preventDefault(),e.stopImmediatePropagation()}function C2(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function k2(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function y_(){return this.__zoom||Uu}function U2(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function P2(){return navigator.maxTouchPoints||"ontouchstart"in this}function $2(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function V2(){var e=C2,t=k2,n=$2,r=U2,i=P2,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Ex,u=Mh("start","zoom","end"),f,p,E,T=500,U=150,J=0,lt=10;function X(m){m.property("__zoom",y_).on("wheel.zoom",yn,{passive:!1}).on("mousedown.zoom",Ge).on("dblclick.zoom",ce).filter(i).on("touchstart.zoom",Qt).on("touchmove.zoom",at).on("touchend.zoom touchcancel.zoom",ct).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}X.transform=function(m,F,h,L){var $=m.selection?m.selection():m;$.property("__zoom",y_),m!==$?Wt(m,F,h,L):$.interrupt().each(function(){le(this,arguments).event(L).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},X.scaleBy=function(m,F,h,L){X.scaleTo(m,function(){var $=this.__zoom.k,D=typeof F=="function"?F.apply(this,arguments):F;return $*D},h,L)},X.scaleTo=function(m,F,h,L){X.transform(m,function(){var $=t.apply(this,arguments),D=this.__zoom,z=h==null?ue($):typeof h=="function"?h.apply(this,arguments):h,Z=D.invert(z),_t=typeof F=="function"?F.apply(this,arguments):F;return n(Jt(Kt(D,_t),z,Z),$,a)},h,L)},X.translateBy=function(m,F,h,L){X.transform(m,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof h=="function"?h.apply(this,arguments):h),t.apply(this,arguments),a)},null,L)},X.translateTo=function(m,F,h,L,$){X.transform(m,function(){var D=t.apply(this,arguments),z=this.__zoom,Z=L==null?ue(D):typeof L=="function"?L.apply(this,arguments):L;return n(Uu.translate(Z[0],Z[1]).scale(z.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof h=="function"?-h.apply(this,arguments):-h),D,a)},L,$)};function Kt(m,F){return F=Math.max(s[0],Math.min(s[1],F)),F===m.k?m:new Js(F,m.x,m.y)}function Jt(m,F,h){var L=F[0]-h[0]*m.k,$=F[1]-h[1]*m.k;return L===m.x&&$===m.y?m:new Js(m.k,L,$)}function ue(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function Wt(m,F,h,L){m.on("start.zoom",function(){le(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){le(this,arguments).event(L).end()}).tween("zoom",function(){var $=this,D=arguments,z=le($,D).event(L),Z=t.apply($,D),_t=h==null?ue(Z):typeof h=="function"?h.apply($,D):h,wt=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),st=$.__zoom,qt=typeof F=="function"?F.apply($,D):F,ne=l(st.invert(_t).concat(wt/st.k),qt.invert(_t).concat(wt/qt.k));return function(Zt){if(Zt===1)Zt=qt;else{var Ye=ne(Zt),Yn=wt/Ye[2];Zt=new Js(Yn,_t[0]-Ye[0]*Yn,_t[1]-Ye[1]*Yn)}z.zoom(null,Zt)}})}function le(m,F,h){return!h&&m.__zooming||new $t(m,F)}function $t(m,F){this.that=m,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,F),this.taps=0}$t.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,F){return this.mouse&&m!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var F=Xs(this.that).datum();u.call(m,this.that,new M2(m,{sourceEvent:this.sourceEvent,target:X,transform:this.that.__zoom,dispatch:u}),F)}};function yn(m,...F){if(!e.apply(this,arguments))return;var h=le(this,F).event(m),L=this.__zoom,$=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,r.apply(this,arguments)))),D=eo(m);if(h.wheel)(h.mouse[0][0]!==D[0]||h.mouse[0][1]!==D[1])&&(h.mouse[1]=L.invert(h.mouse[0]=D)),clearTimeout(h.wheel);else{if(L.k===$)return;h.mouse=[D,L.invert(D)],Cu(this),h.start()}sc(m),h.wheel=setTimeout(z,U),h.zoom("mouse",n(Jt(Kt(L,$),h.mouse[0],h.mouse[1]),h.extent,a));function z(){h.wheel=null,h.end()}}function Ge(m,...F){if(E||!e.apply(this,arguments))return;var h=m.currentTarget,L=le(this,F,!0).event(m),$=Xs(m.view).on("mousemove.zoom",_t,!0).on("mouseup.zoom",wt,!0),D=eo(m,h),z=m.clientX,Z=m.clientY;KA(m.view),Jh(m),L.mouse=[D,this.__zoom.invert(D)],Cu(this),L.start();function _t(st){if(sc(st),!L.moved){var qt=st.clientX-z,ne=st.clientY-Z;L.moved=qt*qt+ne*ne>J}L.event(st).zoom("mouse",n(Jt(L.that.__zoom,L.mouse[0]=eo(st,h),L.mouse[1]),L.extent,a))}function wt(st){$.on("mousemove.zoom mouseup.zoom",null),QA(st.view,L.moved),sc(st),L.event(st).end()}}function ce(m,...F){if(e.apply(this,arguments)){var h=this.__zoom,L=eo(m.changedTouches?m.changedTouches[0]:m,this),$=h.invert(L),D=h.k*(m.shiftKey?.5:2),z=n(Jt(Kt(h,D),L,$),t.apply(this,F),a);sc(m),o>0?Xs(this).transition().duration(o).call(Wt,z,L,m):Xs(this).call(X.transform,z,L,m)}}function Qt(m,...F){if(e.apply(this,arguments)){var h=m.touches,L=h.length,$=le(this,F,m.changedTouches.length===L).event(m),D,z,Z,_t;for(Jh(m),z=0;z<L;++z)Z=h[z],_t=eo(Z,this),_t=[_t,this.__zoom.invert(_t),Z.identifier],$.touch0?!$.touch1&&$.touch0[2]!==_t[2]&&($.touch1=_t,$.taps=0):($.touch0=_t,D=!0,$.taps=1+!!f);f&&(f=clearTimeout(f)),D&&($.taps<2&&(p=_t[0],f=setTimeout(function(){f=null},T)),Cu(this),$.start())}}function at(m,...F){if(this.__zooming){var h=le(this,F).event(m),L=m.changedTouches,$=L.length,D,z,Z,_t;for(sc(m),D=0;D<$;++D)z=L[D],Z=eo(z,this),h.touch0&&h.touch0[2]===z.identifier?h.touch0[0]=Z:h.touch1&&h.touch1[2]===z.identifier&&(h.touch1[0]=Z);if(z=h.that.__zoom,h.touch1){var wt=h.touch0[0],st=h.touch0[1],qt=h.touch1[0],ne=h.touch1[1],Zt=(Zt=qt[0]-wt[0])*Zt+(Zt=qt[1]-wt[1])*Zt,Ye=(Ye=ne[0]-st[0])*Ye+(Ye=ne[1]-st[1])*Ye;z=Kt(z,Math.sqrt(Zt/Ye)),Z=[(wt[0]+qt[0])/2,(wt[1]+qt[1])/2],_t=[(st[0]+ne[0])/2,(st[1]+ne[1])/2]}else if(h.touch0)Z=h.touch0[0],_t=h.touch0[1];else return;h.zoom("touch",n(Jt(z,Z,_t),h.extent,a))}}function ct(m,...F){if(this.__zooming){var h=le(this,F).event(m),L=m.changedTouches,$=L.length,D,z;for(Jh(m),E&&clearTimeout(E),E=setTimeout(function(){E=null},T),D=0;D<$;++D)z=L[D],h.touch0&&h.touch0[2]===z.identifier?delete h.touch0:h.touch1&&h.touch1[2]===z.identifier&&delete h.touch1;if(h.touch1&&!h.touch0&&(h.touch0=h.touch1,delete h.touch1),h.touch0)h.touch0[1]=this.__zoom.invert(h.touch0[0]);else if(h.end(),h.taps===2&&(z=eo(z,this),Math.hypot(p[0]-z[0],p[1]-z[1])<lt)){var Z=Xs(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return X.wheelDelta=function(m){return arguments.length?(r=typeof m=="function"?m:ku(+m),X):r},X.filter=function(m){return arguments.length?(e=typeof m=="function"?m:ku(!!m),X):e},X.touchable=function(m){return arguments.length?(i=typeof m=="function"?m:ku(!!m),X):i},X.extent=function(m){return arguments.length?(t=typeof m=="function"?m:ku([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),X):t},X.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],X):[s[0],s[1]]},X.translateExtent=function(m){return arguments.length?(a[0][0]=+m[0][0],a[1][0]=+m[1][0],a[0][1]=+m[0][1],a[1][1]=+m[1][1],X):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},X.constrain=function(m){return arguments.length?(n=m,X):n},X.duration=function(m){return arguments.length?(o=+m,X):o},X.interpolate=function(m){return arguments.length?(l=m,X):l},X.on=function(){var m=u.on.apply(u,arguments);return m===u?X:m},X.clickDistance=function(m){return arguments.length?(J=(m=+m)*m,X):Math.sqrt(J)},X.tapDistance=function(m){return arguments.length?(lt=+m,X):lt},X}const z2=c.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map},selectedMapEntries:{type:[Array,Map],default:()=>[]}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=c.ref(null),i=c.ref(null),s=c.ref(null),a=c.ref(null);let o=null,l=null,u=null,f=[],p=null,E=null,T=null,U=0,J=0,lt=1;c.watch(()=>n.colorMap,F,{deep:!0});function X(h){if(!h||h.length<7)return[1,0,0];const L=parseInt(h.slice(1,3),16)/255,$=parseInt(h.slice(3,5),16)/255,D=parseInt(h.slice(5,7),16)/255;return[L,$,D].some(Number.isNaN)?[1,0,0]:[L,$,D]}const Kt=(h,L,$)=>h+(L-h)*$;function Jt(h,L){const $=h.parentElement;$&&(lt=window.devicePixelRatio||1,U=$.clientWidth||800,J=$.clientHeight||400,h.style.width=`${U}px`,h.style.height=`${J}px`,h.width=Math.round(U*lt),h.height=Math.round(J*lt),L.viewport(0,0,h.width,h.height))}function ue(h,L){var $,D,z,Z,_t,wt,st,qt,ne,Zt,Ye,Yn;const _n=(wt=(_t=(Z=(z=(D=($=n.metaData)==null?void 0:$.row_groups)==null?void 0:D[0])==null?void 0:z.columns)==null?void 0:Z[0])==null?void 0:_t.meta_data)==null?void 0:wt.statistics,cr=(Yn=(Ye=(Zt=(ne=(qt=(st=n.metaData)==null?void 0:st.row_groups)==null?void 0:qt[0])==null?void 0:ne.columns)==null?void 0:Zt[1])==null?void 0:Ye.meta_data)==null?void 0:Yn.statistics,Fr=Number((_n==null?void 0:_n.min_value)??-1),Si=Number((_n==null?void 0:_n.max_value)??1),gr=Number((cr==null?void 0:cr.min_value)??-1),qr=Number((cr==null?void 0:cr.max_value)??1),Lr=(Fr+Si)/2,Ht=(gr+qr)/2,tt=Math.max(1e-9,Si-Fr),te=Math.max(1e-9,qr-gr),Mn=2/Math.max(tt,te),Mr=p.x/h*2-1,li=-p.y/L*2+1,g=p.k*Mn,Qn=Mr-g*Lr,Rr=li-g*Ht;return{s:g,tx:Qn,ty:Rr}}function Wt(h,L,$,D){const{s:z,tx:Z,ty:_t}=ue($,D),wt=h/$*2-1,st=-(L/D*2-1),qt=(wt-Z)/z,ne=(st-_t)/z;return{x:qt,y:ne}}function le(h,L,$,D,z){if(!h.length||!p)return null;const Z=Wt(L,$,D,z);let _t=1/0,wt=null;for(const st of h){const qt=st.x-Z.x,ne=st.y-Z.y,Zt=Math.hypot(qt,ne),Ye=3/(p.k/2);Zt<_t&&Zt<Ye&&(_t=Zt,wt=st)}return wt}function $t(){var h,L;const $=[],D=((h=n.metaData)==null?void 0:h.schema)||[],z=n.data;for(let Z=0;Z<z.length;Z++){const _t=z[Z],wt=Number(_t[0]),st=Number(_t[1]),qt={};for(let ne=0;ne<D.length;ne++){const Zt=((L=D[ne])==null?void 0:L.name)??`col_${ne}`;qt[Zt]=_t[ne]}$.push({x:wt,y:st,rawX:wt,rawY:st,color:[.5,.5,.5],id:Z,attrs:qt})}return $}function yn(h,L,$){const D=h.createShader(h.VERTEX_SHADER);if(h.shaderSource(D,L),h.compileShader(D),!h.getShaderParameter(D,h.COMPILE_STATUS))return console.error("Vertex shader error:",h.getShaderInfoLog(D)),null;const z=h.createShader(h.FRAGMENT_SHADER);if(h.shaderSource(z,$),h.compileShader(z),!h.getShaderParameter(z,h.COMPILE_STATUS))return console.error("Fragment shader error:",h.getShaderInfoLog(z)),null;const Z=h.createProgram();return h.attachShader(Z,D),h.attachShader(Z,z),h.linkProgram(Z),h.getProgramParameter(Z,h.LINK_STATUS)?(h.validateProgram(Z),h.getProgramParameter(Z,h.VALIDATE_STATUS)?Z:(console.error("Program validate error:",h.getProgramInfoLog(Z)),null)):(console.error("Program link error:",h.getProgramInfoLog(Z)),null)}function Ge(h,L,$){if(!$.length)return null;const D=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,D);const z=new Float32Array($.flatMap(Zt=>[Zt.x,Zt.y]));h.bufferData(h.ARRAY_BUFFER,z,h.STATIC_DRAW);const Z=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,Z);const _t=new Float32Array($.flatMap(Zt=>Zt.color));h.bufferData(h.ARRAY_BUFFER,_t,h.STATIC_DRAW);const wt=h.getAttribLocation(L,"a_position"),st=h.getAttribLocation(L,"a_color"),qt=h.getUniformLocation(L,"u_viewMatrix"),ne=h.getUniformLocation(L,"u_pointSize");return{program:L,positionBuffer:D,colorBuffer:Z,positionAttributeLocation:wt,colorAttributeLocation:st,viewMatrixLocation:qt,pointSizeLocation:ne,count:$.length}}function ce(h,L,$,D=null){if(!h||!L||!p)return;const{program:z,positionBuffer:Z,colorBuffer:_t,positionAttributeLocation:wt,colorAttributeLocation:st,viewMatrixLocation:qt,pointSizeLocation:ne,count:Zt}=L;h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.useProgram(z),h.enableVertexAttribArray(wt),h.bindBuffer(h.ARRAY_BUFFER,Z),h.vertexAttribPointer(wt,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(st),h.bindBuffer(h.ARRAY_BUFFER,_t),h.vertexAttribPointer(st,3,h.FLOAT,!1,0,0);const Ye=h.canvas.clientWidth,Yn=h.canvas.clientHeight,{s:_n,tx:cr,ty:Fr}=ue(Ye,Yn),Si=new Float32Array([_n,0,0,0,0,_n,0,0,0,0,1,0,cr,Fr,0,1]);if(h.uniformMatrix4fv(qt,!1,Si),h.uniform1f(ne,Math.max(1.5,$*Math.sqrt(p.k)*lt)),h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),h.drawArrays(h.POINTS,0,Zt),D){const gr=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,gr),h.bufferData(h.ARRAY_BUFFER,new Float32Array([D.x,D.y]),h.STATIC_DRAW),h.vertexAttribPointer(wt,2,h.FLOAT,!1,0,0);const qr=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,qr),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,1,.5]),h.STATIC_DRAW),h.vertexAttribPointer(st,3,h.FLOAT,!1,0,0),h.uniform1f(ne,Math.max(2.5,$*Math.sqrt(p.k)*2.5*lt)),h.drawArrays(h.POINTS,0,1);const Lr=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,Lr),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,.8,.2]),h.STATIC_DRAW),h.vertexAttribPointer(st,3,h.FLOAT,!1,0,0),h.uniform1f(ne,Math.max(3,$*Math.sqrt(p.k)*3*lt)),h.drawArrays(h.POINTS,0,1),h.deleteBuffer(gr),h.deleteBuffer(qr),h.deleteBuffer(Lr)}}function Qt(){if(!(!i.value||!r.value)){if(o=i.value.getContext("webgl",{preserveDrawingBuffer:!0,antialias:!0,alpha:!0})||i.value.getContext("experimental-webgl"),!o){console.error("WebGL not supported");return}Jt(i.value,o),l=yn(o,`
13
+ LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);c.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:nt.value,tableName:u.value,isConnected:j.value,activeConnections:i.activeConnectionCount,hasActiveConnections:i.hasActiveConnections}));async function on(){if(nt.value)return;const{connectionId:R}=await i.createConnection(n.viewerId);nt.value=R}const ge=async()=>{try{nt.value||await on(),l.value&&await ne()}catch(R){console.error("Failed to initialize viewer:",R),y.value=`Failed to initialize: ${R.message}`}},ne=async()=>{if(!l.value){y.value="Please provide a valid S3 URL";return}a.value=!0,y.value="";try{const R=n.fileId?`file_${n.fileId}`:`data_${Date.now()}`,U=await i.loadFile(l.value,n.fileType,R,s.value,n.viewerId,$t.value);u.value=U,T("SELECT * FROM data;")}catch{}finally{a.value=!1}},Qt=R=>!u.value||!R?R:R.replace(/\bFROM\s+data\b/gi,`FROM ${u.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${u.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${u.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${u.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${u.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${u.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${u.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${u.value})`),rt=async()=>{if(!d.value||!nt.value){y.value="Please provide a valid SQL query";return}if(!u.value){y.value="No data table loaded";return}o.value=!0,y.value="",M.value=1;try{const R=Qt(d.value.trim());h.value=await i.executeQuery(R,nt.value),await i.publishViewFromQuery("umap_result",R,nt.value),r("query-results",{results:h.value,query:R})}catch(R){console.error("Query execution failed:",R),y.value=`Query execution failed: ${R.message}`,h.value=null}finally{o.value=!1}},ot=R=>{M.value=R},m=R=>{H.value=R,M.value=1},T=R=>{d.value=R},p=R=>R==null?"NULL":typeof R=="number"?Number.isInteger(R)?R.toString():R.toFixed(4):typeof R=="string"&&R.length>100?R.substring(0,100)+"...":R.toString(),L=()=>{if(!h.value||h.value.length===0)return;const R=Object.keys(h.value[0]),U=[R.join(","),...h.value.map(J=>R.map(Jt=>{const re=J[Jt],Rt=re==null?"":re.toString();return Rt.includes(",")?`"${Rt}"`:Rt}).join(","))].join(`
14
+ `),tt=new Blob([U],{type:"text/csv"}),ht=URL.createObjectURL(tt),ut=document.createElement("a");ut.href=ht,ut.download="query-results.csv",ut.click(),URL.revokeObjectURL(ht)},C=()=>{y.value=""};return c.onMounted(async()=>{await ge()}),c.onUnmounted(async()=>{nt.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(nt.value),i.activeConnectionCount,i.loadedFiles.size)}),(R,U)=>{const tt=c.resolveComponent("bf-button"),ht=c.resolveComponent("el-pagination");return c.openBlock(),c.createElementBlock("div",IT,[c.createElementVNode("header",TT,[U[3]||(U[3]=c.createElementVNode("h1",null,"Data Explorer",-1)),c.createElementVNode("div",{class:c.normalizeClass(["status-indicator",{connected:j.value,loading:a.value}])},c.toDisplayString(Ct.value),3)]),c.createElementVNode("div",AT,[j.value?(c.openBlock(),c.createElementBlock("div",xT,[U[5]||(U[5]=c.createElementVNode("h3",null,"SQL Query",-1)),c.createElementVNode("div",NT,[U[4]||(U[4]=c.createElementVNode("span",null,"Quick queries:",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(xt.value,ut=>(c.openBlock(),c.createElementBlock("button",{key:ut.name,onClick:J=>T(ut.query),class:"example-btn"},c.toDisplayString(ut.name),9,RT))),128))]),c.withDirectives(c.createElementVNode("textarea",{"onUpdate:modelValue":U[0]||(U[0]=ut=>d.value=ut),placeholder:"SELECT * FROM data;",class:"query-textarea",rows:"4"},null,512),[[c.vModelText,d.value]]),c.createVNode(tt,{class:"execute-query-button",onClick:rt,disabled:o.value||!d.value},{default:c.withCtx(()=>[c.createTextVNode(c.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):c.createCommentVNode("",!0),h.value?(c.openBlock(),c.createElementBlock("div",BT,[c.createElementVNode("h3",null,"Results ("+c.toDisplayString(h.value.length)+" rows)",1),c.createElementVNode("div",OT,[c.createElementVNode("div",DT,[c.createVNode(tt,{class:"secondary",onClick:L},{default:c.withCtx(()=>[...U[6]||(U[6]=[c.createTextVNode("Export to CSV",-1)])]),_:1})]),c.createElementVNode("div",FT,[S.value==="table"&&Lt.value>1?(c.openBlock(),c.createBlock(ht,{key:0,"current-page":M.value,"onUpdate:currentPage":U[1]||(U[1]=ut=>M.value=ut),"page-size":H.value,total:h.value.length,layout:"prev, pager, next",onCurrentChange:ot,class:"results-pagination"},null,8,["current-page","page-size","total"])):c.createCommentVNode("",!0)])]),U[7]||(U[7]=c.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),S.value==="table"?(c.openBlock(),c.createElementBlock("div",LT,[c.createElementVNode("table",MT,[c.createElementVNode("thead",null,[c.createElementVNode("tr",null,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(Zt.value,ut=>(c.openBlock(),c.createElementBlock("th",{key:ut},c.toDisplayString(ut),1))),128))])]),c.createElementVNode("tbody",null,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(ie.value,(ut,J)=>(c.openBlock(),c.createElementBlock("tr",{key:J},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(Zt.value,Jt=>(c.openBlock(),c.createElementBlock("td",{key:Jt},c.toDisplayString(p(ut[Jt])),1))),128))]))),128))])]),Lt.value>1?(c.openBlock(),c.createElementBlock("div",CT,[c.createVNode(ht,{"current-page":M.value,"onUpdate:currentPage":U[2]||(U[2]=ut=>M.value=ut),"page-size":H.value,total:h.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:ot,onSizeChange:m},null,8,["current-page","page-size","total"])])):c.createCommentVNode("",!0)])):(c.openBlock(),c.createElementBlock("div",kT,[c.createElementVNode("pre",null,c.toDisplayString(JSON.stringify(h.value.slice(0,100),null,2)),1)]))])):c.createCommentVNode("",!0),y.value?(c.openBlock(),c.createElementBlock("div",UT,[U[8]||(U[8]=c.createElementVNode("h3",null,"Error",-1)),c.createElementVNode("p",null,c.toDisplayString(y.value),1),c.createElementVNode("button",{onClick:C,class:"clear-error-btn"},"Clear")])):c.createCommentVNode("",!0)])])}}},$T=ko(PT,[["__scopeId","data-v-b5de149e"]]),VT={class:"app-container"},zT=c.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=c.ref([]),s=c.ref(""),a=c.ref("parquet"),o=c.ref("");c.onMounted(async()=>{var y,S,M,H,nt;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet");return}const j=ET("",["content","id"],n.pkg);if(!j||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await d(j);const $t=(M=(S=(y=i.value)==null?void 0:y[0])==null?void 0:S.content)==null?void 0:M.id;if(!$t){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=$t,s.value=await h(j,$t);const Ct=(nt=(H=n.pkg)==null?void 0:H.content)==null?void 0:nt.packageType;a.value=Ct==="CSV"?"csv":"parquet"}catch($t){console.error($t)}});function l(y){r("queryResults",y)}async function u(){const{useGetToken:y}=await Promise.resolve().then(()=>bE);return y()}async function d(y){const S=await u(),M=`${n.apiUrl}/packages/${y}/view?api_key=${S}`,H=await fetch(M);if(!H.ok)throw new Error(`view failed: ${H.status}`);i.value=await H.json()}async function h(y,S){const M=await u(),H=`${n.apiUrl}/packages/${y}/files/${S}?api_key=${M}`,nt=await fetch(H);if(!nt.ok)throw new Error(`file url failed: ${nt.status}`);return(await nt.json()).url}return(y,S)=>(c.openBlock(),c.createElementBlock("div",VT,[c.createVNode($T,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:S[0]||(S[0]=M=>l(M))},null,8,["url","file-type","file-id"])]))}}),GT=ko(zT,[["__scopeId","data-v-7298e5bf"]]);var jT={value:()=>{}};function Vh(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new xu(n)}function xu(e){this._=e}function YT(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}xu.prototype=Vh.prototype={constructor:xu,on:function(e,t){var n=this._,r=YT(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=WT(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=Yg(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Yg(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new xu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function WT(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Yg(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=jT,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var zh="http://www.w3.org/1999/xhtml";const Wg={svg:"http://www.w3.org/2000/svg",xhtml:zh,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Nu(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Wg.hasOwnProperty(t)?{space:Wg[t],local:e}:e}function HT(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zh&&t.documentElement.namespaceURI===zh?t.createElement(e):t.createElementNS(n,e)}}function qT(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Hg(e){var t=Nu(e);return(t.local?qT:HT)(t)}function XT(){}function Gh(e){return e==null?XT:function(){return this.querySelector(e)}}function KT(e){typeof e!="function"&&(e=Gh(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,d=0;d<a;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),o[d]=u);return new xi(r,this._parents)}function QT(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function JT(){return[]}function qg(e){return e==null?JT:function(){return this.querySelectorAll(e)}}function ZT(e){return function(){return QT(e.apply(this,arguments))}}function tA(e){typeof e=="function"?e=ZT(e):e=qg(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new xi(r,i)}function Xg(e){return function(){return this.matches(e)}}function Kg(e){return function(t){return t.matches(e)}}var eA=Array.prototype.find;function nA(e){return function(){return eA.call(this.children,e)}}function rA(){return this.firstElementChild}function iA(e){return this.select(e==null?rA:nA(typeof e=="function"?e:Kg(e)))}var sA=Array.prototype.filter;function aA(){return Array.from(this.children)}function oA(e){return function(){return sA.call(this.children,e)}}function lA(e){return this.selectAll(e==null?aA:oA(typeof e=="function"?e:Kg(e)))}function cA(e){typeof e!="function"&&(e=Xg(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new xi(r,this._parents)}function Qg(e){return new Array(e.length)}function uA(){return new xi(this._enter||this._groups.map(Qg),this._parents)}function Ru(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ru.prototype={constructor:Ru,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function dA(e){return function(){return e}}function fA(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new Ru(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function hA(e,t,n,r,i,s,a){var o,l,u=new Map,d=t.length,h=s.length,y=new Array(d),S;for(o=0;o<d;++o)(l=t[o])&&(y[o]=S=a.call(l,l.__data__,o,t)+"",u.has(S)?i[o]=l:u.set(S,l));for(o=0;o<h;++o)S=a.call(e,s[o],o,s)+"",(l=u.get(S))?(r[o]=l,l.__data__=s[o],u.delete(S)):n[o]=new Ru(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&u.get(y[o])===l&&(i[o]=l)}function pA(e){return e.__data__}function mA(e,t){if(!arguments.length)return Array.from(this,pA);var n=t?hA:fA,r=this._parents,i=this._groups;typeof e!="function"&&(e=dA(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var d=r[u],h=i[u],y=h.length,S=yA(e.call(d,d&&d.__data__,u,r)),M=S.length,H=o[u]=new Array(M),nt=a[u]=new Array(M),j=l[u]=new Array(y);n(d,h,H,nt,j,S,t);for(var $t=0,Ct=0,Zt,Lt;$t<M;++$t)if(Zt=H[$t]){for($t>=Ct&&(Ct=$t+1);!(Lt=nt[Ct])&&++Ct<M;);Zt._next=Lt||null}}return a=new xi(a,r),a._enter=o,a._exit=l,a}function yA(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gA(){return new xi(this._exit||this._groups.map(Qg),this._parents)}function _A(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function vA(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],d=r[l],h=u.length,y=o[l]=new Array(h),S,M=0;M<h;++M)(S=u[M]||d[M])&&(y[M]=S);for(;l<i;++l)o[l]=n[l];return new xi(o,this._parents)}function bA(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function wA(e){e||(e=SA);function t(h,y){return h&&y?e(h.__data__,y.__data__):!h-!y}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,d=0;d<o;++d)(u=a[d])&&(l[d]=u);l.sort(t)}return new xi(i,this._parents).order()}function SA(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function EA(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function IA(){return Array.from(this)}function TA(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function AA(){let e=0;for(const t of this)++e;return e}function xA(){return!this.node()}function NA(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function RA(e){return function(){this.removeAttribute(e)}}function BA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function OA(e,t){return function(){this.setAttribute(e,t)}}function DA(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function FA(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function LA(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function MA(e,t){var n=Nu(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?BA:RA:typeof t=="function"?n.local?LA:FA:n.local?DA:OA)(n,t))}function Jg(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function CA(e){return function(){this.style.removeProperty(e)}}function kA(e,t,n){return function(){this.style.setProperty(e,t,n)}}function UA(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function PA(e,t,n){return arguments.length>1?this.each((t==null?CA:typeof t=="function"?UA:kA)(e,t,n??"")):Uo(this.node(),e)}function Uo(e,t){return e.style.getPropertyValue(t)||Jg(e).getComputedStyle(e,null).getPropertyValue(t)}function $A(e){return function(){delete this[e]}}function VA(e,t){return function(){this[e]=t}}function zA(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function GA(e,t){return arguments.length>1?this.each((t==null?$A:typeof t=="function"?zA:VA)(e,t)):this.node()[e]}function Zg(e){return e.trim().split(/^|\s+/)}function jh(e){return e.classList||new t_(e)}function t_(e){this._node=e,this._names=Zg(e.getAttribute("class")||"")}t_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function e_(e,t){for(var n=jh(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function n_(e,t){for(var n=jh(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function jA(e){return function(){e_(this,e)}}function YA(e){return function(){n_(this,e)}}function WA(e,t){return function(){(t.apply(this,arguments)?e_:n_)(this,e)}}function HA(e,t){var n=Zg(e+"");if(arguments.length<2){for(var r=jh(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?WA:t?jA:YA)(n,t))}function qA(){this.textContent=""}function XA(e){return function(){this.textContent=e}}function KA(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function QA(e){return arguments.length?this.each(e==null?qA:(typeof e=="function"?KA:XA)(e)):this.node().textContent}function JA(){this.innerHTML=""}function ZA(e){return function(){this.innerHTML=e}}function tx(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ex(e){return arguments.length?this.each(e==null?JA:(typeof e=="function"?tx:ZA)(e)):this.node().innerHTML}function nx(){this.nextSibling&&this.parentNode.appendChild(this)}function rx(){return this.each(nx)}function ix(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function sx(){return this.each(ix)}function ax(e){var t=typeof e=="function"?e:Hg(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ox(){return null}function lx(e,t){var n=typeof e=="function"?e:Hg(e),r=t==null?ox:typeof t=="function"?t:Gh(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function cx(){var e=this.parentNode;e&&e.removeChild(this)}function ux(){return this.each(cx)}function dx(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function fx(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function hx(e){return this.select(e?fx:dx)}function px(e){return arguments.length?this.property("__data__",e):this.node().__data__}function mx(e){return function(t){e.call(this,t,this.__data__)}}function yx(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function gx(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function _x(e,t,n){return function(){var r=this.__on,i,s=mx(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function vx(e,t,n){var r=yx(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,d;l<u;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?_x:gx,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function r_(e,t,n){var r=Jg(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function bx(e,t){return function(){return r_(this,e,t)}}function wx(e,t){return function(){return r_(this,e,t.apply(this,arguments))}}function Sx(e,t){return this.each((typeof t=="function"?wx:bx)(e,t))}function*Ex(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var i_=[null];function xi(e,t){this._groups=e,this._parents=t}function tc(){return new xi([[document.documentElement]],i_)}function Ix(){return this}xi.prototype=tc.prototype={constructor:xi,select:KT,selectAll:tA,selectChild:iA,selectChildren:lA,filter:cA,data:mA,enter:uA,exit:gA,join:_A,merge:vA,selection:Ix,order:bA,sort:wA,call:EA,nodes:IA,node:TA,size:AA,empty:xA,each:NA,attr:MA,style:PA,property:GA,classed:HA,text:QA,html:ex,raise:rx,lower:sx,append:ax,insert:lx,remove:ux,clone:hx,datum:px,on:vx,dispatch:Sx,[Symbol.iterator]:Ex};function Qs(e){return typeof e=="string"?new xi([[document.querySelector(e)]],[document.documentElement]):new xi([[e]],i_)}function Tx(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ro(e,t){if(e=Tx(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Yh={capture:!0,passive:!1};function Wh(e){e.preventDefault(),e.stopImmediatePropagation()}function Ax(e){var t=e.document.documentElement,n=Qs(e).on("dragstart.drag",Wh,Yh);"onselectstart"in t?n.on("selectstart.drag",Wh,Yh):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function xx(e,t){var n=e.document.documentElement,r=Qs(e).on("dragstart.drag",null);t&&(r.on("click.drag",Wh,Yh),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Hh(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function s_(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function ec(){}var nc=.7,Bu=1/nc,Po="\\s*([+-]?\\d+)\\s*",rc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ws="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Nx=/^#([0-9a-f]{3,8})$/,Rx=new RegExp(`^rgb\\(${Po},${Po},${Po}\\)$`),Bx=new RegExp(`^rgb\\(${ws},${ws},${ws}\\)$`),Ox=new RegExp(`^rgba\\(${Po},${Po},${Po},${rc}\\)$`),Dx=new RegExp(`^rgba\\(${ws},${ws},${ws},${rc}\\)$`),Fx=new RegExp(`^hsl\\(${rc},${ws},${ws}\\)$`),Lx=new RegExp(`^hsla\\(${rc},${ws},${ws},${rc}\\)$`),a_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Hh(ec,ic,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:o_,formatHex:o_,formatHex8:Mx,formatHsl:Cx,formatRgb:l_,toString:l_});function o_(){return this.rgb().formatHex()}function Mx(){return this.rgb().formatHex8()}function Cx(){return h_(this).formatHsl()}function l_(){return this.rgb().formatRgb()}function ic(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Nx.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?c_(t):n===3?new mi(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Ou(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Ou(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Rx.exec(e))?new mi(t[1],t[2],t[3],1):(t=Bx.exec(e))?new mi(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ox.exec(e))?Ou(t[1],t[2],t[3],t[4]):(t=Dx.exec(e))?Ou(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Fx.exec(e))?f_(t[1],t[2]/100,t[3]/100,1):(t=Lx.exec(e))?f_(t[1],t[2]/100,t[3]/100,t[4]):a_.hasOwnProperty(e)?c_(a_[e]):e==="transparent"?new mi(NaN,NaN,NaN,0):null}function c_(e){return new mi(e>>16&255,e>>8&255,e&255,1)}function Ou(e,t,n,r){return r<=0&&(e=t=n=NaN),new mi(e,t,n,r)}function kx(e){return e instanceof ec||(e=ic(e)),e?(e=e.rgb(),new mi(e.r,e.g,e.b,e.opacity)):new mi}function qh(e,t,n,r){return arguments.length===1?kx(e):new mi(e,t,n,r??1)}function mi(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Hh(mi,qh,s_(ec,{brighter(e){return e=e==null?Bu:Math.pow(Bu,e),new mi(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?nc:Math.pow(nc,e),new mi(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new mi(io(this.r),io(this.g),io(this.b),Du(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:u_,formatHex:u_,formatHex8:Ux,formatRgb:d_,toString:d_}));function u_(){return`#${so(this.r)}${so(this.g)}${so(this.b)}`}function Ux(){return`#${so(this.r)}${so(this.g)}${so(this.b)}${so((isNaN(this.opacity)?1:this.opacity)*255)}`}function d_(){const e=Du(this.opacity);return`${e===1?"rgb(":"rgba("}${io(this.r)}, ${io(this.g)}, ${io(this.b)}${e===1?")":`, ${e})`}`}function Du(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function io(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function so(e){return e=io(e),(e<16?"0":"")+e.toString(16)}function f_(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rs(e,t,n,r)}function h_(e){if(e instanceof rs)return new rs(e.h,e.s,e.l,e.opacity);if(e instanceof ec||(e=ic(e)),!e)return new rs;if(e instanceof rs)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new rs(a,o,l,e.opacity)}function Px(e,t,n,r){return arguments.length===1?h_(e):new rs(e,t,n,r??1)}function rs(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Hh(rs,Px,s_(ec,{brighter(e){return e=e==null?Bu:Math.pow(Bu,e),new rs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?nc:Math.pow(nc,e),new rs(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new mi(Xh(e>=240?e-240:e+120,i,r),Xh(e,i,r),Xh(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new rs(p_(this.h),Fu(this.s),Fu(this.l),Du(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Du(this.opacity);return`${e===1?"hsl(":"hsla("}${p_(this.h)}, ${Fu(this.s)*100}%, ${Fu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function p_(e){return e=(e||0)%360,e<0?e+360:e}function Fu(e){return Math.max(0,Math.min(1,e||0))}function Xh(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const m_=e=>()=>e;function $x(e,t){return function(n){return e+n*t}}function Vx(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function zx(e){return(e=+e)==1?y_:function(t,n){return n-t?Vx(t,n,e):m_(isNaN(t)?n:t)}}function y_(e,t){var n=t-e;return n?$x(e,n):m_(isNaN(e)?t:e)}const g_=(function e(t){var n=zx(t);function r(i,s){var a=n((i=qh(i)).r,(s=qh(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=y_(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=e,r})(1);function Ba(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Kh=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Qh=new RegExp(Kh.source,"g");function Gx(e){return function(){return e}}function jx(e){return function(t){return e(t)+""}}function Yx(e,t){var n=Kh.lastIndex=Qh.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Kh.exec(e))&&(i=Qh.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Ba(r,i)})),n=Qh.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?jx(l[0].x):Gx(t):(t=l.length,function(u){for(var d=0,h;d<t;++d)o[(h=l[d]).i]=h.x(u);return o.join("")})}var __=180/Math.PI,v_={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function b_(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*__,skewX:Math.atan(l)*__,scaleX:a,scaleY:o}}var Lu;function Wx(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?v_:b_(t.a,t.b,t.c,t.d,t.e,t.f)}function Hx(e){return e==null||(Lu||(Lu=document.createElementNS("http://www.w3.org/2000/svg","g")),Lu.setAttribute("transform",e),!(e=Lu.transform.baseVal.consolidate()))?v_:(e=e.matrix,b_(e.a,e.b,e.c,e.d,e.e,e.f))}function w_(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,d,h,y,S,M){if(u!==h||d!==y){var H=S.push("translate(",null,t,null,n);M.push({i:H-4,x:Ba(u,h)},{i:H-2,x:Ba(d,y)})}else(h||y)&&S.push("translate("+h+t+y+n)}function a(u,d,h,y){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),y.push({i:h.push(i(h)+"rotate(",null,r)-2,x:Ba(u,d)})):d&&h.push(i(h)+"rotate("+d+r)}function o(u,d,h,y){u!==d?y.push({i:h.push(i(h)+"skewX(",null,r)-2,x:Ba(u,d)}):d&&h.push(i(h)+"skewX("+d+r)}function l(u,d,h,y,S,M){if(u!==h||d!==y){var H=S.push(i(S)+"scale(",null,",",null,")");M.push({i:H-4,x:Ba(u,h)},{i:H-2,x:Ba(d,y)})}else(h!==1||y!==1)&&S.push(i(S)+"scale("+h+","+y+")")}return function(u,d){var h=[],y=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,h,y),a(u.rotate,d.rotate,h,y),o(u.skewX,d.skewX,h,y),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,h,y),u=d=null,function(S){for(var M=-1,H=y.length,nt;++M<H;)h[(nt=y[M]).i]=nt.x(S);return h.join("")}}}var qx=w_(Wx,"px, ","px)","deg)"),Xx=w_(Hx,", ",")",")"),Kx=1e-12;function S_(e){return((e=Math.exp(e))+1/e)/2}function Qx(e){return((e=Math.exp(e))-1/e)/2}function Jx(e){return((e=Math.exp(2*e))-1)/(e+1)}const Zx=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],d=a[0],h=a[1],y=a[2],S=d-o,M=h-l,H=S*S+M*M,nt,j;if(H<Kx)j=Math.log(y/u)/t,nt=function(xt){return[o+xt*S,l+xt*M,u*Math.exp(t*xt*j)]};else{var $t=Math.sqrt(H),Ct=(y*y-u*u+r*H)/(2*u*n*$t),Zt=(y*y-u*u-r*H)/(2*y*n*$t),Lt=Math.log(Math.sqrt(Ct*Ct+1)-Ct),ie=Math.log(Math.sqrt(Zt*Zt+1)-Zt);j=(ie-Lt)/t,nt=function(xt){var on=xt*j,ge=S_(Lt),ne=u/(n*$t)*(ge*Jx(t*on+Lt)-Qx(Lt));return[o+ne*S,l+ne*M,u*ge/S_(t*on+Lt)]}}return nt.duration=j*1e3*t/Math.SQRT2,nt}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);var $o=0,sc=0,ac=0,E_=1e3,Mu,oc,Cu=0,ao=0,ku=0,lc=typeof performance=="object"&&performance.now?performance:Date,I_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Jh(){return ao||(I_(t2),ao=lc.now()+ku)}function t2(){ao=0}function Uu(){this._call=this._time=this._next=null}Uu.prototype=T_.prototype={constructor:Uu,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Jh():+n)+(t==null?0:+t),!this._next&&oc!==this&&(oc?oc._next=this:Mu=this,oc=this),this._call=e,this._time=n,Zh()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zh())}};function T_(e,t,n){var r=new Uu;return r.restart(e,t,n),r}function e2(){Jh(),++$o;for(var e=Mu,t;e;)(t=ao-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$o}function A_(){ao=(Cu=lc.now())+ku,$o=sc=0;try{e2()}finally{$o=0,r2(),ao=0}}function n2(){var e=lc.now(),t=e-Cu;t>E_&&(ku-=t,Cu=e)}function r2(){for(var e,t=Mu,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Mu=n);oc=e,Zh(r)}function Zh(e){if(!$o){sc&&(sc=clearTimeout(sc));var t=e-ao;t>24?(e<1/0&&(sc=setTimeout(A_,e-lc.now()-ku)),ac&&(ac=clearInterval(ac))):(ac||(Cu=lc.now(),ac=setInterval(n2,E_)),$o=1,I_(A_))}}function x_(e,t,n){var r=new Uu;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var i2=Vh("start","end","cancel","interrupt"),s2=[],N_=0,R_=1,tp=2,Pu=3,B_=4,ep=5,$u=6;function Vu(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;a2(e,n,{name:t,index:r,group:i,on:i2,tween:s2,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:N_})}function np(e,t){var n=is(e,t);if(n.state>N_)throw new Error("too late; already scheduled");return n}function Ss(e,t){var n=is(e,t);if(n.state>Pu)throw new Error("too late; already running");return n}function is(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function a2(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=T_(s,0,n.time);function s(u){n.state=R_,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,h,y,S;if(n.state!==R_)return l();for(d in r)if(S=r[d],S.name===n.name){if(S.state===Pu)return x_(a);S.state===B_?(S.state=$u,S.timer.stop(),S.on.call("interrupt",e,e.__data__,S.index,S.group),delete r[d]):+d<t&&(S.state=$u,S.timer.stop(),S.on.call("cancel",e,e.__data__,S.index,S.group),delete r[d])}if(x_(function(){n.state===Pu&&(n.state=B_,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=tp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===tp){for(n.state=Pu,i=new Array(y=n.tween.length),d=0,h=-1;d<y;++d)(S=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++h]=S);i.length=h+1}}function o(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=ep,1),h=-1,y=i.length;++h<y;)i[h].call(e,d);n.state===ep&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=$u,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function zu(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>tp&&r.state<ep,r.state=$u,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function o2(e){return this.each(function(){zu(this,e)})}function l2(e,t){var n,r;return function(){var i=Ss(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function c2(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=Ss(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function u2(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=is(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?l2:c2)(n,e,t))}function rp(e,t,n){var r=e._id;return e.each(function(){var i=Ss(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return is(i,r).value[t]}}function O_(e,t){var n;return(typeof t=="number"?Ba:t instanceof ic?g_:(n=ic(t))?(t=n,g_):Yx)(e,t)}function d2(e){return function(){this.removeAttribute(e)}}function f2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function h2(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function p2(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function m2(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function y2(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function g2(e,t){var n=Nu(e),r=n==="transform"?Xx:O_;return this.attrTween(e,typeof t=="function"?(n.local?y2:m2)(n,r,rp(this,"attr."+e,t)):t==null?(n.local?f2:d2)(n):(n.local?p2:h2)(n,r,t))}function _2(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function v2(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function b2(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&v2(e,s)),n}return i._value=t,i}function w2(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&_2(e,s)),n}return i._value=t,i}function S2(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Nu(e);return this.tween(n,(r.local?b2:w2)(r,t))}function E2(e,t){return function(){np(this,e).delay=+t.apply(this,arguments)}}function I2(e,t){return t=+t,function(){np(this,e).delay=t}}function T2(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?E2:I2)(t,e)):is(this.node(),t).delay}function A2(e,t){return function(){Ss(this,e).duration=+t.apply(this,arguments)}}function x2(e,t){return t=+t,function(){Ss(this,e).duration=t}}function N2(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?A2:x2)(t,e)):is(this.node(),t).duration}function R2(e,t){if(typeof t!="function")throw new Error;return function(){Ss(this,e).ease=t}}function B2(e){var t=this._id;return arguments.length?this.each(R2(t,e)):is(this.node(),t).ease}function O2(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ss(this,e).ease=n}}function D2(e){if(typeof e!="function")throw new Error;return this.each(O2(this._id,e))}function F2(e){typeof e!="function"&&(e=Xg(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Js(r,this._parents,this._name,this._id)}function L2(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],d=l.length,h=a[o]=new Array(d),y,S=0;S<d;++S)(y=l[S]||u[S])&&(h[S]=y);for(;o<r;++o)a[o]=t[o];return new Js(a,this._parents,this._name,this._id)}function M2(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function C2(e,t,n){var r,i,s=M2(t)?np:Ss;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function k2(e,t){var n=this._id;return arguments.length<2?is(this.node(),n).on.on(e):this.each(C2(n,e,t))}function U2(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function P2(){return this.on("end.remove",U2(this._id))}function $2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gh(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),d,h,y=0;y<l;++y)(d=o[y])&&(h=e.call(d,d.__data__,y,o))&&("__data__"in d&&(h.__data__=d.__data__),u[y]=h,Vu(u[y],t,n,y,u,is(d,n)));return new Js(s,this._parents,t,n)}function V2(e){var t=this._name,n=this._id;typeof e!="function"&&(e=qg(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){for(var y=e.call(d,d.__data__,h,l),S,M=is(d,n),H=0,nt=y.length;H<nt;++H)(S=y[H])&&Vu(S,t,n,H,y,M);s.push(y),a.push(d)}return new Js(s,a,t,n)}var z2=tc.prototype.constructor;function G2(){return new z2(this._groups,this._parents)}function j2(e,t){var n,r,i;return function(){var s=Uo(this,e),a=(this.style.removeProperty(e),Uo(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function D_(e){return function(){this.style.removeProperty(e)}}function Y2(e,t,n){var r,i=n+"",s;return function(){var a=Uo(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function W2(e,t,n){var r,i,s;return function(){var a=Uo(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Uo(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function H2(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=Ss(this,e),u=l.on,d=l.value[s]==null?o||(o=D_(t)):void 0;(u!==n||i!==d)&&(r=(n=u).copy()).on(a,i=d),l.on=r}}function q2(e,t,n){var r=(e+="")=="transform"?qx:O_;return t==null?this.styleTween(e,j2(e,r)).on("end.style."+e,D_(e)):typeof t=="function"?this.styleTween(e,W2(e,r,rp(this,"style."+e,t))).each(H2(this._id,e)):this.styleTween(e,Y2(e,r,t),n).on("end.style."+e,null)}function X2(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function K2(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&X2(e,a,n)),r}return s._value=t,s}function Q2(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,K2(e,t,n??""))}function J2(e){return function(){this.textContent=e}}function Z2(e){return function(){var t=e(this);this.textContent=t??""}}function tN(e){return this.tween("text",typeof e=="function"?Z2(rp(this,"text",e)):J2(e==null?"":e+""))}function eN(e){return function(t){this.textContent=e.call(this,t)}}function nN(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&eN(i)),t}return r._value=e,r}function rN(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,nN(e))}function iN(){for(var e=this._name,t=this._id,n=F_(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var d=is(l,t);Vu(l,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Js(r,this._parents,e,n)}function sN(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=Ss(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var aN=0;function Js(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function F_(){return++aN}var Zs=tc.prototype;Js.prototype={constructor:Js,select:$2,selectAll:V2,selectChild:Zs.selectChild,selectChildren:Zs.selectChildren,filter:F2,merge:L2,selection:G2,transition:iN,call:Zs.call,nodes:Zs.nodes,node:Zs.node,size:Zs.size,empty:Zs.empty,each:Zs.each,on:k2,attr:g2,attrTween:S2,style:q2,styleTween:Q2,text:tN,textTween:rN,remove:P2,tween:u2,delay:T2,duration:N2,ease:B2,easeVarying:D2,end:sN,[Symbol.iterator]:Zs[Symbol.iterator]};function oN(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lN={time:null,delay:0,duration:250,ease:oN};function cN(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function uN(e){var t,n;e instanceof Js?(t=e._id,e=e._name):(t=F_(),(n=lN).time=Jh(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&Vu(l,e,t,u,a,n||cN(l,t));return new Js(r,this._parents,e,t)}tc.prototype.interrupt=o2,tc.prototype.transition=uN;const Gu=e=>()=>e;function dN(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ta(e,t,n){this.k=e,this.x=t,this.y=n}ta.prototype={constructor:ta,scale:function(e){return e===1?this:new ta(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ta(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ju=new ta(1,0,0);ta.prototype;function ip(e){e.stopImmediatePropagation()}function cc(e){e.preventDefault(),e.stopImmediatePropagation()}function fN(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function L_(){return this.__zoom||ju}function pN(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function mN(){return navigator.maxTouchPoints||"ontouchstart"in this}function yN(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function gN(){var e=fN,t=hN,n=yN,r=pN,i=mN,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Zx,u=Vh("start","zoom","end"),d,h,y,S=500,M=150,H=0,nt=10;function j(m){m.property("__zoom",L_).on("wheel.zoom",on,{passive:!1}).on("mousedown.zoom",ge).on("dblclick.zoom",ne).filter(i).on("touchstart.zoom",Qt).on("touchmove.zoom",rt).on("touchend.zoom touchcancel.zoom",ot).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(m,T,p,L){var C=m.selection?m.selection():m;C.property("__zoom",L_),m!==C?Lt(m,T,p,L):C.interrupt().each(function(){ie(this,arguments).event(L).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},j.scaleBy=function(m,T,p,L){j.scaleTo(m,function(){var C=this.__zoom.k,R=typeof T=="function"?T.apply(this,arguments):T;return C*R},p,L)},j.scaleTo=function(m,T,p,L){j.transform(m,function(){var C=t.apply(this,arguments),R=this.__zoom,U=p==null?Zt(C):typeof p=="function"?p.apply(this,arguments):p,tt=R.invert(U),ht=typeof T=="function"?T.apply(this,arguments):T;return n(Ct($t(R,ht),U,tt),C,a)},p,L)},j.translateBy=function(m,T,p,L){j.transform(m,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof p=="function"?p.apply(this,arguments):p),t.apply(this,arguments),a)},null,L)},j.translateTo=function(m,T,p,L,C){j.transform(m,function(){var R=t.apply(this,arguments),U=this.__zoom,tt=L==null?Zt(R):typeof L=="function"?L.apply(this,arguments):L;return n(ju.translate(tt[0],tt[1]).scale(U.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof p=="function"?-p.apply(this,arguments):-p),R,a)},L,C)};function $t(m,T){return T=Math.max(s[0],Math.min(s[1],T)),T===m.k?m:new ta(T,m.x,m.y)}function Ct(m,T,p){var L=T[0]-p[0]*m.k,C=T[1]-p[1]*m.k;return L===m.x&&C===m.y?m:new ta(m.k,L,C)}function Zt(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function Lt(m,T,p,L){m.on("start.zoom",function(){ie(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){ie(this,arguments).event(L).end()}).tween("zoom",function(){var C=this,R=arguments,U=ie(C,R).event(L),tt=t.apply(C,R),ht=p==null?Zt(tt):typeof p=="function"?p.apply(C,R):p,ut=Math.max(tt[1][0]-tt[0][0],tt[1][1]-tt[0][1]),J=C.__zoom,Jt=typeof T=="function"?T.apply(C,R):T,re=l(J.invert(ht).concat(ut/J.k),Jt.invert(ht).concat(ut/Jt.k));return function(Rt){if(Rt===1)Rt=Jt;else{var fe=re(Rt),En=ut/fe[2];Rt=new ta(En,ht[0]-fe[0]*En,ht[1]-fe[1]*En)}U.zoom(null,Rt)}})}function ie(m,T,p){return!p&&m.__zooming||new xt(m,T)}function xt(m,T){this.that=m,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,T),this.taps=0}xt.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,T){return this.mouse&&m!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var T=Qs(this.that).datum();u.call(m,this.that,new dN(m,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:u}),T)}};function on(m,...T){if(!e.apply(this,arguments))return;var p=ie(this,T).event(m),L=this.__zoom,C=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,r.apply(this,arguments)))),R=ro(m);if(p.wheel)(p.mouse[0][0]!==R[0]||p.mouse[0][1]!==R[1])&&(p.mouse[1]=L.invert(p.mouse[0]=R)),clearTimeout(p.wheel);else{if(L.k===C)return;p.mouse=[R,L.invert(R)],zu(this),p.start()}cc(m),p.wheel=setTimeout(U,M),p.zoom("mouse",n(Ct($t(L,C),p.mouse[0],p.mouse[1]),p.extent,a));function U(){p.wheel=null,p.end()}}function ge(m,...T){if(y||!e.apply(this,arguments))return;var p=m.currentTarget,L=ie(this,T,!0).event(m),C=Qs(m.view).on("mousemove.zoom",ht,!0).on("mouseup.zoom",ut,!0),R=ro(m,p),U=m.clientX,tt=m.clientY;Ax(m.view),ip(m),L.mouse=[R,this.__zoom.invert(R)],zu(this),L.start();function ht(J){if(cc(J),!L.moved){var Jt=J.clientX-U,re=J.clientY-tt;L.moved=Jt*Jt+re*re>H}L.event(J).zoom("mouse",n(Ct(L.that.__zoom,L.mouse[0]=ro(J,p),L.mouse[1]),L.extent,a))}function ut(J){C.on("mousemove.zoom mouseup.zoom",null),xx(J.view,L.moved),cc(J),L.event(J).end()}}function ne(m,...T){if(e.apply(this,arguments)){var p=this.__zoom,L=ro(m.changedTouches?m.changedTouches[0]:m,this),C=p.invert(L),R=p.k*(m.shiftKey?.5:2),U=n(Ct($t(p,R),L,C),t.apply(this,T),a);cc(m),o>0?Qs(this).transition().duration(o).call(Lt,U,L,m):Qs(this).call(j.transform,U,L,m)}}function Qt(m,...T){if(e.apply(this,arguments)){var p=m.touches,L=p.length,C=ie(this,T,m.changedTouches.length===L).event(m),R,U,tt,ht;for(ip(m),U=0;U<L;++U)tt=p[U],ht=ro(tt,this),ht=[ht,this.__zoom.invert(ht),tt.identifier],C.touch0?!C.touch1&&C.touch0[2]!==ht[2]&&(C.touch1=ht,C.taps=0):(C.touch0=ht,R=!0,C.taps=1+!!d);d&&(d=clearTimeout(d)),R&&(C.taps<2&&(h=ht[0],d=setTimeout(function(){d=null},S)),zu(this),C.start())}}function rt(m,...T){if(this.__zooming){var p=ie(this,T).event(m),L=m.changedTouches,C=L.length,R,U,tt,ht;for(cc(m),R=0;R<C;++R)U=L[R],tt=ro(U,this),p.touch0&&p.touch0[2]===U.identifier?p.touch0[0]=tt:p.touch1&&p.touch1[2]===U.identifier&&(p.touch1[0]=tt);if(U=p.that.__zoom,p.touch1){var ut=p.touch0[0],J=p.touch0[1],Jt=p.touch1[0],re=p.touch1[1],Rt=(Rt=Jt[0]-ut[0])*Rt+(Rt=Jt[1]-ut[1])*Rt,fe=(fe=re[0]-J[0])*fe+(fe=re[1]-J[1])*fe;U=$t(U,Math.sqrt(Rt/fe)),tt=[(ut[0]+Jt[0])/2,(ut[1]+Jt[1])/2],ht=[(J[0]+re[0])/2,(J[1]+re[1])/2]}else if(p.touch0)tt=p.touch0[0],ht=p.touch0[1];else return;p.zoom("touch",n(Ct(U,tt,ht),p.extent,a))}}function ot(m,...T){if(this.__zooming){var p=ie(this,T).event(m),L=m.changedTouches,C=L.length,R,U;for(ip(m),y&&clearTimeout(y),y=setTimeout(function(){y=null},S),R=0;R<C;++R)U=L[R],p.touch0&&p.touch0[2]===U.identifier?delete p.touch0:p.touch1&&p.touch1[2]===U.identifier&&delete p.touch1;if(p.touch1&&!p.touch0&&(p.touch0=p.touch1,delete p.touch1),p.touch0)p.touch0[1]=this.__zoom.invert(p.touch0[0]);else if(p.end(),p.taps===2&&(U=ro(U,this),Math.hypot(h[0]-U[0],h[1]-U[1])<nt)){var tt=Qs(this).on("dblclick.zoom");tt&&tt.apply(this,arguments)}}}return j.wheelDelta=function(m){return arguments.length?(r=typeof m=="function"?m:Gu(+m),j):r},j.filter=function(m){return arguments.length?(e=typeof m=="function"?m:Gu(!!m),j):e},j.touchable=function(m){return arguments.length?(i=typeof m=="function"?m:Gu(!!m),j):i},j.extent=function(m){return arguments.length?(t=typeof m=="function"?m:Gu([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),j):t},j.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],j):[s[0],s[1]]},j.translateExtent=function(m){return arguments.length?(a[0][0]=+m[0][0],a[1][0]=+m[1][0],a[0][1]=+m[0][1],a[1][1]=+m[1][1],j):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},j.constrain=function(m){return arguments.length?(n=m,j):n},j.duration=function(m){return arguments.length?(o=+m,j):o},j.interpolate=function(m){return arguments.length?(l=m,j):l},j.on=function(){var m=u.on.apply(u,arguments);return m===u?j:m},j.clickDistance=function(m){return arguments.length?(H=(m=+m)*m,j):Math.sqrt(H)},j.tapDistance=function(m){return arguments.length?(nt=+m,j):nt},j}const _N=c.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map},selectedMapEntries:{type:[Array,Map],default:()=>[]}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=c.ref(null),i=c.ref(null),s=c.ref(null),a=c.ref(null);let o=null,l=null,u=null,d=[],h=null,y=null,S=null,M=0,H=0,nt=1;c.watch(()=>n.colorMap,T,{deep:!0});function j(p){if(!p||p.length<7)return[1,0,0];const L=parseInt(p.slice(1,3),16)/255,C=parseInt(p.slice(3,5),16)/255,R=parseInt(p.slice(5,7),16)/255;return[L,C,R].some(Number.isNaN)?[1,0,0]:[L,C,R]}const $t=(p,L,C)=>p+(L-p)*C;function Ct(p,L){const C=p.parentElement;C&&(nt=window.devicePixelRatio||1,M=C.clientWidth||800,H=C.clientHeight||400,p.style.width=`${M}px`,p.style.height=`${H}px`,p.width=Math.round(M*nt),p.height=Math.round(H*nt),L.viewport(0,0,p.width,p.height))}function Zt(p,L){var C,R,U,tt,ht,ut,J,Jt,re,Rt,fe,En;const hn=(ut=(ht=(tt=(U=(R=(C=n.metaData)==null?void 0:C.row_groups)==null?void 0:R[0])==null?void 0:U.columns)==null?void 0:tt[0])==null?void 0:ht.meta_data)==null?void 0:ut.statistics,Kn=(En=(fe=(Rt=(re=(Jt=(J=n.metaData)==null?void 0:J.row_groups)==null?void 0:Jt[0])==null?void 0:re.columns)==null?void 0:Rt[1])==null?void 0:fe.meta_data)==null?void 0:En.statistics,pn=Number((hn==null?void 0:hn.min_value)??-1),yn=Number((hn==null?void 0:hn.max_value)??1),In=Number((Kn==null?void 0:Kn.min_value)??-1),ir=Number((Kn==null?void 0:Kn.max_value)??1),sr=(pn+yn)/2,qt=(In+ir)/2,et=Math.max(1e-9,yn-pn),te=Math.max(1e-9,ir-In),gn=2/Math.max(et,te),_n=h.x/p*2-1,tr=-h.y/L*2+1,_=h.k*gn,Qn=_n-_*sr,Ir=tr-_*qt;return{s:_,tx:Qn,ty:Ir}}function Lt(p,L,C,R){const{s:U,tx:tt,ty:ht}=Zt(C,R),ut=p/C*2-1,J=-(L/R*2-1),Jt=(ut-tt)/U,re=(J-ht)/U;return{x:Jt,y:re}}function ie(p,L,C,R,U){if(!p.length||!h)return null;const tt=Lt(L,C,R,U);let ht=1/0,ut=null;for(const J of p){const Jt=J.x-tt.x,re=J.y-tt.y,Rt=Math.hypot(Jt,re),fe=3/(h.k/2);Rt<ht&&Rt<fe&&(ht=Rt,ut=J)}return ut}function xt(){var p,L;const C=[],R=((p=n.metaData)==null?void 0:p.schema)||[],U=n.data;for(let tt=0;tt<U.length;tt++){const ht=U[tt],ut=Number(ht[0]),J=Number(ht[1]),Jt={};for(let re=0;re<R.length;re++){const Rt=((L=R[re])==null?void 0:L.name)??`col_${re}`;Jt[Rt]=ht[re]}C.push({x:ut,y:J,rawX:ut,rawY:J,color:[.5,.5,.5],id:tt,attrs:Jt})}return C}function on(p,L,C){const R=p.createShader(p.VERTEX_SHADER);if(p.shaderSource(R,L),p.compileShader(R),!p.getShaderParameter(R,p.COMPILE_STATUS))return console.error("Vertex shader error:",p.getShaderInfoLog(R)),null;const U=p.createShader(p.FRAGMENT_SHADER);if(p.shaderSource(U,C),p.compileShader(U),!p.getShaderParameter(U,p.COMPILE_STATUS))return console.error("Fragment shader error:",p.getShaderInfoLog(U)),null;const tt=p.createProgram();return p.attachShader(tt,R),p.attachShader(tt,U),p.linkProgram(tt),p.getProgramParameter(tt,p.LINK_STATUS)?(p.validateProgram(tt),p.getProgramParameter(tt,p.VALIDATE_STATUS)?tt:(console.error("Program validate error:",p.getProgramInfoLog(tt)),null)):(console.error("Program link error:",p.getProgramInfoLog(tt)),null)}function ge(p,L,C){if(!C.length)return null;const R=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,R);const U=new Float32Array(C.flatMap(Rt=>[Rt.x,Rt.y]));p.bufferData(p.ARRAY_BUFFER,U,p.STATIC_DRAW);const tt=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,tt);const ht=new Float32Array(C.flatMap(Rt=>Rt.color));p.bufferData(p.ARRAY_BUFFER,ht,p.STATIC_DRAW);const ut=p.getAttribLocation(L,"a_position"),J=p.getAttribLocation(L,"a_color"),Jt=p.getUniformLocation(L,"u_viewMatrix"),re=p.getUniformLocation(L,"u_pointSize");return{program:L,positionBuffer:R,colorBuffer:tt,positionAttributeLocation:ut,colorAttributeLocation:J,viewMatrixLocation:Jt,pointSizeLocation:re,count:C.length}}function ne(p,L,C,R=null){if(!p||!L||!h)return;const{program:U,positionBuffer:tt,colorBuffer:ht,positionAttributeLocation:ut,colorAttributeLocation:J,viewMatrixLocation:Jt,pointSizeLocation:re,count:Rt}=L;p.clearColor(0,0,0,1),p.clear(p.COLOR_BUFFER_BIT),p.useProgram(U),p.enableVertexAttribArray(ut),p.bindBuffer(p.ARRAY_BUFFER,tt),p.vertexAttribPointer(ut,2,p.FLOAT,!1,0,0),p.enableVertexAttribArray(J),p.bindBuffer(p.ARRAY_BUFFER,ht),p.vertexAttribPointer(J,3,p.FLOAT,!1,0,0);const fe=p.canvas.clientWidth,En=p.canvas.clientHeight,{s:hn,tx:Kn,ty:pn}=Zt(fe,En),yn=new Float32Array([hn,0,0,0,0,hn,0,0,0,0,1,0,Kn,pn,0,1]);if(p.uniformMatrix4fv(Jt,!1,yn),p.uniform1f(re,Math.max(1.5,C*Math.sqrt(h.k)*nt)),p.enable(p.BLEND),p.blendFunc(p.SRC_ALPHA,p.ONE_MINUS_SRC_ALPHA),p.drawArrays(p.POINTS,0,Rt),R){const In=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,In),p.bufferData(p.ARRAY_BUFFER,new Float32Array([R.x,R.y]),p.STATIC_DRAW),p.vertexAttribPointer(ut,2,p.FLOAT,!1,0,0);const ir=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,ir),p.bufferData(p.ARRAY_BUFFER,new Float32Array([1,1,.5]),p.STATIC_DRAW),p.vertexAttribPointer(J,3,p.FLOAT,!1,0,0),p.uniform1f(re,Math.max(2.5,C*Math.sqrt(h.k)*2.5*nt)),p.drawArrays(p.POINTS,0,1);const sr=p.createBuffer();p.bindBuffer(p.ARRAY_BUFFER,sr),p.bufferData(p.ARRAY_BUFFER,new Float32Array([1,.8,.2]),p.STATIC_DRAW),p.vertexAttribPointer(J,3,p.FLOAT,!1,0,0),p.uniform1f(re,Math.max(3,C*Math.sqrt(h.k)*3*nt)),p.drawArrays(p.POINTS,0,1),p.deleteBuffer(In),p.deleteBuffer(ir),p.deleteBuffer(sr)}}function Qt(){if(!(!i.value||!r.value)){if(o=i.value.getContext("webgl",{preserveDrawingBuffer:!0,antialias:!0,alpha:!0})||i.value.getContext("experimental-webgl"),!o){console.error("WebGL not supported");return}Ct(i.value,o),l=on(o,`
15
15
  attribute vec2 a_position;
16
16
  attribute vec3 a_color;
17
17
  uniform mat4 u_viewMatrix;
@@ -32,40 +32,40 @@
32
32
  if (dist > 0.4) { alpha = 1.0 - (dist - 0.4) * 2.0; }
33
33
  gl_FragColor = vec4(v_color, alpha);
34
34
  }
35
- `),l&&(o.useProgram(l),f=$t(),u=Ge(o,l,f),p=Uu.translate(U/2,J/2).scale(1),E=V2().scaleExtent([.1,100]).on("zoom",h=>{p=h.transform,ce(o,u,2,T)}),Xs(i.value).call(E),requestAnimationFrame(()=>ce(o,u,2,null)),i.value.addEventListener("mousemove",at),i.value.addEventListener("mouseleave",ct))}}function at(h){var L,$,D,z,Z;if(!i.value)return;const _t=i.value.getBoundingClientRect(),wt=h.clientX-_t.left,st=h.clientY-_t.top,qt=le(f,wt,st,U,J);if(qt){const ne=s.value;ne.style.left=`${h.clientX+15}px`,ne.style.top=`${h.clientY-15}px`,ne.style.opacity="1";const Zt=((L=n.metaData)==null?void 0:L.schema)||[],Ye=Zt.findIndex(gr=>(gr==null?void 0:gr.name)===n.colorMode),Yn=n.colorMode,_n=Ye>=0?(D=qt.attrs)==null?void 0:D[(($=Zt[Ye])==null?void 0:$.name)||""]:void 0;let cr="";const Fr=n.selectedMapEntries;_n!==void 0&&(Fr instanceof Map?cr=Fr.has(_n)?String(_n):"":Array.isArray(Fr)&&(cr=Fr.some(([gr])=>gr===_n)?String(_n):""));const Si=[];for(let gr=2;gr<Math.min(Zt.length,7);gr++){const qr=(z=Zt[gr])==null?void 0:z.name;if(!qr)continue;const Lr=(Z=qt.attrs)==null?void 0:Z[qr];Si.push(`<div><em>${qr}</em>: ${Lr===void 0?"—":String(Lr)}</div>`)}ne.innerHTML=`
36
- <strong>(${qt.rawX.toFixed(2)}, ${qt.rawY.toFixed(2)})</strong>
37
- ${Ye>=0?`<div><b>${Yn}</b>: ${cr||String(_n)}</div>`:""}
38
- ${Si.join("")}
39
- `,T=qt,ce(o,u,2,T)}else s.value&&(s.value.style.opacity="0"),T!==null&&(T=null,ce(o,u,2,null))}function ct(){s.value&&(s.value.style.opacity="0"),T!==null&&(T=null,ce(o,u,2,null))}function m(){!i.value||!o||(Jt(i.value,o),ce(o,u,2,T))}function F(){var h;if(!o||!u||!n.data.length)return;const L=(((h=n.metaData)==null?void 0:h.schema)||[]).findIndex(wt=>(wt==null?void 0:wt.name)===n.colorMode),$=L>=0?L:-1,D=X(n.startColor),z=X(n.endColor);let Z=[];if(n.colorMap&&n.colorMap.size>0&&$>=0)Z=n.data.flatMap(wt=>n.colorMap.get(wt[$])||[.6,.6,.6]);else if($>=0){const wt=n.data.map(ne=>Number(ne[$])).filter(Number.isFinite),st=Math.min(...wt),qt=Math.max(...wt)-st||1;Z=n.data.flatMap(ne=>{const Zt=Number(ne[$]),Ye=Math.max(0,Math.min(1,(Zt-st)/qt));return[Kt(D[0],z[0],Ye),Kt(D[1],z[1],Ye),Kt(D[2],z[2],Ye)]})}else{const wt=X(n.singleColor);Z=n.data.flatMap(()=>wt)}o.deleteBuffer(u.colorBuffer);const _t=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,_t),o.bufferData(o.ARRAY_BUFFER,new Float32Array(Z),o.STATIC_DRAW),u.colorBuffer=_t,ce(o,u,2,T)}return c.watch(()=>n.forceRegenerate,()=>{!o||!l||(f=$t(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=Ge(o,l,f),p=Uu,i.value&&E&&Xs(i.value).call(E.transform,p),F(),ce(o,u,2,null))}),c.watch(()=>n.data,()=>{if(!o||!l){Qt();return}f=$t(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=Ge(o,l,f),F(),ce(o,u,2,null)}),c.watch(()=>n.colorMode,F),c.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],F),c.watch(()=>n.pointCount,h=>{!o||!l||(f=$t(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=Ge(o,l,f),F(),ce(o,u,2,null))}),c.onMounted(()=>{window.addEventListener("resize",m)}),c.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",at),i.value.removeEventListener("mouseleave",ct)),window.removeEventListener("resize",m),o&&u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer),l&&o.deleteProgram(l))}),(h,L)=>(c.openBlock(),c.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[c.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),c.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),c.withDirectives(c.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:a},null,512),[[c.vShow,!1]])],512))}}),G2=Lo(z2,[["__scopeId","data-v-aa7d57bd"]]),j2={class:"control-panel"},Y2={class:"color-option"},W2=["value"],H2={key:0,class:"color-option"},q2={class:"legend"},X2={class:"legend-label"},K2=c.defineComponent({__name:"control",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},colorScheme:{type:Map,default:()=>new Map},colorMapMap:{type:Map,default:()=>new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate","updateColorMap"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(n.pointCount),s=c.ref(n.colorMode),a=c.ref(n.startColor),o=c.ref(n.endColor),l=c.ref(n.singleColor),u=c.computed(()=>n.colorMapMap instanceof Map?Array.from(n.colorMapMap.keys()):[]),f=c.computed(()=>n.colorMapMap instanceof Map?n.colorMapMap.get(s.value):void 0),p=c.computed(()=>f.value?Array.from(f.value.entries()):[]);function E(U){if(!U)return"rgb(150,150,150)";const[J,lt,X]=U;return`rgb(${Math.round(J*255)}, ${Math.round(lt*255)}, ${Math.round(X*255)})`}function T(){r("update:colorMode",s.value),r("updateColorMap",[s.value,f.value??new Map]),r("update:startColor",a.value),r("update:endColor",o.value),r("update:singleColor",l.value)}return c.watch(()=>n.pointCount,U=>i.value=U),c.watch(()=>n.colorMode,U=>s.value=U),c.watch(()=>n.startColor,U=>a.value=U),c.watch(()=>n.endColor,U=>o.value=U),c.watch(()=>n.singleColor,U=>l.value=U),c.watch(s,T),c.watch(()=>n.colorMapMap,()=>{n.colorMapMap instanceof Map&&(s.value!=="random"&&!n.colorMapMap.has(s.value)&&(s.value="random"),T())}),(U,J)=>(c.openBlock(),c.createElementBlock("div",j2,[J[4]||(J[4]=c.createElementVNode("h3",null,"Color Controls",-1)),c.createElementVNode("div",Y2,[J[2]||(J[2]=c.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),c.withDirectives(c.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":J[0]||(J[0]=lt=>s.value=lt)},[J[1]||(J[1]=c.createElementVNode("option",{value:"random"},"all",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(u.value,lt=>(c.openBlock(),c.createElementBlock("option",{key:lt,value:lt},c.toDisplayString(lt),9,W2))),128))],512),[[c.vModelSelect,s.value]])]),p.value.length?(c.openBlock(),c.createElementBlock("div",H2,[c.createElementVNode("div",q2,[J[3]||(J[3]=c.createElementVNode("h4",null,"Legend",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(p.value,([lt,X],Kt)=>(c.openBlock(),c.createElementBlock("div",{class:"legend-item",key:`${lt}-${Kt}`},[c.createElementVNode("div",{class:"legend-color",style:c.normalizeStyle({backgroundColor:E(X)})},null,4),c.createElementVNode("div",X2,c.toDisplayString(lt),1)]))),128))])])):c.createCommentVNode("",!0)]))}}),Q2=Lo(K2,[["__scopeId","data-v-832c88a6"]]),J2={class:"app-container"},Zh="UMAP_1",tp="UMAP_2",Z2=c.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=c.ref(5e3),r=c.ref("random"),i=c.ref("#ff0000"),s=c.ref("#0000ff"),a=c.ref("#4285f4"),o=c.ref(!1),l=c.ref(0),u=c.ref([]),f=c.ref(null),p=c.ref(new Map),E=c.ref(new Map),T=c.ref([]),U=Lh(),J=c.ref(null),lt=c.ref(null),X=c.computed(()=>U.formatIdFromUrl(t.srcUrl));c.watch(()=>{var F,h,L,$;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((h=(F=t.pkg)==null?void 0:F.content)==null?void 0:h.id)||"",pkgType:(($=(L=t.pkg)==null?void 0:L.content)==null?void 0:$.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:F,srcFileType:h,srcFileId:L,pkgId:$,pkgType:D,apiUrl:z})=>{var Z,_t,wt;try{if(u.value=[],f.value=null,await Kt(),F){const st=h??(F.toLowerCase().endsWith(".csv")?"csv":"parquet");await Jt(F,st,X.value),await ue();return}if($&&z){await yn($,z);const st=(wt=(_t=(Z=T.value)==null?void 0:Z[0])==null?void 0:_t.content)==null?void 0:wt.id;if(!st)return;const qt=await Ge($,st,z);await Jt(qt,D==="CSV"?"csv":"parquet",st),await ue()}}catch(st){console.error("[UMAP Wrapper] Load failed:",(st==null?void 0:st.message)||st)}},{immediate:!0}),c.watch(n,async()=>{lt.value&&J.value&&await Wt()}),c.watch([()=>U.sharedVersion,()=>U.sharedResultName],async()=>{U.sharedResultName&&(await Kt(),lt.value=U.sharedResultName,await ue())});async function Kt(){if(J.value)return;const{connectionId:F}=await U.createConnection(`umap_${Date.now()}`);J.value=F}async function Jt(F,h,L){const $=`umap_${L.replace(/[^a-zA-Z0-9_]/g,"_")}`;lt.value=await U.loadFile(F,h,$,{},J.value,L)}async function ue(){var F,h,L,$;if(!lt.value||!J.value)return;const D=await m(lt.value),z=D.filter(wt=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(wt.type)),Z=D.some(wt=>wt.name===Zh)?Zh:((F=z[0])==null?void 0:F.name)||((h=D[0])==null?void 0:h.name),_t=D.some(wt=>wt.name===tp)?tp:((L=z[1])==null?void 0:L.name)||(($=D[1])==null?void 0:$.name)||Z;await Wt(Z,_t,D.map(wt=>wt.name)),await le(D,Z,_t)}async function Wt(F=Zh,h=tp,L){var $;if(!lt.value||!J.value)return;const D=(L||(await m(lt.value)).map(st=>st.name)).filter(st=>st!==F&&st!==h),z=`SELECT ${[`CAST(${ce(F)} AS DOUBLE) AS __x`,`CAST(${ce(h)} AS DOUBLE) AS __y`,...D.map(st=>ce(st))].join(", ")} FROM ${lt.value} LIMIT ${n.value}`,Z=await U.executeQuery(z,J.value);u.value=Z.map(st=>[st.__x,st.__y,...D.map(qt=>st[qt])]);const _t=`
40
- SELECT min(${ce(F)}) AS xmin, max(${ce(F)}) AS xmax,
41
- min(${ce(h)}) AS ymin, max(${ce(h)}) AS ymax
42
- FROM ${lt.value}
43
- `,wt=(($=await U.executeQuery(_t,J.value))==null?void 0:$[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};f.value={schema:[{name:F},{name:h},...D.map(st=>({name:st}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:wt.xmin,max_value:wt.xmax}}},{meta_data:{statistics:{min_value:wt.ymin,max_value:wt.ymax}}}]}]}}async function le(F,h,L){E.value=new Map;const $=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],D=z=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(z);for(const z of F){if(z.name===h||z.name===L){E.value.set(z.name,new Map);continue}if(D(z.type))E.value.set(z.name,new Map);else{const Z=`SELECT DISTINCT ${ce(z.name)} AS v FROM ${lt.value} LIMIT 10000`,_t=(await U.executeQuery(Z,J.value)).map(st=>st.v).filter(st=>st!=null),wt=new Map;_t.forEach((st,qt)=>wt.set(st,at($[qt%$.length]))),E.value.set(z.name,wt)}}(f.value||(f.value={})).key_value_metadata=Array.from(E.value.keys()).map(z=>{var Z;return{key:z,value:JSON.stringify(Array.from(((Z=E.value.get(z))==null?void 0:Z.keys())??[]))}}),r.value!=="random"&&!E.value.has(r.value)&&(r.value="random")}async function $t(){const{useGetToken:F}=await Promise.resolve().then(()=>jS);return F()}async function yn(F,h){const L=await $t(),$=`${h}/packages/${F}/view?api_key=${L}`,D=await fetch($);if(!D.ok)throw new Error(`view failed: ${D.status}`);T.value=await D.json()}async function Ge(F,h,L){const $=await $t(),D=`${L}/packages/${F}/files/${h}?api_key=${$}`,z=await fetch(D);if(!z.ok)throw new Error(`file url failed: ${z.status}`);return(await z.json()).url}function ce(F){return`"${F.replace(/"/g,'""')}"`}function Qt(){o.value=!o.value,l.value++}function at(F){try{if(!F||F.length<7)return[1,0,0];const h=parseInt(F.slice(1,3),16)/255,L=parseInt(F.slice(3,5),16)/255,$=parseInt(F.slice(5,7),16)/255;return Number.isNaN(h)||Number.isNaN(L)||Number.isNaN($)?[1,0,0]:[h,L,$]}catch{return[1,0,0]}}function ct(F){p.value=F[1]}async function m(F){return(await U.executeQuery(`PRAGMA table_info(${F});`,J.value)).map(h=>({name:h.name,type:h.type}))}return c.onMounted(async()=>{await Kt()}),c.onBeforeUnmount(async()=>{J.value&&await U.closeConnection(J.value)}),(F,h)=>(c.openBlock(),c.createElementBlock("div",J2,[(c.openBlock(),c.createBlock(G2,{data:u.value,metaData:f.value,pointCount:n.value,"color-map":p.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,selectedMapEntries:Array.from(p.value),forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","selectedMapEntries","forceRegenerate"])),c.createVNode(Q2,{pointCount:n.value,"onUpdate:pointCount":h[0]||(h[0]=L=>n.value=L),colorMode:r.value,"onUpdate:colorMode":h[1]||(h[1]=L=>r.value=L),startColor:i.value,"onUpdate:startColor":h[2]||(h[2]=L=>i.value=L),endColor:s.value,"onUpdate:endColor":h[3]||(h[3]=L=>s.value=L),singleColor:a.value,"onUpdate:singleColor":h[4]||(h[4]=L=>a.value=L),"color-scheme":p.value,"color-map-map":E.value,onRegenerate:Qt,onUpdateColorMap:ct},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),tR=Lo(Z2,[["__scopeId","data-v-1515ae28"]]),eR={class:"pp-container"},nR={class:"pp-header"},rR={class:"pp-controls"},iR={class:"pp-field"},sR=["disabled"],aR={class:"pp-field"},oR=["disabled"],lR=["value"],cR=["value"],uR=["disabled"],dR=["value"],fR={class:"pp-field"},hR=["disabled"],pR={key:0,class:"pp-message"},ep=100,np=12,rp="(other)",mR=c.defineComponent({__name:"proportionPlot",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{},tableNameOverride:{}},setup(e){const t=e;let n;const r=Lh(),i=c.ref(null),s=c.ref(null),a=c.ref(t.srcUrl||"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/precision_human_drg_data.parquet"),o=c.computed(()=>r.formatIdFromUrl(a.value)),l=c.ref(!1),u=c.ref(""),f=c.ref([]),p=c.ref(""),E=c.ref(""),T=`proportion-plot-${Math.random().toString(36).slice(2)}`;c.watch(()=>({srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkg:t.pkg,apiUrl:t.apiUrl}),async({srcUrl:at,srcFileType:ct,srcFileId:m,pkg:F,apiUrl:h})=>{var L,$;try{if(at&&(a.value=at),await X(),a.value){const Z=ct??(a.value.toLowerCase().endsWith(".csv")?"csv":"parquet");await Jt(Z,o.value);return}const D=(L=F==null?void 0:F.content)==null?void 0:L.id,z=($=F==null?void 0:F.content)==null?void 0:$.packageType;if(D&&h){const Z=await yn(D,h);if(!Z)return;const _t=await Ge(D,Z,h),wt=z==="CSV"?"csv":"parquet",st=Z.replace(/[^a-zA-Z0-9_.-]/g,"_");a.value=_t,await Jt(wt,st)}}catch(D){console.error("[ProportionPlot] Load failed:",(D==null?void 0:D.message)||D),u.value=`Load failed: ${(D==null?void 0:D.message)||D}`}},{immediate:!0});const U=new Set(["VARCHAR","STRING","TEXT","BOOL","BOOLEAN","DATE","TIMESTAMP"]),J=c.computed(()=>f.value.filter(at=>U.has(at.type)||at.type.startsWith("VARCHAR"))),lt=c.computed(()=>f.value.filter(at=>!U.has(at.type)));async function X(){if(i.value)return;const{connectionId:at}=await r.createConnection(`prop_${Date.now()}`);i.value=at}function Kt(at){const ct=String(at).replace(/[^A-Za-z0-9_]/g,"_");return(/^[A-Za-z_]/.test(ct)?ct:`t_${ct}`).slice(0,63)}async function Jt(at,ct){i.value||await X();const m=(ct||t.srcFileId||a.value||"file").replace(/[^A-Za-z0-9]/g,"_");l.value=!0,u.value="Loading file into DuckDB…";try{const F=at??(a.value.toLowerCase().endsWith(".csv")?"csv":"parquet"),h=t.tableNameOverride||Kt(`file_${m.slice(0,48)}`),L=await r.loadFile(a.value,F,h,{},i.value,m);s.value=L,await Wt(!0)}finally{l.value=!1}}function ue(at){return'"'+String(at).replace(/"/g,'""')+'"'}async function Wt(at=!1){var ct,m,F,h;if(!s.value||!i.value)return;const L=`PRAGMA table_info(${ue(s.value)})`,$=await r.executeQuery(L,i.value);if(f.value=$.map(D=>({name:String(D.name),type:String(D.type).toUpperCase()})),at||!p.value||!E.value){const D=f.value.filter(z=>U.has(z.type)||z.type.startsWith("VARCHAR"));p.value=((ct=D[0])==null?void 0:ct.name)||((m=f.value[0])==null?void 0:m.name)||"",E.value=((F=D[1])==null?void 0:F.name)||((h=D[0])==null?void 0:h.name)||""}u.value=`Columns: ${f.value.length}.`}async function le(){if(!(!s.value||!i.value)){if(!p.value||!E.value){u.value="Pick both X and Y";return}l.value=!0,u.value="Computing proportions…";try{const at=ue(s.value),ct=ue(p.value),m=ue(E.value),F=`
35
+ `),l&&(o.useProgram(l),d=xt(),u=ge(o,l,d),h=ju.translate(M/2,H/2).scale(1),y=gN().scaleExtent([.1,100]).on("zoom",p=>{h=p.transform,ne(o,u,2,S)}),Qs(i.value).call(y),requestAnimationFrame(()=>ne(o,u,2,null)),i.value.addEventListener("mousemove",rt),i.value.addEventListener("mouseleave",ot))}}function rt(p){var L,C,R,U,tt;if(!i.value)return;const ht=i.value.getBoundingClientRect(),ut=p.clientX-ht.left,J=p.clientY-ht.top,Jt=ie(d,ut,J,M,H);if(Jt){const re=s.value;re.style.left=`${p.clientX+15}px`,re.style.top=`${p.clientY-15}px`,re.style.opacity="1";const Rt=((L=n.metaData)==null?void 0:L.schema)||[],fe=Rt.findIndex(In=>(In==null?void 0:In.name)===n.colorMode),En=n.colorMode,hn=fe>=0?(R=Jt.attrs)==null?void 0:R[((C=Rt[fe])==null?void 0:C.name)||""]:void 0;let Kn="";const pn=n.selectedMapEntries;hn!==void 0&&(pn instanceof Map?Kn=pn.has(hn)?String(hn):"":Array.isArray(pn)&&(Kn=pn.some(([In])=>In===hn)?String(hn):""));const yn=[];for(let In=2;In<Math.min(Rt.length,7);In++){const ir=(U=Rt[In])==null?void 0:U.name;if(!ir)continue;const sr=(tt=Jt.attrs)==null?void 0:tt[ir];yn.push(`<div><em>${ir}</em>: ${sr===void 0?"—":String(sr)}</div>`)}re.innerHTML=`
36
+ <strong>(${Jt.rawX.toFixed(2)}, ${Jt.rawY.toFixed(2)})</strong>
37
+ ${fe>=0?`<div><b>${En}</b>: ${Kn||String(hn)}</div>`:""}
38
+ ${yn.join("")}
39
+ `,S=Jt,ne(o,u,2,S)}else s.value&&(s.value.style.opacity="0"),S!==null&&(S=null,ne(o,u,2,null))}function ot(){s.value&&(s.value.style.opacity="0"),S!==null&&(S=null,ne(o,u,2,null))}function m(){!i.value||!o||(Ct(i.value,o),ne(o,u,2,S))}function T(){var p;if(!o||!u||!n.data.length)return;const L=(((p=n.metaData)==null?void 0:p.schema)||[]).findIndex(ut=>(ut==null?void 0:ut.name)===n.colorMode),C=L>=0?L:-1,R=j(n.startColor),U=j(n.endColor);let tt=[];if(n.colorMap&&n.colorMap.size>0&&C>=0)tt=n.data.flatMap(ut=>n.colorMap.get(ut[C])||[.6,.6,.6]);else if(C>=0){const ut=n.data.map(re=>Number(re[C])).filter(Number.isFinite),J=Math.min(...ut),Jt=Math.max(...ut)-J||1;tt=n.data.flatMap(re=>{const Rt=Number(re[C]),fe=Math.max(0,Math.min(1,(Rt-J)/Jt));return[$t(R[0],U[0],fe),$t(R[1],U[1],fe),$t(R[2],U[2],fe)]})}else{const ut=j(n.singleColor);tt=n.data.flatMap(()=>ut)}o.deleteBuffer(u.colorBuffer);const ht=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,ht),o.bufferData(o.ARRAY_BUFFER,new Float32Array(tt),o.STATIC_DRAW),u.colorBuffer=ht,ne(o,u,2,S)}return c.watch(()=>n.forceRegenerate,()=>{!o||!l||(d=xt(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=ge(o,l,d),h=ju,i.value&&y&&Qs(i.value).call(y.transform,h),T(),ne(o,u,2,null))}),c.watch(()=>n.data,()=>{if(!o||!l){Qt();return}d=xt(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=ge(o,l,d),T(),ne(o,u,2,null)}),c.watch(()=>n.colorMode,T),c.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],T),c.watch(()=>n.pointCount,p=>{!o||!l||(d=xt(),u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer)),u=ge(o,l,d),T(),ne(o,u,2,null))}),c.onMounted(()=>{window.addEventListener("resize",m)}),c.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",rt),i.value.removeEventListener("mouseleave",ot)),window.removeEventListener("resize",m),o&&u&&(o.deleteBuffer(u.positionBuffer),o.deleteBuffer(u.colorBuffer),l&&o.deleteProgram(l))}),(p,L)=>(c.openBlock(),c.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[c.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),c.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),c.withDirectives(c.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:a},null,512),[[c.vShow,!1]])],512))}}),vN=ko(_N,[["__scopeId","data-v-aa7d57bd"]]),bN={class:"control-panel"},wN={class:"color-option"},SN=["value"],EN={key:0,class:"color-option"},IN={class:"legend"},TN={class:"legend-label"},AN=c.defineComponent({__name:"control",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},colorScheme:{type:Map,default:()=>new Map},colorMapMap:{type:Map,default:()=>new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate","updateColorMap"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(n.pointCount),s=c.ref(n.colorMode),a=c.ref(n.startColor),o=c.ref(n.endColor),l=c.ref(n.singleColor),u=c.computed(()=>n.colorMapMap instanceof Map?Array.from(n.colorMapMap.keys()):[]),d=c.computed(()=>n.colorMapMap instanceof Map?n.colorMapMap.get(s.value):void 0),h=c.computed(()=>d.value?Array.from(d.value.entries()):[]);function y(M){if(!M)return"rgb(150,150,150)";const[H,nt,j]=M;return`rgb(${Math.round(H*255)}, ${Math.round(nt*255)}, ${Math.round(j*255)})`}function S(){r("update:colorMode",s.value),r("updateColorMap",[s.value,d.value??new Map]),r("update:startColor",a.value),r("update:endColor",o.value),r("update:singleColor",l.value)}return c.watch(()=>n.pointCount,M=>i.value=M),c.watch(()=>n.colorMode,M=>s.value=M),c.watch(()=>n.startColor,M=>a.value=M),c.watch(()=>n.endColor,M=>o.value=M),c.watch(()=>n.singleColor,M=>l.value=M),c.watch(s,S),c.watch(()=>n.colorMapMap,()=>{n.colorMapMap instanceof Map&&(s.value!=="random"&&!n.colorMapMap.has(s.value)&&(s.value="random"),S())}),(M,H)=>(c.openBlock(),c.createElementBlock("div",bN,[H[4]||(H[4]=c.createElementVNode("h3",null,"Color Controls",-1)),c.createElementVNode("div",wN,[H[2]||(H[2]=c.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),c.withDirectives(c.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":H[0]||(H[0]=nt=>s.value=nt)},[H[1]||(H[1]=c.createElementVNode("option",{value:"random"},"all",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(u.value,nt=>(c.openBlock(),c.createElementBlock("option",{key:nt,value:nt},c.toDisplayString(nt),9,SN))),128))],512),[[c.vModelSelect,s.value]])]),h.value.length?(c.openBlock(),c.createElementBlock("div",EN,[c.createElementVNode("div",IN,[H[3]||(H[3]=c.createElementVNode("h4",null,"Legend",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(h.value,([nt,j],$t)=>(c.openBlock(),c.createElementBlock("div",{class:"legend-item",key:`${nt}-${$t}`},[c.createElementVNode("div",{class:"legend-color",style:c.normalizeStyle({backgroundColor:y(j)})},null,4),c.createElementVNode("div",TN,c.toDisplayString(nt),1)]))),128))])])):c.createCommentVNode("",!0)]))}}),xN=ko(AN,[["__scopeId","data-v-832c88a6"]]),NN={class:"app-container"},sp="UMAP_1",ap="UMAP_2",RN=c.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=c.ref(5e3),r=c.ref("random"),i=c.ref("#ff0000"),s=c.ref("#0000ff"),a=c.ref("#4285f4"),o=c.ref(!1),l=c.ref(0),u=c.ref([]),d=c.ref(null),h=c.ref(new Map),y=c.ref(new Map),S=c.ref([]),M=$h(),H=c.ref(null),nt=c.ref(null),j=c.computed(()=>M.formatIdFromUrl(t.srcUrl));c.watch(()=>{var T,p,L,C;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((p=(T=t.pkg)==null?void 0:T.content)==null?void 0:p.id)||"",pkgType:((C=(L=t.pkg)==null?void 0:L.content)==null?void 0:C.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:T,srcFileType:p,srcFileId:L,pkgId:C,pkgType:R,apiUrl:U})=>{var tt,ht,ut;try{if(u.value=[],d.value=null,await $t(),T){const J=p??(T.toLowerCase().endsWith(".csv")?"csv":"parquet");await Ct(T,J,j.value),await Zt();return}if(C&&U){await on(C,U);const J=(ut=(ht=(tt=S.value)==null?void 0:tt[0])==null?void 0:ht.content)==null?void 0:ut.id;if(!J)return;const Jt=await ge(C,J,U);await Ct(Jt,R==="CSV"?"csv":"parquet",J),await Zt()}}catch(J){console.error("[UMAP Wrapper] Load failed:",(J==null?void 0:J.message)||J)}},{immediate:!0}),c.watch(n,async()=>{nt.value&&H.value&&await Lt()}),c.watch([()=>M.sharedVersion,()=>M.sharedResultName],async()=>{M.sharedResultName&&(await $t(),nt.value=M.sharedResultName,await Zt())});async function $t(){if(H.value)return;const{connectionId:T}=await M.createConnection(`umap_${Date.now()}`);H.value=T}async function Ct(T,p,L){const C=`umap_${L.replace(/[^a-zA-Z0-9_]/g,"_")}`;nt.value=await M.loadFile(T,p,C,{},H.value,L)}async function Zt(){var T,p,L,C;if(!nt.value||!H.value)return;const R=await m(nt.value),U=R.filter(ut=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(ut.type)),tt=R.some(ut=>ut.name===sp)?sp:((T=U[0])==null?void 0:T.name)||((p=R[0])==null?void 0:p.name),ht=R.some(ut=>ut.name===ap)?ap:((L=U[1])==null?void 0:L.name)||((C=R[1])==null?void 0:C.name)||tt;await Lt(tt,ht,R.map(ut=>ut.name)),await ie(R,tt,ht)}async function Lt(T=sp,p=ap,L){var C;if(!nt.value||!H.value)return;const R=(L||(await m(nt.value)).map(J=>J.name)).filter(J=>J!==T&&J!==p),U=`SELECT ${[`CAST(${ne(T)} AS DOUBLE) AS __x`,`CAST(${ne(p)} AS DOUBLE) AS __y`,...R.map(J=>ne(J))].join(", ")} FROM ${nt.value} LIMIT ${n.value}`,tt=await M.executeQuery(U,H.value);u.value=tt.map(J=>[J.__x,J.__y,...R.map(Jt=>J[Jt])]);const ht=`
40
+ SELECT min(${ne(T)}) AS xmin, max(${ne(T)}) AS xmax,
41
+ min(${ne(p)}) AS ymin, max(${ne(p)}) AS ymax
42
+ FROM ${nt.value}
43
+ `,ut=((C=await M.executeQuery(ht,H.value))==null?void 0:C[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};d.value={schema:[{name:T},{name:p},...R.map(J=>({name:J}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:ut.xmin,max_value:ut.xmax}}},{meta_data:{statistics:{min_value:ut.ymin,max_value:ut.ymax}}}]}]}}async function ie(T,p,L){y.value=new Map;const C=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],R=U=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(U);for(const U of T){if(U.name===p||U.name===L){y.value.set(U.name,new Map);continue}if(R(U.type))y.value.set(U.name,new Map);else{const tt=`SELECT DISTINCT ${ne(U.name)} AS v FROM ${nt.value} LIMIT 10000`,ht=(await M.executeQuery(tt,H.value)).map(J=>J.v).filter(J=>J!=null),ut=new Map;ht.forEach((J,Jt)=>ut.set(J,rt(C[Jt%C.length]))),y.value.set(U.name,ut)}}(d.value||(d.value={})).key_value_metadata=Array.from(y.value.keys()).map(U=>{var tt;return{key:U,value:JSON.stringify(Array.from(((tt=y.value.get(U))==null?void 0:tt.keys())??[]))}}),r.value!=="random"&&!y.value.has(r.value)&&(r.value="random")}async function xt(){const{useGetToken:T}=await Promise.resolve().then(()=>bE);return T()}async function on(T,p){const L=await xt(),C=`${p}/packages/${T}/view?api_key=${L}`,R=await fetch(C);if(!R.ok)throw new Error(`view failed: ${R.status}`);S.value=await R.json()}async function ge(T,p,L){const C=await xt(),R=`${L}/packages/${T}/files/${p}?api_key=${C}`,U=await fetch(R);if(!U.ok)throw new Error(`file url failed: ${U.status}`);return(await U.json()).url}function ne(T){return`"${T.replace(/"/g,'""')}"`}function Qt(){o.value=!o.value,l.value++}function rt(T){try{if(!T||T.length<7)return[1,0,0];const p=parseInt(T.slice(1,3),16)/255,L=parseInt(T.slice(3,5),16)/255,C=parseInt(T.slice(5,7),16)/255;return Number.isNaN(p)||Number.isNaN(L)||Number.isNaN(C)?[1,0,0]:[p,L,C]}catch{return[1,0,0]}}function ot(T){h.value=T[1]}async function m(T){return(await M.executeQuery(`PRAGMA table_info(${T});`,H.value)).map(p=>({name:p.name,type:p.type}))}return c.onMounted(async()=>{await $t()}),c.onBeforeUnmount(async()=>{H.value&&await M.closeConnection(H.value)}),(T,p)=>(c.openBlock(),c.createElementBlock("div",NN,[(c.openBlock(),c.createBlock(vN,{data:u.value,metaData:d.value,pointCount:n.value,"color-map":h.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,selectedMapEntries:Array.from(h.value),forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","selectedMapEntries","forceRegenerate"])),c.createVNode(xN,{pointCount:n.value,"onUpdate:pointCount":p[0]||(p[0]=L=>n.value=L),colorMode:r.value,"onUpdate:colorMode":p[1]||(p[1]=L=>r.value=L),startColor:i.value,"onUpdate:startColor":p[2]||(p[2]=L=>i.value=L),endColor:s.value,"onUpdate:endColor":p[3]||(p[3]=L=>s.value=L),singleColor:a.value,"onUpdate:singleColor":p[4]||(p[4]=L=>a.value=L),"color-scheme":h.value,"color-map-map":y.value,onRegenerate:Qt,onUpdateColorMap:ot},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),BN=ko(RN,[["__scopeId","data-v-1515ae28"]]),ON={class:"pp-container"},DN={class:"pp-header"},FN={class:"pp-controls"},LN={class:"pp-field"},MN=["disabled"],CN={class:"pp-field"},kN=["disabled"],UN=["value"],PN=["value"],$N=["disabled"],VN=["value"],zN={class:"pp-field"},GN=["disabled"],jN={key:0,class:"pp-message"},op=100,lp=12,cp="(other)",YN=c.defineComponent({__name:"proportionPlot",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{},tableNameOverride:{}},setup(e){const t=e;let n;const r=$h(),i=c.ref(null),s=c.ref(null),a=c.ref(t.srcUrl||"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/precision_human_drg_data.parquet"),o=c.computed(()=>r.formatIdFromUrl(a.value)),l=c.ref(!1),u=c.ref(""),d=c.ref([]),h=c.ref(""),y=c.ref(""),S=`proportion-plot-${Math.random().toString(36).slice(2)}`;c.watch(()=>({srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkg:t.pkg,apiUrl:t.apiUrl}),async({srcUrl:rt,srcFileType:ot,srcFileId:m,pkg:T,apiUrl:p})=>{var L,C;try{if(rt&&(a.value=rt),await j(),a.value){const tt=ot??(a.value.toLowerCase().endsWith(".csv")?"csv":"parquet");await Ct(tt,o.value);return}const R=(L=T==null?void 0:T.content)==null?void 0:L.id,U=(C=T==null?void 0:T.content)==null?void 0:C.packageType;if(R&&p){const tt=await on(R,p);if(!tt)return;const ht=await ge(R,tt,p),ut=U==="CSV"?"csv":"parquet",J=tt.replace(/[^a-zA-Z0-9_.-]/g,"_");a.value=ht,await Ct(ut,J)}}catch(R){console.error("[ProportionPlot] Load failed:",(R==null?void 0:R.message)||R),u.value=`Load failed: ${(R==null?void 0:R.message)||R}`}},{immediate:!0});const M=new Set(["VARCHAR","STRING","TEXT","BOOL","BOOLEAN","DATE","TIMESTAMP"]),H=c.computed(()=>d.value.filter(rt=>M.has(rt.type)||rt.type.startsWith("VARCHAR"))),nt=c.computed(()=>d.value.filter(rt=>!M.has(rt.type)));async function j(){if(i.value)return;const{connectionId:rt}=await r.createConnection(`prop_${Date.now()}`);i.value=rt}function $t(rt){const ot=String(rt).replace(/[^A-Za-z0-9_]/g,"_");return(/^[A-Za-z_]/.test(ot)?ot:`t_${ot}`).slice(0,63)}async function Ct(rt,ot){i.value||await j();const m=(ot||t.srcFileId||a.value||"file").replace(/[^A-Za-z0-9]/g,"_");l.value=!0,u.value="Loading file into DuckDB…";try{const T=rt??(a.value.toLowerCase().endsWith(".csv")?"csv":"parquet"),p=t.tableNameOverride||$t(`file_${m.slice(0,48)}`),L=await r.loadFile(a.value,T,p,{},i.value,m);s.value=L,await Lt(!0)}finally{l.value=!1}}function Zt(rt){return'"'+String(rt).replace(/"/g,'""')+'"'}async function Lt(rt=!1){var ot,m,T,p;if(!s.value||!i.value)return;const L=`PRAGMA table_info(${Zt(s.value)})`,C=await r.executeQuery(L,i.value);if(d.value=C.map(R=>({name:String(R.name),type:String(R.type).toUpperCase()})),rt||!h.value||!y.value){const R=d.value.filter(U=>M.has(U.type)||U.type.startsWith("VARCHAR"));h.value=((ot=R[0])==null?void 0:ot.name)||((m=d.value[0])==null?void 0:m.name)||"",y.value=((T=R[1])==null?void 0:T.name)||((p=R[0])==null?void 0:p.name)||""}u.value=`Columns: ${d.value.length}.`}async function ie(){if(!(!s.value||!i.value)){if(!h.value||!y.value){u.value="Pick both X and Y";return}l.value=!0,u.value="Computing proportions…";try{const rt=Zt(s.value),ot=Zt(h.value),m=Zt(y.value),T=`
44
44
  WITH xf AS (
45
- SELECT ${ct} AS x, COUNT(*) AS c
46
- FROM ${at}
45
+ SELECT ${ot} AS x, COUNT(*) AS c
46
+ FROM ${rt}
47
47
  GROUP BY 1
48
48
  ORDER BY c DESC
49
- LIMIT ${ep}
49
+ LIMIT ${op}
50
50
  ),
51
51
  yf AS (
52
52
  SELECT ${m} AS y, COUNT(*) AS c
53
- FROM ${at}
53
+ FROM ${rt}
54
54
  GROUP BY 1
55
55
  ORDER BY c DESC
56
- LIMIT ${np}
56
+ LIMIT ${lp}
57
57
  ),
58
58
  filtered AS (
59
59
  SELECT src.*
60
- FROM ${at} AS src
61
- JOIN xf ON src.${ct} = xf.x -- <-- src."org.ident"
60
+ FROM ${rt} AS src
61
+ JOIN xf ON src.${ot} = xf.x -- <-- src."org.ident"
62
62
  ),
63
63
  labeled AS (
64
64
  SELECT
65
- ${ct} AS x,
65
+ ${ot} AS x,
66
66
  CASE
67
67
  WHEN ${m} IN (SELECT y FROM yf) THEN COALESCE(${m}, '(missing)')
68
- ELSE '${rp}'
68
+ ELSE '${cp}'
69
69
  END AS y
70
70
  FROM filtered
71
71
  ),
@@ -85,17 +85,17 @@
85
85
  JOIN denom d USING (x)
86
86
  )
87
87
  SELECT * FROM props ORDER BY x, y;
88
- `,h=await r.executeQuery(F,i.value);if(!h.length){u.value="No rows returned. Try different columns.",n.purge(T);return}const L=Array.from(new Set(h.map(st=>String(st.x)))),$=Array.from(new Set(h.map(st=>String(st.y)))),D=(st,qt)=>`${st}\0${qt}`,z=new Map;for(const st of h)z.set(D(String(st.x),String(st.y)),Number(st.p??0));const Z=$.map(st=>({type:"bar",name:st,x:L,y:L.map(qt=>z.get(D(qt,st))??0),hovertemplate:`${E.value}=%{fullData.name}<br>${p.value}=%{x}<br>Proportion=%{y:.1%}<extra></extra>`})),_t={title:`${E.value} proportions within ${p.value}`,barmode:"stack",yaxis:{range:[0,1],tickformat:".0%",title:"Proportion"},xaxis:{title:p.value},legend:{orientation:"h",y:-.2},margin:{t:48,r:16,b:96,l:56}};await n.newPlot(T,Z,_t,{responsive:!0});const wt=(L.length>=ep?` Limited to top ${ep} ${p.value}.`:"")+($.length>=np||$.includes(rp)?` Limited to top ${np} ${E.value} (+ ${rp}).`:"");u.value=`Plotted ${$.length} categories across ${L.length} groups.${wt}`}catch(at){console.error(at),u.value=`Error: ${(at==null?void 0:at.message)||at}`}finally{l.value=!1}}}async function $t(){}async function yn(at,ct){var m,F;const h=await $t(),L=`${ct}/packages/${at}/view?api_key=${h}`,$=await fetch(L);if(!$.ok)return null;const D=await $.json();return(F=(m=D==null?void 0:D[0])==null?void 0:m.content)==null?void 0:F.id}async function Ge(at,ct,m){const F=await $t(),h=`${m}/packages/${at}/files/${ct}?api_key=${F}`,L=await fetch(h);if(!L.ok)throw new Error(`file url failed: ${L.status}`);return(await L.json()).url}function ce(){return typeof window<"u"&&typeof document<"u"}async function Qt(){return ce()?n||(await new Promise((at,ct)=>{const m=document.createElement("script");m.src="https://cdn.plot.ly/plotly-2.35.3.min.js",m.onload=()=>at(),m.onerror=()=>ct(new Error("Failed to load Plotly CDN")),document.head.appendChild(m)}),n=window.Plotly,console.log(n),n):null}return c.onMounted(async()=>{await X(),await Qt()}),c.onBeforeUnmount(async()=>{i.value&&await r.closeConnection(i.value)}),(at,ct)=>(c.openBlock(),c.createElementBlock("div",eR,[c.createElementVNode("div",nR,[c.createElementVNode("div",rR,[c.createElementVNode("div",iR,[ct[3]||(ct[3]=c.createElementVNode("label",null,"Data URL",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":ct[0]||(ct[0]=m=>a.value=m),type:"text",class:"pp-input pp-input--url",disabled:l.value,placeholder:"https://.../file.parquet"},null,8,sR),[[c.vModelText,a.value]])]),c.createElementVNode("div",aR,[c.createElementVNode("div",null,[ct[5]||(ct[5]=c.createElementVNode("label",null,"X (group) column",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":ct[1]||(ct[1]=m=>p.value=m),class:"pp-select",disabled:l.value||f.value.length===0},[ct[4]||(ct[4]=c.createElementVNode("option",{disabled:"",value:""},"— choose —",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(J.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name,value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,lR))),128)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(lt.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name+"-num",value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,cR))),128))],8,oR),[[c.vModelSelect,p.value]])]),c.createElementVNode("div",null,[ct[7]||(ct[7]=c.createElementVNode("label",null,"Y (category) column",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":ct[2]||(ct[2]=m=>E.value=m),class:"pp-select",disabled:l.value||f.value.length===0},[ct[6]||(ct[6]=c.createElementVNode("option",{disabled:"",value:""},"— choose —",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(J.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name+"-y",value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,dR))),128))],8,uR),[[c.vModelSelect,E.value]])])]),c.createElementVNode("div",fR,[c.createElementVNode("button",{class:"pp-btn pp-btn--primary",disabled:!p.value||!E.value||l.value||!i.value||!s.value,onClick:le},c.toDisplayString(l.value?"Working…":"Plot"),9,hR),u.value?(c.openBlock(),c.createElementBlock("div",pR,c.toDisplayString(u.value),1)):c.createCommentVNode("",!0)])])]),c.createElementVNode("div",{id:T,class:"pp-plot"})]))}}),yR=Lo(mR,[["__scopeId","data-v-1e3cf8a1"]]),gR="dashboard:globalVars";function ac(e=!1){const t=c.inject(gR,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const _R={class:"data-explorer-wrap"},vR={class:"data-explorer-info"},bR=c.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=ac(),n=c.ref("Data Explorer"),r=c.computed(()=>c.unref(t.s3Url));return c.watchEffect(()=>{}),(i,s)=>{const a=c.resolveComponent("el-icon");return c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),c.createElementVNode("div",_R,[c.createElementVNode("div",vR,[c.createVNode(c.unref(PI.ElTooltip),{placement:"top-start"},{content:c.withCtx(()=>[...s[0]||(s[0]=[c.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:c.withCtx(()=>[c.createVNode(a,{color:"#8300BF"},{default:c.withCtx(()=>[c.createVNode(c.unref(VI))]),_:1})]),_:1})]),c.createVNode(c.unref(hT),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),so=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},wR=so(bR,[["__scopeId","data-v-e47a9f7d"]]),SR={class:"umap-wrap"},ER=so(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=ac(),n=c.ref("Data Explorer"),r=c.computed(()=>c.unref(t==null?void 0:t.s3Url));return(i,s)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),c.createElementVNode("div",SR,[c.createVNode(c.unref(tR),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-d8a1dc37"]]),IR={class:"proportion-plot-wrap"},TR=so(c.defineComponent({inheritAttrs:!1,__name:"Proportion",setup(e){const t=ac(),n=c.computed(()=>c.unref(t.s3Url));return(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",IR,[c.createVNode(c.unref(yR),{srcUrl:n.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-96c1c44d"]]),g_=Ag.defineStore("precisionGlobalVars",()=>{const e=c.ref(null),t=c.ref(null),n=c.ref(null),r=c.ref(null);function i(u){e.value=u===""?null:u}function s(u){t.value=u===""?null:u}function a(u){n.value=u===""?null:u}function o(u){r.value=u===""?null:u}function l(u,f){switch(u){case"selectedGene":i(f);break;case"selectedMetadataColumn":s(f);break;case"selectedGene1":a(f);break;case"selectedGene2":o(f);break;default:console.warn(`Unknown selection key: ${u}`)}}return{selectedGene:e,selectedMetadataColumn:t,selectedGene1:n,selectedGene2:r,setSelectedGene:i,setSelectedMetadataColumn:s,setSelectedGene1:a,setSelectedGene2:o,setSelection:l}});function Pu(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function AR(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function __(e){let t,n,r;e.length!==2?(t=Pu,n=(o,l)=>Pu(e(o),l),r=(o,l)=>e(o)-l):(t=e===Pu||e===AR?e:xR,n=e,r=e);function i(o,l,u=0,f=o.length){if(u<f){if(t(l,l)!==0)return f;do{const p=u+f>>>1;n(o[p],l)<0?u=p+1:f=p}while(u<f)}return u}function s(o,l,u=0,f=o.length){if(u<f){if(t(l,l)!==0)return f;do{const p=u+f>>>1;n(o[p],l)<=0?u=p+1:f=p}while(u<f)}return u}function a(o,l,u=0,f=o.length){const p=i(o,l,u,f-1);return p>u&&r(o[p-1],l)>-r(o[p],l)?p-1:p}return{left:i,center:a,right:s}}function xR(){return 0}function RR(e){return e===null?NaN:+e}const NR=__(Pu).right;__(RR).center;function Ra(e,t){let n,r;if(t===void 0)for(const i of e)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let s of e)(s=t(s,++i,e))!=null&&(n===void 0?s>=s&&(n=r=s):(n>s&&(n=s),r<s&&(r=s)))}return[n,r]}class v_ extends Map{constructor(t,n=DR){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(b_(this,t))}has(t){return super.has(b_(this,t))}set(t,n){return super.set(BR(this,t),n)}delete(t){return super.delete(OR(this,t))}}function b_({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function BR({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function OR({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function DR(e){return e!==null&&typeof e=="object"?e.valueOf():e}const FR=Math.sqrt(50),LR=Math.sqrt(10),MR=Math.sqrt(2);function $u(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=FR?10:s>=LR?5:s>=MR?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(e*u),l=Math.round(t*u),o/u<e&&++o,l/u>t&&--l,u=-u):(u=Math.pow(10,i)*a,o=Math.round(e/u),l=Math.round(t/u),o*u<e&&++o,l*u>t&&--l),l<o&&.5<=n&&n<2?$u(e,t,n*2):[o,l,u]}function CR(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[i,s,a]=r?$u(t,e,n):$u(e,t,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let u=0;u<o;++u)l[u]=(s-u)/-a;else for(let u=0;u<o;++u)l[u]=(s-u)*a;else if(a<0)for(let u=0;u<o;++u)l[u]=(i+u)/-a;else for(let u=0;u<o;++u)l[u]=(i+u)*a;return l}function ip(e,t,n){return t=+t,e=+e,n=+n,$u(e,t,n)[2]}function kR(e,t,n){t=+t,e=+e,n=+n;const r=t<e,i=r?ip(t,e,n):ip(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}var UR={value:()=>{}};function sp(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Vu(n)}function Vu(e){this._=e}function PR(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Vu.prototype=sp.prototype={constructor:Vu,on:function(e,t){var n=this._,r=PR(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=$R(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=w_(n[i],e.name,t);else if(t==null)for(i in n)n[i]=w_(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Vu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function $R(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function w_(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=UR,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ap="http://www.w3.org/1999/xhtml";const S_={svg:"http://www.w3.org/2000/svg",xhtml:ap,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zu(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),S_.hasOwnProperty(t)?{space:S_[t],local:e}:e}function VR(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ap&&t.documentElement.namespaceURI===ap?t.createElement(e):t.createElementNS(n,e)}}function zR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function E_(e){var t=zu(e);return(t.local?zR:VR)(t)}function GR(){}function op(e){return e==null?GR:function(){return this.querySelector(e)}}function jR(e){typeof e!="function"&&(e=op(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,f=0;f<a;++f)(l=s[f])&&(u=e.call(l,l.__data__,f,s))&&("__data__"in l&&(u.__data__=l.__data__),o[f]=u);return new Ai(r,this._parents)}function YR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function WR(){return[]}function I_(e){return e==null?WR:function(){return this.querySelectorAll(e)}}function HR(e){return function(){return YR(e.apply(this,arguments))}}function qR(e){typeof e=="function"?e=HR(e):e=I_(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new Ai(r,i)}function T_(e){return function(){return this.matches(e)}}function A_(e){return function(t){return t.matches(e)}}var XR=Array.prototype.find;function KR(e){return function(){return XR.call(this.children,e)}}function QR(){return this.firstElementChild}function JR(e){return this.select(e==null?QR:KR(typeof e=="function"?e:A_(e)))}var ZR=Array.prototype.filter;function tN(){return Array.from(this.children)}function eN(e){return function(){return ZR.call(this.children,e)}}function nN(e){return this.selectAll(e==null?tN:eN(typeof e=="function"?e:A_(e)))}function rN(e){typeof e!="function"&&(e=T_(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Ai(r,this._parents)}function x_(e){return new Array(e.length)}function iN(){return new Ai(this._enter||this._groups.map(x_),this._parents)}function Gu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Gu.prototype={constructor:Gu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function sN(e){return function(){return e}}function aN(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new Gu(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function oN(e,t,n,r,i,s,a){var o,l,u=new Map,f=t.length,p=s.length,E=new Array(f),T;for(o=0;o<f;++o)(l=t[o])&&(E[o]=T=a.call(l,l.__data__,o,t)+"",u.has(T)?i[o]=l:u.set(T,l));for(o=0;o<p;++o)T=a.call(e,s[o],o,s)+"",(l=u.get(T))?(r[o]=l,l.__data__=s[o],u.delete(T)):n[o]=new Gu(e,s[o]);for(o=0;o<f;++o)(l=t[o])&&u.get(E[o])===l&&(i[o]=l)}function lN(e){return e.__data__}function cN(e,t){if(!arguments.length)return Array.from(this,lN);var n=t?oN:aN,r=this._parents,i=this._groups;typeof e!="function"&&(e=sN(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var f=r[u],p=i[u],E=p.length,T=uN(e.call(f,f&&f.__data__,u,r)),U=T.length,J=o[u]=new Array(U),lt=a[u]=new Array(U),X=l[u]=new Array(E);n(f,p,J,lt,X,T,t);for(var Kt=0,Jt=0,ue,Wt;Kt<U;++Kt)if(ue=J[Kt]){for(Kt>=Jt&&(Jt=Kt+1);!(Wt=lt[Jt])&&++Jt<U;);ue._next=Wt||null}}return a=new Ai(a,r),a._enter=o,a._exit=l,a}function uN(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function dN(){return new Ai(this._exit||this._groups.map(x_),this._parents)}function fN(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function hN(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],f=r[l],p=u.length,E=o[l]=new Array(p),T,U=0;U<p;++U)(T=u[U]||f[U])&&(E[U]=T);for(;l<i;++l)o[l]=n[l];return new Ai(o,this._parents)}function pN(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function mN(e){e||(e=yN);function t(p,E){return p&&E?e(p.__data__,E.__data__):!p-!E}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,f=0;f<o;++f)(u=a[f])&&(l[f]=u);l.sort(t)}return new Ai(i,this._parents).order()}function yN(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function gN(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function _N(){return Array.from(this)}function vN(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function bN(){let e=0;for(const t of this)++e;return e}function wN(){return!this.node()}function SN(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function EN(e){return function(){this.removeAttribute(e)}}function IN(e){return function(){this.removeAttributeNS(e.space,e.local)}}function TN(e,t){return function(){this.setAttribute(e,t)}}function AN(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function xN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function RN(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function NN(e,t){var n=zu(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?IN:EN:typeof t=="function"?n.local?RN:xN:n.local?AN:TN)(n,t))}function R_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function BN(e){return function(){this.style.removeProperty(e)}}function ON(e,t,n){return function(){this.style.setProperty(e,t,n)}}function DN(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function FN(e,t,n){return arguments.length>1?this.each((t==null?BN:typeof t=="function"?DN:ON)(e,t,n??"")):Uo(this.node(),e)}function Uo(e,t){return e.style.getPropertyValue(t)||R_(e).getComputedStyle(e,null).getPropertyValue(t)}function LN(e){return function(){delete this[e]}}function MN(e,t){return function(){this[e]=t}}function CN(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function kN(e,t){return arguments.length>1?this.each((t==null?LN:typeof t=="function"?CN:MN)(e,t)):this.node()[e]}function N_(e){return e.trim().split(/^|\s+/)}function lp(e){return e.classList||new B_(e)}function B_(e){this._node=e,this._names=N_(e.getAttribute("class")||"")}B_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function O_(e,t){for(var n=lp(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function D_(e,t){for(var n=lp(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function UN(e){return function(){O_(this,e)}}function PN(e){return function(){D_(this,e)}}function $N(e,t){return function(){(t.apply(this,arguments)?O_:D_)(this,e)}}function VN(e,t){var n=N_(e+"");if(arguments.length<2){for(var r=lp(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?$N:t?UN:PN)(n,t))}function zN(){this.textContent=""}function GN(e){return function(){this.textContent=e}}function jN(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function YN(e){return arguments.length?this.each(e==null?zN:(typeof e=="function"?jN:GN)(e)):this.node().textContent}function WN(){this.innerHTML=""}function HN(e){return function(){this.innerHTML=e}}function qN(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function XN(e){return arguments.length?this.each(e==null?WN:(typeof e=="function"?qN:HN)(e)):this.node().innerHTML}function KN(){this.nextSibling&&this.parentNode.appendChild(this)}function QN(){return this.each(KN)}function JN(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ZN(){return this.each(JN)}function tB(e){var t=typeof e=="function"?e:E_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function eB(){return null}function nB(e,t){var n=typeof e=="function"?e:E_(e),r=t==null?eB:typeof t=="function"?t:op(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function rB(){var e=this.parentNode;e&&e.removeChild(this)}function iB(){return this.each(rB)}function sB(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function aB(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function oB(e){return this.select(e?aB:sB)}function lB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function cB(e){return function(t){e.call(this,t,this.__data__)}}function uB(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function dB(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function fB(e,t,n){return function(){var r=this.__on,i,s=cB(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function hB(e,t,n){var r=uB(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,f;l<u;++l)for(i=0,f=o[l];i<s;++i)if((a=r[i]).type===f.type&&a.name===f.name)return f.value}return}for(o=t?fB:dB,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function F_(e,t,n){var r=R_(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function pB(e,t){return function(){return F_(this,e,t)}}function mB(e,t){return function(){return F_(this,e,t.apply(this,arguments))}}function yB(e,t){return this.each((typeof t=="function"?mB:pB)(e,t))}function*gB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var L_=[null];function Ai(e,t){this._groups=e,this._parents=t}function oc(){return new Ai([[document.documentElement]],L_)}function _B(){return this}Ai.prototype=oc.prototype={constructor:Ai,select:jR,selectAll:qR,selectChild:JR,selectChildren:nN,filter:rN,data:cN,enter:iN,exit:dN,join:fN,merge:hN,selection:_B,order:pN,sort:mN,call:gN,nodes:_N,node:vN,size:bN,empty:wN,each:SN,attr:NN,style:FN,property:kN,classed:VN,text:YN,html:XN,raise:QN,lower:ZN,append:tB,insert:nB,remove:iB,clone:oB,datum:lB,on:hB,dispatch:yB,[Symbol.iterator]:gB};function Gr(e){return typeof e=="string"?new Ai([[document.querySelector(e)]],[document.documentElement]):new Ai([[e]],L_)}function vB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ao(e,t){if(e=vB(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const cp={capture:!0,passive:!1};function up(e){e.preventDefault(),e.stopImmediatePropagation()}function bB(e){var t=e.document.documentElement,n=Gr(e).on("dragstart.drag",up,cp);"onselectstart"in t?n.on("selectstart.drag",up,cp):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function wB(e,t){var n=e.document.documentElement,r=Gr(e).on("dragstart.drag",null);t&&(r.on("click.drag",up,cp),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function dp(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function M_(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function lc(){}var cc=.7,ju=1/cc,Po="\\s*([+-]?\\d+)\\s*",uc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",bs="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",SB=/^#([0-9a-f]{3,8})$/,EB=new RegExp(`^rgb\\(${Po},${Po},${Po}\\)$`),IB=new RegExp(`^rgb\\(${bs},${bs},${bs}\\)$`),TB=new RegExp(`^rgba\\(${Po},${Po},${Po},${uc}\\)$`),AB=new RegExp(`^rgba\\(${bs},${bs},${bs},${uc}\\)$`),xB=new RegExp(`^hsl\\(${uc},${bs},${bs}\\)$`),RB=new RegExp(`^hsla\\(${uc},${bs},${bs},${uc}\\)$`),C_={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};dp(lc,rs,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:k_,formatHex:k_,formatHex8:NB,formatHsl:BB,formatRgb:U_,toString:U_});function k_(){return this.rgb().formatHex()}function NB(){return this.rgb().formatHex8()}function BB(){return G_(this).formatHsl()}function U_(){return this.rgb().formatRgb()}function rs(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=SB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?P_(t):n===3?new fi(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Yu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Yu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=EB.exec(e))?new fi(t[1],t[2],t[3],1):(t=IB.exec(e))?new fi(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=TB.exec(e))?Yu(t[1],t[2],t[3],t[4]):(t=AB.exec(e))?Yu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=xB.exec(e))?z_(t[1],t[2]/100,t[3]/100,1):(t=RB.exec(e))?z_(t[1],t[2]/100,t[3]/100,t[4]):C_.hasOwnProperty(e)?P_(C_[e]):e==="transparent"?new fi(NaN,NaN,NaN,0):null}function P_(e){return new fi(e>>16&255,e>>8&255,e&255,1)}function Yu(e,t,n,r){return r<=0&&(e=t=n=NaN),new fi(e,t,n,r)}function OB(e){return e instanceof lc||(e=rs(e)),e?(e=e.rgb(),new fi(e.r,e.g,e.b,e.opacity)):new fi}function fp(e,t,n,r){return arguments.length===1?OB(e):new fi(e,t,n,r??1)}function fi(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}dp(fi,fp,M_(lc,{brighter(e){return e=e==null?ju:Math.pow(ju,e),new fi(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?cc:Math.pow(cc,e),new fi(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new fi(oo(this.r),oo(this.g),oo(this.b),Wu(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$_,formatHex:$_,formatHex8:DB,formatRgb:V_,toString:V_}));function $_(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}`}function DB(){return`#${lo(this.r)}${lo(this.g)}${lo(this.b)}${lo((isNaN(this.opacity)?1:this.opacity)*255)}`}function V_(){const e=Wu(this.opacity);return`${e===1?"rgb(":"rgba("}${oo(this.r)}, ${oo(this.g)}, ${oo(this.b)}${e===1?")":`, ${e})`}`}function Wu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function oo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function lo(e){return e=oo(e),(e<16?"0":"")+e.toString(16)}function z_(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new is(e,t,n,r)}function G_(e){if(e instanceof is)return new is(e.h,e.s,e.l,e.opacity);if(e instanceof lc||(e=rs(e)),!e)return new is;if(e instanceof is)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new is(a,o,l,e.opacity)}function FB(e,t,n,r){return arguments.length===1?G_(e):new is(e,t,n,r??1)}function is(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}dp(is,FB,M_(lc,{brighter(e){return e=e==null?ju:Math.pow(ju,e),new is(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?cc:Math.pow(cc,e),new is(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new fi(hp(e>=240?e-240:e+120,i,r),hp(e,i,r),hp(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new is(j_(this.h),Hu(this.s),Hu(this.l),Wu(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Wu(this.opacity);return`${e===1?"hsl(":"hsla("}${j_(this.h)}, ${Hu(this.s)*100}%, ${Hu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function j_(e){return e=(e||0)%360,e<0?e+360:e}function Hu(e){return Math.max(0,Math.min(1,e||0))}function hp(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const pp=e=>()=>e;function LB(e,t){return function(n){return e+n*t}}function MB(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function CB(e){return(e=+e)==1?Y_:function(t,n){return n-t?MB(t,n,e):pp(isNaN(t)?n:t)}}function Y_(e,t){var n=t-e;return n?LB(e,n):pp(isNaN(e)?t:e)}const qu=(function e(t){var n=CB(t);function r(i,s){var a=n((i=fp(i)).r,(s=fp(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=Y_(i.opacity,s.opacity);return function(f){return i.r=a(f),i.g=o(f),i.b=l(f),i.opacity=u(f),i+""}}return r.gamma=e,r})(1);function kB(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=e[i]*(1-s)+t[i]*s;return r}}function UB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function PB(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=gp(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function $B(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ss(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function VB(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=gp(e[i],t[i]):r[i]=t[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var mp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,yp=new RegExp(mp.source,"g");function zB(e){return function(){return e}}function GB(e){return function(t){return e(t)+""}}function W_(e,t){var n=mp.lastIndex=yp.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=mp.exec(e))&&(i=yp.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:ss(r,i)})),n=yp.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?GB(l[0].x):zB(t):(t=l.length,function(u){for(var f=0,p;f<t;++f)o[(p=l[f]).i]=p.x(u);return o.join("")})}function gp(e,t){var n=typeof t,r;return t==null||n==="boolean"?pp(t):(n==="number"?ss:n==="string"?(r=rs(t))?(t=r,qu):W_:t instanceof rs?qu:t instanceof Date?$B:UB(t)?kB:Array.isArray(t)?PB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?VB:ss)(e,t)}function jB(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var H_=180/Math.PI,_p={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function q_(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*H_,skewX:Math.atan(l)*H_,scaleX:a,scaleY:o}}var Xu;function YB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?_p:q_(t.a,t.b,t.c,t.d,t.e,t.f)}function WB(e){return e==null||(Xu||(Xu=document.createElementNS("http://www.w3.org/2000/svg","g")),Xu.setAttribute("transform",e),!(e=Xu.transform.baseVal.consolidate()))?_p:(e=e.matrix,q_(e.a,e.b,e.c,e.d,e.e,e.f))}function X_(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,f,p,E,T,U){if(u!==p||f!==E){var J=T.push("translate(",null,t,null,n);U.push({i:J-4,x:ss(u,p)},{i:J-2,x:ss(f,E)})}else(p||E)&&T.push("translate("+p+t+E+n)}function a(u,f,p,E){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),E.push({i:p.push(i(p)+"rotate(",null,r)-2,x:ss(u,f)})):f&&p.push(i(p)+"rotate("+f+r)}function o(u,f,p,E){u!==f?E.push({i:p.push(i(p)+"skewX(",null,r)-2,x:ss(u,f)}):f&&p.push(i(p)+"skewX("+f+r)}function l(u,f,p,E,T,U){if(u!==p||f!==E){var J=T.push(i(T)+"scale(",null,",",null,")");U.push({i:J-4,x:ss(u,p)},{i:J-2,x:ss(f,E)})}else(p!==1||E!==1)&&T.push(i(T)+"scale("+p+","+E+")")}return function(u,f){var p=[],E=[];return u=e(u),f=e(f),s(u.translateX,u.translateY,f.translateX,f.translateY,p,E),a(u.rotate,f.rotate,p,E),o(u.skewX,f.skewX,p,E),l(u.scaleX,u.scaleY,f.scaleX,f.scaleY,p,E),u=f=null,function(T){for(var U=-1,J=E.length,lt;++U<J;)p[(lt=E[U]).i]=lt.x(T);return p.join("")}}}var HB=X_(YB,"px, ","px)","deg)"),qB=X_(WB,", ",")",")"),XB=1e-12;function K_(e){return((e=Math.exp(e))+1/e)/2}function KB(e){return((e=Math.exp(e))-1/e)/2}function QB(e){return((e=Math.exp(2*e))-1)/(e+1)}const JB=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],f=a[0],p=a[1],E=a[2],T=f-o,U=p-l,J=T*T+U*U,lt,X;if(J<XB)X=Math.log(E/u)/t,lt=function($t){return[o+$t*T,l+$t*U,u*Math.exp(t*$t*X)]};else{var Kt=Math.sqrt(J),Jt=(E*E-u*u+r*J)/(2*u*n*Kt),ue=(E*E-u*u-r*J)/(2*E*n*Kt),Wt=Math.log(Math.sqrt(Jt*Jt+1)-Jt),le=Math.log(Math.sqrt(ue*ue+1)-ue);X=(le-Wt)/t,lt=function($t){var yn=$t*X,Ge=K_(Wt),ce=u/(n*Kt)*(Ge*QB(t*yn+Wt)-KB(Wt));return[o+ce*T,l+ce*U,u*Ge/K_(t*yn+Wt)]}}return lt.duration=X*1e3*t/Math.SQRT2,lt}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);var $o=0,dc=0,fc=0,Q_=1e3,Ku,hc,Qu=0,co=0,Ju=0,pc=typeof performance=="object"&&performance.now?performance:Date,J_=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function vp(){return co||(J_(ZB),co=pc.now()+Ju)}function ZB(){co=0}function Zu(){this._call=this._time=this._next=null}Zu.prototype=Z_.prototype={constructor:Zu,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?vp():+n)+(t==null?0:+t),!this._next&&hc!==this&&(hc?hc._next=this:Ku=this,hc=this),this._call=e,this._time=n,bp()},stop:function(){this._call&&(this._call=null,this._time=1/0,bp())}};function Z_(e,t,n){var r=new Zu;return r.restart(e,t,n),r}function tO(){vp(),++$o;for(var e=Ku,t;e;)(t=co-e._time)>=0&&e._call.call(void 0,t),e=e._next;--$o}function tv(){co=(Qu=pc.now())+Ju,$o=dc=0;try{tO()}finally{$o=0,nO(),co=0}}function eO(){var e=pc.now(),t=e-Qu;t>Q_&&(Ju-=t,Qu=e)}function nO(){for(var e,t=Ku,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Ku=n);hc=e,bp(r)}function bp(e){if(!$o){dc&&(dc=clearTimeout(dc));var t=e-co;t>24?(e<1/0&&(dc=setTimeout(tv,e-pc.now()-Ju)),fc&&(fc=clearInterval(fc))):(fc||(Qu=pc.now(),fc=setInterval(eO,Q_)),$o=1,J_(tv))}}function ev(e,t,n){var r=new Zu;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var rO=sp("start","end","cancel","interrupt"),iO=[],nv=0,rv=1,wp=2,td=3,iv=4,Sp=5,ed=6;function nd(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;sO(e,n,{name:t,index:r,group:i,on:rO,tween:iO,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:nv})}function Ep(e,t){var n=as(e,t);if(n.state>nv)throw new Error("too late; already scheduled");return n}function ws(e,t){var n=as(e,t);if(n.state>td)throw new Error("too late; already running");return n}function as(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function sO(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Z_(s,0,n.time);function s(u){n.state=rv,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,p,E,T;if(n.state!==rv)return l();for(f in r)if(T=r[f],T.name===n.name){if(T.state===td)return ev(a);T.state===iv?(T.state=ed,T.timer.stop(),T.on.call("interrupt",e,e.__data__,T.index,T.group),delete r[f]):+f<t&&(T.state=ed,T.timer.stop(),T.on.call("cancel",e,e.__data__,T.index,T.group),delete r[f])}if(ev(function(){n.state===td&&(n.state=iv,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=wp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===wp){for(n.state=td,i=new Array(E=n.tween.length),f=0,p=-1;f<E;++f)(T=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(i[++p]=T);i.length=p+1}}function o(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=Sp,1),p=-1,E=i.length;++p<E;)i[p].call(e,f);n.state===Sp&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=ed,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function rd(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>wp&&r.state<Sp,r.state=ed,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function aO(e){return this.each(function(){rd(this,e)})}function oO(e,t){var n,r;return function(){var i=ws(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function lO(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ws(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function cO(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=as(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?oO:lO)(n,e,t))}function Ip(e,t,n){var r=e._id;return e.each(function(){var i=ws(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return as(i,r).value[t]}}function sv(e,t){var n;return(typeof t=="number"?ss:t instanceof rs?qu:(n=rs(t))?(t=n,qu):W_)(e,t)}function uO(e){return function(){this.removeAttribute(e)}}function dO(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fO(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function hO(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function pO(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function mO(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function yO(e,t){var n=zu(e),r=n==="transform"?qB:sv;return this.attrTween(e,typeof t=="function"?(n.local?mO:pO)(n,r,Ip(this,"attr."+e,t)):t==null?(n.local?dO:uO)(n):(n.local?hO:fO)(n,r,t))}function gO(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function _O(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function vO(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&_O(e,s)),n}return i._value=t,i}function bO(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&gO(e,s)),n}return i._value=t,i}function wO(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=zu(e);return this.tween(n,(r.local?vO:bO)(r,t))}function SO(e,t){return function(){Ep(this,e).delay=+t.apply(this,arguments)}}function EO(e,t){return t=+t,function(){Ep(this,e).delay=t}}function IO(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?SO:EO)(t,e)):as(this.node(),t).delay}function TO(e,t){return function(){ws(this,e).duration=+t.apply(this,arguments)}}function AO(e,t){return t=+t,function(){ws(this,e).duration=t}}function xO(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?TO:AO)(t,e)):as(this.node(),t).duration}function RO(e,t){if(typeof t!="function")throw new Error;return function(){ws(this,e).ease=t}}function NO(e){var t=this._id;return arguments.length?this.each(RO(t,e)):as(this.node(),t).ease}function BO(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ws(this,e).ease=n}}function OO(e){if(typeof e!="function")throw new Error;return this.each(BO(this._id,e))}function DO(e){typeof e!="function"&&(e=T_(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Zs(r,this._parents,this._name,this._id)}function FO(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],f=l.length,p=a[o]=new Array(f),E,T=0;T<f;++T)(E=l[T]||u[T])&&(p[T]=E);for(;o<r;++o)a[o]=t[o];return new Zs(a,this._parents,this._name,this._id)}function LO(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function MO(e,t,n){var r,i,s=LO(t)?Ep:ws;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function CO(e,t){var n=this._id;return arguments.length<2?as(this.node(),n).on.on(e):this.each(MO(n,e,t))}function kO(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function UO(){return this.on("end.remove",kO(this._id))}function PO(e){var t=this._name,n=this._id;typeof e!="function"&&(e=op(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),f,p,E=0;E<l;++E)(f=o[E])&&(p=e.call(f,f.__data__,E,o))&&("__data__"in f&&(p.__data__=f.__data__),u[E]=p,nd(u[E],t,n,E,u,as(f,n)));return new Zs(s,this._parents,t,n)}function $O(e){var t=this._name,n=this._id;typeof e!="function"&&(e=I_(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,f,p=0;p<u;++p)if(f=l[p]){for(var E=e.call(f,f.__data__,p,l),T,U=as(f,n),J=0,lt=E.length;J<lt;++J)(T=E[J])&&nd(T,t,n,J,E,U);s.push(E),a.push(f)}return new Zs(s,a,t,n)}var VO=oc.prototype.constructor;function zO(){return new VO(this._groups,this._parents)}function GO(e,t){var n,r,i;return function(){var s=Uo(this,e),a=(this.style.removeProperty(e),Uo(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function av(e){return function(){this.style.removeProperty(e)}}function jO(e,t,n){var r,i=n+"",s;return function(){var a=Uo(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function YO(e,t,n){var r,i,s;return function(){var a=Uo(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Uo(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function WO(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=ws(this,e),u=l.on,f=l.value[s]==null?o||(o=av(t)):void 0;(u!==n||i!==f)&&(r=(n=u).copy()).on(a,i=f),l.on=r}}function HO(e,t,n){var r=(e+="")=="transform"?HB:sv;return t==null?this.styleTween(e,GO(e,r)).on("end.style."+e,av(e)):typeof t=="function"?this.styleTween(e,YO(e,r,Ip(this,"style."+e,t))).each(WO(this._id,e)):this.styleTween(e,jO(e,r,t),n).on("end.style."+e,null)}function qO(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function XO(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&qO(e,a,n)),r}return s._value=t,s}function KO(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,XO(e,t,n??""))}function QO(e){return function(){this.textContent=e}}function JO(e){return function(){var t=e(this);this.textContent=t??""}}function ZO(e){return this.tween("text",typeof e=="function"?JO(Ip(this,"text",e)):QO(e==null?"":e+""))}function tD(e){return function(t){this.textContent=e.call(this,t)}}function eD(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&tD(i)),t}return r._value=e,r}function nD(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,eD(e))}function rD(){for(var e=this._name,t=this._id,n=ov(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var f=as(l,t);nd(l,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Zs(r,this._parents,e,n)}function iD(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=ws(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var sD=0;function Zs(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ov(){return++sD}var ta=oc.prototype;Zs.prototype={constructor:Zs,select:PO,selectAll:$O,selectChild:ta.selectChild,selectChildren:ta.selectChildren,filter:DO,merge:FO,selection:zO,transition:rD,call:ta.call,nodes:ta.nodes,node:ta.node,size:ta.size,empty:ta.empty,each:ta.each,on:CO,attr:yO,attrTween:wO,style:HO,styleTween:KO,text:ZO,textTween:nD,remove:UO,tween:cO,delay:IO,duration:xO,ease:NO,easeVarying:OO,end:iD,[Symbol.iterator]:ta[Symbol.iterator]};function aD(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var oD={time:null,delay:0,duration:250,ease:aD};function lD(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function cD(e){var t,n;e instanceof Zs?(t=e._id,e=e._name):(t=ov(),(n=oD).time=vp(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&nd(l,e,t,u,a,n||lD(l,t));return new Zs(r,this._parents,e,t)}oc.prototype.interrupt=aO,oc.prototype.transition=cD;function uD(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function id(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Vo(e){return e=id(Math.abs(e)),e?e[1]:NaN}function dD(e,t){return function(n,r){for(var i=n.length,s=[],a=0,o=e[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=e[a=(a+1)%e.length];return s.reverse().join(t)}}function fD(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var hD=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sd(e){if(!(t=hD.exec(e)))throw new Error("invalid format: "+e);var t;return new Tp({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}sd.prototype=Tp.prototype;function Tp(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}Tp.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function pD(e){t:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+e[n])break t;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var lv;function mD(e,t){var n=id(e,t);if(!n)return e+"";var r=n[0],i=n[1],s=i-(lv=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+id(e,Math.max(0,t+s-1))[0]}function cv(e,t){var n=id(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const uv={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:uD,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>cv(e*100,t),r:cv,s:mD,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function dv(e){return e}var fv=Array.prototype.map,hv=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function yD(e){var t=e.grouping===void 0||e.thousands===void 0?dv:dD(fv.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?dv:fD(fv.call(e.numerals,String)),a=e.percent===void 0?"%":e.percent+"",o=e.minus===void 0?"−":e.minus+"",l=e.nan===void 0?"NaN":e.nan+"";function u(p){p=sd(p);var E=p.fill,T=p.align,U=p.sign,J=p.symbol,lt=p.zero,X=p.width,Kt=p.comma,Jt=p.precision,ue=p.trim,Wt=p.type;Wt==="n"?(Kt=!0,Wt="g"):uv[Wt]||(Jt===void 0&&(Jt=12),ue=!0,Wt="g"),(lt||E==="0"&&T==="=")&&(lt=!0,E="0",T="=");var le=J==="$"?n:J==="#"&&/[boxX]/.test(Wt)?"0"+Wt.toLowerCase():"",$t=J==="$"?r:/[%p]/.test(Wt)?a:"",yn=uv[Wt],Ge=/[defgprs%]/.test(Wt);Jt=Jt===void 0?6:/[gprs]/.test(Wt)?Math.max(1,Math.min(21,Jt)):Math.max(0,Math.min(20,Jt));function ce(Qt){var at=le,ct=$t,m,F,h;if(Wt==="c")ct=yn(Qt)+ct,Qt="";else{Qt=+Qt;var L=Qt<0||1/Qt<0;if(Qt=isNaN(Qt)?l:yn(Math.abs(Qt),Jt),ue&&(Qt=pD(Qt)),L&&+Qt==0&&U!=="+"&&(L=!1),at=(L?U==="("?U:o:U==="-"||U==="("?"":U)+at,ct=(Wt==="s"?hv[8+lv/3]:"")+ct+(L&&U==="("?")":""),Ge){for(m=-1,F=Qt.length;++m<F;)if(h=Qt.charCodeAt(m),48>h||h>57){ct=(h===46?i+Qt.slice(m+1):Qt.slice(m))+ct,Qt=Qt.slice(0,m);break}}}Kt&&!lt&&(Qt=t(Qt,1/0));var $=at.length+Qt.length+ct.length,D=$<X?new Array(X-$+1).join(E):"";switch(Kt&&lt&&(Qt=t(D+Qt,D.length?X-ct.length:1/0),D=""),T){case"<":Qt=at+Qt+ct+D;break;case"=":Qt=at+D+Qt+ct;break;case"^":Qt=D.slice(0,$=D.length>>1)+at+Qt+ct+D.slice($);break;default:Qt=D+at+Qt+ct;break}return s(Qt)}return ce.toString=function(){return p+""},ce}function f(p,E){var T=u((p=sd(p),p.type="f",p)),U=Math.max(-8,Math.min(8,Math.floor(Vo(E)/3)))*3,J=Math.pow(10,-U),lt=hv[8+U/3];return function(X){return T(J*X)+lt}}return{format:u,formatPrefix:f}}var ad,pv,mv;gD({thousands:",",grouping:[3],currency:["$",""]});function gD(e){return ad=yD(e),pv=ad.format,mv=ad.formatPrefix,ad}function _D(e){return Math.max(0,-Vo(Math.abs(e)))}function vD(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Vo(t)/3)))*3-Vo(Math.abs(e)))}function bD(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Vo(t)-Vo(e))+1}function yv(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const gv=Symbol("implicit");function _v(){var e=new v_,t=[],n=[],r=gv;function i(s){let a=e.get(s);if(a===void 0){if(r!==gv)return r;e.set(s,a=t.push(s)-1)}return n[a%n.length]}return i.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new v_;for(const a of s)e.has(a)||e.set(a,t.push(a)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return _v(t,n).unknown(r)},yv.apply(i,arguments),i}function wD(e){return function(){return e}}function SD(e){return+e}var vv=[0,1];function zo(e){return e}function Ap(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:wD(isNaN(t)?NaN:.5)}function ED(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function ID(e,t,n){var r=e[0],i=e[1],s=t[0],a=t[1];return i<r?(r=Ap(i,r),s=n(a,s)):(r=Ap(r,i),s=n(s,a)),function(o){return s(r(o))}}function TD(e,t,n){var r=Math.min(e.length,t.length)-1,i=new Array(r),s=new Array(r),a=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++a<r;)i[a]=Ap(e[a],e[a+1]),s[a]=n(t[a],t[a+1]);return function(o){var l=NR(e,o,1,r)-1;return s[l](i[l](o))}}function AD(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function xD(){var e=vv,t=vv,n=gp,r,i,s,a=zo,o,l,u;function f(){var E=Math.min(e.length,t.length);return a!==zo&&(a=ED(e[0],e[E-1])),o=E>2?TD:ID,l=u=null,p}function p(E){return E==null||isNaN(E=+E)?s:(l||(l=o(e.map(r),t,n)))(r(a(E)))}return p.invert=function(E){return a(i((u||(u=o(t,e.map(r),ss)))(E)))},p.domain=function(E){return arguments.length?(e=Array.from(E,SD),f()):e.slice()},p.range=function(E){return arguments.length?(t=Array.from(E),f()):t.slice()},p.rangeRound=function(E){return t=Array.from(E),n=jB,f()},p.clamp=function(E){return arguments.length?(a=E?!0:zo,f()):a!==zo},p.interpolate=function(E){return arguments.length?(n=E,f()):n},p.unknown=function(E){return arguments.length?(s=E,p):s},function(E,T){return r=E,i=T,f()}}function RD(){return xD()(zo,zo)}function ND(e,t,n,r){var i=kR(e,t,n),s;switch(r=sd(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(s=vD(i,a))&&(r.precision=s),mv(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=bD(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=_D(i))&&(r.precision=s-(r.type==="%")*2);break}}return pv(r)}function BD(e){var t=e.domain;return e.ticks=function(n){var r=t();return CR(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return ND(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,s=r.length-1,a=r[i],o=r[s],l,u,f=10;for(o<a&&(u=a,a=o,o=u,u=i,i=s,s=u);f-- >0;){if(u=ip(a,o,n),u===l)return r[i]=a,r[s]=o,t(r);if(u>0)a=Math.floor(a/u)*u,o=Math.ceil(o/u)*u;else if(u<0)a=Math.ceil(a*u)/u,o=Math.floor(o*u)/u;else break;l=u}return e},e}function ea(){var e=RD();return e.copy=function(){return AD(e,ea())},yv.apply(e,arguments),BD(e)}function OD(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(r*6,++r*6);return n}const DD=OD("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),od=e=>()=>e;function FD(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function na(e,t,n){this.k=e,this.x=t,this.y=n}na.prototype={constructor:na,scale:function(e){return e===1?this:new na(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new na(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var xi=new na(1,0,0);na.prototype;function xp(e){e.stopImmediatePropagation()}function mc(e){e.preventDefault(),e.stopImmediatePropagation()}function LD(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function MD(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function bv(){return this.__zoom||xi}function CD(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function kD(){return navigator.maxTouchPoints||"ontouchstart"in this}function UD(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Rp(){var e=LD,t=MD,n=UD,r=CD,i=kD,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=JB,u=sp("start","zoom","end"),f,p,E,T=500,U=150,J=0,lt=10;function X(m){m.property("__zoom",bv).on("wheel.zoom",yn,{passive:!1}).on("mousedown.zoom",Ge).on("dblclick.zoom",ce).filter(i).on("touchstart.zoom",Qt).on("touchmove.zoom",at).on("touchend.zoom touchcancel.zoom",ct).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}X.transform=function(m,F,h,L){var $=m.selection?m.selection():m;$.property("__zoom",bv),m!==$?Wt(m,F,h,L):$.interrupt().each(function(){le(this,arguments).event(L).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},X.scaleBy=function(m,F,h,L){X.scaleTo(m,function(){var $=this.__zoom.k,D=typeof F=="function"?F.apply(this,arguments):F;return $*D},h,L)},X.scaleTo=function(m,F,h,L){X.transform(m,function(){var $=t.apply(this,arguments),D=this.__zoom,z=h==null?ue($):typeof h=="function"?h.apply(this,arguments):h,Z=D.invert(z),_t=typeof F=="function"?F.apply(this,arguments):F;return n(Jt(Kt(D,_t),z,Z),$,a)},h,L)},X.translateBy=function(m,F,h,L){X.transform(m,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof h=="function"?h.apply(this,arguments):h),t.apply(this,arguments),a)},null,L)},X.translateTo=function(m,F,h,L,$){X.transform(m,function(){var D=t.apply(this,arguments),z=this.__zoom,Z=L==null?ue(D):typeof L=="function"?L.apply(this,arguments):L;return n(xi.translate(Z[0],Z[1]).scale(z.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof h=="function"?-h.apply(this,arguments):-h),D,a)},L,$)};function Kt(m,F){return F=Math.max(s[0],Math.min(s[1],F)),F===m.k?m:new na(F,m.x,m.y)}function Jt(m,F,h){var L=F[0]-h[0]*m.k,$=F[1]-h[1]*m.k;return L===m.x&&$===m.y?m:new na(m.k,L,$)}function ue(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function Wt(m,F,h,L){m.on("start.zoom",function(){le(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){le(this,arguments).event(L).end()}).tween("zoom",function(){var $=this,D=arguments,z=le($,D).event(L),Z=t.apply($,D),_t=h==null?ue(Z):typeof h=="function"?h.apply($,D):h,wt=Math.max(Z[1][0]-Z[0][0],Z[1][1]-Z[0][1]),st=$.__zoom,qt=typeof F=="function"?F.apply($,D):F,ne=l(st.invert(_t).concat(wt/st.k),qt.invert(_t).concat(wt/qt.k));return function(Zt){if(Zt===1)Zt=qt;else{var Ye=ne(Zt),Yn=wt/Ye[2];Zt=new na(Yn,_t[0]-Ye[0]*Yn,_t[1]-Ye[1]*Yn)}z.zoom(null,Zt)}})}function le(m,F,h){return!h&&m.__zooming||new $t(m,F)}function $t(m,F){this.that=m,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,F),this.taps=0}$t.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,F){return this.mouse&&m!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var F=Gr(this.that).datum();u.call(m,this.that,new FD(m,{sourceEvent:this.sourceEvent,target:X,transform:this.that.__zoom,dispatch:u}),F)}};function yn(m,...F){if(!e.apply(this,arguments))return;var h=le(this,F).event(m),L=this.__zoom,$=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,r.apply(this,arguments)))),D=ao(m);if(h.wheel)(h.mouse[0][0]!==D[0]||h.mouse[0][1]!==D[1])&&(h.mouse[1]=L.invert(h.mouse[0]=D)),clearTimeout(h.wheel);else{if(L.k===$)return;h.mouse=[D,L.invert(D)],rd(this),h.start()}mc(m),h.wheel=setTimeout(z,U),h.zoom("mouse",n(Jt(Kt(L,$),h.mouse[0],h.mouse[1]),h.extent,a));function z(){h.wheel=null,h.end()}}function Ge(m,...F){if(E||!e.apply(this,arguments))return;var h=m.currentTarget,L=le(this,F,!0).event(m),$=Gr(m.view).on("mousemove.zoom",_t,!0).on("mouseup.zoom",wt,!0),D=ao(m,h),z=m.clientX,Z=m.clientY;bB(m.view),xp(m),L.mouse=[D,this.__zoom.invert(D)],rd(this),L.start();function _t(st){if(mc(st),!L.moved){var qt=st.clientX-z,ne=st.clientY-Z;L.moved=qt*qt+ne*ne>J}L.event(st).zoom("mouse",n(Jt(L.that.__zoom,L.mouse[0]=ao(st,h),L.mouse[1]),L.extent,a))}function wt(st){$.on("mousemove.zoom mouseup.zoom",null),wB(st.view,L.moved),mc(st),L.event(st).end()}}function ce(m,...F){if(e.apply(this,arguments)){var h=this.__zoom,L=ao(m.changedTouches?m.changedTouches[0]:m,this),$=h.invert(L),D=h.k*(m.shiftKey?.5:2),z=n(Jt(Kt(h,D),L,$),t.apply(this,F),a);mc(m),o>0?Gr(this).transition().duration(o).call(Wt,z,L,m):Gr(this).call(X.transform,z,L,m)}}function Qt(m,...F){if(e.apply(this,arguments)){var h=m.touches,L=h.length,$=le(this,F,m.changedTouches.length===L).event(m),D,z,Z,_t;for(xp(m),z=0;z<L;++z)Z=h[z],_t=ao(Z,this),_t=[_t,this.__zoom.invert(_t),Z.identifier],$.touch0?!$.touch1&&$.touch0[2]!==_t[2]&&($.touch1=_t,$.taps=0):($.touch0=_t,D=!0,$.taps=1+!!f);f&&(f=clearTimeout(f)),D&&($.taps<2&&(p=_t[0],f=setTimeout(function(){f=null},T)),rd(this),$.start())}}function at(m,...F){if(this.__zooming){var h=le(this,F).event(m),L=m.changedTouches,$=L.length,D,z,Z,_t;for(mc(m),D=0;D<$;++D)z=L[D],Z=ao(z,this),h.touch0&&h.touch0[2]===z.identifier?h.touch0[0]=Z:h.touch1&&h.touch1[2]===z.identifier&&(h.touch1[0]=Z);if(z=h.that.__zoom,h.touch1){var wt=h.touch0[0],st=h.touch0[1],qt=h.touch1[0],ne=h.touch1[1],Zt=(Zt=qt[0]-wt[0])*Zt+(Zt=qt[1]-wt[1])*Zt,Ye=(Ye=ne[0]-st[0])*Ye+(Ye=ne[1]-st[1])*Ye;z=Kt(z,Math.sqrt(Zt/Ye)),Z=[(wt[0]+qt[0])/2,(wt[1]+qt[1])/2],_t=[(st[0]+ne[0])/2,(st[1]+ne[1])/2]}else if(h.touch0)Z=h.touch0[0],_t=h.touch0[1];else return;h.zoom("touch",n(Jt(z,Z,_t),h.extent,a))}}function ct(m,...F){if(this.__zooming){var h=le(this,F).event(m),L=m.changedTouches,$=L.length,D,z;for(xp(m),E&&clearTimeout(E),E=setTimeout(function(){E=null},T),D=0;D<$;++D)z=L[D],h.touch0&&h.touch0[2]===z.identifier?delete h.touch0:h.touch1&&h.touch1[2]===z.identifier&&delete h.touch1;if(h.touch1&&!h.touch0&&(h.touch0=h.touch1,delete h.touch1),h.touch0)h.touch0[1]=this.__zoom.invert(h.touch0[0]);else if(h.end(),h.taps===2&&(z=ao(z,this),Math.hypot(p[0]-z[0],p[1]-z[1])<lt)){var Z=Gr(this).on("dblclick.zoom");Z&&Z.apply(this,arguments)}}}return X.wheelDelta=function(m){return arguments.length?(r=typeof m=="function"?m:od(+m),X):r},X.filter=function(m){return arguments.length?(e=typeof m=="function"?m:od(!!m),X):e},X.touchable=function(m){return arguments.length?(i=typeof m=="function"?m:od(!!m),X):i},X.extent=function(m){return arguments.length?(t=typeof m=="function"?m:od([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),X):t},X.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],X):[s[0],s[1]]},X.translateExtent=function(m){return arguments.length?(a[0][0]=+m[0][0],a[1][0]=+m[1][0],a[0][1]=+m[0][1],a[1][1]=+m[1][1],X):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},X.constrain=function(m){return arguments.length?(n=m,X):n},X.duration=function(m){return arguments.length?(o=+m,X):o},X.interpolate=function(m){return arguments.length?(l=m,X):l},X.on=function(){var m=u.on.apply(u,arguments);return m===u?X:m},X.clickDistance=function(m){return arguments.length?(J=(m=+m)*m,X):Math.sqrt(J)},X.tapDistance=function(m){return arguments.length?(lt=+m,X):lt},X}function PD(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ld={exports:{}},$D=ld.exports,wv;function VD(){return wv||(wv=1,(function(e,t){(function(n,r){e.exports=r()})($D,(function(){var n=function(d){return d instanceof Uint8Array||d instanceof Uint16Array||d instanceof Uint32Array||d instanceof Int8Array||d instanceof Int16Array||d instanceof Int32Array||d instanceof Float32Array||d instanceof Float64Array||d instanceof Uint8ClampedArray},r=function(d,_){for(var I=Object.keys(_),W=0;W<I.length;++W)d[I[W]]=_[I[W]];return d},i=`
89
- `;function s(d){return typeof atob<"u"?atob(d):"base64:"+d}function a(d){var _=new Error("(regl) "+d);throw console.error(_),_}function o(d,_){d||a(_)}function l(d){return d?": "+d:""}function u(d,_,I){d in _||a("unknown parameter ("+d+")"+l(I)+". possible values: "+Object.keys(_).join())}function f(d,_){n(d)||a("invalid parameter type"+l(_)+". must be a typed array")}function p(d,_){switch(_){case"number":return typeof d=="number";case"object":return typeof d=="object";case"string":return typeof d=="string";case"boolean":return typeof d=="boolean";case"function":return typeof d=="function";case"undefined":return typeof d>"u";case"symbol":return typeof d=="symbol"}}function E(d,_,I){p(d,_)||a("invalid parameter type"+l(I)+". expected "+_+", got "+typeof d)}function T(d,_){d>=0&&(d|0)===d||a("invalid parameter type, ("+d+")"+l(_)+". must be a nonnegative integer")}function U(d,_,I){_.indexOf(d)<0&&a("invalid value"+l(I)+". must be one of: "+_)}var J=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function lt(d){Object.keys(d).forEach(function(_){J.indexOf(_)<0&&a('invalid regl constructor argument "'+_+'". must be one of '+J)})}function X(d,_){for(d=d+"";d.length<_;)d=" "+d;return d}function Kt(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function Jt(d,_){this.number=d,this.line=_,this.errors=[]}function ue(d,_,I){this.file=d,this.line=_,this.message=I}function Wt(){var d=new Error,_=(d.stack||d).toString(),I=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(_);if(I)return I[1];var W=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(_);return W?W[1]:"unknown"}function le(){var d=new Error,_=(d.stack||d).toString(),I=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(_);if(I)return I[1];var W=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(_);return W?W[1]:"unknown"}function $t(d,_){var I=d.split(`
90
- `),W=1,nt=0,Y={unknown:new Kt,0:new Kt};Y.unknown.name=Y[0].name=_||Wt(),Y.unknown.lines.push(new Jt(0,""));for(var Q=0;Q<I.length;++Q){var dt=I[Q],ut=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(dt);if(ut)switch(ut[1]){case"line":var yt=/(\d+)(\s+\d+)?/.exec(ut[2]);yt&&(W=yt[1]|0,yt[2]&&(nt=yt[2]|0,nt in Y||(Y[nt]=new Kt)));break;case"define":var vt=/SHADER_NAME(_B64)?\s+(.*)$/.exec(ut[2]);vt&&(Y[nt].name=vt[1]?s(vt[2]):vt[2]);break}Y[nt].lines.push(new Jt(W++,dt))}return Object.keys(Y).forEach(function(gt){var Tt=Y[gt];Tt.lines.forEach(function(ft){Tt.index[ft.number]=ft})}),Y}function yn(d){var _=[];return d.split(`
91
- `).forEach(function(I){if(!(I.length<5)){var W=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(I);W?_.push(new ue(W[1]|0,W[2]|0,W[3].trim())):I.length>0&&_.push(new ue("unknown",0,I))}}),_}function Ge(d,_){_.forEach(function(I){var W=d[I.file];if(W){var nt=W.index[I.line];if(nt){nt.errors.push(I),W.hasErrors=!0;return}}d.unknown.hasErrors=!0,d.unknown.lines[0].errors.push(I)})}function ce(d,_,I,W,nt){if(!d.getShaderParameter(_,d.COMPILE_STATUS)){var Y=d.getShaderInfoLog(_),Q=W===d.FRAGMENT_SHADER?"fragment":"vertex";L(I,"string",Q+" shader source must be a string",nt);var dt=$t(I,nt),ut=yn(Y);Ge(dt,ut),Object.keys(dt).forEach(function(yt){var vt=dt[yt];if(!vt.hasErrors)return;var gt=[""],Tt=[""];function ft(mt,k){gt.push(mt),Tt.push(k||"")}ft("file number "+yt+": "+vt.name+`
92
- `,"color:red;text-decoration:underline;font-weight:bold"),vt.lines.forEach(function(mt){if(mt.errors.length>0){ft(X(mt.number,4)+"| ","background-color:yellow; font-weight:bold"),ft(mt.line+i,"color:red; background-color:yellow; font-weight:bold");var k=0;mt.errors.forEach(function(K){var pt=K.message,Mt=/^\s*'(.*)'\s*:\s*(.*)$/.exec(pt);if(Mt){var ot=Mt[1];switch(pt=Mt[2],ot){case"assign":ot="=";break}k=Math.max(mt.line.indexOf(ot,k),0)}else k=0;ft(X("| ",6)),ft(X("^^^",k+3)+i,"font-weight:bold"),ft(X("| ",6)),ft(pt+i,"font-weight:bold")}),ft(X("| ",6)+i)}else ft(X(mt.number,4)+"| "),ft(mt.line+i,"color:red")}),typeof document<"u"&&!window.chrome?(Tt[0]=gt.join("%c"),console.log.apply(console,Tt)):console.log(gt.join(""))}),o.raise("Error compiling "+Q+" shader, "+dt[0].name)}}function Qt(d,_,I,W,nt){if(!d.getProgramParameter(_,d.LINK_STATUS)){var Y=d.getProgramInfoLog(_),Q=$t(I,nt),dt=$t(W,nt),ut='Error linking program with vertex shader, "'+dt[0].name+'", and fragment shader "'+Q[0].name+'"';typeof document<"u"?console.log("%c"+ut+i+"%c"+Y,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(ut+i+Y),o.raise(ut)}}function at(d){d._commandRef=Wt()}function ct(d,_,I,W){at(d);function nt(ut){return ut?W.id(ut):0}d._fragId=nt(d.static.frag),d._vertId=nt(d.static.vert);function Y(ut,yt){Object.keys(yt).forEach(function(vt){ut[W.id(vt)]=!0})}var Q=d._uniformSet={};Y(Q,_.static),Y(Q,_.dynamic);var dt=d._attributeSet={};Y(dt,I.static),Y(dt,I.dynamic),d._hasCount="count"in d.static||"count"in d.dynamic||"elements"in d.static||"elements"in d.dynamic}function m(d,_){var I=le();a(d+" in command "+(_||Wt())+(I==="unknown"?"":" called from "+I))}function F(d,_,I){d||m(_,I||Wt())}function h(d,_,I,W){d in _||m("unknown parameter ("+d+")"+l(I)+". possible values: "+Object.keys(_).join(),W||Wt())}function L(d,_,I,W){p(d,_)||m("invalid parameter type"+l(I)+". expected "+_+", got "+typeof d,W||Wt())}function $(d){d()}function D(d,_,I){d.texture?U(d.texture._texture.internalformat,_,"unsupported texture format for attachment"):U(d.renderbuffer._renderbuffer.format,I,"unsupported renderbuffer format for attachment")}var z=33071,Z=9728,_t=9984,wt=9985,st=9986,qt=9987,ne=5120,Zt=5121,Ye=5122,Yn=5123,_n=5124,cr=5125,Fr=5126,Si=32819,gr=32820,qr=33635,Lr=34042,Ht=36193,tt={};tt[ne]=tt[Zt]=1,tt[Ye]=tt[Yn]=tt[Ht]=tt[qr]=tt[Si]=tt[gr]=2,tt[_n]=tt[cr]=tt[Fr]=tt[Lr]=4;function te(d,_){return d===gr||d===Si||d===qr?2:d===Lr?4:tt[d]*_}function Mn(d){return!(d&d-1)&&!!d}function Mr(d,_,I){var W,nt=_.width,Y=_.height,Q=_.channels;o(nt>0&&nt<=I.maxTextureSize&&Y>0&&Y<=I.maxTextureSize,"invalid texture shape"),(d.wrapS!==z||d.wrapT!==z)&&o(Mn(nt)&&Mn(Y),"incompatible wrap mode for texture, both width and height must be power of 2"),_.mipmask===1?nt!==1&&Y!==1&&o(d.minFilter!==_t&&d.minFilter!==st&&d.minFilter!==wt&&d.minFilter!==qt,"min filter requires mipmap"):(o(Mn(nt)&&Mn(Y),"texture must be a square power of 2 to support mipmapping"),o(_.mipmask===(nt<<1)-1,"missing or incomplete mipmap data")),_.type===Fr&&(I.extensions.indexOf("oes_texture_float_linear")<0&&o(d.minFilter===Z&&d.magFilter===Z,"filter not supported, must enable oes_texture_float_linear"),o(!d.genMipmaps,"mipmap generation not supported with float textures"));var dt=_.images;for(W=0;W<16;++W)if(dt[W]){var ut=nt>>W,yt=Y>>W;o(_.mipmask&1<<W,"missing mipmap data");var vt=dt[W];if(o(vt.width===ut&&vt.height===yt,"invalid shape for mip images"),o(vt.format===_.format&&vt.internalformat===_.internalformat&&vt.type===_.type,"incompatible type for mip image"),!vt.compressed)if(vt.data){var gt=Math.ceil(te(vt.type,Q)*ut/vt.unpackAlignment)*vt.unpackAlignment;o(vt.data.byteLength===gt*yt,"invalid data for image, buffer size is inconsistent with image format")}else vt.element||vt.copy}else d.genMipmaps||o((_.mipmask&1<<W)===0,"extra mipmap data");_.compressed&&o(!d.genMipmaps,"mipmap generation for compressed images not supported")}function li(d,_,I,W){var nt=d.width,Y=d.height,Q=d.channels;o(nt>0&&nt<=W.maxTextureSize&&Y>0&&Y<=W.maxTextureSize,"invalid texture shape"),o(nt===Y,"cube map must be square"),o(_.wrapS===z&&_.wrapT===z,"wrap mode not supported by cube map");for(var dt=0;dt<I.length;++dt){var ut=I[dt];o(ut.width===nt&&ut.height===Y,"inconsistent cube map face shape"),_.genMipmaps&&(o(!ut.compressed,"can not generate mipmap for compressed textures"),o(ut.mipmask===1,"can not specify mipmaps and generate mipmaps"));for(var yt=ut.images,vt=0;vt<16;++vt){var gt=yt[vt];if(gt){var Tt=nt>>vt,ft=Y>>vt;o(ut.mipmask&1<<vt,"missing mipmap data"),o(gt.width===Tt&&gt.height===ft,"invalid shape for mip images"),o(gt.format===d.format&&gt.internalformat===d.internalformat&&gt.type===d.type,"incompatible type for mip image"),gt.compressed||(gt.data?o(gt.data.byteLength===Tt*ft*Math.max(te(gt.type,Q),gt.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):gt.element||gt.copy)}}}}var g=r(o,{optional:$,raise:a,commandRaise:m,command:F,parameter:u,commandParameter:h,constructor:lt,type:E,commandType:L,isTypedArray:f,nni:T,oneOf:U,shaderError:ce,linkError:Qt,callSite:le,saveCommandRef:at,saveDrawInfo:ct,framebufferFormat:D,guessCommand:Wt,texture2D:Mr,textureCube:li}),Qn=0,Rr=0,Xe=5,zs=6;function Un(d,_){this.id=Qn++,this.type=d,this.data=_}function Li(d){return d.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function ke(d){if(d.length===0)return[];var _=d.charAt(0),I=d.charAt(d.length-1);if(d.length>1&&_===I&&(_==='"'||_==="'"))return['"'+Li(d.substr(1,d.length-2))+'"'];var W=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(d);if(W)return ke(d.substr(0,W.index)).concat(ke(W[1])).concat(ke(d.substr(W.index+W[0].length)));var nt=d.split(".");if(nt.length===1)return['"'+Li(d)+'"'];for(var Y=[],Q=0;Q<nt.length;++Q)Y=Y.concat(ke(nt[Q]));return Y}function Nr(d){return"["+ke(d).join("][")+"]"}function Mi(d,_){return new Un(d,Nr(_+""))}function H(d){return typeof d=="function"&&!d._reglType||d instanceof Un}function bt(d,_){if(typeof d=="function")return new Un(Rr,d);if(typeof d=="number"||typeof d=="boolean")return new Un(Xe,d);if(Array.isArray(d))return new Un(zs,d.map(function(I,W){return bt(I,_+"["+W+"]")}));if(d instanceof Un)return d;g(!1,"invalid option type in uniform "+_)}var Ft={DynamicVariable:Un,define:Mi,isDynamic:H,unbox:bt,accessor:Nr},Ut={next:typeof requestAnimationFrame=="function"?function(d){return requestAnimationFrame(d)}:function(d){return setTimeout(d,16)},cancel:typeof cancelAnimationFrame=="function"?function(d){return cancelAnimationFrame(d)}:clearTimeout},fe=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return+new Date};function De(){var d={"":0},_=[""];return{id:function(I){var W=d[I];return W||(W=d[I]=_.length,_.push(I),W)},str:function(I){return _[I]}}}function Ue(d,_,I){var W=document.createElement("canvas");r(W.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),d.appendChild(W),d===document.body&&(W.style.position="absolute",r(d.style,{margin:0,padding:0}));function nt(){var dt=window.innerWidth,ut=window.innerHeight;if(d!==document.body){var yt=W.getBoundingClientRect();dt=yt.right-yt.left,ut=yt.bottom-yt.top}W.width=I*dt,W.height=I*ut}var Y;d!==document.body&&typeof ResizeObserver=="function"?(Y=new ResizeObserver(function(){setTimeout(nt)}),Y.observe(d)):window.addEventListener("resize",nt,!1);function Q(){Y?Y.disconnect():window.removeEventListener("resize",nt),d.removeChild(W)}return nt(),{canvas:W,onDestroy:Q}}function Fe(d,_){function I(W){try{return d.getContext(W,_)}catch{return null}}return I("webgl")||I("experimental-webgl")||I("webgl-experimental")}function Pn(d){return typeof d.nodeName=="string"&&typeof d.appendChild=="function"&&typeof d.getBoundingClientRect=="function"}function Rn(d){return typeof d.drawArrays=="function"||typeof d.drawElements=="function"}function on(d){return typeof d=="string"?d.split():(g(Array.isArray(d),"invalid extension array"),d)}function hn(d){return typeof d=="string"?(g(typeof document<"u","not supported outside of DOM"),document.querySelector(d)):d}function ur(d){var _=d||{},I,W,nt,Y,Q={},dt=[],ut=[],yt=typeof window>"u"?1:window.devicePixelRatio,vt=!1,gt=function(mt){mt&&g.raise(mt)},Tt=function(){};if(typeof _=="string"?(g(typeof document<"u","selector queries only supported in DOM environments"),I=document.querySelector(_),g(I,"invalid query string for element")):typeof _=="object"?Pn(_)?I=_:Rn(_)?(Y=_,nt=Y.canvas):(g.constructor(_),"gl"in _?Y=_.gl:"canvas"in _?nt=hn(_.canvas):"container"in _&&(W=hn(_.container)),"attributes"in _&&(Q=_.attributes,g.type(Q,"object","invalid context attributes")),"extensions"in _&&(dt=on(_.extensions)),"optionalExtensions"in _&&(ut=on(_.optionalExtensions)),"onDone"in _&&(g.type(_.onDone,"function","invalid or missing onDone callback"),gt=_.onDone),"profile"in _&&(vt=!!_.profile),"pixelRatio"in _&&(yt=+_.pixelRatio,g(yt>0,"invalid pixel ratio"))):g.raise("invalid arguments to regl"),I&&(I.nodeName.toLowerCase()==="canvas"?nt=I:W=I),!Y){if(!nt){g(typeof document<"u","must manually specify webgl context outside of DOM environments");var ft=Ue(W||document.body,gt,yt);if(!ft)return null;nt=ft.canvas,Tt=ft.onDestroy}Q.premultipliedAlpha===void 0&&(Q.premultipliedAlpha=!0),Y=Fe(nt,Q)}return Y?{gl:Y,canvas:nt,container:W,extensions:dt,optionalExtensions:ut,pixelRatio:yt,profile:vt,onDone:gt,onDestroy:Tt}:(Tt(),gt("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function ci(d,_){var I={};function W(Q){g.type(Q,"string","extension name must be string");var dt=Q.toLowerCase(),ut;try{ut=I[dt]=d.getExtension(dt)}catch{}return!!ut}for(var nt=0;nt<_.extensions.length;++nt){var Y=_.extensions[nt];if(!W(Y))return _.onDestroy(),_.onDone('"'+Y+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return _.optionalExtensions.forEach(W),{extensions:I,restore:function(){Object.keys(I).forEach(function(Q){if(I[Q]&&!W(Q))throw new Error("(regl): error restoring extension "+Q)})}}}function Ke(d,_){for(var I=Array(d),W=0;W<d;++W)I[W]=_(W);return I}var Cn=5120,kt=5121,nn=5122,kn=5123,vn=5124,rn=5125,Br=5126;function _r(d){for(var _=16;_<=1<<28;_*=16)if(d<=_)return _;return 0}function Xr(d){var _,I;return _=(d>65535)<<4,d>>>=_,I=(d>255)<<3,d>>>=I,_|=I,I=(d>15)<<2,d>>>=I,_|=I,I=(d>3)<<1,d>>>=I,_|=I,_|d>>1}function Kr(){var d=Ke(8,function(){return[]});function _(Y){var Q=_r(Y),dt=d[Xr(Q)>>2];return dt.length>0?dt.pop():new ArrayBuffer(Q)}function I(Y){d[Xr(Y.byteLength)>>2].push(Y)}function W(Y,Q){var dt=null;switch(Y){case Cn:dt=new Int8Array(_(Q),0,Q);break;case kt:dt=new Uint8Array(_(Q),0,Q);break;case nn:dt=new Int16Array(_(2*Q),0,Q);break;case kn:dt=new Uint16Array(_(2*Q),0,Q);break;case vn:dt=new Int32Array(_(4*Q),0,Q);break;case rn:dt=new Uint32Array(_(4*Q),0,Q);break;case Br:dt=new Float32Array(_(4*Q),0,Q);break;default:return null}return dt.length!==Q?dt.subarray(0,Q):dt}function nt(Y){I(Y.buffer)}return{alloc:_,free:I,allocType:W,freeType:nt}}var Xt=Kr();Xt.zero=Kr();var he=3408,gn=3410,bn=3411,sr=3412,wn=3413,$n=3414,Qr=3415,Jr=33901,Vr=33902,Zn=3379,tr=3386,dr=34921,fr=36347,Cr=36348,ui=35661,kr=35660,zr=34930,Ji=36349,va=34076,hs=34024,ps=7936,th=7937,eh=7938,YP=35724,WP=34047,HP=36063,qP=34852,nh=3553,YS=34067,XP=34069,KP=33984,zc=6408,Ay=5126,WS=5121,xy=36160,QP=36053,JP=36064,ZP=16384,t8=function(d,_){var I=1;_.ext_texture_filter_anisotropic&&(I=d.getParameter(WP));var W=1,nt=1;_.webgl_draw_buffers&&(W=d.getParameter(qP),nt=d.getParameter(HP));var Y=!!_.oes_texture_float;if(Y){var Q=d.createTexture();d.bindTexture(nh,Q),d.texImage2D(nh,0,zc,1,1,0,zc,Ay,null);var dt=d.createFramebuffer();if(d.bindFramebuffer(xy,dt),d.framebufferTexture2D(xy,JP,nh,Q,0),d.bindTexture(nh,null),d.checkFramebufferStatus(xy)!==QP)Y=!1;else{d.viewport(0,0,1,1),d.clearColor(1,0,0,1),d.clear(ZP);var ut=Xt.allocType(Ay,4);d.readPixels(0,0,1,1,zc,Ay,ut),d.getError()?Y=!1:(d.deleteFramebuffer(dt),d.deleteTexture(Q),Y=ut[0]===1),Xt.freeType(ut)}}var yt=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),vt=!0;if(!yt){var gt=d.createTexture(),Tt=Xt.allocType(WS,36);d.activeTexture(KP),d.bindTexture(YS,gt),d.texImage2D(XP,0,zc,3,3,0,zc,WS,Tt),Xt.freeType(Tt),d.bindTexture(YS,null),d.deleteTexture(gt),vt=!d.getError()}return{colorBits:[d.getParameter(gn),d.getParameter(bn),d.getParameter(sr),d.getParameter(wn)],depthBits:d.getParameter($n),stencilBits:d.getParameter(Qr),subpixelBits:d.getParameter(he),extensions:Object.keys(_).filter(function(ft){return!!_[ft]}),maxAnisotropic:I,maxDrawbuffers:W,maxColorAttachments:nt,pointSizeDims:d.getParameter(Jr),lineWidthDims:d.getParameter(Vr),maxViewportDims:d.getParameter(tr),maxCombinedTextureUnits:d.getParameter(ui),maxCubeMapSize:d.getParameter(va),maxRenderbufferSize:d.getParameter(hs),maxTextureUnits:d.getParameter(zr),maxTextureSize:d.getParameter(Zn),maxAttributes:d.getParameter(dr),maxVertexUniforms:d.getParameter(fr),maxVertexTextureUnits:d.getParameter(kr),maxVaryingVectors:d.getParameter(Cr),maxFragmentUniforms:d.getParameter(Ji),glsl:d.getParameter(YP),renderer:d.getParameter(th),vendor:d.getParameter(ps),version:d.getParameter(eh),readFloat:Y,npotTextureCube:vt}};function ms(d){return!!d&&typeof d=="object"&&Array.isArray(d.shape)&&Array.isArray(d.stride)&&typeof d.offset=="number"&&d.shape.length===d.stride.length&&(Array.isArray(d.data)||n(d.data))}var Ci=function(d){return Object.keys(d).map(function(_){return d[_]})},rh={shape:i8,flatten:r8};function e8(d,_,I){for(var W=0;W<_;++W)I[W]=d[W]}function n8(d,_,I,W){for(var nt=0,Y=0;Y<_;++Y)for(var Q=d[Y],dt=0;dt<I;++dt)W[nt++]=Q[dt]}function HS(d,_,I,W,nt,Y){for(var Q=Y,dt=0;dt<_;++dt)for(var ut=d[dt],yt=0;yt<I;++yt)for(var vt=ut[yt],gt=0;gt<W;++gt)nt[Q++]=vt[gt]}function qS(d,_,I,W,nt){for(var Y=1,Q=I+1;Q<_.length;++Q)Y*=_[Q];var dt=_[I];if(_.length-I===4){var ut=_[I+1],yt=_[I+2],vt=_[I+3];for(Q=0;Q<dt;++Q)HS(d[Q],ut,yt,vt,W,nt),nt+=Y}else for(Q=0;Q<dt;++Q)qS(d[Q],_,I+1,W,nt),nt+=Y}function r8(d,_,I,W){var nt=1;if(_.length)for(var Y=0;Y<_.length;++Y)nt*=_[Y];else nt=0;var Q=W||Xt.allocType(I,nt);switch(_.length){case 0:break;case 1:e8(d,_[0],Q);break;case 2:n8(d,_[0],_[1],Q);break;case 3:HS(d,_[0],_[1],_[2],Q,0);break;default:qS(d,_,0,Q,0)}return Q}function i8(d){for(var _=[],I=d;I.length;I=I[0])_.push(I.length);return _}var Ry={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},s8=5120,a8=5122,o8=5124,l8=5121,c8=5123,u8=5125,d8=5126,f8=5126,Eo={int8:s8,int16:a8,int32:o8,uint8:l8,uint16:c8,uint32:u8,float:d8,float32:f8},h8=35048,p8=35040,ih={dynamic:h8,stream:p8,static:35044},Ny=rh.flatten,XS=rh.shape,KS=35044,m8=35040,By=5121,Oy=5126,Ya=[];Ya[5120]=1,Ya[5122]=2,Ya[5124]=4,Ya[5121]=1,Ya[5123]=2,Ya[5125]=4,Ya[5126]=4;function sh(d){return Ry[Object.prototype.toString.call(d)]|0}function QS(d,_){for(var I=0;I<_.length;++I)d[I]=_[I]}function JS(d,_,I,W,nt,Y,Q){for(var dt=0,ut=0;ut<I;++ut)for(var yt=0;yt<W;++yt)d[dt++]=_[nt*ut+Y*yt+Q]}function y8(d,_,I,W){var nt=0,Y={};function Q(k){this.id=nt++,this.buffer=d.createBuffer(),this.type=k,this.usage=KS,this.byteLength=0,this.dimension=1,this.dtype=By,this.persistentData=null,I.profile&&(this.stats={size:0})}Q.prototype.bind=function(){d.bindBuffer(this.type,this.buffer)},Q.prototype.destroy=function(){Tt(this)};var dt=[];function ut(k,K){var pt=dt.pop();return pt||(pt=new Q(k)),pt.bind(),gt(pt,K,m8,0,1,!1),pt}function yt(k){dt.push(k)}function vt(k,K,pt){k.byteLength=K.byteLength,d.bufferData(k.type,K,pt)}function gt(k,K,pt,Mt,ot,Dt){var Nt;if(k.usage=pt,Array.isArray(K)){if(k.dtype=Mt||Oy,K.length>0){var ee;if(Array.isArray(K[0])){Nt=XS(K);for(var rt=1,et=1;et<Nt.length;++et)rt*=Nt[et];k.dimension=rt,ee=Ny(K,Nt,k.dtype),vt(k,ee,pt),Dt?k.persistentData=ee:Xt.freeType(ee)}else if(typeof K[0]=="number"){k.dimension=ot;var Vt=Xt.allocType(k.dtype,K.length);QS(Vt,K),vt(k,Vt,pt),Dt?k.persistentData=Vt:Xt.freeType(Vt)}else n(K[0])?(k.dimension=K[0].length,k.dtype=Mt||sh(K[0])||Oy,ee=Ny(K,[K.length,K[0].length],k.dtype),vt(k,ee,pt),Dt?k.persistentData=ee:Xt.freeType(ee)):g.raise("invalid buffer data")}}else if(n(K))k.dtype=Mt||sh(K),k.dimension=ot,vt(k,K,pt),Dt&&(k.persistentData=new Uint8Array(new Uint8Array(K.buffer)));else if(ms(K)){Nt=K.shape;var At=K.stride,ht=K.offset,xt=0,Rt=0,me=0,de=0;Nt.length===1?(xt=Nt[0],Rt=1,me=At[0],de=0):Nt.length===2?(xt=Nt[0],Rt=Nt[1],me=At[0],de=At[1]):g.raise("invalid shape"),k.dtype=Mt||sh(K.data)||Oy,k.dimension=Rt;var Bt=Xt.allocType(k.dtype,xt*Rt);JS(Bt,K.data,xt,Rt,me,de,ht),vt(k,Bt,pt),Dt?k.persistentData=Bt:Xt.freeType(Bt)}else K instanceof ArrayBuffer?(k.dtype=By,k.dimension=ot,vt(k,K,pt),Dt&&(k.persistentData=new Uint8Array(new Uint8Array(K)))):g.raise("invalid buffer data")}function Tt(k){_.bufferCount--,W(k);var K=k.buffer;g(K,"buffer must not be deleted already"),d.deleteBuffer(K),k.buffer=null,delete Y[k.id]}function ft(k,K,pt,Mt){_.bufferCount++;var ot=new Q(K);Y[ot.id]=ot;function Dt(rt){var et=KS,Vt=null,At=0,ht=0,xt=1;return Array.isArray(rt)||n(rt)||ms(rt)||rt instanceof ArrayBuffer?Vt=rt:typeof rt=="number"?At=rt|0:rt&&(g.type(rt,"object","buffer arguments must be an object, a number or an array"),"data"in rt&&(g(Vt===null||Array.isArray(Vt)||n(Vt)||ms(Vt),"invalid data for buffer"),Vt=rt.data),"usage"in rt&&(g.parameter(rt.usage,ih,"invalid buffer usage"),et=ih[rt.usage]),"type"in rt&&(g.parameter(rt.type,Eo,"invalid buffer type"),ht=Eo[rt.type]),"dimension"in rt&&(g.type(rt.dimension,"number","invalid dimension"),xt=rt.dimension|0),"length"in rt&&(g.nni(At,"buffer length must be a nonnegative integer"),At=rt.length|0)),ot.bind(),Vt?gt(ot,Vt,et,ht,xt,Mt):(At&&d.bufferData(ot.type,At,et),ot.dtype=ht||By,ot.usage=et,ot.dimension=xt,ot.byteLength=At),I.profile&&(ot.stats.size=ot.byteLength*Ya[ot.dtype]),Dt}function Nt(rt,et){g(et+rt.byteLength<=ot.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+rt.byteLength+" starting from offset "+et+" to a buffer of size "+ot.byteLength),d.bufferSubData(ot.type,et,rt)}function ee(rt,et){var Vt=(et||0)|0,At;if(ot.bind(),n(rt)||rt instanceof ArrayBuffer)Nt(rt,Vt);else if(Array.isArray(rt)){if(rt.length>0)if(typeof rt[0]=="number"){var ht=Xt.allocType(ot.dtype,rt.length);QS(ht,rt),Nt(ht,Vt),Xt.freeType(ht)}else if(Array.isArray(rt[0])||n(rt[0])){At=XS(rt);var xt=Ny(rt,At,ot.dtype);Nt(xt,Vt),Xt.freeType(xt)}else g.raise("invalid buffer data")}else if(ms(rt)){At=rt.shape;var Rt=rt.stride,me=0,de=0,Bt=0,Lt=0;At.length===1?(me=At[0],de=1,Bt=Rt[0],Lt=0):At.length===2?(me=At[0],de=At[1],Bt=Rt[0],Lt=Rt[1]):g.raise("invalid shape");var ie=Array.isArray(rt.data)?ot.dtype:sh(rt.data),pe=Xt.allocType(ie,me*de);JS(pe,rt.data,me,de,Bt,Lt,rt.offset),Nt(pe,Vt),Xt.freeType(pe)}else g.raise("invalid data for buffer subdata");return Dt}return pt||Dt(k),Dt._reglType="buffer",Dt._buffer=ot,Dt.subdata=ee,I.profile&&(Dt.stats=ot.stats),Dt.destroy=function(){Tt(ot)},Dt}function mt(){Ci(Y).forEach(function(k){k.buffer=d.createBuffer(),d.bindBuffer(k.type,k.buffer),d.bufferData(k.type,k.persistentData||k.byteLength,k.usage)})}return I.profile&&(_.getTotalBufferSize=function(){var k=0;return Object.keys(Y).forEach(function(K){k+=Y[K].stats.size}),k}),{create:ft,createStream:ut,destroyStream:yt,clear:function(){Ci(Y).forEach(Tt),dt.forEach(Tt)},getBuffer:function(k){return k&&k._buffer instanceof Q?k._buffer:null},restore:mt,_initBuffer:gt}}var g8=0,_8=0,v8=1,b8=1,w8=4,S8=4,Wa={points:g8,point:_8,lines:v8,line:b8,triangles:w8,triangle:S8,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},E8=0,I8=1,Gc=4,T8=5120,Tl=5121,ZS=5122,Al=5123,tE=5124,Io=5125,Dy=34963,A8=35040,x8=35044;function R8(d,_,I,W){var nt={},Y=0,Q={uint8:Tl,uint16:Al};_.oes_element_index_uint&&(Q.uint32=Io);function dt(mt){this.id=Y++,nt[this.id]=this,this.buffer=mt,this.primType=Gc,this.vertCount=0,this.type=0}dt.prototype.bind=function(){this.buffer.bind()};var ut=[];function yt(mt){var k=ut.pop();return k||(k=new dt(I.create(null,Dy,!0,!1)._buffer)),gt(k,mt,A8,-1,-1,0,0),k}function vt(mt){ut.push(mt)}function gt(mt,k,K,pt,Mt,ot,Dt){mt.buffer.bind();var Nt;if(k){var ee=Dt;!Dt&&(!n(k)||ms(k)&&!n(k.data))&&(ee=_.oes_element_index_uint?Io:Al),I._initBuffer(mt.buffer,k,K,ee,3)}else d.bufferData(Dy,ot,K),mt.buffer.dtype=Nt||Tl,mt.buffer.usage=K,mt.buffer.dimension=3,mt.buffer.byteLength=ot;if(Nt=Dt,!Dt){switch(mt.buffer.dtype){case Tl:case T8:Nt=Tl;break;case Al:case ZS:Nt=Al;break;case Io:case tE:Nt=Io;break;default:g.raise("unsupported type for element array")}mt.buffer.dtype=Nt}mt.type=Nt,g(Nt!==Io||!!_.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var rt=Mt;rt<0&&(rt=mt.buffer.byteLength,Nt===Al?rt>>=1:Nt===Io&&(rt>>=2)),mt.vertCount=rt;var et=pt;if(pt<0){et=Gc;var Vt=mt.buffer.dimension;Vt===1&&(et=E8),Vt===2&&(et=I8),Vt===3&&(et=Gc)}mt.primType=et}function Tt(mt){W.elementsCount--,g(mt.buffer!==null,"must not double destroy elements"),delete nt[mt.id],mt.buffer.destroy(),mt.buffer=null}function ft(mt,k){var K=I.create(null,Dy,!0),pt=new dt(K._buffer);W.elementsCount++;function Mt(ot){if(!ot)K(),pt.primType=Gc,pt.vertCount=0,pt.type=Tl;else if(typeof ot=="number")K(ot),pt.primType=Gc,pt.vertCount=ot|0,pt.type=Tl;else{var Dt=null,Nt=x8,ee=-1,rt=-1,et=0,Vt=0;Array.isArray(ot)||n(ot)||ms(ot)?Dt=ot:(g.type(ot,"object","invalid arguments for elements"),"data"in ot&&(Dt=ot.data,g(Array.isArray(Dt)||n(Dt)||ms(Dt),"invalid data for element buffer")),"usage"in ot&&(g.parameter(ot.usage,ih,"invalid element buffer usage"),Nt=ih[ot.usage]),"primitive"in ot&&(g.parameter(ot.primitive,Wa,"invalid element buffer primitive"),ee=Wa[ot.primitive]),"count"in ot&&(g(typeof ot.count=="number"&&ot.count>=0,"invalid vertex count for elements"),rt=ot.count|0),"type"in ot&&(g.parameter(ot.type,Q,"invalid buffer type"),Vt=Q[ot.type]),"length"in ot?et=ot.length|0:(et=rt,Vt===Al||Vt===ZS?et*=2:(Vt===Io||Vt===tE)&&(et*=4))),gt(pt,Dt,Nt,ee,rt,et,Vt)}return Mt}return Mt(mt),Mt._reglType="elements",Mt._elements=pt,Mt.subdata=function(ot,Dt){return K.subdata(ot,Dt),Mt},Mt.destroy=function(){Tt(pt)},Mt}return{create:ft,createStream:yt,destroyStream:vt,getElements:function(mt){return typeof mt=="function"&&mt._elements instanceof dt?mt._elements:null},clear:function(){Ci(nt).forEach(Tt)}}}var eE=new Float32Array(1),N8=new Uint32Array(eE.buffer),B8=5123;function nE(d){for(var _=Xt.allocType(B8,d.length),I=0;I<d.length;++I)if(isNaN(d[I]))_[I]=65535;else if(d[I]===1/0)_[I]=31744;else if(d[I]===-1/0)_[I]=64512;else{eE[0]=d[I];var W=N8[0],nt=W>>>31<<15,Y=(W<<1>>>24)-127,Q=W>>13&1023;if(Y<-24)_[I]=nt;else if(Y<-14){var dt=-14-Y;_[I]=nt+(Q+1024>>dt)}else Y>15?_[I]=nt+31744:_[I]=nt+(Y+15<<10)+Q}return _}function ar(d){return Array.isArray(d)||n(d)}var rE=function(d){return!(d&d-1)&&!!d},O8=34467,Gs=3553,Fy=34067,ah=34069,To=6408,Ly=6406,oh=6407,jc=6409,lh=6410,iE=32854,My=32855,sE=36194,D8=32819,F8=32820,L8=33635,M8=34042,Cy=6402,ch=34041,ky=35904,Uy=35906,xl=36193,Py=33776,$y=33777,Vy=33778,zy=33779,aE=35986,oE=35987,lE=34798,cE=35840,uE=35841,dE=35842,fE=35843,hE=36196,Rl=5121,Gy=5123,jy=5125,Yc=5126,C8=10242,k8=10243,U8=10497,Yy=33071,P8=33648,$8=10240,V8=10241,Wy=9728,z8=9729,Hy=9984,pE=9985,mE=9986,qy=9987,G8=33170,uh=4352,j8=4353,Y8=4354,W8=34046,H8=3317,q8=37440,X8=37441,K8=37443,yE=37444,Wc=33984,Q8=[Hy,mE,pE,qy],dh=[0,jc,lh,oh,To],Zi={};Zi[jc]=Zi[Ly]=Zi[Cy]=1,Zi[ch]=Zi[lh]=2,Zi[oh]=Zi[ky]=3,Zi[To]=Zi[Uy]=4;function Nl(d){return"[object "+d+"]"}var gE=Nl("HTMLCanvasElement"),_E=Nl("OffscreenCanvas"),vE=Nl("CanvasRenderingContext2D"),bE=Nl("ImageBitmap"),wE=Nl("HTMLImageElement"),SE=Nl("HTMLVideoElement"),J8=Object.keys(Ry).concat([gE,_E,vE,bE,wE,SE]),Bl=[];Bl[Rl]=1,Bl[Yc]=4,Bl[xl]=2,Bl[Gy]=2,Bl[jy]=4;var Ur=[];Ur[iE]=2,Ur[My]=2,Ur[sE]=2,Ur[ch]=4,Ur[Py]=.5,Ur[$y]=.5,Ur[Vy]=1,Ur[zy]=1,Ur[aE]=.5,Ur[oE]=1,Ur[lE]=1,Ur[cE]=.5,Ur[uE]=.25,Ur[dE]=.5,Ur[fE]=.25,Ur[hE]=.5;function EE(d){return Array.isArray(d)&&(d.length===0||typeof d[0]=="number")}function IE(d){if(!Array.isArray(d))return!1;var _=d.length;return!(_===0||!ar(d[0]))}function Ao(d){return Object.prototype.toString.call(d)}function TE(d){return Ao(d)===gE}function AE(d){return Ao(d)===_E}function Z8(d){return Ao(d)===vE}function t4(d){return Ao(d)===bE}function e4(d){return Ao(d)===wE}function n4(d){return Ao(d)===SE}function Xy(d){if(!d)return!1;var _=Ao(d);return J8.indexOf(_)>=0?!0:EE(d)||IE(d)||ms(d)}function xE(d){return Ry[Object.prototype.toString.call(d)]|0}function r4(d,_){var I=_.length;switch(d.type){case Rl:case Gy:case jy:case Yc:var W=Xt.allocType(d.type,I);W.set(_),d.data=W;break;case xl:d.data=nE(_);break;default:g.raise("unsupported texture type, must specify a typed array")}}function RE(d,_){return Xt.allocType(d.type===xl?Yc:d.type,_)}function NE(d,_){d.type===xl?(d.data=nE(_),Xt.freeType(_)):d.data=_}function i4(d,_,I,W,nt,Y){for(var Q=d.width,dt=d.height,ut=d.channels,yt=Q*dt*ut,vt=RE(d,yt),gt=0,Tt=0;Tt<dt;++Tt)for(var ft=0;ft<Q;++ft)for(var mt=0;mt<ut;++mt)vt[gt++]=_[I*ft+W*Tt+nt*mt+Y];NE(d,vt)}function fh(d,_,I,W,nt,Y){var Q;if(typeof Ur[d]<"u"?Q=Ur[d]:Q=Zi[d]*Bl[_],Y&&(Q*=6),nt){for(var dt=0,ut=I;ut>=1;)dt+=Q*ut*ut,ut/=2;return dt}else return Q*I*W}function s4(d,_,I,W,nt,Y,Q){var dt={"don't care":uh,"dont care":uh,nice:Y8,fast:j8},ut={repeat:U8,clamp:Yy,mirror:P8},yt={nearest:Wy,linear:z8},vt=r({mipmap:qy,"nearest mipmap nearest":Hy,"linear mipmap nearest":pE,"nearest mipmap linear":mE,"linear mipmap linear":qy},yt),gt={none:0,browser:yE},Tt={uint8:Rl,rgba4:D8,rgb565:L8,"rgb5 a1":F8},ft={alpha:Ly,luminance:jc,"luminance alpha":lh,rgb:oh,rgba:To,rgba4:iE,"rgb5 a1":My,rgb565:sE},mt={};_.ext_srgb&&(ft.srgb=ky,ft.srgba=Uy),_.oes_texture_float&&(Tt.float32=Tt.float=Yc),_.oes_texture_half_float&&(Tt.float16=Tt["half float"]=xl),_.webgl_depth_texture&&(r(ft,{depth:Cy,"depth stencil":ch}),r(Tt,{uint16:Gy,uint32:jy,"depth stencil":M8})),_.webgl_compressed_texture_s3tc&&r(mt,{"rgb s3tc dxt1":Py,"rgba s3tc dxt1":$y,"rgba s3tc dxt3":Vy,"rgba s3tc dxt5":zy}),_.webgl_compressed_texture_atc&&r(mt,{"rgb atc":aE,"rgba atc explicit alpha":oE,"rgba atc interpolated alpha":lE}),_.webgl_compressed_texture_pvrtc&&r(mt,{"rgb pvrtc 4bppv1":cE,"rgb pvrtc 2bppv1":uE,"rgba pvrtc 4bppv1":dE,"rgba pvrtc 2bppv1":fE}),_.webgl_compressed_texture_etc1&&(mt["rgb etc1"]=hE);var k=Array.prototype.slice.call(d.getParameter(O8));Object.keys(mt).forEach(function(S){var q=mt[S];k.indexOf(q)>=0&&(ft[S]=q)});var K=Object.keys(ft);I.textureFormats=K;var pt=[];Object.keys(ft).forEach(function(S){var q=ft[S];pt[q]=S});var Mt=[];Object.keys(Tt).forEach(function(S){var q=Tt[S];Mt[q]=S});var ot=[];Object.keys(yt).forEach(function(S){var q=yt[S];ot[q]=S});var Dt=[];Object.keys(vt).forEach(function(S){var q=vt[S];Dt[q]=S});var Nt=[];Object.keys(ut).forEach(function(S){var q=ut[S];Nt[q]=S});var ee=K.reduce(function(S,q){var j=ft[q];return j===jc||j===Ly||j===jc||j===lh||j===Cy||j===ch||_.ext_srgb&&(j===ky||j===Uy)?S[j]=j:j===My||q.indexOf("rgba")>=0?S[j]=To:S[j]=oh,S},{});function rt(){this.internalformat=To,this.format=To,this.type=Rl,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=yE,this.width=0,this.height=0,this.channels=0}function et(S,q){S.internalformat=q.internalformat,S.format=q.format,S.type=q.type,S.compressed=q.compressed,S.premultiplyAlpha=q.premultiplyAlpha,S.flipY=q.flipY,S.unpackAlignment=q.unpackAlignment,S.colorSpace=q.colorSpace,S.width=q.width,S.height=q.height,S.channels=q.channels}function Vt(S,q){if(!(typeof q!="object"||!q)){if("premultiplyAlpha"in q&&(g.type(q.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),S.premultiplyAlpha=q.premultiplyAlpha),"flipY"in q&&(g.type(q.flipY,"boolean","invalid texture flip"),S.flipY=q.flipY),"alignment"in q&&(g.oneOf(q.alignment,[1,2,4,8],"invalid texture unpack alignment"),S.unpackAlignment=q.alignment),"colorSpace"in q&&(g.parameter(q.colorSpace,gt,"invalid colorSpace"),S.colorSpace=gt[q.colorSpace]),"type"in q){var j=q.type;g(_.oes_texture_float||!(j==="float"||j==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),g(_.oes_texture_half_float||!(j==="half float"||j==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),g(_.webgl_depth_texture||!(j==="uint16"||j==="uint32"||j==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),g.parameter(j,Tt,"invalid texture type"),S.type=Tt[j]}var Pt=S.width,je=S.height,b=S.channels,y=!1;"shape"in q?(g(Array.isArray(q.shape)&&q.shape.length>=2,"shape must be an array"),Pt=q.shape[0],je=q.shape[1],q.shape.length===3&&(b=q.shape[2],g(b>0&&b<=4,"invalid number of channels"),y=!0),g(Pt>=0&&Pt<=I.maxTextureSize,"invalid width"),g(je>=0&&je<=I.maxTextureSize,"invalid height")):("radius"in q&&(Pt=je=q.radius,g(Pt>=0&&Pt<=I.maxTextureSize,"invalid radius")),"width"in q&&(Pt=q.width,g(Pt>=0&&Pt<=I.maxTextureSize,"invalid width")),"height"in q&&(je=q.height,g(je>=0&&je<=I.maxTextureSize,"invalid height")),"channels"in q&&(b=q.channels,g(b>0&&b<=4,"invalid number of channels"),y=!0)),S.width=Pt|0,S.height=je|0,S.channels=b|0;var x=!1;if("format"in q){var C=q.format;g(_.webgl_depth_texture||!(C==="depth"||C==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),g.parameter(C,ft,"invalid texture format");var V=S.internalformat=ft[C];S.format=ee[V],C in Tt&&("type"in q||(S.type=Tt[C])),C in mt&&(S.compressed=!0),x=!0}!y&&x?S.channels=Zi[S.format]:y&&!x?S.channels!==dh[S.format]&&(S.format=S.internalformat=dh[S.channels]):x&&y&&g(S.channels===Zi[S.format],"number of channels inconsistent with specified format")}}function At(S){d.pixelStorei(q8,S.flipY),d.pixelStorei(X8,S.premultiplyAlpha),d.pixelStorei(K8,S.colorSpace),d.pixelStorei(H8,S.unpackAlignment)}function ht(){rt.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function xt(S,q){var j=null;if(Xy(q)?j=q:q&&(g.type(q,"object","invalid pixel data type"),Vt(S,q),"x"in q&&(S.xOffset=q.x|0),"y"in q&&(S.yOffset=q.y|0),Xy(q.data)&&(j=q.data)),g(!S.compressed||j instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),q.copy){g(!j,"can not specify copy and data field for the same texture");var Pt=nt.viewportWidth,je=nt.viewportHeight;S.width=S.width||Pt-S.xOffset,S.height=S.height||je-S.yOffset,S.needsCopy=!0,g(S.xOffset>=0&&S.xOffset<Pt&&S.yOffset>=0&&S.yOffset<je&&S.width>0&&S.width<=Pt&&S.height>0&&S.height<=je,"copy texture read out of bounds")}else if(!j)S.width=S.width||1,S.height=S.height||1,S.channels=S.channels||4;else if(n(j))S.channels=S.channels||4,S.data=j,!("type"in q)&&S.type===Rl&&(S.type=xE(j));else if(EE(j))S.channels=S.channels||4,r4(S,j),S.alignment=1,S.needsFree=!0;else if(ms(j)){var b=j.data;!Array.isArray(b)&&S.type===Rl&&(S.type=xE(b));var y=j.shape,x=j.stride,C,V,N,R,M,v;y.length===3?(N=y[2],v=x[2]):(g(y.length===2,"invalid ndarray pixel data, must be 2 or 3D"),N=1,v=1),C=y[0],V=y[1],R=x[0],M=x[1],S.alignment=1,S.width=C,S.height=V,S.channels=N,S.format=S.internalformat=dh[N],S.needsFree=!0,i4(S,b,R,M,v,j.offset)}else if(TE(j)||AE(j)||Z8(j))TE(j)||AE(j)?S.element=j:S.element=j.canvas,S.width=S.element.width,S.height=S.element.height,S.channels=4;else if(t4(j))S.element=j,S.width=j.width,S.height=j.height,S.channels=4;else if(e4(j))S.element=j,S.width=j.naturalWidth,S.height=j.naturalHeight,S.channels=4;else if(n4(j))S.element=j,S.width=j.videoWidth,S.height=j.videoHeight,S.channels=4;else if(IE(j)){var A=S.width||j[0].length,w=S.height||j.length,P=S.channels;ar(j[0][0])?P=P||j[0][0].length:P=P||1;for(var G=rh.shape(j),it=1,Et=0;Et<G.length;++Et)it*=G[Et];var It=RE(S,it);rh.flatten(j,G,"",It),NE(S,It),S.alignment=1,S.width=A,S.height=w,S.channels=P,S.format=S.internalformat=dh[P],S.needsFree=!0}S.type===Yc?g(I.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):S.type===xl&&g(I.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function Rt(S,q,j){var Pt=S.element,je=S.data,b=S.internalformat,y=S.format,x=S.type,C=S.width,V=S.height;At(S),Pt?d.texImage2D(q,j,y,y,x,Pt):S.compressed?d.compressedTexImage2D(q,j,b,C,V,0,je):S.needsCopy?(W(),d.copyTexImage2D(q,j,y,S.xOffset,S.yOffset,C,V,0)):d.texImage2D(q,j,y,C,V,0,y,x,je||null)}function me(S,q,j,Pt,je){var b=S.element,y=S.data,x=S.internalformat,C=S.format,V=S.type,N=S.width,R=S.height;At(S),b?d.texSubImage2D(q,je,j,Pt,C,V,b):S.compressed?d.compressedTexSubImage2D(q,je,j,Pt,x,N,R,y):S.needsCopy?(W(),d.copyTexSubImage2D(q,je,j,Pt,S.xOffset,S.yOffset,N,R)):d.texSubImage2D(q,je,j,Pt,N,R,C,V,y)}var de=[];function Bt(){return de.pop()||new ht}function Lt(S){S.needsFree&&Xt.freeType(S.data),ht.call(S),de.push(S)}function ie(){rt.call(this),this.genMipmaps=!1,this.mipmapHint=uh,this.mipmask=0,this.images=Array(16)}function pe(S,q,j){var Pt=S.images[0]=Bt();S.mipmask=1,Pt.width=S.width=q,Pt.height=S.height=j,Pt.channels=S.channels=4}function We(S,q){var j=null;if(Xy(q))j=S.images[0]=Bt(),et(j,S),xt(j,q),S.mipmask=1;else if(Vt(S,q),Array.isArray(q.mipmap))for(var Pt=q.mipmap,je=0;je<Pt.length;++je)j=S.images[je]=Bt(),et(j,S),j.width>>=je,j.height>>=je,xt(j,Pt[je]),S.mipmask|=1<<je;else j=S.images[0]=Bt(),et(j,S),xt(j,q),S.mipmask=1;et(S,S.images[0]),S.compressed&&(S.internalformat===Py||S.internalformat===$y||S.internalformat===Vy||S.internalformat===zy)&&g(S.width%4===0&&S.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function qn(S,q){for(var j=S.images,Pt=0;Pt<j.length;++Pt){if(!j[Pt])return;Rt(j[Pt],q,Pt)}}var Jn=[];function qe(){var S=Jn.pop()||new ie;rt.call(S),S.mipmask=0;for(var q=0;q<16;++q)S.images[q]=null;return S}function vr(S){for(var q=S.images,j=0;j<q.length;++j)q[j]&&Lt(q[j]),q[j]=null;Jn.push(S)}function Vn(){this.minFilter=Wy,this.magFilter=Wy,this.wrapS=Yy,this.wrapT=Yy,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=uh}function pr(S,q){if("min"in q){var j=q.min;g.parameter(j,vt),S.minFilter=vt[j],Q8.indexOf(S.minFilter)>=0&&!("faces"in q)&&(S.genMipmaps=!0)}if("mag"in q){var Pt=q.mag;g.parameter(Pt,yt),S.magFilter=yt[Pt]}var je=S.wrapS,b=S.wrapT;if("wrap"in q){var y=q.wrap;typeof y=="string"?(g.parameter(y,ut),je=b=ut[y]):Array.isArray(y)&&(g.parameter(y[0],ut),g.parameter(y[1],ut),je=ut[y[0]],b=ut[y[1]])}else{if("wrapS"in q){var x=q.wrapS;g.parameter(x,ut),je=ut[x]}if("wrapT"in q){var C=q.wrapT;g.parameter(C,ut),b=ut[C]}}if(S.wrapS=je,S.wrapT=b,"anisotropic"in q){var V=q.anisotropic;g(typeof V=="number"&&V>=1&&V<=I.maxAnisotropic,"aniso samples must be between 1 and "),S.anisotropic=q.anisotropic}if("mipmap"in q){var N=!1;switch(typeof q.mipmap){case"string":g.parameter(q.mipmap,dt,"invalid mipmap hint"),S.mipmapHint=dt[q.mipmap],S.genMipmaps=!0,N=!0;break;case"boolean":N=S.genMipmaps=q.mipmap;break;case"object":g(Array.isArray(q.mipmap),"invalid mipmap type"),S.genMipmaps=!1,N=!0;break;default:g.raise("invalid mipmap type")}N&&!("min"in q)&&(S.minFilter=Hy)}}function br(S,q){d.texParameteri(q,V8,S.minFilter),d.texParameteri(q,$8,S.magFilter),d.texParameteri(q,C8,S.wrapS),d.texParameteri(q,k8,S.wrapT),_.ext_texture_filter_anisotropic&&d.texParameteri(q,W8,S.anisotropic),S.genMipmaps&&(d.hint(G8,S.mipmapHint),d.generateMipmap(q))}var wr=0,Or={},Pr=I.maxTextureUnits,or=Array(Pr).map(function(){return null});function Le(S){rt.call(this),this.mipmask=0,this.internalformat=To,this.id=wr++,this.refCount=1,this.target=S,this.texture=d.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new Vn,Q.profile&&(this.stats={size:0})}function $r(S){d.activeTexture(Wc),d.bindTexture(S.target,S.texture)}function ln(){var S=or[0];S?d.bindTexture(S.target,S.texture):d.bindTexture(Gs,null)}function re(S){var q=S.texture;g(q,"must not double destroy texture");var j=S.unit,Pt=S.target;j>=0&&(d.activeTexture(Wc+j),d.bindTexture(Pt,null),or[j]=null),d.deleteTexture(q),S.texture=null,S.params=null,S.pixels=null,S.refCount=0,delete Or[S.id],Y.textureCount--}r(Le.prototype,{bind:function(){var S=this;S.bindCount+=1;var q=S.unit;if(q<0){for(var j=0;j<Pr;++j){var Pt=or[j];if(Pt){if(Pt.bindCount>0)continue;Pt.unit=-1}or[j]=S,q=j;break}q>=Pr&&g.raise("insufficient number of texture units"),Q.profile&&Y.maxTextureUnits<q+1&&(Y.maxTextureUnits=q+1),S.unit=q,d.activeTexture(Wc+q),d.bindTexture(S.target,S.texture)}return q},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&re(this)}});function He(S,q){var j=new Le(Gs);Or[j.id]=j,Y.textureCount++;function Pt(y,x){var C=j.texInfo;Vn.call(C);var V=qe();return typeof y=="number"?typeof x=="number"?pe(V,y|0,x|0):pe(V,y|0,y|0):y?(g.type(y,"object","invalid arguments to regl.texture"),pr(C,y),We(V,y)):pe(V,1,1),C.genMipmaps&&(V.mipmask=(V.width<<1)-1),j.mipmask=V.mipmask,et(j,V),g.texture2D(C,V,I),j.internalformat=V.internalformat,Pt.width=V.width,Pt.height=V.height,$r(j),qn(V,Gs),br(C,Gs),ln(),vr(V),Q.profile&&(j.stats.size=fh(j.internalformat,j.type,V.width,V.height,C.genMipmaps,!1)),Pt.format=pt[j.internalformat],Pt.type=Mt[j.type],Pt.mag=ot[C.magFilter],Pt.min=Dt[C.minFilter],Pt.wrapS=Nt[C.wrapS],Pt.wrapT=Nt[C.wrapT],Pt}function je(y,x,C,V){g(!!y,"must specify image data");var N=x|0,R=C|0,M=V|0,v=Bt();return et(v,j),v.width=0,v.height=0,xt(v,y),v.width=v.width||(j.width>>M)-N,v.height=v.height||(j.height>>M)-R,g(j.type===v.type&&j.format===v.format&&j.internalformat===v.internalformat,"incompatible format for texture.subimage"),g(N>=0&&R>=0&&N+v.width<=j.width&&R+v.height<=j.height,"texture.subimage write out of bounds"),g(j.mipmask&1<<M,"missing mipmap data"),g(v.data||v.element||v.needsCopy,"missing image data"),$r(j),me(v,Gs,N,R,M),ln(),Lt(v),Pt}function b(y,x){var C=y|0,V=x|0||C;if(C===j.width&&V===j.height)return Pt;Pt.width=j.width=C,Pt.height=j.height=V,$r(j);for(var N=0;j.mipmask>>N;++N){var R=C>>N,M=V>>N;if(!R||!M)break;d.texImage2D(Gs,N,j.format,R,M,0,j.format,j.type,null)}return ln(),Q.profile&&(j.stats.size=fh(j.internalformat,j.type,C,V,!1,!1)),Pt}return Pt(S,q),Pt.subimage=je,Pt.resize=b,Pt._reglType="texture2d",Pt._texture=j,Q.profile&&(Pt.stats=j.stats),Pt.destroy=function(){j.decRef()},Pt}function Ze(S,q,j,Pt,je,b){var y=new Le(Fy);Or[y.id]=y,Y.cubeCount++;var x=new Array(6);function C(R,M,v,A,w,P){var G,it=y.texInfo;for(Vn.call(it),G=0;G<6;++G)x[G]=qe();if(typeof R=="number"||!R){var Et=R|0||1;for(G=0;G<6;++G)pe(x[G],Et,Et)}else if(typeof R=="object")if(M)We(x[0],R),We(x[1],M),We(x[2],v),We(x[3],A),We(x[4],w),We(x[5],P);else if(pr(it,R),Vt(y,R),"faces"in R){var It=R.faces;for(g(Array.isArray(It)&&It.length===6,"cube faces must be a length 6 array"),G=0;G<6;++G)g(typeof It[G]=="object"&&!!It[G],"invalid input for cube map face"),et(x[G],y),We(x[G],It[G])}else for(G=0;G<6;++G)We(x[G],R);else g.raise("invalid arguments to cube map");for(et(y,x[0]),g.optional(function(){I.npotTextureCube||g(rE(y.width)&&rE(y.height),"your browser does not support non power or two texture dimensions")}),it.genMipmaps?y.mipmask=(x[0].width<<1)-1:y.mipmask=x[0].mipmask,g.textureCube(y,it,x,I),y.internalformat=x[0].internalformat,C.width=x[0].width,C.height=x[0].height,$r(y),G=0;G<6;++G)qn(x[G],ah+G);for(br(it,Fy),ln(),Q.profile&&(y.stats.size=fh(y.internalformat,y.type,C.width,C.height,it.genMipmaps,!0)),C.format=pt[y.internalformat],C.type=Mt[y.type],C.mag=ot[it.magFilter],C.min=Dt[it.minFilter],C.wrapS=Nt[it.wrapS],C.wrapT=Nt[it.wrapT],G=0;G<6;++G)vr(x[G]);return C}function V(R,M,v,A,w){g(!!M,"must specify image data"),g(typeof R=="number"&&R===(R|0)&&R>=0&&R<6,"invalid face");var P=v|0,G=A|0,it=w|0,Et=Bt();return et(Et,y),Et.width=0,Et.height=0,xt(Et,M),Et.width=Et.width||(y.width>>it)-P,Et.height=Et.height||(y.height>>it)-G,g(y.type===Et.type&&y.format===Et.format&&y.internalformat===Et.internalformat,"incompatible format for texture.subimage"),g(P>=0&&G>=0&&P+Et.width<=y.width&&G+Et.height<=y.height,"texture.subimage write out of bounds"),g(y.mipmask&1<<it,"missing mipmap data"),g(Et.data||Et.element||Et.needsCopy,"missing image data"),$r(y),me(Et,ah+R,P,G,it),ln(),Lt(Et),C}function N(R){var M=R|0;if(M!==y.width){C.width=y.width=M,C.height=y.height=M,$r(y);for(var v=0;v<6;++v)for(var A=0;y.mipmask>>A;++A)d.texImage2D(ah+v,A,y.format,M>>A,M>>A,0,y.format,y.type,null);return ln(),Q.profile&&(y.stats.size=fh(y.internalformat,y.type,C.width,C.height,!1,!0)),C}}return C(S,q,j,Pt,je,b),C.subimage=V,C.resize=N,C._reglType="textureCube",C._texture=y,Q.profile&&(C.stats=y.stats),C.destroy=function(){y.decRef()},C}function lr(){for(var S=0;S<Pr;++S)d.activeTexture(Wc+S),d.bindTexture(Gs,null),or[S]=null;Ci(Or).forEach(re),Y.cubeCount=0,Y.textureCount=0}Q.profile&&(Y.getTotalTextureSize=function(){var S=0;return Object.keys(Or).forEach(function(q){S+=Or[q].stats.size}),S});function Ys(){for(var S=0;S<Pr;++S){var q=or[S];q&&(q.bindCount=0,q.unit=-1,or[S]=null)}Ci(Or).forEach(function(j){j.texture=d.createTexture(),d.bindTexture(j.target,j.texture);for(var Pt=0;Pt<32;++Pt)if((j.mipmask&1<<Pt)!==0)if(j.target===Gs)d.texImage2D(Gs,Pt,j.internalformat,j.width>>Pt,j.height>>Pt,0,j.internalformat,j.type,null);else for(var je=0;je<6;++je)d.texImage2D(ah+je,Pt,j.internalformat,j.width>>Pt,j.height>>Pt,0,j.internalformat,j.type,null);br(j.texInfo,j.target)})}function Fo(){for(var S=0;S<Pr;++S){var q=or[S];q&&(q.bindCount=0,q.unit=-1,or[S]=null),d.activeTexture(Wc+S),d.bindTexture(Gs,null),d.bindTexture(Fy,null)}}return{create2D:He,createCube:Ze,clear:lr,getTexture:function(S){return null},restore:Ys,refresh:Fo}}var Ha=36161,hh=32854,BE=32855,OE=36194,DE=33189,FE=36168,LE=34041,ME=35907,CE=34836,kE=34842,UE=34843,ys=[];ys[hh]=2,ys[BE]=2,ys[OE]=2,ys[DE]=2,ys[FE]=1,ys[LE]=4,ys[ME]=4,ys[CE]=16,ys[kE]=8,ys[UE]=6;function PE(d,_,I){return ys[d]*_*I}var a4=function(d,_,I,W,nt){var Y={rgba4:hh,rgb565:OE,"rgb5 a1":BE,depth:DE,stencil:FE,"depth stencil":LE};_.ext_srgb&&(Y.srgba=ME),_.ext_color_buffer_half_float&&(Y.rgba16f=kE,Y.rgb16f=UE),_.webgl_color_buffer_float&&(Y.rgba32f=CE);var Q=[];Object.keys(Y).forEach(function(ft){var mt=Y[ft];Q[mt]=ft});var dt=0,ut={};function yt(ft){this.id=dt++,this.refCount=1,this.renderbuffer=ft,this.format=hh,this.width=0,this.height=0,nt.profile&&(this.stats={size:0})}yt.prototype.decRef=function(){--this.refCount<=0&&vt(this)};function vt(ft){var mt=ft.renderbuffer;g(mt,"must not double destroy renderbuffer"),d.bindRenderbuffer(Ha,null),d.deleteRenderbuffer(mt),ft.renderbuffer=null,ft.refCount=0,delete ut[ft.id],W.renderbufferCount--}function gt(ft,mt){var k=new yt(d.createRenderbuffer());ut[k.id]=k,W.renderbufferCount++;function K(Mt,ot){var Dt=0,Nt=0,ee=hh;if(typeof Mt=="object"&&Mt){var rt=Mt;if("shape"in rt){var et=rt.shape;g(Array.isArray(et)&&et.length>=2,"invalid renderbuffer shape"),Dt=et[0]|0,Nt=et[1]|0}else"radius"in rt&&(Dt=Nt=rt.radius|0),"width"in rt&&(Dt=rt.width|0),"height"in rt&&(Nt=rt.height|0);"format"in rt&&(g.parameter(rt.format,Y,"invalid renderbuffer format"),ee=Y[rt.format])}else typeof Mt=="number"?(Dt=Mt|0,typeof ot=="number"?Nt=ot|0:Nt=Dt):Mt?g.raise("invalid arguments to renderbuffer constructor"):Dt=Nt=1;if(g(Dt>0&&Nt>0&&Dt<=I.maxRenderbufferSize&&Nt<=I.maxRenderbufferSize,"invalid renderbuffer size"),!(Dt===k.width&&Nt===k.height&&ee===k.format))return K.width=k.width=Dt,K.height=k.height=Nt,k.format=ee,d.bindRenderbuffer(Ha,k.renderbuffer),d.renderbufferStorage(Ha,ee,Dt,Nt),g(d.getError()===0,"invalid render buffer format"),nt.profile&&(k.stats.size=PE(k.format,k.width,k.height)),K.format=Q[k.format],K}function pt(Mt,ot){var Dt=Mt|0,Nt=ot|0||Dt;return Dt===k.width&&Nt===k.height||(g(Dt>0&&Nt>0&&Dt<=I.maxRenderbufferSize&&Nt<=I.maxRenderbufferSize,"invalid renderbuffer size"),K.width=k.width=Dt,K.height=k.height=Nt,d.bindRenderbuffer(Ha,k.renderbuffer),d.renderbufferStorage(Ha,k.format,Dt,Nt),g(d.getError()===0,"invalid render buffer format"),nt.profile&&(k.stats.size=PE(k.format,k.width,k.height))),K}return K(ft,mt),K.resize=pt,K._reglType="renderbuffer",K._renderbuffer=k,nt.profile&&(K.stats=k.stats),K.destroy=function(){k.decRef()},K}nt.profile&&(W.getTotalRenderbufferSize=function(){var ft=0;return Object.keys(ut).forEach(function(mt){ft+=ut[mt].stats.size}),ft});function Tt(){Ci(ut).forEach(function(ft){ft.renderbuffer=d.createRenderbuffer(),d.bindRenderbuffer(Ha,ft.renderbuffer),d.renderbufferStorage(Ha,ft.format,ft.width,ft.height)}),d.bindRenderbuffer(Ha,null)}return{create:gt,clear:function(){Ci(ut).forEach(vt)},restore:Tt}},ba=36160,Ky=36161,xo=3553,ph=34069,$E=36064,VE=36096,zE=36128,GE=33306,jE=36053,o4=36054,l4=36055,c4=36057,u4=36061,d4=36193,f4=5121,h4=5126,YE=6407,WE=6408,p4=6402,m4=[YE,WE],Qy=[];Qy[WE]=4,Qy[YE]=3;var mh=[];mh[f4]=1,mh[h4]=4,mh[d4]=2;var y4=32854,g4=32855,_4=36194,v4=33189,b4=36168,HE=34041,w4=35907,S4=34836,E4=34842,I4=34843,T4=[y4,g4,_4,w4,E4,I4,S4],Ol={};Ol[jE]="complete",Ol[o4]="incomplete attachment",Ol[c4]="incomplete dimensions",Ol[l4]="incomplete, missing attachment",Ol[u4]="unsupported";function A4(d,_,I,W,nt,Y){var Q={cur:null,next:null,dirty:!1,setFBO:null},dt=["rgba"],ut=["rgba4","rgb565","rgb5 a1"];_.ext_srgb&&ut.push("srgba"),_.ext_color_buffer_half_float&&ut.push("rgba16f","rgb16f"),_.webgl_color_buffer_float&&ut.push("rgba32f");var yt=["uint8"];_.oes_texture_half_float&&yt.push("half float","float16"),_.oes_texture_float&&yt.push("float","float32");function vt(ht,xt,Rt){this.target=ht,this.texture=xt,this.renderbuffer=Rt;var me=0,de=0;xt?(me=xt.width,de=xt.height):Rt&&(me=Rt.width,de=Rt.height),this.width=me,this.height=de}function gt(ht){ht&&(ht.texture&&ht.texture._texture.decRef(),ht.renderbuffer&&ht.renderbuffer._renderbuffer.decRef())}function Tt(ht,xt,Rt){if(ht)if(ht.texture){var me=ht.texture._texture,de=Math.max(1,me.width),Bt=Math.max(1,me.height);g(de===xt&&Bt===Rt,"inconsistent width/height for supplied texture"),me.refCount+=1}else{var Lt=ht.renderbuffer._renderbuffer;g(Lt.width===xt&&Lt.height===Rt,"inconsistent width/height for renderbuffer"),Lt.refCount+=1}}function ft(ht,xt){xt&&(xt.texture?d.framebufferTexture2D(ba,ht,xt.target,xt.texture._texture.texture,0):d.framebufferRenderbuffer(ba,ht,Ky,xt.renderbuffer._renderbuffer.renderbuffer))}function mt(ht){var xt=xo,Rt=null,me=null,de=ht;typeof ht=="object"&&(de=ht.data,"target"in ht&&(xt=ht.target|0)),g.type(de,"function","invalid attachment data");var Bt=de._reglType;return Bt==="texture2d"?(Rt=de,g(xt===xo)):Bt==="textureCube"?(Rt=de,g(xt>=ph&&xt<ph+6,"invalid cube map target")):Bt==="renderbuffer"?(me=de,xt=Ky):g.raise("invalid regl object for attachment"),new vt(xt,Rt,me)}function k(ht,xt,Rt,me,de){if(Rt){var Bt=W.create2D({width:ht,height:xt,format:me,type:de});return Bt._texture.refCount=0,new vt(xo,Bt,null)}else{var Lt=nt.create({width:ht,height:xt,format:me});return Lt._renderbuffer.refCount=0,new vt(Ky,null,Lt)}}function K(ht){return ht&&(ht.texture||ht.renderbuffer)}function pt(ht,xt,Rt){ht&&(ht.texture?ht.texture.resize(xt,Rt):ht.renderbuffer&&ht.renderbuffer.resize(xt,Rt),ht.width=xt,ht.height=Rt)}var Mt=0,ot={};function Dt(){this.id=Mt++,ot[this.id]=this,this.framebuffer=d.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function Nt(ht){ht.colorAttachments.forEach(gt),gt(ht.depthAttachment),gt(ht.stencilAttachment),gt(ht.depthStencilAttachment)}function ee(ht){var xt=ht.framebuffer;g(xt,"must not double destroy framebuffer"),d.deleteFramebuffer(xt),ht.framebuffer=null,Y.framebufferCount--,delete ot[ht.id]}function rt(ht){var xt;d.bindFramebuffer(ba,ht.framebuffer);var Rt=ht.colorAttachments;for(xt=0;xt<Rt.length;++xt)ft($E+xt,Rt[xt]);for(xt=Rt.length;xt<I.maxColorAttachments;++xt)d.framebufferTexture2D(ba,$E+xt,xo,null,0);d.framebufferTexture2D(ba,GE,xo,null,0),d.framebufferTexture2D(ba,VE,xo,null,0),d.framebufferTexture2D(ba,zE,xo,null,0),ft(VE,ht.depthAttachment),ft(zE,ht.stencilAttachment),ft(GE,ht.depthStencilAttachment);var me=d.checkFramebufferStatus(ba);!d.isContextLost()&&me!==jE&&g.raise("framebuffer configuration not supported, status = "+Ol[me]),d.bindFramebuffer(ba,Q.next?Q.next.framebuffer:null),Q.cur=Q.next,d.getError()}function et(ht,xt){var Rt=new Dt;Y.framebufferCount++;function me(Bt,Lt){var ie;g(Q.next!==Rt,"can not update framebuffer which is currently in use");var pe=0,We=0,qn=!0,Jn=!0,qe=null,vr=!0,Vn="rgba",pr="uint8",br=1,wr=null,Or=null,Pr=null,or=!1;if(typeof Bt=="number")pe=Bt|0,We=Lt|0||pe;else if(!Bt)pe=We=1;else{g.type(Bt,"object","invalid arguments for framebuffer");var Le=Bt;if("shape"in Le){var $r=Le.shape;g(Array.isArray($r)&&$r.length>=2,"invalid shape for framebuffer"),pe=$r[0],We=$r[1]}else"radius"in Le&&(pe=We=Le.radius),"width"in Le&&(pe=Le.width),"height"in Le&&(We=Le.height);("color"in Le||"colors"in Le)&&(qe=Le.color||Le.colors,Array.isArray(qe)&&g(qe.length===1||_.webgl_draw_buffers,"multiple render targets not supported")),qe||("colorCount"in Le&&(br=Le.colorCount|0,g(br>0,"invalid color buffer count")),"colorTexture"in Le&&(vr=!!Le.colorTexture,Vn="rgba4"),"colorType"in Le&&(pr=Le.colorType,vr?(g(_.oes_texture_float||!(pr==="float"||pr==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),g(_.oes_texture_half_float||!(pr==="half float"||pr==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):pr==="half float"||pr==="float16"?(g(_.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),Vn="rgba16f"):(pr==="float"||pr==="float32")&&(g(_.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),Vn="rgba32f"),g.oneOf(pr,yt,"invalid color type")),"colorFormat"in Le&&(Vn=Le.colorFormat,dt.indexOf(Vn)>=0?vr=!0:ut.indexOf(Vn)>=0?vr=!1:g.optional(function(){vr?g.oneOf(Le.colorFormat,dt,"invalid color format for texture"):g.oneOf(Le.colorFormat,ut,"invalid color format for renderbuffer")}))),("depthTexture"in Le||"depthStencilTexture"in Le)&&(or=!!(Le.depthTexture||Le.depthStencilTexture),g(!or||_.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in Le&&(typeof Le.depth=="boolean"?qn=Le.depth:(wr=Le.depth,Jn=!1)),"stencil"in Le&&(typeof Le.stencil=="boolean"?Jn=Le.stencil:(Or=Le.stencil,qn=!1)),"depthStencil"in Le&&(typeof Le.depthStencil=="boolean"?qn=Jn=Le.depthStencil:(Pr=Le.depthStencil,qn=!1,Jn=!1))}var ln=null,re=null,He=null,Ze=null;if(Array.isArray(qe))ln=qe.map(mt);else if(qe)ln=[mt(qe)];else for(ln=new Array(br),ie=0;ie<br;++ie)ln[ie]=k(pe,We,vr,Vn,pr);g(_.webgl_draw_buffers||ln.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),g(ln.length<=I.maxColorAttachments,"too many color attachments, not supported"),pe=pe||ln[0].width,We=We||ln[0].height,wr?re=mt(wr):qn&&!Jn&&(re=k(pe,We,or,"depth","uint32")),Or?He=mt(Or):Jn&&!qn&&(He=k(pe,We,!1,"stencil","uint8")),Pr?Ze=mt(Pr):!wr&&!Or&&Jn&&qn&&(Ze=k(pe,We,or,"depth stencil","depth stencil")),g(!!wr+!!Or+!!Pr<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var lr=null;for(ie=0;ie<ln.length;++ie)if(Tt(ln[ie],pe,We),g(!ln[ie]||ln[ie].texture&&m4.indexOf(ln[ie].texture._texture.format)>=0||ln[ie].renderbuffer&&T4.indexOf(ln[ie].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+ie+" is invalid"),ln[ie]&&ln[ie].texture){var Ys=Qy[ln[ie].texture._texture.format]*mh[ln[ie].texture._texture.type];lr===null?lr=Ys:g(lr===Ys,"all color attachments much have the same number of bits per pixel.")}return Tt(re,pe,We),g(!re||re.texture&&re.texture._texture.format===p4||re.renderbuffer&&re.renderbuffer._renderbuffer.format===v4,"invalid depth attachment for framebuffer object"),Tt(He,pe,We),g(!He||He.renderbuffer&&He.renderbuffer._renderbuffer.format===b4,"invalid stencil attachment for framebuffer object"),Tt(Ze,pe,We),g(!Ze||Ze.texture&&Ze.texture._texture.format===HE||Ze.renderbuffer&&Ze.renderbuffer._renderbuffer.format===HE,"invalid depth-stencil attachment for framebuffer object"),Nt(Rt),Rt.width=pe,Rt.height=We,Rt.colorAttachments=ln,Rt.depthAttachment=re,Rt.stencilAttachment=He,Rt.depthStencilAttachment=Ze,me.color=ln.map(K),me.depth=K(re),me.stencil=K(He),me.depthStencil=K(Ze),me.width=Rt.width,me.height=Rt.height,rt(Rt),me}function de(Bt,Lt){g(Q.next!==Rt,"can not resize a framebuffer which is currently in use");var ie=Math.max(Bt|0,1),pe=Math.max(Lt|0||ie,1);if(ie===Rt.width&&pe===Rt.height)return me;for(var We=Rt.colorAttachments,qn=0;qn<We.length;++qn)pt(We[qn],ie,pe);return pt(Rt.depthAttachment,ie,pe),pt(Rt.stencilAttachment,ie,pe),pt(Rt.depthStencilAttachment,ie,pe),Rt.width=me.width=ie,Rt.height=me.height=pe,rt(Rt),me}return me(ht,xt),r(me,{resize:de,_reglType:"framebuffer",_framebuffer:Rt,destroy:function(){ee(Rt),Nt(Rt)},use:function(Bt){Q.setFBO({framebuffer:me},Bt)}})}function Vt(ht){var xt=Array(6);function Rt(de){var Bt;g(xt.indexOf(Q.next)<0,"can not update framebuffer which is currently in use");var Lt={color:null},ie=0,pe=null,We="rgba",qn="uint8",Jn=1;if(typeof de=="number")ie=de|0;else if(!de)ie=1;else{g.type(de,"object","invalid arguments for framebuffer");var qe=de;if("shape"in qe){var vr=qe.shape;g(Array.isArray(vr)&&vr.length>=2,"invalid shape for framebuffer"),g(vr[0]===vr[1],"cube framebuffer must be square"),ie=vr[0]}else"radius"in qe&&(ie=qe.radius|0),"width"in qe?(ie=qe.width|0,"height"in qe&&g(qe.height===ie,"must be square")):"height"in qe&&(ie=qe.height|0);("color"in qe||"colors"in qe)&&(pe=qe.color||qe.colors,Array.isArray(pe)&&g(pe.length===1||_.webgl_draw_buffers,"multiple render targets not supported")),pe||("colorCount"in qe&&(Jn=qe.colorCount|0,g(Jn>0,"invalid color buffer count")),"colorType"in qe&&(g.oneOf(qe.colorType,yt,"invalid color type"),qn=qe.colorType),"colorFormat"in qe&&(We=qe.colorFormat,g.oneOf(qe.colorFormat,dt,"invalid color format for texture"))),"depth"in qe&&(Lt.depth=qe.depth),"stencil"in qe&&(Lt.stencil=qe.stencil),"depthStencil"in qe&&(Lt.depthStencil=qe.depthStencil)}var Vn;if(pe)if(Array.isArray(pe))for(Vn=[],Bt=0;Bt<pe.length;++Bt)Vn[Bt]=pe[Bt];else Vn=[pe];else{Vn=Array(Jn);var pr={radius:ie,format:We,type:qn};for(Bt=0;Bt<Jn;++Bt)Vn[Bt]=W.createCube(pr)}for(Lt.color=Array(Vn.length),Bt=0;Bt<Vn.length;++Bt){var br=Vn[Bt];g(typeof br=="function"&&br._reglType==="textureCube","invalid cube map"),ie=ie||br.width,g(br.width===ie&&br.height===ie,"invalid cube map shape"),Lt.color[Bt]={target:ph,data:Vn[Bt]}}for(Bt=0;Bt<6;++Bt){for(var wr=0;wr<Vn.length;++wr)Lt.color[wr].target=ph+Bt;Bt>0&&(Lt.depth=xt[0].depth,Lt.stencil=xt[0].stencil,Lt.depthStencil=xt[0].depthStencil),xt[Bt]?xt[Bt](Lt):xt[Bt]=et(Lt)}return r(Rt,{width:ie,height:ie,color:Vn})}function me(de){var Bt,Lt=de|0;if(g(Lt>0&&Lt<=I.maxCubeMapSize,"invalid radius for cube fbo"),Lt===Rt.width)return Rt;var ie=Rt.color;for(Bt=0;Bt<ie.length;++Bt)ie[Bt].resize(Lt);for(Bt=0;Bt<6;++Bt)xt[Bt].resize(Lt);return Rt.width=Rt.height=Lt,Rt}return Rt(ht),r(Rt,{faces:xt,resize:me,_reglType:"framebufferCube",destroy:function(){xt.forEach(function(de){de.destroy()})}})}function At(){Q.cur=null,Q.next=null,Q.dirty=!0,Ci(ot).forEach(function(ht){ht.framebuffer=d.createFramebuffer(),rt(ht)})}return r(Q,{getFramebuffer:function(ht){if(typeof ht=="function"&&ht._reglType==="framebuffer"){var xt=ht._framebuffer;if(xt instanceof Dt)return xt}return null},create:et,createCube:Vt,clear:function(){Ci(ot).forEach(ee)},restore:At})}var x4=5126,qE=34962,yh=34963,XE=["attributes","elements","offset","count","primitive","instances"];function Jy(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=x4,this.offset=0,this.stride=0,this.divisor=0}function R4(d,_,I,W,nt,Y,Q){for(var dt=I.maxAttributes,ut=new Array(dt),yt=0;yt<dt;++yt)ut[yt]=new Jy;var vt=0,gt={},Tt={Record:Jy,scope:{},state:ut,currentVAO:null,targetVAO:null,restore:mt()?Nt:function(){},createVAO:ee,getVAO:K,destroyBuffer:ft,setVAO:mt()?pt:Mt,clear:mt()?ot:function(){}};function ft(rt){for(var et=0;et<ut.length;++et){var Vt=ut[et];Vt.buffer===rt&&(d.disableVertexAttribArray(et),Vt.buffer=null)}}function mt(){return _.oes_vertex_array_object}function k(){return _.angle_instanced_arrays}function K(rt){return typeof rt=="function"&&rt._vao?rt._vao:null}function pt(rt){if(rt!==Tt.currentVAO){var et=mt();rt?et.bindVertexArrayOES(rt.vao):et.bindVertexArrayOES(null),Tt.currentVAO=rt}}function Mt(rt){if(rt!==Tt.currentVAO){if(rt)rt.bindAttrs();else{for(var et=k(),Vt=0;Vt<ut.length;++Vt){var At=ut[Vt];At.buffer?(d.enableVertexAttribArray(Vt),At.buffer.bind(),d.vertexAttribPointer(Vt,At.size,At.type,At.normalized,At.stride,At.offfset),et&&At.divisor&&et.vertexAttribDivisorANGLE(Vt,At.divisor)):(d.disableVertexAttribArray(Vt),d.vertexAttrib4f(Vt,At.x,At.y,At.z,At.w))}Q.elements?d.bindBuffer(yh,Q.elements.buffer.buffer):d.bindBuffer(yh,null)}Tt.currentVAO=rt}}function ot(){Ci(gt).forEach(function(rt){rt.destroy()})}function Dt(){this.id=++vt,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var rt=mt();rt?this.vao=rt.createVertexArrayOES():this.vao=null,gt[this.id]=this,this.buffers=[]}Dt.prototype.bindAttrs=function(){for(var rt=k(),et=this.attributes,Vt=0;Vt<et.length;++Vt){var At=et[Vt];At.buffer?(d.enableVertexAttribArray(Vt),d.bindBuffer(qE,At.buffer.buffer),d.vertexAttribPointer(Vt,At.size,At.type,At.normalized,At.stride,At.offset),rt&&At.divisor&&rt.vertexAttribDivisorANGLE(Vt,At.divisor)):(d.disableVertexAttribArray(Vt),d.vertexAttrib4f(Vt,At.x,At.y,At.z,At.w))}for(var ht=et.length;ht<dt;++ht)d.disableVertexAttribArray(ht);var xt=Y.getElements(this.elements);xt?d.bindBuffer(yh,xt.buffer.buffer):d.bindBuffer(yh,null)},Dt.prototype.refresh=function(){var rt=mt();rt&&(rt.bindVertexArrayOES(this.vao),this.bindAttrs(),Tt.currentVAO=null,rt.bindVertexArrayOES(null))},Dt.prototype.destroy=function(){if(this.vao){var rt=mt();this===Tt.currentVAO&&(Tt.currentVAO=null,rt.bindVertexArrayOES(null)),rt.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),gt[this.id]&&(delete gt[this.id],W.vaoCount-=1)};function Nt(){var rt=mt();rt&&Ci(gt).forEach(function(et){et.refresh()})}function ee(rt){var et=new Dt;W.vaoCount+=1;function Vt(At){var ht;if(Array.isArray(At))ht=At,et.elements&&et.ownsElements&&et.elements.destroy(),et.elements=null,et.ownsElements=!1,et.offset=0,et.count=0,et.instances=-1,et.primitive=4;else{if(g(typeof At=="object","invalid arguments for create vao"),g("attributes"in At,"must specify attributes for vao"),At.elements){var xt=At.elements;et.ownsElements?typeof xt=="function"&&xt._reglType==="elements"?(et.elements.destroy(),et.ownsElements=!1):(et.elements(xt),et.ownsElements=!1):Y.getElements(At.elements)?(et.elements=At.elements,et.ownsElements=!1):(et.elements=Y.create(At.elements),et.ownsElements=!0)}else et.elements=null,et.ownsElements=!1;ht=At.attributes,et.offset=0,et.count=-1,et.instances=-1,et.primitive=4,et.elements&&(et.count=et.elements._elements.vertCount,et.primitive=et.elements._elements.primType),"offset"in At&&(et.offset=At.offset|0),"count"in At&&(et.count=At.count|0),"instances"in At&&(et.instances=At.instances|0),"primitive"in At&&(g(At.primitive in Wa,"bad primitive type: "+At.primitive),et.primitive=Wa[At.primitive]),g.optional(()=>{for(var qn=Object.keys(At),Jn=0;Jn<qn.length;++Jn)g(XE.indexOf(qn[Jn])>=0,'invalid option for vao: "'+qn[Jn]+'" valid options are '+XE)}),g(Array.isArray(ht),"attributes must be an array")}g(ht.length<dt,"too many attributes"),g(ht.length>0,"must specify at least one attribute");var Rt={},me=et.attributes;me.length=ht.length;for(var de=0;de<ht.length;++de){var Bt=ht[de],Lt=me[de]=new Jy,ie=Bt.data||Bt;if(Array.isArray(ie)||n(ie)||ms(ie)){var pe;et.buffers[de]&&(pe=et.buffers[de],n(ie)&&pe._buffer.byteLength>=ie.byteLength?pe.subdata(ie):(pe.destroy(),et.buffers[de]=null)),et.buffers[de]||(pe=et.buffers[de]=nt.create(Bt,qE,!1,!0)),Lt.buffer=nt.getBuffer(pe),Lt.size=Lt.buffer.dimension|0,Lt.normalized=!1,Lt.type=Lt.buffer.dtype,Lt.offset=0,Lt.stride=0,Lt.divisor=0,Lt.state=1,Rt[de]=1}else nt.getBuffer(Bt)?(Lt.buffer=nt.getBuffer(Bt),Lt.size=Lt.buffer.dimension|0,Lt.normalized=!1,Lt.type=Lt.buffer.dtype,Lt.offset=0,Lt.stride=0,Lt.divisor=0,Lt.state=1):nt.getBuffer(Bt.buffer)?(Lt.buffer=nt.getBuffer(Bt.buffer),Lt.size=(+Bt.size||Lt.buffer.dimension)|0,Lt.normalized=!!Bt.normalized||!1,"type"in Bt?(g.parameter(Bt.type,Eo,"invalid buffer type"),Lt.type=Eo[Bt.type]):Lt.type=Lt.buffer.dtype,Lt.offset=(Bt.offset||0)|0,Lt.stride=(Bt.stride||0)|0,Lt.divisor=(Bt.divisor||0)|0,Lt.state=1,g(Lt.size>=1&&Lt.size<=4,"size must be between 1 and 4"),g(Lt.offset>=0,"invalid offset"),g(Lt.stride>=0&&Lt.stride<=255,"stride must be between 0 and 255"),g(Lt.divisor>=0,"divisor must be positive"),g(!Lt.divisor||!!_.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in Bt?(g(de>0,"first attribute must not be a constant"),Lt.x=+Bt.x||0,Lt.y=+Bt.y||0,Lt.z=+Bt.z||0,Lt.w=+Bt.w||0,Lt.state=2):g(!1,"invalid attribute spec for location "+de)}for(var We=0;We<et.buffers.length;++We)!Rt[We]&&et.buffers[We]&&(et.buffers[We].destroy(),et.buffers[We]=null);return et.refresh(),Vt}return Vt.destroy=function(){for(var At=0;At<et.buffers.length;++At)et.buffers[At]&&et.buffers[At].destroy();et.buffers.length=0,et.ownsElements&&(et.elements.destroy(),et.elements=null,et.ownsElements=!1),et.destroy()},Vt._vao=et,Vt._reglType="vao",Vt(rt)}return Tt}var KE=35632,N4=35633,B4=35718,O4=35721;function D4(d,_,I,W){var nt={},Y={};function Q(k,K,pt,Mt){this.name=k,this.id=K,this.location=pt,this.info=Mt}function dt(k,K){for(var pt=0;pt<k.length;++pt)if(k[pt].id===K.id){k[pt].location=K.location;return}k.push(K)}function ut(k,K,pt){var Mt=k===KE?nt:Y,ot=Mt[K];if(!ot){var Dt=_.str(K);ot=d.createShader(k),d.shaderSource(ot,Dt),d.compileShader(ot),g.shaderError(d,ot,Dt,k,pt),Mt[K]=ot}return ot}var yt={},vt=[],gt=0;function Tt(k,K){this.id=gt++,this.fragId=k,this.vertId=K,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,W.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function ft(k,K,pt){var Mt,ot,Dt=ut(KE,k.fragId),Nt=ut(N4,k.vertId),ee=k.program=d.createProgram();if(d.attachShader(ee,Dt),d.attachShader(ee,Nt),pt)for(Mt=0;Mt<pt.length;++Mt){var rt=pt[Mt];d.bindAttribLocation(ee,rt[0],rt[1])}d.linkProgram(ee),g.linkError(d,ee,_.str(k.fragId),_.str(k.vertId),K);var et=d.getProgramParameter(ee,B4);W.profile&&(k.stats.uniformsCount=et);var Vt=k.uniforms;for(Mt=0;Mt<et;++Mt)if(ot=d.getActiveUniform(ee,Mt),ot)if(ot.size>1)for(var At=0;At<ot.size;++At){var ht=ot.name.replace("[0]","["+At+"]");dt(Vt,new Q(ht,_.id(ht),d.getUniformLocation(ee,ht),ot))}else dt(Vt,new Q(ot.name,_.id(ot.name),d.getUniformLocation(ee,ot.name),ot));var xt=d.getProgramParameter(ee,O4);W.profile&&(k.stats.attributesCount=xt);var Rt=k.attributes;for(Mt=0;Mt<xt;++Mt)ot=d.getActiveAttrib(ee,Mt),ot&&dt(Rt,new Q(ot.name,_.id(ot.name),d.getAttribLocation(ee,ot.name),ot))}W.profile&&(I.getMaxUniformsCount=function(){var k=0;return vt.forEach(function(K){K.stats.uniformsCount>k&&(k=K.stats.uniformsCount)}),k},I.getMaxAttributesCount=function(){var k=0;return vt.forEach(function(K){K.stats.attributesCount>k&&(k=K.stats.attributesCount)}),k});function mt(){nt={},Y={};for(var k=0;k<vt.length;++k)ft(vt[k],null,vt[k].attributes.map(function(K){return[K.location,K.name]}))}return{clear:function(){var k=d.deleteShader.bind(d);Ci(nt).forEach(k),nt={},Ci(Y).forEach(k),Y={},vt.forEach(function(K){d.deleteProgram(K.program)}),vt.length=0,yt={},I.shaderCount=0},program:function(k,K,pt,Mt){g.command(k>=0,"missing vertex shader",pt),g.command(K>=0,"missing fragment shader",pt);var ot=yt[K];ot||(ot=yt[K]={});var Dt=ot[k];if(Dt&&(Dt.refCount++,!Mt))return Dt;var Nt=new Tt(K,k);return I.shaderCount++,ft(Nt,pt,Mt),Dt||(ot[k]=Nt),vt.push(Nt),r(Nt,{destroy:function(){if(Nt.refCount--,Nt.refCount<=0){d.deleteProgram(Nt.program);var ee=vt.indexOf(Nt);vt.splice(ee,1),I.shaderCount--}ot[Nt.vertId].refCount<=0&&(d.deleteShader(Y[Nt.vertId]),delete Y[Nt.vertId],delete yt[Nt.fragId][Nt.vertId]),Object.keys(yt[Nt.fragId]).length||(d.deleteShader(nt[Nt.fragId]),delete nt[Nt.fragId],delete yt[Nt.fragId])}})},restore:mt,shader:ut,frag:-1,vert:-1}}var F4=6408,Hc=5121,L4=3333,gh=5126;function M4(d,_,I,W,nt,Y,Q){function dt(vt){var gt;_.next===null?(g(nt.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),gt=Hc):(g(_.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),gt=_.next.colorAttachments[0].texture._texture.type,g.optional(function(){Y.oes_texture_float?(g(gt===Hc||gt===gh,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),gt===gh&&g(Q.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):g(gt===Hc,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var Tt=0,ft=0,mt=W.framebufferWidth,k=W.framebufferHeight,K=null;n(vt)?K=vt:vt&&(g.type(vt,"object","invalid arguments to regl.read()"),Tt=vt.x|0,ft=vt.y|0,g(Tt>=0&&Tt<W.framebufferWidth,"invalid x offset for regl.read"),g(ft>=0&&ft<W.framebufferHeight,"invalid y offset for regl.read"),mt=(vt.width||W.framebufferWidth-Tt)|0,k=(vt.height||W.framebufferHeight-ft)|0,K=vt.data||null),K&&(gt===Hc?g(K instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):gt===gh&&g(K instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),g(mt>0&&mt+Tt<=W.framebufferWidth,"invalid width for read pixels"),g(k>0&&k+ft<=W.framebufferHeight,"invalid height for read pixels"),I();var pt=mt*k*4;return K||(gt===Hc?K=new Uint8Array(pt):gt===gh&&(K=K||new Float32Array(pt))),g.isTypedArray(K,"data buffer for regl.read() must be a typedarray"),g(K.byteLength>=pt,"data buffer for regl.read() too small"),d.pixelStorei(L4,4),d.readPixels(Tt,ft,mt,k,F4,gt,K),K}function ut(vt){var gt;return _.setFBO({framebuffer:vt.framebuffer},function(){gt=dt(vt)}),gt}function yt(vt){return!vt||!("framebuffer"in vt)?dt(vt):ut(vt)}return yt}function Dl(d){return Array.prototype.slice.call(d)}function Fl(d){return Dl(d).join("")}function C4(){var d=0,_=[],I=[];function W(gt){for(var Tt=0;Tt<I.length;++Tt)if(I[Tt]===gt)return _[Tt];var ft="g"+d++;return _.push(ft),I.push(gt),ft}function nt(){var gt=[];function Tt(){gt.push.apply(gt,Dl(arguments))}var ft=[];function mt(){var k="v"+d++;return ft.push(k),arguments.length>0&&(gt.push(k,"="),gt.push.apply(gt,Dl(arguments)),gt.push(";")),k}return r(Tt,{def:mt,toString:function(){return Fl([ft.length>0?"var "+ft.join(",")+";":"",Fl(gt)])}})}function Y(){var gt=nt(),Tt=nt(),ft=gt.toString,mt=Tt.toString;function k(K,pt){Tt(K,pt,"=",gt.def(K,pt),";")}return r(function(){gt.apply(gt,Dl(arguments))},{def:gt.def,entry:gt,exit:Tt,save:k,set:function(K,pt,Mt){k(K,pt),gt(K,pt,"=",Mt,";")},toString:function(){return ft()+mt()}})}function Q(){var gt=Fl(arguments),Tt=Y(),ft=Y(),mt=Tt.toString,k=ft.toString;return r(Tt,{then:function(){return Tt.apply(Tt,Dl(arguments)),this},else:function(){return ft.apply(ft,Dl(arguments)),this},toString:function(){var K=k();return K&&(K="else{"+K+"}"),Fl(["if(",gt,"){",mt(),"}",K])}})}var dt=nt(),ut={};function yt(gt,Tt){var ft=[];function mt(){var ot="a"+ft.length;return ft.push(ot),ot}Tt=Tt||0;for(var k=0;k<Tt;++k)mt();var K=Y(),pt=K.toString,Mt=ut[gt]=r(K,{arg:mt,toString:function(){return Fl(["function(",ft.join(),"){",pt(),"}"])}});return Mt}function vt(){var gt=['"use strict";',dt,"return {"];Object.keys(ut).forEach(function(mt){gt.push('"',mt,'":',ut[mt].toString(),",")}),gt.push("}");var Tt=Fl(gt).replace(/;/g,`;
88
+ `,p=await r.executeQuery(T,i.value);if(!p.length){u.value="No rows returned. Try different columns.",n.purge(S);return}const L=Array.from(new Set(p.map(J=>String(J.x)))),C=Array.from(new Set(p.map(J=>String(J.y)))),R=(J,Jt)=>`${J}\0${Jt}`,U=new Map;for(const J of p)U.set(R(String(J.x),String(J.y)),Number(J.p??0));const tt=C.map(J=>({type:"bar",name:J,x:L,y:L.map(Jt=>U.get(R(Jt,J))??0),hovertemplate:`${y.value}=%{fullData.name}<br>${h.value}=%{x}<br>Proportion=%{y:.1%}<extra></extra>`})),ht={title:`${y.value} proportions within ${h.value}`,barmode:"stack",yaxis:{range:[0,1],tickformat:".0%",title:"Proportion"},xaxis:{title:h.value},legend:{orientation:"h",y:-.2},margin:{t:48,r:16,b:96,l:56}};await n.newPlot(S,tt,ht,{responsive:!0});const ut=(L.length>=op?` Limited to top ${op} ${h.value}.`:"")+(C.length>=lp||C.includes(cp)?` Limited to top ${lp} ${y.value} (+ ${cp}).`:"");u.value=`Plotted ${C.length} categories across ${L.length} groups.${ut}`}catch(rt){console.error(rt),u.value=`Error: ${(rt==null?void 0:rt.message)||rt}`}finally{l.value=!1}}}async function xt(){}async function on(rt,ot){var m,T;const p=await xt(),L=`${ot}/packages/${rt}/view?api_key=${p}`,C=await fetch(L);if(!C.ok)return null;const R=await C.json();return(T=(m=R==null?void 0:R[0])==null?void 0:m.content)==null?void 0:T.id}async function ge(rt,ot,m){const T=await xt(),p=`${m}/packages/${rt}/files/${ot}?api_key=${T}`,L=await fetch(p);if(!L.ok)throw new Error(`file url failed: ${L.status}`);return(await L.json()).url}function ne(){return typeof window<"u"&&typeof document<"u"}async function Qt(){return ne()?n||(await new Promise((rt,ot)=>{const m=document.createElement("script");m.src="https://cdn.plot.ly/plotly-2.35.3.min.js",m.onload=()=>rt(),m.onerror=()=>ot(new Error("Failed to load Plotly CDN")),document.head.appendChild(m)}),n=window.Plotly,console.log(n),n):null}return c.onMounted(async()=>{await j(),await Qt()}),c.onBeforeUnmount(async()=>{i.value&&await r.closeConnection(i.value)}),(rt,ot)=>(c.openBlock(),c.createElementBlock("div",ON,[c.createElementVNode("div",DN,[c.createElementVNode("div",FN,[c.createElementVNode("div",LN,[ot[3]||(ot[3]=c.createElementVNode("label",null,"Data URL",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":ot[0]||(ot[0]=m=>a.value=m),type:"text",class:"pp-input pp-input--url",disabled:l.value,placeholder:"https://.../file.parquet"},null,8,MN),[[c.vModelText,a.value]])]),c.createElementVNode("div",CN,[c.createElementVNode("div",null,[ot[5]||(ot[5]=c.createElementVNode("label",null,"X (group) column",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":ot[1]||(ot[1]=m=>h.value=m),class:"pp-select",disabled:l.value||d.value.length===0},[ot[4]||(ot[4]=c.createElementVNode("option",{disabled:"",value:""},"— choose —",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(H.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name,value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,UN))),128)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(nt.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name+"-num",value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,PN))),128))],8,kN),[[c.vModelSelect,h.value]])]),c.createElementVNode("div",null,[ot[7]||(ot[7]=c.createElementVNode("label",null,"Y (category) column",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":ot[2]||(ot[2]=m=>y.value=m),class:"pp-select",disabled:l.value||d.value.length===0},[ot[6]||(ot[6]=c.createElementVNode("option",{disabled:"",value:""},"— choose —",-1)),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(H.value,m=>(c.openBlock(),c.createElementBlock("option",{key:m.name+"-y",value:m.name},c.toDisplayString(m.name)+" ("+c.toDisplayString(m.type)+")",9,VN))),128))],8,$N),[[c.vModelSelect,y.value]])])]),c.createElementVNode("div",zN,[c.createElementVNode("button",{class:"pp-btn pp-btn--primary",disabled:!h.value||!y.value||l.value||!i.value||!s.value,onClick:ie},c.toDisplayString(l.value?"Working…":"Plot"),9,GN),u.value?(c.openBlock(),c.createElementBlock("div",jN,c.toDisplayString(u.value),1)):c.createCommentVNode("",!0)])])]),c.createElementVNode("div",{id:S,class:"pp-plot"})]))}}),WN=ko(YN,[["__scopeId","data-v-1e3cf8a1"]]),HN="dashboard:globalVars";function Vo(e=!1){const t=c.inject(HN,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const qN={class:"data-explorer-wrap"},XN={class:"data-explorer-info"},KN=c.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=Vo(),n=c.ref("Data Explorer"),r=c.computed(()=>c.unref(t.s3Url));return c.watchEffect(()=>{}),(i,s)=>{const a=c.resolveComponent("el-icon");return c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),c.createElementVNode("div",qN,[c.createElementVNode("div",XN,[c.createVNode(c.unref(mT.ElTooltip),{placement:"top-start"},{content:c.withCtx(()=>[...s[0]||(s[0]=[c.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:c.withCtx(()=>[c.createVNode(a,{color:"#8300BF"},{default:c.withCtx(()=>[c.createVNode(c.unref(gT))]),_:1})]),_:1})]),c.createVNode(c.unref(GT),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),ea=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},QN=ea(KN,[["__scopeId","data-v-e47a9f7d"]]),JN={class:"umap-wrap"},ZN=ea(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=Vo(),n=c.ref("Data Explorer"),r=c.computed(()=>c.unref(t==null?void 0:t.s3Url));return(i,s)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),c.createElementVNode("div",JN,[c.createVNode(c.unref(BN),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-d8a1dc37"]]),tR={class:"proportion-plot-wrap"},eR=ea(c.defineComponent({inheritAttrs:!1,__name:"Proportion",setup(e){const t=Vo(),n=c.computed(()=>c.unref(t.s3Url));return(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",tR,[c.createVNode(c.unref(WN),{srcUrl:n.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-96c1c44d"]]),up=jg.defineStore("precisionGlobalVars",()=>{const e=c.ref(null),t=c.ref(null),n=c.ref(null),r=c.ref(null),i=c.ref(null);function s(h){e.value=h===""?null:h}function a(h){t.value=h===""?null:h}function o(h){n.value=h===""?null:h}function l(h){r.value=h===""?null:h}function u(h){i.value=h===""?null:h}function d(h,y){switch(h){case"selectedGene":s(y);break;case"selectedMetadataColumn":a(y);break;case"selectedGene1":o(y);break;case"selectedGene2":l(y);break;case"selectedGeneX":u(y);break;default:console.warn(`Unknown selection key: ${h}`)}}return{selectedGene:e,selectedMetadataColumn:t,selectedGene1:n,selectedGene2:r,selectedGeneX:i,setSelectedGene:s,setSelectedMetadataColumn:a,setSelectedGene1:o,setSelectedGene2:l,setSelectedGeneX:u,setSelection:d}});function oo(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function nR(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function M_(e){let t,n,r;e.length!==2?(t=oo,n=(o,l)=>oo(e(o),l),r=(o,l)=>e(o)-l):(t=e===oo||e===nR?e:rR,n=e,r=e);function i(o,l,u=0,d=o.length){if(u<d){if(t(l,l)!==0)return d;do{const h=u+d>>>1;n(o[h],l)<0?u=h+1:d=h}while(u<d)}return u}function s(o,l,u=0,d=o.length){if(u<d){if(t(l,l)!==0)return d;do{const h=u+d>>>1;n(o[h],l)<=0?u=h+1:d=h}while(u<d)}return u}function a(o,l,u=0,d=o.length){const h=i(o,l,u,d-1);return h>u&&r(o[h-1],l)>-r(o[h],l)?h-1:h}return{left:i,center:a,right:s}}function rR(){return 0}function iR(e){return e===null?NaN:+e}function*sR(e,t){for(let n of e)n!=null&&(n=+n)>=n&&(yield n)}const aR=M_(oo).right;M_(iR).center;function oR(e,t){let n=0,r,i=0,s=0;for(let a of e)a!=null&&(a=+a)>=a&&(r=a-i,i+=r/++n,s+=r*(a-i));if(n>1)return s/(n-1)}function lR(e,t){const n=oR(e);return n&&Math.sqrt(n)}function na(e,t){let n,r;if(t===void 0)for(const i of e)i!=null&&(n===void 0?i>=i&&(n=r=i):(n>i&&(n=i),r<i&&(r=i)));else{let i=-1;for(let s of e)(s=t(s,++i,e))!=null&&(n===void 0?s>=s&&(n=r=s):(n>s&&(n=s),r<s&&(r=s)))}return[n,r]}class C_ extends Map{constructor(t,n=dR){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[r,i]of t)this.set(r,i)}get(t){return super.get(k_(this,t))}has(t){return super.has(k_(this,t))}set(t,n){return super.set(cR(this,t),n)}delete(t){return super.delete(uR(this,t))}}function k_({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):n}function cR({_intern:e,_key:t},n){const r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function uR({_intern:e,_key:t},n){const r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function dR(e){return e!==null&&typeof e=="object"?e.valueOf():e}function fR(e=oo){if(e===oo)return U_;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function U_(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:e>t?1:0)}const hR=Math.sqrt(50),pR=Math.sqrt(10),mR=Math.sqrt(2);function Yu(e,t,n){const r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),s=r/Math.pow(10,i),a=s>=hR?10:s>=pR?5:s>=mR?2:1;let o,l,u;return i<0?(u=Math.pow(10,-i)/a,o=Math.round(e*u),l=Math.round(t*u),o/u<e&&++o,l/u>t&&--l,u=-u):(u=Math.pow(10,i)*a,o=Math.round(e/u),l=Math.round(t/u),o*u<e&&++o,l*u>t&&--l),l<o&&.5<=n&&n<2?Yu(e,t,n*2):[o,l,u]}function yR(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[i,s,a]=r?Yu(t,e,n):Yu(e,t,n);if(!(s>=i))return[];const o=s-i+1,l=new Array(o);if(r)if(a<0)for(let u=0;u<o;++u)l[u]=(s-u)/-a;else for(let u=0;u<o;++u)l[u]=(s-u)*a;else if(a<0)for(let u=0;u<o;++u)l[u]=(i+u)/-a;else for(let u=0;u<o;++u)l[u]=(i+u)*a;return l}function dp(e,t,n){return t=+t,e=+e,n=+n,Yu(e,t,n)[2]}function gR(e,t,n){t=+t,e=+e,n=+n;const r=t<e,i=r?dp(t,e,n):dp(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Wu(e,t){let n;if(t===void 0)for(const r of e)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n<i||n===void 0&&i>=i)&&(n=i)}return n}function fp(e,t){let n;for(const r of e)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function P_(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?U_:fR(i);r>n;){if(r-n>600){const l=r-n+1,u=t-n+1,d=Math.log(l),h=.5*Math.exp(2*d/3),y=.5*Math.sqrt(d*h*(l-h)/l)*(u-l/2<0?-1:1),S=Math.max(n,Math.floor(t-u*h/l+y)),M=Math.min(r,Math.floor(t+(l-u)*h/l+y));P_(e,t,S,M,i)}const s=e[t];let a=n,o=r;for(uc(e,n,t),i(e[r],s)>0&&uc(e,n,r);a<o;){for(uc(e,a,o),++a,--o;i(e[a],s)<0;)++a;for(;i(e[o],s)>0;)--o}i(e[n],s)===0?uc(e,n,o):(++o,uc(e,o,r)),o<=t&&(n=o+1),t<=o&&(r=o-1)}return e}function uc(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function hp(e,t,n){if(e=Float64Array.from(sR(e)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return fp(e);if(t>=1)return Wu(e);var r,i=(r-1)*t,s=Math.floor(i),a=Wu(P_(e,s).subarray(0,s+1)),o=fp(e.subarray(s+1));return a+(o-a)*(i-s)}}function _R(e,t){let n=0,r=0;if(t===void 0)for(let i of e)i!=null&&(i=+i)>=i&&(++n,r+=i);else{let i=-1;for(let s of e)(s=t(s,++i,e))!=null&&(s=+s)>=s&&(++n,r+=s)}if(n)return r/n}function vR(e,t){return hp(e,.5)}function bR(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,s=new Array(i);++r<i;)s[r]=e+r*n;return s}function wR(e){return e}var pp=1,mp=2,yp=3,dc=4,$_=1e-6;function SR(e){return"translate("+e+",0)"}function ER(e){return"translate(0,"+e+")"}function IR(e){return t=>+e(t)}function TR(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function AR(){return!this.__axis}function V_(e,t){var n=[],r=null,i=null,s=6,a=6,o=3,l=typeof window<"u"&&window.devicePixelRatio>1?0:.5,u=e===pp||e===dc?-1:1,d=e===dc||e===mp?"x":"y",h=e===pp||e===yp?SR:ER;function y(S){var M=r??(t.ticks?t.ticks.apply(t,n):t.domain()),H=i??(t.tickFormat?t.tickFormat.apply(t,n):wR),nt=Math.max(s,0)+o,j=t.range(),$t=+j[0]+l,Ct=+j[j.length-1]+l,Zt=(t.bandwidth?TR:IR)(t.copy(),l),Lt=S.selection?S.selection():S,ie=Lt.selectAll(".domain").data([null]),xt=Lt.selectAll(".tick").data(M,t).order(),on=xt.exit(),ge=xt.enter().append("g").attr("class","tick"),ne=xt.select("line"),Qt=xt.select("text");ie=ie.merge(ie.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),xt=xt.merge(ge),ne=ne.merge(ge.append("line").attr("stroke","currentColor").attr(d+"2",u*s)),Qt=Qt.merge(ge.append("text").attr("fill","currentColor").attr(d,u*nt).attr("dy",e===pp?"0em":e===yp?"0.71em":"0.32em")),S!==Lt&&(ie=ie.transition(S),xt=xt.transition(S),ne=ne.transition(S),Qt=Qt.transition(S),on=on.transition(S).attr("opacity",$_).attr("transform",function(rt){return isFinite(rt=Zt(rt))?h(rt+l):this.getAttribute("transform")}),ge.attr("opacity",$_).attr("transform",function(rt){var ot=this.parentNode.__axis;return h((ot&&isFinite(ot=ot(rt))?ot:Zt(rt))+l)})),on.remove(),ie.attr("d",e===dc||e===mp?a?"M"+u*a+","+$t+"H"+l+"V"+Ct+"H"+u*a:"M"+l+","+$t+"V"+Ct:a?"M"+$t+","+u*a+"V"+l+"H"+Ct+"V"+u*a:"M"+$t+","+l+"H"+Ct),xt.attr("opacity",1).attr("transform",function(rt){return h(Zt(rt)+l)}),ne.attr(d+"2",u*s),Qt.attr(d,u*nt).text(H),Lt.filter(AR).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",e===mp?"start":e===dc?"end":"middle"),Lt.each(function(){this.__axis=Zt})}return y.scale=function(S){return arguments.length?(t=S,y):t},y.ticks=function(){return n=Array.from(arguments),y},y.tickArguments=function(S){return arguments.length?(n=S==null?[]:Array.from(S),y):n.slice()},y.tickValues=function(S){return arguments.length?(r=S==null?null:Array.from(S),y):r&&r.slice()},y.tickFormat=function(S){return arguments.length?(i=S,y):i},y.tickSize=function(S){return arguments.length?(s=a=+S,y):s},y.tickSizeInner=function(S){return arguments.length?(s=+S,y):s},y.tickSizeOuter=function(S){return arguments.length?(a=+S,y):a},y.tickPadding=function(S){return arguments.length?(o=+S,y):o},y.offset=function(S){return arguments.length?(l=+S,y):l},y}function xR(e){return V_(yp,e)}function NR(e){return V_(dc,e)}var RR={value:()=>{}};function gp(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Hu(n)}function Hu(e){this._=e}function BR(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Hu.prototype=gp.prototype={constructor:Hu,on:function(e,t){var n=this._,r=BR(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=OR(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=z_(n[i],e.name,t);else if(t==null)for(i in n)n[i]=z_(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Hu(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function OR(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function z_(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=RR,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var _p="http://www.w3.org/1999/xhtml";const G_={svg:"http://www.w3.org/2000/svg",xhtml:_p,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function qu(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),G_.hasOwnProperty(t)?{space:G_[t],local:e}:e}function DR(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===_p&&t.documentElement.namespaceURI===_p?t.createElement(e):t.createElementNS(n,e)}}function FR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function j_(e){var t=qu(e);return(t.local?FR:DR)(t)}function LR(){}function vp(e){return e==null?LR:function(){return this.querySelector(e)}}function MR(e){typeof e!="function"&&(e=vp(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,u,d=0;d<a;++d)(l=s[d])&&(u=e.call(l,l.__data__,d,s))&&("__data__"in l&&(u.__data__=l.__data__),o[d]=u);return new Ni(r,this._parents)}function CR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function kR(){return[]}function Y_(e){return e==null?kR:function(){return this.querySelectorAll(e)}}function UR(e){return function(){return CR(e.apply(this,arguments))}}function PR(e){typeof e=="function"?e=UR(e):e=Y_(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&(r.push(e.call(l,l.__data__,u,a)),i.push(l));return new Ni(r,i)}function W_(e){return function(){return this.matches(e)}}function H_(e){return function(t){return t.matches(e)}}var $R=Array.prototype.find;function VR(e){return function(){return $R.call(this.children,e)}}function zR(){return this.firstElementChild}function GR(e){return this.select(e==null?zR:VR(typeof e=="function"?e:H_(e)))}var jR=Array.prototype.filter;function YR(){return Array.from(this.children)}function WR(e){return function(){return jR.call(this.children,e)}}function HR(e){return this.selectAll(e==null?YR:WR(typeof e=="function"?e:H_(e)))}function qR(e){typeof e!="function"&&(e=W_(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new Ni(r,this._parents)}function q_(e){return new Array(e.length)}function XR(){return new Ni(this._enter||this._groups.map(q_),this._parents)}function Xu(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Xu.prototype={constructor:Xu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function KR(e){return function(){return e}}function QR(e,t,n,r,i,s){for(var a=0,o,l=t.length,u=s.length;a<u;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new Xu(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function JR(e,t,n,r,i,s,a){var o,l,u=new Map,d=t.length,h=s.length,y=new Array(d),S;for(o=0;o<d;++o)(l=t[o])&&(y[o]=S=a.call(l,l.__data__,o,t)+"",u.has(S)?i[o]=l:u.set(S,l));for(o=0;o<h;++o)S=a.call(e,s[o],o,s)+"",(l=u.get(S))?(r[o]=l,l.__data__=s[o],u.delete(S)):n[o]=new Xu(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&u.get(y[o])===l&&(i[o]=l)}function ZR(e){return e.__data__}function tB(e,t){if(!arguments.length)return Array.from(this,ZR);var n=t?JR:QR,r=this._parents,i=this._groups;typeof e!="function"&&(e=KR(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),u=0;u<s;++u){var d=r[u],h=i[u],y=h.length,S=eB(e.call(d,d&&d.__data__,u,r)),M=S.length,H=o[u]=new Array(M),nt=a[u]=new Array(M),j=l[u]=new Array(y);n(d,h,H,nt,j,S,t);for(var $t=0,Ct=0,Zt,Lt;$t<M;++$t)if(Zt=H[$t]){for($t>=Ct&&(Ct=$t+1);!(Lt=nt[Ct])&&++Ct<M;);Zt._next=Lt||null}}return a=new Ni(a,r),a._enter=o,a._exit=l,a}function eB(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function nB(){return new Ni(this._exit||this._groups.map(q_),this._parents)}function rB(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function iB(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var u=n[l],d=r[l],h=u.length,y=o[l]=new Array(h),S,M=0;M<h;++M)(S=u[M]||d[M])&&(y[M]=S);for(;l<i;++l)o[l]=n[l];return new Ni(o,this._parents)}function sB(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function aB(e){e||(e=oB);function t(h,y){return h&&y?e(h.__data__,y.__data__):!h-!y}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),u,d=0;d<o;++d)(u=a[d])&&(l[d]=u);l.sort(t)}return new Ni(i,this._parents).order()}function oB(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function lB(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function cB(){return Array.from(this)}function uB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function dB(){let e=0;for(const t of this)++e;return e}function fB(){return!this.node()}function hB(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function pB(e){return function(){this.removeAttribute(e)}}function mB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yB(e,t){return function(){this.setAttribute(e,t)}}function gB(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function _B(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function vB(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function bB(e,t){var n=qu(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?mB:pB:typeof t=="function"?n.local?vB:_B:n.local?gB:yB)(n,t))}function X_(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wB(e){return function(){this.style.removeProperty(e)}}function SB(e,t,n){return function(){this.style.setProperty(e,t,n)}}function EB(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function IB(e,t,n){return arguments.length>1?this.each((t==null?wB:typeof t=="function"?EB:SB)(e,t,n??"")):zo(this.node(),e)}function zo(e,t){return e.style.getPropertyValue(t)||X_(e).getComputedStyle(e,null).getPropertyValue(t)}function TB(e){return function(){delete this[e]}}function AB(e,t){return function(){this[e]=t}}function xB(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function NB(e,t){return arguments.length>1?this.each((t==null?TB:typeof t=="function"?xB:AB)(e,t)):this.node()[e]}function K_(e){return e.trim().split(/^|\s+/)}function bp(e){return e.classList||new Q_(e)}function Q_(e){this._node=e,this._names=K_(e.getAttribute("class")||"")}Q_.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function J_(e,t){for(var n=bp(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Z_(e,t){for(var n=bp(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function RB(e){return function(){J_(this,e)}}function BB(e){return function(){Z_(this,e)}}function OB(e,t){return function(){(t.apply(this,arguments)?J_:Z_)(this,e)}}function DB(e,t){var n=K_(e+"");if(arguments.length<2){for(var r=bp(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?OB:t?RB:BB)(n,t))}function FB(){this.textContent=""}function LB(e){return function(){this.textContent=e}}function MB(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function CB(e){return arguments.length?this.each(e==null?FB:(typeof e=="function"?MB:LB)(e)):this.node().textContent}function kB(){this.innerHTML=""}function UB(e){return function(){this.innerHTML=e}}function PB(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function $B(e){return arguments.length?this.each(e==null?kB:(typeof e=="function"?PB:UB)(e)):this.node().innerHTML}function VB(){this.nextSibling&&this.parentNode.appendChild(this)}function zB(){return this.each(VB)}function GB(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jB(){return this.each(GB)}function YB(e){var t=typeof e=="function"?e:j_(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function WB(){return null}function HB(e,t){var n=typeof e=="function"?e:j_(e),r=t==null?WB:typeof t=="function"?t:vp(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function qB(){var e=this.parentNode;e&&e.removeChild(this)}function XB(){return this.each(qB)}function KB(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function QB(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function JB(e){return this.select(e?QB:KB)}function ZB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function tO(e){return function(t){e.call(this,t,this.__data__)}}function eO(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function nO(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function rO(e,t,n){return function(){var r=this.__on,i,s=tO(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function iO(e,t,n){var r=eO(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,u=o.length,d;l<u;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?rO:nO,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function tv(e,t,n){var r=X_(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function sO(e,t){return function(){return tv(this,e,t)}}function aO(e,t){return function(){return tv(this,e,t.apply(this,arguments))}}function oO(e,t){return this.each((typeof t=="function"?aO:sO)(e,t))}function*lO(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var ev=[null];function Ni(e,t){this._groups=e,this._parents=t}function fc(){return new Ni([[document.documentElement]],ev)}function cO(){return this}Ni.prototype=fc.prototype={constructor:Ni,select:MR,selectAll:PR,selectChild:GR,selectChildren:HR,filter:qR,data:tB,enter:XR,exit:nB,join:rB,merge:iB,selection:cO,order:sB,sort:aB,call:lB,nodes:cB,node:uB,size:dB,empty:fB,each:hB,attr:bB,style:IB,property:NB,classed:DB,text:CB,html:$B,raise:zB,lower:jB,append:YB,insert:HB,remove:XB,clone:JB,datum:ZB,on:iO,dispatch:oO,[Symbol.iterator]:lO};function Pr(e){return typeof e=="string"?new Ni([[document.querySelector(e)]],[document.documentElement]):new Ni([[e]],ev)}function uO(e){let t;for(;t=e.sourceEvent;)e=t;return e}function lo(e,t){if(e=uO(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const wp={capture:!0,passive:!1};function Sp(e){e.preventDefault(),e.stopImmediatePropagation()}function dO(e){var t=e.document.documentElement,n=Pr(e).on("dragstart.drag",Sp,wp);"onselectstart"in t?n.on("selectstart.drag",Sp,wp):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fO(e,t){var n=e.document.documentElement,r=Pr(e).on("dragstart.drag",null);t&&(r.on("click.drag",Sp,wp),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Ep(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function nv(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function hc(){}var pc=.7,Ku=1/pc,Go="\\s*([+-]?\\d+)\\s*",mc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Es="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",hO=/^#([0-9a-f]{3,8})$/,pO=new RegExp(`^rgb\\(${Go},${Go},${Go}\\)$`),mO=new RegExp(`^rgb\\(${Es},${Es},${Es}\\)$`),yO=new RegExp(`^rgba\\(${Go},${Go},${Go},${mc}\\)$`),gO=new RegExp(`^rgba\\(${Es},${Es},${Es},${mc}\\)$`),_O=new RegExp(`^hsl\\(${mc},${Es},${Es}\\)$`),vO=new RegExp(`^hsla\\(${mc},${Es},${Es},${mc}\\)$`),rv={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ep(hc,ss,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:iv,formatHex:iv,formatHex8:bO,formatHsl:wO,formatRgb:sv,toString:sv});function iv(){return this.rgb().formatHex()}function bO(){return this.rgb().formatHex8()}function wO(){return uv(this).formatHsl()}function sv(){return this.rgb().formatRgb()}function ss(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=hO.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?av(t):n===3?new yi(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Qu(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Qu(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=pO.exec(e))?new yi(t[1],t[2],t[3],1):(t=mO.exec(e))?new yi(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=yO.exec(e))?Qu(t[1],t[2],t[3],t[4]):(t=gO.exec(e))?Qu(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=_O.exec(e))?cv(t[1],t[2]/100,t[3]/100,1):(t=vO.exec(e))?cv(t[1],t[2]/100,t[3]/100,t[4]):rv.hasOwnProperty(e)?av(rv[e]):e==="transparent"?new yi(NaN,NaN,NaN,0):null}function av(e){return new yi(e>>16&255,e>>8&255,e&255,1)}function Qu(e,t,n,r){return r<=0&&(e=t=n=NaN),new yi(e,t,n,r)}function SO(e){return e instanceof hc||(e=ss(e)),e?(e=e.rgb(),new yi(e.r,e.g,e.b,e.opacity)):new yi}function Ip(e,t,n,r){return arguments.length===1?SO(e):new yi(e,t,n,r??1)}function yi(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ep(yi,Ip,nv(hc,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new yi(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?pc:Math.pow(pc,e),new yi(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yi(co(this.r),co(this.g),co(this.b),Ju(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ov,formatHex:ov,formatHex8:EO,formatRgb:lv,toString:lv}));function ov(){return`#${uo(this.r)}${uo(this.g)}${uo(this.b)}`}function EO(){return`#${uo(this.r)}${uo(this.g)}${uo(this.b)}${uo((isNaN(this.opacity)?1:this.opacity)*255)}`}function lv(){const e=Ju(this.opacity);return`${e===1?"rgb(":"rgba("}${co(this.r)}, ${co(this.g)}, ${co(this.b)}${e===1?")":`, ${e})`}`}function Ju(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function co(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function uo(e){return e=co(e),(e<16?"0":"")+e.toString(16)}function cv(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new as(e,t,n,r)}function uv(e){if(e instanceof as)return new as(e.h,e.s,e.l,e.opacity);if(e instanceof hc||(e=ss(e)),!e)return new as;if(e instanceof as)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new as(a,o,l,e.opacity)}function IO(e,t,n,r){return arguments.length===1?uv(e):new as(e,t,n,r??1)}function as(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ep(as,IO,nv(hc,{brighter(e){return e=e==null?Ku:Math.pow(Ku,e),new as(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?pc:Math.pow(pc,e),new as(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new yi(Tp(e>=240?e-240:e+120,i,r),Tp(e,i,r),Tp(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new as(dv(this.h),Zu(this.s),Zu(this.l),Ju(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ju(this.opacity);return`${e===1?"hsl(":"hsla("}${dv(this.h)}, ${Zu(this.s)*100}%, ${Zu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function dv(e){return e=(e||0)%360,e<0?e+360:e}function Zu(e){return Math.max(0,Math.min(1,e||0))}function Tp(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Ap=e=>()=>e;function TO(e,t){return function(n){return e+n*t}}function AO(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function xO(e){return(e=+e)==1?fv:function(t,n){return n-t?AO(t,n,e):Ap(isNaN(t)?n:t)}}function fv(e,t){var n=t-e;return n?TO(e,n):Ap(isNaN(e)?t:e)}const td=(function e(t){var n=xO(t);function r(i,s){var a=n((i=Ip(i)).r,(s=Ip(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),u=fv(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=u(d),i+""}}return r.gamma=e,r})(1);function NO(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(s){for(i=0;i<n;++i)r[i]=e[i]*(1-s)+t[i]*s;return r}}function RO(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function BO(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),s=new Array(n),a;for(a=0;a<r;++a)i[a]=Rp(e[a],t[a]);for(;a<n;++a)s[a]=t[a];return function(o){for(a=0;a<r;++a)s[a]=i[a](o);return s}}function OO(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function os(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function DO(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Rp(e[i],t[i]):r[i]=t[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var xp=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Np=new RegExp(xp.source,"g");function FO(e){return function(){return e}}function LO(e){return function(t){return e(t)+""}}function hv(e,t){var n=xp.lastIndex=Np.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=xp.exec(e))&&(i=Np.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:os(r,i)})),n=Np.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?LO(l[0].x):FO(t):(t=l.length,function(u){for(var d=0,h;d<t;++d)o[(h=l[d]).i]=h.x(u);return o.join("")})}function Rp(e,t){var n=typeof t,r;return t==null||n==="boolean"?Ap(t):(n==="number"?os:n==="string"?(r=ss(t))?(t=r,td):hv:t instanceof ss?td:t instanceof Date?OO:RO(t)?NO:Array.isArray(t)?BO:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?DO:os)(e,t)}function MO(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var pv=180/Math.PI,Bp={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function mv(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*pv,skewX:Math.atan(l)*pv,scaleX:a,scaleY:o}}var ed;function CO(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Bp:mv(t.a,t.b,t.c,t.d,t.e,t.f)}function kO(e){return e==null||(ed||(ed=document.createElementNS("http://www.w3.org/2000/svg","g")),ed.setAttribute("transform",e),!(e=ed.transform.baseVal.consolidate()))?Bp:(e=e.matrix,mv(e.a,e.b,e.c,e.d,e.e,e.f))}function yv(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function s(u,d,h,y,S,M){if(u!==h||d!==y){var H=S.push("translate(",null,t,null,n);M.push({i:H-4,x:os(u,h)},{i:H-2,x:os(d,y)})}else(h||y)&&S.push("translate("+h+t+y+n)}function a(u,d,h,y){u!==d?(u-d>180?d+=360:d-u>180&&(u+=360),y.push({i:h.push(i(h)+"rotate(",null,r)-2,x:os(u,d)})):d&&h.push(i(h)+"rotate("+d+r)}function o(u,d,h,y){u!==d?y.push({i:h.push(i(h)+"skewX(",null,r)-2,x:os(u,d)}):d&&h.push(i(h)+"skewX("+d+r)}function l(u,d,h,y,S,M){if(u!==h||d!==y){var H=S.push(i(S)+"scale(",null,",",null,")");M.push({i:H-4,x:os(u,h)},{i:H-2,x:os(d,y)})}else(h!==1||y!==1)&&S.push(i(S)+"scale("+h+","+y+")")}return function(u,d){var h=[],y=[];return u=e(u),d=e(d),s(u.translateX,u.translateY,d.translateX,d.translateY,h,y),a(u.rotate,d.rotate,h,y),o(u.skewX,d.skewX,h,y),l(u.scaleX,u.scaleY,d.scaleX,d.scaleY,h,y),u=d=null,function(S){for(var M=-1,H=y.length,nt;++M<H;)h[(nt=y[M]).i]=nt.x(S);return h.join("")}}}var UO=yv(CO,"px, ","px)","deg)"),PO=yv(kO,", ",")",")"),$O=1e-12;function gv(e){return((e=Math.exp(e))+1/e)/2}function VO(e){return((e=Math.exp(e))-1/e)/2}function zO(e){return((e=Math.exp(2*e))-1)/(e+1)}const GO=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],u=s[2],d=a[0],h=a[1],y=a[2],S=d-o,M=h-l,H=S*S+M*M,nt,j;if(H<$O)j=Math.log(y/u)/t,nt=function(xt){return[o+xt*S,l+xt*M,u*Math.exp(t*xt*j)]};else{var $t=Math.sqrt(H),Ct=(y*y-u*u+r*H)/(2*u*n*$t),Zt=(y*y-u*u-r*H)/(2*y*n*$t),Lt=Math.log(Math.sqrt(Ct*Ct+1)-Ct),ie=Math.log(Math.sqrt(Zt*Zt+1)-Zt);j=(ie-Lt)/t,nt=function(xt){var on=xt*j,ge=gv(Lt),ne=u/(n*$t)*(ge*zO(t*on+Lt)-VO(Lt));return[o+ne*S,l+ne*M,u*ge/gv(t*on+Lt)]}}return nt.duration=j*1e3*t/Math.SQRT2,nt}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);var jo=0,yc=0,gc=0,_v=1e3,nd,_c,rd=0,fo=0,id=0,vc=typeof performance=="object"&&performance.now?performance:Date,vv=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Op(){return fo||(vv(jO),fo=vc.now()+id)}function jO(){fo=0}function sd(){this._call=this._time=this._next=null}sd.prototype=bv.prototype={constructor:sd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Op():+n)+(t==null?0:+t),!this._next&&_c!==this&&(_c?_c._next=this:nd=this,_c=this),this._call=e,this._time=n,Dp()},stop:function(){this._call&&(this._call=null,this._time=1/0,Dp())}};function bv(e,t,n){var r=new sd;return r.restart(e,t,n),r}function YO(){Op(),++jo;for(var e=nd,t;e;)(t=fo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--jo}function wv(){fo=(rd=vc.now())+id,jo=yc=0;try{YO()}finally{jo=0,HO(),fo=0}}function WO(){var e=vc.now(),t=e-rd;t>_v&&(id-=t,rd=e)}function HO(){for(var e,t=nd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:nd=n);_c=e,Dp(r)}function Dp(e){if(!jo){yc&&(yc=clearTimeout(yc));var t=e-fo;t>24?(e<1/0&&(yc=setTimeout(wv,e-vc.now()-id)),gc&&(gc=clearInterval(gc))):(gc||(rd=vc.now(),gc=setInterval(WO,_v)),jo=1,vv(wv))}}function Sv(e,t,n){var r=new sd;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var qO=gp("start","end","cancel","interrupt"),XO=[],Ev=0,Iv=1,Fp=2,ad=3,Tv=4,Lp=5,od=6;function ld(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;KO(e,n,{name:t,index:r,group:i,on:qO,tween:XO,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Ev})}function Mp(e,t){var n=ls(e,t);if(n.state>Ev)throw new Error("too late; already scheduled");return n}function Is(e,t){var n=ls(e,t);if(n.state>ad)throw new Error("too late; already running");return n}function ls(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function KO(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=bv(s,0,n.time);function s(u){n.state=Iv,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var d,h,y,S;if(n.state!==Iv)return l();for(d in r)if(S=r[d],S.name===n.name){if(S.state===ad)return Sv(a);S.state===Tv?(S.state=od,S.timer.stop(),S.on.call("interrupt",e,e.__data__,S.index,S.group),delete r[d]):+d<t&&(S.state=od,S.timer.stop(),S.on.call("cancel",e,e.__data__,S.index,S.group),delete r[d])}if(Sv(function(){n.state===ad&&(n.state=Tv,n.timer.restart(o,n.delay,n.time),o(u))}),n.state=Fp,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Fp){for(n.state=ad,i=new Array(y=n.tween.length),d=0,h=-1;d<y;++d)(S=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++h]=S);i.length=h+1}}function o(u){for(var d=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=Lp,1),h=-1,y=i.length;++h<y;)i[h].call(e,d);n.state===Lp&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=od,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function cd(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>Fp&&r.state<Lp,r.state=od,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function QO(e){return this.each(function(){cd(this,e)})}function JO(e,t){var n,r;return function(){var i=Is(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function ZO(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=Is(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=o;break}l===u&&i.push(o)}s.tween=i}}function tD(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=ls(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?JO:ZO)(n,e,t))}function Cp(e,t,n){var r=e._id;return e.each(function(){var i=Is(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return ls(i,r).value[t]}}function Av(e,t){var n;return(typeof t=="number"?os:t instanceof ss?td:(n=ss(t))?(t=n,td):hv)(e,t)}function eD(e){return function(){this.removeAttribute(e)}}function nD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rD(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function iD(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function sD(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function aD(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function oD(e,t){var n=qu(e),r=n==="transform"?PO:Av;return this.attrTween(e,typeof t=="function"?(n.local?aD:sD)(n,r,Cp(this,"attr."+e,t)):t==null?(n.local?nD:eD)(n):(n.local?iD:rD)(n,r,t))}function lD(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cD(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function uD(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&cD(e,s)),n}return i._value=t,i}function dD(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&lD(e,s)),n}return i._value=t,i}function fD(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=qu(e);return this.tween(n,(r.local?uD:dD)(r,t))}function hD(e,t){return function(){Mp(this,e).delay=+t.apply(this,arguments)}}function pD(e,t){return t=+t,function(){Mp(this,e).delay=t}}function mD(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?hD:pD)(t,e)):ls(this.node(),t).delay}function yD(e,t){return function(){Is(this,e).duration=+t.apply(this,arguments)}}function gD(e,t){return t=+t,function(){Is(this,e).duration=t}}function _D(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?yD:gD)(t,e)):ls(this.node(),t).duration}function vD(e,t){if(typeof t!="function")throw new Error;return function(){Is(this,e).ease=t}}function bD(e){var t=this._id;return arguments.length?this.each(vD(t,e)):ls(this.node(),t).ease}function wD(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Is(this,e).ease=n}}function SD(e){if(typeof e!="function")throw new Error;return this.each(wD(this._id,e))}function ED(e){typeof e!="function"&&(e=W_(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,u=0;u<a;++u)(l=s[u])&&e.call(l,l.__data__,u,s)&&o.push(l);return new ra(r,this._parents,this._name,this._id)}function ID(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],u=n[o],d=l.length,h=a[o]=new Array(d),y,S=0;S<d;++S)(y=l[S]||u[S])&&(h[S]=y);for(;o<r;++o)a[o]=t[o];return new ra(a,this._parents,this._name,this._id)}function TD(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function AD(e,t,n){var r,i,s=TD(t)?Mp:Is;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function xD(e,t){var n=this._id;return arguments.length<2?ls(this.node(),n).on.on(e):this.each(AD(n,e,t))}function ND(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RD(){return this.on("end.remove",ND(this._id))}function BD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vp(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,u=s[a]=new Array(l),d,h,y=0;y<l;++y)(d=o[y])&&(h=e.call(d,d.__data__,y,o))&&("__data__"in d&&(h.__data__=d.__data__),u[y]=h,ld(u[y],t,n,y,u,ls(d,n)));return new ra(s,this._parents,t,n)}function OD(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Y_(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],u=l.length,d,h=0;h<u;++h)if(d=l[h]){for(var y=e.call(d,d.__data__,h,l),S,M=ls(d,n),H=0,nt=y.length;H<nt;++H)(S=y[H])&&ld(S,t,n,H,y,M);s.push(y),a.push(d)}return new ra(s,a,t,n)}var DD=fc.prototype.constructor;function FD(){return new DD(this._groups,this._parents)}function LD(e,t){var n,r,i;return function(){var s=zo(this,e),a=(this.style.removeProperty(e),zo(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function xv(e){return function(){this.style.removeProperty(e)}}function MD(e,t,n){var r,i=n+"",s;return function(){var a=zo(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function CD(e,t,n){var r,i,s;return function(){var a=zo(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),zo(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function kD(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=Is(this,e),u=l.on,d=l.value[s]==null?o||(o=xv(t)):void 0;(u!==n||i!==d)&&(r=(n=u).copy()).on(a,i=d),l.on=r}}function UD(e,t,n){var r=(e+="")=="transform"?UO:Av;return t==null?this.styleTween(e,LD(e,r)).on("end.style."+e,xv(e)):typeof t=="function"?this.styleTween(e,CD(e,r,Cp(this,"style."+e,t))).each(kD(this._id,e)):this.styleTween(e,MD(e,r,t),n).on("end.style."+e,null)}function PD(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $D(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&PD(e,a,n)),r}return s._value=t,s}function VD(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,$D(e,t,n??""))}function zD(e){return function(){this.textContent=e}}function GD(e){return function(){var t=e(this);this.textContent=t??""}}function jD(e){return this.tween("text",typeof e=="function"?GD(Cp(this,"text",e)):zD(e==null?"":e+""))}function YD(e){return function(t){this.textContent=e.call(this,t)}}function WD(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&YD(i)),t}return r._value=e,r}function HD(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,WD(e))}function qD(){for(var e=this._name,t=this._id,n=Nv(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)if(l=a[u]){var d=ls(l,t);ld(l,e,n,u,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ra(r,this._parents,e,n)}function XD(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var u=Is(this,r),d=u.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),u.on=t}),i===0&&s()})}var KD=0;function ra(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Nv(){return++KD}var ia=fc.prototype;ra.prototype={constructor:ra,select:BD,selectAll:OD,selectChild:ia.selectChild,selectChildren:ia.selectChildren,filter:ED,merge:ID,selection:FD,transition:qD,call:ia.call,nodes:ia.nodes,node:ia.node,size:ia.size,empty:ia.empty,each:ia.each,on:xD,attr:oD,attrTween:fD,style:UD,styleTween:VD,text:jD,textTween:HD,remove:RD,tween:tD,delay:mD,duration:_D,ease:bD,easeVarying:SD,end:XD,[Symbol.iterator]:ia[Symbol.iterator]};function QD(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var JD={time:null,delay:0,duration:250,ease:QD};function ZD(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function tF(e){var t,n;e instanceof ra?(t=e._id,e=e._name):(t=Nv(),(n=JD).time=Op(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,u=0;u<o;++u)(l=a[u])&&ld(l,e,t,u,a,n||ZD(l,t));return new ra(r,this._parents,e,t)}fc.prototype.interrupt=QO,fc.prototype.transition=tF;const kp=Math.PI,Up=2*kp,ho=1e-6,eF=Up-ho;function Rv(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function nF(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return Rv;const n=10**t;return function(r){this._+=r[0];for(let i=1,s=r.length;i<s;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class rF{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Rv:nF(t)}moveTo(t,n){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,n){this._append`L${this._x1=+t},${this._y1=+n}`}quadraticCurveTo(t,n,r,i){this._append`Q${+t},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(t,n,r,i,s,a){this._append`C${+t},${+n},${+r},${+i},${this._x1=+s},${this._y1=+a}`}arcTo(t,n,r,i,s){if(t=+t,n=+n,r=+r,i=+i,s=+s,s<0)throw new Error(`negative radius: ${s}`);let a=this._x1,o=this._y1,l=r-t,u=i-n,d=a-t,h=o-n,y=d*d+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=n}`;else if(y>ho)if(!(Math.abs(h*l-u*d)>ho)||!s)this._append`L${this._x1=t},${this._y1=n}`;else{let S=r-a,M=i-o,H=l*l+u*u,nt=S*S+M*M,j=Math.sqrt(H),$t=Math.sqrt(y),Ct=s*Math.tan((kp-Math.acos((H+y-nt)/(2*j*$t)))/2),Zt=Ct/$t,Lt=Ct/j;Math.abs(Zt-1)>ho&&this._append`L${t+Zt*d},${n+Zt*h}`,this._append`A${s},${s},0,0,${+(h*S>d*M)},${this._x1=t+Lt*l},${this._y1=n+Lt*u}`}}arc(t,n,r,i,s,a){if(t=+t,n=+n,r=+r,a=!!a,r<0)throw new Error(`negative radius: ${r}`);let o=r*Math.cos(i),l=r*Math.sin(i),u=t+o,d=n+l,h=1^a,y=a?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>ho||Math.abs(this._y1-d)>ho)&&this._append`L${u},${d}`,r&&(y<0&&(y=y%Up+Up),y>eF?this._append`A${r},${r},0,1,${h},${t-o},${n-l}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:y>ho&&this._append`A${r},${r},0,${+(y>=kp)},${h},${this._x1=t+r*Math.cos(s)},${this._y1=n+r*Math.sin(s)}`)}rect(t,n,r,i){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function iF(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function ud(e,t){if((n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var n,r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function Yo(e){return e=ud(Math.abs(e)),e?e[1]:NaN}function sF(e,t){return function(n,r){for(var i=n.length,s=[],a=0,o=e[0],l=0;i>0&&o>0&&(l+o+1>r&&(o=Math.max(1,r-l)),s.push(n.substring(i-=o,i+o)),!((l+=o+1)>r));)o=e[a=(a+1)%e.length];return s.reverse().join(t)}}function aF(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var oF=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function dd(e){if(!(t=oF.exec(e)))throw new Error("invalid format: "+e);var t;return new Pp({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}dd.prototype=Pp.prototype;function Pp(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}Pp.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function lF(e){t:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case".":r=i=n;break;case"0":r===0&&(r=n),i=n;break;default:if(!+e[n])break t;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var Bv;function cF(e,t){var n=ud(e,t);if(!n)return e+"";var r=n[0],i=n[1],s=i-(Bv=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=r.length;return s===a?r:s>a?r+new Array(s-a+1).join("0"):s>0?r.slice(0,s)+"."+r.slice(s):"0."+new Array(1-s).join("0")+ud(e,Math.max(0,t+s-1))[0]}function Ov(e,t){var n=ud(e,t);if(!n)return e+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}const Dv={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:iF,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>Ov(e*100,t),r:Ov,s:cF,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function Fv(e){return e}var Lv=Array.prototype.map,Mv=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function uF(e){var t=e.grouping===void 0||e.thousands===void 0?Fv:sF(Lv.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",i=e.decimal===void 0?".":e.decimal+"",s=e.numerals===void 0?Fv:aF(Lv.call(e.numerals,String)),a=e.percent===void 0?"%":e.percent+"",o=e.minus===void 0?"−":e.minus+"",l=e.nan===void 0?"NaN":e.nan+"";function u(h){h=dd(h);var y=h.fill,S=h.align,M=h.sign,H=h.symbol,nt=h.zero,j=h.width,$t=h.comma,Ct=h.precision,Zt=h.trim,Lt=h.type;Lt==="n"?($t=!0,Lt="g"):Dv[Lt]||(Ct===void 0&&(Ct=12),Zt=!0,Lt="g"),(nt||y==="0"&&S==="=")&&(nt=!0,y="0",S="=");var ie=H==="$"?n:H==="#"&&/[boxX]/.test(Lt)?"0"+Lt.toLowerCase():"",xt=H==="$"?r:/[%p]/.test(Lt)?a:"",on=Dv[Lt],ge=/[defgprs%]/.test(Lt);Ct=Ct===void 0?6:/[gprs]/.test(Lt)?Math.max(1,Math.min(21,Ct)):Math.max(0,Math.min(20,Ct));function ne(Qt){var rt=ie,ot=xt,m,T,p;if(Lt==="c")ot=on(Qt)+ot,Qt="";else{Qt=+Qt;var L=Qt<0||1/Qt<0;if(Qt=isNaN(Qt)?l:on(Math.abs(Qt),Ct),Zt&&(Qt=lF(Qt)),L&&+Qt==0&&M!=="+"&&(L=!1),rt=(L?M==="("?M:o:M==="-"||M==="("?"":M)+rt,ot=(Lt==="s"?Mv[8+Bv/3]:"")+ot+(L&&M==="("?")":""),ge){for(m=-1,T=Qt.length;++m<T;)if(p=Qt.charCodeAt(m),48>p||p>57){ot=(p===46?i+Qt.slice(m+1):Qt.slice(m))+ot,Qt=Qt.slice(0,m);break}}}$t&&!nt&&(Qt=t(Qt,1/0));var C=rt.length+Qt.length+ot.length,R=C<j?new Array(j-C+1).join(y):"";switch($t&&nt&&(Qt=t(R+Qt,R.length?j-ot.length:1/0),R=""),S){case"<":Qt=rt+Qt+ot+R;break;case"=":Qt=rt+R+Qt+ot;break;case"^":Qt=R.slice(0,C=R.length>>1)+rt+Qt+ot+R.slice(C);break;default:Qt=R+rt+Qt+ot;break}return s(Qt)}return ne.toString=function(){return h+""},ne}function d(h,y){var S=u((h=dd(h),h.type="f",h)),M=Math.max(-8,Math.min(8,Math.floor(Yo(y)/3)))*3,H=Math.pow(10,-M),nt=Mv[8+M/3];return function(j){return S(H*j)+nt}}return{format:u,formatPrefix:d}}var fd,Cv,kv;dF({thousands:",",grouping:[3],currency:["$",""]});function dF(e){return fd=uF(e),Cv=fd.format,kv=fd.formatPrefix,fd}function fF(e){return Math.max(0,-Yo(Math.abs(e)))}function hF(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Yo(t)/3)))*3-Yo(Math.abs(e)))}function pF(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,Yo(t)-Yo(e))+1}function $p(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}const Uv=Symbol("implicit");function bc(){var e=new C_,t=[],n=[],r=Uv;function i(s){let a=e.get(s);if(a===void 0){if(r!==Uv)return r;e.set(s,a=t.push(s)-1)}return n[a%n.length]}return i.domain=function(s){if(!arguments.length)return t.slice();t=[],e=new C_;for(const a of s)e.has(a)||e.set(a,t.push(a)-1);return i},i.range=function(s){return arguments.length?(n=Array.from(s),i):n.slice()},i.unknown=function(s){return arguments.length?(r=s,i):r},i.copy=function(){return bc(t,n).unknown(r)},$p.apply(i,arguments),i}function Pv(){var e=bc().unknown(void 0),t=e.domain,n=e.range,r=0,i=1,s,a,o=!1,l=0,u=0,d=.5;delete e.unknown;function h(){var y=t().length,S=i<r,M=S?i:r,H=S?r:i;s=(H-M)/Math.max(1,y-l+u*2),o&&(s=Math.floor(s)),M+=(H-M-s*(y-l))*d,a=s*(1-l),o&&(M=Math.round(M),a=Math.round(a));var nt=bR(y).map(function(j){return M+s*j});return n(S?nt.reverse():nt)}return e.domain=function(y){return arguments.length?(t(y),h()):t()},e.range=function(y){return arguments.length?([r,i]=y,r=+r,i=+i,h()):[r,i]},e.rangeRound=function(y){return[r,i]=y,r=+r,i=+i,o=!0,h()},e.bandwidth=function(){return a},e.step=function(){return s},e.round=function(y){return arguments.length?(o=!!y,h()):o},e.padding=function(y){return arguments.length?(l=Math.min(1,u=+y),h()):l},e.paddingInner=function(y){return arguments.length?(l=Math.min(1,y),h()):l},e.paddingOuter=function(y){return arguments.length?(u=+y,h()):u},e.align=function(y){return arguments.length?(d=Math.max(0,Math.min(1,y)),h()):d},e.copy=function(){return Pv(t(),[r,i]).round(o).paddingInner(l).paddingOuter(u).align(d)},$p.apply(h(),arguments)}function mF(e){return function(){return e}}function yF(e){return+e}var $v=[0,1];function Wo(e){return e}function Vp(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:mF(isNaN(t)?NaN:.5)}function gF(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function _F(e,t,n){var r=e[0],i=e[1],s=t[0],a=t[1];return i<r?(r=Vp(i,r),s=n(a,s)):(r=Vp(r,i),s=n(s,a)),function(o){return s(r(o))}}function vF(e,t,n){var r=Math.min(e.length,t.length)-1,i=new Array(r),s=new Array(r),a=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++a<r;)i[a]=Vp(e[a],e[a+1]),s[a]=n(t[a],t[a+1]);return function(o){var l=aR(e,o,1,r)-1;return s[l](i[l](o))}}function bF(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function wF(){var e=$v,t=$v,n=Rp,r,i,s,a=Wo,o,l,u;function d(){var y=Math.min(e.length,t.length);return a!==Wo&&(a=gF(e[0],e[y-1])),o=y>2?vF:_F,l=u=null,h}function h(y){return y==null||isNaN(y=+y)?s:(l||(l=o(e.map(r),t,n)))(r(a(y)))}return h.invert=function(y){return a(i((u||(u=o(t,e.map(r),os)))(y)))},h.domain=function(y){return arguments.length?(e=Array.from(y,yF),d()):e.slice()},h.range=function(y){return arguments.length?(t=Array.from(y),d()):t.slice()},h.rangeRound=function(y){return t=Array.from(y),n=MO,d()},h.clamp=function(y){return arguments.length?(a=y?!0:Wo,d()):a!==Wo},h.interpolate=function(y){return arguments.length?(n=y,d()):n},h.unknown=function(y){return arguments.length?(s=y,h):s},function(y,S){return r=y,i=S,d()}}function SF(){return wF()(Wo,Wo)}function EF(e,t,n,r){var i=gR(e,t,n),s;switch(r=dd(r??",f"),r.type){case"s":{var a=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(s=hF(i,a))&&(r.precision=s),kv(r,a)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=pF(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=fF(i))&&(r.precision=s-(r.type==="%")*2);break}}return Cv(r)}function IF(e){var t=e.domain;return e.ticks=function(n){var r=t();return yR(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var i=t();return EF(i[0],i[i.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),i=0,s=r.length-1,a=r[i],o=r[s],l,u,d=10;for(o<a&&(u=a,a=o,o=u,u=i,i=s,s=u);d-- >0;){if(u=dp(a,o,n),u===l)return r[i]=a,r[s]=o,t(r);if(u>0)a=Math.floor(a/u)*u,o=Math.ceil(o/u)*u;else if(u<0)a=Math.ceil(a*u)/u,o=Math.floor(o*u)/u;else break;l=u}return e},e}function cs(){var e=SF();return e.copy=function(){return bF(e,cs())},$p.apply(e,arguments),IF(e)}function TF(e){for(var t=e.length/6|0,n=new Array(t),r=0;r<t;)n[r]="#"+e.slice(r*6,++r*6);return n}const zp=TF("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf");function $r(e){return function(){return e}}const Vv=1e-12;function zv(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const r=Math.floor(n);if(!(r>=0))throw new RangeError(`invalid digits: ${n}`);t=r}return e},()=>new rF(t)}function Gv(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function jv(e){this._context=e}jv.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Yv(e){return new jv(e)}function Wv(e){return e[0]}function Hv(e){return e[1]}function AF(e,t){var n=$r(!0),r=null,i=Yv,s=null,a=zv(o);e=typeof e=="function"?e:e===void 0?Wv:$r(e),t=typeof t=="function"?t:t===void 0?Hv:$r(t);function o(l){var u,d=(l=Gv(l)).length,h,y=!1,S;for(r==null&&(s=i(S=a())),u=0;u<=d;++u)!(u<d&&n(h=l[u],u,l))===y&&((y=!y)?s.lineStart():s.lineEnd()),y&&s.point(+e(h,u,l),+t(h,u,l));if(S)return s=null,S+""||null}return o.x=function(l){return arguments.length?(e=typeof l=="function"?l:$r(+l),o):e},o.y=function(l){return arguments.length?(t=typeof l=="function"?l:$r(+l),o):t},o.defined=function(l){return arguments.length?(n=typeof l=="function"?l:$r(!!l),o):n},o.curve=function(l){return arguments.length?(i=l,r!=null&&(s=i(r)),o):i},o.context=function(l){return arguments.length?(l==null?r=s=null:s=i(r=l),o):r},o}function xF(e,t,n){var r=null,i=$r(!0),s=null,a=Yv,o=null,l=zv(u);e=typeof e=="function"?e:e===void 0?Wv:$r(+e),t=typeof t=="function"?t:$r(t===void 0?0:+t),n=typeof n=="function"?n:n===void 0?Hv:$r(+n);function u(h){var y,S,M,H=(h=Gv(h)).length,nt,j=!1,$t,Ct=new Array(H),Zt=new Array(H);for(s==null&&(o=a($t=l())),y=0;y<=H;++y){if(!(y<H&&i(nt=h[y],y,h))===j)if(j=!j)S=y,o.areaStart(),o.lineStart();else{for(o.lineEnd(),o.lineStart(),M=y-1;M>=S;--M)o.point(Ct[M],Zt[M]);o.lineEnd(),o.areaEnd()}j&&(Ct[y]=+e(nt,y,h),Zt[y]=+t(nt,y,h),o.point(r?+r(nt,y,h):Ct[y],n?+n(nt,y,h):Zt[y]))}if($t)return o=null,$t+""||null}function d(){return AF().defined(i).curve(a).context(s)}return u.x=function(h){return arguments.length?(e=typeof h=="function"?h:$r(+h),r=null,u):e},u.x0=function(h){return arguments.length?(e=typeof h=="function"?h:$r(+h),u):e},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:$r(+h),u):r},u.y=function(h){return arguments.length?(t=typeof h=="function"?h:$r(+h),n=null,u):t},u.y0=function(h){return arguments.length?(t=typeof h=="function"?h:$r(+h),u):t},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:$r(+h),u):n},u.lineX0=u.lineY0=function(){return d().x(e).y(t)},u.lineY1=function(){return d().x(e).y(n)},u.lineX1=function(){return d().x(r).y(t)},u.defined=function(h){return arguments.length?(i=typeof h=="function"?h:$r(!!h),u):i},u.curve=function(h){return arguments.length?(a=h,s!=null&&(o=a(s)),u):a},u.context=function(h){return arguments.length?(h==null?s=o=null:o=a(s=h),u):s},u}function qv(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function Gp(e,t){this._context=e,this._k=(1-t)/6}Gp.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:qv(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:qv(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}},(function e(t){function n(r){return new Gp(r,t)}return n.tension=function(r){return e(+r)},n})(0);function NF(e,t,n){var r=e._x1,i=e._y1,s=e._x2,a=e._y2;if(e._l01_a>Vv){var o=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,l=3*e._l01_a*(e._l01_a+e._l12_a);r=(r*o-e._x0*e._l12_2a+e._x2*e._l01_2a)/l,i=(i*o-e._y0*e._l12_2a+e._y2*e._l01_2a)/l}if(e._l23_a>Vv){var u=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,d=3*e._l23_a*(e._l23_a+e._l12_a);s=(s*u+e._x1*e._l23_2a-t*e._l12_2a)/d,a=(a*u+e._y1*e._l23_2a-n*e._l12_2a)/d}e._context.bezierCurveTo(r,i,s,a,e._x2,e._y2)}function Xv(e,t){this._context=e,this._alpha=t}Xv.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,r=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:NF(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const RF=(function e(t){function n(r){return t?new Xv(r,t):new Gp(r,0)}return n.alpha=function(r){return e(+r)},n})(.5),hd=e=>()=>e;function BF(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function sa(e,t,n){this.k=e,this.x=t,this.y=n}sa.prototype={constructor:sa,scale:function(e){return e===1?this:new sa(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new sa(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ri=new sa(1,0,0);sa.prototype;function jp(e){e.stopImmediatePropagation()}function wc(e){e.preventDefault(),e.stopImmediatePropagation()}function OF(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function DF(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Kv(){return this.__zoom||Ri}function FF(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function LF(){return navigator.maxTouchPoints||"ontouchstart"in this}function MF(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Yp(){var e=OF,t=DF,n=MF,r=FF,i=LF,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=GO,u=gp("start","zoom","end"),d,h,y,S=500,M=150,H=0,nt=10;function j(m){m.property("__zoom",Kv).on("wheel.zoom",on,{passive:!1}).on("mousedown.zoom",ge).on("dblclick.zoom",ne).filter(i).on("touchstart.zoom",Qt).on("touchmove.zoom",rt).on("touchend.zoom touchcancel.zoom",ot).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}j.transform=function(m,T,p,L){var C=m.selection?m.selection():m;C.property("__zoom",Kv),m!==C?Lt(m,T,p,L):C.interrupt().each(function(){ie(this,arguments).event(L).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},j.scaleBy=function(m,T,p,L){j.scaleTo(m,function(){var C=this.__zoom.k,R=typeof T=="function"?T.apply(this,arguments):T;return C*R},p,L)},j.scaleTo=function(m,T,p,L){j.transform(m,function(){var C=t.apply(this,arguments),R=this.__zoom,U=p==null?Zt(C):typeof p=="function"?p.apply(this,arguments):p,tt=R.invert(U),ht=typeof T=="function"?T.apply(this,arguments):T;return n(Ct($t(R,ht),U,tt),C,a)},p,L)},j.translateBy=function(m,T,p,L){j.transform(m,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof p=="function"?p.apply(this,arguments):p),t.apply(this,arguments),a)},null,L)},j.translateTo=function(m,T,p,L,C){j.transform(m,function(){var R=t.apply(this,arguments),U=this.__zoom,tt=L==null?Zt(R):typeof L=="function"?L.apply(this,arguments):L;return n(Ri.translate(tt[0],tt[1]).scale(U.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof p=="function"?-p.apply(this,arguments):-p),R,a)},L,C)};function $t(m,T){return T=Math.max(s[0],Math.min(s[1],T)),T===m.k?m:new sa(T,m.x,m.y)}function Ct(m,T,p){var L=T[0]-p[0]*m.k,C=T[1]-p[1]*m.k;return L===m.x&&C===m.y?m:new sa(m.k,L,C)}function Zt(m){return[(+m[0][0]+ +m[1][0])/2,(+m[0][1]+ +m[1][1])/2]}function Lt(m,T,p,L){m.on("start.zoom",function(){ie(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){ie(this,arguments).event(L).end()}).tween("zoom",function(){var C=this,R=arguments,U=ie(C,R).event(L),tt=t.apply(C,R),ht=p==null?Zt(tt):typeof p=="function"?p.apply(C,R):p,ut=Math.max(tt[1][0]-tt[0][0],tt[1][1]-tt[0][1]),J=C.__zoom,Jt=typeof T=="function"?T.apply(C,R):T,re=l(J.invert(ht).concat(ut/J.k),Jt.invert(ht).concat(ut/Jt.k));return function(Rt){if(Rt===1)Rt=Jt;else{var fe=re(Rt),En=ut/fe[2];Rt=new sa(En,ht[0]-fe[0]*En,ht[1]-fe[1]*En)}U.zoom(null,Rt)}})}function ie(m,T,p){return!p&&m.__zooming||new xt(m,T)}function xt(m,T){this.that=m,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(m,T),this.taps=0}xt.prototype={event:function(m){return m&&(this.sourceEvent=m),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(m,T){return this.mouse&&m!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&m!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&m!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(m){var T=Pr(this.that).datum();u.call(m,this.that,new BF(m,{sourceEvent:this.sourceEvent,target:j,transform:this.that.__zoom,dispatch:u}),T)}};function on(m,...T){if(!e.apply(this,arguments))return;var p=ie(this,T).event(m),L=this.__zoom,C=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,r.apply(this,arguments)))),R=lo(m);if(p.wheel)(p.mouse[0][0]!==R[0]||p.mouse[0][1]!==R[1])&&(p.mouse[1]=L.invert(p.mouse[0]=R)),clearTimeout(p.wheel);else{if(L.k===C)return;p.mouse=[R,L.invert(R)],cd(this),p.start()}wc(m),p.wheel=setTimeout(U,M),p.zoom("mouse",n(Ct($t(L,C),p.mouse[0],p.mouse[1]),p.extent,a));function U(){p.wheel=null,p.end()}}function ge(m,...T){if(y||!e.apply(this,arguments))return;var p=m.currentTarget,L=ie(this,T,!0).event(m),C=Pr(m.view).on("mousemove.zoom",ht,!0).on("mouseup.zoom",ut,!0),R=lo(m,p),U=m.clientX,tt=m.clientY;dO(m.view),jp(m),L.mouse=[R,this.__zoom.invert(R)],cd(this),L.start();function ht(J){if(wc(J),!L.moved){var Jt=J.clientX-U,re=J.clientY-tt;L.moved=Jt*Jt+re*re>H}L.event(J).zoom("mouse",n(Ct(L.that.__zoom,L.mouse[0]=lo(J,p),L.mouse[1]),L.extent,a))}function ut(J){C.on("mousemove.zoom mouseup.zoom",null),fO(J.view,L.moved),wc(J),L.event(J).end()}}function ne(m,...T){if(e.apply(this,arguments)){var p=this.__zoom,L=lo(m.changedTouches?m.changedTouches[0]:m,this),C=p.invert(L),R=p.k*(m.shiftKey?.5:2),U=n(Ct($t(p,R),L,C),t.apply(this,T),a);wc(m),o>0?Pr(this).transition().duration(o).call(Lt,U,L,m):Pr(this).call(j.transform,U,L,m)}}function Qt(m,...T){if(e.apply(this,arguments)){var p=m.touches,L=p.length,C=ie(this,T,m.changedTouches.length===L).event(m),R,U,tt,ht;for(jp(m),U=0;U<L;++U)tt=p[U],ht=lo(tt,this),ht=[ht,this.__zoom.invert(ht),tt.identifier],C.touch0?!C.touch1&&C.touch0[2]!==ht[2]&&(C.touch1=ht,C.taps=0):(C.touch0=ht,R=!0,C.taps=1+!!d);d&&(d=clearTimeout(d)),R&&(C.taps<2&&(h=ht[0],d=setTimeout(function(){d=null},S)),cd(this),C.start())}}function rt(m,...T){if(this.__zooming){var p=ie(this,T).event(m),L=m.changedTouches,C=L.length,R,U,tt,ht;for(wc(m),R=0;R<C;++R)U=L[R],tt=lo(U,this),p.touch0&&p.touch0[2]===U.identifier?p.touch0[0]=tt:p.touch1&&p.touch1[2]===U.identifier&&(p.touch1[0]=tt);if(U=p.that.__zoom,p.touch1){var ut=p.touch0[0],J=p.touch0[1],Jt=p.touch1[0],re=p.touch1[1],Rt=(Rt=Jt[0]-ut[0])*Rt+(Rt=Jt[1]-ut[1])*Rt,fe=(fe=re[0]-J[0])*fe+(fe=re[1]-J[1])*fe;U=$t(U,Math.sqrt(Rt/fe)),tt=[(ut[0]+Jt[0])/2,(ut[1]+Jt[1])/2],ht=[(J[0]+re[0])/2,(J[1]+re[1])/2]}else if(p.touch0)tt=p.touch0[0],ht=p.touch0[1];else return;p.zoom("touch",n(Ct(U,tt,ht),p.extent,a))}}function ot(m,...T){if(this.__zooming){var p=ie(this,T).event(m),L=m.changedTouches,C=L.length,R,U;for(jp(m),y&&clearTimeout(y),y=setTimeout(function(){y=null},S),R=0;R<C;++R)U=L[R],p.touch0&&p.touch0[2]===U.identifier?delete p.touch0:p.touch1&&p.touch1[2]===U.identifier&&delete p.touch1;if(p.touch1&&!p.touch0&&(p.touch0=p.touch1,delete p.touch1),p.touch0)p.touch0[1]=this.__zoom.invert(p.touch0[0]);else if(p.end(),p.taps===2&&(U=lo(U,this),Math.hypot(h[0]-U[0],h[1]-U[1])<nt)){var tt=Pr(this).on("dblclick.zoom");tt&&tt.apply(this,arguments)}}}return j.wheelDelta=function(m){return arguments.length?(r=typeof m=="function"?m:hd(+m),j):r},j.filter=function(m){return arguments.length?(e=typeof m=="function"?m:hd(!!m),j):e},j.touchable=function(m){return arguments.length?(i=typeof m=="function"?m:hd(!!m),j):i},j.extent=function(m){return arguments.length?(t=typeof m=="function"?m:hd([[+m[0][0],+m[0][1]],[+m[1][0],+m[1][1]]]),j):t},j.scaleExtent=function(m){return arguments.length?(s[0]=+m[0],s[1]=+m[1],j):[s[0],s[1]]},j.translateExtent=function(m){return arguments.length?(a[0][0]=+m[0][0],a[1][0]=+m[1][0],a[0][1]=+m[0][1],a[1][1]=+m[1][1],j):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},j.constrain=function(m){return arguments.length?(n=m,j):n},j.duration=function(m){return arguments.length?(o=+m,j):o},j.interpolate=function(m){return arguments.length?(l=m,j):l},j.on=function(){var m=u.on.apply(u,arguments);return m===u?j:m},j.clickDistance=function(m){return arguments.length?(H=(m=+m)*m,j):Math.sqrt(H)},j.tapDistance=function(m){return arguments.length?(nt=+m,j):nt},j}function CF(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var pd={exports:{}},kF=pd.exports,Qv;function UF(){return Qv||(Qv=1,(function(e,t){(function(n,r){e.exports=r()})(kF,(function(){var n=function(f){return f instanceof Uint8Array||f instanceof Uint16Array||f instanceof Uint32Array||f instanceof Int8Array||f instanceof Int16Array||f instanceof Int32Array||f instanceof Float32Array||f instanceof Float64Array||f instanceof Uint8ClampedArray},r=function(f,v){for(var A=Object.keys(v),q=0;q<A.length;++q)f[A[q]]=v[A[q]];return f},i=`
89
+ `;function s(f){return typeof atob<"u"?atob(f):"base64:"+f}function a(f){var v=new Error("(regl) "+f);throw console.error(v),v}function o(f,v){f||a(v)}function l(f){return f?": "+f:""}function u(f,v,A){f in v||a("unknown parameter ("+f+")"+l(A)+". possible values: "+Object.keys(v).join())}function d(f,v){n(f)||a("invalid parameter type"+l(v)+". must be a typed array")}function h(f,v){switch(v){case"number":return typeof f=="number";case"object":return typeof f=="object";case"string":return typeof f=="string";case"boolean":return typeof f=="boolean";case"function":return typeof f=="function";case"undefined":return typeof f>"u";case"symbol":return typeof f=="symbol"}}function y(f,v,A){h(f,v)||a("invalid parameter type"+l(A)+". expected "+v+", got "+typeof f)}function S(f,v){f>=0&&(f|0)===f||a("invalid parameter type, ("+f+")"+l(v)+". must be a nonnegative integer")}function M(f,v,A){v.indexOf(f)<0&&a("invalid value"+l(A)+". must be one of: "+v)}var H=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"];function nt(f){Object.keys(f).forEach(function(v){H.indexOf(v)<0&&a('invalid regl constructor argument "'+v+'". must be one of '+H)})}function j(f,v){for(f=f+"";f.length<v;)f=" "+f;return f}function $t(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function Ct(f,v){this.number=f,this.line=v,this.errors=[]}function Zt(f,v,A){this.file=f,this.line=v,this.message=A}function Lt(){var f=new Error,v=(f.stack||f).toString(),A=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(v);if(A)return A[1];var q=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(v);return q?q[1]:"unknown"}function ie(){var f=new Error,v=(f.stack||f).toString(),A=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(v);if(A)return A[1];var q=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(v);return q?q[1]:"unknown"}function xt(f,v){var A=f.split(`
90
+ `),q=1,st=0,W={unknown:new $t,0:new $t};W.unknown.name=W[0].name=v||Lt(),W.unknown.lines.push(new Ct(0,""));for(var Z=0;Z<A.length;++Z){var ft=A[Z],dt=/^\s*#\s*(\w+)\s+(.+)\s*$/.exec(ft);if(dt)switch(dt[1]){case"line":var _t=/(\d+)(\s+\d+)?/.exec(dt[2]);_t&&(q=_t[1]|0,_t[2]&&(st=_t[2]|0,st in W||(W[st]=new $t)));break;case"define":var bt=/SHADER_NAME(_B64)?\s+(.*)$/.exec(dt[2]);bt&&(W[st].name=bt[1]?s(bt[2]):bt[2]);break}W[st].lines.push(new Ct(q++,ft))}return Object.keys(W).forEach(function(vt){var Tt=W[vt];Tt.lines.forEach(function(pt){Tt.index[pt.number]=pt})}),W}function on(f){var v=[];return f.split(`
91
+ `).forEach(function(A){if(!(A.length<5)){var q=/^ERROR:\s+(\d+):(\d+):\s*(.*)$/.exec(A);q?v.push(new Zt(q[1]|0,q[2]|0,q[3].trim())):A.length>0&&v.push(new Zt("unknown",0,A))}}),v}function ge(f,v){v.forEach(function(A){var q=f[A.file];if(q){var st=q.index[A.line];if(st){st.errors.push(A),q.hasErrors=!0;return}}f.unknown.hasErrors=!0,f.unknown.lines[0].errors.push(A)})}function ne(f,v,A,q,st){if(!f.getShaderParameter(v,f.COMPILE_STATUS)){var W=f.getShaderInfoLog(v),Z=q===f.FRAGMENT_SHADER?"fragment":"vertex";L(A,"string",Z+" shader source must be a string",st);var ft=xt(A,st),dt=on(W);ge(ft,dt),Object.keys(ft).forEach(function(_t){var bt=ft[_t];if(!bt.hasErrors)return;var vt=[""],Tt=[""];function pt(gt,$){vt.push(gt),Tt.push($||"")}pt("file number "+_t+": "+bt.name+`
92
+ `,"color:red;text-decoration:underline;font-weight:bold"),bt.lines.forEach(function(gt){if(gt.errors.length>0){pt(j(gt.number,4)+"| ","background-color:yellow; font-weight:bold"),pt(gt.line+i,"color:red; background-color:yellow; font-weight:bold");var $=0;gt.errors.forEach(function(Q){var yt=Q.message,Pt=/^\s*'(.*)'\s*:\s*(.*)$/.exec(yt);if(Pt){var ct=Pt[1];switch(yt=Pt[2],ct){case"assign":ct="=";break}$=Math.max(gt.line.indexOf(ct,$),0)}else $=0;pt(j("| ",6)),pt(j("^^^",$+3)+i,"font-weight:bold"),pt(j("| ",6)),pt(yt+i,"font-weight:bold")}),pt(j("| ",6)+i)}else pt(j(gt.number,4)+"| "),pt(gt.line+i,"color:red")}),typeof document<"u"&&!window.chrome?(Tt[0]=vt.join("%c"),console.log.apply(console,Tt)):console.log(vt.join(""))}),o.raise("Error compiling "+Z+" shader, "+ft[0].name)}}function Qt(f,v,A,q,st){if(!f.getProgramParameter(v,f.LINK_STATUS)){var W=f.getProgramInfoLog(v),Z=xt(A,st),ft=xt(q,st),dt='Error linking program with vertex shader, "'+ft[0].name+'", and fragment shader "'+Z[0].name+'"';typeof document<"u"?console.log("%c"+dt+i+"%c"+W,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(dt+i+W),o.raise(dt)}}function rt(f){f._commandRef=Lt()}function ot(f,v,A,q){rt(f);function st(dt){return dt?q.id(dt):0}f._fragId=st(f.static.frag),f._vertId=st(f.static.vert);function W(dt,_t){Object.keys(_t).forEach(function(bt){dt[q.id(bt)]=!0})}var Z=f._uniformSet={};W(Z,v.static),W(Z,v.dynamic);var ft=f._attributeSet={};W(ft,A.static),W(ft,A.dynamic),f._hasCount="count"in f.static||"count"in f.dynamic||"elements"in f.static||"elements"in f.dynamic}function m(f,v){var A=ie();a(f+" in command "+(v||Lt())+(A==="unknown"?"":" called from "+A))}function T(f,v,A){f||m(v,A||Lt())}function p(f,v,A,q){f in v||m("unknown parameter ("+f+")"+l(A)+". possible values: "+Object.keys(v).join(),q||Lt())}function L(f,v,A,q){h(f,v)||m("invalid parameter type"+l(A)+". expected "+v+", got "+typeof f,q||Lt())}function C(f){f()}function R(f,v,A){f.texture?M(f.texture._texture.internalformat,v,"unsupported texture format for attachment"):M(f.renderbuffer._renderbuffer.format,A,"unsupported renderbuffer format for attachment")}var U=33071,tt=9728,ht=9984,ut=9985,J=9986,Jt=9987,re=5120,Rt=5121,fe=5122,En=5123,hn=5124,Kn=5125,pn=5126,yn=32819,In=32820,ir=33635,sr=34042,qt=36193,et={};et[re]=et[Rt]=1,et[fe]=et[En]=et[qt]=et[ir]=et[yn]=et[In]=2,et[hn]=et[Kn]=et[pn]=et[sr]=4;function te(f,v){return f===In||f===yn||f===ir?2:f===sr?4:et[f]*v}function gn(f){return!(f&f-1)&&!!f}function _n(f,v,A){var q,st=v.width,W=v.height,Z=v.channels;o(st>0&&st<=A.maxTextureSize&&W>0&&W<=A.maxTextureSize,"invalid texture shape"),(f.wrapS!==U||f.wrapT!==U)&&o(gn(st)&&gn(W),"incompatible wrap mode for texture, both width and height must be power of 2"),v.mipmask===1?st!==1&&W!==1&&o(f.minFilter!==ht&&f.minFilter!==J&&f.minFilter!==ut&&f.minFilter!==Jt,"min filter requires mipmap"):(o(gn(st)&&gn(W),"texture must be a square power of 2 to support mipmapping"),o(v.mipmask===(st<<1)-1,"missing or incomplete mipmap data")),v.type===pn&&(A.extensions.indexOf("oes_texture_float_linear")<0&&o(f.minFilter===tt&&f.magFilter===tt,"filter not supported, must enable oes_texture_float_linear"),o(!f.genMipmaps,"mipmap generation not supported with float textures"));var ft=v.images;for(q=0;q<16;++q)if(ft[q]){var dt=st>>q,_t=W>>q;o(v.mipmask&1<<q,"missing mipmap data");var bt=ft[q];if(o(bt.width===dt&&bt.height===_t,"invalid shape for mip images"),o(bt.format===v.format&&bt.internalformat===v.internalformat&&bt.type===v.type,"incompatible type for mip image"),!bt.compressed)if(bt.data){var vt=Math.ceil(te(bt.type,Z)*dt/bt.unpackAlignment)*bt.unpackAlignment;o(bt.data.byteLength===vt*_t,"invalid data for image, buffer size is inconsistent with image format")}else bt.element||bt.copy}else f.genMipmaps||o((v.mipmask&1<<q)===0,"extra mipmap data");v.compressed&&o(!f.genMipmaps,"mipmap generation for compressed images not supported")}function tr(f,v,A,q){var st=f.width,W=f.height,Z=f.channels;o(st>0&&st<=q.maxTextureSize&&W>0&&W<=q.maxTextureSize,"invalid texture shape"),o(st===W,"cube map must be square"),o(v.wrapS===U&&v.wrapT===U,"wrap mode not supported by cube map");for(var ft=0;ft<A.length;++ft){var dt=A[ft];o(dt.width===st&&dt.height===W,"inconsistent cube map face shape"),v.genMipmaps&&(o(!dt.compressed,"can not generate mipmap for compressed textures"),o(dt.mipmask===1,"can not specify mipmaps and generate mipmaps"));for(var _t=dt.images,bt=0;bt<16;++bt){var vt=_t[bt];if(vt){var Tt=st>>bt,pt=W>>bt;o(dt.mipmask&1<<bt,"missing mipmap data"),o(vt.width===Tt&&vt.height===pt,"invalid shape for mip images"),o(vt.format===f.format&&vt.internalformat===f.internalformat&&vt.type===f.type,"incompatible type for mip image"),vt.compressed||(vt.data?o(vt.data.byteLength===Tt*pt*Math.max(te(vt.type,Z),vt.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):vt.element||vt.copy)}}}}var _=r(o,{optional:C,raise:a,commandRaise:m,command:T,parameter:u,commandParameter:p,constructor:nt,type:y,commandType:L,isTypedArray:d,nni:S,oneOf:M,shaderError:ne,linkError:Qt,callSite:ie,saveCommandRef:rt,saveDrawInfo:ot,framebufferFormat:R,guessCommand:Lt,texture2D:_n,textureCube:tr}),Qn=0,Ir=0,Ye=5,Zi=6;function Tn(f,v){this.id=Qn++,this.type=f,this.data=v}function di(f){return f.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function he(f){if(f.length===0)return[];var v=f.charAt(0),A=f.charAt(f.length-1);if(f.length>1&&v===A&&(v==='"'||v==="'"))return['"'+di(f.substr(1,f.length-2))+'"'];var q=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(f);if(q)return he(f.substr(0,q.index)).concat(he(q[1])).concat(he(f.substr(q.index+q[0].length)));var st=f.split(".");if(st.length===1)return['"'+di(f)+'"'];for(var W=[],Z=0;Z<st.length;++Z)W=W.concat(he(st[Z]));return W}function Mr(f){return"["+he(f).join("][")+"]"}function Ci(f,v){return new Tn(f,Mr(v+""))}function X(f){return typeof f=="function"&&!f._reglType||f instanceof Tn}function wt(f,v){if(typeof f=="function")return new Tn(Ir,f);if(typeof f=="number"||typeof f=="boolean")return new Tn(Ye,f);if(Array.isArray(f))return new Tn(Zi,f.map(function(A,q){return wt(A,v+"["+q+"]")}));if(f instanceof Tn)return f;_(!1,"invalid option type in uniform "+v)}var kt={DynamicVariable:Tn,define:Ci,isDynamic:X,unbox:wt,accessor:Mr},Gt={next:typeof requestAnimationFrame=="function"?function(f){return requestAnimationFrame(f)}:function(f){return setTimeout(f,16)},cancel:typeof cancelAnimationFrame=="function"?function(f){return cancelAnimationFrame(f)}:clearTimeout},pe=typeof performance<"u"&&performance.now?function(){return performance.now()}:function(){return+new Date};function Me(){var f={"":0},v=[""];return{id:function(A){var q=f[A];return q||(q=f[A]=v.length,v.push(A),q)},str:function(A){return v[A]}}}function $e(f,v,A){var q=document.createElement("canvas");r(q.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),f.appendChild(q),f===document.body&&(q.style.position="absolute",r(f.style,{margin:0,padding:0}));function st(){var ft=window.innerWidth,dt=window.innerHeight;if(f!==document.body){var _t=q.getBoundingClientRect();ft=_t.right-_t.left,dt=_t.bottom-_t.top}q.width=A*ft,q.height=A*dt}var W;f!==document.body&&typeof ResizeObserver=="function"?(W=new ResizeObserver(function(){setTimeout(st)}),W.observe(f)):window.addEventListener("resize",st,!1);function Z(){W?W.disconnect():window.removeEventListener("resize",st),f.removeChild(q)}return st(),{canvas:q,onDestroy:Z}}function Ce(f,v){function A(q){try{return f.getContext(q,v)}catch{return null}}return A("webgl")||A("experimental-webgl")||A("webgl-experimental")}function jn(f){return typeof f.nodeName=="string"&&typeof f.appendChild=="function"&&typeof f.getBoundingClientRect=="function"}function Mn(f){return typeof f.drawArrays=="function"||typeof f.drawElements=="function"}function ln(f){return typeof f=="string"?f.split():(_(Array.isArray(f),"invalid extension array"),f)}function vn(f){return typeof f=="string"?(_(typeof document<"u","not supported outside of DOM"),document.querySelector(f)):f}function gr(f){var v=f||{},A,q,st,W,Z={},ft=[],dt=[],_t=typeof window>"u"?1:window.devicePixelRatio,bt=!1,vt=function(gt){gt&&_.raise(gt)},Tt=function(){};if(typeof v=="string"?(_(typeof document<"u","selector queries only supported in DOM environments"),A=document.querySelector(v),_(A,"invalid query string for element")):typeof v=="object"?jn(v)?A=v:Mn(v)?(W=v,st=W.canvas):(_.constructor(v),"gl"in v?W=v.gl:"canvas"in v?st=vn(v.canvas):"container"in v&&(q=vn(v.container)),"attributes"in v&&(Z=v.attributes,_.type(Z,"object","invalid context attributes")),"extensions"in v&&(ft=ln(v.extensions)),"optionalExtensions"in v&&(dt=ln(v.optionalExtensions)),"onDone"in v&&(_.type(v.onDone,"function","invalid or missing onDone callback"),vt=v.onDone),"profile"in v&&(bt=!!v.profile),"pixelRatio"in v&&(_t=+v.pixelRatio,_(_t>0,"invalid pixel ratio"))):_.raise("invalid arguments to regl"),A&&(A.nodeName.toLowerCase()==="canvas"?st=A:q=A),!W){if(!st){_(typeof document<"u","must manually specify webgl context outside of DOM environments");var pt=$e(q||document.body,vt,_t);if(!pt)return null;st=pt.canvas,Tt=pt.onDestroy}Z.premultipliedAlpha===void 0&&(Z.premultipliedAlpha=!0),W=Ce(st,Z)}return W?{gl:W,canvas:st,container:q,extensions:ft,optionalExtensions:dt,pixelRatio:_t,profile:bt,onDone:vt,onDestroy:Tt}:(Tt(),vt("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function fi(f,v){var A={};function q(Z){_.type(Z,"string","extension name must be string");var ft=Z.toLowerCase(),dt;try{dt=A[ft]=f.getExtension(ft)}catch{}return!!dt}for(var st=0;st<v.extensions.length;++st){var W=v.extensions[st];if(!q(W))return v.onDestroy(),v.onDone('"'+W+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return v.optionalExtensions.forEach(q),{extensions:A,restore:function(){Object.keys(A).forEach(function(Z){if(A[Z]&&!q(Z))throw new Error("(regl): error restoring extension "+Z)})}}}function Ke(f,v){for(var A=Array(f),q=0;q<f;++q)A[q]=v(q);return A}var zn=5120,zt=5121,nn=5122,Gn=5123,An=5124,rn=5125,Cr=5126;function Tr(f){for(var v=16;v<=1<<28;v*=16)if(f<=v)return v;return 0}function Jr(f){var v,A;return v=(f>65535)<<4,f>>>=v,A=(f>255)<<3,f>>>=A,v|=A,A=(f>15)<<2,f>>>=A,v|=A,A=(f>3)<<1,f>>>=A,v|=A,v|f>>1}function Zr(){var f=Ke(8,function(){return[]});function v(W){var Z=Tr(W),ft=f[Jr(Z)>>2];return ft.length>0?ft.pop():new ArrayBuffer(Z)}function A(W){f[Jr(W.byteLength)>>2].push(W)}function q(W,Z){var ft=null;switch(W){case zn:ft=new Int8Array(v(Z),0,Z);break;case zt:ft=new Uint8Array(v(Z),0,Z);break;case nn:ft=new Int16Array(v(2*Z),0,Z);break;case Gn:ft=new Uint16Array(v(2*Z),0,Z);break;case An:ft=new Int32Array(v(4*Z),0,Z);break;case rn:ft=new Uint32Array(v(4*Z),0,Z);break;case Cr:ft=new Float32Array(v(4*Z),0,Z);break;default:return null}return ft.length!==Z?ft.subarray(0,Z):ft}function st(W){A(W.buffer)}return{alloc:v,free:A,allocType:q,freeType:st}}var ee=Zr();ee.zero=Zr();var me=3408,Sn=3410,xn=3411,hr=3412,Nn=3413,Yn=3414,ti=3415,ei=33901,Wr=33902,or=3379,lr=3386,_r=34921,vr=36347,Vr=36348,hi=35661,zr=35660,Hr=34930,ts=36349,Sa=34076,ys=34024,gs=7936,ah=7937,oh=7938,c8=35724,u8=34047,d8=36063,f8=34852,lh=3553,wE=34067,h8=34069,p8=33984,qc=6408,jy=5126,SE=5121,Yy=36160,m8=36053,y8=36064,g8=16384,_8=function(f,v){var A=1;v.ext_texture_filter_anisotropic&&(A=f.getParameter(u8));var q=1,st=1;v.webgl_draw_buffers&&(q=f.getParameter(f8),st=f.getParameter(d8));var W=!!v.oes_texture_float;if(W){var Z=f.createTexture();f.bindTexture(lh,Z),f.texImage2D(lh,0,qc,1,1,0,qc,jy,null);var ft=f.createFramebuffer();if(f.bindFramebuffer(Yy,ft),f.framebufferTexture2D(Yy,y8,lh,Z,0),f.bindTexture(lh,null),f.checkFramebufferStatus(Yy)!==m8)W=!1;else{f.viewport(0,0,1,1),f.clearColor(1,0,0,1),f.clear(g8);var dt=ee.allocType(jy,4);f.readPixels(0,0,1,1,qc,jy,dt),f.getError()?W=!1:(f.deleteFramebuffer(ft),f.deleteTexture(Z),W=dt[0]===1),ee.freeType(dt)}}var _t=typeof navigator<"u"&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent)),bt=!0;if(!_t){var vt=f.createTexture(),Tt=ee.allocType(SE,36);f.activeTexture(p8),f.bindTexture(wE,vt),f.texImage2D(h8,0,qc,3,3,0,qc,SE,Tt),ee.freeType(Tt),f.bindTexture(wE,null),f.deleteTexture(vt),bt=!f.getError()}return{colorBits:[f.getParameter(Sn),f.getParameter(xn),f.getParameter(hr),f.getParameter(Nn)],depthBits:f.getParameter(Yn),stencilBits:f.getParameter(ti),subpixelBits:f.getParameter(me),extensions:Object.keys(v).filter(function(pt){return!!v[pt]}),maxAnisotropic:A,maxDrawbuffers:q,maxColorAttachments:st,pointSizeDims:f.getParameter(ei),lineWidthDims:f.getParameter(Wr),maxViewportDims:f.getParameter(lr),maxCombinedTextureUnits:f.getParameter(hi),maxCubeMapSize:f.getParameter(Sa),maxRenderbufferSize:f.getParameter(ys),maxTextureUnits:f.getParameter(Hr),maxTextureSize:f.getParameter(or),maxAttributes:f.getParameter(_r),maxVertexUniforms:f.getParameter(vr),maxVertexTextureUnits:f.getParameter(zr),maxVaryingVectors:f.getParameter(Vr),maxFragmentUniforms:f.getParameter(ts),glsl:f.getParameter(c8),renderer:f.getParameter(ah),vendor:f.getParameter(gs),version:f.getParameter(oh),readFloat:W,npotTextureCube:bt}};function _s(f){return!!f&&typeof f=="object"&&Array.isArray(f.shape)&&Array.isArray(f.stride)&&typeof f.offset=="number"&&f.shape.length===f.stride.length&&(Array.isArray(f.data)||n(f.data))}var ki=function(f){return Object.keys(f).map(function(v){return f[v]})},ch={shape:S8,flatten:w8};function v8(f,v,A){for(var q=0;q<v;++q)A[q]=f[q]}function b8(f,v,A,q){for(var st=0,W=0;W<v;++W)for(var Z=f[W],ft=0;ft<A;++ft)q[st++]=Z[ft]}function EE(f,v,A,q,st,W){for(var Z=W,ft=0;ft<v;++ft)for(var dt=f[ft],_t=0;_t<A;++_t)for(var bt=dt[_t],vt=0;vt<q;++vt)st[Z++]=bt[vt]}function IE(f,v,A,q,st){for(var W=1,Z=A+1;Z<v.length;++Z)W*=v[Z];var ft=v[A];if(v.length-A===4){var dt=v[A+1],_t=v[A+2],bt=v[A+3];for(Z=0;Z<ft;++Z)EE(f[Z],dt,_t,bt,q,st),st+=W}else for(Z=0;Z<ft;++Z)IE(f[Z],v,A+1,q,st),st+=W}function w8(f,v,A,q){var st=1;if(v.length)for(var W=0;W<v.length;++W)st*=v[W];else st=0;var Z=q||ee.allocType(A,st);switch(v.length){case 0:break;case 1:v8(f,v[0],Z);break;case 2:b8(f,v[0],v[1],Z);break;case 3:EE(f,v[0],v[1],v[2],Z,0);break;default:IE(f,v,0,Z,0)}return Z}function S8(f){for(var v=[],A=f;A.length;A=A[0])v.push(A.length);return v}var Wy={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},E8=5120,I8=5122,T8=5124,A8=5121,x8=5123,N8=5125,R8=5126,B8=5126,Ao={int8:E8,int16:I8,int32:T8,uint8:A8,uint16:x8,uint32:N8,float:R8,float32:B8},O8=35048,D8=35040,uh={dynamic:O8,stream:D8,static:35044},Hy=ch.flatten,TE=ch.shape,AE=35044,F8=35040,qy=5121,Xy=5126,Ha=[];Ha[5120]=1,Ha[5122]=2,Ha[5124]=4,Ha[5121]=1,Ha[5123]=2,Ha[5125]=4,Ha[5126]=4;function dh(f){return Wy[Object.prototype.toString.call(f)]|0}function xE(f,v){for(var A=0;A<v.length;++A)f[A]=v[A]}function NE(f,v,A,q,st,W,Z){for(var ft=0,dt=0;dt<A;++dt)for(var _t=0;_t<q;++_t)f[ft++]=v[st*dt+W*_t+Z]}function L8(f,v,A,q){var st=0,W={};function Z($){this.id=st++,this.buffer=f.createBuffer(),this.type=$,this.usage=AE,this.byteLength=0,this.dimension=1,this.dtype=qy,this.persistentData=null,A.profile&&(this.stats={size:0})}Z.prototype.bind=function(){f.bindBuffer(this.type,this.buffer)},Z.prototype.destroy=function(){Tt(this)};var ft=[];function dt($,Q){var yt=ft.pop();return yt||(yt=new Z($)),yt.bind(),vt(yt,Q,F8,0,1,!1),yt}function _t($){ft.push($)}function bt($,Q,yt){$.byteLength=Q.byteLength,f.bufferData($.type,Q,yt)}function vt($,Q,yt,Pt,ct,Mt){var Ot;if($.usage=yt,Array.isArray(Q)){if($.dtype=Pt||Xy,Q.length>0){var se;if(Array.isArray(Q[0])){Ot=TE(Q);for(var at=1,it=1;it<Ot.length;++it)at*=Ot[it];$.dimension=at,se=Hy(Q,Ot,$.dtype),bt($,se,yt),Mt?$.persistentData=se:ee.freeType(se)}else if(typeof Q[0]=="number"){$.dimension=ct;var Yt=ee.allocType($.dtype,Q.length);xE(Yt,Q),bt($,Yt,yt),Mt?$.persistentData=Yt:ee.freeType(Yt)}else n(Q[0])?($.dimension=Q[0].length,$.dtype=Pt||dh(Q[0])||Xy,se=Hy(Q,[Q.length,Q[0].length],$.dtype),bt($,se,yt),Mt?$.persistentData=se:ee.freeType(se)):_.raise("invalid buffer data")}}else if(n(Q))$.dtype=Pt||dh(Q),$.dimension=ct,bt($,Q,yt),Mt&&($.persistentData=new Uint8Array(new Uint8Array(Q.buffer)));else if(_s(Q)){Ot=Q.shape;var At=Q.stride,mt=Q.offset,Nt=0,Bt=0,_e=0,de=0;Ot.length===1?(Nt=Ot[0],Bt=1,_e=At[0],de=0):Ot.length===2?(Nt=Ot[0],Bt=Ot[1],_e=At[0],de=At[1]):_.raise("invalid shape"),$.dtype=Pt||dh(Q.data)||Xy,$.dimension=Bt;var Dt=ee.allocType($.dtype,Nt*Bt);NE(Dt,Q.data,Nt,Bt,_e,de,mt),bt($,Dt,yt),Mt?$.persistentData=Dt:ee.freeType(Dt)}else Q instanceof ArrayBuffer?($.dtype=qy,$.dimension=ct,bt($,Q,yt),Mt&&($.persistentData=new Uint8Array(new Uint8Array(Q)))):_.raise("invalid buffer data")}function Tt($){v.bufferCount--,q($);var Q=$.buffer;_(Q,"buffer must not be deleted already"),f.deleteBuffer(Q),$.buffer=null,delete W[$.id]}function pt($,Q,yt,Pt){v.bufferCount++;var ct=new Z(Q);W[ct.id]=ct;function Mt(at){var it=AE,Yt=null,At=0,mt=0,Nt=1;return Array.isArray(at)||n(at)||_s(at)||at instanceof ArrayBuffer?Yt=at:typeof at=="number"?At=at|0:at&&(_.type(at,"object","buffer arguments must be an object, a number or an array"),"data"in at&&(_(Yt===null||Array.isArray(Yt)||n(Yt)||_s(Yt),"invalid data for buffer"),Yt=at.data),"usage"in at&&(_.parameter(at.usage,uh,"invalid buffer usage"),it=uh[at.usage]),"type"in at&&(_.parameter(at.type,Ao,"invalid buffer type"),mt=Ao[at.type]),"dimension"in at&&(_.type(at.dimension,"number","invalid dimension"),Nt=at.dimension|0),"length"in at&&(_.nni(At,"buffer length must be a nonnegative integer"),At=at.length|0)),ct.bind(),Yt?vt(ct,Yt,it,mt,Nt,Pt):(At&&f.bufferData(ct.type,At,it),ct.dtype=mt||qy,ct.usage=it,ct.dimension=Nt,ct.byteLength=At),A.profile&&(ct.stats.size=ct.byteLength*Ha[ct.dtype]),Mt}function Ot(at,it){_(it+at.byteLength<=ct.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+at.byteLength+" starting from offset "+it+" to a buffer of size "+ct.byteLength),f.bufferSubData(ct.type,it,at)}function se(at,it){var Yt=(it||0)|0,At;if(ct.bind(),n(at)||at instanceof ArrayBuffer)Ot(at,Yt);else if(Array.isArray(at)){if(at.length>0)if(typeof at[0]=="number"){var mt=ee.allocType(ct.dtype,at.length);xE(mt,at),Ot(mt,Yt),ee.freeType(mt)}else if(Array.isArray(at[0])||n(at[0])){At=TE(at);var Nt=Hy(at,At,ct.dtype);Ot(Nt,Yt),ee.freeType(Nt)}else _.raise("invalid buffer data")}else if(_s(at)){At=at.shape;var Bt=at.stride,_e=0,de=0,Dt=0,Ut=0;At.length===1?(_e=At[0],de=1,Dt=Bt[0],Ut=0):At.length===2?(_e=At[0],de=At[1],Dt=Bt[0],Ut=Bt[1]):_.raise("invalid shape");var oe=Array.isArray(at.data)?ct.dtype:dh(at.data),ye=ee.allocType(oe,_e*de);NE(ye,at.data,_e,de,Dt,Ut,at.offset),Ot(ye,Yt),ee.freeType(ye)}else _.raise("invalid data for buffer subdata");return Mt}return yt||Mt($),Mt._reglType="buffer",Mt._buffer=ct,Mt.subdata=se,A.profile&&(Mt.stats=ct.stats),Mt.destroy=function(){Tt(ct)},Mt}function gt(){ki(W).forEach(function($){$.buffer=f.createBuffer(),f.bindBuffer($.type,$.buffer),f.bufferData($.type,$.persistentData||$.byteLength,$.usage)})}return A.profile&&(v.getTotalBufferSize=function(){var $=0;return Object.keys(W).forEach(function(Q){$+=W[Q].stats.size}),$}),{create:pt,createStream:dt,destroyStream:_t,clear:function(){ki(W).forEach(Tt),ft.forEach(Tt)},getBuffer:function($){return $&&$._buffer instanceof Z?$._buffer:null},restore:gt,_initBuffer:vt}}var M8=0,C8=0,k8=1,U8=1,P8=4,$8=4,qa={points:M8,point:C8,lines:k8,line:U8,triangles:P8,triangle:$8,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},V8=0,z8=1,Xc=4,G8=5120,Rl=5121,RE=5122,Bl=5123,BE=5124,xo=5125,Ky=34963,j8=35040,Y8=35044;function W8(f,v,A,q){var st={},W=0,Z={uint8:Rl,uint16:Bl};v.oes_element_index_uint&&(Z.uint32=xo);function ft(gt){this.id=W++,st[this.id]=this,this.buffer=gt,this.primType=Xc,this.vertCount=0,this.type=0}ft.prototype.bind=function(){this.buffer.bind()};var dt=[];function _t(gt){var $=dt.pop();return $||($=new ft(A.create(null,Ky,!0,!1)._buffer)),vt($,gt,j8,-1,-1,0,0),$}function bt(gt){dt.push(gt)}function vt(gt,$,Q,yt,Pt,ct,Mt){gt.buffer.bind();var Ot;if($){var se=Mt;!Mt&&(!n($)||_s($)&&!n($.data))&&(se=v.oes_element_index_uint?xo:Bl),A._initBuffer(gt.buffer,$,Q,se,3)}else f.bufferData(Ky,ct,Q),gt.buffer.dtype=Ot||Rl,gt.buffer.usage=Q,gt.buffer.dimension=3,gt.buffer.byteLength=ct;if(Ot=Mt,!Mt){switch(gt.buffer.dtype){case Rl:case G8:Ot=Rl;break;case Bl:case RE:Ot=Bl;break;case xo:case BE:Ot=xo;break;default:_.raise("unsupported type for element array")}gt.buffer.dtype=Ot}gt.type=Ot,_(Ot!==xo||!!v.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var at=Pt;at<0&&(at=gt.buffer.byteLength,Ot===Bl?at>>=1:Ot===xo&&(at>>=2)),gt.vertCount=at;var it=yt;if(yt<0){it=Xc;var Yt=gt.buffer.dimension;Yt===1&&(it=V8),Yt===2&&(it=z8),Yt===3&&(it=Xc)}gt.primType=it}function Tt(gt){q.elementsCount--,_(gt.buffer!==null,"must not double destroy elements"),delete st[gt.id],gt.buffer.destroy(),gt.buffer=null}function pt(gt,$){var Q=A.create(null,Ky,!0),yt=new ft(Q._buffer);q.elementsCount++;function Pt(ct){if(!ct)Q(),yt.primType=Xc,yt.vertCount=0,yt.type=Rl;else if(typeof ct=="number")Q(ct),yt.primType=Xc,yt.vertCount=ct|0,yt.type=Rl;else{var Mt=null,Ot=Y8,se=-1,at=-1,it=0,Yt=0;Array.isArray(ct)||n(ct)||_s(ct)?Mt=ct:(_.type(ct,"object","invalid arguments for elements"),"data"in ct&&(Mt=ct.data,_(Array.isArray(Mt)||n(Mt)||_s(Mt),"invalid data for element buffer")),"usage"in ct&&(_.parameter(ct.usage,uh,"invalid element buffer usage"),Ot=uh[ct.usage]),"primitive"in ct&&(_.parameter(ct.primitive,qa,"invalid element buffer primitive"),se=qa[ct.primitive]),"count"in ct&&(_(typeof ct.count=="number"&&ct.count>=0,"invalid vertex count for elements"),at=ct.count|0),"type"in ct&&(_.parameter(ct.type,Z,"invalid buffer type"),Yt=Z[ct.type]),"length"in ct?it=ct.length|0:(it=at,Yt===Bl||Yt===RE?it*=2:(Yt===xo||Yt===BE)&&(it*=4))),vt(yt,Mt,Ot,se,at,it,Yt)}return Pt}return Pt(gt),Pt._reglType="elements",Pt._elements=yt,Pt.subdata=function(ct,Mt){return Q.subdata(ct,Mt),Pt},Pt.destroy=function(){Tt(yt)},Pt}return{create:pt,createStream:_t,destroyStream:bt,getElements:function(gt){return typeof gt=="function"&&gt._elements instanceof ft?gt._elements:null},clear:function(){ki(st).forEach(Tt)}}}var OE=new Float32Array(1),H8=new Uint32Array(OE.buffer),q8=5123;function DE(f){for(var v=ee.allocType(q8,f.length),A=0;A<f.length;++A)if(isNaN(f[A]))v[A]=65535;else if(f[A]===1/0)v[A]=31744;else if(f[A]===-1/0)v[A]=64512;else{OE[0]=f[A];var q=H8[0],st=q>>>31<<15,W=(q<<1>>>24)-127,Z=q>>13&1023;if(W<-24)v[A]=st;else if(W<-14){var ft=-14-W;v[A]=st+(Z+1024>>ft)}else W>15?v[A]=st+31744:v[A]=st+(W+15<<10)+Z}return v}function pr(f){return Array.isArray(f)||n(f)}var FE=function(f){return!(f&f-1)&&!!f},X8=34467,Ys=3553,Qy=34067,fh=34069,No=6408,Jy=6406,hh=6407,Kc=6409,ph=6410,LE=32854,Zy=32855,ME=36194,K8=32819,Q8=32820,J8=33635,Z8=34042,tg=6402,mh=34041,eg=35904,ng=35906,Ol=36193,rg=33776,ig=33777,sg=33778,ag=33779,CE=35986,kE=35987,UE=34798,PE=35840,$E=35841,VE=35842,zE=35843,GE=36196,Dl=5121,og=5123,lg=5125,Qc=5126,t4=10242,e4=10243,n4=10497,cg=33071,r4=33648,i4=10240,s4=10241,ug=9728,a4=9729,dg=9984,jE=9985,YE=9986,fg=9987,o4=33170,yh=4352,l4=4353,c4=4354,u4=34046,d4=3317,f4=37440,h4=37441,p4=37443,WE=37444,Jc=33984,m4=[dg,YE,jE,fg],gh=[0,Kc,ph,hh,No],es={};es[Kc]=es[Jy]=es[tg]=1,es[mh]=es[ph]=2,es[hh]=es[eg]=3,es[No]=es[ng]=4;function Fl(f){return"[object "+f+"]"}var HE=Fl("HTMLCanvasElement"),qE=Fl("OffscreenCanvas"),XE=Fl("CanvasRenderingContext2D"),KE=Fl("ImageBitmap"),QE=Fl("HTMLImageElement"),JE=Fl("HTMLVideoElement"),y4=Object.keys(Wy).concat([HE,qE,XE,KE,QE,JE]),Ll=[];Ll[Dl]=1,Ll[Qc]=4,Ll[Ol]=2,Ll[og]=2,Ll[lg]=4;var Gr=[];Gr[LE]=2,Gr[Zy]=2,Gr[ME]=2,Gr[mh]=4,Gr[rg]=.5,Gr[ig]=.5,Gr[sg]=1,Gr[ag]=1,Gr[CE]=.5,Gr[kE]=1,Gr[UE]=1,Gr[PE]=.5,Gr[$E]=.25,Gr[VE]=.5,Gr[zE]=.25,Gr[GE]=.5;function ZE(f){return Array.isArray(f)&&(f.length===0||typeof f[0]=="number")}function tI(f){if(!Array.isArray(f))return!1;var v=f.length;return!(v===0||!pr(f[0]))}function Ro(f){return Object.prototype.toString.call(f)}function eI(f){return Ro(f)===HE}function nI(f){return Ro(f)===qE}function g4(f){return Ro(f)===XE}function _4(f){return Ro(f)===KE}function v4(f){return Ro(f)===QE}function b4(f){return Ro(f)===JE}function hg(f){if(!f)return!1;var v=Ro(f);return y4.indexOf(v)>=0?!0:ZE(f)||tI(f)||_s(f)}function rI(f){return Wy[Object.prototype.toString.call(f)]|0}function w4(f,v){var A=v.length;switch(f.type){case Dl:case og:case lg:case Qc:var q=ee.allocType(f.type,A);q.set(v),f.data=q;break;case Ol:f.data=DE(v);break;default:_.raise("unsupported texture type, must specify a typed array")}}function iI(f,v){return ee.allocType(f.type===Ol?Qc:f.type,v)}function sI(f,v){f.type===Ol?(f.data=DE(v),ee.freeType(v)):f.data=v}function S4(f,v,A,q,st,W){for(var Z=f.width,ft=f.height,dt=f.channels,_t=Z*ft*dt,bt=iI(f,_t),vt=0,Tt=0;Tt<ft;++Tt)for(var pt=0;pt<Z;++pt)for(var gt=0;gt<dt;++gt)bt[vt++]=v[A*pt+q*Tt+st*gt+W];sI(f,bt)}function _h(f,v,A,q,st,W){var Z;if(typeof Gr[f]<"u"?Z=Gr[f]:Z=es[f]*Ll[v],W&&(Z*=6),st){for(var ft=0,dt=A;dt>=1;)ft+=Z*dt*dt,dt/=2;return ft}else return Z*A*q}function E4(f,v,A,q,st,W,Z){var ft={"don't care":yh,"dont care":yh,nice:c4,fast:l4},dt={repeat:n4,clamp:cg,mirror:r4},_t={nearest:ug,linear:a4},bt=r({mipmap:fg,"nearest mipmap nearest":dg,"linear mipmap nearest":jE,"nearest mipmap linear":YE,"linear mipmap linear":fg},_t),vt={none:0,browser:WE},Tt={uint8:Dl,rgba4:K8,rgb565:J8,"rgb5 a1":Q8},pt={alpha:Jy,luminance:Kc,"luminance alpha":ph,rgb:hh,rgba:No,rgba4:LE,"rgb5 a1":Zy,rgb565:ME},gt={};v.ext_srgb&&(pt.srgb=eg,pt.srgba=ng),v.oes_texture_float&&(Tt.float32=Tt.float=Qc),v.oes_texture_half_float&&(Tt.float16=Tt["half float"]=Ol),v.webgl_depth_texture&&(r(pt,{depth:tg,"depth stencil":mh}),r(Tt,{uint16:og,uint32:lg,"depth stencil":Z8})),v.webgl_compressed_texture_s3tc&&r(gt,{"rgb s3tc dxt1":rg,"rgba s3tc dxt1":ig,"rgba s3tc dxt3":sg,"rgba s3tc dxt5":ag}),v.webgl_compressed_texture_atc&&r(gt,{"rgb atc":CE,"rgba atc explicit alpha":kE,"rgba atc interpolated alpha":UE}),v.webgl_compressed_texture_pvrtc&&r(gt,{"rgb pvrtc 4bppv1":PE,"rgb pvrtc 2bppv1":$E,"rgba pvrtc 4bppv1":VE,"rgba pvrtc 2bppv1":zE}),v.webgl_compressed_texture_etc1&&(gt["rgb etc1"]=GE);var $=Array.prototype.slice.call(f.getParameter(X8));Object.keys(gt).forEach(function(I){var K=gt[I];$.indexOf(K)>=0&&(pt[I]=K)});var Q=Object.keys(pt);A.textureFormats=Q;var yt=[];Object.keys(pt).forEach(function(I){var K=pt[I];yt[K]=I});var Pt=[];Object.keys(Tt).forEach(function(I){var K=Tt[I];Pt[K]=I});var ct=[];Object.keys(_t).forEach(function(I){var K=_t[I];ct[K]=I});var Mt=[];Object.keys(bt).forEach(function(I){var K=bt[I];Mt[K]=I});var Ot=[];Object.keys(dt).forEach(function(I){var K=dt[I];Ot[K]=I});var se=Q.reduce(function(I,K){var Y=pt[K];return Y===Kc||Y===Jy||Y===Kc||Y===ph||Y===tg||Y===mh||v.ext_srgb&&(Y===eg||Y===ng)?I[Y]=Y:Y===Zy||K.indexOf("rgba")>=0?I[Y]=No:I[Y]=hh,I},{});function at(){this.internalformat=No,this.format=No,this.type=Dl,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=WE,this.width=0,this.height=0,this.channels=0}function it(I,K){I.internalformat=K.internalformat,I.format=K.format,I.type=K.type,I.compressed=K.compressed,I.premultiplyAlpha=K.premultiplyAlpha,I.flipY=K.flipY,I.unpackAlignment=K.unpackAlignment,I.colorSpace=K.colorSpace,I.width=K.width,I.height=K.height,I.channels=K.channels}function Yt(I,K){if(!(typeof K!="object"||!K)){if("premultiplyAlpha"in K&&(_.type(K.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),I.premultiplyAlpha=K.premultiplyAlpha),"flipY"in K&&(_.type(K.flipY,"boolean","invalid texture flip"),I.flipY=K.flipY),"alignment"in K&&(_.oneOf(K.alignment,[1,2,4,8],"invalid texture unpack alignment"),I.unpackAlignment=K.alignment),"colorSpace"in K&&(_.parameter(K.colorSpace,vt,"invalid colorSpace"),I.colorSpace=vt[K.colorSpace]),"type"in K){var Y=K.type;_(v.oes_texture_float||!(Y==="float"||Y==="float32"),"you must enable the OES_texture_float extension in order to use floating point textures."),_(v.oes_texture_half_float||!(Y==="half float"||Y==="float16"),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),_(v.webgl_depth_texture||!(Y==="uint16"||Y==="uint32"||Y==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),_.parameter(Y,Tt,"invalid texture type"),I.type=Tt[Y]}var jt=I.width,We=I.height,w=I.channels,g=!1;"shape"in K?(_(Array.isArray(K.shape)&&K.shape.length>=2,"shape must be an array"),jt=K.shape[0],We=K.shape[1],K.shape.length===3&&(w=K.shape[2],_(w>0&&w<=4,"invalid number of channels"),g=!0),_(jt>=0&&jt<=A.maxTextureSize,"invalid width"),_(We>=0&&We<=A.maxTextureSize,"invalid height")):("radius"in K&&(jt=We=K.radius,_(jt>=0&&jt<=A.maxTextureSize,"invalid radius")),"width"in K&&(jt=K.width,_(jt>=0&&jt<=A.maxTextureSize,"invalid width")),"height"in K&&(We=K.height,_(We>=0&&We<=A.maxTextureSize,"invalid height")),"channels"in K&&(w=K.channels,_(w>0&&w<=4,"invalid number of channels"),g=!0)),I.width=jt|0,I.height=We|0,I.channels=w|0;var N=!1;if("format"in K){var P=K.format;_(v.webgl_depth_texture||!(P==="depth"||P==="depth stencil"),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),_.parameter(P,pt,"invalid texture format");var z=I.internalformat=pt[P];I.format=se[z],P in Tt&&("type"in K||(I.type=Tt[P])),P in gt&&(I.compressed=!0),N=!0}!g&&N?I.channels=es[I.format]:g&&!N?I.channels!==gh[I.format]&&(I.format=I.internalformat=gh[I.channels]):N&&g&&_(I.channels===es[I.format],"number of channels inconsistent with specified format")}}function At(I){f.pixelStorei(f4,I.flipY),f.pixelStorei(h4,I.premultiplyAlpha),f.pixelStorei(p4,I.colorSpace),f.pixelStorei(d4,I.unpackAlignment)}function mt(){at.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function Nt(I,K){var Y=null;if(hg(K)?Y=K:K&&(_.type(K,"object","invalid pixel data type"),Yt(I,K),"x"in K&&(I.xOffset=K.x|0),"y"in K&&(I.yOffset=K.y|0),hg(K.data)&&(Y=K.data)),_(!I.compressed||Y instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),K.copy){_(!Y,"can not specify copy and data field for the same texture");var jt=st.viewportWidth,We=st.viewportHeight;I.width=I.width||jt-I.xOffset,I.height=I.height||We-I.yOffset,I.needsCopy=!0,_(I.xOffset>=0&&I.xOffset<jt&&I.yOffset>=0&&I.yOffset<We&&I.width>0&&I.width<=jt&&I.height>0&&I.height<=We,"copy texture read out of bounds")}else if(!Y)I.width=I.width||1,I.height=I.height||1,I.channels=I.channels||4;else if(n(Y))I.channels=I.channels||4,I.data=Y,!("type"in K)&&I.type===Dl&&(I.type=rI(Y));else if(ZE(Y))I.channels=I.channels||4,w4(I,Y),I.alignment=1,I.needsFree=!0;else if(_s(Y)){var w=Y.data;!Array.isArray(w)&&I.type===Dl&&(I.type=rI(w));var g=Y.shape,N=Y.stride,P,z,O,B,k,b;g.length===3?(O=g[2],b=N[2]):(_(g.length===2,"invalid ndarray pixel data, must be 2 or 3D"),O=1,b=1),P=g[0],z=g[1],B=N[0],k=N[1],I.alignment=1,I.width=P,I.height=z,I.channels=O,I.format=I.internalformat=gh[O],I.needsFree=!0,S4(I,w,B,k,b,Y.offset)}else if(eI(Y)||nI(Y)||g4(Y))eI(Y)||nI(Y)?I.element=Y:I.element=Y.canvas,I.width=I.element.width,I.height=I.element.height,I.channels=4;else if(_4(Y))I.element=Y,I.width=Y.width,I.height=Y.height,I.channels=4;else if(v4(Y))I.element=Y,I.width=Y.naturalWidth,I.height=Y.naturalHeight,I.channels=4;else if(b4(Y))I.element=Y,I.width=Y.videoWidth,I.height=Y.videoHeight,I.channels=4;else if(tI(Y)){var x=I.width||Y[0].length,E=I.height||Y.length,V=I.channels;pr(Y[0][0])?V=V||Y[0][0].length:V=V||1;for(var G=ch.shape(Y),lt=1,Et=0;Et<G.length;++Et)lt*=G[Et];var It=iI(I,lt);ch.flatten(Y,G,"",It),sI(I,It),I.alignment=1,I.width=x,I.height=E,I.channels=V,I.format=I.internalformat=gh[V],I.needsFree=!0}I.type===Qc?_(A.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):I.type===Ol&&_(A.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function Bt(I,K,Y){var jt=I.element,We=I.data,w=I.internalformat,g=I.format,N=I.type,P=I.width,z=I.height;At(I),jt?f.texImage2D(K,Y,g,g,N,jt):I.compressed?f.compressedTexImage2D(K,Y,w,P,z,0,We):I.needsCopy?(q(),f.copyTexImage2D(K,Y,g,I.xOffset,I.yOffset,P,z,0)):f.texImage2D(K,Y,g,P,z,0,g,N,We||null)}function _e(I,K,Y,jt,We){var w=I.element,g=I.data,N=I.internalformat,P=I.format,z=I.type,O=I.width,B=I.height;At(I),w?f.texSubImage2D(K,We,Y,jt,P,z,w):I.compressed?f.compressedTexSubImage2D(K,We,Y,jt,N,O,B,g):I.needsCopy?(q(),f.copyTexSubImage2D(K,We,Y,jt,I.xOffset,I.yOffset,O,B)):f.texSubImage2D(K,We,Y,jt,O,B,P,z,g)}var de=[];function Dt(){return de.pop()||new mt}function Ut(I){I.needsFree&&ee.freeType(I.data),mt.call(I),de.push(I)}function oe(){at.call(this),this.genMipmaps=!1,this.mipmapHint=yh,this.mipmask=0,this.images=Array(16)}function ye(I,K,Y){var jt=I.images[0]=Dt();I.mipmask=1,jt.width=I.width=K,jt.height=I.height=Y,jt.channels=I.channels=4}function He(I,K){var Y=null;if(hg(K))Y=I.images[0]=Dt(),it(Y,I),Nt(Y,K),I.mipmask=1;else if(Yt(I,K),Array.isArray(K.mipmap))for(var jt=K.mipmap,We=0;We<jt.length;++We)Y=I.images[We]=Dt(),it(Y,I),Y.width>>=We,Y.height>>=We,Nt(Y,jt[We]),I.mipmask|=1<<We;else Y=I.images[0]=Dt(),it(Y,I),Nt(Y,K),I.mipmask=1;it(I,I.images[0]),I.compressed&&(I.internalformat===rg||I.internalformat===ig||I.internalformat===sg||I.internalformat===ag)&&_(I.width%4===0&&I.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function er(I,K){for(var Y=I.images,jt=0;jt<Y.length;++jt){if(!Y[jt])return;Bt(Y[jt],K,jt)}}var ar=[];function Xe(){var I=ar.pop()||new oe;at.call(I),I.mipmask=0;for(var K=0;K<16;++K)I.images[K]=null;return I}function Ar(I){for(var K=I.images,Y=0;Y<K.length;++Y)K[Y]&&Ut(K[Y]),K[Y]=null;ar.push(I)}function Wn(){this.minFilter=ug,this.magFilter=ug,this.wrapS=cg,this.wrapT=cg,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=yh}function wr(I,K){if("min"in K){var Y=K.min;_.parameter(Y,bt),I.minFilter=bt[Y],m4.indexOf(I.minFilter)>=0&&!("faces"in K)&&(I.genMipmaps=!0)}if("mag"in K){var jt=K.mag;_.parameter(jt,_t),I.magFilter=_t[jt]}var We=I.wrapS,w=I.wrapT;if("wrap"in K){var g=K.wrap;typeof g=="string"?(_.parameter(g,dt),We=w=dt[g]):Array.isArray(g)&&(_.parameter(g[0],dt),_.parameter(g[1],dt),We=dt[g[0]],w=dt[g[1]])}else{if("wrapS"in K){var N=K.wrapS;_.parameter(N,dt),We=dt[N]}if("wrapT"in K){var P=K.wrapT;_.parameter(P,dt),w=dt[P]}}if(I.wrapS=We,I.wrapT=w,"anisotropic"in K){var z=K.anisotropic;_(typeof z=="number"&&z>=1&&z<=A.maxAnisotropic,"aniso samples must be between 1 and "),I.anisotropic=K.anisotropic}if("mipmap"in K){var O=!1;switch(typeof K.mipmap){case"string":_.parameter(K.mipmap,ft,"invalid mipmap hint"),I.mipmapHint=ft[K.mipmap],I.genMipmaps=!0,O=!0;break;case"boolean":O=I.genMipmaps=K.mipmap;break;case"object":_(Array.isArray(K.mipmap),"invalid mipmap type"),I.genMipmaps=!1,O=!0;break;default:_.raise("invalid mipmap type")}O&&!("min"in K)&&(I.minFilter=dg)}}function xr(I,K){f.texParameteri(K,s4,I.minFilter),f.texParameteri(K,i4,I.magFilter),f.texParameteri(K,t4,I.wrapS),f.texParameteri(K,e4,I.wrapT),v.ext_texture_filter_anisotropic&&f.texParameteri(K,u4,I.anisotropic),I.genMipmaps&&(f.hint(o4,I.mipmapHint),f.generateMipmap(K))}var Nr=0,kr={},jr=A.maxTextureUnits,mr=Array(jr).map(function(){return null});function ke(I){at.call(this),this.mipmask=0,this.internalformat=No,this.id=Nr++,this.refCount=1,this.target=I,this.texture=f.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new Wn,Z.profile&&(this.stats={size:0})}function Yr(I){f.activeTexture(Jc),f.bindTexture(I.target,I.texture)}function cn(){var I=mr[0];I?f.bindTexture(I.target,I.texture):f.bindTexture(Ys,null)}function ae(I){var K=I.texture;_(K,"must not double destroy texture");var Y=I.unit,jt=I.target;Y>=0&&(f.activeTexture(Jc+Y),f.bindTexture(jt,null),mr[Y]=null),f.deleteTexture(K),I.texture=null,I.params=null,I.pixels=null,I.refCount=0,delete kr[I.id],W.textureCount--}r(ke.prototype,{bind:function(){var I=this;I.bindCount+=1;var K=I.unit;if(K<0){for(var Y=0;Y<jr;++Y){var jt=mr[Y];if(jt){if(jt.bindCount>0)continue;jt.unit=-1}mr[Y]=I,K=Y;break}K>=jr&&_.raise("insufficient number of texture units"),Z.profile&&W.maxTextureUnits<K+1&&(W.maxTextureUnits=K+1),I.unit=K,f.activeTexture(Jc+K),f.bindTexture(I.target,I.texture)}return K},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&ae(this)}});function qe(I,K){var Y=new ke(Ys);kr[Y.id]=Y,W.textureCount++;function jt(g,N){var P=Y.texInfo;Wn.call(P);var z=Xe();return typeof g=="number"?typeof N=="number"?ye(z,g|0,N|0):ye(z,g|0,g|0):g?(_.type(g,"object","invalid arguments to regl.texture"),wr(P,g),He(z,g)):ye(z,1,1),P.genMipmaps&&(z.mipmask=(z.width<<1)-1),Y.mipmask=z.mipmask,it(Y,z),_.texture2D(P,z,A),Y.internalformat=z.internalformat,jt.width=z.width,jt.height=z.height,Yr(Y),er(z,Ys),xr(P,Ys),cn(),Ar(z),Z.profile&&(Y.stats.size=_h(Y.internalformat,Y.type,z.width,z.height,P.genMipmaps,!1)),jt.format=yt[Y.internalformat],jt.type=Pt[Y.type],jt.mag=ct[P.magFilter],jt.min=Mt[P.minFilter],jt.wrapS=Ot[P.wrapS],jt.wrapT=Ot[P.wrapT],jt}function We(g,N,P,z){_(!!g,"must specify image data");var O=N|0,B=P|0,k=z|0,b=Dt();return it(b,Y),b.width=0,b.height=0,Nt(b,g),b.width=b.width||(Y.width>>k)-O,b.height=b.height||(Y.height>>k)-B,_(Y.type===b.type&&Y.format===b.format&&Y.internalformat===b.internalformat,"incompatible format for texture.subimage"),_(O>=0&&B>=0&&O+b.width<=Y.width&&B+b.height<=Y.height,"texture.subimage write out of bounds"),_(Y.mipmask&1<<k,"missing mipmap data"),_(b.data||b.element||b.needsCopy,"missing image data"),Yr(Y),_e(b,Ys,O,B,k),cn(),Ut(b),jt}function w(g,N){var P=g|0,z=N|0||P;if(P===Y.width&&z===Y.height)return jt;jt.width=Y.width=P,jt.height=Y.height=z,Yr(Y);for(var O=0;Y.mipmask>>O;++O){var B=P>>O,k=z>>O;if(!B||!k)break;f.texImage2D(Ys,O,Y.format,B,k,0,Y.format,Y.type,null)}return cn(),Z.profile&&(Y.stats.size=_h(Y.internalformat,Y.type,P,z,!1,!1)),jt}return jt(I,K),jt.subimage=We,jt.resize=w,jt._reglType="texture2d",jt._texture=Y,Z.profile&&(jt.stats=Y.stats),jt.destroy=function(){Y.decRef()},jt}function Ze(I,K,Y,jt,We,w){var g=new ke(Qy);kr[g.id]=g,W.cubeCount++;var N=new Array(6);function P(B,k,b,x,E,V){var G,lt=g.texInfo;for(Wn.call(lt),G=0;G<6;++G)N[G]=Xe();if(typeof B=="number"||!B){var Et=B|0||1;for(G=0;G<6;++G)ye(N[G],Et,Et)}else if(typeof B=="object")if(k)He(N[0],B),He(N[1],k),He(N[2],b),He(N[3],x),He(N[4],E),He(N[5],V);else if(wr(lt,B),Yt(g,B),"faces"in B){var It=B.faces;for(_(Array.isArray(It)&&It.length===6,"cube faces must be a length 6 array"),G=0;G<6;++G)_(typeof It[G]=="object"&&!!It[G],"invalid input for cube map face"),it(N[G],g),He(N[G],It[G])}else for(G=0;G<6;++G)He(N[G],B);else _.raise("invalid arguments to cube map");for(it(g,N[0]),_.optional(function(){A.npotTextureCube||_(FE(g.width)&&FE(g.height),"your browser does not support non power or two texture dimensions")}),lt.genMipmaps?g.mipmask=(N[0].width<<1)-1:g.mipmask=N[0].mipmask,_.textureCube(g,lt,N,A),g.internalformat=N[0].internalformat,P.width=N[0].width,P.height=N[0].height,Yr(g),G=0;G<6;++G)er(N[G],fh+G);for(xr(lt,Qy),cn(),Z.profile&&(g.stats.size=_h(g.internalformat,g.type,P.width,P.height,lt.genMipmaps,!0)),P.format=yt[g.internalformat],P.type=Pt[g.type],P.mag=ct[lt.magFilter],P.min=Mt[lt.minFilter],P.wrapS=Ot[lt.wrapS],P.wrapT=Ot[lt.wrapT],G=0;G<6;++G)Ar(N[G]);return P}function z(B,k,b,x,E){_(!!k,"must specify image data"),_(typeof B=="number"&&B===(B|0)&&B>=0&&B<6,"invalid face");var V=b|0,G=x|0,lt=E|0,Et=Dt();return it(Et,g),Et.width=0,Et.height=0,Nt(Et,k),Et.width=Et.width||(g.width>>lt)-V,Et.height=Et.height||(g.height>>lt)-G,_(g.type===Et.type&&g.format===Et.format&&g.internalformat===Et.internalformat,"incompatible format for texture.subimage"),_(V>=0&&G>=0&&V+Et.width<=g.width&&G+Et.height<=g.height,"texture.subimage write out of bounds"),_(g.mipmask&1<<lt,"missing mipmap data"),_(Et.data||Et.element||Et.needsCopy,"missing image data"),Yr(g),_e(Et,fh+B,V,G,lt),cn(),Ut(Et),P}function O(B){var k=B|0;if(k!==g.width){P.width=g.width=k,P.height=g.height=k,Yr(g);for(var b=0;b<6;++b)for(var x=0;g.mipmask>>x;++x)f.texImage2D(fh+b,x,g.format,k>>x,k>>x,0,g.format,g.type,null);return cn(),Z.profile&&(g.stats.size=_h(g.internalformat,g.type,P.width,P.height,!1,!0)),P}}return P(I,K,Y,jt,We,w),P.subimage=z,P.resize=O,P._reglType="textureCube",P._texture=g,Z.profile&&(P.stats=g.stats),P.destroy=function(){g.decRef()},P}function yr(){for(var I=0;I<jr;++I)f.activeTexture(Jc+I),f.bindTexture(Ys,null),mr[I]=null;ki(kr).forEach(ae),W.cubeCount=0,W.textureCount=0}Z.profile&&(W.getTotalTextureSize=function(){var I=0;return Object.keys(kr).forEach(function(K){I+=kr[K].stats.size}),I});function Hs(){for(var I=0;I<jr;++I){var K=mr[I];K&&(K.bindCount=0,K.unit=-1,mr[I]=null)}ki(kr).forEach(function(Y){Y.texture=f.createTexture(),f.bindTexture(Y.target,Y.texture);for(var jt=0;jt<32;++jt)if((Y.mipmask&1<<jt)!==0)if(Y.target===Ys)f.texImage2D(Ys,jt,Y.internalformat,Y.width>>jt,Y.height>>jt,0,Y.internalformat,Y.type,null);else for(var We=0;We<6;++We)f.texImage2D(fh+We,jt,Y.internalformat,Y.width>>jt,Y.height>>jt,0,Y.internalformat,Y.type,null);xr(Y.texInfo,Y.target)})}function Co(){for(var I=0;I<jr;++I){var K=mr[I];K&&(K.bindCount=0,K.unit=-1,mr[I]=null),f.activeTexture(Jc+I),f.bindTexture(Ys,null),f.bindTexture(Qy,null)}}return{create2D:qe,createCube:Ze,clear:yr,getTexture:function(I){return null},restore:Hs,refresh:Co}}var Xa=36161,vh=32854,aI=32855,oI=36194,lI=33189,cI=36168,uI=34041,dI=35907,fI=34836,hI=34842,pI=34843,vs=[];vs[vh]=2,vs[aI]=2,vs[oI]=2,vs[lI]=2,vs[cI]=1,vs[uI]=4,vs[dI]=4,vs[fI]=16,vs[hI]=8,vs[pI]=6;function mI(f,v,A){return vs[f]*v*A}var I4=function(f,v,A,q,st){var W={rgba4:vh,rgb565:oI,"rgb5 a1":aI,depth:lI,stencil:cI,"depth stencil":uI};v.ext_srgb&&(W.srgba=dI),v.ext_color_buffer_half_float&&(W.rgba16f=hI,W.rgb16f=pI),v.webgl_color_buffer_float&&(W.rgba32f=fI);var Z=[];Object.keys(W).forEach(function(pt){var gt=W[pt];Z[gt]=pt});var ft=0,dt={};function _t(pt){this.id=ft++,this.refCount=1,this.renderbuffer=pt,this.format=vh,this.width=0,this.height=0,st.profile&&(this.stats={size:0})}_t.prototype.decRef=function(){--this.refCount<=0&&bt(this)};function bt(pt){var gt=pt.renderbuffer;_(gt,"must not double destroy renderbuffer"),f.bindRenderbuffer(Xa,null),f.deleteRenderbuffer(gt),pt.renderbuffer=null,pt.refCount=0,delete dt[pt.id],q.renderbufferCount--}function vt(pt,gt){var $=new _t(f.createRenderbuffer());dt[$.id]=$,q.renderbufferCount++;function Q(Pt,ct){var Mt=0,Ot=0,se=vh;if(typeof Pt=="object"&&Pt){var at=Pt;if("shape"in at){var it=at.shape;_(Array.isArray(it)&&it.length>=2,"invalid renderbuffer shape"),Mt=it[0]|0,Ot=it[1]|0}else"radius"in at&&(Mt=Ot=at.radius|0),"width"in at&&(Mt=at.width|0),"height"in at&&(Ot=at.height|0);"format"in at&&(_.parameter(at.format,W,"invalid renderbuffer format"),se=W[at.format])}else typeof Pt=="number"?(Mt=Pt|0,typeof ct=="number"?Ot=ct|0:Ot=Mt):Pt?_.raise("invalid arguments to renderbuffer constructor"):Mt=Ot=1;if(_(Mt>0&&Ot>0&&Mt<=A.maxRenderbufferSize&&Ot<=A.maxRenderbufferSize,"invalid renderbuffer size"),!(Mt===$.width&&Ot===$.height&&se===$.format))return Q.width=$.width=Mt,Q.height=$.height=Ot,$.format=se,f.bindRenderbuffer(Xa,$.renderbuffer),f.renderbufferStorage(Xa,se,Mt,Ot),_(f.getError()===0,"invalid render buffer format"),st.profile&&($.stats.size=mI($.format,$.width,$.height)),Q.format=Z[$.format],Q}function yt(Pt,ct){var Mt=Pt|0,Ot=ct|0||Mt;return Mt===$.width&&Ot===$.height||(_(Mt>0&&Ot>0&&Mt<=A.maxRenderbufferSize&&Ot<=A.maxRenderbufferSize,"invalid renderbuffer size"),Q.width=$.width=Mt,Q.height=$.height=Ot,f.bindRenderbuffer(Xa,$.renderbuffer),f.renderbufferStorage(Xa,$.format,Mt,Ot),_(f.getError()===0,"invalid render buffer format"),st.profile&&($.stats.size=mI($.format,$.width,$.height))),Q}return Q(pt,gt),Q.resize=yt,Q._reglType="renderbuffer",Q._renderbuffer=$,st.profile&&(Q.stats=$.stats),Q.destroy=function(){$.decRef()},Q}st.profile&&(q.getTotalRenderbufferSize=function(){var pt=0;return Object.keys(dt).forEach(function(gt){pt+=dt[gt].stats.size}),pt});function Tt(){ki(dt).forEach(function(pt){pt.renderbuffer=f.createRenderbuffer(),f.bindRenderbuffer(Xa,pt.renderbuffer),f.renderbufferStorage(Xa,pt.format,pt.width,pt.height)}),f.bindRenderbuffer(Xa,null)}return{create:vt,clear:function(){ki(dt).forEach(bt)},restore:Tt}},Ea=36160,pg=36161,Bo=3553,bh=34069,yI=36064,gI=36096,_I=36128,vI=33306,bI=36053,T4=36054,A4=36055,x4=36057,N4=36061,R4=36193,B4=5121,O4=5126,wI=6407,SI=6408,D4=6402,F4=[wI,SI],mg=[];mg[SI]=4,mg[wI]=3;var wh=[];wh[B4]=1,wh[O4]=4,wh[R4]=2;var L4=32854,M4=32855,C4=36194,k4=33189,U4=36168,EI=34041,P4=35907,$4=34836,V4=34842,z4=34843,G4=[L4,M4,C4,P4,V4,z4,$4],Ml={};Ml[bI]="complete",Ml[T4]="incomplete attachment",Ml[x4]="incomplete dimensions",Ml[A4]="incomplete, missing attachment",Ml[N4]="unsupported";function j4(f,v,A,q,st,W){var Z={cur:null,next:null,dirty:!1,setFBO:null},ft=["rgba"],dt=["rgba4","rgb565","rgb5 a1"];v.ext_srgb&&dt.push("srgba"),v.ext_color_buffer_half_float&&dt.push("rgba16f","rgb16f"),v.webgl_color_buffer_float&&dt.push("rgba32f");var _t=["uint8"];v.oes_texture_half_float&&_t.push("half float","float16"),v.oes_texture_float&&_t.push("float","float32");function bt(mt,Nt,Bt){this.target=mt,this.texture=Nt,this.renderbuffer=Bt;var _e=0,de=0;Nt?(_e=Nt.width,de=Nt.height):Bt&&(_e=Bt.width,de=Bt.height),this.width=_e,this.height=de}function vt(mt){mt&&(mt.texture&&mt.texture._texture.decRef(),mt.renderbuffer&&mt.renderbuffer._renderbuffer.decRef())}function Tt(mt,Nt,Bt){if(mt)if(mt.texture){var _e=mt.texture._texture,de=Math.max(1,_e.width),Dt=Math.max(1,_e.height);_(de===Nt&&Dt===Bt,"inconsistent width/height for supplied texture"),_e.refCount+=1}else{var Ut=mt.renderbuffer._renderbuffer;_(Ut.width===Nt&&Ut.height===Bt,"inconsistent width/height for renderbuffer"),Ut.refCount+=1}}function pt(mt,Nt){Nt&&(Nt.texture?f.framebufferTexture2D(Ea,mt,Nt.target,Nt.texture._texture.texture,0):f.framebufferRenderbuffer(Ea,mt,pg,Nt.renderbuffer._renderbuffer.renderbuffer))}function gt(mt){var Nt=Bo,Bt=null,_e=null,de=mt;typeof mt=="object"&&(de=mt.data,"target"in mt&&(Nt=mt.target|0)),_.type(de,"function","invalid attachment data");var Dt=de._reglType;return Dt==="texture2d"?(Bt=de,_(Nt===Bo)):Dt==="textureCube"?(Bt=de,_(Nt>=bh&&Nt<bh+6,"invalid cube map target")):Dt==="renderbuffer"?(_e=de,Nt=pg):_.raise("invalid regl object for attachment"),new bt(Nt,Bt,_e)}function $(mt,Nt,Bt,_e,de){if(Bt){var Dt=q.create2D({width:mt,height:Nt,format:_e,type:de});return Dt._texture.refCount=0,new bt(Bo,Dt,null)}else{var Ut=st.create({width:mt,height:Nt,format:_e});return Ut._renderbuffer.refCount=0,new bt(pg,null,Ut)}}function Q(mt){return mt&&(mt.texture||mt.renderbuffer)}function yt(mt,Nt,Bt){mt&&(mt.texture?mt.texture.resize(Nt,Bt):mt.renderbuffer&&mt.renderbuffer.resize(Nt,Bt),mt.width=Nt,mt.height=Bt)}var Pt=0,ct={};function Mt(){this.id=Pt++,ct[this.id]=this,this.framebuffer=f.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function Ot(mt){mt.colorAttachments.forEach(vt),vt(mt.depthAttachment),vt(mt.stencilAttachment),vt(mt.depthStencilAttachment)}function se(mt){var Nt=mt.framebuffer;_(Nt,"must not double destroy framebuffer"),f.deleteFramebuffer(Nt),mt.framebuffer=null,W.framebufferCount--,delete ct[mt.id]}function at(mt){var Nt;f.bindFramebuffer(Ea,mt.framebuffer);var Bt=mt.colorAttachments;for(Nt=0;Nt<Bt.length;++Nt)pt(yI+Nt,Bt[Nt]);for(Nt=Bt.length;Nt<A.maxColorAttachments;++Nt)f.framebufferTexture2D(Ea,yI+Nt,Bo,null,0);f.framebufferTexture2D(Ea,vI,Bo,null,0),f.framebufferTexture2D(Ea,gI,Bo,null,0),f.framebufferTexture2D(Ea,_I,Bo,null,0),pt(gI,mt.depthAttachment),pt(_I,mt.stencilAttachment),pt(vI,mt.depthStencilAttachment);var _e=f.checkFramebufferStatus(Ea);!f.isContextLost()&&_e!==bI&&_.raise("framebuffer configuration not supported, status = "+Ml[_e]),f.bindFramebuffer(Ea,Z.next?Z.next.framebuffer:null),Z.cur=Z.next,f.getError()}function it(mt,Nt){var Bt=new Mt;W.framebufferCount++;function _e(Dt,Ut){var oe;_(Z.next!==Bt,"can not update framebuffer which is currently in use");var ye=0,He=0,er=!0,ar=!0,Xe=null,Ar=!0,Wn="rgba",wr="uint8",xr=1,Nr=null,kr=null,jr=null,mr=!1;if(typeof Dt=="number")ye=Dt|0,He=Ut|0||ye;else if(!Dt)ye=He=1;else{_.type(Dt,"object","invalid arguments for framebuffer");var ke=Dt;if("shape"in ke){var Yr=ke.shape;_(Array.isArray(Yr)&&Yr.length>=2,"invalid shape for framebuffer"),ye=Yr[0],He=Yr[1]}else"radius"in ke&&(ye=He=ke.radius),"width"in ke&&(ye=ke.width),"height"in ke&&(He=ke.height);("color"in ke||"colors"in ke)&&(Xe=ke.color||ke.colors,Array.isArray(Xe)&&_(Xe.length===1||v.webgl_draw_buffers,"multiple render targets not supported")),Xe||("colorCount"in ke&&(xr=ke.colorCount|0,_(xr>0,"invalid color buffer count")),"colorTexture"in ke&&(Ar=!!ke.colorTexture,Wn="rgba4"),"colorType"in ke&&(wr=ke.colorType,Ar?(_(v.oes_texture_float||!(wr==="float"||wr==="float32"),"you must enable OES_texture_float in order to use floating point framebuffer objects"),_(v.oes_texture_half_float||!(wr==="half float"||wr==="float16"),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):wr==="half float"||wr==="float16"?(_(v.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),Wn="rgba16f"):(wr==="float"||wr==="float32")&&(_(v.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),Wn="rgba32f"),_.oneOf(wr,_t,"invalid color type")),"colorFormat"in ke&&(Wn=ke.colorFormat,ft.indexOf(Wn)>=0?Ar=!0:dt.indexOf(Wn)>=0?Ar=!1:_.optional(function(){Ar?_.oneOf(ke.colorFormat,ft,"invalid color format for texture"):_.oneOf(ke.colorFormat,dt,"invalid color format for renderbuffer")}))),("depthTexture"in ke||"depthStencilTexture"in ke)&&(mr=!!(ke.depthTexture||ke.depthStencilTexture),_(!mr||v.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in ke&&(typeof ke.depth=="boolean"?er=ke.depth:(Nr=ke.depth,ar=!1)),"stencil"in ke&&(typeof ke.stencil=="boolean"?ar=ke.stencil:(kr=ke.stencil,er=!1)),"depthStencil"in ke&&(typeof ke.depthStencil=="boolean"?er=ar=ke.depthStencil:(jr=ke.depthStencil,er=!1,ar=!1))}var cn=null,ae=null,qe=null,Ze=null;if(Array.isArray(Xe))cn=Xe.map(gt);else if(Xe)cn=[gt(Xe)];else for(cn=new Array(xr),oe=0;oe<xr;++oe)cn[oe]=$(ye,He,Ar,Wn,wr);_(v.webgl_draw_buffers||cn.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),_(cn.length<=A.maxColorAttachments,"too many color attachments, not supported"),ye=ye||cn[0].width,He=He||cn[0].height,Nr?ae=gt(Nr):er&&!ar&&(ae=$(ye,He,mr,"depth","uint32")),kr?qe=gt(kr):ar&&!er&&(qe=$(ye,He,!1,"stencil","uint8")),jr?Ze=gt(jr):!Nr&&!kr&&ar&&er&&(Ze=$(ye,He,mr,"depth stencil","depth stencil")),_(!!Nr+!!kr+!!jr<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var yr=null;for(oe=0;oe<cn.length;++oe)if(Tt(cn[oe],ye,He),_(!cn[oe]||cn[oe].texture&&F4.indexOf(cn[oe].texture._texture.format)>=0||cn[oe].renderbuffer&&G4.indexOf(cn[oe].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+oe+" is invalid"),cn[oe]&&cn[oe].texture){var Hs=mg[cn[oe].texture._texture.format]*wh[cn[oe].texture._texture.type];yr===null?yr=Hs:_(yr===Hs,"all color attachments much have the same number of bits per pixel.")}return Tt(ae,ye,He),_(!ae||ae.texture&&ae.texture._texture.format===D4||ae.renderbuffer&&ae.renderbuffer._renderbuffer.format===k4,"invalid depth attachment for framebuffer object"),Tt(qe,ye,He),_(!qe||qe.renderbuffer&&qe.renderbuffer._renderbuffer.format===U4,"invalid stencil attachment for framebuffer object"),Tt(Ze,ye,He),_(!Ze||Ze.texture&&Ze.texture._texture.format===EI||Ze.renderbuffer&&Ze.renderbuffer._renderbuffer.format===EI,"invalid depth-stencil attachment for framebuffer object"),Ot(Bt),Bt.width=ye,Bt.height=He,Bt.colorAttachments=cn,Bt.depthAttachment=ae,Bt.stencilAttachment=qe,Bt.depthStencilAttachment=Ze,_e.color=cn.map(Q),_e.depth=Q(ae),_e.stencil=Q(qe),_e.depthStencil=Q(Ze),_e.width=Bt.width,_e.height=Bt.height,at(Bt),_e}function de(Dt,Ut){_(Z.next!==Bt,"can not resize a framebuffer which is currently in use");var oe=Math.max(Dt|0,1),ye=Math.max(Ut|0||oe,1);if(oe===Bt.width&&ye===Bt.height)return _e;for(var He=Bt.colorAttachments,er=0;er<He.length;++er)yt(He[er],oe,ye);return yt(Bt.depthAttachment,oe,ye),yt(Bt.stencilAttachment,oe,ye),yt(Bt.depthStencilAttachment,oe,ye),Bt.width=_e.width=oe,Bt.height=_e.height=ye,at(Bt),_e}return _e(mt,Nt),r(_e,{resize:de,_reglType:"framebuffer",_framebuffer:Bt,destroy:function(){se(Bt),Ot(Bt)},use:function(Dt){Z.setFBO({framebuffer:_e},Dt)}})}function Yt(mt){var Nt=Array(6);function Bt(de){var Dt;_(Nt.indexOf(Z.next)<0,"can not update framebuffer which is currently in use");var Ut={color:null},oe=0,ye=null,He="rgba",er="uint8",ar=1;if(typeof de=="number")oe=de|0;else if(!de)oe=1;else{_.type(de,"object","invalid arguments for framebuffer");var Xe=de;if("shape"in Xe){var Ar=Xe.shape;_(Array.isArray(Ar)&&Ar.length>=2,"invalid shape for framebuffer"),_(Ar[0]===Ar[1],"cube framebuffer must be square"),oe=Ar[0]}else"radius"in Xe&&(oe=Xe.radius|0),"width"in Xe?(oe=Xe.width|0,"height"in Xe&&_(Xe.height===oe,"must be square")):"height"in Xe&&(oe=Xe.height|0);("color"in Xe||"colors"in Xe)&&(ye=Xe.color||Xe.colors,Array.isArray(ye)&&_(ye.length===1||v.webgl_draw_buffers,"multiple render targets not supported")),ye||("colorCount"in Xe&&(ar=Xe.colorCount|0,_(ar>0,"invalid color buffer count")),"colorType"in Xe&&(_.oneOf(Xe.colorType,_t,"invalid color type"),er=Xe.colorType),"colorFormat"in Xe&&(He=Xe.colorFormat,_.oneOf(Xe.colorFormat,ft,"invalid color format for texture"))),"depth"in Xe&&(Ut.depth=Xe.depth),"stencil"in Xe&&(Ut.stencil=Xe.stencil),"depthStencil"in Xe&&(Ut.depthStencil=Xe.depthStencil)}var Wn;if(ye)if(Array.isArray(ye))for(Wn=[],Dt=0;Dt<ye.length;++Dt)Wn[Dt]=ye[Dt];else Wn=[ye];else{Wn=Array(ar);var wr={radius:oe,format:He,type:er};for(Dt=0;Dt<ar;++Dt)Wn[Dt]=q.createCube(wr)}for(Ut.color=Array(Wn.length),Dt=0;Dt<Wn.length;++Dt){var xr=Wn[Dt];_(typeof xr=="function"&&xr._reglType==="textureCube","invalid cube map"),oe=oe||xr.width,_(xr.width===oe&&xr.height===oe,"invalid cube map shape"),Ut.color[Dt]={target:bh,data:Wn[Dt]}}for(Dt=0;Dt<6;++Dt){for(var Nr=0;Nr<Wn.length;++Nr)Ut.color[Nr].target=bh+Dt;Dt>0&&(Ut.depth=Nt[0].depth,Ut.stencil=Nt[0].stencil,Ut.depthStencil=Nt[0].depthStencil),Nt[Dt]?Nt[Dt](Ut):Nt[Dt]=it(Ut)}return r(Bt,{width:oe,height:oe,color:Wn})}function _e(de){var Dt,Ut=de|0;if(_(Ut>0&&Ut<=A.maxCubeMapSize,"invalid radius for cube fbo"),Ut===Bt.width)return Bt;var oe=Bt.color;for(Dt=0;Dt<oe.length;++Dt)oe[Dt].resize(Ut);for(Dt=0;Dt<6;++Dt)Nt[Dt].resize(Ut);return Bt.width=Bt.height=Ut,Bt}return Bt(mt),r(Bt,{faces:Nt,resize:_e,_reglType:"framebufferCube",destroy:function(){Nt.forEach(function(de){de.destroy()})}})}function At(){Z.cur=null,Z.next=null,Z.dirty=!0,ki(ct).forEach(function(mt){mt.framebuffer=f.createFramebuffer(),at(mt)})}return r(Z,{getFramebuffer:function(mt){if(typeof mt=="function"&&mt._reglType==="framebuffer"){var Nt=mt._framebuffer;if(Nt instanceof Mt)return Nt}return null},create:it,createCube:Yt,clear:function(){ki(ct).forEach(se)},restore:At})}var Y4=5126,II=34962,Sh=34963,TI=["attributes","elements","offset","count","primitive","instances"];function yg(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Y4,this.offset=0,this.stride=0,this.divisor=0}function W4(f,v,A,q,st,W,Z){for(var ft=A.maxAttributes,dt=new Array(ft),_t=0;_t<ft;++_t)dt[_t]=new yg;var bt=0,vt={},Tt={Record:yg,scope:{},state:dt,currentVAO:null,targetVAO:null,restore:gt()?Ot:function(){},createVAO:se,getVAO:Q,destroyBuffer:pt,setVAO:gt()?yt:Pt,clear:gt()?ct:function(){}};function pt(at){for(var it=0;it<dt.length;++it){var Yt=dt[it];Yt.buffer===at&&(f.disableVertexAttribArray(it),Yt.buffer=null)}}function gt(){return v.oes_vertex_array_object}function $(){return v.angle_instanced_arrays}function Q(at){return typeof at=="function"&&at._vao?at._vao:null}function yt(at){if(at!==Tt.currentVAO){var it=gt();at?it.bindVertexArrayOES(at.vao):it.bindVertexArrayOES(null),Tt.currentVAO=at}}function Pt(at){if(at!==Tt.currentVAO){if(at)at.bindAttrs();else{for(var it=$(),Yt=0;Yt<dt.length;++Yt){var At=dt[Yt];At.buffer?(f.enableVertexAttribArray(Yt),At.buffer.bind(),f.vertexAttribPointer(Yt,At.size,At.type,At.normalized,At.stride,At.offfset),it&&At.divisor&&it.vertexAttribDivisorANGLE(Yt,At.divisor)):(f.disableVertexAttribArray(Yt),f.vertexAttrib4f(Yt,At.x,At.y,At.z,At.w))}Z.elements?f.bindBuffer(Sh,Z.elements.buffer.buffer):f.bindBuffer(Sh,null)}Tt.currentVAO=at}}function ct(){ki(vt).forEach(function(at){at.destroy()})}function Mt(){this.id=++bt,this.attributes=[],this.elements=null,this.ownsElements=!1,this.count=0,this.offset=0,this.instances=-1,this.primitive=4;var at=gt();at?this.vao=at.createVertexArrayOES():this.vao=null,vt[this.id]=this,this.buffers=[]}Mt.prototype.bindAttrs=function(){for(var at=$(),it=this.attributes,Yt=0;Yt<it.length;++Yt){var At=it[Yt];At.buffer?(f.enableVertexAttribArray(Yt),f.bindBuffer(II,At.buffer.buffer),f.vertexAttribPointer(Yt,At.size,At.type,At.normalized,At.stride,At.offset),at&&At.divisor&&at.vertexAttribDivisorANGLE(Yt,At.divisor)):(f.disableVertexAttribArray(Yt),f.vertexAttrib4f(Yt,At.x,At.y,At.z,At.w))}for(var mt=it.length;mt<ft;++mt)f.disableVertexAttribArray(mt);var Nt=W.getElements(this.elements);Nt?f.bindBuffer(Sh,Nt.buffer.buffer):f.bindBuffer(Sh,null)},Mt.prototype.refresh=function(){var at=gt();at&&(at.bindVertexArrayOES(this.vao),this.bindAttrs(),Tt.currentVAO=null,at.bindVertexArrayOES(null))},Mt.prototype.destroy=function(){if(this.vao){var at=gt();this===Tt.currentVAO&&(Tt.currentVAO=null,at.bindVertexArrayOES(null)),at.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),vt[this.id]&&(delete vt[this.id],q.vaoCount-=1)};function Ot(){var at=gt();at&&ki(vt).forEach(function(it){it.refresh()})}function se(at){var it=new Mt;q.vaoCount+=1;function Yt(At){var mt;if(Array.isArray(At))mt=At,it.elements&&it.ownsElements&&it.elements.destroy(),it.elements=null,it.ownsElements=!1,it.offset=0,it.count=0,it.instances=-1,it.primitive=4;else{if(_(typeof At=="object","invalid arguments for create vao"),_("attributes"in At,"must specify attributes for vao"),At.elements){var Nt=At.elements;it.ownsElements?typeof Nt=="function"&&Nt._reglType==="elements"?(it.elements.destroy(),it.ownsElements=!1):(it.elements(Nt),it.ownsElements=!1):W.getElements(At.elements)?(it.elements=At.elements,it.ownsElements=!1):(it.elements=W.create(At.elements),it.ownsElements=!0)}else it.elements=null,it.ownsElements=!1;mt=At.attributes,it.offset=0,it.count=-1,it.instances=-1,it.primitive=4,it.elements&&(it.count=it.elements._elements.vertCount,it.primitive=it.elements._elements.primType),"offset"in At&&(it.offset=At.offset|0),"count"in At&&(it.count=At.count|0),"instances"in At&&(it.instances=At.instances|0),"primitive"in At&&(_(At.primitive in qa,"bad primitive type: "+At.primitive),it.primitive=qa[At.primitive]),_.optional(()=>{for(var er=Object.keys(At),ar=0;ar<er.length;++ar)_(TI.indexOf(er[ar])>=0,'invalid option for vao: "'+er[ar]+'" valid options are '+TI)}),_(Array.isArray(mt),"attributes must be an array")}_(mt.length<ft,"too many attributes"),_(mt.length>0,"must specify at least one attribute");var Bt={},_e=it.attributes;_e.length=mt.length;for(var de=0;de<mt.length;++de){var Dt=mt[de],Ut=_e[de]=new yg,oe=Dt.data||Dt;if(Array.isArray(oe)||n(oe)||_s(oe)){var ye;it.buffers[de]&&(ye=it.buffers[de],n(oe)&&ye._buffer.byteLength>=oe.byteLength?ye.subdata(oe):(ye.destroy(),it.buffers[de]=null)),it.buffers[de]||(ye=it.buffers[de]=st.create(Dt,II,!1,!0)),Ut.buffer=st.getBuffer(ye),Ut.size=Ut.buffer.dimension|0,Ut.normalized=!1,Ut.type=Ut.buffer.dtype,Ut.offset=0,Ut.stride=0,Ut.divisor=0,Ut.state=1,Bt[de]=1}else st.getBuffer(Dt)?(Ut.buffer=st.getBuffer(Dt),Ut.size=Ut.buffer.dimension|0,Ut.normalized=!1,Ut.type=Ut.buffer.dtype,Ut.offset=0,Ut.stride=0,Ut.divisor=0,Ut.state=1):st.getBuffer(Dt.buffer)?(Ut.buffer=st.getBuffer(Dt.buffer),Ut.size=(+Dt.size||Ut.buffer.dimension)|0,Ut.normalized=!!Dt.normalized||!1,"type"in Dt?(_.parameter(Dt.type,Ao,"invalid buffer type"),Ut.type=Ao[Dt.type]):Ut.type=Ut.buffer.dtype,Ut.offset=(Dt.offset||0)|0,Ut.stride=(Dt.stride||0)|0,Ut.divisor=(Dt.divisor||0)|0,Ut.state=1,_(Ut.size>=1&&Ut.size<=4,"size must be between 1 and 4"),_(Ut.offset>=0,"invalid offset"),_(Ut.stride>=0&&Ut.stride<=255,"stride must be between 0 and 255"),_(Ut.divisor>=0,"divisor must be positive"),_(!Ut.divisor||!!v.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in Dt?(_(de>0,"first attribute must not be a constant"),Ut.x=+Dt.x||0,Ut.y=+Dt.y||0,Ut.z=+Dt.z||0,Ut.w=+Dt.w||0,Ut.state=2):_(!1,"invalid attribute spec for location "+de)}for(var He=0;He<it.buffers.length;++He)!Bt[He]&&it.buffers[He]&&(it.buffers[He].destroy(),it.buffers[He]=null);return it.refresh(),Yt}return Yt.destroy=function(){for(var At=0;At<it.buffers.length;++At)it.buffers[At]&&it.buffers[At].destroy();it.buffers.length=0,it.ownsElements&&(it.elements.destroy(),it.elements=null,it.ownsElements=!1),it.destroy()},Yt._vao=it,Yt._reglType="vao",Yt(at)}return Tt}var AI=35632,H4=35633,q4=35718,X4=35721;function K4(f,v,A,q){var st={},W={};function Z($,Q,yt,Pt){this.name=$,this.id=Q,this.location=yt,this.info=Pt}function ft($,Q){for(var yt=0;yt<$.length;++yt)if($[yt].id===Q.id){$[yt].location=Q.location;return}$.push(Q)}function dt($,Q,yt){var Pt=$===AI?st:W,ct=Pt[Q];if(!ct){var Mt=v.str(Q);ct=f.createShader($),f.shaderSource(ct,Mt),f.compileShader(ct),_.shaderError(f,ct,Mt,$,yt),Pt[Q]=ct}return ct}var _t={},bt=[],vt=0;function Tt($,Q){this.id=vt++,this.fragId=$,this.vertId=Q,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,q.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function pt($,Q,yt){var Pt,ct,Mt=dt(AI,$.fragId),Ot=dt(H4,$.vertId),se=$.program=f.createProgram();if(f.attachShader(se,Mt),f.attachShader(se,Ot),yt)for(Pt=0;Pt<yt.length;++Pt){var at=yt[Pt];f.bindAttribLocation(se,at[0],at[1])}f.linkProgram(se),_.linkError(f,se,v.str($.fragId),v.str($.vertId),Q);var it=f.getProgramParameter(se,q4);q.profile&&($.stats.uniformsCount=it);var Yt=$.uniforms;for(Pt=0;Pt<it;++Pt)if(ct=f.getActiveUniform(se,Pt),ct)if(ct.size>1)for(var At=0;At<ct.size;++At){var mt=ct.name.replace("[0]","["+At+"]");ft(Yt,new Z(mt,v.id(mt),f.getUniformLocation(se,mt),ct))}else ft(Yt,new Z(ct.name,v.id(ct.name),f.getUniformLocation(se,ct.name),ct));var Nt=f.getProgramParameter(se,X4);q.profile&&($.stats.attributesCount=Nt);var Bt=$.attributes;for(Pt=0;Pt<Nt;++Pt)ct=f.getActiveAttrib(se,Pt),ct&&ft(Bt,new Z(ct.name,v.id(ct.name),f.getAttribLocation(se,ct.name),ct))}q.profile&&(A.getMaxUniformsCount=function(){var $=0;return bt.forEach(function(Q){Q.stats.uniformsCount>$&&($=Q.stats.uniformsCount)}),$},A.getMaxAttributesCount=function(){var $=0;return bt.forEach(function(Q){Q.stats.attributesCount>$&&($=Q.stats.attributesCount)}),$});function gt(){st={},W={};for(var $=0;$<bt.length;++$)pt(bt[$],null,bt[$].attributes.map(function(Q){return[Q.location,Q.name]}))}return{clear:function(){var $=f.deleteShader.bind(f);ki(st).forEach($),st={},ki(W).forEach($),W={},bt.forEach(function(Q){f.deleteProgram(Q.program)}),bt.length=0,_t={},A.shaderCount=0},program:function($,Q,yt,Pt){_.command($>=0,"missing vertex shader",yt),_.command(Q>=0,"missing fragment shader",yt);var ct=_t[Q];ct||(ct=_t[Q]={});var Mt=ct[$];if(Mt&&(Mt.refCount++,!Pt))return Mt;var Ot=new Tt(Q,$);return A.shaderCount++,pt(Ot,yt,Pt),Mt||(ct[$]=Ot),bt.push(Ot),r(Ot,{destroy:function(){if(Ot.refCount--,Ot.refCount<=0){f.deleteProgram(Ot.program);var se=bt.indexOf(Ot);bt.splice(se,1),A.shaderCount--}ct[Ot.vertId].refCount<=0&&(f.deleteShader(W[Ot.vertId]),delete W[Ot.vertId],delete _t[Ot.fragId][Ot.vertId]),Object.keys(_t[Ot.fragId]).length||(f.deleteShader(st[Ot.fragId]),delete st[Ot.fragId],delete _t[Ot.fragId])}})},restore:gt,shader:dt,frag:-1,vert:-1}}var Q4=6408,Zc=5121,J4=3333,Eh=5126;function Z4(f,v,A,q,st,W,Z){function ft(bt){var vt;v.next===null?(_(st.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),vt=Zc):(_(v.next.colorAttachments[0].texture!==null,"You cannot read from a renderbuffer"),vt=v.next.colorAttachments[0].texture._texture.type,_.optional(function(){W.oes_texture_float?(_(vt===Zc||vt===Eh,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),vt===Eh&&_(Z.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):_(vt===Zc,"Reading from a framebuffer is only allowed for the type 'uint8'")}));var Tt=0,pt=0,gt=q.framebufferWidth,$=q.framebufferHeight,Q=null;n(bt)?Q=bt:bt&&(_.type(bt,"object","invalid arguments to regl.read()"),Tt=bt.x|0,pt=bt.y|0,_(Tt>=0&&Tt<q.framebufferWidth,"invalid x offset for regl.read"),_(pt>=0&&pt<q.framebufferHeight,"invalid y offset for regl.read"),gt=(bt.width||q.framebufferWidth-Tt)|0,$=(bt.height||q.framebufferHeight-pt)|0,Q=bt.data||null),Q&&(vt===Zc?_(Q instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):vt===Eh&&_(Q instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),_(gt>0&&gt+Tt<=q.framebufferWidth,"invalid width for read pixels"),_($>0&&$+pt<=q.framebufferHeight,"invalid height for read pixels"),A();var yt=gt*$*4;return Q||(vt===Zc?Q=new Uint8Array(yt):vt===Eh&&(Q=Q||new Float32Array(yt))),_.isTypedArray(Q,"data buffer for regl.read() must be a typedarray"),_(Q.byteLength>=yt,"data buffer for regl.read() too small"),f.pixelStorei(J4,4),f.readPixels(Tt,pt,gt,$,Q4,vt,Q),Q}function dt(bt){var vt;return v.setFBO({framebuffer:bt.framebuffer},function(){vt=ft(bt)}),vt}function _t(bt){return!bt||!("framebuffer"in bt)?ft(bt):dt(bt)}return _t}function Cl(f){return Array.prototype.slice.call(f)}function kl(f){return Cl(f).join("")}function t6(){var f=0,v=[],A=[];function q(vt){for(var Tt=0;Tt<A.length;++Tt)if(A[Tt]===vt)return v[Tt];var pt="g"+f++;return v.push(pt),A.push(vt),pt}function st(){var vt=[];function Tt(){vt.push.apply(vt,Cl(arguments))}var pt=[];function gt(){var $="v"+f++;return pt.push($),arguments.length>0&&(vt.push($,"="),vt.push.apply(vt,Cl(arguments)),vt.push(";")),$}return r(Tt,{def:gt,toString:function(){return kl([pt.length>0?"var "+pt.join(",")+";":"",kl(vt)])}})}function W(){var vt=st(),Tt=st(),pt=vt.toString,gt=Tt.toString;function $(Q,yt){Tt(Q,yt,"=",vt.def(Q,yt),";")}return r(function(){vt.apply(vt,Cl(arguments))},{def:vt.def,entry:vt,exit:Tt,save:$,set:function(Q,yt,Pt){$(Q,yt),vt(Q,yt,"=",Pt,";")},toString:function(){return pt()+gt()}})}function Z(){var vt=kl(arguments),Tt=W(),pt=W(),gt=Tt.toString,$=pt.toString;return r(Tt,{then:function(){return Tt.apply(Tt,Cl(arguments)),this},else:function(){return pt.apply(pt,Cl(arguments)),this},toString:function(){var Q=$();return Q&&(Q="else{"+Q+"}"),kl(["if(",vt,"){",gt(),"}",Q])}})}var ft=st(),dt={};function _t(vt,Tt){var pt=[];function gt(){var ct="a"+pt.length;return pt.push(ct),ct}Tt=Tt||0;for(var $=0;$<Tt;++$)gt();var Q=W(),yt=Q.toString,Pt=dt[vt]=r(Q,{arg:gt,toString:function(){return kl(["function(",pt.join(),"){",yt(),"}"])}});return Pt}function bt(){var vt=['"use strict";',ft,"return {"];Object.keys(dt).forEach(function(gt){vt.push('"',gt,'":',dt[gt].toString(),",")}),vt.push("}");var Tt=kl(vt).replace(/;/g,`;
93
93
  `).replace(/}/g,`}
94
94
  `).replace(/{/g,`{
95
- `),ft=Function.apply(null,_.concat(Tt));return ft.apply(null,I)}return{global:dt,link:W,block:nt,proc:yt,scope:Y,cond:Q,compile:vt}}var Ll="xyzw".split(""),QE=5121,Ml=1,Zy=2,tg=0,eg=1,ng=2,rg=3,_h=4,JE=5,ZE=6,tI="dither",eI="blend.enable",nI="blend.color",ig="blend.equation",sg="blend.func",rI="depth.enable",iI="depth.func",sI="depth.range",aI="depth.mask",ag="colorMask",oI="cull.enable",lI="cull.face",og="frontFace",lg="lineWidth",cI="polygonOffset.enable",cg="polygonOffset.offset",uI="sample.alpha",dI="sample.enable",ug="sample.coverage",fI="stencil.enable",hI="stencil.mask",dg="stencil.func",fg="stencil.opFront",qc="stencil.opBack",pI="scissor.enable",vh="scissor.box",wa="viewport",Xc="profile",Ro="framebuffer",Kc="vert",Qc="frag",No="elements",Bo="primitive",Oo="count",bh="offset",wh="instances",Jc="vao",hg="Width",pg="Height",Cl=Ro+hg,kl=Ro+pg,k4=wa+hg,U4=wa+pg,mI="drawingBuffer",yI=mI+hg,gI=mI+pg,P4=[sg,ig,dg,fg,qc,ug,wa,vh,cg],Ul=34962,mg=34963,$4=35632,V4=35633,_I=3553,z4=34067,G4=2884,j4=3042,Y4=3024,W4=2960,H4=2929,q4=3089,X4=32823,K4=32926,Q4=32928,yg=5126,Sh=35664,Eh=35665,Ih=35666,gg=5124,Th=35667,Ah=35668,xh=35669,_g=35670,Rh=35671,Nh=35672,Bh=35673,Zc=35674,tu=35675,eu=35676,nu=35678,ru=35680,vg=4,iu=1028,Do=1029,vI=2304,bg=2305,J4=32775,Z4=32776,t6=519,qa=7680,bI=0,wI=1,SI=32774,e6=513,EI=36160,n6=36064,js={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},II=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Pl={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Xa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},TI={frag:$4,vert:V4},wg={cw:vI,ccw:bg};function Oh(d){return Array.isArray(d)||n(d)||ms(d)}function AI(d){return d.sort(function(_,I){return _===wa?-1:I===wa?1:_<I?-1:1})}function Sr(d,_,I,W){this.thisDep=d,this.contextDep=_,this.propDep=I,this.append=W}function Ka(d){return d&&!(d.thisDep||d.contextDep||d.propDep)}function hr(d){return new Sr(!1,!1,!1,d)}function Ei(d,_){var I=d.type;if(I===tg){var W=d.data.length;return new Sr(!0,W>=1,W>=2,_)}else if(I===_h){var nt=d.data;return new Sr(nt.thisDep,nt.contextDep,nt.propDep,_)}else{if(I===JE)return new Sr(!1,!1,!1,_);if(I===ZE){for(var Y=!1,Q=!1,dt=!1,ut=0;ut<d.data.length;++ut){var yt=d.data[ut];if(yt.type===eg)dt=!0;else if(yt.type===ng)Q=!0;else if(yt.type===rg)Y=!0;else if(yt.type===tg){Y=!0;var vt=yt.data;vt>=1&&(Q=!0),vt>=2&&(dt=!0)}else yt.type===_h&&(Y=Y||yt.data.thisDep,Q=Q||yt.data.contextDep,dt=dt||yt.data.propDep)}return new Sr(Y,Q,dt,_)}else return new Sr(I===rg,I===ng,I===eg,_)}}var xI=new Sr(!1,!1,!1,function(){});function r6(d,_,I,W,nt,Y,Q,dt,ut,yt,vt,gt,Tt,ft,mt){var k=yt.Record,K={add:32774,subtract:32778,"reverse subtract":32779};I.ext_blend_minmax&&(K.min=J4,K.max=Z4);var pt=I.angle_instanced_arrays,Mt=I.webgl_draw_buffers,ot=I.oes_vertex_array_object,Dt={dirty:!0,profile:mt.profile},Nt={},ee=[],rt={},et={};function Vt(b){return b.replace(".","_")}function At(b,y,x){var C=Vt(b);ee.push(b),Nt[C]=Dt[C]=!!x,rt[C]=y}function ht(b,y,x){var C=Vt(b);ee.push(b),Array.isArray(x)?(Dt[C]=x.slice(),Nt[C]=x.slice()):Dt[C]=Nt[C]=x,et[C]=y}At(tI,Y4),At(eI,j4),ht(nI,"blendColor",[0,0,0,0]),ht(ig,"blendEquationSeparate",[SI,SI]),ht(sg,"blendFuncSeparate",[wI,bI,wI,bI]),At(rI,H4,!0),ht(iI,"depthFunc",e6),ht(sI,"depthRange",[0,1]),ht(aI,"depthMask",!0),ht(ag,ag,[!0,!0,!0,!0]),At(oI,G4),ht(lI,"cullFace",Do),ht(og,og,bg),ht(lg,lg,1),At(cI,X4),ht(cg,"polygonOffset",[0,0]),At(uI,K4),At(dI,Q4),ht(ug,"sampleCoverage",[1,!1]),At(fI,W4),ht(hI,"stencilMask",-1),ht(dg,"stencilFunc",[t6,0,-1]),ht(fg,"stencilOpSeparate",[iu,qa,qa,qa]),ht(qc,"stencilOpSeparate",[Do,qa,qa,qa]),At(pI,q4),ht(vh,"scissor",[0,0,d.drawingBufferWidth,d.drawingBufferHeight]),ht(wa,wa,[0,0,d.drawingBufferWidth,d.drawingBufferHeight]);var xt={gl:d,context:Tt,strings:_,next:Nt,current:Dt,draw:gt,elements:Y,buffer:nt,shader:vt,attributes:yt.state,vao:yt,uniforms:ut,framebuffer:dt,extensions:I,timer:ft,isBufferArgs:Oh},Rt={primTypes:Wa,compareFuncs:Pl,blendFuncs:js,blendEquations:K,stencilOps:Xa,glTypes:Eo,orientationType:wg};g.optional(function(){xt.isArrayLike=ar}),Mt&&(Rt.backBuffer=[Do],Rt.drawBuffer=Ke(W.maxDrawbuffers,function(b){return b===0?[0]:Ke(b,function(y){return n6+y})}));var me=0;function de(){var b=C4(),y=b.link,x=b.global;b.id=me++,b.batchId="0";var C=y(xt),V=b.shared={props:"a0"};Object.keys(xt).forEach(function(A){V[A]=x.def(C,".",A)}),g.optional(function(){b.CHECK=y(g),b.commandStr=g.guessCommand(),b.command=y(b.commandStr),b.assert=function(A,w,P){A("if(!(",w,"))",this.CHECK,".commandRaise(",y(P),",",this.command,");")},Rt.invalidBlendCombinations=II});var N=b.next={},R=b.current={};Object.keys(et).forEach(function(A){Array.isArray(Dt[A])&&(N[A]=x.def(V.next,".",A),R[A]=x.def(V.current,".",A))});var M=b.constants={};Object.keys(Rt).forEach(function(A){M[A]=x.def(JSON.stringify(Rt[A]))}),b.invoke=function(A,w){switch(w.type){case tg:var P=["this",V.context,V.props,b.batchId];return A.def(y(w.data),".call(",P.slice(0,Math.max(w.data.length+1,4)),")");case eg:return A.def(V.props,w.data);case ng:return A.def(V.context,w.data);case rg:return A.def("this",w.data);case _h:return w.data.append(b,A),w.data.ref;case JE:return w.data.toString();case ZE:return w.data.map(function(G){return b.invoke(A,G)})}},b.attribCache={};var v={};return b.scopeAttrib=function(A){var w=_.id(A);if(w in v)return v[w];var P=yt.scope[w];P||(P=yt.scope[w]=new k);var G=v[w]=y(P);return G},b}function Bt(b){var y=b.static,x=b.dynamic,C;if(Xc in y){var V=!!y[Xc];C=hr(function(R,M){return V}),C.enable=V}else if(Xc in x){var N=x[Xc];C=Ei(N,function(R,M){return R.invoke(M,N)})}return C}function Lt(b,y){var x=b.static,C=b.dynamic;if(Ro in x){var V=x[Ro];return V?(V=dt.getFramebuffer(V),g.command(V,"invalid framebuffer object"),hr(function(R,M){var v=R.link(V),A=R.shared;M.set(A.framebuffer,".next",v);var w=A.context;return M.set(w,"."+Cl,v+".width"),M.set(w,"."+kl,v+".height"),v})):hr(function(R,M){var v=R.shared;M.set(v.framebuffer,".next","null");var A=v.context;return M.set(A,"."+Cl,A+"."+yI),M.set(A,"."+kl,A+"."+gI),"null"})}else if(Ro in C){var N=C[Ro];return Ei(N,function(R,M){var v=R.invoke(M,N),A=R.shared,w=A.framebuffer,P=M.def(w,".getFramebuffer(",v,")");g.optional(function(){R.assert(M,"!"+v+"||"+P,"invalid framebuffer object")}),M.set(w,".next",P);var G=A.context;return M.set(G,"."+Cl,P+"?"+P+".width:"+G+"."+yI),M.set(G,"."+kl,P+"?"+P+".height:"+G+"."+gI),P})}else return null}function ie(b,y,x){var C=b.static,V=b.dynamic;function N(v){if(v in C){var A=C[v];g.commandType(A,"object","invalid "+v,x.commandStr);var w=!0,P=A.x|0,G=A.y|0,it,Et;return"width"in A?(it=A.width|0,g.command(it>=0,"invalid "+v,x.commandStr)):w=!1,"height"in A?(Et=A.height|0,g.command(Et>=0,"invalid "+v,x.commandStr)):w=!1,new Sr(!w&&y&&y.thisDep,!w&&y&&y.contextDep,!w&&y&&y.propDep,function(St,jt){var Ct=St.shared.context,zt=it;"width"in A||(zt=jt.def(Ct,".",Cl,"-",P));var Gt=Et;return"height"in A||(Gt=jt.def(Ct,".",kl,"-",G)),[P,G,zt,Gt]})}else if(v in V){var It=V[v],Ot=Ei(It,function(St,jt){var Ct=St.invoke(jt,It);g.optional(function(){St.assert(jt,Ct+"&&typeof "+Ct+'==="object"',"invalid "+v)});var zt=St.shared.context,Gt=jt.def(Ct,".x|0"),Yt=jt.def(Ct,".y|0"),se=jt.def('"width" in ',Ct,"?",Ct,".width|0:","(",zt,".",Cl,"-",Gt,")"),Nn=jt.def('"height" in ',Ct,"?",Ct,".height|0:","(",zt,".",kl,"-",Yt,")");return g.optional(function(){St.assert(jt,se+">=0&&"+Nn+">=0","invalid "+v)}),[Gt,Yt,se,Nn]});return y&&(Ot.thisDep=Ot.thisDep||y.thisDep,Ot.contextDep=Ot.contextDep||y.contextDep,Ot.propDep=Ot.propDep||y.propDep),Ot}else return y?new Sr(y.thisDep,y.contextDep,y.propDep,function(St,jt){var Ct=St.shared.context;return[0,0,jt.def(Ct,".",Cl),jt.def(Ct,".",kl)]}):null}var R=N(wa);if(R){var M=R;R=new Sr(R.thisDep,R.contextDep,R.propDep,function(v,A){var w=M.append(v,A),P=v.shared.context;return A.set(P,"."+k4,w[2]),A.set(P,"."+U4,w[3]),w})}return{viewport:R,scissor_box:N(vh)}}function pe(b,y){var x=b.static,C=typeof x[Qc]=="string"&&typeof x[Kc]=="string";if(C){if(Object.keys(y.dynamic).length>0)return null;var V=y.static,N=Object.keys(V);if(N.length>0&&typeof V[N[0]]=="number"){for(var R=[],M=0;M<N.length;++M)g(typeof V[N[M]]=="number","must specify all vertex attribute locations when using vaos"),R.push([V[N[M]]|0,N[M]]);return R}}return null}function We(b,y,x){var C=b.static,V=b.dynamic;function N(w){if(w in C){var P=_.id(C[w]);g.optional(function(){vt.shader(TI[w],P,g.guessCommand())});var G=hr(function(){return P});return G.id=P,G}else if(w in V){var it=V[w];return Ei(it,function(Et,It){var Ot=Et.invoke(It,it),St=It.def(Et.shared.strings,".id(",Ot,")");return g.optional(function(){It(Et.shared.shader,".shader(",TI[w],",",St,",",Et.command,");")}),St})}return null}var R=N(Qc),M=N(Kc),v=null,A;return Ka(R)&&Ka(M)?(v=vt.program(M.id,R.id,null,x),A=hr(function(w,P){return w.link(v)})):A=new Sr(R&&R.thisDep||M&&M.thisDep,R&&R.contextDep||M&&M.contextDep,R&&R.propDep||M&&M.propDep,function(w,P){var G=w.shared.shader,it;R?it=R.append(w,P):it=P.def(G,".",Qc);var Et;M?Et=M.append(w,P):Et=P.def(G,".",Kc);var It=G+".program("+Et+","+it;return g.optional(function(){It+=","+w.command}),P.def(It+")")}),{frag:R,vert:M,progVar:A,program:v}}function qn(b,y){var x=b.static,C=b.dynamic,V={},N=!1;function R(){if(Jc in x){var jt=x[Jc];return jt!==null&&yt.getVAO(jt)===null&&(jt=yt.createVAO(jt)),N=!0,V.vao=jt,hr(function(zt){var Gt=yt.getVAO(jt);return Gt?zt.link(Gt):"null"})}else if(Jc in C){N=!0;var Ct=C[Jc];return Ei(Ct,function(zt,Gt){var Yt=zt.invoke(Gt,Ct);return Gt.def(zt.shared.vao+".getVAO("+Yt+")")})}return null}var M=R(),v=!1;function A(){if(No in x){var jt=x[No];if(V.elements=jt,Oh(jt)){var Ct=V.elements=Y.create(jt,!0);jt=Y.getElements(Ct),v=!0}else jt&&(jt=Y.getElements(jt),v=!0,g.command(jt,"invalid elements",y.commandStr));var zt=hr(function(Yt,se){if(jt){var Nn=Yt.link(jt);return Yt.ELEMENTS=Nn,Nn}return Yt.ELEMENTS=null,null});return zt.value=jt,zt}else if(No in C){v=!0;var Gt=C[No];return Ei(Gt,function(Yt,se){var Nn=Yt.shared,Dr=Nn.isBufferArgs,Sa=Nn.elements,Ea=Yt.invoke(se,Gt),Ia=se.def("null"),Zr=se.def(Dr,"(",Ea,")"),Ws=Yt.cond(Zr).then(Ia,"=",Sa,".createStream(",Ea,");").else(Ia,"=",Sa,".getElements(",Ea,");");return g.optional(function(){Yt.assert(Ws.else,"!"+Ea+"||"+Ia,"invalid elements")}),se.entry(Ws),se.exit(Yt.cond(Zr).then(Sa,".destroyStream(",Ia,");")),Yt.ELEMENTS=Ia,Ia})}else if(N)return new Sr(M.thisDep,M.contextDep,M.propDep,function(Yt,se){return se.def(Yt.shared.vao+".currentVAO?"+Yt.shared.elements+".getElements("+Yt.shared.vao+".currentVAO.elements):null")});return null}var w=A();function P(){if(Bo in x){var jt=x[Bo];return V.primitive=jt,g.commandParameter(jt,Wa,"invalid primitve",y.commandStr),hr(function(zt,Gt){return Wa[jt]})}else if(Bo in C){var Ct=C[Bo];return Ei(Ct,function(zt,Gt){var Yt=zt.constants.primTypes,se=zt.invoke(Gt,Ct);return g.optional(function(){zt.assert(Gt,se+" in "+Yt,"invalid primitive, must be one of "+Object.keys(Wa))}),Gt.def(Yt,"[",se,"]")})}else{if(v)return Ka(w)?w.value?hr(function(zt,Gt){return Gt.def(zt.ELEMENTS,".primType")}):hr(function(){return vg}):new Sr(w.thisDep,w.contextDep,w.propDep,function(zt,Gt){var Yt=zt.ELEMENTS;return Gt.def(Yt,"?",Yt,".primType:",vg)});if(N)return new Sr(M.thisDep,M.contextDep,M.propDep,function(zt,Gt){return Gt.def(zt.shared.vao+".currentVAO?"+zt.shared.vao+".currentVAO.primitive:"+vg)})}return null}function G(jt,Ct){if(jt in x){var zt=x[jt]|0;return Ct?V.offset=zt:V.instances=zt,g.command(!Ct||zt>=0,"invalid "+jt,y.commandStr),hr(function(Yt,se){return Ct&&(Yt.OFFSET=zt),zt})}else if(jt in C){var Gt=C[jt];return Ei(Gt,function(Yt,se){var Nn=Yt.invoke(se,Gt);return Ct&&(Yt.OFFSET=Nn,g.optional(function(){Yt.assert(se,Nn+">=0","invalid "+jt)})),Nn})}else if(Ct){if(v)return hr(function(Yt,se){return Yt.OFFSET=0,0});if(N)return new Sr(M.thisDep,M.contextDep,M.propDep,function(Yt,se){return se.def(Yt.shared.vao+".currentVAO?"+Yt.shared.vao+".currentVAO.offset:0")})}else if(N)return new Sr(M.thisDep,M.contextDep,M.propDep,function(Yt,se){return se.def(Yt.shared.vao+".currentVAO?"+Yt.shared.vao+".currentVAO.instances:-1")});return null}var it=G(bh,!0);function Et(){if(Oo in x){var jt=x[Oo]|0;return V.count=jt,g.command(typeof jt=="number"&&jt>=0,"invalid vertex count",y.commandStr),hr(function(){return jt})}else if(Oo in C){var Ct=C[Oo];return Ei(Ct,function(se,Nn){var Dr=se.invoke(Nn,Ct);return g.optional(function(){se.assert(Nn,"typeof "+Dr+'==="number"&&'+Dr+">=0&&"+Dr+"===("+Dr+"|0)","invalid vertex count")}),Dr})}else if(v)if(Ka(w)){if(w)return it?new Sr(it.thisDep,it.contextDep,it.propDep,function(se,Nn){var Dr=Nn.def(se.ELEMENTS,".vertCount-",se.OFFSET);return g.optional(function(){se.assert(Nn,Dr+">=0","invalid vertex offset/element buffer too small")}),Dr}):hr(function(se,Nn){return Nn.def(se.ELEMENTS,".vertCount")});var zt=hr(function(){return-1});return g.optional(function(){zt.MISSING=!0}),zt}else{var Gt=new Sr(w.thisDep||it.thisDep,w.contextDep||it.contextDep,w.propDep||it.propDep,function(se,Nn){var Dr=se.ELEMENTS;return se.OFFSET?Nn.def(Dr,"?",Dr,".vertCount-",se.OFFSET,":-1"):Nn.def(Dr,"?",Dr,".vertCount:-1")});return g.optional(function(){Gt.DYNAMIC=!0}),Gt}else if(N){var Yt=new Sr(M.thisDep,M.contextDep,M.propDep,function(se,Nn){return Nn.def(se.shared.vao,".currentVAO?",se.shared.vao,".currentVAO.count:-1")});return Yt}return null}var It=P(),Ot=Et(),St=G(wh,!1);return{elements:w,primitive:It,count:Ot,instances:St,offset:it,vao:M,vaoActive:N,elementsActive:v,static:V}}function Jn(b,y){var x=b.static,C=b.dynamic,V={};return ee.forEach(function(N){var R=Vt(N);function M(v,A){if(N in x){var w=v(x[N]);V[R]=hr(function(){return w})}else if(N in C){var P=C[N];V[R]=Ei(P,function(G,it){return A(G,it,G.invoke(it,P))})}}switch(N){case oI:case eI:case tI:case fI:case rI:case pI:case cI:case uI:case dI:case aI:return M(function(v){return g.commandType(v,"boolean",N,y.commandStr),v},function(v,A,w){return g.optional(function(){v.assert(A,"typeof "+w+'==="boolean"',"invalid flag "+N,v.commandStr)}),w});case iI:return M(function(v){return g.commandParameter(v,Pl,"invalid "+N,y.commandStr),Pl[v]},function(v,A,w){var P=v.constants.compareFuncs;return g.optional(function(){v.assert(A,w+" in "+P,"invalid "+N+", must be one of "+Object.keys(Pl))}),A.def(P,"[",w,"]")});case sI:return M(function(v){return g.command(ar(v)&&v.length===2&&typeof v[0]=="number"&&typeof v[1]=="number"&&v[0]<=v[1],"depth range is 2d array",y.commandStr),v},function(v,A,w){g.optional(function(){v.assert(A,v.shared.isArrayLike+"("+w+")&&"+w+".length===2&&typeof "+w+'[0]==="number"&&typeof '+w+'[1]==="number"&&'+w+"[0]<="+w+"[1]","depth range must be a 2d array")});var P=A.def("+",w,"[0]"),G=A.def("+",w,"[1]");return[P,G]});case sg:return M(function(v){g.commandType(v,"object","blend.func",y.commandStr);var A="srcRGB"in v?v.srcRGB:v.src,w="srcAlpha"in v?v.srcAlpha:v.src,P="dstRGB"in v?v.dstRGB:v.dst,G="dstAlpha"in v?v.dstAlpha:v.dst;return g.commandParameter(A,js,R+".srcRGB",y.commandStr),g.commandParameter(w,js,R+".srcAlpha",y.commandStr),g.commandParameter(P,js,R+".dstRGB",y.commandStr),g.commandParameter(G,js,R+".dstAlpha",y.commandStr),g.command(II.indexOf(A+", "+P)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+A+", "+P+")",y.commandStr),[js[A],js[P],js[w],js[G]]},function(v,A,w){var P=v.constants.blendFuncs;g.optional(function(){v.assert(A,w+"&&typeof "+w+'==="object"',"invalid blend func, must be an object")});function G(Ct,zt){var Gt=A.def('"',Ct,zt,'" in ',w,"?",w,".",Ct,zt,":",w,".",Ct);return g.optional(function(){v.assert(A,Gt+" in "+P,"invalid "+N+"."+Ct+zt+", must be one of "+Object.keys(js))}),Gt}var it=G("src","RGB"),Et=G("dst","RGB");g.optional(function(){var Ct=v.constants.invalidBlendCombinations;v.assert(A,Ct+".indexOf("+it+'+", "+'+Et+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var It=A.def(P,"[",it,"]"),Ot=A.def(P,"[",G("src","Alpha"),"]"),St=A.def(P,"[",Et,"]"),jt=A.def(P,"[",G("dst","Alpha"),"]");return[It,St,Ot,jt]});case ig:return M(function(v){if(typeof v=="string")return g.commandParameter(v,K,"invalid "+N,y.commandStr),[K[v],K[v]];if(typeof v=="object")return g.commandParameter(v.rgb,K,N+".rgb",y.commandStr),g.commandParameter(v.alpha,K,N+".alpha",y.commandStr),[K[v.rgb],K[v.alpha]];g.commandRaise("invalid blend.equation",y.commandStr)},function(v,A,w){var P=v.constants.blendEquations,G=A.def(),it=A.def(),Et=v.cond("typeof ",w,'==="string"');return g.optional(function(){function It(Ot,St,jt){v.assert(Ot,jt+" in "+P,"invalid "+St+", must be one of "+Object.keys(K))}It(Et.then,N,w),v.assert(Et.else,w+"&&typeof "+w+'==="object"',"invalid "+N),It(Et.else,N+".rgb",w+".rgb"),It(Et.else,N+".alpha",w+".alpha")}),Et.then(G,"=",it,"=",P,"[",w,"];"),Et.else(G,"=",P,"[",w,".rgb];",it,"=",P,"[",w,".alpha];"),A(Et),[G,it]});case nI:return M(function(v){return g.command(ar(v)&&v.length===4,"blend.color must be a 4d array",y.commandStr),Ke(4,function(A){return+v[A]})},function(v,A,w){return g.optional(function(){v.assert(A,v.shared.isArrayLike+"("+w+")&&"+w+".length===4","blend.color must be a 4d array")}),Ke(4,function(P){return A.def("+",w,"[",P,"]")})});case hI:return M(function(v){return g.commandType(v,"number",R,y.commandStr),v|0},function(v,A,w){return g.optional(function(){v.assert(A,"typeof "+w+'==="number"',"invalid stencil.mask")}),A.def(w,"|0")});case dg:return M(function(v){g.commandType(v,"object",R,y.commandStr);var A=v.cmp||"keep",w=v.ref||0,P="mask"in v?v.mask:-1;return g.commandParameter(A,Pl,N+".cmp",y.commandStr),g.commandType(w,"number",N+".ref",y.commandStr),g.commandType(P,"number",N+".mask",y.commandStr),[Pl[A],w,P]},function(v,A,w){var P=v.constants.compareFuncs;g.optional(function(){function It(){v.assert(A,Array.prototype.join.call(arguments,""),"invalid stencil.func")}It(w+"&&typeof ",w,'==="object"'),It('!("cmp" in ',w,")||(",w,".cmp in ",P,")")});var G=A.def('"cmp" in ',w,"?",P,"[",w,".cmp]",":",qa),it=A.def(w,".ref|0"),Et=A.def('"mask" in ',w,"?",w,".mask|0:-1");return[G,it,Et]});case fg:case qc:return M(function(v){g.commandType(v,"object",R,y.commandStr);var A=v.fail||"keep",w=v.zfail||"keep",P=v.zpass||"keep";return g.commandParameter(A,Xa,N+".fail",y.commandStr),g.commandParameter(w,Xa,N+".zfail",y.commandStr),g.commandParameter(P,Xa,N+".zpass",y.commandStr),[N===qc?Do:iu,Xa[A],Xa[w],Xa[P]]},function(v,A,w){var P=v.constants.stencilOps;g.optional(function(){v.assert(A,w+"&&typeof "+w+'==="object"',"invalid "+N)});function G(it){return g.optional(function(){v.assert(A,'!("'+it+'" in '+w+")||("+w+"."+it+" in "+P+")","invalid "+N+"."+it+", must be one of "+Object.keys(Xa))}),A.def('"',it,'" in ',w,"?",P,"[",w,".",it,"]:",qa)}return[N===qc?Do:iu,G("fail"),G("zfail"),G("zpass")]});case cg:return M(function(v){g.commandType(v,"object",R,y.commandStr);var A=v.factor|0,w=v.units|0;return g.commandType(A,"number",R+".factor",y.commandStr),g.commandType(w,"number",R+".units",y.commandStr),[A,w]},function(v,A,w){g.optional(function(){v.assert(A,w+"&&typeof "+w+'==="object"',"invalid "+N)});var P=A.def(w,".factor|0"),G=A.def(w,".units|0");return[P,G]});case lI:return M(function(v){var A=0;return v==="front"?A=iu:v==="back"&&(A=Do),g.command(!!A,R,y.commandStr),A},function(v,A,w){return g.optional(function(){v.assert(A,w+'==="front"||'+w+'==="back"',"invalid cull.face")}),A.def(w,'==="front"?',iu,":",Do)});case lg:return M(function(v){return g.command(typeof v=="number"&&v>=W.lineWidthDims[0]&&v<=W.lineWidthDims[1],"invalid line width, must be a positive number between "+W.lineWidthDims[0]+" and "+W.lineWidthDims[1],y.commandStr),v},function(v,A,w){return g.optional(function(){v.assert(A,"typeof "+w+'==="number"&&'+w+">="+W.lineWidthDims[0]+"&&"+w+"<="+W.lineWidthDims[1],"invalid line width")}),w});case og:return M(function(v){return g.commandParameter(v,wg,R,y.commandStr),wg[v]},function(v,A,w){return g.optional(function(){v.assert(A,w+'==="cw"||'+w+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),A.def(w+'==="cw"?'+vI+":"+bg)});case ag:return M(function(v){return g.command(ar(v)&&v.length===4,"color.mask must be length 4 array",y.commandStr),v.map(function(A){return!!A})},function(v,A,w){return g.optional(function(){v.assert(A,v.shared.isArrayLike+"("+w+")&&"+w+".length===4","invalid color.mask")}),Ke(4,function(P){return"!!"+w+"["+P+"]"})});case ug:return M(function(v){g.command(typeof v=="object"&&v,R,y.commandStr);var A="value"in v?v.value:1,w=!!v.invert;return g.command(typeof A=="number"&&A>=0&&A<=1,"sample.coverage.value must be a number between 0 and 1",y.commandStr),[A,w]},function(v,A,w){g.optional(function(){v.assert(A,w+"&&typeof "+w+'==="object"',"invalid sample.coverage")});var P=A.def('"value" in ',w,"?+",w,".value:1"),G=A.def("!!",w,".invert");return[P,G]})}}),V}function qe(b,y){var x=b.static,C=b.dynamic,V={};return Object.keys(x).forEach(function(N){var R=x[N],M;if(typeof R=="number"||typeof R=="boolean")M=hr(function(){return R});else if(typeof R=="function"){var v=R._reglType;v==="texture2d"||v==="textureCube"?M=hr(function(A){return A.link(R)}):v==="framebuffer"||v==="framebufferCube"?(g.command(R.color.length>0,'missing color attachment for framebuffer sent to uniform "'+N+'"',y.commandStr),M=hr(function(A){return A.link(R.color[0])})):g.commandRaise('invalid data for uniform "'+N+'"',y.commandStr)}else ar(R)?M=hr(function(A){var w=A.global.def("[",Ke(R.length,function(P){return g.command(typeof R[P]=="number"||typeof R[P]=="boolean","invalid uniform "+N,A.commandStr),R[P]}),"]");return w}):g.commandRaise('invalid or missing data for uniform "'+N+'"',y.commandStr);M.value=R,V[N]=M}),Object.keys(C).forEach(function(N){var R=C[N];V[N]=Ei(R,function(M,v){return M.invoke(v,R)})}),V}function vr(b,y){var x=b.static,C=b.dynamic,V={};return Object.keys(x).forEach(function(N){var R=x[N],M=_.id(N),v=new k;if(Oh(R))v.state=Ml,v.buffer=nt.getBuffer(nt.create(R,Ul,!1,!0)),v.type=0;else{var A=nt.getBuffer(R);if(A)v.state=Ml,v.buffer=A,v.type=0;else if(g.command(typeof R=="object"&&R,"invalid data for attribute "+N,y.commandStr),"constant"in R){var w=R.constant;v.buffer="null",v.state=Zy,typeof w=="number"?v.x=w:(g.command(ar(w)&&w.length>0&&w.length<=4,"invalid constant for attribute "+N,y.commandStr),Ll.forEach(function(St,jt){jt<w.length&&(v[St]=w[jt])}))}else{Oh(R.buffer)?A=nt.getBuffer(nt.create(R.buffer,Ul,!1,!0)):A=nt.getBuffer(R.buffer),g.command(!!A,'missing buffer for attribute "'+N+'"',y.commandStr);var P=R.offset|0;g.command(P>=0,'invalid offset for attribute "'+N+'"',y.commandStr);var G=R.stride|0;g.command(G>=0&&G<256,'invalid stride for attribute "'+N+'", must be integer betweeen [0, 255]',y.commandStr);var it=R.size|0;g.command(!("size"in R)||it>0&&it<=4,'invalid size for attribute "'+N+'", must be 1,2,3,4',y.commandStr);var Et=!!R.normalized,It=0;"type"in R&&(g.commandParameter(R.type,Eo,"invalid type for attribute "+N,y.commandStr),It=Eo[R.type]);var Ot=R.divisor|0;g.optional(function(){"divisor"in R&&(g.command(Ot===0||pt,'cannot specify divisor for attribute "'+N+'", instancing not supported',y.commandStr),g.command(Ot>=0,'invalid divisor for attribute "'+N+'"',y.commandStr));var St=y.commandStr,jt=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(R).forEach(function(Ct){g.command(jt.indexOf(Ct)>=0,'unknown parameter "'+Ct+'" for attribute pointer "'+N+'" (valid parameters are '+jt+")",St)})}),v.buffer=A,v.state=Ml,v.size=it,v.normalized=Et,v.type=It||A.dtype,v.offset=P,v.stride=G,v.divisor=Ot}}V[N]=hr(function(St,jt){var Ct=St.attribCache;if(M in Ct)return Ct[M];var zt={isStream:!1};return Object.keys(v).forEach(function(Gt){zt[Gt]=v[Gt]}),v.buffer&&(zt.buffer=St.link(v.buffer),zt.type=zt.type||zt.buffer+".dtype"),Ct[M]=zt,zt})}),Object.keys(C).forEach(function(N){var R=C[N];function M(v,A){var w=v.invoke(A,R),P=v.shared,G=v.constants,it=P.isBufferArgs,Et=P.buffer;g.optional(function(){v.assert(A,w+"&&(typeof "+w+'==="object"||typeof '+w+'==="function")&&('+it+"("+w+")||"+Et+".getBuffer("+w+")||"+Et+".getBuffer("+w+".buffer)||"+it+"("+w+'.buffer)||("constant" in '+w+"&&(typeof "+w+'.constant==="number"||'+P.isArrayLike+"("+w+".constant))))",'invalid dynamic attribute "'+N+'"')});var It={isStream:A.def(!1)},Ot=new k;Ot.state=Ml,Object.keys(Ot).forEach(function(zt){It[zt]=A.def(""+Ot[zt])});var St=It.buffer,jt=It.type;A("if(",it,"(",w,")){",It.isStream,"=true;",St,"=",Et,".createStream(",Ul,",",w,");",jt,"=",St,".dtype;","}else{",St,"=",Et,".getBuffer(",w,");","if(",St,"){",jt,"=",St,".dtype;",'}else if("constant" in ',w,"){",It.state,"=",Zy,";","if(typeof "+w+'.constant === "number"){',It[Ll[0]],"=",w,".constant;",Ll.slice(1).map(function(zt){return It[zt]}).join("="),"=0;","}else{",Ll.map(function(zt,Gt){return It[zt]+"="+w+".constant.length>"+Gt+"?"+w+".constant["+Gt+"]:0;"}).join(""),"}}else{","if(",it,"(",w,".buffer)){",St,"=",Et,".createStream(",Ul,",",w,".buffer);","}else{",St,"=",Et,".getBuffer(",w,".buffer);","}",jt,'="type" in ',w,"?",G.glTypes,"[",w,".type]:",St,".dtype;",It.normalized,"=!!",w,".normalized;");function Ct(zt){A(It[zt],"=",w,".",zt,"|0;")}return Ct("size"),Ct("offset"),Ct("stride"),Ct("divisor"),A("}}"),A.exit("if(",It.isStream,"){",Et,".destroyStream(",St,");","}"),It}V[N]=Ei(R,M)}),V}function Vn(b){var y=b.static,x=b.dynamic,C={};return Object.keys(y).forEach(function(V){var N=y[V];C[V]=hr(function(R,M){return typeof N=="number"||typeof N=="boolean"?""+N:R.link(N)})}),Object.keys(x).forEach(function(V){var N=x[V];C[V]=Ei(N,function(R,M){return R.invoke(M,N)})}),C}function pr(b,y,x,C,V){var N=b.static,R=b.dynamic;g.optional(function(){var Ct=[Ro,Kc,Qc,No,Bo,bh,Oo,wh,Xc,Jc].concat(ee);function zt(Gt){Object.keys(Gt).forEach(function(Yt){g.command(Ct.indexOf(Yt)>=0,'unknown parameter "'+Yt+'"',V.commandStr)})}zt(N),zt(R)});var M=pe(b,y),v=Lt(b),A=ie(b,v,V),w=qn(b,V),P=Jn(b,V),G=We(b,V,M);function it(Ct){var zt=A[Ct];zt&&(P[Ct]=zt)}it(wa),it(Vt(vh));var Et=Object.keys(P).length>0,It={framebuffer:v,draw:w,shader:G,state:P,dirty:Et,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(It.profile=Bt(b),It.uniforms=qe(x,V),It.drawVAO=It.scopeVAO=w.vao,!It.drawVAO&&G.program&&!M&&I.angle_instanced_arrays&&w.static.elements){var Ot=!0,St=G.program.attributes.map(function(Ct){var zt=y.static[Ct];return Ot=Ot&&!!zt,zt});if(Ot&&St.length>0){var jt=yt.getVAO(yt.createVAO({attributes:St,elements:w.static.elements}));It.drawVAO=new Sr(null,null,null,function(Ct,zt){return Ct.link(jt)}),It.useVAO=!0}}return M?It.useVAO=!0:It.attributes=vr(y,V),It.context=Vn(C),It}function br(b,y,x){var C=b.shared,V=C.context,N=b.scope();Object.keys(x).forEach(function(R){y.save(V,"."+R);var M=x[R],v=M.append(b,y);Array.isArray(v)?N(V,".",R,"=[",v.join(),"];"):N(V,".",R,"=",v,";")}),y(N)}function wr(b,y,x,C){var V=b.shared,N=V.gl,R=V.framebuffer,M;Mt&&(M=y.def(V.extensions,".webgl_draw_buffers"));var v=b.constants,A=v.drawBuffer,w=v.backBuffer,P;x?P=x.append(b,y):P=y.def(R,".next"),C||y("if(",P,"!==",R,".cur){"),y("if(",P,"){",N,".bindFramebuffer(",EI,",",P,".framebuffer);"),Mt&&y(M,".drawBuffersWEBGL(",A,"[",P,".colorAttachments.length]);"),y("}else{",N,".bindFramebuffer(",EI,",null);"),Mt&&y(M,".drawBuffersWEBGL(",w,");"),y("}",R,".cur=",P,";"),C||y("}")}function Or(b,y,x){var C=b.shared,V=C.gl,N=b.current,R=b.next,M=C.current,v=C.next,A=b.cond(M,".dirty");ee.forEach(function(w){var P=Vt(w);if(!(P in x.state)){var G,it;if(P in R){G=R[P],it=N[P];var Et=Ke(Dt[P].length,function(Ot){return A.def(G,"[",Ot,"]")});A(b.cond(Et.map(function(Ot,St){return Ot+"!=="+it+"["+St+"]"}).join("||")).then(V,".",et[P],"(",Et,");",Et.map(function(Ot,St){return it+"["+St+"]="+Ot}).join(";"),";"))}else{G=A.def(v,".",P);var It=b.cond(G,"!==",M,".",P);A(It),P in rt?It(b.cond(G).then(V,".enable(",rt[P],");").else(V,".disable(",rt[P],");"),M,".",P,"=",G,";"):It(V,".",et[P],"(",G,");",M,".",P,"=",G,";")}}}),Object.keys(x.state).length===0&&A(M,".dirty=false;"),y(A)}function Pr(b,y,x,C){var V=b.shared,N=b.current,R=V.current,M=V.gl;AI(Object.keys(x)).forEach(function(v){var A=x[v];if(!(C&&!C(A))){var w=A.append(b,y);if(rt[v]){var P=rt[v];Ka(A)?w?y(M,".enable(",P,");"):y(M,".disable(",P,");"):y(b.cond(w).then(M,".enable(",P,");").else(M,".disable(",P,");")),y(R,".",v,"=",w,";")}else if(ar(w)){var G=N[v];y(M,".",et[v],"(",w,");",w.map(function(it,Et){return G+"["+Et+"]="+it}).join(";"),";")}else y(M,".",et[v],"(",w,");",R,".",v,"=",w,";")}})}function or(b,y){pt&&(b.instancing=y.def(b.shared.extensions,".angle_instanced_arrays"))}function Le(b,y,x,C,V){var N=b.shared,R=b.stats,M=N.current,v=N.timer,A=x.profile;function w(){return typeof performance>"u"?"Date.now()":"performance.now()"}var P,G;function it(Ct){P=y.def(),Ct(P,"=",w(),";"),typeof V=="string"?Ct(R,".count+=",V,";"):Ct(R,".count++;"),ft&&(C?(G=y.def(),Ct(G,"=",v,".getNumPendingQueries();")):Ct(v,".beginQuery(",R,");"))}function Et(Ct){Ct(R,".cpuTime+=",w(),"-",P,";"),ft&&(C?Ct(v,".pushScopeStats(",G,",",v,".getNumPendingQueries(),",R,");"):Ct(v,".endQuery();"))}function It(Ct){var zt=y.def(M,".profile");y(M,".profile=",Ct,";"),y.exit(M,".profile=",zt,";")}var Ot;if(A){if(Ka(A)){A.enable?(it(y),Et(y.exit),It("true")):It("false");return}Ot=A.append(b,y),It(Ot)}else Ot=y.def(M,".profile");var St=b.block();it(St),y("if(",Ot,"){",St,"}");var jt=b.block();Et(jt),y.exit("if(",Ot,"){",jt,"}")}function $r(b,y,x,C,V){var N=b.shared;function R(v){switch(v){case Sh:case Th:case Rh:return 2;case Eh:case Ah:case Nh:return 3;case Ih:case xh:case Bh:return 4;default:return 1}}function M(v,A,w){var P=N.gl,G=y.def(v,".location"),it=y.def(N.attributes,"[",G,"]"),Et=w.state,It=w.buffer,Ot=[w.x,w.y,w.z,w.w],St=["buffer","normalized","offset","stride"];function jt(){y("if(!",it,".buffer){",P,".enableVertexAttribArray(",G,");}");var zt=w.type,Gt;if(w.size?Gt=y.def(w.size,"||",A):Gt=A,y("if(",it,".type!==",zt,"||",it,".size!==",Gt,"||",St.map(function(se){return it+"."+se+"!=="+w[se]}).join("||"),"){",P,".bindBuffer(",Ul,",",It,".buffer);",P,".vertexAttribPointer(",[G,Gt,zt,w.normalized,w.stride,w.offset],");",it,".type=",zt,";",it,".size=",Gt,";",St.map(function(se){return it+"."+se+"="+w[se]+";"}).join(""),"}"),pt){var Yt=w.divisor;y("if(",it,".divisor!==",Yt,"){",b.instancing,".vertexAttribDivisorANGLE(",[G,Yt],");",it,".divisor=",Yt,";}")}}function Ct(){y("if(",it,".buffer){",P,".disableVertexAttribArray(",G,");",it,".buffer=null;","}if(",Ll.map(function(zt,Gt){return it+"."+zt+"!=="+Ot[Gt]}).join("||"),"){",P,".vertexAttrib4f(",G,",",Ot,");",Ll.map(function(zt,Gt){return it+"."+zt+"="+Ot[Gt]+";"}).join(""),"}")}Et===Ml?jt():Et===Zy?Ct():(y("if(",Et,"===",Ml,"){"),jt(),y("}else{"),Ct(),y("}"))}C.forEach(function(v){var A=v.name,w=x.attributes[A],P;if(w){if(!V(w))return;P=w.append(b,y)}else{if(!V(xI))return;var G=b.scopeAttrib(A);g.optional(function(){b.assert(y,G+".state","missing attribute "+A)}),P={},Object.keys(new k).forEach(function(it){P[it]=y.def(G,".",it)})}M(b.link(v),R(v.info.type),P)})}function ln(b,y,x,C,V,N){for(var R=b.shared,M=R.gl,v,A=0;A<C.length;++A){var w=C[A],P=w.name,G=w.info.type,it=x.uniforms[P],Et=b.link(w),It=Et+".location",Ot;if(it){if(!V(it))continue;if(Ka(it)){var St=it.value;if(g.command(St!==null&&typeof St<"u",'missing uniform "'+P+'"',b.commandStr),G===nu||G===ru){g.command(typeof St=="function"&&(G===nu&&(St._reglType==="texture2d"||St._reglType==="framebuffer")||G===ru&&(St._reglType==="textureCube"||St._reglType==="framebufferCube")),"invalid texture for uniform "+P,b.commandStr);var jt=b.link(St._texture||St.color[0]._texture);y(M,".uniform1i(",It,",",jt+".bind());"),y.exit(jt,".unbind();")}else if(G===Zc||G===tu||G===eu){g.optional(function(){g.command(ar(St),"invalid matrix for uniform "+P,b.commandStr),g.command(G===Zc&&St.length===4||G===tu&&St.length===9||G===eu&&St.length===16,"invalid length for matrix uniform "+P,b.commandStr)});var Ct=b.global.def("new Float32Array(["+Array.prototype.slice.call(St)+"])"),zt=2;G===tu?zt=3:G===eu&&(zt=4),y(M,".uniformMatrix",zt,"fv(",It,",false,",Ct,");")}else{switch(G){case yg:g.commandType(St,"number","uniform "+P,b.commandStr),v="1f";break;case Sh:g.command(ar(St)&&St.length===2,"uniform "+P,b.commandStr),v="2f";break;case Eh:g.command(ar(St)&&St.length===3,"uniform "+P,b.commandStr),v="3f";break;case Ih:g.command(ar(St)&&St.length===4,"uniform "+P,b.commandStr),v="4f";break;case _g:g.commandType(St,"boolean","uniform "+P,b.commandStr),v="1i";break;case gg:g.commandType(St,"number","uniform "+P,b.commandStr),v="1i";break;case Rh:g.command(ar(St)&&St.length===2,"uniform "+P,b.commandStr),v="2i";break;case Th:g.command(ar(St)&&St.length===2,"uniform "+P,b.commandStr),v="2i";break;case Nh:g.command(ar(St)&&St.length===3,"uniform "+P,b.commandStr),v="3i";break;case Ah:g.command(ar(St)&&St.length===3,"uniform "+P,b.commandStr),v="3i";break;case Bh:g.command(ar(St)&&St.length===4,"uniform "+P,b.commandStr),v="4i";break;case xh:g.command(ar(St)&&St.length===4,"uniform "+P,b.commandStr),v="4i";break}y(M,".uniform",v,"(",It,",",ar(St)?Array.prototype.slice.call(St):St,");")}continue}else Ot=it.append(b,y)}else{if(!V(xI))continue;Ot=y.def(R.uniforms,"[",_.id(P),"]")}G===nu?(g(!Array.isArray(Ot),"must specify a scalar prop for textures"),y("if(",Ot,"&&",Ot,'._reglType==="framebuffer"){',Ot,"=",Ot,".color[0];","}")):G===ru&&(g(!Array.isArray(Ot),"must specify a scalar prop for cube maps"),y("if(",Ot,"&&",Ot,'._reglType==="framebufferCube"){',Ot,"=",Ot,".color[0];","}")),g.optional(function(){function Zr(gs,LI){b.assert(y,gs,'bad data or missing for uniform "'+P+'". '+LI)}function Ws(gs){g(!Array.isArray(Ot),"must not specify an array type for uniform"),Zr("typeof "+Ot+'==="'+gs+'"',"invalid type, expected "+gs)}function ts(gs,LI){Array.isArray(Ot)?g(Ot.length===gs,"must have length "+gs):Zr(R.isArrayLike+"("+Ot+")&&"+Ot+".length==="+gs,"invalid vector, should have length "+gs,b.commandStr)}function FI(gs){g(!Array.isArray(Ot),"must not specify a value type"),Zr("typeof "+Ot+'==="function"&&'+Ot+'._reglType==="texture'+(gs===_I?"2d":"Cube")+'"',"invalid texture type",b.commandStr)}switch(G){case gg:Ws("number");break;case Th:ts(2);break;case Ah:ts(3);break;case xh:ts(4);break;case yg:Ws("number");break;case Sh:ts(2);break;case Eh:ts(3);break;case Ih:ts(4);break;case _g:Ws("boolean");break;case Rh:ts(2);break;case Nh:ts(3);break;case Bh:ts(4);break;case Zc:ts(4);break;case tu:ts(9);break;case eu:ts(16);break;case nu:FI(_I);break;case ru:FI(z4);break}});var Gt=1;switch(G){case nu:case ru:var Yt=y.def(Ot,"._texture");y(M,".uniform1i(",It,",",Yt,".bind());"),y.exit(Yt,".unbind();");continue;case gg:case _g:v="1i";break;case Th:case Rh:v="2i",Gt=2;break;case Ah:case Nh:v="3i",Gt=3;break;case xh:case Bh:v="4i",Gt=4;break;case yg:v="1f";break;case Sh:v="2f",Gt=2;break;case Eh:v="3f",Gt=3;break;case Ih:v="4f",Gt=4;break;case Zc:v="Matrix2fv";break;case tu:v="Matrix3fv";break;case eu:v="Matrix4fv";break}if(v.charAt(0)==="M"){y(M,".uniform",v,"(",It,",");var se=Math.pow(G-Zc+2,2),Nn=b.global.def("new Float32Array(",se,")");Array.isArray(Ot)?y("false,(",Ke(se,function(Zr){return Nn+"["+Zr+"]="+Ot[Zr]}),",",Nn,")"):y("false,(Array.isArray(",Ot,")||",Ot," instanceof Float32Array)?",Ot,":(",Ke(se,function(Zr){return Nn+"["+Zr+"]="+Ot+"["+Zr+"]"}),",",Nn,")"),y(");")}else if(Gt>1){for(var Dr=[],Sa=[],Ea=0;Ea<Gt;++Ea)Array.isArray(Ot)?Sa.push(Ot[Ea]):Sa.push(y.def(Ot+"["+Ea+"]")),N&&Dr.push(y.def());N&&y("if(!",b.batchId,"||",Dr.map(function(Zr,Ws){return Zr+"!=="+Sa[Ws]}).join("||"),"){",Dr.map(function(Zr,Ws){return Zr+"="+Sa[Ws]+";"}).join("")),y(M,".uniform",v,"(",It,",",Sa.join(","),");"),N&&y("}")}else{if(g(!Array.isArray(Ot),"uniform value must not be an array"),N){var Ia=y.def();y("if(!",b.batchId,"||",Ia,"!==",Ot,"){",Ia,"=",Ot,";")}y(M,".uniform",v,"(",It,",",Ot,");"),N&&y("}")}}}function re(b,y,x,C){var V=b.shared,N=V.gl,R=V.draw,M=C.draw;function v(){var Gt=M.elements,Yt,se=y;return Gt?((Gt.contextDep&&C.contextDynamic||Gt.propDep)&&(se=x),Yt=Gt.append(b,se),M.elementsActive&&se("if("+Yt+")"+N+".bindBuffer("+mg+","+Yt+".buffer.buffer);")):(Yt=se.def(),se(Yt,"=",R,".",No,";","if(",Yt,"){",N,".bindBuffer(",mg,",",Yt,".buffer.buffer);}","else if(",V.vao,".currentVAO){",Yt,"=",b.shared.elements+".getElements("+V.vao,".currentVAO.elements);",ot?"":"if("+Yt+")"+N+".bindBuffer("+mg+","+Yt+".buffer.buffer);","}")),Yt}function A(){var Gt=M.count,Yt,se=y;return Gt?((Gt.contextDep&&C.contextDynamic||Gt.propDep)&&(se=x),Yt=Gt.append(b,se),g.optional(function(){Gt.MISSING&&b.assert(y,"false","missing vertex count"),Gt.DYNAMIC&&b.assert(se,Yt+">=0","missing vertex count")})):(Yt=se.def(R,".",Oo),g.optional(function(){b.assert(se,Yt+">=0","missing vertex count")})),Yt}var w=v();function P(Gt){var Yt=M[Gt];return Yt?Yt.contextDep&&C.contextDynamic||Yt.propDep?Yt.append(b,x):Yt.append(b,y):y.def(R,".",Gt)}var G=P(Bo),it=P(bh),Et=A();if(typeof Et=="number"){if(Et===0)return}else x("if(",Et,"){"),x.exit("}");var It,Ot;pt&&(It=P(wh),Ot=b.instancing);var St=w+".type",jt=M.elements&&Ka(M.elements)&&!M.vaoActive;function Ct(){function Gt(){x(Ot,".drawElementsInstancedANGLE(",[G,Et,St,it+"<<(("+St+"-"+QE+")>>1)",It],");")}function Yt(){x(Ot,".drawArraysInstancedANGLE(",[G,it,Et,It],");")}w&&w!=="null"?jt?Gt():(x("if(",w,"){"),Gt(),x("}else{"),Yt(),x("}")):Yt()}function zt(){function Gt(){x(N+".drawElements("+[G,Et,St,it+"<<(("+St+"-"+QE+")>>1)"]+");")}function Yt(){x(N+".drawArrays("+[G,it,Et]+");")}w&&w!=="null"?jt?Gt():(x("if(",w,"){"),Gt(),x("}else{"),Yt(),x("}")):Yt()}pt&&(typeof It!="number"||It>=0)?typeof It=="string"?(x("if(",It,">0){"),Ct(),x("}else if(",It,"<0){"),zt(),x("}")):Ct():zt()}function He(b,y,x,C,V){var N=de(),R=N.proc("body",V);return g.optional(function(){N.commandStr=y.commandStr,N.command=N.link(y.commandStr)}),pt&&(N.instancing=R.def(N.shared.extensions,".angle_instanced_arrays")),b(N,R,x,C),N.compile().body}function Ze(b,y,x,C){or(b,y),x.useVAO?x.drawVAO?y(b.shared.vao,".setVAO(",x.drawVAO.append(b,y),");"):y(b.shared.vao,".setVAO(",b.shared.vao,".targetVAO);"):(y(b.shared.vao,".setVAO(null);"),$r(b,y,x,C.attributes,function(){return!0})),ln(b,y,x,C.uniforms,function(){return!0},!1),re(b,y,y,x)}function lr(b,y){var x=b.proc("draw",1);or(b,x),br(b,x,y.context),wr(b,x,y.framebuffer),Or(b,x,y),Pr(b,x,y.state),Le(b,x,y,!1,!0);var C=y.shader.progVar.append(b,x);if(x(b.shared.gl,".useProgram(",C,".program);"),y.shader.program)Ze(b,x,y,y.shader.program);else{x(b.shared.vao,".setVAO(null);");var V=b.global.def("{}"),N=x.def(C,".id"),R=x.def(V,"[",N,"]");x(b.cond(R).then(R,".call(this,a0);").else(R,"=",V,"[",N,"]=",b.link(function(M){return He(Ze,b,y,M,1)}),"(",C,");",R,".call(this,a0);"))}Object.keys(y.state).length>0&&x(b.shared.current,".dirty=true;"),b.shared.vao&&x(b.shared.vao,".setVAO(null);")}function Ys(b,y,x,C){b.batchId="a1",or(b,y);function V(){return!0}$r(b,y,x,C.attributes,V),ln(b,y,x,C.uniforms,V,!1),re(b,y,y,x)}function Fo(b,y,x,C){or(b,y);var V=x.contextDep,N=y.def(),R="a0",M="a1",v=y.def();b.shared.props=v,b.batchId=N;var A=b.scope(),w=b.scope();y(A.entry,"for(",N,"=0;",N,"<",M,";++",N,"){",v,"=",R,"[",N,"];",w,"}",A.exit);function P(St){return St.contextDep&&V||St.propDep}function G(St){return!P(St)}if(x.needsContext&&br(b,w,x.context),x.needsFramebuffer&&wr(b,w,x.framebuffer),Pr(b,w,x.state,P),x.profile&&P(x.profile)&&Le(b,w,x,!1,!0),C)x.useVAO?x.drawVAO?P(x.drawVAO)?w(b.shared.vao,".setVAO(",x.drawVAO.append(b,w),");"):A(b.shared.vao,".setVAO(",x.drawVAO.append(b,A),");"):A(b.shared.vao,".setVAO(",b.shared.vao,".targetVAO);"):(A(b.shared.vao,".setVAO(null);"),$r(b,A,x,C.attributes,G),$r(b,w,x,C.attributes,P)),ln(b,A,x,C.uniforms,G,!1),ln(b,w,x,C.uniforms,P,!0),re(b,A,w,x);else{var it=b.global.def("{}"),Et=x.shader.progVar.append(b,w),It=w.def(Et,".id"),Ot=w.def(it,"[",It,"]");w(b.shared.gl,".useProgram(",Et,".program);","if(!",Ot,"){",Ot,"=",it,"[",It,"]=",b.link(function(St){return He(Ys,b,x,St,2)}),"(",Et,");}",Ot,".call(this,a0[",N,"],",N,");")}}function S(b,y){var x=b.proc("batch",2);b.batchId="0",or(b,x);var C=!1,V=!0;Object.keys(y.context).forEach(function(it){C=C||y.context[it].propDep}),C||(br(b,x,y.context),V=!1);var N=y.framebuffer,R=!1;N?(N.propDep?C=R=!0:N.contextDep&&C&&(R=!0),R||wr(b,x,N)):wr(b,x,null),y.state.viewport&&y.state.viewport.propDep&&(C=!0);function M(it){return it.contextDep&&C||it.propDep}Or(b,x,y),Pr(b,x,y.state,function(it){return!M(it)}),(!y.profile||!M(y.profile))&&Le(b,x,y,!1,"a1"),y.contextDep=C,y.needsContext=V,y.needsFramebuffer=R;var v=y.shader.progVar;if(v.contextDep&&C||v.propDep)Fo(b,x,y,null);else{var A=v.append(b,x);if(x(b.shared.gl,".useProgram(",A,".program);"),y.shader.program)Fo(b,x,y,y.shader.program);else{x(b.shared.vao,".setVAO(null);");var w=b.global.def("{}"),P=x.def(A,".id"),G=x.def(w,"[",P,"]");x(b.cond(G).then(G,".call(this,a0,a1);").else(G,"=",w,"[",P,"]=",b.link(function(it){return He(Fo,b,y,it,2)}),"(",A,");",G,".call(this,a0,a1);"))}}Object.keys(y.state).length>0&&x(b.shared.current,".dirty=true;"),b.shared.vao&&x(b.shared.vao,".setVAO(null);")}function q(b,y){var x=b.proc("scope",3);b.batchId="a2";var C=b.shared,V=C.current;br(b,x,y.context),y.framebuffer&&y.framebuffer.append(b,x),AI(Object.keys(y.state)).forEach(function(R){var M=y.state[R],v=M.append(b,x);ar(v)?v.forEach(function(A,w){x.set(b.next[R],"["+w+"]",A)}):x.set(C.next,"."+R,v)}),Le(b,x,y,!0,!0),[No,bh,Oo,wh,Bo].forEach(function(R){var M=y.draw[R];M&&x.set(C.draw,"."+R,""+M.append(b,x))}),Object.keys(y.uniforms).forEach(function(R){var M=y.uniforms[R].append(b,x);Array.isArray(M)&&(M="["+M.join()+"]"),x.set(C.uniforms,"["+_.id(R)+"]",M)}),Object.keys(y.attributes).forEach(function(R){var M=y.attributes[R].append(b,x),v=b.scopeAttrib(R);Object.keys(new k).forEach(function(A){x.set(v,"."+A,M[A])})}),y.scopeVAO&&x.set(C.vao,".targetVAO",y.scopeVAO.append(b,x));function N(R){var M=y.shader[R];M&&x.set(C.shader,"."+R,M.append(b,x))}N(Kc),N(Qc),Object.keys(y.state).length>0&&(x(V,".dirty=true;"),x.exit(V,".dirty=true;")),x("a1(",b.shared.context,",a0,",b.batchId,");")}function j(b){if(!(typeof b!="object"||ar(b))){for(var y=Object.keys(b),x=0;x<y.length;++x)if(Ft.isDynamic(b[y[x]]))return!0;return!1}}function Pt(b,y,x){var C=y.static[x];if(!C||!j(C))return;var V=b.global,N=Object.keys(C),R=!1,M=!1,v=!1,A=b.global.def("{}");N.forEach(function(P){var G=C[P];if(Ft.isDynamic(G)){typeof G=="function"&&(G=C[P]=Ft.unbox(G));var it=Ei(G,null);R=R||it.thisDep,v=v||it.propDep,M=M||it.contextDep}else{switch(V(A,".",P,"="),typeof G){case"number":V(G);break;case"string":V('"',G,'"');break;case"object":Array.isArray(G)&&V("[",G.join(),"]");break;default:V(b.link(G));break}V(";")}});function w(P,G){N.forEach(function(it){var Et=C[it];if(Ft.isDynamic(Et)){var It=P.invoke(G,Et);G(A,".",it,"=",It,";")}})}y.dynamic[x]=new Ft.DynamicVariable(_h,{thisDep:R,contextDep:M,propDep:v,ref:A,append:w}),delete y.static[x]}function je(b,y,x,C,V){var N=de();N.stats=N.link(V),Object.keys(y.static).forEach(function(M){Pt(N,y,M)}),P4.forEach(function(M){Pt(N,b,M)});var R=pr(b,y,x,C,N);return lr(N,R),q(N,R),S(N,R),r(N.compile(),{destroy:function(){R.shader.program.destroy()}})}return{next:Nt,current:Dt,procs:(function(){var b=de(),y=b.proc("poll"),x=b.proc("refresh"),C=b.block();y(C),x(C);var V=b.shared,N=V.gl,R=V.next,M=V.current;C(M,".dirty=false;"),wr(b,y),wr(b,x,null,!0);var v;pt&&(v=b.link(pt)),I.oes_vertex_array_object&&x(b.link(I.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var A=0;A<W.maxAttributes;++A){var w=x.def(V.attributes,"[",A,"]"),P=b.cond(w,".buffer");P.then(N,".enableVertexAttribArray(",A,");",N,".bindBuffer(",Ul,",",w,".buffer.buffer);",N,".vertexAttribPointer(",A,",",w,".size,",w,".type,",w,".normalized,",w,".stride,",w,".offset);").else(N,".disableVertexAttribArray(",A,");",N,".vertexAttrib4f(",A,",",w,".x,",w,".y,",w,".z,",w,".w);",w,".buffer=null;"),x(P),pt&&x(v,".vertexAttribDivisorANGLE(",A,",",w,".divisor);")}return x(b.shared.vao,".currentVAO=null;",b.shared.vao,".setVAO(",b.shared.vao,".targetVAO);"),Object.keys(rt).forEach(function(G){var it=rt[G],Et=C.def(R,".",G),It=b.block();It("if(",Et,"){",N,".enable(",it,")}else{",N,".disable(",it,")}",M,".",G,"=",Et,";"),x(It),y("if(",Et,"!==",M,".",G,"){",It,"}")}),Object.keys(et).forEach(function(G){var it=et[G],Et=Dt[G],It,Ot,St=b.block();if(St(N,".",it,"("),ar(Et)){var jt=Et.length;It=b.global.def(R,".",G),Ot=b.global.def(M,".",G),St(Ke(jt,function(Ct){return It+"["+Ct+"]"}),");",Ke(jt,function(Ct){return Ot+"["+Ct+"]="+It+"["+Ct+"];"}).join("")),y("if(",Ke(jt,function(Ct){return It+"["+Ct+"]!=="+Ot+"["+Ct+"]"}).join("||"),"){",St,"}")}else It=C.def(R,".",G),Ot=C.def(M,".",G),St(It,");",M,".",G,"=",It,";"),y("if(",It,"!==",Ot,"){",St,"}");x(St)}),b.compile()})(),compile:je}}function i6(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var s6=34918,a6=34919,RI=35007,o6=function(d,_){if(!_.ext_disjoint_timer_query)return null;var I=[];function W(){return I.pop()||_.ext_disjoint_timer_query.createQueryEXT()}function nt(pt){I.push(pt)}var Y=[];function Q(pt){var Mt=W();_.ext_disjoint_timer_query.beginQueryEXT(RI,Mt),Y.push(Mt),ft(Y.length-1,Y.length,pt)}function dt(){_.ext_disjoint_timer_query.endQueryEXT(RI)}function ut(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var yt=[];function vt(){return yt.pop()||new ut}function gt(pt){yt.push(pt)}var Tt=[];function ft(pt,Mt,ot){var Dt=vt();Dt.startQueryIndex=pt,Dt.endQueryIndex=Mt,Dt.sum=0,Dt.stats=ot,Tt.push(Dt)}var mt=[],k=[];function K(){var pt,Mt,ot=Y.length;if(ot!==0){k.length=Math.max(k.length,ot+1),mt.length=Math.max(mt.length,ot+1),mt[0]=0,k[0]=0;var Dt=0;for(pt=0,Mt=0;Mt<Y.length;++Mt){var Nt=Y[Mt];_.ext_disjoint_timer_query.getQueryObjectEXT(Nt,a6)?(Dt+=_.ext_disjoint_timer_query.getQueryObjectEXT(Nt,s6),nt(Nt)):Y[pt++]=Nt,mt[Mt+1]=Dt,k[Mt+1]=pt}for(Y.length=pt,pt=0,Mt=0;Mt<Tt.length;++Mt){var ee=Tt[Mt],rt=ee.startQueryIndex,et=ee.endQueryIndex;ee.sum+=mt[et]-mt[rt];var Vt=k[rt],At=k[et];At===Vt?(ee.stats.gpuTime+=ee.sum/1e6,gt(ee)):(ee.startQueryIndex=Vt,ee.endQueryIndex=At,Tt[pt++]=ee)}Tt.length=pt}}return{beginQuery:Q,endQuery:dt,pushScopeStats:ft,update:K,getNumPendingQueries:function(){return Y.length},clear:function(){I.push.apply(I,Y);for(var pt=0;pt<I.length;pt++)_.ext_disjoint_timer_query.deleteQueryEXT(I[pt]);Y.length=0,I.length=0},restore:function(){Y.length=0,I.length=0}}},l6=16384,c6=256,u6=1024,d6=34962,NI="webglcontextlost",BI="webglcontextrestored",OI=1,f6=2,h6=3;function DI(d,_){for(var I=0;I<d.length;++I)if(d[I]===_)return I;return-1}function p6(d){var _=ur(d);if(!_)return null;var I=_.gl,W=I.getContextAttributes(),nt=I.isContextLost(),Y=ci(I,_);if(!Y)return null;var Q=De(),dt=i6(),ut=Y.extensions,yt=o6(I,ut),vt=fe(),gt=I.drawingBufferWidth,Tt=I.drawingBufferHeight,ft={tick:0,time:0,viewportWidth:gt,viewportHeight:Tt,framebufferWidth:gt,framebufferHeight:Tt,drawingBufferWidth:gt,drawingBufferHeight:Tt,pixelRatio:_.pixelRatio},mt={},k={elements:null,primitive:4,count:-1,offset:0,instances:-1},K=t8(I,ut),pt=y8(I,dt,_,Dt),Mt=R8(I,ut,pt,dt),ot=R4(I,ut,K,dt,pt,Mt,k);function Dt(re){return ot.destroyBuffer(re)}var Nt=D4(I,Q,dt,_),ee=s4(I,ut,K,function(){Vt.procs.poll()},ft,dt,_),rt=a4(I,ut,K,dt,_),et=A4(I,ut,K,ee,rt,dt),Vt=r6(I,Q,ut,K,pt,Mt,ee,et,mt,ot,Nt,k,ft,yt,_),At=M4(I,et,Vt.procs.poll,ft,W,ut,K),ht=Vt.next,xt=I.canvas,Rt=[],me=[],de=[],Bt=[_.onDestroy],Lt=null;function ie(){if(Rt.length===0){yt&&yt.update(),Lt=null;return}Lt=Ut.next(ie),Pr();for(var re=Rt.length-1;re>=0;--re){var He=Rt[re];He&&He(ft,null,0)}I.flush(),yt&&yt.update()}function pe(){!Lt&&Rt.length>0&&(Lt=Ut.next(ie))}function We(){Lt&&(Ut.cancel(ie),Lt=null)}function qn(re){re.preventDefault(),nt=!0,We(),me.forEach(function(He){He()})}function Jn(re){I.getError(),nt=!1,Y.restore(),Nt.restore(),pt.restore(),ee.restore(),rt.restore(),et.restore(),ot.restore(),yt&&yt.restore(),Vt.procs.refresh(),pe(),de.forEach(function(He){He()})}xt&&(xt.addEventListener(NI,qn,!1),xt.addEventListener(BI,Jn,!1));function qe(){Rt.length=0,We(),xt&&(xt.removeEventListener(NI,qn),xt.removeEventListener(BI,Jn)),Nt.clear(),et.clear(),rt.clear(),ot.clear(),ee.clear(),Mt.clear(),pt.clear(),yt&&yt.clear(),Bt.forEach(function(re){re()})}function vr(re){g(!!re,"invalid args to regl({...})"),g.type(re,"object","invalid args to regl({...})");function He(V){var N=r({},V);delete N.uniforms,delete N.attributes,delete N.context,delete N.vao,"stencil"in N&&N.stencil.op&&(N.stencil.opBack=N.stencil.opFront=N.stencil.op,delete N.stencil.op);function R(M){if(M in N){var v=N[M];delete N[M],Object.keys(v).forEach(function(A){N[M+"."+A]=v[A]})}}return R("blend"),R("depth"),R("cull"),R("stencil"),R("polygonOffset"),R("scissor"),R("sample"),"vao"in V&&(N.vao=V.vao),N}function Ze(V,N){var R={},M={};return Object.keys(V).forEach(function(v){var A=V[v];if(Ft.isDynamic(A)){M[v]=Ft.unbox(A,v);return}else if(N&&Array.isArray(A)){for(var w=0;w<A.length;++w)if(Ft.isDynamic(A[w])){M[v]=Ft.unbox(A,v);return}}R[v]=A}),{dynamic:M,static:R}}var lr=Ze(re.context||{},!0),Ys=Ze(re.uniforms||{},!0),Fo=Ze(re.attributes||{},!1),S=Ze(He(re),!1),q={gpuTime:0,cpuTime:0,count:0},j=Vt.compile(S,Fo,Ys,lr,q),Pt=j.draw,je=j.batch,b=j.scope,y=[];function x(V){for(;y.length<V;)y.push(null);return y}function C(V,N){var R;if(nt&&g.raise("context lost"),typeof V=="function")return b.call(this,null,V,0);if(typeof N=="function")if(typeof V=="number")for(R=0;R<V;++R)b.call(this,null,N,R);else if(Array.isArray(V))for(R=0;R<V.length;++R)b.call(this,V[R],N,R);else return b.call(this,V,N,0);else if(typeof V=="number"){if(V>0)return je.call(this,x(V|0),V|0)}else if(Array.isArray(V)){if(V.length)return je.call(this,V,V.length)}else return Pt.call(this,V)}return r(C,{stats:q,destroy:function(){j.destroy()}})}var Vn=et.setFBO=vr({framebuffer:Ft.define.call(null,OI,"framebuffer")});function pr(re,He){var Ze=0;Vt.procs.poll();var lr=He.color;lr&&(I.clearColor(+lr[0]||0,+lr[1]||0,+lr[2]||0,+lr[3]||0),Ze|=l6),"depth"in He&&(I.clearDepth(+He.depth),Ze|=c6),"stencil"in He&&(I.clearStencil(He.stencil|0),Ze|=u6),g(!!Ze,"called regl.clear with no buffer specified"),I.clear(Ze)}function br(re){if(g(typeof re=="object"&&re,"regl.clear() takes an object as input"),"framebuffer"in re)if(re.framebuffer&&re.framebuffer_reglType==="framebufferCube")for(var He=0;He<6;++He)Vn(r({framebuffer:re.framebuffer.faces[He]},re),pr);else Vn(re,pr);else pr(null,re)}function wr(re){g.type(re,"function","regl.frame() callback must be a function"),Rt.push(re);function He(){var Ze=DI(Rt,re);g(Ze>=0,"cannot cancel a frame twice");function lr(){var Ys=DI(Rt,lr);Rt[Ys]=Rt[Rt.length-1],Rt.length-=1,Rt.length<=0&&We()}Rt[Ze]=lr}return pe(),{cancel:He}}function Or(){var re=ht.viewport,He=ht.scissor_box;re[0]=re[1]=He[0]=He[1]=0,ft.viewportWidth=ft.framebufferWidth=ft.drawingBufferWidth=re[2]=He[2]=I.drawingBufferWidth,ft.viewportHeight=ft.framebufferHeight=ft.drawingBufferHeight=re[3]=He[3]=I.drawingBufferHeight}function Pr(){ft.tick+=1,ft.time=Le(),Or(),Vt.procs.poll()}function or(){ee.refresh(),Or(),Vt.procs.refresh(),yt&&yt.update()}function Le(){return(fe()-vt)/1e3}or();function $r(re,He){g.type(He,"function","listener callback must be a function");var Ze;switch(re){case"frame":return wr(He);case"lost":Ze=me;break;case"restore":Ze=de;break;case"destroy":Ze=Bt;break;default:g.raise("invalid event, must be one of frame,lost,restore,destroy")}return Ze.push(He),{cancel:function(){for(var lr=0;lr<Ze.length;++lr)if(Ze[lr]===He){Ze[lr]=Ze[Ze.length-1],Ze.pop();return}}}}var ln=r(vr,{clear:br,prop:Ft.define.bind(null,OI),context:Ft.define.bind(null,f6),this:Ft.define.bind(null,h6),draw:vr({}),buffer:function(re){return pt.create(re,d6,!1,!1)},elements:function(re){return Mt.create(re,!1)},texture:ee.create2D,cube:ee.createCube,renderbuffer:rt.create,framebuffer:et.create,framebufferCube:et.createCube,vao:ot.createVAO,attributes:W,frame:wr,on:$r,limits:K,hasExtension:function(re){return K.extensions.indexOf(re.toLowerCase())>=0},read:At,destroy:qe,_gl:I,_refresh:or,poll:function(){Pr(),yt&&yt.update()},now:Le,stats:dt});return _.onDone(null,ln),ln}return p6}))})(ld)),ld.exports}var zD=VD();const Np=PD(zD);function Ve(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(f){try{u(r.next(f))}catch(p){a(p)}}function l(f){try{u(r.throw(f))}catch(p){a(p)}}function u(f){f.done?s(f.value):i(f.value).then(o,l)}u((r=r.apply(e,t||[])).next())})}function Sv(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Qe(e){return this instanceof Qe?(this.v=e,this):new Qe(e)}function Ss(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(T){return function(U){return Promise.resolve(U).then(T,p)}}function o(T,U){r[T]&&(i[T]=function(J){return new Promise(function(lt,X){s.push([T,J,lt,X])>1||l(T,J)})},U&&(i[T]=U(i[T])))}function l(T,U){try{u(r[T](U))}catch(J){E(s[0][3],J)}}function u(T){T.value instanceof Qe?Promise.resolve(T.value.v).then(f,p):E(s[0][2],T)}function f(T){l("next",T)}function p(T){l("throw",T)}function E(T,U){T(U),s.shift(),s.length&&l(s[0][0],s[0][1])}}function cd(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:Qe(e[i](a)),done:!1}:s?s(a):a}:s}}function uo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Sv=="function"?Sv(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(u){s({value:u,done:o})},a)}}typeof SuppressedError=="function"&&SuppressedError;const GD=new TextDecoder("utf-8"),Bp=e=>GD.decode(e),jD=new TextEncoder,Op=e=>jD.encode(e),YD=e=>typeof e=="number",Ev=e=>typeof e=="boolean",Er=e=>typeof e=="function",hi=e=>e!=null&&Object(e)===e,fo=e=>hi(e)&&Er(e.then),yc=e=>hi(e)&&Er(e[Symbol.iterator]),Go=e=>hi(e)&&Er(e[Symbol.asyncIterator]),Dp=e=>hi(e)&&hi(e.schema),Iv=e=>hi(e)&&"done"in e&&"value"in e,Tv=e=>hi(e)&&Er(e.stat)&&YD(e.fd),Av=e=>hi(e)&&Fp(e.body),ud=e=>"_getDOMStream"in e&&"_getNodeStream"in e,WD=e=>hi(e)&&Er(e.abort)&&Er(e.getWriter)&&!ud(e),Fp=e=>hi(e)&&Er(e.cancel)&&Er(e.getReader)&&!ud(e),HD=e=>hi(e)&&Er(e.end)&&Er(e.write)&&Ev(e.writable)&&!ud(e),xv=e=>hi(e)&&Er(e.read)&&Er(e.pipe)&&Ev(e.readable)&&!ud(e),qD=e=>hi(e)&&Er(e.clear)&&Er(e.bytes)&&Er(e.position)&&Er(e.setPosition)&&Er(e.capacity)&&Er(e.getBufferIdentifier)&&Er(e.createLong),Lp=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function XD(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,u=0,f=e.length;++l<f;){if(a=t[u],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++u]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++u]=o);continue}t[u]=new Uint8Array(a.buffer,n,r-n+s)}return t}function Rv(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function Es(e,t){const n=XD(e),r=n.reduce((f,p)=>f+p.byteLength,0);let i,s,a,o=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,r);for(const f=n.length;++l<f;){if(i=n[l],s=i.subarray(0,Math.min(i.length,u-o)),u<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?Rv(a,s,o):a=s;break}Rv(a||(a=new Uint8Array(u)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function Bn(e,t){let n=Iv(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Op(n)),n instanceof ArrayBuffer?new e(n):n instanceof Lp?new e(n):qD(n)?Bn(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const gc=e=>Bn(Int32Array,e),Nv=e=>Bn(BigInt64Array,e),cn=e=>Bn(Uint8Array,e),Mp=e=>(e.next(),e);function*KD(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Lp?n(t):yc(t)?t:n(t);return yield*Mp((function*(i){let s=null;do s=i.next(yield Bn(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const QD=e=>KD(Uint8Array,e);function Bv(e,t){return Ss(this,arguments,function*(){if(fo(t))return yield Qe(yield Qe(yield*cd(uo(Bv(e,yield Qe(t))))));const r=function(a){return Ss(this,arguments,function*(){yield yield Qe(yield Qe(a))})},i=function(a){return Ss(this,arguments,function*(){yield Qe(yield*cd(uo(Mp((function*(o){let l=null;do l=o.next(yield l==null?void 0:l.value);while(!l.done)})(a[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Lp?r(t):yc(t)?i(t):Go(t)?t:r(t);return yield Qe(yield*cd(uo(Mp((function(a){return Ss(this,arguments,function*(){let o=null;do o=yield Qe(a.next(yield yield Qe(Bn(e,o))));while(!o.done)})})(s[Symbol.asyncIterator]()))))),yield Qe(new e)})}const JD=e=>Bv(Uint8Array,e);function Ov(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function ZD(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const ki={fromIterable(e){return dd(tF(e))},fromAsyncIterable(e){return dd(eF(e))},fromDOMStream(e){return dd(nF(e))},fromNodeStream(e){return dd(iF(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},dd=e=>(e.next(),e);function*tF(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Es(r,a)[0]:([i,r,o]=Es(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const u=QD(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?u.next():u.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(f){(n=!0)&&typeof u.throw=="function"&&u.throw(f)}finally{n===!1&&typeof u.return=="function"&&u.return(null)}return null}function eF(e){return Ss(this,arguments,function*(){let n,r=!1,i=[],s,a,o,l=0;function u(){return a==="peek"?Es(i,o)[0]:([s,i,l]=Es(i,o),s)}({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0});const f=JD(e)[Symbol.asyncIterator]();try{do if({done:n,value:s}=Number.isNaN(o-l)?yield Qe(f.next()):yield Qe(f.next(o-l)),!n&&s.byteLength>0&&(i.push(s),l+=s.byteLength),n||o<=l)do({cmd:a,size:o}=yield yield Qe(u()));while(o<l);while(!n)}catch(p){(r=!0)&&typeof f.throw=="function"&&(yield Qe(f.throw(p)))}finally{r===!1&&typeof f.return=="function"&&(yield Qe(f.return(new Uint8Array(0))))}return yield Qe(null)})}function nF(e){return Ss(this,arguments,function*(){let n=!1,r=!1,i=[],s,a,o,l=0;function u(){return a==="peek"?Es(i,o)[0]:([s,i,l]=Es(i,o),s)}({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0});const f=new rF(e);try{do if({done:n,value:s}=Number.isNaN(o-l)?yield Qe(f.read()):yield Qe(f.read(o-l)),!n&&s.byteLength>0&&(i.push(cn(s)),l+=s.byteLength),n||o<=l)do({cmd:a,size:o}=yield yield Qe(u()));while(o<l);while(!n)}catch(p){(r=!0)&&(yield Qe(f.cancel(p)))}finally{r===!1?yield Qe(f.cancel()):e.locked&&f.releaseLock()}return yield Qe(null)})}class rF{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Ve(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Ve(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=cn(n)),n})}}const Cp=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function iF(e){return Ss(this,arguments,function*(){const n=[];let r="error",i=!1,s=null,a,o,l=0,u=[],f;function p(){return a==="peek"?Es(u,o)[0]:([f,u,l]=Es(u,o),f)}if({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0},e.isTTY)return yield yield Qe(new Uint8Array(0)),yield Qe(null);try{n[0]=Cp(e,"end"),n[1]=Cp(e,"error");do{if(n[2]=Cp(e,"readable"),[r,s]=yield Qe(Promise.race(n.map(T=>T[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(o-l)?(f=cn(e.read(o-l)),f.byteLength<o-l&&(f=cn(e.read()))):f=cn(e.read()),f.byteLength>0&&(u.push(f),l+=f.byteLength)),i||o<=l)do({cmd:a,size:o}=yield yield Qe(p()));while(o<l)}while(!i)}finally{yield Qe(E(n,r==="error"?s:null))}return yield Qe(null);function E(T,U){return f=u=null,new Promise((J,lt)=>{for(const[X,Kt]of T)e.off(X,Kt);try{const X=e.destroy;X&&X.call(e,U),U=void 0}catch(X){U=X||U}finally{U!=null?lt(U):J()}})}})}var mr;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(mr||(mr={}));var jr;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(jr||(jr={}));var Yr;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Yr||(Yr={}));var Ui;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Ui||(Ui={}));var Ie;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(Ie||(Ie={}));var Is;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Is||(Is={}));const kp=2,Ts=4,ra=4,Sn=4,Na=new Int32Array(2),Dv=new Float32Array(Na.buffer),Fv=new Float64Array(Na.buffer),fd=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Up;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Up||(Up={}));let jo=class MI{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new MI(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Na[0]=this.readInt32(t),Dv[0]}readFloat64(t){return Na[fd?0:1]=this.readInt32(t),Na[fd?1:0]=this.readInt32(t+4),Fv[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){Dv[0]=n,this.writeInt32(t,Na[0])}writeFloat64(t,n){Fv[0]=n,this.writeInt32(t,Na[fd?0:1]),this.writeInt32(t+4,Na[fd?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ts+ra)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<ra;n++)t+=String.fromCharCode(this.readInt8(this.position_+Ts+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=Ts;const i=this.bytes_.subarray(t,t+r);return n===Up.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+Ts}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ra)throw new Error("FlatBuffers: file identifier must be length "+ra);for(let n=0;n<ra;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Ts+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},Lv=class CI{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=jo.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=CI.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=jo.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(Ts,0),this.writeInt32(this.offset()-t+Ts)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*kp;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let u=kp;u<s;u+=kp)if(this.bb.readInt16(o+u)!=this.bb.readInt16(l+u))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?Sn:0;if(n){const s=n;if(this.prep(this.minalign,Ts+ra+i),s.length!=ra)throw new TypeError("FlatBuffers: file identifier must be length "+ra);for(let a=ra-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Ts+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(Ts,t*n),this.prep(r,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var hd;(function(e){e[e.BUFFER=0]="BUFFER"})(hd||(hd={}));var pd;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(pd||(pd={}));class Ba{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Ba).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Sn),(n||new Ba).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):pd.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):hd.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,pd.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,hd.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Ba.startBodyCompression(t),Ba.addCodec(t,n),Ba.addMethod(t,r),Ba.endBodyCompression(t)}}class Mv{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Cv=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}},ia=class Sg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new Sg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Sn),(n||new Sg).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Cv).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Mv).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Ba).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},Yo=class Eg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new Eg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Sn),(n||new Eg).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new ia).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var Wo;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(Wo||(Wo={}));var md;(function(e){e[e.DenseArray=0]="DenseArray"})(md||(md={}));class Ri{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Ri).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Sn),(n||new Ri).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Ri.startInt(t),Ri.addBitWidth(t,n),Ri.addIsSigned(t,r),Ri.endInt(t)}}class sa{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new sa).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Sn),(n||new sa).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ri).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):md.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,md.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Ir{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new Ir).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Sn),(n||new Ir).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return Ir.startKeyValue(t),Ir.addKey(t,n),Ir.addValue(t,r),Ir.endKeyValue(t)}}let kv=class su{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new su).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Sn),(n||new su).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return su.startBinary(t),su.endBinary(t)}},Uv=class au{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new au).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Sn),(n||new au).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return au.startBool(t),au.endBool(t)}},yd=class $l{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new $l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Sn),(n||new $l).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ui.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Ui.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return $l.startDate(t),$l.addUnit(t,n),$l.endDate(t)}},Ho=class Qa{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new Qa).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Sn),(n||new Qa).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return Qa.startDecimal(t),Qa.addPrecision(t,n),Qa.addScale(t,r),Qa.addBitWidth(t,i),Qa.endDecimal(t)}},gd=class Vl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new Vl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Sn),(n||new Vl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ie.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Ie.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Vl.startDuration(t),Vl.addUnit(t,n),Vl.endDuration(t)}},_d=class zl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new zl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Sn),(n||new zl).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return zl.startFixedSizeBinary(t),zl.addByteWidth(t,n),zl.endFixedSizeBinary(t)}},vd=class Gl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new Gl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Sn),(n||new Gl).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return Gl.startFixedSizeList(t),Gl.addListSize(t,n),Gl.endFixedSizeList(t)}};class As{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new As).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Sn),(n||new As).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Yr.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Yr.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return As.startFloatingPoint(t),As.addPrecision(t,n),As.endFloatingPoint(t)}}class xs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new xs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Sn),(n||new xs).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Is.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Is.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return xs.startInterval(t),xs.addUnit(t,n),xs.endInterval(t)}}let Pv=class ou{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new ou).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Sn),(n||new ou).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return ou.startLargeBinary(t),ou.endLargeBinary(t)}},$v=class lu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new lu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Sn),(n||new lu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return lu.startLargeUtf8(t),lu.endLargeUtf8(t)}},Vv=class cu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new cu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Sn),(n||new cu).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return cu.startList(t),cu.endList(t)}},bd=class jl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new jl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Sn),(n||new jl).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return jl.startMap(t),jl.addKeysSorted(t,n),jl.endMap(t)}},zv=class uu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new uu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Sn),(n||new uu).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return uu.startNull(t),uu.endNull(t)}};class ho{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new ho).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Sn),(n||new ho).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return ho.startStruct_(t),ho.endStruct_(t)}}class Pi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new Pi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Sn),(n||new Pi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ie.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Ie.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return Pi.startTime(t),Pi.addUnit(t,n),Pi.addBitWidth(t,r),Pi.endTime(t)}}class $i{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new $i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Sn),(n||new $i).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ie.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Ie.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return $i.startTimestamp(t),$i.addUnit(t,n),$i.addTimezone(t,r),$i.endTimestamp(t)}}class pi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new pi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Sn),(n||new pi).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):jr.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,jr.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return pi.startUnion(t),pi.addMode(t,n),pi.addTypeIds(t,r),pi.endUnion(t)}}let Gv=class du{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new du).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Sn),(n||new du).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return du.startUtf8(t),du.endUtf8(t)}};var Wn;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(Wn||(Wn={}));let Vi=class Dh{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new Dh).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Sn),(n||new Dh).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Wn.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new sa).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Dh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new Ir).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,Wn.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},Rs=class Ta{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Ta).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Sn),(n||new Ta).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Wo.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Vi).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ir).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,Wo.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Ta.startSchema(t),Ta.addEndianness(t,n),Ta.addFields(t,r),Ta.addCustomMetadata(t,i),Ta.addFeatures(t,s),Ta.endSchema(t)}};var pn;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(pn||(pn={}));var B;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(B||(B={}));var aa;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(aa||(aa={}));const sF=void 0;function _c(e){if(e===null)return"null";if(e===sF)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>_c(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function zn(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function jv(e,t){return zn(e/t)+zn(e%t)/zn(t)}const aF=Symbol.for("isArrowBigNum");function os(e,...t){return t.length===0?Object.setPrototypeOf(Bn(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}os.prototype[aF]=!0,os.prototype.toJSON=function(){return`"${bc(this)}"`},os.prototype.valueOf=function(e){return Yv(this,e)},os.prototype.toString=function(){return bc(this)},os.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Yv(this);case"string":return bc(this);case"default":return lF(this)}return bc(this)};function qo(...e){return os.apply(this,e)}function Xo(...e){return os.apply(this,e)}function vc(...e){return os.apply(this,e)}Object.setPrototypeOf(qo.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Xo.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(vc.prototype,Object.create(Uint32Array.prototype)),Object.assign(qo.prototype,os.prototype,{constructor:qo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Xo.prototype,os.prototype,{constructor:Xo,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(vc.prototype,os.prototype,{constructor:vc,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const oF=BigInt(4294967296)*BigInt(4294967296)-BigInt(1);function Yv(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),u=0;if(o){for(const f of a)l|=(f^oF)*(BigInt(1)<<BigInt(64*u++));l*=BigInt(-1),l-=BigInt(1)}else for(const f of a)l|=f*(BigInt(1)<<BigInt(64*u++));if(typeof t=="number"){const f=BigInt(Math.pow(10,t)),p=l/f,E=l%f;return zn(p)+zn(E)/zn(f)}return zn(l)}function bc(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Pp(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Pp(e);t=t.slice();let r=1;for(let s=0;s<t.length;s++){const a=t[s],o=~a+r;t[s]=o,r&=a===0?1:0}return`-${Pp(t)}`}function lF(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:bc(e)}function Pp(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class $p{static new(t,n){switch(n){case!0:return new qo(t);case!1:return new Xo(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new qo(t)}return t.byteLength===16?new vc(t):new Xo(t)}static signed(t){return new qo(t)}static unsigned(t){return new Xo(t)}static decimal(t){return new vc(t)}constructor(t,n){return $p.new(t,n)}}var Wv,Hv,qv,Xv,Kv,Qv,Jv,Zv,tb,eb,nb,rb,ib,sb,ab,ob,lb,cb,ub,db,fb,hb;class ae{static isNull(t){return(t==null?void 0:t.typeId)===B.Null}static isInt(t){return(t==null?void 0:t.typeId)===B.Int}static isFloat(t){return(t==null?void 0:t.typeId)===B.Float}static isBinary(t){return(t==null?void 0:t.typeId)===B.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===B.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===B.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===B.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===B.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===B.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===B.Date}static isTime(t){return(t==null?void 0:t.typeId)===B.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===B.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===B.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===B.Duration}static isList(t){return(t==null?void 0:t.typeId)===B.List}static isStruct(t){return(t==null?void 0:t.typeId)===B.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===B.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===B.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===B.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===B.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===B.Dictionary}static isDenseUnion(t){return ae.isUnion(t)&&t.mode===jr.Dense}static isSparseUnion(t){return ae.isUnion(t)&&t.mode===jr.Sparse}constructor(t){this.typeId=t}}Wv=Symbol.toStringTag,ae[Wv]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(ae.prototype);class Oa extends ae{constructor(){super(B.Null)}toString(){return"Null"}}Hv=Symbol.toStringTag,Oa[Hv]=(e=>e[Symbol.toStringTag]="Null")(Oa.prototype);class po extends ae{constructor(t,n){super(B.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}qv=Symbol.toStringTag,po[qv]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(po.prototype);class wc extends po{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(wc.prototype,"ArrayType",{value:Int32Array});class wd extends ae{constructor(t){super(B.Float),this.precision=t}get ArrayType(){switch(this.precision){case Yr.HALF:return Uint16Array;case Yr.SINGLE:return Float32Array;case Yr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Xv=Symbol.toStringTag,wd[Xv]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(wd.prototype);class Sd extends ae{constructor(){super(B.Binary)}toString(){return"Binary"}}Kv=Symbol.toStringTag,Sd[Kv]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Sd.prototype);class Ed extends ae{constructor(){super(B.LargeBinary)}toString(){return"LargeBinary"}}Qv=Symbol.toStringTag,Ed[Qv]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Ed.prototype);class Id extends ae{constructor(){super(B.Utf8)}toString(){return"Utf8"}}Jv=Symbol.toStringTag,Id[Jv]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Id.prototype);class Td extends ae{constructor(){super(B.LargeUtf8)}toString(){return"LargeUtf8"}}Zv=Symbol.toStringTag,Td[Zv]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(Td.prototype);class Ad extends ae{constructor(){super(B.Bool)}toString(){return"Bool"}}tb=Symbol.toStringTag,Ad[tb]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Ad.prototype);class xd extends ae{constructor(t,n,r=128){super(B.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}eb=Symbol.toStringTag,xd[eb]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(xd.prototype);class Rd extends ae{constructor(t){super(B.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Ui[this.unit]}>`}get ArrayType(){return this.unit===Ui.DAY?Int32Array:BigInt64Array}}nb=Symbol.toStringTag,Rd[nb]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(Rd.prototype);class Nd extends ae{constructor(t,n){super(B.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${Ie[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}rb=Symbol.toStringTag,Nd[rb]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(Nd.prototype);class Bd extends ae{constructor(t,n){super(B.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${Ie[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}ib=Symbol.toStringTag,Bd[ib]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Bd.prototype);class Od extends ae{constructor(t){super(B.Interval),this.unit=t}toString(){return`Interval<${Is[this.unit]}>`}}sb=Symbol.toStringTag,Od[sb]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Od.prototype);class Dd extends ae{constructor(t){super(B.Duration),this.unit=t}toString(){return`Duration<${Ie[this.unit]}>`}}ab=Symbol.toStringTag,Dd[ab]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(Dd.prototype);class Fd extends ae{constructor(t){super(B.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}ob=Symbol.toStringTag,Fd[ob]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Fd.prototype);class ti extends ae{constructor(t){super(B.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}lb=Symbol.toStringTag,ti[lb]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(ti.prototype);class Ld extends ae{constructor(t,n,r){super(B.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}cb=Symbol.toStringTag,Ld[cb]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Ld.prototype);class Md extends ae{constructor(t){super(B.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}ub=Symbol.toStringTag,Md[ub]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Md.prototype);class Cd extends ae{constructor(t,n){super(B.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}db=Symbol.toStringTag,Cd[db]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Cd.prototype);class kd extends ae{constructor(t,n=!1){var r,i,s;if(super(B.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}fb=Symbol.toStringTag,kd[fb]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(kd.prototype);const cF=(e=>()=>++e)(-1);class Ko extends ae{constructor(t,n,r,i){super(B.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?cF():zn(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}hb=Symbol.toStringTag,Ko[hb]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(Ko.prototype);function oa(e){const t=e;switch(e.typeId){case B.Decimal:return e.bitWidth/32;case B.Interval:return 1+t.unit;case B.FixedSizeList:return t.listSize;case B.FixedSizeBinary:return t.byteWidth;default:return 1}}class tn{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return uF(this,t,n)}getVisitFnByTypeId(t,n=!0){return Qo(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function uF(e,t,n=!0){return typeof t=="number"?Qo(e,t,n):typeof t=="string"&&t in B?Qo(e,B[t],n):t&&t instanceof ae?Qo(e,pb(t),n):t!=null&&t.type&&t.type instanceof ae?Qo(e,pb(t.type),n):Qo(e,B.NONE,n)}function Qo(e,t,n=!0){let r=null;switch(t){case B.Null:r=e.visitNull;break;case B.Bool:r=e.visitBool;break;case B.Int:r=e.visitInt;break;case B.Int8:r=e.visitInt8||e.visitInt;break;case B.Int16:r=e.visitInt16||e.visitInt;break;case B.Int32:r=e.visitInt32||e.visitInt;break;case B.Int64:r=e.visitInt64||e.visitInt;break;case B.Uint8:r=e.visitUint8||e.visitInt;break;case B.Uint16:r=e.visitUint16||e.visitInt;break;case B.Uint32:r=e.visitUint32||e.visitInt;break;case B.Uint64:r=e.visitUint64||e.visitInt;break;case B.Float:r=e.visitFloat;break;case B.Float16:r=e.visitFloat16||e.visitFloat;break;case B.Float32:r=e.visitFloat32||e.visitFloat;break;case B.Float64:r=e.visitFloat64||e.visitFloat;break;case B.Utf8:r=e.visitUtf8;break;case B.LargeUtf8:r=e.visitLargeUtf8;break;case B.Binary:r=e.visitBinary;break;case B.LargeBinary:r=e.visitLargeBinary;break;case B.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case B.Date:r=e.visitDate;break;case B.DateDay:r=e.visitDateDay||e.visitDate;break;case B.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case B.Timestamp:r=e.visitTimestamp;break;case B.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case B.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case B.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case B.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case B.Time:r=e.visitTime;break;case B.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case B.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case B.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case B.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case B.Decimal:r=e.visitDecimal;break;case B.List:r=e.visitList;break;case B.Struct:r=e.visitStruct;break;case B.Union:r=e.visitUnion;break;case B.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case B.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case B.Dictionary:r=e.visitDictionary;break;case B.Interval:r=e.visitInterval;break;case B.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case B.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case B.Duration:r=e.visitDuration;break;case B.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case B.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case B.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case B.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case B.FixedSizeList:r=e.visitFixedSizeList;break;case B.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${B[t]}'`)}function pb(e){switch(e.typeId){case B.Null:return B.Null;case B.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?B.Int8:B.Uint8;case 16:return n?B.Int16:B.Uint16;case 32:return n?B.Int32:B.Uint32;case 64:return n?B.Int64:B.Uint64}return B.Int}case B.Float:switch(e.precision){case Yr.HALF:return B.Float16;case Yr.SINGLE:return B.Float32;case Yr.DOUBLE:return B.Float64}return B.Float;case B.Binary:return B.Binary;case B.LargeBinary:return B.LargeBinary;case B.Utf8:return B.Utf8;case B.LargeUtf8:return B.LargeUtf8;case B.Bool:return B.Bool;case B.Decimal:return B.Decimal;case B.Time:switch(e.unit){case Ie.SECOND:return B.TimeSecond;case Ie.MILLISECOND:return B.TimeMillisecond;case Ie.MICROSECOND:return B.TimeMicrosecond;case Ie.NANOSECOND:return B.TimeNanosecond}return B.Time;case B.Timestamp:switch(e.unit){case Ie.SECOND:return B.TimestampSecond;case Ie.MILLISECOND:return B.TimestampMillisecond;case Ie.MICROSECOND:return B.TimestampMicrosecond;case Ie.NANOSECOND:return B.TimestampNanosecond}return B.Timestamp;case B.Date:switch(e.unit){case Ui.DAY:return B.DateDay;case Ui.MILLISECOND:return B.DateMillisecond}return B.Date;case B.Interval:switch(e.unit){case Is.DAY_TIME:return B.IntervalDayTime;case Is.YEAR_MONTH:return B.IntervalYearMonth}return B.Interval;case B.Duration:switch(e.unit){case Ie.SECOND:return B.DurationSecond;case Ie.MILLISECOND:return B.DurationMillisecond;case Ie.MICROSECOND:return B.DurationMicrosecond;case Ie.NANOSECOND:return B.DurationNanosecond}return B.Duration;case B.Map:return B.Map;case B.List:return B.List;case B.Struct:return B.Struct;case B.Union:switch(e.mode){case jr.Dense:return B.DenseUnion;case jr.Sparse:return B.SparseUnion}return B.Union;case B.FixedSizeBinary:return B.FixedSizeBinary;case B.FixedSizeList:return B.FixedSizeList;case B.Dictionary:return B.Dictionary}throw new Error(`Unrecognized type '${B[e.typeId]}'`)}tn.prototype.visitInt8=null,tn.prototype.visitInt16=null,tn.prototype.visitInt32=null,tn.prototype.visitInt64=null,tn.prototype.visitUint8=null,tn.prototype.visitUint16=null,tn.prototype.visitUint32=null,tn.prototype.visitUint64=null,tn.prototype.visitFloat16=null,tn.prototype.visitFloat32=null,tn.prototype.visitFloat64=null,tn.prototype.visitDateDay=null,tn.prototype.visitDateMillisecond=null,tn.prototype.visitTimestampSecond=null,tn.prototype.visitTimestampMillisecond=null,tn.prototype.visitTimestampMicrosecond=null,tn.prototype.visitTimestampNanosecond=null,tn.prototype.visitTimeSecond=null,tn.prototype.visitTimeMillisecond=null,tn.prototype.visitTimeMicrosecond=null,tn.prototype.visitTimeNanosecond=null,tn.prototype.visitDenseUnion=null,tn.prototype.visitSparseUnion=null,tn.prototype.visitIntervalDayTime=null,tn.prototype.visitIntervalYearMonth=null,tn.prototype.visitDuration=null,tn.prototype.visitDurationSecond=null,tn.prototype.visitDurationMillisecond=null,tn.prototype.visitDurationMicrosecond=null,tn.prototype.visitDurationNanosecond=null;const mb=new Float64Array(1),Jo=new Uint32Array(mb.buffer);function yb(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function dF(e){if(e!==e)return 32256;mb[0]=e;const t=(Jo[1]&2147483648)>>16&65535;let n=Jo[1]&2146435072,r=0;return n>=1089470464?Jo[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Jo[1]&1048575)>>10):n<=1056964608?(r=1048576+(Jo[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Jo[1]&1048575)+512>>10),t|n|r&65535}class Te extends tn{}function Me(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const fF=(e,t,n)=>{e[t]=Math.floor(n/864e5)},gb=(e,t,n,r)=>{if(n+1<t.length){const i=zn(t[n]),s=zn(t[n+1]);e.set(r.subarray(0,s-i),i)}},hF=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},la=({values:e},t,n)=>{e[t]=n},Vp=({values:e},t,n)=>{e[t]=n},_b=({values:e},t,n)=>{e[t]=dF(n)},pF=(e,t,n)=>{switch(e.type.precision){case Yr.HALF:return _b(e,t,n);case Yr.SINGLE:case Yr.DOUBLE:return Vp(e,t,n)}},vb=({values:e},t,n)=>{fF(e,t,n.valueOf())},bb=({values:e},t,n)=>{e[t]=BigInt(n)},mF=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},wb=({values:e,valueOffsets:t},n,r)=>gb(e,t,n,r),Sb=({values:e,valueOffsets:t},n,r)=>gb(e,t,n,Op(r)),yF=(e,t,n)=>{e.type.unit===Ui.DAY?vb(e,t,n):bb(e,t,n)},Eb=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},Ib=({values:e},t,n)=>{e[t]=BigInt(n)},Tb=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Ab=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},gF=(e,t,n)=>{switch(e.type.unit){case Ie.SECOND:return Eb(e,t,n);case Ie.MILLISECOND:return Ib(e,t,n);case Ie.MICROSECOND:return Tb(e,t,n);case Ie.NANOSECOND:return Ab(e,t,n)}},xb=({values:e},t,n)=>{e[t]=n},Rb=({values:e},t,n)=>{e[t]=n},Nb=({values:e},t,n)=>{e[t]=n},Bb=({values:e},t,n)=>{e[t]=n},_F=(e,t,n)=>{switch(e.type.unit){case Ie.SECOND:return xb(e,t,n);case Ie.MILLISECOND:return Rb(e,t,n);case Ie.MICROSECOND:return Nb(e,t,n);case Ie.NANOSECOND:return Bb(e,t,n)}},vF=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},bF=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=zi.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},wF=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=zi.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const u of l)if(s(r,a,u),++a>=o)break},SF=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),EF=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),IF=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),TF=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),AF=(e,t,n)=>{const r=e.type.children.map(s=>zi.getVisitFn(s.type)),i=n instanceof Map?IF(t,n):n instanceof En?EF(t,n):Array.isArray(n)?SF(t,n):TF(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},xF=(e,t,n)=>{e.type.mode===jr.Dense?Ob(e,t,n):Db(e,t,n)},Ob=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];zi.visit(i,e.valueOffsets[t],n)},Db=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];zi.visit(i,t,n)},RF=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},NF=(e,t,n)=>{e.type.unit===Is.DAY_TIME?Fb(e,t,n):Lb(e,t,n)},Fb=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Lb=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Mb=({values:e},t,n)=>{e[t]=n},Cb=({values:e},t,n)=>{e[t]=n},kb=({values:e},t,n)=>{e[t]=n},Ub=({values:e},t,n)=>{e[t]=n},BF=(e,t,n)=>{switch(e.type.unit){case Ie.SECOND:return Mb(e,t,n);case Ie.MILLISECOND:return Cb(e,t,n);case Ie.MICROSECOND:return kb(e,t,n);case Ie.NANOSECOND:return Ub(e,t,n)}},OF=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=zi.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};Te.prototype.visitBool=Me(hF),Te.prototype.visitInt=Me(la),Te.prototype.visitInt8=Me(la),Te.prototype.visitInt16=Me(la),Te.prototype.visitInt32=Me(la),Te.prototype.visitInt64=Me(la),Te.prototype.visitUint8=Me(la),Te.prototype.visitUint16=Me(la),Te.prototype.visitUint32=Me(la),Te.prototype.visitUint64=Me(la),Te.prototype.visitFloat=Me(pF),Te.prototype.visitFloat16=Me(_b),Te.prototype.visitFloat32=Me(Vp),Te.prototype.visitFloat64=Me(Vp),Te.prototype.visitUtf8=Me(Sb),Te.prototype.visitLargeUtf8=Me(Sb),Te.prototype.visitBinary=Me(wb),Te.prototype.visitLargeBinary=Me(wb),Te.prototype.visitFixedSizeBinary=Me(mF),Te.prototype.visitDate=Me(yF),Te.prototype.visitDateDay=Me(vb),Te.prototype.visitDateMillisecond=Me(bb),Te.prototype.visitTimestamp=Me(gF),Te.prototype.visitTimestampSecond=Me(Eb),Te.prototype.visitTimestampMillisecond=Me(Ib),Te.prototype.visitTimestampMicrosecond=Me(Tb),Te.prototype.visitTimestampNanosecond=Me(Ab),Te.prototype.visitTime=Me(_F),Te.prototype.visitTimeSecond=Me(xb),Te.prototype.visitTimeMillisecond=Me(Rb),Te.prototype.visitTimeMicrosecond=Me(Nb),Te.prototype.visitTimeNanosecond=Me(Bb),Te.prototype.visitDecimal=Me(vF),Te.prototype.visitList=Me(bF),Te.prototype.visitStruct=Me(AF),Te.prototype.visitUnion=Me(xF),Te.prototype.visitDenseUnion=Me(Ob),Te.prototype.visitSparseUnion=Me(Db),Te.prototype.visitDictionary=Me(RF),Te.prototype.visitInterval=Me(NF),Te.prototype.visitIntervalDayTime=Me(Fb),Te.prototype.visitIntervalYearMonth=Me(Lb),Te.prototype.visitDuration=Me(BF),Te.prototype.visitDurationSecond=Me(Mb),Te.prototype.visitDurationMillisecond=Me(Cb),Te.prototype.visitDurationMicrosecond=Me(kb),Te.prototype.visitDurationNanosecond=Me(Ub),Te.prototype.visitFixedSizeList=Me(OF),Te.prototype.visitMap=Me(wF);const zi=new Te,ls=Symbol.for("parent"),Zo=Symbol.for("rowIndex");class zp{constructor(t,n){return this[ls]=t,this[Zo]=n,new Proxy(this,new FF)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Zo],n=this[ls],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=mi.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${_c(t)}: ${_c(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new DF(this[ls],this[Zo])}}class DF{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,mi.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(zp.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ls]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Zo]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class FF{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ls].type.children.map(n=>n.name)}has(t,n){return t[ls].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ls].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[ls].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=mi.visit(t[ls].children[r],t[Zo]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ls].type.children.findIndex(s=>s.name===n);return i!==-1?(zi.visit(t[ls].children[i],t[Zo],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class ye extends tn{}function Ae(e){return(t,n)=>t.getValid(n)?e(t,n):null}const LF=(e,t)=>864e5*e[t],MF=(e,t)=>null,Pb=(e,t,n)=>{if(n+1>=t.length)return null;const r=zn(t[n]),i=zn(t[n+1]);return e.subarray(r,i)},CF=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},$b=({values:e},t)=>LF(e,t),Vb=({values:e},t)=>zn(e[t]),Da=({stride:e,values:t},n)=>t[e*n],kF=({stride:e,values:t},n)=>yb(t[e*n]),zb=({values:e},t)=>e[t],UF=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Gb=({values:e,valueOffsets:t},n)=>Pb(e,t,n),jb=({values:e,valueOffsets:t},n)=>{const r=Pb(e,t,n);return r!==null?Bp(r):null},PF=({values:e},t)=>e[t],$F=({type:e,values:t},n)=>e.precision!==Yr.HALF?t[n]:yb(t[n]),VF=(e,t)=>e.type.unit===Ui.DAY?$b(e,t):Vb(e,t),Yb=({values:e},t)=>1e3*zn(e[t]),Wb=({values:e},t)=>zn(e[t]),Hb=({values:e},t)=>jv(e[t],BigInt(1e3)),qb=({values:e},t)=>jv(e[t],BigInt(1e6)),zF=(e,t)=>{switch(e.type.unit){case Ie.SECOND:return Yb(e,t);case Ie.MILLISECOND:return Wb(e,t);case Ie.MICROSECOND:return Hb(e,t);case Ie.NANOSECOND:return qb(e,t)}},Xb=({values:e},t)=>e[t],Kb=({values:e},t)=>e[t],Qb=({values:e},t)=>e[t],Jb=({values:e},t)=>e[t],GF=(e,t)=>{switch(e.type.unit){case Ie.SECOND:return Xb(e,t);case Ie.MILLISECOND:return Kb(e,t);case Ie.MICROSECOND:return Qb(e,t);case Ie.NANOSECOND:return Jb(e,t)}},jF=({values:e,stride:t},n)=>$p.decimal(e.subarray(t*n,t*(n+1))),YF=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,l=i[0].slice(s,a-s);return new En([l])},WF=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new jp(a.slice(i,s-i))},HF=(e,t)=>new zp(e,t),qF=(e,t)=>e.type.mode===jr.Dense?Zb(e,t):t0(e,t),Zb=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return mi.visit(r,e.valueOffsets[t])},t0=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return mi.visit(r,t)},XF=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},KF=(e,t)=>e.type.unit===Is.DAY_TIME?e0(e,t):n0(e,t),e0=({values:e},t)=>e.subarray(2*t,2*(t+1)),n0=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},r0=({values:e},t)=>e[t],i0=({values:e},t)=>e[t],s0=({values:e},t)=>e[t],a0=({values:e},t)=>e[t],QF=(e,t)=>{switch(e.type.unit){case Ie.SECOND:return r0(e,t);case Ie.MILLISECOND:return i0(e,t);case Ie.MICROSECOND:return s0(e,t);case Ie.NANOSECOND:return a0(e,t)}},JF=(e,t)=>{const{stride:n,children:r}=e,s=r[0].slice(t*n,n);return new En([s])};ye.prototype.visitNull=Ae(MF),ye.prototype.visitBool=Ae(CF),ye.prototype.visitInt=Ae(PF),ye.prototype.visitInt8=Ae(Da),ye.prototype.visitInt16=Ae(Da),ye.prototype.visitInt32=Ae(Da),ye.prototype.visitInt64=Ae(zb),ye.prototype.visitUint8=Ae(Da),ye.prototype.visitUint16=Ae(Da),ye.prototype.visitUint32=Ae(Da),ye.prototype.visitUint64=Ae(zb),ye.prototype.visitFloat=Ae($F),ye.prototype.visitFloat16=Ae(kF),ye.prototype.visitFloat32=Ae(Da),ye.prototype.visitFloat64=Ae(Da),ye.prototype.visitUtf8=Ae(jb),ye.prototype.visitLargeUtf8=Ae(jb),ye.prototype.visitBinary=Ae(Gb),ye.prototype.visitLargeBinary=Ae(Gb),ye.prototype.visitFixedSizeBinary=Ae(UF),ye.prototype.visitDate=Ae(VF),ye.prototype.visitDateDay=Ae($b),ye.prototype.visitDateMillisecond=Ae(Vb),ye.prototype.visitTimestamp=Ae(zF),ye.prototype.visitTimestampSecond=Ae(Yb),ye.prototype.visitTimestampMillisecond=Ae(Wb),ye.prototype.visitTimestampMicrosecond=Ae(Hb),ye.prototype.visitTimestampNanosecond=Ae(qb),ye.prototype.visitTime=Ae(GF),ye.prototype.visitTimeSecond=Ae(Xb),ye.prototype.visitTimeMillisecond=Ae(Kb),ye.prototype.visitTimeMicrosecond=Ae(Qb),ye.prototype.visitTimeNanosecond=Ae(Jb),ye.prototype.visitDecimal=Ae(jF),ye.prototype.visitList=Ae(YF),ye.prototype.visitStruct=Ae(HF),ye.prototype.visitUnion=Ae(qF),ye.prototype.visitDenseUnion=Ae(Zb),ye.prototype.visitSparseUnion=Ae(t0),ye.prototype.visitDictionary=Ae(XF),ye.prototype.visitInterval=Ae(KF),ye.prototype.visitIntervalDayTime=Ae(e0),ye.prototype.visitIntervalYearMonth=Ae(n0),ye.prototype.visitDuration=Ae(QF),ye.prototype.visitDurationSecond=Ae(r0),ye.prototype.visitDurationMillisecond=Ae(i0),ye.prototype.visitDurationMicrosecond=Ae(s0),ye.prototype.visitDurationNanosecond=Ae(a0),ye.prototype.visitFixedSizeList=Ae(JF),ye.prototype.visitMap=Ae(WF);const mi=new ye,tl=Symbol.for("keys"),el=Symbol.for("vals"),nl=Symbol.for("kKeysAsStrings"),Gp=Symbol.for("_kKeysAsStrings");class jp{constructor(t){return this[tl]=new En([t.children[0]]).memoize(),this[el]=t.children[1],new Proxy(this,new tL)}get[nl](){return this[Gp]||(this[Gp]=Array.from(this[tl].toArray(),String))}[Symbol.iterator](){return new ZF(this[tl],this[el])}get size(){return this[tl].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[tl],n=this[el],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=mi.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${_c(t)}: ${_c(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class ZF{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),mi.visit(this.vals,t)]})}}class tL{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[nl]}has(t,n){return t[nl].includes(n)}getOwnPropertyDescriptor(t,n){if(t[nl].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[nl].indexOf(n);if(r!==-1){const i=mi.visit(Reflect.get(t,el),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[nl].indexOf(n);return i!==-1?(zi.visit(Reflect.get(t,el),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(jp.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[tl]:{writable:!0,enumerable:!1,configurable:!1,value:null},[el]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Gp]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let o0;function l0(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(o0=s,s=a,a=o0),a>i&&(a=i),r?r(e,s,a):[s,a]}const Yp=(e,t)=>e<0?t+e:e,c0=e=>e!==e;function rl(e){if(typeof e!=="object"||e===null)return c0(e)?c0:n=>n===e;if(e instanceof Date){const n=e.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(e)?n=>n?ZD(e,n):!1:e instanceof Map?nL(e):Array.isArray(e)?eL(e):e instanceof En?rL(e):iL(e,!0)}function eL(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=rl(e[n]);return Ud(t)}function nL(e){let t=-1;const n=[];for(const r of e.values())n[++t]=rl(r);return Ud(n)}function rL(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=rl(e.get(n));return Ud(t)}function iL(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=rl(e[n[i]]);return Ud(r,n)}function Ud(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return sL(e,n);case Map:return u0(e,n,n.keys());case jp:case zp:case Object:case void 0:return u0(e,n,t||Object.keys(n))}return n instanceof En?aL(e,n):!1}}function sL(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function aL(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function u0(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),u=r.next(),f=i.next();for(;a<o&&!u.done&&!f.done&&!l.done&&!(u.value!==f.value||!e[a](l.value));++a,u=r.next(),f=i.next(),l=s.next());return a===o&&u.done&&f.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function d0(e,t,n,r){return(n&1<<r)!==0}function oL(e,t,n,r){return(n&1<<r)>>r}function Pd(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):$d(new Wp(n,e,t,null,d0)).subarray(0,r)),i}return n}function $d(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class Wp{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function Hp(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new Wp(e,t,n-t,e,oL))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return Hp(e,t,i)+Hp(e,r,n)+lL(e,i>>3,r-i>>3)}function lL(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=qp(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=qp(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=qp(s.getUint8(i)),i+=1;return r}function qp(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const cL=-1;class On{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return ae.isSparseUnion(t)?this.children.some(n=>n.nullable):ae.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(ae.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=cL&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-Hp(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof On?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=oa(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(ae.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===jr.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(ae.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===jr.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,u=1<<l%8,f=l>>3;(!s||s.byteLength<=f)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Pd(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const p=s[f];r=(p&u)!==0,s[f]=n?p|u:p&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new On(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===B.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Pd(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[aa.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[aa.TYPE])&&(a[aa.TYPE]=s.subarray(t,t+n)),(s=a[aa.OFFSET])&&(a[aa.OFFSET]=s.subarray(t,t+n+1))||(s=a[aa.DATA])&&(a[aa.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}On.prototype.children=Object.freeze([]);class Sc extends tn{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new On(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.data),s=cn(t.nullBitmap),a=gc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.data),s=cn(t.nullBitmap),a=Nv(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.data),s=cn(t.nullBitmap),a=gc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.data),s=cn(t.nullBitmap),a=Nv(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=cn(t.nullBitmap),a=gc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=cn(t.nullBitmap),{length:a=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=Bn(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(ae.isSparseUnion(n))return new On(n,r,a,o,[void 0,void 0,void 0,s],i);const l=gc(t.valueOffsets);return new On(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.indices.ArrayType,t.data),{["dictionary"]:a=new En([new Sc().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=cn(t.nullBitmap),s=Bn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Sc().visit({type:n.valueType})}=t,s=cn(t.nullBitmap),{["length"]:a=i.length/oa(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new On(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Sc().visit({type:n.childType})}=t,s=cn(t.nullBitmap),a=gc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new On(n,r,o,l,[a,void 0,s],[i])}}const uL=new Sc;function sn(e){return uL.visit(e)}class f0{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function dL(e){return e.some(t=>t.nullable)}function h0(e){return e.reduce((t,n)=>t+n.nullCount,0)}function p0(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function m0(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:u}=o;if(l>=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(o);continue}const f=Math.max(0,n-l),p=Math.min(r-l,u);i.push(o.slice(f,p-f))}return i.length===0&&i.push(e[0].slice(0,0)),i}function Xp(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function Kp(e,t){return e.getValid(t)}function Vd(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return Xp(r,this._offsets,n,t)}}function y0(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=Xp(s,this._offsets,r,n);return t=void 0,a}}function g0(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let u=i-1,f=r.length;++u<f;){const p=r[u];if(~(o=e(p,t,a)))return l+o;a=0,l+=p.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):Xp(s,this._offsets,i,n);return t=void 0,a}}class ge extends tn{}function fL(e,t){return t===null&&e.length>0?0:-1}function hL(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new Wp(n,e.offset+(t||0),e.length,n,d0)){if(!i)return r;++r}return-1}function Pe(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case B.Union:break;case B.Dictionary:break;default:return hL(e,n)}const r=mi.getVisitFn(e),i=rl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function _0(e,t,n){const r=mi.getVisitFn(e),i=rl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}ge.prototype.visitNull=fL,ge.prototype.visitBool=Pe,ge.prototype.visitInt=Pe,ge.prototype.visitInt8=Pe,ge.prototype.visitInt16=Pe,ge.prototype.visitInt32=Pe,ge.prototype.visitInt64=Pe,ge.prototype.visitUint8=Pe,ge.prototype.visitUint16=Pe,ge.prototype.visitUint32=Pe,ge.prototype.visitUint64=Pe,ge.prototype.visitFloat=Pe,ge.prototype.visitFloat16=Pe,ge.prototype.visitFloat32=Pe,ge.prototype.visitFloat64=Pe,ge.prototype.visitUtf8=Pe,ge.prototype.visitLargeUtf8=Pe,ge.prototype.visitBinary=Pe,ge.prototype.visitLargeBinary=Pe,ge.prototype.visitFixedSizeBinary=Pe,ge.prototype.visitDate=Pe,ge.prototype.visitDateDay=Pe,ge.prototype.visitDateMillisecond=Pe,ge.prototype.visitTimestamp=Pe,ge.prototype.visitTimestampSecond=Pe,ge.prototype.visitTimestampMillisecond=Pe,ge.prototype.visitTimestampMicrosecond=Pe,ge.prototype.visitTimestampNanosecond=Pe,ge.prototype.visitTime=Pe,ge.prototype.visitTimeSecond=Pe,ge.prototype.visitTimeMillisecond=Pe,ge.prototype.visitTimeMicrosecond=Pe,ge.prototype.visitTimeNanosecond=Pe,ge.prototype.visitDecimal=Pe,ge.prototype.visitList=Pe,ge.prototype.visitStruct=Pe,ge.prototype.visitUnion=Pe,ge.prototype.visitDenseUnion=_0,ge.prototype.visitSparseUnion=_0,ge.prototype.visitDictionary=Pe,ge.prototype.visitInterval=Pe,ge.prototype.visitIntervalDayTime=Pe,ge.prototype.visitIntervalYearMonth=Pe,ge.prototype.visitDuration=Pe,ge.prototype.visitDurationSecond=Pe,ge.prototype.visitDurationMillisecond=Pe,ge.prototype.visitDurationMicrosecond=Pe,ge.prototype.visitDurationNanosecond=Pe,ge.prototype.visitFixedSizeList=Pe,ge.prototype.visitMap=Pe;const zd=new ge;class _e extends tn{}function xe(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(ae.isInt(t)&&t.bitWidth!==64||ae.isTime(t)&&t.bitWidth!==64||ae.isFloat(t)&&t.precision!==Yr.HALF))return new f0(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new f0(e.data.length,r=>{const s=e.data[r].length,a=e.slice(n,n+s);return n+=s,new pL(a)})}class pL{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}_e.prototype.visitNull=xe,_e.prototype.visitBool=xe,_e.prototype.visitInt=xe,_e.prototype.visitInt8=xe,_e.prototype.visitInt16=xe,_e.prototype.visitInt32=xe,_e.prototype.visitInt64=xe,_e.prototype.visitUint8=xe,_e.prototype.visitUint16=xe,_e.prototype.visitUint32=xe,_e.prototype.visitUint64=xe,_e.prototype.visitFloat=xe,_e.prototype.visitFloat16=xe,_e.prototype.visitFloat32=xe,_e.prototype.visitFloat64=xe,_e.prototype.visitUtf8=xe,_e.prototype.visitLargeUtf8=xe,_e.prototype.visitBinary=xe,_e.prototype.visitLargeBinary=xe,_e.prototype.visitFixedSizeBinary=xe,_e.prototype.visitDate=xe,_e.prototype.visitDateDay=xe,_e.prototype.visitDateMillisecond=xe,_e.prototype.visitTimestamp=xe,_e.prototype.visitTimestampSecond=xe,_e.prototype.visitTimestampMillisecond=xe,_e.prototype.visitTimestampMicrosecond=xe,_e.prototype.visitTimestampNanosecond=xe,_e.prototype.visitTime=xe,_e.prototype.visitTimeSecond=xe,_e.prototype.visitTimeMillisecond=xe,_e.prototype.visitTimeMicrosecond=xe,_e.prototype.visitTimeNanosecond=xe,_e.prototype.visitDecimal=xe,_e.prototype.visitList=xe,_e.prototype.visitStruct=xe,_e.prototype.visitUnion=xe,_e.prototype.visitDenseUnion=xe,_e.prototype.visitSparseUnion=xe,_e.prototype.visitDictionary=xe,_e.prototype.visitInterval=xe,_e.prototype.visitIntervalDayTime=xe,_e.prototype.visitIntervalYearMonth=xe,_e.prototype.visitDuration=xe,_e.prototype.visitDurationSecond=xe,_e.prototype.visitDurationMillisecond=xe,_e.prototype.visitDurationMicrosecond=xe,_e.prototype.visitDurationNanosecond=xe,_e.prototype.visitFixedSizeList=xe,_e.prototype.visitMap=xe;const Qp=new _e;var v0;const b0={},w0={};class En{constructor(t){var n,r,i;const s=t[0]instanceof En?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof On)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:u}=b0[a.typeId],f=s[0];this.isValid=p=>Kp(f,p),this.get=p=>o(f,p),this.set=(p,E)=>l(f,p,E),this.indexOf=p=>u(f,p),this._offsets=[0,f.length];break}default:Object.setPrototypeOf(this,w0[a.typeId]),this._offsets=p0(s);break}this.data=s,this.type=a,this.stride=oa(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return dL(this.data)}get nullCount(){return h0(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${B[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Yp(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return Qp.visit(this)}concat(...t){return new En(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new En(l0(this,t,n,({data:r,_offsets:i},s,a)=>m0(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case B.Int:case B.Float:case B.Decimal:case B.Time:case B.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new En(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return ae.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(ae.isDictionary(this.type)){const t=new Gd(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new En(n)}return new Gd(this)}unmemoize(){if(ae.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new En(n)}return this}}v0=Symbol.toStringTag,En[v0]=(e=>{e.type=ae.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(B).map(n=>B[n]).filter(n=>typeof n=="number"&&n!==B.NONE);for(const n of t){const r=mi.getVisitFnByTypeId(n),i=zi.getVisitFnByTypeId(n),s=zd.getVisitFnByTypeId(n);b0[n]={get:r,set:i,indexOf:s},w0[n]=Object.create(e,{isValid:{value:Vd(Kp)},get:{value:Vd(mi.getVisitFnByTypeId(n))},set:{value:y0(zi.getVisitFnByTypeId(n))},indexOf:{value:g0(zd.getVisitFnByTypeId(n))}})}return"Vector"})(En.prototype);class Gd extends En{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new Gd(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new En(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Jp{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Ni{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Ni).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Sn),(n||new Ni).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mr.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Rs).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Jp).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new Jp).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Ir).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,mr.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class In{constructor(t=[],n,r,i=mr.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=Zp(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new In(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new In(n,this.metadata)}assign(...t){const n=t[0]instanceof In?t[0]:Array.isArray(t[0])?new In(t[0]):new In(t),r=[...this.fields],i=jd(jd(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(u=>u.name===o.name);return~l?(r[l]=o.clone({metadata:jd(jd(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=Zp(s,new Map);return new In([...r,...s],i,new Map([...this.dictionaries,...a]))}}In.prototype.fields=null,In.prototype.metadata=null,In.prototype.dictionaries=null;class Xn{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new Xn(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],Xn.new(n,r,i,s)}}Xn.prototype.type=null,Xn.prototype.name=null,Xn.prototype.nullable=null,Xn.prototype.metadata=null;function jd(e,t){return new Map([...e||new Map,...t||new Map])}function Zp(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const s=e[n].type;if(ae.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&Zp(s.children,t)}return t}var mL=Lv,yL=jo;class Ec{static decode(t){t=new yL(cn(t));const n=Ni.getRootAsFooter(t),r=In.decode(n.schema(),new Map,n.version());return new gL(r,n)}static encode(t){const n=new mL,r=In.encode(n,t.schema);Ni.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Fa.encode(n,a);const i=n.endVector();Ni.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Fa.encode(n,a);const s=n.endVector();return Ni.startFooter(n),Ni.addSchema(n,r),Ni.addVersion(n,mr.V5),Ni.addRecordBatches(n,i),Ni.addDictionaries(n,s),Ni.finishFooterBuffer(n,Ni.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=mr.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class gL extends Ec{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Fa.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Fa.decode(n)}return null}}class Fa{static decode(t){return new Fa(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return Jp.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=zn(r),this.bodyLength=zn(n)}}const nr=Object.freeze({done:!0,value:void 0});class S0{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class tm{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class _L extends tm{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Ve(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(nr);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ki.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ki.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Ve(this,void 0,void 0,function*(){return yield this.abort(t),nr})}return(t){return Ve(this,void 0,void 0,function*(){return yield this.close(),nr})}read(t){return Ve(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ve(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(nr)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Yd extends _L{write(t){if((t=cn(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Bp(this.toUint8Array(!0)):this.toUint8Array(!1).then(Bp)}toUint8Array(t=!1){return t?Es(this._values)[0]:Ve(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,u=uo(this),f;f=yield u.next(),n=f.done,!n;l=!0){s=f.value,l=!1;const p=s;a.push(p),o+=p.byteLength}}catch(p){r={error:p}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Es(a,o)[0]})}}class Wd{constructor(t){t&&(this.source=new vL(ki.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class il{constructor(t){t instanceof il?this.source=t.source:t instanceof Yd?this.source=new mo(ki.fromAsyncIterable(t)):xv(t)?this.source=new mo(ki.fromNodeStream(t)):Fp(t)?this.source=new mo(ki.fromDOMStream(t)):Av(t)?this.source=new mo(ki.fromDOMStream(t.body)):yc(t)?this.source=new mo(ki.fromIterable(t)):fo(t)?this.source=new mo(ki.fromAsyncIterable(t)):Go(t)&&(this.source=new mo(ki.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class vL{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||nr)}return(t){return Object.create(this.source.return&&this.source.return(t)||nr)}}class mo{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Ve(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Ve(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ve(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Ve(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Ve(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||nr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Ve(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||nr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class E0 extends Wd{constructor(t,n){super(),this.position=0,this.buffer=cn(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class Hd extends il{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Ve(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Ve(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return Ve(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return Ve(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),u=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<u.byteLength;)({bytesRead:o}=yield n.read(u,a,u.byteLength-a,s));return u}return null})}readAt(t,n){return Ve(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Ve(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Ve(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Ve(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const bL=65536;function sl(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const al=8,em=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class I0{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?bL:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${sl(this.buffer[1])} ${sl(this.buffer[0])}`}}class Dn extends I0{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return Dn.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Dn.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new Dn(n);for(let s=0;s<r;){const a=al<r-s?al:r-s,o=new Dn(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new Dn(new Uint32Array([em[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Dn.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Dn(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Dn(new Uint32Array(t.buffer)).plus(n)}}class yi extends I0{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return yi.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return yi.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new yi(n);for(let a=r?1:0;a<i;){const o=al<i-a?al:i-a,l=new yi(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),u=new yi(new Uint32Array([em[o],0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)yi.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new yi(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new yi(new Uint32Array(t.buffer)).plus(n)}}class Ns{constructor(t){this.buffer=t}high(){return new yi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new yi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){const n=new Dn(new Uint32Array([this.buffer[3],0])),r=new Dn(new Uint32Array([this.buffer[2],0])),i=new Dn(new Uint32Array([this.buffer[1],0])),s=new Dn(new Uint32Array([this.buffer[0],0])),a=new Dn(new Uint32Array([t.buffer[3],0])),o=new Dn(new Uint32Array([t.buffer[2],0])),l=new Dn(new Uint32Array([t.buffer[1],0])),u=new Dn(new Uint32Array([t.buffer[0],0]));let f=Dn.multiply(s,u);this.buffer[0]=f.low();const p=new Dn(new Uint32Array([f.high(),0]));return f=Dn.multiply(i,u),p.plus(f),f=Dn.multiply(s,l),p.plus(f),this.buffer[1]=p.low(),this.buffer[3]=p.lessThan(f)?1:0,this.buffer[2]=p.high(),new Dn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Dn.multiply(r,u)).plus(Dn.multiply(i,l)).plus(Dn.multiply(s,o)),this.buffer[3]+=Dn.multiply(n,u).plus(Dn.multiply(r,l)).plus(Dn.multiply(i,o)).plus(Dn.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${sl(this.buffer[3])} ${sl(this.buffer[2])} ${sl(this.buffer[1])} ${sl(this.buffer[0])}`}static multiply(t,n){return new Ns(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Ns(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return Ns.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return Ns.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new Ns(n);for(let a=r?1:0;a<i;){const o=al<i-a?al:i-a,l=new Ns(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),u=new Ns(new Uint32Array([em[o],0,0,0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)Ns.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class T0 extends tn{constructor(t,n,r,i,s=mr.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof Xn?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return sn({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<mr.V5&&this.readNullBitmap(t,r),t.mode===jr.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class wL extends T0{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):$d(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return Bn(Uint8Array,Bn(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return Bn(Uint8Array,Bn(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return ae.isTimestamp(t)||(ae.isInt(t)||ae.isTime(t))&&t.bitWidth===64||ae.isDuration(t)||ae.isDate(t)&&t.unit===Ui.MILLISECOND?Bn(Uint8Array,yi.convertArray(r[n])):ae.isDecimal(t)?Bn(Uint8Array,Ns.convertArray(r[n])):ae.isBinary(t)||ae.isLargeBinary(t)||ae.isFixedSizeBinary(t)?SL(r[n]):ae.isBool(t)?$d(r[n]):ae.isUtf8(t)||ae.isLargeUtf8(t)?Op(r[n].join("")):Bn(Uint8Array,Bn(t.ArrayType,r[n].map(i=>+i)))}}function SL(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class ve extends tn{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function ei(e,t){return t instanceof e.constructor}function yo(e,t){return e===t||ei(e,t)}function ca(e,t){return e===t||ei(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function qd(e,t){return e===t||ei(e,t)&&e.precision===t.precision}function EL(e,t){return e===t||ei(e,t)&&e.byteWidth===t.byteWidth}function nm(e,t){return e===t||ei(e,t)&&e.unit===t.unit}function Ic(e,t){return e===t||ei(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Tc(e,t){return e===t||ei(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function IL(e,t){return e===t||ei(e,t)&&e.children.length===t.children.length&&La.compareManyFields(e.children,t.children)}function TL(e,t){return e===t||ei(e,t)&&e.children.length===t.children.length&&La.compareManyFields(e.children,t.children)}function rm(e,t){return e===t||ei(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&La.compareManyFields(e.children,t.children)}function AL(e,t){return e===t||ei(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&La.visit(e.indices,t.indices)&&La.visit(e.dictionary,t.dictionary)}function im(e,t){return e===t||ei(e,t)&&e.unit===t.unit}function Ac(e,t){return e===t||ei(e,t)&&e.unit===t.unit}function xL(e,t){return e===t||ei(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&La.compareManyFields(e.children,t.children)}function RL(e,t){return e===t||ei(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&La.compareManyFields(e.children,t.children)}ve.prototype.visitNull=yo,ve.prototype.visitBool=yo,ve.prototype.visitInt=ca,ve.prototype.visitInt8=ca,ve.prototype.visitInt16=ca,ve.prototype.visitInt32=ca,ve.prototype.visitInt64=ca,ve.prototype.visitUint8=ca,ve.prototype.visitUint16=ca,ve.prototype.visitUint32=ca,ve.prototype.visitUint64=ca,ve.prototype.visitFloat=qd,ve.prototype.visitFloat16=qd,ve.prototype.visitFloat32=qd,ve.prototype.visitFloat64=qd,ve.prototype.visitUtf8=yo,ve.prototype.visitLargeUtf8=yo,ve.prototype.visitBinary=yo,ve.prototype.visitLargeBinary=yo,ve.prototype.visitFixedSizeBinary=EL,ve.prototype.visitDate=nm,ve.prototype.visitDateDay=nm,ve.prototype.visitDateMillisecond=nm,ve.prototype.visitTimestamp=Ic,ve.prototype.visitTimestampSecond=Ic,ve.prototype.visitTimestampMillisecond=Ic,ve.prototype.visitTimestampMicrosecond=Ic,ve.prototype.visitTimestampNanosecond=Ic,ve.prototype.visitTime=Tc,ve.prototype.visitTimeSecond=Tc,ve.prototype.visitTimeMillisecond=Tc,ve.prototype.visitTimeMicrosecond=Tc,ve.prototype.visitTimeNanosecond=Tc,ve.prototype.visitDecimal=yo,ve.prototype.visitList=IL,ve.prototype.visitStruct=TL,ve.prototype.visitUnion=rm,ve.prototype.visitDenseUnion=rm,ve.prototype.visitSparseUnion=rm,ve.prototype.visitDictionary=AL,ve.prototype.visitInterval=im,ve.prototype.visitIntervalDayTime=im,ve.prototype.visitIntervalYearMonth=im,ve.prototype.visitDuration=Ac,ve.prototype.visitDurationSecond=Ac,ve.prototype.visitDurationMillisecond=Ac,ve.prototype.visitDurationMicrosecond=Ac,ve.prototype.visitDurationNanosecond=Ac,ve.prototype.visitFixedSizeList=xL,ve.prototype.visitMap=RL;const La=new ve;function sm(e,t){return La.compareSchemas(e,t)}function am(e,t){return NL(e,t.map(n=>n.data.concat()))}function NL(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((p,E)=>Math.max(p,E.length),0)};let s=0,a=0,o=-1;const l=t.length;let u,f=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)f[o]=u=t[o].shift(),a=Math.min(a,u?u.length:a);Number.isFinite(a)&&(f=BL(n,a,f,t,i),a>0&&(r[s++]=sn({type:new ti(n),length:a,nullCount:0,children:f.slice()})))}return[e=e.assign(n),r.map(p=>new gi(e,p))]}function BL(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const u=n[o],f=u==null?void 0:u.length;if(f>=t)f===t?n[o]=u:(n[o]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(u.slice(t,f-t))));else{const p=e[o];e[o]=p.clone({nullable:!0}),n[o]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:sn({type:p.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var A0;class ni{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new In([]),this._offsets=[0],this;let i,s;t[0]instanceof In&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof gi)return[l];if(l instanceof ni)return l.batches;if(l instanceof On){if(l.type instanceof ti)return[new gi(new In(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>a(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>a(u));if(typeof l=="object"){const u=Object.keys(l),f=u.map(T=>new En([l[T]])),p=i??new In(u.map((T,U)=>new Xn(String(T),f[U].type,f[U].nullable))),[,E]=am(p,f);return E.length===0?[new gi(l)]:E}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new In([]),!(i instanceof In))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof gi))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!sm(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??p0(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=h0(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Yp(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?Qp.visit(new En(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
95
+ `),pt=Function.apply(null,v.concat(Tt));return pt.apply(null,A)}return{global:ft,link:q,block:st,proc:_t,scope:W,cond:Z,compile:bt}}var Ul="xyzw".split(""),xI=5121,Pl=1,gg=2,_g=0,vg=1,bg=2,wg=3,Ih=4,NI=5,RI=6,BI="dither",OI="blend.enable",DI="blend.color",Sg="blend.equation",Eg="blend.func",FI="depth.enable",LI="depth.func",MI="depth.range",CI="depth.mask",Ig="colorMask",kI="cull.enable",UI="cull.face",Tg="frontFace",Ag="lineWidth",PI="polygonOffset.enable",xg="polygonOffset.offset",$I="sample.alpha",VI="sample.enable",Ng="sample.coverage",zI="stencil.enable",GI="stencil.mask",Rg="stencil.func",Bg="stencil.opFront",tu="stencil.opBack",jI="scissor.enable",Th="scissor.box",Ia="viewport",eu="profile",Oo="framebuffer",nu="vert",ru="frag",Do="elements",Fo="primitive",Lo="count",Ah="offset",xh="instances",iu="vao",Og="Width",Dg="Height",$l=Oo+Og,Vl=Oo+Dg,e6=Ia+Og,n6=Ia+Dg,YI="drawingBuffer",WI=YI+Og,HI=YI+Dg,r6=[Eg,Sg,Rg,Bg,tu,Ng,Ia,Th,xg],zl=34962,Fg=34963,i6=35632,s6=35633,qI=3553,a6=34067,o6=2884,l6=3042,c6=3024,u6=2960,d6=2929,f6=3089,h6=32823,p6=32926,m6=32928,Lg=5126,Nh=35664,Rh=35665,Bh=35666,Mg=5124,Oh=35667,Dh=35668,Fh=35669,Cg=35670,Lh=35671,Mh=35672,Ch=35673,su=35674,au=35675,ou=35676,lu=35678,cu=35680,kg=4,uu=1028,Mo=1029,XI=2304,Ug=2305,y6=32775,g6=32776,_6=519,Ka=7680,KI=0,QI=1,JI=32774,v6=513,ZI=36160,b6=36064,Ws={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},tT=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],Gl={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Qa={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},eT={frag:i6,vert:s6},Pg={cw:XI,ccw:Ug};function kh(f){return Array.isArray(f)||n(f)||_s(f)}function nT(f){return f.sort(function(v,A){return v===Ia?-1:A===Ia?1:v<A?-1:1})}function Rr(f,v,A,q){this.thisDep=f,this.contextDep=v,this.propDep=A,this.append=q}function Ja(f){return f&&!(f.thisDep||f.contextDep||f.propDep)}function br(f){return new Rr(!1,!1,!1,f)}function Ai(f,v){var A=f.type;if(A===_g){var q=f.data.length;return new Rr(!0,q>=1,q>=2,v)}else if(A===Ih){var st=f.data;return new Rr(st.thisDep,st.contextDep,st.propDep,v)}else{if(A===NI)return new Rr(!1,!1,!1,v);if(A===RI){for(var W=!1,Z=!1,ft=!1,dt=0;dt<f.data.length;++dt){var _t=f.data[dt];if(_t.type===vg)ft=!0;else if(_t.type===bg)Z=!0;else if(_t.type===wg)W=!0;else if(_t.type===_g){W=!0;var bt=_t.data;bt>=1&&(Z=!0),bt>=2&&(ft=!0)}else _t.type===Ih&&(W=W||_t.data.thisDep,Z=Z||_t.data.contextDep,ft=ft||_t.data.propDep)}return new Rr(W,Z,ft,v)}else return new Rr(A===wg,A===bg,A===vg,v)}}var rT=new Rr(!1,!1,!1,function(){});function w6(f,v,A,q,st,W,Z,ft,dt,_t,bt,vt,Tt,pt,gt){var $=_t.Record,Q={add:32774,subtract:32778,"reverse subtract":32779};A.ext_blend_minmax&&(Q.min=y6,Q.max=g6);var yt=A.angle_instanced_arrays,Pt=A.webgl_draw_buffers,ct=A.oes_vertex_array_object,Mt={dirty:!0,profile:gt.profile},Ot={},se=[],at={},it={};function Yt(w){return w.replace(".","_")}function At(w,g,N){var P=Yt(w);se.push(w),Ot[P]=Mt[P]=!!N,at[P]=g}function mt(w,g,N){var P=Yt(w);se.push(w),Array.isArray(N)?(Mt[P]=N.slice(),Ot[P]=N.slice()):Mt[P]=Ot[P]=N,it[P]=g}At(BI,c6),At(OI,l6),mt(DI,"blendColor",[0,0,0,0]),mt(Sg,"blendEquationSeparate",[JI,JI]),mt(Eg,"blendFuncSeparate",[QI,KI,QI,KI]),At(FI,d6,!0),mt(LI,"depthFunc",v6),mt(MI,"depthRange",[0,1]),mt(CI,"depthMask",!0),mt(Ig,Ig,[!0,!0,!0,!0]),At(kI,o6),mt(UI,"cullFace",Mo),mt(Tg,Tg,Ug),mt(Ag,Ag,1),At(PI,h6),mt(xg,"polygonOffset",[0,0]),At($I,p6),At(VI,m6),mt(Ng,"sampleCoverage",[1,!1]),At(zI,u6),mt(GI,"stencilMask",-1),mt(Rg,"stencilFunc",[_6,0,-1]),mt(Bg,"stencilOpSeparate",[uu,Ka,Ka,Ka]),mt(tu,"stencilOpSeparate",[Mo,Ka,Ka,Ka]),At(jI,f6),mt(Th,"scissor",[0,0,f.drawingBufferWidth,f.drawingBufferHeight]),mt(Ia,Ia,[0,0,f.drawingBufferWidth,f.drawingBufferHeight]);var Nt={gl:f,context:Tt,strings:v,next:Ot,current:Mt,draw:vt,elements:W,buffer:st,shader:bt,attributes:_t.state,vao:_t,uniforms:dt,framebuffer:ft,extensions:A,timer:pt,isBufferArgs:kh},Bt={primTypes:qa,compareFuncs:Gl,blendFuncs:Ws,blendEquations:Q,stencilOps:Qa,glTypes:Ao,orientationType:Pg};_.optional(function(){Nt.isArrayLike=pr}),Pt&&(Bt.backBuffer=[Mo],Bt.drawBuffer=Ke(q.maxDrawbuffers,function(w){return w===0?[0]:Ke(w,function(g){return b6+g})}));var _e=0;function de(){var w=t6(),g=w.link,N=w.global;w.id=_e++,w.batchId="0";var P=g(Nt),z=w.shared={props:"a0"};Object.keys(Nt).forEach(function(x){z[x]=N.def(P,".",x)}),_.optional(function(){w.CHECK=g(_),w.commandStr=_.guessCommand(),w.command=g(w.commandStr),w.assert=function(x,E,V){x("if(!(",E,"))",this.CHECK,".commandRaise(",g(V),",",this.command,");")},Bt.invalidBlendCombinations=tT});var O=w.next={},B=w.current={};Object.keys(it).forEach(function(x){Array.isArray(Mt[x])&&(O[x]=N.def(z.next,".",x),B[x]=N.def(z.current,".",x))});var k=w.constants={};Object.keys(Bt).forEach(function(x){k[x]=N.def(JSON.stringify(Bt[x]))}),w.invoke=function(x,E){switch(E.type){case _g:var V=["this",z.context,z.props,w.batchId];return x.def(g(E.data),".call(",V.slice(0,Math.max(E.data.length+1,4)),")");case vg:return x.def(z.props,E.data);case bg:return x.def(z.context,E.data);case wg:return x.def("this",E.data);case Ih:return E.data.append(w,x),E.data.ref;case NI:return E.data.toString();case RI:return E.data.map(function(G){return w.invoke(x,G)})}},w.attribCache={};var b={};return w.scopeAttrib=function(x){var E=v.id(x);if(E in b)return b[E];var V=_t.scope[E];V||(V=_t.scope[E]=new $);var G=b[E]=g(V);return G},w}function Dt(w){var g=w.static,N=w.dynamic,P;if(eu in g){var z=!!g[eu];P=br(function(B,k){return z}),P.enable=z}else if(eu in N){var O=N[eu];P=Ai(O,function(B,k){return B.invoke(k,O)})}return P}function Ut(w,g){var N=w.static,P=w.dynamic;if(Oo in N){var z=N[Oo];return z?(z=ft.getFramebuffer(z),_.command(z,"invalid framebuffer object"),br(function(B,k){var b=B.link(z),x=B.shared;k.set(x.framebuffer,".next",b);var E=x.context;return k.set(E,"."+$l,b+".width"),k.set(E,"."+Vl,b+".height"),b})):br(function(B,k){var b=B.shared;k.set(b.framebuffer,".next","null");var x=b.context;return k.set(x,"."+$l,x+"."+WI),k.set(x,"."+Vl,x+"."+HI),"null"})}else if(Oo in P){var O=P[Oo];return Ai(O,function(B,k){var b=B.invoke(k,O),x=B.shared,E=x.framebuffer,V=k.def(E,".getFramebuffer(",b,")");_.optional(function(){B.assert(k,"!"+b+"||"+V,"invalid framebuffer object")}),k.set(E,".next",V);var G=x.context;return k.set(G,"."+$l,V+"?"+V+".width:"+G+"."+WI),k.set(G,"."+Vl,V+"?"+V+".height:"+G+"."+HI),V})}else return null}function oe(w,g,N){var P=w.static,z=w.dynamic;function O(b){if(b in P){var x=P[b];_.commandType(x,"object","invalid "+b,N.commandStr);var E=!0,V=x.x|0,G=x.y|0,lt,Et;return"width"in x?(lt=x.width|0,_.command(lt>=0,"invalid "+b,N.commandStr)):E=!1,"height"in x?(Et=x.height|0,_.command(Et>=0,"invalid "+b,N.commandStr)):E=!1,new Rr(!E&&g&&g.thisDep,!E&&g&&g.contextDep,!E&&g&&g.propDep,function(St,Xt){var Vt=St.shared.context,Wt=lt;"width"in x||(Wt=Xt.def(Vt,".",$l,"-",V));var Ht=Et;return"height"in x||(Ht=Xt.def(Vt,".",Vl,"-",G)),[V,G,Wt,Ht]})}else if(b in z){var It=z[b],Ft=Ai(It,function(St,Xt){var Vt=St.invoke(Xt,It);_.optional(function(){St.assert(Xt,Vt+"&&typeof "+Vt+'==="object"',"invalid "+b)});var Wt=St.shared.context,Ht=Xt.def(Vt,".x|0"),Kt=Xt.def(Vt,".y|0"),le=Xt.def('"width" in ',Vt,"?",Vt,".width|0:","(",Wt,".",$l,"-",Ht,")"),Cn=Xt.def('"height" in ',Vt,"?",Vt,".height|0:","(",Wt,".",Vl,"-",Kt,")");return _.optional(function(){St.assert(Xt,le+">=0&&"+Cn+">=0","invalid "+b)}),[Ht,Kt,le,Cn]});return g&&(Ft.thisDep=Ft.thisDep||g.thisDep,Ft.contextDep=Ft.contextDep||g.contextDep,Ft.propDep=Ft.propDep||g.propDep),Ft}else return g?new Rr(g.thisDep,g.contextDep,g.propDep,function(St,Xt){var Vt=St.shared.context;return[0,0,Xt.def(Vt,".",$l),Xt.def(Vt,".",Vl)]}):null}var B=O(Ia);if(B){var k=B;B=new Rr(B.thisDep,B.contextDep,B.propDep,function(b,x){var E=k.append(b,x),V=b.shared.context;return x.set(V,"."+e6,E[2]),x.set(V,"."+n6,E[3]),E})}return{viewport:B,scissor_box:O(Th)}}function ye(w,g){var N=w.static,P=typeof N[ru]=="string"&&typeof N[nu]=="string";if(P){if(Object.keys(g.dynamic).length>0)return null;var z=g.static,O=Object.keys(z);if(O.length>0&&typeof z[O[0]]=="number"){for(var B=[],k=0;k<O.length;++k)_(typeof z[O[k]]=="number","must specify all vertex attribute locations when using vaos"),B.push([z[O[k]]|0,O[k]]);return B}}return null}function He(w,g,N){var P=w.static,z=w.dynamic;function O(E){if(E in P){var V=v.id(P[E]);_.optional(function(){bt.shader(eT[E],V,_.guessCommand())});var G=br(function(){return V});return G.id=V,G}else if(E in z){var lt=z[E];return Ai(lt,function(Et,It){var Ft=Et.invoke(It,lt),St=It.def(Et.shared.strings,".id(",Ft,")");return _.optional(function(){It(Et.shared.shader,".shader(",eT[E],",",St,",",Et.command,");")}),St})}return null}var B=O(ru),k=O(nu),b=null,x;return Ja(B)&&Ja(k)?(b=bt.program(k.id,B.id,null,N),x=br(function(E,V){return E.link(b)})):x=new Rr(B&&B.thisDep||k&&k.thisDep,B&&B.contextDep||k&&k.contextDep,B&&B.propDep||k&&k.propDep,function(E,V){var G=E.shared.shader,lt;B?lt=B.append(E,V):lt=V.def(G,".",ru);var Et;k?Et=k.append(E,V):Et=V.def(G,".",nu);var It=G+".program("+Et+","+lt;return _.optional(function(){It+=","+E.command}),V.def(It+")")}),{frag:B,vert:k,progVar:x,program:b}}function er(w,g){var N=w.static,P=w.dynamic,z={},O=!1;function B(){if(iu in N){var Xt=N[iu];return Xt!==null&&_t.getVAO(Xt)===null&&(Xt=_t.createVAO(Xt)),O=!0,z.vao=Xt,br(function(Wt){var Ht=_t.getVAO(Xt);return Ht?Wt.link(Ht):"null"})}else if(iu in P){O=!0;var Vt=P[iu];return Ai(Vt,function(Wt,Ht){var Kt=Wt.invoke(Ht,Vt);return Ht.def(Wt.shared.vao+".getVAO("+Kt+")")})}return null}var k=B(),b=!1;function x(){if(Do in N){var Xt=N[Do];if(z.elements=Xt,kh(Xt)){var Vt=z.elements=W.create(Xt,!0);Xt=W.getElements(Vt),b=!0}else Xt&&(Xt=W.getElements(Xt),b=!0,_.command(Xt,"invalid elements",g.commandStr));var Wt=br(function(Kt,le){if(Xt){var Cn=Kt.link(Xt);return Kt.ELEMENTS=Cn,Cn}return Kt.ELEMENTS=null,null});return Wt.value=Xt,Wt}else if(Do in P){b=!0;var Ht=P[Do];return Ai(Ht,function(Kt,le){var Cn=Kt.shared,Ur=Cn.isBufferArgs,Ta=Cn.elements,Aa=Kt.invoke(le,Ht),xa=le.def("null"),ni=le.def(Ur,"(",Aa,")"),qs=Kt.cond(ni).then(xa,"=",Ta,".createStream(",Aa,");").else(xa,"=",Ta,".getElements(",Aa,");");return _.optional(function(){Kt.assert(qs.else,"!"+Aa+"||"+xa,"invalid elements")}),le.entry(qs),le.exit(Kt.cond(ni).then(Ta,".destroyStream(",xa,");")),Kt.ELEMENTS=xa,xa})}else if(O)return new Rr(k.thisDep,k.contextDep,k.propDep,function(Kt,le){return le.def(Kt.shared.vao+".currentVAO?"+Kt.shared.elements+".getElements("+Kt.shared.vao+".currentVAO.elements):null")});return null}var E=x();function V(){if(Fo in N){var Xt=N[Fo];return z.primitive=Xt,_.commandParameter(Xt,qa,"invalid primitve",g.commandStr),br(function(Wt,Ht){return qa[Xt]})}else if(Fo in P){var Vt=P[Fo];return Ai(Vt,function(Wt,Ht){var Kt=Wt.constants.primTypes,le=Wt.invoke(Ht,Vt);return _.optional(function(){Wt.assert(Ht,le+" in "+Kt,"invalid primitive, must be one of "+Object.keys(qa))}),Ht.def(Kt,"[",le,"]")})}else{if(b)return Ja(E)?E.value?br(function(Wt,Ht){return Ht.def(Wt.ELEMENTS,".primType")}):br(function(){return kg}):new Rr(E.thisDep,E.contextDep,E.propDep,function(Wt,Ht){var Kt=Wt.ELEMENTS;return Ht.def(Kt,"?",Kt,".primType:",kg)});if(O)return new Rr(k.thisDep,k.contextDep,k.propDep,function(Wt,Ht){return Ht.def(Wt.shared.vao+".currentVAO?"+Wt.shared.vao+".currentVAO.primitive:"+kg)})}return null}function G(Xt,Vt){if(Xt in N){var Wt=N[Xt]|0;return Vt?z.offset=Wt:z.instances=Wt,_.command(!Vt||Wt>=0,"invalid "+Xt,g.commandStr),br(function(Kt,le){return Vt&&(Kt.OFFSET=Wt),Wt})}else if(Xt in P){var Ht=P[Xt];return Ai(Ht,function(Kt,le){var Cn=Kt.invoke(le,Ht);return Vt&&(Kt.OFFSET=Cn,_.optional(function(){Kt.assert(le,Cn+">=0","invalid "+Xt)})),Cn})}else if(Vt){if(b)return br(function(Kt,le){return Kt.OFFSET=0,0});if(O)return new Rr(k.thisDep,k.contextDep,k.propDep,function(Kt,le){return le.def(Kt.shared.vao+".currentVAO?"+Kt.shared.vao+".currentVAO.offset:0")})}else if(O)return new Rr(k.thisDep,k.contextDep,k.propDep,function(Kt,le){return le.def(Kt.shared.vao+".currentVAO?"+Kt.shared.vao+".currentVAO.instances:-1")});return null}var lt=G(Ah,!0);function Et(){if(Lo in N){var Xt=N[Lo]|0;return z.count=Xt,_.command(typeof Xt=="number"&&Xt>=0,"invalid vertex count",g.commandStr),br(function(){return Xt})}else if(Lo in P){var Vt=P[Lo];return Ai(Vt,function(le,Cn){var Ur=le.invoke(Cn,Vt);return _.optional(function(){le.assert(Cn,"typeof "+Ur+'==="number"&&'+Ur+">=0&&"+Ur+"===("+Ur+"|0)","invalid vertex count")}),Ur})}else if(b)if(Ja(E)){if(E)return lt?new Rr(lt.thisDep,lt.contextDep,lt.propDep,function(le,Cn){var Ur=Cn.def(le.ELEMENTS,".vertCount-",le.OFFSET);return _.optional(function(){le.assert(Cn,Ur+">=0","invalid vertex offset/element buffer too small")}),Ur}):br(function(le,Cn){return Cn.def(le.ELEMENTS,".vertCount")});var Wt=br(function(){return-1});return _.optional(function(){Wt.MISSING=!0}),Wt}else{var Ht=new Rr(E.thisDep||lt.thisDep,E.contextDep||lt.contextDep,E.propDep||lt.propDep,function(le,Cn){var Ur=le.ELEMENTS;return le.OFFSET?Cn.def(Ur,"?",Ur,".vertCount-",le.OFFSET,":-1"):Cn.def(Ur,"?",Ur,".vertCount:-1")});return _.optional(function(){Ht.DYNAMIC=!0}),Ht}else if(O){var Kt=new Rr(k.thisDep,k.contextDep,k.propDep,function(le,Cn){return Cn.def(le.shared.vao,".currentVAO?",le.shared.vao,".currentVAO.count:-1")});return Kt}return null}var It=V(),Ft=Et(),St=G(xh,!1);return{elements:E,primitive:It,count:Ft,instances:St,offset:lt,vao:k,vaoActive:O,elementsActive:b,static:z}}function ar(w,g){var N=w.static,P=w.dynamic,z={};return se.forEach(function(O){var B=Yt(O);function k(b,x){if(O in N){var E=b(N[O]);z[B]=br(function(){return E})}else if(O in P){var V=P[O];z[B]=Ai(V,function(G,lt){return x(G,lt,G.invoke(lt,V))})}}switch(O){case kI:case OI:case BI:case zI:case FI:case jI:case PI:case $I:case VI:case CI:return k(function(b){return _.commandType(b,"boolean",O,g.commandStr),b},function(b,x,E){return _.optional(function(){b.assert(x,"typeof "+E+'==="boolean"',"invalid flag "+O,b.commandStr)}),E});case LI:return k(function(b){return _.commandParameter(b,Gl,"invalid "+O,g.commandStr),Gl[b]},function(b,x,E){var V=b.constants.compareFuncs;return _.optional(function(){b.assert(x,E+" in "+V,"invalid "+O+", must be one of "+Object.keys(Gl))}),x.def(V,"[",E,"]")});case MI:return k(function(b){return _.command(pr(b)&&b.length===2&&typeof b[0]=="number"&&typeof b[1]=="number"&&b[0]<=b[1],"depth range is 2d array",g.commandStr),b},function(b,x,E){_.optional(function(){b.assert(x,b.shared.isArrayLike+"("+E+")&&"+E+".length===2&&typeof "+E+'[0]==="number"&&typeof '+E+'[1]==="number"&&'+E+"[0]<="+E+"[1]","depth range must be a 2d array")});var V=x.def("+",E,"[0]"),G=x.def("+",E,"[1]");return[V,G]});case Eg:return k(function(b){_.commandType(b,"object","blend.func",g.commandStr);var x="srcRGB"in b?b.srcRGB:b.src,E="srcAlpha"in b?b.srcAlpha:b.src,V="dstRGB"in b?b.dstRGB:b.dst,G="dstAlpha"in b?b.dstAlpha:b.dst;return _.commandParameter(x,Ws,B+".srcRGB",g.commandStr),_.commandParameter(E,Ws,B+".srcAlpha",g.commandStr),_.commandParameter(V,Ws,B+".dstRGB",g.commandStr),_.commandParameter(G,Ws,B+".dstAlpha",g.commandStr),_.command(tT.indexOf(x+", "+V)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+x+", "+V+")",g.commandStr),[Ws[x],Ws[V],Ws[E],Ws[G]]},function(b,x,E){var V=b.constants.blendFuncs;_.optional(function(){b.assert(x,E+"&&typeof "+E+'==="object"',"invalid blend func, must be an object")});function G(Vt,Wt){var Ht=x.def('"',Vt,Wt,'" in ',E,"?",E,".",Vt,Wt,":",E,".",Vt);return _.optional(function(){b.assert(x,Ht+" in "+V,"invalid "+O+"."+Vt+Wt+", must be one of "+Object.keys(Ws))}),Ht}var lt=G("src","RGB"),Et=G("dst","RGB");_.optional(function(){var Vt=b.constants.invalidBlendCombinations;b.assert(x,Vt+".indexOf("+lt+'+", "+'+Et+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var It=x.def(V,"[",lt,"]"),Ft=x.def(V,"[",G("src","Alpha"),"]"),St=x.def(V,"[",Et,"]"),Xt=x.def(V,"[",G("dst","Alpha"),"]");return[It,St,Ft,Xt]});case Sg:return k(function(b){if(typeof b=="string")return _.commandParameter(b,Q,"invalid "+O,g.commandStr),[Q[b],Q[b]];if(typeof b=="object")return _.commandParameter(b.rgb,Q,O+".rgb",g.commandStr),_.commandParameter(b.alpha,Q,O+".alpha",g.commandStr),[Q[b.rgb],Q[b.alpha]];_.commandRaise("invalid blend.equation",g.commandStr)},function(b,x,E){var V=b.constants.blendEquations,G=x.def(),lt=x.def(),Et=b.cond("typeof ",E,'==="string"');return _.optional(function(){function It(Ft,St,Xt){b.assert(Ft,Xt+" in "+V,"invalid "+St+", must be one of "+Object.keys(Q))}It(Et.then,O,E),b.assert(Et.else,E+"&&typeof "+E+'==="object"',"invalid "+O),It(Et.else,O+".rgb",E+".rgb"),It(Et.else,O+".alpha",E+".alpha")}),Et.then(G,"=",lt,"=",V,"[",E,"];"),Et.else(G,"=",V,"[",E,".rgb];",lt,"=",V,"[",E,".alpha];"),x(Et),[G,lt]});case DI:return k(function(b){return _.command(pr(b)&&b.length===4,"blend.color must be a 4d array",g.commandStr),Ke(4,function(x){return+b[x]})},function(b,x,E){return _.optional(function(){b.assert(x,b.shared.isArrayLike+"("+E+")&&"+E+".length===4","blend.color must be a 4d array")}),Ke(4,function(V){return x.def("+",E,"[",V,"]")})});case GI:return k(function(b){return _.commandType(b,"number",B,g.commandStr),b|0},function(b,x,E){return _.optional(function(){b.assert(x,"typeof "+E+'==="number"',"invalid stencil.mask")}),x.def(E,"|0")});case Rg:return k(function(b){_.commandType(b,"object",B,g.commandStr);var x=b.cmp||"keep",E=b.ref||0,V="mask"in b?b.mask:-1;return _.commandParameter(x,Gl,O+".cmp",g.commandStr),_.commandType(E,"number",O+".ref",g.commandStr),_.commandType(V,"number",O+".mask",g.commandStr),[Gl[x],E,V]},function(b,x,E){var V=b.constants.compareFuncs;_.optional(function(){function It(){b.assert(x,Array.prototype.join.call(arguments,""),"invalid stencil.func")}It(E+"&&typeof ",E,'==="object"'),It('!("cmp" in ',E,")||(",E,".cmp in ",V,")")});var G=x.def('"cmp" in ',E,"?",V,"[",E,".cmp]",":",Ka),lt=x.def(E,".ref|0"),Et=x.def('"mask" in ',E,"?",E,".mask|0:-1");return[G,lt,Et]});case Bg:case tu:return k(function(b){_.commandType(b,"object",B,g.commandStr);var x=b.fail||"keep",E=b.zfail||"keep",V=b.zpass||"keep";return _.commandParameter(x,Qa,O+".fail",g.commandStr),_.commandParameter(E,Qa,O+".zfail",g.commandStr),_.commandParameter(V,Qa,O+".zpass",g.commandStr),[O===tu?Mo:uu,Qa[x],Qa[E],Qa[V]]},function(b,x,E){var V=b.constants.stencilOps;_.optional(function(){b.assert(x,E+"&&typeof "+E+'==="object"',"invalid "+O)});function G(lt){return _.optional(function(){b.assert(x,'!("'+lt+'" in '+E+")||("+E+"."+lt+" in "+V+")","invalid "+O+"."+lt+", must be one of "+Object.keys(Qa))}),x.def('"',lt,'" in ',E,"?",V,"[",E,".",lt,"]:",Ka)}return[O===tu?Mo:uu,G("fail"),G("zfail"),G("zpass")]});case xg:return k(function(b){_.commandType(b,"object",B,g.commandStr);var x=b.factor|0,E=b.units|0;return _.commandType(x,"number",B+".factor",g.commandStr),_.commandType(E,"number",B+".units",g.commandStr),[x,E]},function(b,x,E){_.optional(function(){b.assert(x,E+"&&typeof "+E+'==="object"',"invalid "+O)});var V=x.def(E,".factor|0"),G=x.def(E,".units|0");return[V,G]});case UI:return k(function(b){var x=0;return b==="front"?x=uu:b==="back"&&(x=Mo),_.command(!!x,B,g.commandStr),x},function(b,x,E){return _.optional(function(){b.assert(x,E+'==="front"||'+E+'==="back"',"invalid cull.face")}),x.def(E,'==="front"?',uu,":",Mo)});case Ag:return k(function(b){return _.command(typeof b=="number"&&b>=q.lineWidthDims[0]&&b<=q.lineWidthDims[1],"invalid line width, must be a positive number between "+q.lineWidthDims[0]+" and "+q.lineWidthDims[1],g.commandStr),b},function(b,x,E){return _.optional(function(){b.assert(x,"typeof "+E+'==="number"&&'+E+">="+q.lineWidthDims[0]+"&&"+E+"<="+q.lineWidthDims[1],"invalid line width")}),E});case Tg:return k(function(b){return _.commandParameter(b,Pg,B,g.commandStr),Pg[b]},function(b,x,E){return _.optional(function(){b.assert(x,E+'==="cw"||'+E+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),x.def(E+'==="cw"?'+XI+":"+Ug)});case Ig:return k(function(b){return _.command(pr(b)&&b.length===4,"color.mask must be length 4 array",g.commandStr),b.map(function(x){return!!x})},function(b,x,E){return _.optional(function(){b.assert(x,b.shared.isArrayLike+"("+E+")&&"+E+".length===4","invalid color.mask")}),Ke(4,function(V){return"!!"+E+"["+V+"]"})});case Ng:return k(function(b){_.command(typeof b=="object"&&b,B,g.commandStr);var x="value"in b?b.value:1,E=!!b.invert;return _.command(typeof x=="number"&&x>=0&&x<=1,"sample.coverage.value must be a number between 0 and 1",g.commandStr),[x,E]},function(b,x,E){_.optional(function(){b.assert(x,E+"&&typeof "+E+'==="object"',"invalid sample.coverage")});var V=x.def('"value" in ',E,"?+",E,".value:1"),G=x.def("!!",E,".invert");return[V,G]})}}),z}function Xe(w,g){var N=w.static,P=w.dynamic,z={};return Object.keys(N).forEach(function(O){var B=N[O],k;if(typeof B=="number"||typeof B=="boolean")k=br(function(){return B});else if(typeof B=="function"){var b=B._reglType;b==="texture2d"||b==="textureCube"?k=br(function(x){return x.link(B)}):b==="framebuffer"||b==="framebufferCube"?(_.command(B.color.length>0,'missing color attachment for framebuffer sent to uniform "'+O+'"',g.commandStr),k=br(function(x){return x.link(B.color[0])})):_.commandRaise('invalid data for uniform "'+O+'"',g.commandStr)}else pr(B)?k=br(function(x){var E=x.global.def("[",Ke(B.length,function(V){return _.command(typeof B[V]=="number"||typeof B[V]=="boolean","invalid uniform "+O,x.commandStr),B[V]}),"]");return E}):_.commandRaise('invalid or missing data for uniform "'+O+'"',g.commandStr);k.value=B,z[O]=k}),Object.keys(P).forEach(function(O){var B=P[O];z[O]=Ai(B,function(k,b){return k.invoke(b,B)})}),z}function Ar(w,g){var N=w.static,P=w.dynamic,z={};return Object.keys(N).forEach(function(O){var B=N[O],k=v.id(O),b=new $;if(kh(B))b.state=Pl,b.buffer=st.getBuffer(st.create(B,zl,!1,!0)),b.type=0;else{var x=st.getBuffer(B);if(x)b.state=Pl,b.buffer=x,b.type=0;else if(_.command(typeof B=="object"&&B,"invalid data for attribute "+O,g.commandStr),"constant"in B){var E=B.constant;b.buffer="null",b.state=gg,typeof E=="number"?b.x=E:(_.command(pr(E)&&E.length>0&&E.length<=4,"invalid constant for attribute "+O,g.commandStr),Ul.forEach(function(St,Xt){Xt<E.length&&(b[St]=E[Xt])}))}else{kh(B.buffer)?x=st.getBuffer(st.create(B.buffer,zl,!1,!0)):x=st.getBuffer(B.buffer),_.command(!!x,'missing buffer for attribute "'+O+'"',g.commandStr);var V=B.offset|0;_.command(V>=0,'invalid offset for attribute "'+O+'"',g.commandStr);var G=B.stride|0;_.command(G>=0&&G<256,'invalid stride for attribute "'+O+'", must be integer betweeen [0, 255]',g.commandStr);var lt=B.size|0;_.command(!("size"in B)||lt>0&&lt<=4,'invalid size for attribute "'+O+'", must be 1,2,3,4',g.commandStr);var Et=!!B.normalized,It=0;"type"in B&&(_.commandParameter(B.type,Ao,"invalid type for attribute "+O,g.commandStr),It=Ao[B.type]);var Ft=B.divisor|0;_.optional(function(){"divisor"in B&&(_.command(Ft===0||yt,'cannot specify divisor for attribute "'+O+'", instancing not supported',g.commandStr),_.command(Ft>=0,'invalid divisor for attribute "'+O+'"',g.commandStr));var St=g.commandStr,Xt=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(B).forEach(function(Vt){_.command(Xt.indexOf(Vt)>=0,'unknown parameter "'+Vt+'" for attribute pointer "'+O+'" (valid parameters are '+Xt+")",St)})}),b.buffer=x,b.state=Pl,b.size=lt,b.normalized=Et,b.type=It||x.dtype,b.offset=V,b.stride=G,b.divisor=Ft}}z[O]=br(function(St,Xt){var Vt=St.attribCache;if(k in Vt)return Vt[k];var Wt={isStream:!1};return Object.keys(b).forEach(function(Ht){Wt[Ht]=b[Ht]}),b.buffer&&(Wt.buffer=St.link(b.buffer),Wt.type=Wt.type||Wt.buffer+".dtype"),Vt[k]=Wt,Wt})}),Object.keys(P).forEach(function(O){var B=P[O];function k(b,x){var E=b.invoke(x,B),V=b.shared,G=b.constants,lt=V.isBufferArgs,Et=V.buffer;_.optional(function(){b.assert(x,E+"&&(typeof "+E+'==="object"||typeof '+E+'==="function")&&('+lt+"("+E+")||"+Et+".getBuffer("+E+")||"+Et+".getBuffer("+E+".buffer)||"+lt+"("+E+'.buffer)||("constant" in '+E+"&&(typeof "+E+'.constant==="number"||'+V.isArrayLike+"("+E+".constant))))",'invalid dynamic attribute "'+O+'"')});var It={isStream:x.def(!1)},Ft=new $;Ft.state=Pl,Object.keys(Ft).forEach(function(Wt){It[Wt]=x.def(""+Ft[Wt])});var St=It.buffer,Xt=It.type;x("if(",lt,"(",E,")){",It.isStream,"=true;",St,"=",Et,".createStream(",zl,",",E,");",Xt,"=",St,".dtype;","}else{",St,"=",Et,".getBuffer(",E,");","if(",St,"){",Xt,"=",St,".dtype;",'}else if("constant" in ',E,"){",It.state,"=",gg,";","if(typeof "+E+'.constant === "number"){',It[Ul[0]],"=",E,".constant;",Ul.slice(1).map(function(Wt){return It[Wt]}).join("="),"=0;","}else{",Ul.map(function(Wt,Ht){return It[Wt]+"="+E+".constant.length>"+Ht+"?"+E+".constant["+Ht+"]:0;"}).join(""),"}}else{","if(",lt,"(",E,".buffer)){",St,"=",Et,".createStream(",zl,",",E,".buffer);","}else{",St,"=",Et,".getBuffer(",E,".buffer);","}",Xt,'="type" in ',E,"?",G.glTypes,"[",E,".type]:",St,".dtype;",It.normalized,"=!!",E,".normalized;");function Vt(Wt){x(It[Wt],"=",E,".",Wt,"|0;")}return Vt("size"),Vt("offset"),Vt("stride"),Vt("divisor"),x("}}"),x.exit("if(",It.isStream,"){",Et,".destroyStream(",St,");","}"),It}z[O]=Ai(B,k)}),z}function Wn(w){var g=w.static,N=w.dynamic,P={};return Object.keys(g).forEach(function(z){var O=g[z];P[z]=br(function(B,k){return typeof O=="number"||typeof O=="boolean"?""+O:B.link(O)})}),Object.keys(N).forEach(function(z){var O=N[z];P[z]=Ai(O,function(B,k){return B.invoke(k,O)})}),P}function wr(w,g,N,P,z){var O=w.static,B=w.dynamic;_.optional(function(){var Vt=[Oo,nu,ru,Do,Fo,Ah,Lo,xh,eu,iu].concat(se);function Wt(Ht){Object.keys(Ht).forEach(function(Kt){_.command(Vt.indexOf(Kt)>=0,'unknown parameter "'+Kt+'"',z.commandStr)})}Wt(O),Wt(B)});var k=ye(w,g),b=Ut(w),x=oe(w,b,z),E=er(w,z),V=ar(w,z),G=He(w,z,k);function lt(Vt){var Wt=x[Vt];Wt&&(V[Vt]=Wt)}lt(Ia),lt(Yt(Th));var Et=Object.keys(V).length>0,It={framebuffer:b,draw:E,shader:G,state:V,dirty:Et,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(It.profile=Dt(w),It.uniforms=Xe(N,z),It.drawVAO=It.scopeVAO=E.vao,!It.drawVAO&&G.program&&!k&&A.angle_instanced_arrays&&E.static.elements){var Ft=!0,St=G.program.attributes.map(function(Vt){var Wt=g.static[Vt];return Ft=Ft&&!!Wt,Wt});if(Ft&&St.length>0){var Xt=_t.getVAO(_t.createVAO({attributes:St,elements:E.static.elements}));It.drawVAO=new Rr(null,null,null,function(Vt,Wt){return Vt.link(Xt)}),It.useVAO=!0}}return k?It.useVAO=!0:It.attributes=Ar(g,z),It.context=Wn(P),It}function xr(w,g,N){var P=w.shared,z=P.context,O=w.scope();Object.keys(N).forEach(function(B){g.save(z,"."+B);var k=N[B],b=k.append(w,g);Array.isArray(b)?O(z,".",B,"=[",b.join(),"];"):O(z,".",B,"=",b,";")}),g(O)}function Nr(w,g,N,P){var z=w.shared,O=z.gl,B=z.framebuffer,k;Pt&&(k=g.def(z.extensions,".webgl_draw_buffers"));var b=w.constants,x=b.drawBuffer,E=b.backBuffer,V;N?V=N.append(w,g):V=g.def(B,".next"),P||g("if(",V,"!==",B,".cur){"),g("if(",V,"){",O,".bindFramebuffer(",ZI,",",V,".framebuffer);"),Pt&&g(k,".drawBuffersWEBGL(",x,"[",V,".colorAttachments.length]);"),g("}else{",O,".bindFramebuffer(",ZI,",null);"),Pt&&g(k,".drawBuffersWEBGL(",E,");"),g("}",B,".cur=",V,";"),P||g("}")}function kr(w,g,N){var P=w.shared,z=P.gl,O=w.current,B=w.next,k=P.current,b=P.next,x=w.cond(k,".dirty");se.forEach(function(E){var V=Yt(E);if(!(V in N.state)){var G,lt;if(V in B){G=B[V],lt=O[V];var Et=Ke(Mt[V].length,function(Ft){return x.def(G,"[",Ft,"]")});x(w.cond(Et.map(function(Ft,St){return Ft+"!=="+lt+"["+St+"]"}).join("||")).then(z,".",it[V],"(",Et,");",Et.map(function(Ft,St){return lt+"["+St+"]="+Ft}).join(";"),";"))}else{G=x.def(b,".",V);var It=w.cond(G,"!==",k,".",V);x(It),V in at?It(w.cond(G).then(z,".enable(",at[V],");").else(z,".disable(",at[V],");"),k,".",V,"=",G,";"):It(z,".",it[V],"(",G,");",k,".",V,"=",G,";")}}}),Object.keys(N.state).length===0&&x(k,".dirty=false;"),g(x)}function jr(w,g,N,P){var z=w.shared,O=w.current,B=z.current,k=z.gl;nT(Object.keys(N)).forEach(function(b){var x=N[b];if(!(P&&!P(x))){var E=x.append(w,g);if(at[b]){var V=at[b];Ja(x)?E?g(k,".enable(",V,");"):g(k,".disable(",V,");"):g(w.cond(E).then(k,".enable(",V,");").else(k,".disable(",V,");")),g(B,".",b,"=",E,";")}else if(pr(E)){var G=O[b];g(k,".",it[b],"(",E,");",E.map(function(lt,Et){return G+"["+Et+"]="+lt}).join(";"),";")}else g(k,".",it[b],"(",E,");",B,".",b,"=",E,";")}})}function mr(w,g){yt&&(w.instancing=g.def(w.shared.extensions,".angle_instanced_arrays"))}function ke(w,g,N,P,z){var O=w.shared,B=w.stats,k=O.current,b=O.timer,x=N.profile;function E(){return typeof performance>"u"?"Date.now()":"performance.now()"}var V,G;function lt(Vt){V=g.def(),Vt(V,"=",E(),";"),typeof z=="string"?Vt(B,".count+=",z,";"):Vt(B,".count++;"),pt&&(P?(G=g.def(),Vt(G,"=",b,".getNumPendingQueries();")):Vt(b,".beginQuery(",B,");"))}function Et(Vt){Vt(B,".cpuTime+=",E(),"-",V,";"),pt&&(P?Vt(b,".pushScopeStats(",G,",",b,".getNumPendingQueries(),",B,");"):Vt(b,".endQuery();"))}function It(Vt){var Wt=g.def(k,".profile");g(k,".profile=",Vt,";"),g.exit(k,".profile=",Wt,";")}var Ft;if(x){if(Ja(x)){x.enable?(lt(g),Et(g.exit),It("true")):It("false");return}Ft=x.append(w,g),It(Ft)}else Ft=g.def(k,".profile");var St=w.block();lt(St),g("if(",Ft,"){",St,"}");var Xt=w.block();Et(Xt),g.exit("if(",Ft,"){",Xt,"}")}function Yr(w,g,N,P,z){var O=w.shared;function B(b){switch(b){case Nh:case Oh:case Lh:return 2;case Rh:case Dh:case Mh:return 3;case Bh:case Fh:case Ch:return 4;default:return 1}}function k(b,x,E){var V=O.gl,G=g.def(b,".location"),lt=g.def(O.attributes,"[",G,"]"),Et=E.state,It=E.buffer,Ft=[E.x,E.y,E.z,E.w],St=["buffer","normalized","offset","stride"];function Xt(){g("if(!",lt,".buffer){",V,".enableVertexAttribArray(",G,");}");var Wt=E.type,Ht;if(E.size?Ht=g.def(E.size,"||",x):Ht=x,g("if(",lt,".type!==",Wt,"||",lt,".size!==",Ht,"||",St.map(function(le){return lt+"."+le+"!=="+E[le]}).join("||"),"){",V,".bindBuffer(",zl,",",It,".buffer);",V,".vertexAttribPointer(",[G,Ht,Wt,E.normalized,E.stride,E.offset],");",lt,".type=",Wt,";",lt,".size=",Ht,";",St.map(function(le){return lt+"."+le+"="+E[le]+";"}).join(""),"}"),yt){var Kt=E.divisor;g("if(",lt,".divisor!==",Kt,"){",w.instancing,".vertexAttribDivisorANGLE(",[G,Kt],");",lt,".divisor=",Kt,";}")}}function Vt(){g("if(",lt,".buffer){",V,".disableVertexAttribArray(",G,");",lt,".buffer=null;","}if(",Ul.map(function(Wt,Ht){return lt+"."+Wt+"!=="+Ft[Ht]}).join("||"),"){",V,".vertexAttrib4f(",G,",",Ft,");",Ul.map(function(Wt,Ht){return lt+"."+Wt+"="+Ft[Ht]+";"}).join(""),"}")}Et===Pl?Xt():Et===gg?Vt():(g("if(",Et,"===",Pl,"){"),Xt(),g("}else{"),Vt(),g("}"))}P.forEach(function(b){var x=b.name,E=N.attributes[x],V;if(E){if(!z(E))return;V=E.append(w,g)}else{if(!z(rT))return;var G=w.scopeAttrib(x);_.optional(function(){w.assert(g,G+".state","missing attribute "+x)}),V={},Object.keys(new $).forEach(function(lt){V[lt]=g.def(G,".",lt)})}k(w.link(b),B(b.info.type),V)})}function cn(w,g,N,P,z,O){for(var B=w.shared,k=B.gl,b,x=0;x<P.length;++x){var E=P[x],V=E.name,G=E.info.type,lt=N.uniforms[V],Et=w.link(E),It=Et+".location",Ft;if(lt){if(!z(lt))continue;if(Ja(lt)){var St=lt.value;if(_.command(St!==null&&typeof St<"u",'missing uniform "'+V+'"',w.commandStr),G===lu||G===cu){_.command(typeof St=="function"&&(G===lu&&(St._reglType==="texture2d"||St._reglType==="framebuffer")||G===cu&&(St._reglType==="textureCube"||St._reglType==="framebufferCube")),"invalid texture for uniform "+V,w.commandStr);var Xt=w.link(St._texture||St.color[0]._texture);g(k,".uniform1i(",It,",",Xt+".bind());"),g.exit(Xt,".unbind();")}else if(G===su||G===au||G===ou){_.optional(function(){_.command(pr(St),"invalid matrix for uniform "+V,w.commandStr),_.command(G===su&&St.length===4||G===au&&St.length===9||G===ou&&St.length===16,"invalid length for matrix uniform "+V,w.commandStr)});var Vt=w.global.def("new Float32Array(["+Array.prototype.slice.call(St)+"])"),Wt=2;G===au?Wt=3:G===ou&&(Wt=4),g(k,".uniformMatrix",Wt,"fv(",It,",false,",Vt,");")}else{switch(G){case Lg:_.commandType(St,"number","uniform "+V,w.commandStr),b="1f";break;case Nh:_.command(pr(St)&&St.length===2,"uniform "+V,w.commandStr),b="2f";break;case Rh:_.command(pr(St)&&St.length===3,"uniform "+V,w.commandStr),b="3f";break;case Bh:_.command(pr(St)&&St.length===4,"uniform "+V,w.commandStr),b="4f";break;case Cg:_.commandType(St,"boolean","uniform "+V,w.commandStr),b="1i";break;case Mg:_.commandType(St,"number","uniform "+V,w.commandStr),b="1i";break;case Lh:_.command(pr(St)&&St.length===2,"uniform "+V,w.commandStr),b="2i";break;case Oh:_.command(pr(St)&&St.length===2,"uniform "+V,w.commandStr),b="2i";break;case Mh:_.command(pr(St)&&St.length===3,"uniform "+V,w.commandStr),b="3i";break;case Dh:_.command(pr(St)&&St.length===3,"uniform "+V,w.commandStr),b="3i";break;case Ch:_.command(pr(St)&&St.length===4,"uniform "+V,w.commandStr),b="4i";break;case Fh:_.command(pr(St)&&St.length===4,"uniform "+V,w.commandStr),b="4i";break}g(k,".uniform",b,"(",It,",",pr(St)?Array.prototype.slice.call(St):St,");")}continue}else Ft=lt.append(w,g)}else{if(!z(rT))continue;Ft=g.def(B.uniforms,"[",v.id(V),"]")}G===lu?(_(!Array.isArray(Ft),"must specify a scalar prop for textures"),g("if(",Ft,"&&",Ft,'._reglType==="framebuffer"){',Ft,"=",Ft,".color[0];","}")):G===cu&&(_(!Array.isArray(Ft),"must specify a scalar prop for cube maps"),g("if(",Ft,"&&",Ft,'._reglType==="framebufferCube"){',Ft,"=",Ft,".color[0];","}")),_.optional(function(){function ni(bs,uT){w.assert(g,bs,'bad data or missing for uniform "'+V+'". '+uT)}function qs(bs){_(!Array.isArray(Ft),"must not specify an array type for uniform"),ni("typeof "+Ft+'==="'+bs+'"',"invalid type, expected "+bs)}function ns(bs,uT){Array.isArray(Ft)?_(Ft.length===bs,"must have length "+bs):ni(B.isArrayLike+"("+Ft+")&&"+Ft+".length==="+bs,"invalid vector, should have length "+bs,w.commandStr)}function cT(bs){_(!Array.isArray(Ft),"must not specify a value type"),ni("typeof "+Ft+'==="function"&&'+Ft+'._reglType==="texture'+(bs===qI?"2d":"Cube")+'"',"invalid texture type",w.commandStr)}switch(G){case Mg:qs("number");break;case Oh:ns(2);break;case Dh:ns(3);break;case Fh:ns(4);break;case Lg:qs("number");break;case Nh:ns(2);break;case Rh:ns(3);break;case Bh:ns(4);break;case Cg:qs("boolean");break;case Lh:ns(2);break;case Mh:ns(3);break;case Ch:ns(4);break;case su:ns(4);break;case au:ns(9);break;case ou:ns(16);break;case lu:cT(qI);break;case cu:cT(a6);break}});var Ht=1;switch(G){case lu:case cu:var Kt=g.def(Ft,"._texture");g(k,".uniform1i(",It,",",Kt,".bind());"),g.exit(Kt,".unbind();");continue;case Mg:case Cg:b="1i";break;case Oh:case Lh:b="2i",Ht=2;break;case Dh:case Mh:b="3i",Ht=3;break;case Fh:case Ch:b="4i",Ht=4;break;case Lg:b="1f";break;case Nh:b="2f",Ht=2;break;case Rh:b="3f",Ht=3;break;case Bh:b="4f",Ht=4;break;case su:b="Matrix2fv";break;case au:b="Matrix3fv";break;case ou:b="Matrix4fv";break}if(b.charAt(0)==="M"){g(k,".uniform",b,"(",It,",");var le=Math.pow(G-su+2,2),Cn=w.global.def("new Float32Array(",le,")");Array.isArray(Ft)?g("false,(",Ke(le,function(ni){return Cn+"["+ni+"]="+Ft[ni]}),",",Cn,")"):g("false,(Array.isArray(",Ft,")||",Ft," instanceof Float32Array)?",Ft,":(",Ke(le,function(ni){return Cn+"["+ni+"]="+Ft+"["+ni+"]"}),",",Cn,")"),g(");")}else if(Ht>1){for(var Ur=[],Ta=[],Aa=0;Aa<Ht;++Aa)Array.isArray(Ft)?Ta.push(Ft[Aa]):Ta.push(g.def(Ft+"["+Aa+"]")),O&&Ur.push(g.def());O&&g("if(!",w.batchId,"||",Ur.map(function(ni,qs){return ni+"!=="+Ta[qs]}).join("||"),"){",Ur.map(function(ni,qs){return ni+"="+Ta[qs]+";"}).join("")),g(k,".uniform",b,"(",It,",",Ta.join(","),");"),O&&g("}")}else{if(_(!Array.isArray(Ft),"uniform value must not be an array"),O){var xa=g.def();g("if(!",w.batchId,"||",xa,"!==",Ft,"){",xa,"=",Ft,";")}g(k,".uniform",b,"(",It,",",Ft,");"),O&&g("}")}}}function ae(w,g,N,P){var z=w.shared,O=z.gl,B=z.draw,k=P.draw;function b(){var Ht=k.elements,Kt,le=g;return Ht?((Ht.contextDep&&P.contextDynamic||Ht.propDep)&&(le=N),Kt=Ht.append(w,le),k.elementsActive&&le("if("+Kt+")"+O+".bindBuffer("+Fg+","+Kt+".buffer.buffer);")):(Kt=le.def(),le(Kt,"=",B,".",Do,";","if(",Kt,"){",O,".bindBuffer(",Fg,",",Kt,".buffer.buffer);}","else if(",z.vao,".currentVAO){",Kt,"=",w.shared.elements+".getElements("+z.vao,".currentVAO.elements);",ct?"":"if("+Kt+")"+O+".bindBuffer("+Fg+","+Kt+".buffer.buffer);","}")),Kt}function x(){var Ht=k.count,Kt,le=g;return Ht?((Ht.contextDep&&P.contextDynamic||Ht.propDep)&&(le=N),Kt=Ht.append(w,le),_.optional(function(){Ht.MISSING&&w.assert(g,"false","missing vertex count"),Ht.DYNAMIC&&w.assert(le,Kt+">=0","missing vertex count")})):(Kt=le.def(B,".",Lo),_.optional(function(){w.assert(le,Kt+">=0","missing vertex count")})),Kt}var E=b();function V(Ht){var Kt=k[Ht];return Kt?Kt.contextDep&&P.contextDynamic||Kt.propDep?Kt.append(w,N):Kt.append(w,g):g.def(B,".",Ht)}var G=V(Fo),lt=V(Ah),Et=x();if(typeof Et=="number"){if(Et===0)return}else N("if(",Et,"){"),N.exit("}");var It,Ft;yt&&(It=V(xh),Ft=w.instancing);var St=E+".type",Xt=k.elements&&Ja(k.elements)&&!k.vaoActive;function Vt(){function Ht(){N(Ft,".drawElementsInstancedANGLE(",[G,Et,St,lt+"<<(("+St+"-"+xI+")>>1)",It],");")}function Kt(){N(Ft,".drawArraysInstancedANGLE(",[G,lt,Et,It],");")}E&&E!=="null"?Xt?Ht():(N("if(",E,"){"),Ht(),N("}else{"),Kt(),N("}")):Kt()}function Wt(){function Ht(){N(O+".drawElements("+[G,Et,St,lt+"<<(("+St+"-"+xI+")>>1)"]+");")}function Kt(){N(O+".drawArrays("+[G,lt,Et]+");")}E&&E!=="null"?Xt?Ht():(N("if(",E,"){"),Ht(),N("}else{"),Kt(),N("}")):Kt()}yt&&(typeof It!="number"||It>=0)?typeof It=="string"?(N("if(",It,">0){"),Vt(),N("}else if(",It,"<0){"),Wt(),N("}")):Vt():Wt()}function qe(w,g,N,P,z){var O=de(),B=O.proc("body",z);return _.optional(function(){O.commandStr=g.commandStr,O.command=O.link(g.commandStr)}),yt&&(O.instancing=B.def(O.shared.extensions,".angle_instanced_arrays")),w(O,B,N,P),O.compile().body}function Ze(w,g,N,P){mr(w,g),N.useVAO?N.drawVAO?g(w.shared.vao,".setVAO(",N.drawVAO.append(w,g),");"):g(w.shared.vao,".setVAO(",w.shared.vao,".targetVAO);"):(g(w.shared.vao,".setVAO(null);"),Yr(w,g,N,P.attributes,function(){return!0})),cn(w,g,N,P.uniforms,function(){return!0},!1),ae(w,g,g,N)}function yr(w,g){var N=w.proc("draw",1);mr(w,N),xr(w,N,g.context),Nr(w,N,g.framebuffer),kr(w,N,g),jr(w,N,g.state),ke(w,N,g,!1,!0);var P=g.shader.progVar.append(w,N);if(N(w.shared.gl,".useProgram(",P,".program);"),g.shader.program)Ze(w,N,g,g.shader.program);else{N(w.shared.vao,".setVAO(null);");var z=w.global.def("{}"),O=N.def(P,".id"),B=N.def(z,"[",O,"]");N(w.cond(B).then(B,".call(this,a0);").else(B,"=",z,"[",O,"]=",w.link(function(k){return qe(Ze,w,g,k,1)}),"(",P,");",B,".call(this,a0);"))}Object.keys(g.state).length>0&&N(w.shared.current,".dirty=true;"),w.shared.vao&&N(w.shared.vao,".setVAO(null);")}function Hs(w,g,N,P){w.batchId="a1",mr(w,g);function z(){return!0}Yr(w,g,N,P.attributes,z),cn(w,g,N,P.uniforms,z,!1),ae(w,g,g,N)}function Co(w,g,N,P){mr(w,g);var z=N.contextDep,O=g.def(),B="a0",k="a1",b=g.def();w.shared.props=b,w.batchId=O;var x=w.scope(),E=w.scope();g(x.entry,"for(",O,"=0;",O,"<",k,";++",O,"){",b,"=",B,"[",O,"];",E,"}",x.exit);function V(St){return St.contextDep&&z||St.propDep}function G(St){return!V(St)}if(N.needsContext&&xr(w,E,N.context),N.needsFramebuffer&&Nr(w,E,N.framebuffer),jr(w,E,N.state,V),N.profile&&V(N.profile)&&ke(w,E,N,!1,!0),P)N.useVAO?N.drawVAO?V(N.drawVAO)?E(w.shared.vao,".setVAO(",N.drawVAO.append(w,E),");"):x(w.shared.vao,".setVAO(",N.drawVAO.append(w,x),");"):x(w.shared.vao,".setVAO(",w.shared.vao,".targetVAO);"):(x(w.shared.vao,".setVAO(null);"),Yr(w,x,N,P.attributes,G),Yr(w,E,N,P.attributes,V)),cn(w,x,N,P.uniforms,G,!1),cn(w,E,N,P.uniforms,V,!0),ae(w,x,E,N);else{var lt=w.global.def("{}"),Et=N.shader.progVar.append(w,E),It=E.def(Et,".id"),Ft=E.def(lt,"[",It,"]");E(w.shared.gl,".useProgram(",Et,".program);","if(!",Ft,"){",Ft,"=",lt,"[",It,"]=",w.link(function(St){return qe(Hs,w,N,St,2)}),"(",Et,");}",Ft,".call(this,a0[",O,"],",O,");")}}function I(w,g){var N=w.proc("batch",2);w.batchId="0",mr(w,N);var P=!1,z=!0;Object.keys(g.context).forEach(function(lt){P=P||g.context[lt].propDep}),P||(xr(w,N,g.context),z=!1);var O=g.framebuffer,B=!1;O?(O.propDep?P=B=!0:O.contextDep&&P&&(B=!0),B||Nr(w,N,O)):Nr(w,N,null),g.state.viewport&&g.state.viewport.propDep&&(P=!0);function k(lt){return lt.contextDep&&P||lt.propDep}kr(w,N,g),jr(w,N,g.state,function(lt){return!k(lt)}),(!g.profile||!k(g.profile))&&ke(w,N,g,!1,"a1"),g.contextDep=P,g.needsContext=z,g.needsFramebuffer=B;var b=g.shader.progVar;if(b.contextDep&&P||b.propDep)Co(w,N,g,null);else{var x=b.append(w,N);if(N(w.shared.gl,".useProgram(",x,".program);"),g.shader.program)Co(w,N,g,g.shader.program);else{N(w.shared.vao,".setVAO(null);");var E=w.global.def("{}"),V=N.def(x,".id"),G=N.def(E,"[",V,"]");N(w.cond(G).then(G,".call(this,a0,a1);").else(G,"=",E,"[",V,"]=",w.link(function(lt){return qe(Co,w,g,lt,2)}),"(",x,");",G,".call(this,a0,a1);"))}}Object.keys(g.state).length>0&&N(w.shared.current,".dirty=true;"),w.shared.vao&&N(w.shared.vao,".setVAO(null);")}function K(w,g){var N=w.proc("scope",3);w.batchId="a2";var P=w.shared,z=P.current;xr(w,N,g.context),g.framebuffer&&g.framebuffer.append(w,N),nT(Object.keys(g.state)).forEach(function(B){var k=g.state[B],b=k.append(w,N);pr(b)?b.forEach(function(x,E){N.set(w.next[B],"["+E+"]",x)}):N.set(P.next,"."+B,b)}),ke(w,N,g,!0,!0),[Do,Ah,Lo,xh,Fo].forEach(function(B){var k=g.draw[B];k&&N.set(P.draw,"."+B,""+k.append(w,N))}),Object.keys(g.uniforms).forEach(function(B){var k=g.uniforms[B].append(w,N);Array.isArray(k)&&(k="["+k.join()+"]"),N.set(P.uniforms,"["+v.id(B)+"]",k)}),Object.keys(g.attributes).forEach(function(B){var k=g.attributes[B].append(w,N),b=w.scopeAttrib(B);Object.keys(new $).forEach(function(x){N.set(b,"."+x,k[x])})}),g.scopeVAO&&N.set(P.vao,".targetVAO",g.scopeVAO.append(w,N));function O(B){var k=g.shader[B];k&&N.set(P.shader,"."+B,k.append(w,N))}O(nu),O(ru),Object.keys(g.state).length>0&&(N(z,".dirty=true;"),N.exit(z,".dirty=true;")),N("a1(",w.shared.context,",a0,",w.batchId,");")}function Y(w){if(!(typeof w!="object"||pr(w))){for(var g=Object.keys(w),N=0;N<g.length;++N)if(kt.isDynamic(w[g[N]]))return!0;return!1}}function jt(w,g,N){var P=g.static[N];if(!P||!Y(P))return;var z=w.global,O=Object.keys(P),B=!1,k=!1,b=!1,x=w.global.def("{}");O.forEach(function(V){var G=P[V];if(kt.isDynamic(G)){typeof G=="function"&&(G=P[V]=kt.unbox(G));var lt=Ai(G,null);B=B||lt.thisDep,b=b||lt.propDep,k=k||lt.contextDep}else{switch(z(x,".",V,"="),typeof G){case"number":z(G);break;case"string":z('"',G,'"');break;case"object":Array.isArray(G)&&z("[",G.join(),"]");break;default:z(w.link(G));break}z(";")}});function E(V,G){O.forEach(function(lt){var Et=P[lt];if(kt.isDynamic(Et)){var It=V.invoke(G,Et);G(x,".",lt,"=",It,";")}})}g.dynamic[N]=new kt.DynamicVariable(Ih,{thisDep:B,contextDep:k,propDep:b,ref:x,append:E}),delete g.static[N]}function We(w,g,N,P,z){var O=de();O.stats=O.link(z),Object.keys(g.static).forEach(function(k){jt(O,g,k)}),r6.forEach(function(k){jt(O,w,k)});var B=wr(w,g,N,P,O);return yr(O,B),K(O,B),I(O,B),r(O.compile(),{destroy:function(){B.shader.program.destroy()}})}return{next:Ot,current:Mt,procs:(function(){var w=de(),g=w.proc("poll"),N=w.proc("refresh"),P=w.block();g(P),N(P);var z=w.shared,O=z.gl,B=z.next,k=z.current;P(k,".dirty=false;"),Nr(w,g),Nr(w,N,null,!0);var b;yt&&(b=w.link(yt)),A.oes_vertex_array_object&&N(w.link(A.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var x=0;x<q.maxAttributes;++x){var E=N.def(z.attributes,"[",x,"]"),V=w.cond(E,".buffer");V.then(O,".enableVertexAttribArray(",x,");",O,".bindBuffer(",zl,",",E,".buffer.buffer);",O,".vertexAttribPointer(",x,",",E,".size,",E,".type,",E,".normalized,",E,".stride,",E,".offset);").else(O,".disableVertexAttribArray(",x,");",O,".vertexAttrib4f(",x,",",E,".x,",E,".y,",E,".z,",E,".w);",E,".buffer=null;"),N(V),yt&&N(b,".vertexAttribDivisorANGLE(",x,",",E,".divisor);")}return N(w.shared.vao,".currentVAO=null;",w.shared.vao,".setVAO(",w.shared.vao,".targetVAO);"),Object.keys(at).forEach(function(G){var lt=at[G],Et=P.def(B,".",G),It=w.block();It("if(",Et,"){",O,".enable(",lt,")}else{",O,".disable(",lt,")}",k,".",G,"=",Et,";"),N(It),g("if(",Et,"!==",k,".",G,"){",It,"}")}),Object.keys(it).forEach(function(G){var lt=it[G],Et=Mt[G],It,Ft,St=w.block();if(St(O,".",lt,"("),pr(Et)){var Xt=Et.length;It=w.global.def(B,".",G),Ft=w.global.def(k,".",G),St(Ke(Xt,function(Vt){return It+"["+Vt+"]"}),");",Ke(Xt,function(Vt){return Ft+"["+Vt+"]="+It+"["+Vt+"];"}).join("")),g("if(",Ke(Xt,function(Vt){return It+"["+Vt+"]!=="+Ft+"["+Vt+"]"}).join("||"),"){",St,"}")}else It=P.def(B,".",G),Ft=P.def(k,".",G),St(It,");",k,".",G,"=",It,";"),g("if(",It,"!==",Ft,"){",St,"}");N(St)}),w.compile()})(),compile:We}}function S6(){return{vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}var E6=34918,I6=34919,iT=35007,T6=function(f,v){if(!v.ext_disjoint_timer_query)return null;var A=[];function q(){return A.pop()||v.ext_disjoint_timer_query.createQueryEXT()}function st(yt){A.push(yt)}var W=[];function Z(yt){var Pt=q();v.ext_disjoint_timer_query.beginQueryEXT(iT,Pt),W.push(Pt),pt(W.length-1,W.length,yt)}function ft(){v.ext_disjoint_timer_query.endQueryEXT(iT)}function dt(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var _t=[];function bt(){return _t.pop()||new dt}function vt(yt){_t.push(yt)}var Tt=[];function pt(yt,Pt,ct){var Mt=bt();Mt.startQueryIndex=yt,Mt.endQueryIndex=Pt,Mt.sum=0,Mt.stats=ct,Tt.push(Mt)}var gt=[],$=[];function Q(){var yt,Pt,ct=W.length;if(ct!==0){$.length=Math.max($.length,ct+1),gt.length=Math.max(gt.length,ct+1),gt[0]=0,$[0]=0;var Mt=0;for(yt=0,Pt=0;Pt<W.length;++Pt){var Ot=W[Pt];v.ext_disjoint_timer_query.getQueryObjectEXT(Ot,I6)?(Mt+=v.ext_disjoint_timer_query.getQueryObjectEXT(Ot,E6),st(Ot)):W[yt++]=Ot,gt[Pt+1]=Mt,$[Pt+1]=yt}for(W.length=yt,yt=0,Pt=0;Pt<Tt.length;++Pt){var se=Tt[Pt],at=se.startQueryIndex,it=se.endQueryIndex;se.sum+=gt[it]-gt[at];var Yt=$[at],At=$[it];At===Yt?(se.stats.gpuTime+=se.sum/1e6,vt(se)):(se.startQueryIndex=Yt,se.endQueryIndex=At,Tt[yt++]=se)}Tt.length=yt}}return{beginQuery:Z,endQuery:ft,pushScopeStats:pt,update:Q,getNumPendingQueries:function(){return W.length},clear:function(){A.push.apply(A,W);for(var yt=0;yt<A.length;yt++)v.ext_disjoint_timer_query.deleteQueryEXT(A[yt]);W.length=0,A.length=0},restore:function(){W.length=0,A.length=0}}},A6=16384,x6=256,N6=1024,R6=34962,sT="webglcontextlost",aT="webglcontextrestored",oT=1,B6=2,O6=3;function lT(f,v){for(var A=0;A<f.length;++A)if(f[A]===v)return A;return-1}function D6(f){var v=gr(f);if(!v)return null;var A=v.gl,q=A.getContextAttributes(),st=A.isContextLost(),W=fi(A,v);if(!W)return null;var Z=Me(),ft=S6(),dt=W.extensions,_t=T6(A,dt),bt=pe(),vt=A.drawingBufferWidth,Tt=A.drawingBufferHeight,pt={tick:0,time:0,viewportWidth:vt,viewportHeight:Tt,framebufferWidth:vt,framebufferHeight:Tt,drawingBufferWidth:vt,drawingBufferHeight:Tt,pixelRatio:v.pixelRatio},gt={},$={elements:null,primitive:4,count:-1,offset:0,instances:-1},Q=_8(A,dt),yt=L8(A,ft,v,Mt),Pt=W8(A,dt,yt,ft),ct=W4(A,dt,Q,ft,yt,Pt,$);function Mt(ae){return ct.destroyBuffer(ae)}var Ot=K4(A,Z,ft,v),se=E4(A,dt,Q,function(){Yt.procs.poll()},pt,ft,v),at=I4(A,dt,Q,ft,v),it=j4(A,dt,Q,se,at,ft),Yt=w6(A,Z,dt,Q,yt,Pt,se,it,gt,ct,Ot,$,pt,_t,v),At=Z4(A,it,Yt.procs.poll,pt,q,dt,Q),mt=Yt.next,Nt=A.canvas,Bt=[],_e=[],de=[],Dt=[v.onDestroy],Ut=null;function oe(){if(Bt.length===0){_t&&_t.update(),Ut=null;return}Ut=Gt.next(oe),jr();for(var ae=Bt.length-1;ae>=0;--ae){var qe=Bt[ae];qe&&qe(pt,null,0)}A.flush(),_t&&_t.update()}function ye(){!Ut&&Bt.length>0&&(Ut=Gt.next(oe))}function He(){Ut&&(Gt.cancel(oe),Ut=null)}function er(ae){ae.preventDefault(),st=!0,He(),_e.forEach(function(qe){qe()})}function ar(ae){A.getError(),st=!1,W.restore(),Ot.restore(),yt.restore(),se.restore(),at.restore(),it.restore(),ct.restore(),_t&&_t.restore(),Yt.procs.refresh(),ye(),de.forEach(function(qe){qe()})}Nt&&(Nt.addEventListener(sT,er,!1),Nt.addEventListener(aT,ar,!1));function Xe(){Bt.length=0,He(),Nt&&(Nt.removeEventListener(sT,er),Nt.removeEventListener(aT,ar)),Ot.clear(),it.clear(),at.clear(),ct.clear(),se.clear(),Pt.clear(),yt.clear(),_t&&_t.clear(),Dt.forEach(function(ae){ae()})}function Ar(ae){_(!!ae,"invalid args to regl({...})"),_.type(ae,"object","invalid args to regl({...})");function qe(z){var O=r({},z);delete O.uniforms,delete O.attributes,delete O.context,delete O.vao,"stencil"in O&&O.stencil.op&&(O.stencil.opBack=O.stencil.opFront=O.stencil.op,delete O.stencil.op);function B(k){if(k in O){var b=O[k];delete O[k],Object.keys(b).forEach(function(x){O[k+"."+x]=b[x]})}}return B("blend"),B("depth"),B("cull"),B("stencil"),B("polygonOffset"),B("scissor"),B("sample"),"vao"in z&&(O.vao=z.vao),O}function Ze(z,O){var B={},k={};return Object.keys(z).forEach(function(b){var x=z[b];if(kt.isDynamic(x)){k[b]=kt.unbox(x,b);return}else if(O&&Array.isArray(x)){for(var E=0;E<x.length;++E)if(kt.isDynamic(x[E])){k[b]=kt.unbox(x,b);return}}B[b]=x}),{dynamic:k,static:B}}var yr=Ze(ae.context||{},!0),Hs=Ze(ae.uniforms||{},!0),Co=Ze(ae.attributes||{},!1),I=Ze(qe(ae),!1),K={gpuTime:0,cpuTime:0,count:0},Y=Yt.compile(I,Co,Hs,yr,K),jt=Y.draw,We=Y.batch,w=Y.scope,g=[];function N(z){for(;g.length<z;)g.push(null);return g}function P(z,O){var B;if(st&&_.raise("context lost"),typeof z=="function")return w.call(this,null,z,0);if(typeof O=="function")if(typeof z=="number")for(B=0;B<z;++B)w.call(this,null,O,B);else if(Array.isArray(z))for(B=0;B<z.length;++B)w.call(this,z[B],O,B);else return w.call(this,z,O,0);else if(typeof z=="number"){if(z>0)return We.call(this,N(z|0),z|0)}else if(Array.isArray(z)){if(z.length)return We.call(this,z,z.length)}else return jt.call(this,z)}return r(P,{stats:K,destroy:function(){Y.destroy()}})}var Wn=it.setFBO=Ar({framebuffer:kt.define.call(null,oT,"framebuffer")});function wr(ae,qe){var Ze=0;Yt.procs.poll();var yr=qe.color;yr&&(A.clearColor(+yr[0]||0,+yr[1]||0,+yr[2]||0,+yr[3]||0),Ze|=A6),"depth"in qe&&(A.clearDepth(+qe.depth),Ze|=x6),"stencil"in qe&&(A.clearStencil(qe.stencil|0),Ze|=N6),_(!!Ze,"called regl.clear with no buffer specified"),A.clear(Ze)}function xr(ae){if(_(typeof ae=="object"&&ae,"regl.clear() takes an object as input"),"framebuffer"in ae)if(ae.framebuffer&&ae.framebuffer_reglType==="framebufferCube")for(var qe=0;qe<6;++qe)Wn(r({framebuffer:ae.framebuffer.faces[qe]},ae),wr);else Wn(ae,wr);else wr(null,ae)}function Nr(ae){_.type(ae,"function","regl.frame() callback must be a function"),Bt.push(ae);function qe(){var Ze=lT(Bt,ae);_(Ze>=0,"cannot cancel a frame twice");function yr(){var Hs=lT(Bt,yr);Bt[Hs]=Bt[Bt.length-1],Bt.length-=1,Bt.length<=0&&He()}Bt[Ze]=yr}return ye(),{cancel:qe}}function kr(){var ae=mt.viewport,qe=mt.scissor_box;ae[0]=ae[1]=qe[0]=qe[1]=0,pt.viewportWidth=pt.framebufferWidth=pt.drawingBufferWidth=ae[2]=qe[2]=A.drawingBufferWidth,pt.viewportHeight=pt.framebufferHeight=pt.drawingBufferHeight=ae[3]=qe[3]=A.drawingBufferHeight}function jr(){pt.tick+=1,pt.time=ke(),kr(),Yt.procs.poll()}function mr(){se.refresh(),kr(),Yt.procs.refresh(),_t&&_t.update()}function ke(){return(pe()-bt)/1e3}mr();function Yr(ae,qe){_.type(qe,"function","listener callback must be a function");var Ze;switch(ae){case"frame":return Nr(qe);case"lost":Ze=_e;break;case"restore":Ze=de;break;case"destroy":Ze=Dt;break;default:_.raise("invalid event, must be one of frame,lost,restore,destroy")}return Ze.push(qe),{cancel:function(){for(var yr=0;yr<Ze.length;++yr)if(Ze[yr]===qe){Ze[yr]=Ze[Ze.length-1],Ze.pop();return}}}}var cn=r(Ar,{clear:xr,prop:kt.define.bind(null,oT),context:kt.define.bind(null,B6),this:kt.define.bind(null,O6),draw:Ar({}),buffer:function(ae){return yt.create(ae,R6,!1,!1)},elements:function(ae){return Pt.create(ae,!1)},texture:se.create2D,cube:se.createCube,renderbuffer:at.create,framebuffer:it.create,framebufferCube:it.createCube,vao:ct.createVAO,attributes:q,frame:Nr,on:Yr,limits:Q,hasExtension:function(ae){return Q.extensions.indexOf(ae.toLowerCase())>=0},read:At,destroy:Xe,_gl:A,_refresh:mr,poll:function(){jr(),_t&&_t.update()},now:ke,stats:ft});return v.onDone(null,cn),cn}return D6}))})(pd)),pd.exports}var PF=UF();const Wp=CF(PF);function Ge(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(d){try{u(r.next(d))}catch(h){a(h)}}function l(d){try{u(r.throw(d))}catch(h){a(h)}}function u(d){d.done?s(d.value):i(d.value).then(o,l)}u((r=r.apply(e,t||[])).next())})}function Jv(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Qe(e){return this instanceof Qe?(this.v=e,this):new Qe(e)}function Ts(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(S){return function(M){return Promise.resolve(M).then(S,h)}}function o(S,M){r[S]&&(i[S]=function(H){return new Promise(function(nt,j){s.push([S,H,nt,j])>1||l(S,H)})},M&&(i[S]=M(i[S])))}function l(S,M){try{u(r[S](M))}catch(H){y(s[0][3],H)}}function u(S){S.value instanceof Qe?Promise.resolve(S.value.v).then(d,h):y(s[0][2],S)}function d(S){l("next",S)}function h(S){l("throw",S)}function y(S,M){S(M),s.shift(),s.length&&l(s[0][0],s[0][1])}}function md(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:Qe(e[i](a)),done:!1}:s?s(a):a}:s}}function po(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Jv=="function"?Jv(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(u){s({value:u,done:o})},a)}}typeof SuppressedError=="function"&&SuppressedError;const $F=new TextDecoder("utf-8"),Hp=e=>$F.decode(e),VF=new TextEncoder,qp=e=>VF.encode(e),zF=e=>typeof e=="number",Zv=e=>typeof e=="boolean",Br=e=>typeof e=="function",gi=e=>e!=null&&Object(e)===e,mo=e=>gi(e)&&Br(e.then),Sc=e=>gi(e)&&Br(e[Symbol.iterator]),Ho=e=>gi(e)&&Br(e[Symbol.asyncIterator]),Xp=e=>gi(e)&&gi(e.schema),t0=e=>gi(e)&&"done"in e&&"value"in e,e0=e=>gi(e)&&Br(e.stat)&&zF(e.fd),n0=e=>gi(e)&&Kp(e.body),yd=e=>"_getDOMStream"in e&&"_getNodeStream"in e,GF=e=>gi(e)&&Br(e.abort)&&Br(e.getWriter)&&!yd(e),Kp=e=>gi(e)&&Br(e.cancel)&&Br(e.getReader)&&!yd(e),jF=e=>gi(e)&&Br(e.end)&&Br(e.write)&&Zv(e.writable)&&!yd(e),r0=e=>gi(e)&&Br(e.read)&&Br(e.pipe)&&Zv(e.readable)&&!yd(e),YF=e=>gi(e)&&Br(e.clear)&&Br(e.bytes)&&Br(e.position)&&Br(e.setPosition)&&Br(e.capacity)&&Br(e.getBufferIdentifier)&&Br(e.createLong),Qp=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function WF(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,u=0,d=e.length;++l<d;){if(a=t[u],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++u]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++u]=o);continue}t[u]=new Uint8Array(a.buffer,n,r-n+s)}return t}function i0(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function As(e,t){const n=WF(e),r=n.reduce((d,h)=>d+h.byteLength,0);let i,s,a,o=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=n.length;++l<d;){if(i=n[l],s=i.subarray(0,Math.min(i.length,u-o)),u<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?i0(a,s,o):a=s;break}i0(a||(a=new Uint8Array(u)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function kn(e,t){let n=t0(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=qp(n)),n instanceof ArrayBuffer?new e(n):n instanceof Qp?new e(n):YF(n)?kn(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const Ec=e=>kn(Int32Array,e),s0=e=>kn(BigInt64Array,e),un=e=>kn(Uint8Array,e),Jp=e=>(e.next(),e);function*HF(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Qp?n(t):Sc(t)?t:n(t);return yield*Jp((function*(i){let s=null;do s=i.next(yield kn(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const qF=e=>HF(Uint8Array,e);function a0(e,t){return Ts(this,arguments,function*(){if(mo(t))return yield Qe(yield Qe(yield*md(po(a0(e,yield Qe(t))))));const r=function(a){return Ts(this,arguments,function*(){yield yield Qe(yield Qe(a))})},i=function(a){return Ts(this,arguments,function*(){yield Qe(yield*md(po(Jp((function*(o){let l=null;do l=o.next(yield l==null?void 0:l.value);while(!l.done)})(a[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Qp?r(t):Sc(t)?i(t):Ho(t)?t:r(t);return yield Qe(yield*md(po(Jp((function(a){return Ts(this,arguments,function*(){let o=null;do o=yield Qe(a.next(yield yield Qe(kn(e,o))));while(!o.done)})})(s[Symbol.asyncIterator]()))))),yield Qe(new e)})}const XF=e=>a0(Uint8Array,e);function o0(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function KF(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const Ui={fromIterable(e){return gd(QF(e))},fromAsyncIterable(e){return gd(JF(e))},fromDOMStream(e){return gd(ZF(e))},fromNodeStream(e){return gd(eL(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},gd=e=>(e.next(),e);function*QF(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?As(r,a)[0]:([i,r,o]=As(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const u=qF(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?u.next():u.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(d){(n=!0)&&typeof u.throw=="function"&&u.throw(d)}finally{n===!1&&typeof u.return=="function"&&u.return(null)}return null}function JF(e){return Ts(this,arguments,function*(){let n,r=!1,i=[],s,a,o,l=0;function u(){return a==="peek"?As(i,o)[0]:([s,i,l]=As(i,o),s)}({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0});const d=XF(e)[Symbol.asyncIterator]();try{do if({done:n,value:s}=Number.isNaN(o-l)?yield Qe(d.next()):yield Qe(d.next(o-l)),!n&&s.byteLength>0&&(i.push(s),l+=s.byteLength),n||o<=l)do({cmd:a,size:o}=yield yield Qe(u()));while(o<l);while(!n)}catch(h){(r=!0)&&typeof d.throw=="function"&&(yield Qe(d.throw(h)))}finally{r===!1&&typeof d.return=="function"&&(yield Qe(d.return(new Uint8Array(0))))}return yield Qe(null)})}function ZF(e){return Ts(this,arguments,function*(){let n=!1,r=!1,i=[],s,a,o,l=0;function u(){return a==="peek"?As(i,o)[0]:([s,i,l]=As(i,o),s)}({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0});const d=new tL(e);try{do if({done:n,value:s}=Number.isNaN(o-l)?yield Qe(d.read()):yield Qe(d.read(o-l)),!n&&s.byteLength>0&&(i.push(un(s)),l+=s.byteLength),n||o<=l)do({cmd:a,size:o}=yield yield Qe(u()));while(o<l);while(!n)}catch(h){(r=!0)&&(yield Qe(d.cancel(h)))}finally{r===!1?yield Qe(d.cancel()):e.locked&&d.releaseLock()}return yield Qe(null)})}class tL{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Ge(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Ge(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=un(n)),n})}}const Zp=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function eL(e){return Ts(this,arguments,function*(){const n=[];let r="error",i=!1,s=null,a,o,l=0,u=[],d;function h(){return a==="peek"?As(u,o)[0]:([d,u,l]=As(u,o),d)}if({cmd:a,size:o}=(yield yield Qe(null))||{cmd:"read",size:0},e.isTTY)return yield yield Qe(new Uint8Array(0)),yield Qe(null);try{n[0]=Zp(e,"end"),n[1]=Zp(e,"error");do{if(n[2]=Zp(e,"readable"),[r,s]=yield Qe(Promise.race(n.map(S=>S[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(o-l)?(d=un(e.read(o-l)),d.byteLength<o-l&&(d=un(e.read()))):d=un(e.read()),d.byteLength>0&&(u.push(d),l+=d.byteLength)),i||o<=l)do({cmd:a,size:o}=yield yield Qe(h()));while(o<l)}while(!i)}finally{yield Qe(y(n,r==="error"?s:null))}return yield Qe(null);function y(S,M){return d=u=null,new Promise((H,nt)=>{for(const[j,$t]of S)e.off(j,$t);try{const j=e.destroy;j&&j.call(e,M),M=void 0}catch(j){M=j||M}finally{M!=null?nt(M):H()}})}})}var Sr;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(Sr||(Sr={}));var qr;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(qr||(qr={}));var Xr;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Xr||(Xr={}));var Pi;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Pi||(Pi={}));var xe;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(xe||(xe={}));var xs;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(xs||(xs={}));const tm=2,Ns=4,aa=4,Rn=4,Oa=new Int32Array(2),l0=new Float32Array(Oa.buffer),c0=new Float64Array(Oa.buffer),_d=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var em;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(em||(em={}));let qo=class dT{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new dT(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Oa[0]=this.readInt32(t),l0[0]}readFloat64(t){return Oa[_d?0:1]=this.readInt32(t),Oa[_d?1:0]=this.readInt32(t+4),c0[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){l0[0]=n,this.writeInt32(t,Oa[0])}writeFloat64(t,n){c0[0]=n,this.writeInt32(t,Oa[_d?0:1]),this.writeInt32(t+4,Oa[_d?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ns+aa)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<aa;n++)t+=String.fromCharCode(this.readInt8(this.position_+Ns+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=Ns;const i=this.bytes_.subarray(t,t+r);return n===em.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+Ns}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=aa)throw new Error("FlatBuffers: file identifier must be length "+aa);for(let n=0;n<aa;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Ns+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},u0=class fT{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=qo.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=fT.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=qo.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(Ns,0),this.writeInt32(this.offset()-t+Ns)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*tm;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let u=tm;u<s;u+=tm)if(this.bb.readInt16(o+u)!=this.bb.readInt16(l+u))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?Rn:0;if(n){const s=n;if(this.prep(this.minalign,Ns+aa+i),s.length!=aa)throw new TypeError("FlatBuffers: file identifier must be length "+aa);for(let a=aa-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Ns+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(Ns,t*n),this.prep(r,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var vd;(function(e){e[e.BUFFER=0]="BUFFER"})(vd||(vd={}));var bd;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(bd||(bd={}));class Da{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Da).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Rn),(n||new Da).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):bd.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):vd.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,bd.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,vd.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Da.startBodyCompression(t),Da.addCodec(t,n),Da.addMethod(t,r),Da.endBodyCompression(t)}}class d0{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let f0=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}},oa=class $g{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new $g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Rn),(n||new $g).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new f0).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new d0).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Da).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},Xo=class Vg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new Vg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Rn),(n||new Vg).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new oa).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var Ko;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(Ko||(Ko={}));var wd;(function(e){e[e.DenseArray=0]="DenseArray"})(wd||(wd={}));class Bi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Bi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Rn),(n||new Bi).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Bi.startInt(t),Bi.addBitWidth(t,n),Bi.addIsSigned(t,r),Bi.endInt(t)}}class la{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new la).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Rn),(n||new la).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Bi).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):wd.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,wd.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Or{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new Or).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Rn),(n||new Or).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return Or.startKeyValue(t),Or.addKey(t,n),Or.addValue(t,r),Or.endKeyValue(t)}}let h0=class du{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new du).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Rn),(n||new du).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return du.startBinary(t),du.endBinary(t)}},p0=class fu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new fu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Rn),(n||new fu).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return fu.startBool(t),fu.endBool(t)}},Sd=class jl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new jl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Rn),(n||new jl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Pi.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Pi.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return jl.startDate(t),jl.addUnit(t,n),jl.endDate(t)}},Qo=class Za{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new Za).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Rn),(n||new Za).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return Za.startDecimal(t),Za.addPrecision(t,n),Za.addScale(t,r),Za.addBitWidth(t,i),Za.endDecimal(t)}},Ed=class Yl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new Yl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Rn),(n||new Yl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):xe.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,xe.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Yl.startDuration(t),Yl.addUnit(t,n),Yl.endDuration(t)}},Id=class Wl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new Wl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Rn),(n||new Wl).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return Wl.startFixedSizeBinary(t),Wl.addByteWidth(t,n),Wl.endFixedSizeBinary(t)}},Td=class Hl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new Hl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Rn),(n||new Hl).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return Hl.startFixedSizeList(t),Hl.addListSize(t,n),Hl.endFixedSizeList(t)}};class Rs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new Rs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Rn),(n||new Rs).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Xr.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Xr.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return Rs.startFloatingPoint(t),Rs.addPrecision(t,n),Rs.endFloatingPoint(t)}}class Bs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new Bs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Rn),(n||new Bs).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):xs.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,xs.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return Bs.startInterval(t),Bs.addUnit(t,n),Bs.endInterval(t)}}let m0=class hu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new hu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Rn),(n||new hu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return hu.startLargeBinary(t),hu.endLargeBinary(t)}},y0=class pu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new pu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Rn),(n||new pu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return pu.startLargeUtf8(t),pu.endLargeUtf8(t)}},g0=class mu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new mu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Rn),(n||new mu).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return mu.startList(t),mu.endList(t)}},Ad=class ql{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new ql).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Rn),(n||new ql).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return ql.startMap(t),ql.addKeysSorted(t,n),ql.endMap(t)}},_0=class yu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new yu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Rn),(n||new yu).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return yu.startNull(t),yu.endNull(t)}};class yo{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new yo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Rn),(n||new yo).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return yo.startStruct_(t),yo.endStruct_(t)}}class $i{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new $i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Rn),(n||new $i).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):xe.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,xe.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return $i.startTime(t),$i.addUnit(t,n),$i.addBitWidth(t,r),$i.endTime(t)}}class Vi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new Vi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Rn),(n||new Vi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):xe.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,xe.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return Vi.startTimestamp(t),Vi.addUnit(t,n),Vi.addTimezone(t,r),Vi.endTimestamp(t)}}class _i{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Rn),(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):qr.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,qr.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return _i.startUnion(t),_i.addMode(t,n),_i.addTypeIds(t,r),_i.endUnion(t)}}let v0=class gu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new gu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Rn),(n||new gu).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return gu.startUtf8(t),gu.endUtf8(t)}};var Jn;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(Jn||(Jn={}));let zi=class Uh{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new Uh).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Rn),(n||new Uh).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Jn.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new la).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Uh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new Or).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,Jn.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},Os=class Na{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Na).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Rn),(n||new Na).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ko.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new zi).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Or).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,Ko.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Na.startSchema(t),Na.addEndianness(t,n),Na.addFields(t,r),Na.addCustomMetadata(t,i),Na.addFeatures(t,s),Na.endSchema(t)}};var bn;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(bn||(bn={}));var D;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(D||(D={}));var ca;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(ca||(ca={}));const nL=void 0;function Ic(e){if(e===null)return"null";if(e===nL)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>Ic(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function Hn(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function b0(e,t){return Hn(e/t)+Hn(e%t)/Hn(t)}const rL=Symbol.for("isArrowBigNum");function us(e,...t){return t.length===0?Object.setPrototypeOf(kn(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}us.prototype[rL]=!0,us.prototype.toJSON=function(){return`"${Ac(this)}"`},us.prototype.valueOf=function(e){return w0(this,e)},us.prototype.toString=function(){return Ac(this)},us.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return w0(this);case"string":return Ac(this);case"default":return sL(this)}return Ac(this)};function Jo(...e){return us.apply(this,e)}function Zo(...e){return us.apply(this,e)}function Tc(...e){return us.apply(this,e)}Object.setPrototypeOf(Jo.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Zo.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Tc.prototype,Object.create(Uint32Array.prototype)),Object.assign(Jo.prototype,us.prototype,{constructor:Jo,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Zo.prototype,us.prototype,{constructor:Zo,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Tc.prototype,us.prototype,{constructor:Tc,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const iL=BigInt(4294967296)*BigInt(4294967296)-BigInt(1);function w0(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),u=0;if(o){for(const d of a)l|=(d^iL)*(BigInt(1)<<BigInt(64*u++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*u++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),h=l/d,y=l%d;return Hn(h)+Hn(y)/Hn(d)}return Hn(l)}function Ac(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return nm(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return nm(e);t=t.slice();let r=1;for(let s=0;s<t.length;s++){const a=t[s],o=~a+r;t[s]=o,r&=a===0?1:0}return`-${nm(t)}`}function sL(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Ac(e)}function nm(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class rm{static new(t,n){switch(n){case!0:return new Jo(t);case!1:return new Zo(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Jo(t)}return t.byteLength===16?new Tc(t):new Zo(t)}static signed(t){return new Jo(t)}static unsigned(t){return new Zo(t)}static decimal(t){return new Tc(t)}constructor(t,n){return rm.new(t,n)}}var S0,E0,I0,T0,A0,x0,N0,R0,B0,O0,D0,F0,L0,M0,C0,k0,U0,P0,$0,V0,z0,G0;class ce{static isNull(t){return(t==null?void 0:t.typeId)===D.Null}static isInt(t){return(t==null?void 0:t.typeId)===D.Int}static isFloat(t){return(t==null?void 0:t.typeId)===D.Float}static isBinary(t){return(t==null?void 0:t.typeId)===D.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===D.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===D.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===D.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===D.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===D.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===D.Date}static isTime(t){return(t==null?void 0:t.typeId)===D.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===D.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===D.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===D.Duration}static isList(t){return(t==null?void 0:t.typeId)===D.List}static isStruct(t){return(t==null?void 0:t.typeId)===D.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===D.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===D.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===D.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===D.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===D.Dictionary}static isDenseUnion(t){return ce.isUnion(t)&&t.mode===qr.Dense}static isSparseUnion(t){return ce.isUnion(t)&&t.mode===qr.Sparse}constructor(t){this.typeId=t}}S0=Symbol.toStringTag,ce[S0]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(ce.prototype);class Fa extends ce{constructor(){super(D.Null)}toString(){return"Null"}}E0=Symbol.toStringTag,Fa[E0]=(e=>e[Symbol.toStringTag]="Null")(Fa.prototype);class go extends ce{constructor(t,n){super(D.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}I0=Symbol.toStringTag,go[I0]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(go.prototype);class xc extends go{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(xc.prototype,"ArrayType",{value:Int32Array});class xd extends ce{constructor(t){super(D.Float),this.precision=t}get ArrayType(){switch(this.precision){case Xr.HALF:return Uint16Array;case Xr.SINGLE:return Float32Array;case Xr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}T0=Symbol.toStringTag,xd[T0]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(xd.prototype);class Nd extends ce{constructor(){super(D.Binary)}toString(){return"Binary"}}A0=Symbol.toStringTag,Nd[A0]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Nd.prototype);class Rd extends ce{constructor(){super(D.LargeBinary)}toString(){return"LargeBinary"}}x0=Symbol.toStringTag,Rd[x0]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Rd.prototype);class Bd extends ce{constructor(){super(D.Utf8)}toString(){return"Utf8"}}N0=Symbol.toStringTag,Bd[N0]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Bd.prototype);class Od extends ce{constructor(){super(D.LargeUtf8)}toString(){return"LargeUtf8"}}R0=Symbol.toStringTag,Od[R0]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(Od.prototype);class Dd extends ce{constructor(){super(D.Bool)}toString(){return"Bool"}}B0=Symbol.toStringTag,Dd[B0]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Dd.prototype);class Fd extends ce{constructor(t,n,r=128){super(D.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}O0=Symbol.toStringTag,Fd[O0]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Fd.prototype);class Ld extends ce{constructor(t){super(D.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Pi[this.unit]}>`}get ArrayType(){return this.unit===Pi.DAY?Int32Array:BigInt64Array}}D0=Symbol.toStringTag,Ld[D0]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(Ld.prototype);class Md extends ce{constructor(t,n){super(D.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${xe[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}F0=Symbol.toStringTag,Md[F0]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(Md.prototype);class Cd extends ce{constructor(t,n){super(D.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${xe[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}L0=Symbol.toStringTag,Cd[L0]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Cd.prototype);class kd extends ce{constructor(t){super(D.Interval),this.unit=t}toString(){return`Interval<${xs[this.unit]}>`}}M0=Symbol.toStringTag,kd[M0]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(kd.prototype);class Ud extends ce{constructor(t){super(D.Duration),this.unit=t}toString(){return`Duration<${xe[this.unit]}>`}}C0=Symbol.toStringTag,Ud[C0]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(Ud.prototype);class Pd extends ce{constructor(t){super(D.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}k0=Symbol.toStringTag,Pd[k0]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Pd.prototype);class ri extends ce{constructor(t){super(D.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}U0=Symbol.toStringTag,ri[U0]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(ri.prototype);class $d extends ce{constructor(t,n,r){super(D.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}P0=Symbol.toStringTag,$d[P0]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))($d.prototype);class Vd extends ce{constructor(t){super(D.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}$0=Symbol.toStringTag,Vd[$0]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Vd.prototype);class zd extends ce{constructor(t,n){super(D.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}V0=Symbol.toStringTag,zd[V0]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(zd.prototype);class Gd extends ce{constructor(t,n=!1){var r,i,s;if(super(D.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}z0=Symbol.toStringTag,Gd[z0]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Gd.prototype);const aL=(e=>()=>++e)(-1);class tl extends ce{constructor(t,n,r,i){super(D.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?aL():Hn(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}G0=Symbol.toStringTag,tl[G0]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(tl.prototype);function ua(e){const t=e;switch(e.typeId){case D.Decimal:return e.bitWidth/32;case D.Interval:return 1+t.unit;case D.FixedSizeList:return t.listSize;case D.FixedSizeBinary:return t.byteWidth;default:return 1}}class tn{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return oL(this,t,n)}getVisitFnByTypeId(t,n=!0){return el(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function oL(e,t,n=!0){return typeof t=="number"?el(e,t,n):typeof t=="string"&&t in D?el(e,D[t],n):t&&t instanceof ce?el(e,j0(t),n):t!=null&&t.type&&t.type instanceof ce?el(e,j0(t.type),n):el(e,D.NONE,n)}function el(e,t,n=!0){let r=null;switch(t){case D.Null:r=e.visitNull;break;case D.Bool:r=e.visitBool;break;case D.Int:r=e.visitInt;break;case D.Int8:r=e.visitInt8||e.visitInt;break;case D.Int16:r=e.visitInt16||e.visitInt;break;case D.Int32:r=e.visitInt32||e.visitInt;break;case D.Int64:r=e.visitInt64||e.visitInt;break;case D.Uint8:r=e.visitUint8||e.visitInt;break;case D.Uint16:r=e.visitUint16||e.visitInt;break;case D.Uint32:r=e.visitUint32||e.visitInt;break;case D.Uint64:r=e.visitUint64||e.visitInt;break;case D.Float:r=e.visitFloat;break;case D.Float16:r=e.visitFloat16||e.visitFloat;break;case D.Float32:r=e.visitFloat32||e.visitFloat;break;case D.Float64:r=e.visitFloat64||e.visitFloat;break;case D.Utf8:r=e.visitUtf8;break;case D.LargeUtf8:r=e.visitLargeUtf8;break;case D.Binary:r=e.visitBinary;break;case D.LargeBinary:r=e.visitLargeBinary;break;case D.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case D.Date:r=e.visitDate;break;case D.DateDay:r=e.visitDateDay||e.visitDate;break;case D.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case D.Timestamp:r=e.visitTimestamp;break;case D.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case D.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case D.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case D.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case D.Time:r=e.visitTime;break;case D.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case D.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case D.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case D.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case D.Decimal:r=e.visitDecimal;break;case D.List:r=e.visitList;break;case D.Struct:r=e.visitStruct;break;case D.Union:r=e.visitUnion;break;case D.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case D.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case D.Dictionary:r=e.visitDictionary;break;case D.Interval:r=e.visitInterval;break;case D.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case D.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case D.Duration:r=e.visitDuration;break;case D.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case D.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case D.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case D.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case D.FixedSizeList:r=e.visitFixedSizeList;break;case D.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${D[t]}'`)}function j0(e){switch(e.typeId){case D.Null:return D.Null;case D.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?D.Int8:D.Uint8;case 16:return n?D.Int16:D.Uint16;case 32:return n?D.Int32:D.Uint32;case 64:return n?D.Int64:D.Uint64}return D.Int}case D.Float:switch(e.precision){case Xr.HALF:return D.Float16;case Xr.SINGLE:return D.Float32;case Xr.DOUBLE:return D.Float64}return D.Float;case D.Binary:return D.Binary;case D.LargeBinary:return D.LargeBinary;case D.Utf8:return D.Utf8;case D.LargeUtf8:return D.LargeUtf8;case D.Bool:return D.Bool;case D.Decimal:return D.Decimal;case D.Time:switch(e.unit){case xe.SECOND:return D.TimeSecond;case xe.MILLISECOND:return D.TimeMillisecond;case xe.MICROSECOND:return D.TimeMicrosecond;case xe.NANOSECOND:return D.TimeNanosecond}return D.Time;case D.Timestamp:switch(e.unit){case xe.SECOND:return D.TimestampSecond;case xe.MILLISECOND:return D.TimestampMillisecond;case xe.MICROSECOND:return D.TimestampMicrosecond;case xe.NANOSECOND:return D.TimestampNanosecond}return D.Timestamp;case D.Date:switch(e.unit){case Pi.DAY:return D.DateDay;case Pi.MILLISECOND:return D.DateMillisecond}return D.Date;case D.Interval:switch(e.unit){case xs.DAY_TIME:return D.IntervalDayTime;case xs.YEAR_MONTH:return D.IntervalYearMonth}return D.Interval;case D.Duration:switch(e.unit){case xe.SECOND:return D.DurationSecond;case xe.MILLISECOND:return D.DurationMillisecond;case xe.MICROSECOND:return D.DurationMicrosecond;case xe.NANOSECOND:return D.DurationNanosecond}return D.Duration;case D.Map:return D.Map;case D.List:return D.List;case D.Struct:return D.Struct;case D.Union:switch(e.mode){case qr.Dense:return D.DenseUnion;case qr.Sparse:return D.SparseUnion}return D.Union;case D.FixedSizeBinary:return D.FixedSizeBinary;case D.FixedSizeList:return D.FixedSizeList;case D.Dictionary:return D.Dictionary}throw new Error(`Unrecognized type '${D[e.typeId]}'`)}tn.prototype.visitInt8=null,tn.prototype.visitInt16=null,tn.prototype.visitInt32=null,tn.prototype.visitInt64=null,tn.prototype.visitUint8=null,tn.prototype.visitUint16=null,tn.prototype.visitUint32=null,tn.prototype.visitUint64=null,tn.prototype.visitFloat16=null,tn.prototype.visitFloat32=null,tn.prototype.visitFloat64=null,tn.prototype.visitDateDay=null,tn.prototype.visitDateMillisecond=null,tn.prototype.visitTimestampSecond=null,tn.prototype.visitTimestampMillisecond=null,tn.prototype.visitTimestampMicrosecond=null,tn.prototype.visitTimestampNanosecond=null,tn.prototype.visitTimeSecond=null,tn.prototype.visitTimeMillisecond=null,tn.prototype.visitTimeMicrosecond=null,tn.prototype.visitTimeNanosecond=null,tn.prototype.visitDenseUnion=null,tn.prototype.visitSparseUnion=null,tn.prototype.visitIntervalDayTime=null,tn.prototype.visitIntervalYearMonth=null,tn.prototype.visitDuration=null,tn.prototype.visitDurationSecond=null,tn.prototype.visitDurationMillisecond=null,tn.prototype.visitDurationMicrosecond=null,tn.prototype.visitDurationNanosecond=null;const Y0=new Float64Array(1),nl=new Uint32Array(Y0.buffer);function W0(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function lL(e){if(e!==e)return 32256;Y0[0]=e;const t=(nl[1]&2147483648)>>16&65535;let n=nl[1]&2146435072,r=0;return n>=1089470464?nl[0]>0?n=31744:(n=(n&2080374784)>>16,r=(nl[1]&1048575)>>10):n<=1056964608?(r=1048576+(nl[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(nl[1]&1048575)+512>>10),t|n|r&65535}class Ne extends tn{}function Ue(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const cL=(e,t,n)=>{e[t]=Math.floor(n/864e5)},H0=(e,t,n,r)=>{if(n+1<t.length){const i=Hn(t[n]),s=Hn(t[n+1]);e.set(r.subarray(0,s-i),i)}},uL=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},da=({values:e},t,n)=>{e[t]=n},im=({values:e},t,n)=>{e[t]=n},q0=({values:e},t,n)=>{e[t]=lL(n)},dL=(e,t,n)=>{switch(e.type.precision){case Xr.HALF:return q0(e,t,n);case Xr.SINGLE:case Xr.DOUBLE:return im(e,t,n)}},X0=({values:e},t,n)=>{cL(e,t,n.valueOf())},K0=({values:e},t,n)=>{e[t]=BigInt(n)},fL=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Q0=({values:e,valueOffsets:t},n,r)=>H0(e,t,n,r),J0=({values:e,valueOffsets:t},n,r)=>H0(e,t,n,qp(r)),hL=(e,t,n)=>{e.type.unit===Pi.DAY?X0(e,t,n):K0(e,t,n)},Z0=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},tb=({values:e},t,n)=>{e[t]=BigInt(n)},eb=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},nb=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},pL=(e,t,n)=>{switch(e.type.unit){case xe.SECOND:return Z0(e,t,n);case xe.MILLISECOND:return tb(e,t,n);case xe.MICROSECOND:return eb(e,t,n);case xe.NANOSECOND:return nb(e,t,n)}},rb=({values:e},t,n)=>{e[t]=n},ib=({values:e},t,n)=>{e[t]=n},sb=({values:e},t,n)=>{e[t]=n},ab=({values:e},t,n)=>{e[t]=n},mL=(e,t,n)=>{switch(e.type.unit){case xe.SECOND:return rb(e,t,n);case xe.MILLISECOND:return ib(e,t,n);case xe.MICROSECOND:return sb(e,t,n);case xe.NANOSECOND:return ab(e,t,n)}},yL=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},gL=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Gi.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},_L=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Gi.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const u of l)if(s(r,a,u),++a>=o)break},vL=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),bL=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),wL=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),SL=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),EL=(e,t,n)=>{const r=e.type.children.map(s=>Gi.getVisitFn(s.type)),i=n instanceof Map?wL(t,n):n instanceof Bn?bL(t,n):Array.isArray(n)?vL(t,n):SL(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},IL=(e,t,n)=>{e.type.mode===qr.Dense?ob(e,t,n):lb(e,t,n)},ob=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Gi.visit(i,e.valueOffsets[t],n)},lb=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Gi.visit(i,t,n)},TL=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},AL=(e,t,n)=>{e.type.unit===xs.DAY_TIME?cb(e,t,n):ub(e,t,n)},cb=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},ub=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},fb=({values:e},t,n)=>{e[t]=n},hb=({values:e},t,n)=>{e[t]=n},pb=({values:e},t,n)=>{e[t]=n},mb=({values:e},t,n)=>{e[t]=n},xL=(e,t,n)=>{switch(e.type.unit){case xe.SECOND:return fb(e,t,n);case xe.MILLISECOND:return hb(e,t,n);case xe.MICROSECOND:return pb(e,t,n);case xe.NANOSECOND:return mb(e,t,n)}},NL=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Gi.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};Ne.prototype.visitBool=Ue(uL),Ne.prototype.visitInt=Ue(da),Ne.prototype.visitInt8=Ue(da),Ne.prototype.visitInt16=Ue(da),Ne.prototype.visitInt32=Ue(da),Ne.prototype.visitInt64=Ue(da),Ne.prototype.visitUint8=Ue(da),Ne.prototype.visitUint16=Ue(da),Ne.prototype.visitUint32=Ue(da),Ne.prototype.visitUint64=Ue(da),Ne.prototype.visitFloat=Ue(dL),Ne.prototype.visitFloat16=Ue(q0),Ne.prototype.visitFloat32=Ue(im),Ne.prototype.visitFloat64=Ue(im),Ne.prototype.visitUtf8=Ue(J0),Ne.prototype.visitLargeUtf8=Ue(J0),Ne.prototype.visitBinary=Ue(Q0),Ne.prototype.visitLargeBinary=Ue(Q0),Ne.prototype.visitFixedSizeBinary=Ue(fL),Ne.prototype.visitDate=Ue(hL),Ne.prototype.visitDateDay=Ue(X0),Ne.prototype.visitDateMillisecond=Ue(K0),Ne.prototype.visitTimestamp=Ue(pL),Ne.prototype.visitTimestampSecond=Ue(Z0),Ne.prototype.visitTimestampMillisecond=Ue(tb),Ne.prototype.visitTimestampMicrosecond=Ue(eb),Ne.prototype.visitTimestampNanosecond=Ue(nb),Ne.prototype.visitTime=Ue(mL),Ne.prototype.visitTimeSecond=Ue(rb),Ne.prototype.visitTimeMillisecond=Ue(ib),Ne.prototype.visitTimeMicrosecond=Ue(sb),Ne.prototype.visitTimeNanosecond=Ue(ab),Ne.prototype.visitDecimal=Ue(yL),Ne.prototype.visitList=Ue(gL),Ne.prototype.visitStruct=Ue(EL),Ne.prototype.visitUnion=Ue(IL),Ne.prototype.visitDenseUnion=Ue(ob),Ne.prototype.visitSparseUnion=Ue(lb),Ne.prototype.visitDictionary=Ue(TL),Ne.prototype.visitInterval=Ue(AL),Ne.prototype.visitIntervalDayTime=Ue(cb),Ne.prototype.visitIntervalYearMonth=Ue(ub),Ne.prototype.visitDuration=Ue(xL),Ne.prototype.visitDurationSecond=Ue(fb),Ne.prototype.visitDurationMillisecond=Ue(hb),Ne.prototype.visitDurationMicrosecond=Ue(pb),Ne.prototype.visitDurationNanosecond=Ue(mb),Ne.prototype.visitFixedSizeList=Ue(NL),Ne.prototype.visitMap=Ue(_L);const Gi=new Ne,ds=Symbol.for("parent"),rl=Symbol.for("rowIndex");class sm{constructor(t,n){return this[ds]=t,this[rl]=n,new Proxy(this,new BL)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[rl],n=this[ds],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=vi.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Ic(t)}: ${Ic(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new RL(this[ds],this[rl])}}class RL{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,vi.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(sm.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ds]:{writable:!0,enumerable:!1,configurable:!1,value:null},[rl]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class BL{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ds].type.children.map(n=>n.name)}has(t,n){return t[ds].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ds].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[ds].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=vi.visit(t[ds].children[r],t[rl]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ds].type.children.findIndex(s=>s.name===n);return i!==-1?(Gi.visit(t[ds].children[i],t[rl],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class ve extends tn{}function Re(e){return(t,n)=>t.getValid(n)?e(t,n):null}const OL=(e,t)=>864e5*e[t],DL=(e,t)=>null,yb=(e,t,n)=>{if(n+1>=t.length)return null;const r=Hn(t[n]),i=Hn(t[n+1]);return e.subarray(r,i)},FL=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},gb=({values:e},t)=>OL(e,t),_b=({values:e},t)=>Hn(e[t]),La=({stride:e,values:t},n)=>t[e*n],LL=({stride:e,values:t},n)=>W0(t[e*n]),vb=({values:e},t)=>e[t],ML=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),bb=({values:e,valueOffsets:t},n)=>yb(e,t,n),wb=({values:e,valueOffsets:t},n)=>{const r=yb(e,t,n);return r!==null?Hp(r):null},CL=({values:e},t)=>e[t],kL=({type:e,values:t},n)=>e.precision!==Xr.HALF?t[n]:W0(t[n]),UL=(e,t)=>e.type.unit===Pi.DAY?gb(e,t):_b(e,t),Sb=({values:e},t)=>1e3*Hn(e[t]),Eb=({values:e},t)=>Hn(e[t]),Ib=({values:e},t)=>b0(e[t],BigInt(1e3)),Tb=({values:e},t)=>b0(e[t],BigInt(1e6)),PL=(e,t)=>{switch(e.type.unit){case xe.SECOND:return Sb(e,t);case xe.MILLISECOND:return Eb(e,t);case xe.MICROSECOND:return Ib(e,t);case xe.NANOSECOND:return Tb(e,t)}},Ab=({values:e},t)=>e[t],xb=({values:e},t)=>e[t],Nb=({values:e},t)=>e[t],Rb=({values:e},t)=>e[t],$L=(e,t)=>{switch(e.type.unit){case xe.SECOND:return Ab(e,t);case xe.MILLISECOND:return xb(e,t);case xe.MICROSECOND:return Nb(e,t);case xe.NANOSECOND:return Rb(e,t)}},VL=({values:e,stride:t},n)=>rm.decimal(e.subarray(t*n,t*(n+1))),zL=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,l=i[0].slice(s,a-s);return new Bn([l])},GL=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new om(a.slice(i,s-i))},jL=(e,t)=>new sm(e,t),YL=(e,t)=>e.type.mode===qr.Dense?Bb(e,t):Ob(e,t),Bb=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return vi.visit(r,e.valueOffsets[t])},Ob=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return vi.visit(r,t)},WL=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},HL=(e,t)=>e.type.unit===xs.DAY_TIME?Db(e,t):Fb(e,t),Db=({values:e},t)=>e.subarray(2*t,2*(t+1)),Fb=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},Lb=({values:e},t)=>e[t],Mb=({values:e},t)=>e[t],Cb=({values:e},t)=>e[t],kb=({values:e},t)=>e[t],qL=(e,t)=>{switch(e.type.unit){case xe.SECOND:return Lb(e,t);case xe.MILLISECOND:return Mb(e,t);case xe.MICROSECOND:return Cb(e,t);case xe.NANOSECOND:return kb(e,t)}},XL=(e,t)=>{const{stride:n,children:r}=e,s=r[0].slice(t*n,n);return new Bn([s])};ve.prototype.visitNull=Re(DL),ve.prototype.visitBool=Re(FL),ve.prototype.visitInt=Re(CL),ve.prototype.visitInt8=Re(La),ve.prototype.visitInt16=Re(La),ve.prototype.visitInt32=Re(La),ve.prototype.visitInt64=Re(vb),ve.prototype.visitUint8=Re(La),ve.prototype.visitUint16=Re(La),ve.prototype.visitUint32=Re(La),ve.prototype.visitUint64=Re(vb),ve.prototype.visitFloat=Re(kL),ve.prototype.visitFloat16=Re(LL),ve.prototype.visitFloat32=Re(La),ve.prototype.visitFloat64=Re(La),ve.prototype.visitUtf8=Re(wb),ve.prototype.visitLargeUtf8=Re(wb),ve.prototype.visitBinary=Re(bb),ve.prototype.visitLargeBinary=Re(bb),ve.prototype.visitFixedSizeBinary=Re(ML),ve.prototype.visitDate=Re(UL),ve.prototype.visitDateDay=Re(gb),ve.prototype.visitDateMillisecond=Re(_b),ve.prototype.visitTimestamp=Re(PL),ve.prototype.visitTimestampSecond=Re(Sb),ve.prototype.visitTimestampMillisecond=Re(Eb),ve.prototype.visitTimestampMicrosecond=Re(Ib),ve.prototype.visitTimestampNanosecond=Re(Tb),ve.prototype.visitTime=Re($L),ve.prototype.visitTimeSecond=Re(Ab),ve.prototype.visitTimeMillisecond=Re(xb),ve.prototype.visitTimeMicrosecond=Re(Nb),ve.prototype.visitTimeNanosecond=Re(Rb),ve.prototype.visitDecimal=Re(VL),ve.prototype.visitList=Re(zL),ve.prototype.visitStruct=Re(jL),ve.prototype.visitUnion=Re(YL),ve.prototype.visitDenseUnion=Re(Bb),ve.prototype.visitSparseUnion=Re(Ob),ve.prototype.visitDictionary=Re(WL),ve.prototype.visitInterval=Re(HL),ve.prototype.visitIntervalDayTime=Re(Db),ve.prototype.visitIntervalYearMonth=Re(Fb),ve.prototype.visitDuration=Re(qL),ve.prototype.visitDurationSecond=Re(Lb),ve.prototype.visitDurationMillisecond=Re(Mb),ve.prototype.visitDurationMicrosecond=Re(Cb),ve.prototype.visitDurationNanosecond=Re(kb),ve.prototype.visitFixedSizeList=Re(XL),ve.prototype.visitMap=Re(GL);const vi=new ve,il=Symbol.for("keys"),sl=Symbol.for("vals"),al=Symbol.for("kKeysAsStrings"),am=Symbol.for("_kKeysAsStrings");class om{constructor(t){return this[il]=new Bn([t.children[0]]).memoize(),this[sl]=t.children[1],new Proxy(this,new QL)}get[al](){return this[am]||(this[am]=Array.from(this[il].toArray(),String))}[Symbol.iterator](){return new KL(this[il],this[sl])}get size(){return this[il].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[il],n=this[sl],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=vi.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Ic(t)}: ${Ic(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class KL{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),vi.visit(this.vals,t)]})}}class QL{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[al]}has(t,n){return t[al].includes(n)}getOwnPropertyDescriptor(t,n){if(t[al].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[al].indexOf(n);if(r!==-1){const i=vi.visit(Reflect.get(t,sl),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[al].indexOf(n);return i!==-1?(Gi.visit(Reflect.get(t,sl),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(om.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[il]:{writable:!0,enumerable:!1,configurable:!1,value:null},[sl]:{writable:!0,enumerable:!1,configurable:!1,value:null},[am]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Ub;function Pb(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(Ub=s,s=a,a=Ub),a>i&&(a=i),r?r(e,s,a):[s,a]}const lm=(e,t)=>e<0?t+e:e,$b=e=>e!==e;function ol(e){if(typeof e!=="object"||e===null)return $b(e)?$b:n=>n===e;if(e instanceof Date){const n=e.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(e)?n=>n?KF(e,n):!1:e instanceof Map?ZL(e):Array.isArray(e)?JL(e):e instanceof Bn?tM(e):eM(e,!0)}function JL(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=ol(e[n]);return jd(t)}function ZL(e){let t=-1;const n=[];for(const r of e.values())n[++t]=ol(r);return jd(n)}function tM(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=ol(e.get(n));return jd(t)}function eM(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=ol(e[n[i]]);return jd(r,n)}function jd(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return nM(e,n);case Map:return Vb(e,n,n.keys());case om:case sm:case Object:case void 0:return Vb(e,n,t||Object.keys(n))}return n instanceof Bn?rM(e,n):!1}}function nM(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function rM(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Vb(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),u=r.next(),d=i.next();for(;a<o&&!u.done&&!d.done&&!l.done&&!(u.value!==d.value||!e[a](l.value));++a,u=r.next(),d=i.next(),l=s.next());return a===o&&u.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function zb(e,t,n,r){return(n&1<<r)!==0}function iM(e,t,n,r){return(n&1<<r)>>r}function Yd(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):Wd(new cm(n,e,t,null,zb)).subarray(0,r)),i}return n}function Wd(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class cm{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function um(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new cm(e,t,n-t,e,iM))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return um(e,t,i)+um(e,r,n)+sM(e,i>>3,r-i>>3)}function sM(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=dm(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=dm(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=dm(s.getUint8(i)),i+=1;return r}function dm(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const aM=-1;class Un{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return ce.isSparseUnion(t)?this.children.some(n=>n.nullable):ce.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(ce.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=aM&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-um(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof Un?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=ua(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(ce.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===qr.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(ce.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===qr.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,u=1<<l%8,d=l>>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Yd(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[d];r=(h&u)!==0,s[d]=n?h|u:h&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new Un(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===D.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Yd(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[ca.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[ca.TYPE])&&(a[ca.TYPE]=s.subarray(t,t+n)),(s=a[ca.OFFSET])&&(a[ca.OFFSET]=s.subarray(t,t+n+1))||(s=a[ca.DATA])&&(a[ca.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}Un.prototype.children=Object.freeze([]);class Nc extends tn{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new Un(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=Ec(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=s0(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=Ec(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=s0(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=un(t.nullBitmap),a=Ec(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=un(t.nullBitmap),{length:a=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=kn(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(ce.isSparseUnion(n))return new Un(n,r,a,o,[void 0,void 0,void 0,s],i);const l=Ec(t.valueOffsets);return new Un(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.indices.ArrayType,t.data),{["dictionary"]:a=new Bn([new Nc().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=kn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Nc().visit({type:n.valueType})}=t,s=un(t.nullBitmap),{["length"]:a=i.length/ua(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Un(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Nc().visit({type:n.childType})}=t,s=un(t.nullBitmap),a=Ec(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Un(n,r,o,l,[a,void 0,s],[i])}}const oM=new Nc;function sn(e){return oM.visit(e)}class Gb{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function lM(e){return e.some(t=>t.nullable)}function jb(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Yb(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function Wb(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:u}=o;if(l>=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(o);continue}const d=Math.max(0,n-l),h=Math.min(r-l,u);i.push(o.slice(d,h-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function fm(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function hm(e,t){return e.getValid(t)}function Hd(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return fm(r,this._offsets,n,t)}}function Hb(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=fm(s,this._offsets,r,n);return t=void 0,a}}function qb(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let u=i-1,d=r.length;++u<d;){const h=r[u];if(~(o=e(h,t,a)))return l+o;a=0,l+=h.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):fm(s,this._offsets,i,n);return t=void 0,a}}class be extends tn{}function cM(e,t){return t===null&&e.length>0?0:-1}function uM(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new cm(n,e.offset+(t||0),e.length,n,zb)){if(!i)return r;++r}return-1}function Ve(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case D.Union:break;case D.Dictionary:break;default:return uM(e,n)}const r=vi.getVisitFn(e),i=ol(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function Xb(e,t,n){const r=vi.getVisitFn(e),i=ol(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}be.prototype.visitNull=cM,be.prototype.visitBool=Ve,be.prototype.visitInt=Ve,be.prototype.visitInt8=Ve,be.prototype.visitInt16=Ve,be.prototype.visitInt32=Ve,be.prototype.visitInt64=Ve,be.prototype.visitUint8=Ve,be.prototype.visitUint16=Ve,be.prototype.visitUint32=Ve,be.prototype.visitUint64=Ve,be.prototype.visitFloat=Ve,be.prototype.visitFloat16=Ve,be.prototype.visitFloat32=Ve,be.prototype.visitFloat64=Ve,be.prototype.visitUtf8=Ve,be.prototype.visitLargeUtf8=Ve,be.prototype.visitBinary=Ve,be.prototype.visitLargeBinary=Ve,be.prototype.visitFixedSizeBinary=Ve,be.prototype.visitDate=Ve,be.prototype.visitDateDay=Ve,be.prototype.visitDateMillisecond=Ve,be.prototype.visitTimestamp=Ve,be.prototype.visitTimestampSecond=Ve,be.prototype.visitTimestampMillisecond=Ve,be.prototype.visitTimestampMicrosecond=Ve,be.prototype.visitTimestampNanosecond=Ve,be.prototype.visitTime=Ve,be.prototype.visitTimeSecond=Ve,be.prototype.visitTimeMillisecond=Ve,be.prototype.visitTimeMicrosecond=Ve,be.prototype.visitTimeNanosecond=Ve,be.prototype.visitDecimal=Ve,be.prototype.visitList=Ve,be.prototype.visitStruct=Ve,be.prototype.visitUnion=Ve,be.prototype.visitDenseUnion=Xb,be.prototype.visitSparseUnion=Xb,be.prototype.visitDictionary=Ve,be.prototype.visitInterval=Ve,be.prototype.visitIntervalDayTime=Ve,be.prototype.visitIntervalYearMonth=Ve,be.prototype.visitDuration=Ve,be.prototype.visitDurationSecond=Ve,be.prototype.visitDurationMillisecond=Ve,be.prototype.visitDurationMicrosecond=Ve,be.prototype.visitDurationNanosecond=Ve,be.prototype.visitFixedSizeList=Ve,be.prototype.visitMap=Ve;const qd=new be;class we extends tn{}function Be(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(ce.isInt(t)&&t.bitWidth!==64||ce.isTime(t)&&t.bitWidth!==64||ce.isFloat(t)&&t.precision!==Xr.HALF))return new Gb(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Gb(e.data.length,r=>{const s=e.data[r].length,a=e.slice(n,n+s);return n+=s,new dM(a)})}class dM{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}we.prototype.visitNull=Be,we.prototype.visitBool=Be,we.prototype.visitInt=Be,we.prototype.visitInt8=Be,we.prototype.visitInt16=Be,we.prototype.visitInt32=Be,we.prototype.visitInt64=Be,we.prototype.visitUint8=Be,we.prototype.visitUint16=Be,we.prototype.visitUint32=Be,we.prototype.visitUint64=Be,we.prototype.visitFloat=Be,we.prototype.visitFloat16=Be,we.prototype.visitFloat32=Be,we.prototype.visitFloat64=Be,we.prototype.visitUtf8=Be,we.prototype.visitLargeUtf8=Be,we.prototype.visitBinary=Be,we.prototype.visitLargeBinary=Be,we.prototype.visitFixedSizeBinary=Be,we.prototype.visitDate=Be,we.prototype.visitDateDay=Be,we.prototype.visitDateMillisecond=Be,we.prototype.visitTimestamp=Be,we.prototype.visitTimestampSecond=Be,we.prototype.visitTimestampMillisecond=Be,we.prototype.visitTimestampMicrosecond=Be,we.prototype.visitTimestampNanosecond=Be,we.prototype.visitTime=Be,we.prototype.visitTimeSecond=Be,we.prototype.visitTimeMillisecond=Be,we.prototype.visitTimeMicrosecond=Be,we.prototype.visitTimeNanosecond=Be,we.prototype.visitDecimal=Be,we.prototype.visitList=Be,we.prototype.visitStruct=Be,we.prototype.visitUnion=Be,we.prototype.visitDenseUnion=Be,we.prototype.visitSparseUnion=Be,we.prototype.visitDictionary=Be,we.prototype.visitInterval=Be,we.prototype.visitIntervalDayTime=Be,we.prototype.visitIntervalYearMonth=Be,we.prototype.visitDuration=Be,we.prototype.visitDurationSecond=Be,we.prototype.visitDurationMillisecond=Be,we.prototype.visitDurationMicrosecond=Be,we.prototype.visitDurationNanosecond=Be,we.prototype.visitFixedSizeList=Be,we.prototype.visitMap=Be;const pm=new we;var Kb;const Qb={},Jb={};class Bn{constructor(t){var n,r,i;const s=t[0]instanceof Bn?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof Un)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:u}=Qb[a.typeId],d=s[0];this.isValid=h=>hm(d,h),this.get=h=>o(d,h),this.set=(h,y)=>l(d,h,y),this.indexOf=h=>u(d,h),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,Jb[a.typeId]),this._offsets=Yb(s);break}this.data=s,this.type=a,this.stride=ua(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return lM(this.data)}get nullCount(){return jb(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${D[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(lm(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return pm.visit(this)}concat(...t){return new Bn(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new Bn(Pb(this,t,n,({data:r,_offsets:i},s,a)=>Wb(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case D.Int:case D.Float:case D.Decimal:case D.Time:case D.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new Bn(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return ce.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(ce.isDictionary(this.type)){const t=new Xd(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new Bn(n)}return new Xd(this)}unmemoize(){if(ce.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new Bn(n)}return this}}Kb=Symbol.toStringTag,Bn[Kb]=(e=>{e.type=ce.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(D).map(n=>D[n]).filter(n=>typeof n=="number"&&n!==D.NONE);for(const n of t){const r=vi.getVisitFnByTypeId(n),i=Gi.getVisitFnByTypeId(n),s=qd.getVisitFnByTypeId(n);Qb[n]={get:r,set:i,indexOf:s},Jb[n]=Object.create(e,{isValid:{value:Hd(hm)},get:{value:Hd(vi.getVisitFnByTypeId(n))},set:{value:Hb(Gi.getVisitFnByTypeId(n))},indexOf:{value:qb(qd.getVisitFnByTypeId(n))}})}return"Vector"})(Bn.prototype);class Xd extends Bn{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new Xd(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Bn(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class mm{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Oi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Oi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Rn),(n||new Oi).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Sr.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Os).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new mm).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new mm).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Or).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,Sr.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class On{constructor(t=[],n,r,i=Sr.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=ym(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new On(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new On(n,this.metadata)}assign(...t){const n=t[0]instanceof On?t[0]:Array.isArray(t[0])?new On(t[0]):new On(t),r=[...this.fields],i=Kd(Kd(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(u=>u.name===o.name);return~l?(r[l]=o.clone({metadata:Kd(Kd(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=ym(s,new Map);return new On([...r,...s],i,new Map([...this.dictionaries,...a]))}}On.prototype.fields=null,On.prototype.metadata=null,On.prototype.dictionaries=null;class nr{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new nr(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],nr.new(n,r,i,s)}}nr.prototype.type=null,nr.prototype.name=null,nr.prototype.nullable=null,nr.prototype.metadata=null;function Kd(e,t){return new Map([...e||new Map,...t||new Map])}function ym(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const s=e[n].type;if(ce.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&ym(s.children,t)}return t}var fM=u0,hM=qo;class Rc{static decode(t){t=new hM(un(t));const n=Oi.getRootAsFooter(t),r=On.decode(n.schema(),new Map,n.version());return new pM(r,n)}static encode(t){const n=new fM,r=On.encode(n,t.schema);Oi.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Ma.encode(n,a);const i=n.endVector();Oi.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Ma.encode(n,a);const s=n.endVector();return Oi.startFooter(n),Oi.addSchema(n,r),Oi.addVersion(n,Sr.V5),Oi.addRecordBatches(n,i),Oi.addDictionaries(n,s),Oi.finishFooterBuffer(n,Oi.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=Sr.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class pM extends Rc{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Ma.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Ma.decode(n)}return null}}class Ma{static decode(t){return new Ma(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return mm.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=Hn(r),this.bodyLength=Hn(n)}}const ur=Object.freeze({done:!0,value:void 0});class Zb{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class gm{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class mM extends gm{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Ge(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(ur);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Ui.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Ui.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Ge(this,void 0,void 0,function*(){return yield this.abort(t),ur})}return(t){return Ge(this,void 0,void 0,function*(){return yield this.close(),ur})}read(t){return Ge(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ge(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(ur)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Qd extends mM{write(t){if((t=un(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Hp(this.toUint8Array(!0)):this.toUint8Array(!1).then(Hp)}toUint8Array(t=!1){return t?As(this._values)[0]:Ge(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,u=po(this),d;d=yield u.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const h=s;a.push(h),o+=h.byteLength}}catch(h){r={error:h}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return As(a,o)[0]})}}class Jd{constructor(t){t&&(this.source=new yM(Ui.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class ll{constructor(t){t instanceof ll?this.source=t.source:t instanceof Qd?this.source=new _o(Ui.fromAsyncIterable(t)):r0(t)?this.source=new _o(Ui.fromNodeStream(t)):Kp(t)?this.source=new _o(Ui.fromDOMStream(t)):n0(t)?this.source=new _o(Ui.fromDOMStream(t.body)):Sc(t)?this.source=new _o(Ui.fromIterable(t)):mo(t)?this.source=new _o(Ui.fromAsyncIterable(t)):Ho(t)&&(this.source=new _o(Ui.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class yM{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||ur)}return(t){return Object.create(this.source.return&&this.source.return(t)||ur)}}class _o{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Ge(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Ge(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Ge(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Ge(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Ge(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||ur;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Ge(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||ur;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class tw extends Jd{constructor(t,n){super(),this.position=0,this.buffer=un(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class Zd extends ll{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Ge(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Ge(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return Ge(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return Ge(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),u=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<u.byteLength;)({bytesRead:o}=yield n.read(u,a,u.byteLength-a,s));return u}return null})}readAt(t,n){return Ge(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Ge(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Ge(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Ge(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const gM=65536;function cl(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const ul=8,_m=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class ew{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?gM:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${cl(this.buffer[1])} ${cl(this.buffer[0])}`}}class Pn extends ew{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return Pn.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Pn.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new Pn(n);for(let s=0;s<r;){const a=ul<r-s?ul:r-s,o=new Pn(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new Pn(new Uint32Array([_m[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Pn.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Pn(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Pn(new Uint32Array(t.buffer)).plus(n)}}class bi extends ew{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return bi.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return bi.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new bi(n);for(let a=r?1:0;a<i;){const o=ul<i-a?ul:i-a,l=new bi(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),u=new bi(new Uint32Array([_m[o],0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)bi.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new bi(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new bi(new Uint32Array(t.buffer)).plus(n)}}class Ds{constructor(t){this.buffer=t}high(){return new bi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new bi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){const n=new Pn(new Uint32Array([this.buffer[3],0])),r=new Pn(new Uint32Array([this.buffer[2],0])),i=new Pn(new Uint32Array([this.buffer[1],0])),s=new Pn(new Uint32Array([this.buffer[0],0])),a=new Pn(new Uint32Array([t.buffer[3],0])),o=new Pn(new Uint32Array([t.buffer[2],0])),l=new Pn(new Uint32Array([t.buffer[1],0])),u=new Pn(new Uint32Array([t.buffer[0],0]));let d=Pn.multiply(s,u);this.buffer[0]=d.low();const h=new Pn(new Uint32Array([d.high(),0]));return d=Pn.multiply(i,u),h.plus(d),d=Pn.multiply(s,l),h.plus(d),this.buffer[1]=h.low(),this.buffer[3]=h.lessThan(d)?1:0,this.buffer[2]=h.high(),new Pn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Pn.multiply(r,u)).plus(Pn.multiply(i,l)).plus(Pn.multiply(s,o)),this.buffer[3]+=Pn.multiply(n,u).plus(Pn.multiply(r,l)).plus(Pn.multiply(i,o)).plus(Pn.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${cl(this.buffer[3])} ${cl(this.buffer[2])} ${cl(this.buffer[1])} ${cl(this.buffer[0])}`}static multiply(t,n){return new Ds(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Ds(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return Ds.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return Ds.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new Ds(n);for(let a=r?1:0;a<i;){const o=ul<i-a?ul:i-a,l=new Ds(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),u=new Ds(new Uint32Array([_m[o],0,0,0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)Ds.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class nw extends tn{constructor(t,n,r,i,s=Sr.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof nr?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return sn({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<Sr.V5&&this.readNullBitmap(t,r),t.mode===qr.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return sn({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class _M extends nw{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):Wd(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return kn(Uint8Array,kn(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return kn(Uint8Array,kn(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return ce.isTimestamp(t)||(ce.isInt(t)||ce.isTime(t))&&t.bitWidth===64||ce.isDuration(t)||ce.isDate(t)&&t.unit===Pi.MILLISECOND?kn(Uint8Array,bi.convertArray(r[n])):ce.isDecimal(t)?kn(Uint8Array,Ds.convertArray(r[n])):ce.isBinary(t)||ce.isLargeBinary(t)||ce.isFixedSizeBinary(t)?vM(r[n]):ce.isBool(t)?Wd(r[n]):ce.isUtf8(t)||ce.isLargeUtf8(t)?qp(r[n].join("")):kn(Uint8Array,kn(t.ArrayType,r[n].map(i=>+i)))}}function vM(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class Se extends tn{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function ii(e,t){return t instanceof e.constructor}function vo(e,t){return e===t||ii(e,t)}function fa(e,t){return e===t||ii(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function tf(e,t){return e===t||ii(e,t)&&e.precision===t.precision}function bM(e,t){return e===t||ii(e,t)&&e.byteWidth===t.byteWidth}function vm(e,t){return e===t||ii(e,t)&&e.unit===t.unit}function Bc(e,t){return e===t||ii(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Oc(e,t){return e===t||ii(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function wM(e,t){return e===t||ii(e,t)&&e.children.length===t.children.length&&Ca.compareManyFields(e.children,t.children)}function SM(e,t){return e===t||ii(e,t)&&e.children.length===t.children.length&&Ca.compareManyFields(e.children,t.children)}function bm(e,t){return e===t||ii(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&Ca.compareManyFields(e.children,t.children)}function EM(e,t){return e===t||ii(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Ca.visit(e.indices,t.indices)&&Ca.visit(e.dictionary,t.dictionary)}function wm(e,t){return e===t||ii(e,t)&&e.unit===t.unit}function Dc(e,t){return e===t||ii(e,t)&&e.unit===t.unit}function IM(e,t){return e===t||ii(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Ca.compareManyFields(e.children,t.children)}function TM(e,t){return e===t||ii(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Ca.compareManyFields(e.children,t.children)}Se.prototype.visitNull=vo,Se.prototype.visitBool=vo,Se.prototype.visitInt=fa,Se.prototype.visitInt8=fa,Se.prototype.visitInt16=fa,Se.prototype.visitInt32=fa,Se.prototype.visitInt64=fa,Se.prototype.visitUint8=fa,Se.prototype.visitUint16=fa,Se.prototype.visitUint32=fa,Se.prototype.visitUint64=fa,Se.prototype.visitFloat=tf,Se.prototype.visitFloat16=tf,Se.prototype.visitFloat32=tf,Se.prototype.visitFloat64=tf,Se.prototype.visitUtf8=vo,Se.prototype.visitLargeUtf8=vo,Se.prototype.visitBinary=vo,Se.prototype.visitLargeBinary=vo,Se.prototype.visitFixedSizeBinary=bM,Se.prototype.visitDate=vm,Se.prototype.visitDateDay=vm,Se.prototype.visitDateMillisecond=vm,Se.prototype.visitTimestamp=Bc,Se.prototype.visitTimestampSecond=Bc,Se.prototype.visitTimestampMillisecond=Bc,Se.prototype.visitTimestampMicrosecond=Bc,Se.prototype.visitTimestampNanosecond=Bc,Se.prototype.visitTime=Oc,Se.prototype.visitTimeSecond=Oc,Se.prototype.visitTimeMillisecond=Oc,Se.prototype.visitTimeMicrosecond=Oc,Se.prototype.visitTimeNanosecond=Oc,Se.prototype.visitDecimal=vo,Se.prototype.visitList=wM,Se.prototype.visitStruct=SM,Se.prototype.visitUnion=bm,Se.prototype.visitDenseUnion=bm,Se.prototype.visitSparseUnion=bm,Se.prototype.visitDictionary=EM,Se.prototype.visitInterval=wm,Se.prototype.visitIntervalDayTime=wm,Se.prototype.visitIntervalYearMonth=wm,Se.prototype.visitDuration=Dc,Se.prototype.visitDurationSecond=Dc,Se.prototype.visitDurationMillisecond=Dc,Se.prototype.visitDurationMicrosecond=Dc,Se.prototype.visitDurationNanosecond=Dc,Se.prototype.visitFixedSizeList=IM,Se.prototype.visitMap=TM;const Ca=new Se;function Sm(e,t){return Ca.compareSchemas(e,t)}function Em(e,t){return AM(e,t.map(n=>n.data.concat()))}function AM(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((h,y)=>Math.max(h,y.length),0)};let s=0,a=0,o=-1;const l=t.length;let u,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=u=t[o].shift(),a=Math.min(a,u?u.length:a);Number.isFinite(a)&&(d=xM(n,a,d,t,i),a>0&&(r[s++]=sn({type:new ri(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(h=>new wi(e,h))]}function xM(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const u=n[o],d=u==null?void 0:u.length;if(d>=t)d===t?n[o]=u:(n[o]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(u.slice(t,d-t))));else{const h=e[o];e[o]=h.clone({nullable:!0}),n[o]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:sn({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var rw;class si{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new On([]),this._offsets=[0],this;let i,s;t[0]instanceof On&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof wi)return[l];if(l instanceof si)return l.batches;if(l instanceof Un){if(l.type instanceof ri)return[new wi(new On(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>a(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>a(u));if(typeof l=="object"){const u=Object.keys(l),d=u.map(S=>new Bn([l[S]])),h=i??new On(u.map((S,M)=>new nr(String(S),d[M].type,d[M].nullable))),[,y]=Em(h,d);return y.length===0?[new wi(l)]:y}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new On([]),!(i instanceof On))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof wi))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Sm(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Yb(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jb(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(lm(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?pm.visit(new Bn(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
96
96
  ${this.toArray().join(`,
97
97
  `)}
98
- ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new ni(n,r.map(i=>new gi(n,i)))}slice(t,n){const r=this.schema;[t,n]=l0({length:this.numRows},t,n);const i=m0(this.data,this._offsets,t,n);return new ni(r,i.map(s=>new gi(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=sn({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new En(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new En([sn({type:new Oa,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,u)=>this.getChildAt(u));[s[t],o[t]]=[a,n],[r,i]=am(r,o)}return new ni(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new ni(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,u)=>{const[f,p]=o,E=n.findIndex(T=>T.name===l.name);return~E?p[E]=u:f.push(u),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new ni(...am(s,a))}}A0=Symbol.toStringTag,ni[A0]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Vd(Kp),e.get=Vd(mi.getVisitFn(B.Struct)),e.set=y0(zi.getVisitFn(B.Struct)),e.indexOf=g0(zd.getVisitFn(B.Struct)),"Table"))(ni.prototype);var x0;let gi=class fu{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof In))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=sn({nullCount:0,type:new ti(this.schema.fields),children:this.schema.fields.map(n=>sn({type:n.type,nullCount:0}))})]=t,!(this.data instanceof On))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=R0(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,f)=>(l.children[f]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[f]=Xn.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new In(r),o=sn({type:new ti(r),length:s,children:i,nullCount:0});[this.schema,this.data]=R0(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=N0(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mi.visit(this.data,t)}at(t){return this.get(Yp(t,this.numRows))}set(t,n){return zi.visit(this.data,t,n)}indexOf(t,n){return zd.visit(this.data,t,n)}[Symbol.iterator](){return Qp.visit(new En([this.data]))}toArray(){return[...this]}concat(...t){return new ni(this.schema,[this,...t])}slice(t,n){const[r]=new En([this.data]).slice(t,n).data;return new fu(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new En([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new En([sn({type:new Oa,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new In(s,new Map(this.schema.metadata)),i=sn({type:new ti(s),children:a})}return new fu(r,i)}select(t){const n=this.schema.select(t),r=new ti(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new fu(n,sn({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=sn({type:new ti(n.fields),length:this.numRows,children:r});return new fu(n,i)}};x0=Symbol.toStringTag,gi[x0]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(gi.prototype);function R0(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const u=t[o];(!u||u.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=u==null?void 0:u._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:sn({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),sn({type:new ti(i),length:n,children:s})]}function N0(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const u of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])N0(o.children,u==null?void 0:u.children,n);if(ae.isDictionary(o)){const{id:u}=o;if(!n.has(u))l!=null&&l.dictionary&&n.set(u,l.dictionary);else if(n.get(u)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class om extends gi{constructor(t){const n=t.fields.map(i=>sn({type:i.type})),r=sn({type:new ti(t.fields),nullCount:0,children:n});super(t,r)}}let Ma=class Hs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new Hs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Sn),(n||new Hs).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mr.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):pn.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Ir).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,mr.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,pn.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return Hs.startMessage(t),Hs.addVersion(t,n),Hs.addHeaderType(t,r),Hs.addHeader(t,i),Hs.addBodyLength(t,s),Hs.addCustomMetadata(t,a),Hs.endMessage(t)}};class OL extends tn{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return zv.startNull(n),zv.endNull(n)}visitInt(t,n){return Ri.startInt(n),Ri.addBitWidth(n,t.bitWidth),Ri.addIsSigned(n,t.isSigned),Ri.endInt(n)}visitFloat(t,n){return As.startFloatingPoint(n),As.addPrecision(n,t.precision),As.endFloatingPoint(n)}visitBinary(t,n){return kv.startBinary(n),kv.endBinary(n)}visitLargeBinary(t,n){return Pv.startLargeBinary(n),Pv.endLargeBinary(n)}visitBool(t,n){return Uv.startBool(n),Uv.endBool(n)}visitUtf8(t,n){return Gv.startUtf8(n),Gv.endUtf8(n)}visitLargeUtf8(t,n){return $v.startLargeUtf8(n),$v.endLargeUtf8(n)}visitDecimal(t,n){return Ho.startDecimal(n),Ho.addScale(n,t.scale),Ho.addPrecision(n,t.precision),Ho.addBitWidth(n,t.bitWidth),Ho.endDecimal(n)}visitDate(t,n){return yd.startDate(n),yd.addUnit(n,t.unit),yd.endDate(n)}visitTime(t,n){return Pi.startTime(n),Pi.addUnit(n,t.unit),Pi.addBitWidth(n,t.bitWidth),Pi.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return $i.startTimestamp(n),$i.addUnit(n,t.unit),r!==void 0&&$i.addTimezone(n,r),$i.endTimestamp(n)}visitInterval(t,n){return xs.startInterval(n),xs.addUnit(n,t.unit),xs.endInterval(n)}visitDuration(t,n){return gd.startDuration(n),gd.addUnit(n,t.unit),gd.endDuration(n)}visitList(t,n){return Vv.startList(n),Vv.endList(n)}visitStruct(t,n){return ho.startStruct_(n),ho.endStruct_(n)}visitUnion(t,n){pi.startTypeIdsVector(n,t.typeIds.length);const r=pi.createTypeIdsVector(n,t.typeIds);return pi.startUnion(n),pi.addMode(n,t.mode),pi.addTypeIds(n,r),pi.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return sa.startDictionaryEncoding(n),sa.addId(n,BigInt(t.id)),sa.addIsOrdered(n,t.isOrdered),r!==void 0&&sa.addIndexType(n,r),sa.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return _d.startFixedSizeBinary(n),_d.addByteWidth(n,t.byteWidth),_d.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return vd.startFixedSizeList(n),vd.addListSize(n,t.listSize),vd.endFixedSizeList(n)}visitMap(t,n){return bd.startMap(n),bd.addKeysSorted(n,t.keysSorted),bd.endMap(n)}}const lm=new OL;function DL(e,t=new Map){return new In(LL(e,t),Xd(e.metadata),t)}function B0(e){return new Bi(e.count,D0(e.columns),F0(e.columns))}function FL(e){return new Bs(B0(e.data),e.id,e.isDelta)}function LL(e,t){return(e.fields||[]).filter(Boolean).map(n=>Xn.fromJSON(n,t))}function O0(e,t){return(e.children||[]).filter(Boolean).map(n=>Xn.fromJSON(n,t))}function D0(e){return(e||[]).reduce((t,n)=>[...t,new Ca(n.count,ML(n.VALIDITY)),...D0(n.children)],[])}function F0(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new Os(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new Os(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new Os(t.length,i.OFFSET.length)),i.DATA&&t.push(new Os(t.length,i.DATA.length)),t=F0(i.children,t)}return t}function ML(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function CL(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=M0(e,O0(e,t)),i=new Xn(e.name,a,e.nullable,Xd(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?L0(r):new wc,o=new Ko(t.get(n),r,n,s.isOrdered),i=new Xn(e.name,o,e.nullable,Xd(e.metadata))):(r=(r=s.indexType)?L0(r):new wc,t.set(n,a=M0(e,O0(e,t))),o=new Ko(a,r,n,s.isOrdered),i=new Xn(e.name,o,e.nullable,Xd(e.metadata))),i||null}function Xd(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function L0(e){return new po(e.isSigned,e.bitWidth)}function M0(e,t){const n=e.type.name;switch(n){case"NONE":return new Oa;case"null":return new Oa;case"binary":return new Sd;case"largebinary":return new Ed;case"utf8":return new Id;case"largeutf8":return new Td;case"bool":return new Ad;case"list":return new Fd((t||[])[0]);case"struct":return new ti(t||[]);case"struct_":return new ti(t||[])}switch(n){case"int":{const r=e.type;return new po(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new wd(Yr[r.precision])}case"decimal":{const r=e.type;return new xd(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new Rd(Ui[r.unit])}case"time":{const r=e.type;return new Nd(Ie[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Bd(Ie[r.unit],r.timezone)}case"interval":{const r=e.type;return new Od(Is[r.unit])}case"duration":{const r=e.type;return new Dd(Ie[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Ld(jr[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Md(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Cd(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new kd((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var kL=Lv,UL=jo;class ri{static fromJSON(t,n){const r=new ri(0,mr.V5,n);return r._createHeader=PL(t,n),r}static decode(t){t=new UL(cn(t));const n=Ma.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new ri(r,i,s);return a._createHeader=$L(n,s),a}static encode(t){const n=new kL;let r=-1;return t.isSchema()?r=In.encode(n,t.header()):t.isRecordBatch()?r=Bi.encode(n,t.header()):t.isDictionaryBatch()&&(r=Bs.encode(n,t.header())),Ma.startMessage(n),Ma.addVersion(n,mr.V5),Ma.addHeader(n,r),Ma.addHeaderType(n,t.headerType),Ma.addBodyLength(n,BigInt(t.bodyLength)),Ma.finishMessageBuffer(n,Ma.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof In)return new ri(0,mr.V5,pn.Schema,t);if(t instanceof Bi)return new ri(n,mr.V5,pn.RecordBatch,t);if(t instanceof Bs)return new ri(n,mr.V5,pn.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===pn.Schema}isRecordBatch(){return this.headerType===pn.RecordBatch}isDictionaryBatch(){return this.headerType===pn.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=zn(t)}}class Bi{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=zn(t)}}class Bs{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,n,r=!1){this._data=t,this._isDelta=r,this._id=zn(n)}}class Os{constructor(t,n){this.offset=zn(t),this.length=zn(n)}}class Ca{constructor(t,n){this.length=zn(t),this.nullCount=zn(n)}}function PL(e,t){return(()=>{switch(t){case pn.Schema:return In.fromJSON(e);case pn.RecordBatch:return Bi.fromJSON(e);case pn.DictionaryBatch:return Bs.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${pn[t]}, type: ${t} }`)})}function $L(e,t){return(()=>{switch(t){case pn.Schema:return In.decode(e.header(new Rs),new Map,e.version());case pn.RecordBatch:return Bi.decode(e.header(new ia),e.version());case pn.DictionaryBatch:return Bs.decode(e.header(new Yo),e.version())}throw new Error(`Unrecognized Message type: { name: ${pn[t]}, type: ${t} }`)})}Xn.encode=QL,Xn.decode=XL,Xn.fromJSON=CL,In.encode=KL,In.decode=VL,In.fromJSON=DL,Bi.encode=JL,Bi.decode=zL,Bi.fromJSON=B0,Bs.encode=ZL,Bs.decode=GL,Bs.fromJSON=FL,Ca.encode=tM,Ca.decode=YL,Os.encode=eM,Os.decode=jL;function VL(e,t=new Map,n=mr.V5){const r=qL(e,t);return new In(r,Kd(e),t,n)}function zL(e,t=mr.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new Bi(e.length(),WL(e),HL(e,t))}function GL(e,t=mr.V5){return new Bs(Bi.decode(e.data(),t),e.id(),e.isDelta())}function jL(e){return new Os(e.offset(),e.length())}function YL(e){return new Ca(e.length(),e.nullCount())}function WL(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Ca.decode(n));return t}function HL(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<mr.V4&&(r.bb_pos+=8*(i+1)),n[++s]=Os.decode(r));return n}function qL(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=Xn.decode(r,t));return n}function C0(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=Xn.decode(r,t));return n}function XL(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=U0(e,C0(e,t)),r=new Xn(e.name(),i,e.nullable(),Kd(e))):t.has(n=zn(o.id()))?(s=(s=o.indexType())?k0(s):new wc,a=new Ko(t.get(n),s,n,o.isOrdered()),r=new Xn(e.name(),a,e.nullable(),Kd(e))):(s=(s=o.indexType())?k0(s):new wc,t.set(n,i=U0(e,C0(e,t))),a=new Ko(i,s,n,o.isOrdered()),r=new Xn(e.name(),a,e.nullable(),Kd(e))),r||null}function Kd(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function k0(e){return new po(e.isSigned(),e.bitWidth())}function U0(e,t){const n=e.typeType();switch(n){case Wn.NONE:return new Oa;case Wn.Null:return new Oa;case Wn.Binary:return new Sd;case Wn.LargeBinary:return new Ed;case Wn.Utf8:return new Id;case Wn.LargeUtf8:return new Td;case Wn.Bool:return new Ad;case Wn.List:return new Fd((t||[])[0]);case Wn.Struct_:return new ti(t||[])}switch(n){case Wn.Int:{const r=e.type(new Ri);return new po(r.isSigned(),r.bitWidth())}case Wn.FloatingPoint:{const r=e.type(new As);return new wd(r.precision())}case Wn.Decimal:{const r=e.type(new Ho);return new xd(r.scale(),r.precision(),r.bitWidth())}case Wn.Date:{const r=e.type(new yd);return new Rd(r.unit())}case Wn.Time:{const r=e.type(new Pi);return new Nd(r.unit(),r.bitWidth())}case Wn.Timestamp:{const r=e.type(new $i);return new Bd(r.unit(),r.timezone())}case Wn.Interval:{const r=e.type(new xs);return new Od(r.unit())}case Wn.Duration:{const r=e.type(new gd);return new Dd(r.unit())}case Wn.Union:{const r=e.type(new pi);return new Ld(r.mode(),r.typeIdsArray()||[],t||[])}case Wn.FixedSizeBinary:{const r=e.type(new _d);return new Md(r.byteWidth())}case Wn.FixedSizeList:{const r=e.type(new vd);return new Cd(r.listSize(),(t||[])[0])}case Wn.Map:{const r=e.type(new bd);return new kd((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${Wn[n]}" (${n})`)}function KL(e,t){const n=t.fields.map(s=>Xn.encode(e,s));Rs.startFieldsVector(e,n.length);const r=Rs.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?Rs.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return Ir.startKeyValue(e),Ir.addKey(e,o),Ir.addValue(e,l),Ir.endKeyValue(e)})):-1;return Rs.startSchema(e),Rs.addFields(e,r),Rs.addEndianness(e,nM?Wo.Little:Wo.Big),i!==-1&&Rs.addCustomMetadata(e,i),Rs.endSchema(e)}function QL(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;ae.isDictionary(s)?(a=s.dictionary.typeId,i=lm.visit(s,e),r=lm.visit(s.dictionary,e)):r=lm.visit(s,e);const o=(s.children||[]).map(f=>Xn.encode(e,f)),l=Vi.createChildrenVector(e,o),u=t.metadata&&t.metadata.size>0?Vi.createCustomMetadataVector(e,[...t.metadata].map(([f,p])=>{const E=e.createString(`${f}`),T=e.createString(`${p}`);return Ir.startKeyValue(e),Ir.addKey(e,E),Ir.addValue(e,T),Ir.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Vi.startField(e),Vi.addType(e,r),Vi.addTypeType(e,a),Vi.addChildren(e,l),Vi.addNullable(e,!!t.nullable),n!==-1&&Vi.addName(e,n),i!==-1&&Vi.addDictionary(e,i),u!==-1&&Vi.addCustomMetadata(e,u),Vi.endField(e)}function JL(e,t){const n=t.nodes||[],r=t.buffers||[];ia.startNodesVector(e,n.length);for(const a of n.slice().reverse())Ca.encode(e,a);const i=e.endVector();ia.startBuffersVector(e,r.length);for(const a of r.slice().reverse())Os.encode(e,a);const s=e.endVector();return ia.startRecordBatch(e),ia.addLength(e,BigInt(t.length)),ia.addNodes(e,i),ia.addBuffers(e,s),ia.endRecordBatch(e)}function ZL(e,t){const n=Bi.encode(e,t.data);return Yo.startDictionaryBatch(e),Yo.addId(e,BigInt(t.id)),Yo.addIsDelta(e,t.isDelta),Yo.addData(e,n),Yo.endDictionaryBatch(e)}function tM(e,t){return Cv.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function eM(e,t){return Mv.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const nM=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),cm=e=>`Expected ${pn[e]} Message in stream, but was null or length 0.`,um=e=>`Header pointer of flatbuffer-encoded ${pn[e]} Message is null or length 0.`,P0=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,$0=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class V0{constructor(t){this.source=t instanceof Wd?t:new Wd(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?nr:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(cm(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=cn(this.source.read(t));if(n.byteLength<t)throw new Error($0(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=pn.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(um(n));return i}readMetadataLength(){const t=this.source.read(Qd),n=t&&new jo(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return nr;if(n.byteLength<t)throw new Error(P0(t,n.byteLength));return{done:!1,value:ri.decode(n)}}}class rM{constructor(t,n){this.source=t instanceof il?t:Tv(t)?new Hd(t,n):new il(t)}[Symbol.asyncIterator](){return this}next(){return Ve(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?nr:t})}throw(t){return Ve(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Ve(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Ve(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(cm(t));return n.value})}readMessageBody(t){return Ve(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=cn(yield this.source.read(t));if(n.byteLength<t)throw new Error($0(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Ve(this,arguments,void 0,function*(t=!1){const n=pn.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(um(n));return i})}readMetadataLength(){return Ve(this,void 0,void 0,function*(){const t=yield this.source.read(Qd),n=t&&new jo(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Ve(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return nr;if(n.byteLength<t)throw new Error(P0(t,n.byteLength));return{done:!1,value:ri.decode(n)}})}}class iM extends V0{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof S0?t:new S0(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ri.fromJSON(t.schema,pn.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:ri.fromJSON(n,pn.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:ri.fromJSON(n,pn.RecordBatch)}}return this._body=[],nr}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(cm(t));return n.value}readSchema(){const t=pn.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(um(t));return r}}const Qd=4,dm="ARROW1",xc=new Uint8Array(dm.length);for(let e=0;e<dm.length;e+=1)xc[e]=dm.codePointAt(e);function fm(e,t=0){for(let n=-1,r=xc.length;++n<r;)if(xc[n]!==e[t+n])return!1;return!0}const Rc=xc.length,z0=Rc+Qd,sM=Rc*2+Qd;class Gi extends tm{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return fo(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return ki.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ki.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Gi?t:Dp(t)?cM(t):Tv(t)?fM(t):fo(t)?Ve(this,void 0,void 0,function*(){return yield Gi.from(yield t)}):Av(t)||Fp(t)||xv(t)||Go(t)?dM(new il(t)):uM(new Wd(t))}static readAll(t){return t instanceof Gi?t.isSync()?H0(t):q0(t):Dp(t)||ArrayBuffer.isView(t)||yc(t)||Iv(t)?H0(t):q0(t)}}class Jd extends Gi{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ss(this,arguments,function*(){yield Qe(yield*cd(uo(this[Symbol.iterator]())))})}}class Zd extends Gi{constructor(t){super(t),this._impl=t}readAll(){return Ve(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=uo(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class G0 extends Jd{constructor(t){super(t),this._impl=t}}class aM extends Zd{constructor(t){super(t),this._impl=t}}class j0{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=sn({type:new ti(this.schema.fields),length:t.length,children:r});return new gi(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),u=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new En(u)):new En(u)).memoize()}_loadVectors(t,n,r){return new T0(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class tf extends j0{constructor(t,n){super(n),this._reader=Dp(t)?new iM(this._handle=t):new V0(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=W0(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):nr}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):nr}next(){if(this.closed)return nr;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new om(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class ef extends j0{constructor(t,n){super(n),this._reader=new rM(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Ve(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return Ve(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=W0(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):nr})}return(t){return Ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):nr})}next(){return Ve(this,void 0,void 0,function*(){if(this.closed)return nr;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new om(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Ve(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Y0 extends tf{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof E0?t:new E0(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(pn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(pn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-z0,r=t.readInt32(n),i=t.readAt(n-r,r);return Ec.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class oM extends ef{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof Hd?t:new Hd(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Ve(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return Ve(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(pn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return Ve(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(pn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return Ve(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-z0,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Ec.decode(i)})}_readNextMessageAndValidate(t){return Ve(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class lM extends tf{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new wL(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function W0(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*H0(e){const t=Gi.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function q0(e){return Ss(this,arguments,function*(){const n=yield Qe(Gi.from(e));try{if(!(yield Qe(n.open({autoDestroy:!1}))).closed)do yield yield Qe(n);while(!(yield Qe(n.reset().open())).closed)}finally{yield Qe(n.cancel())}})}function cM(e){return new Jd(new lM(e))}function uM(e){const t=e.peek(Rc+7&-8);return t&&t.byteLength>=4?fm(t)?new G0(new Y0(e.read())):new Jd(new tf(e)):new Jd(new tf((function*(){})()))}function dM(e){return Ve(this,void 0,void 0,function*(){const t=yield e.peek(Rc+7&-8);return t&&t.byteLength>=4?fm(t)?new G0(new Y0(yield e.read())):new Zd(new ef(e)):new Zd(new ef((function(){return Ss(this,arguments,function*(){})})()))})}function fM(e){return Ve(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new Hd(e,t);return t>=sM&&fm(yield n.readAt(0,Rc+7&-8))?new aM(new oM(n)):new Zd(new ef(n))})}class rr extends tn{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof gi?s.data.children:s.data),r=new rr;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof En)return this.visitMany(t.data),this;const{type:n}=t;if(!ae.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(ae.isUnion(n))this.nodes.push(new Ca(r,0));else{const{nullCount:i}=t;ae.isNull(n)||cs.call(this,i<=0?new Uint8Array(0):Pd(t.offset,r,t.nullBitmap)),this.nodes.push(new Ca(r,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function cs(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Os(this._byteLength,t)),this._byteLength+=t,this}function hM(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(cs.call(this,i),n.mode===jr.Sparse)return pm.call(this,e);if(n.mode===jr.Dense){if(e.offset<=0)return cs.call(this,s),pm.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let u,f,p=-1;++p<r;)(u=i[p])!==void 0&&((f=o[u])===void 0&&(f=o[u]=s[p]),a[p]=s[p]-f,l[u]=((t=l[u])!==null&&t!==void 0?t:0)+1);cs.call(this,a),this.visitMany(e.children.map((u,f)=>{const p=n.typeIds[f],E=o[p],T=l[p];return u.slice(E,Math.min(r,T))}))}}return this}function pM(e){let t;return e.nullCount>=e.length?cs.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?cs.call(this,Pd(e.offset,e.length,t)):cs.call(this,$d(e.values))}function ua(e){return cs.call(this,e.values.subarray(0,e.length*e.stride))}function nf(e){const{length:t,values:n,valueOffsets:r}=e,i=zn(r[0]),s=zn(r[t]),a=Math.min(s-i,n.byteLength-i);return cs.call(this,Ov(-i,t+1,r)),cs.call(this,n.subarray(i,i+a)),this}function hm(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return cs.call(this,Ov(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function pm(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}rr.prototype.visitBool=pM,rr.prototype.visitInt=ua,rr.prototype.visitFloat=ua,rr.prototype.visitUtf8=nf,rr.prototype.visitLargeUtf8=nf,rr.prototype.visitBinary=nf,rr.prototype.visitLargeBinary=nf,rr.prototype.visitFixedSizeBinary=ua,rr.prototype.visitDate=ua,rr.prototype.visitTimestamp=ua,rr.prototype.visitTime=ua,rr.prototype.visitDecimal=ua,rr.prototype.visitList=hm,rr.prototype.visitStruct=pm,rr.prototype.visitUnion=hM,rr.prototype.visitInterval=ua,rr.prototype.visitDuration=ua,rr.prototype.visitFixedSizeList=hm,rr.prototype.visitMap=hm;class X0 extends tm{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Yd,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,hi(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return fo(t)?t.then(n=>this.writeAll(n)):Go(t)?_m(this,t):gm(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof Yd?this._sink=t:(this._sink=new Yd,t&&WD(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&HD(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!sm(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof ni&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof gi&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!sm(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof gi?t instanceof om||this._writeRecordBatch(t):t instanceof ni?this.writeAll(t.batches):yc(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=ri.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===pn.RecordBatch?this._recordBatchBlocks.push(new Fa(o,t.bodyLength,this._position)):t.headerType===pn.DictionaryBatch&&this._dictionaryBlocks.push(new Fa(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=cn(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(ri.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(xc)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=rr.assemble(t),a=new Bi(t.numRows,r,i),o=ri.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=rr.assemble(new En([t])),l=new Bi(t.length,s,a),u=new Bs(l,n,r),f=ri.from(u,i);return this._writeMessage(f)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[u,f]of a.entries())this._writeDictionaryBatch(f,i,u>0);else if(l<a.length)for(const u of a.slice(l))this._writeDictionaryBatch(u,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class mm extends X0{static writeAll(t,n){const r=new mm(n);return fo(t)?t.then(i=>r.writeAll(i)):Go(t)?_m(r,t):gm(r,t)}}class ym extends X0{static writeAll(t){const n=new ym;return fo(t)?t.then(r=>n.writeAll(r)):Go(t)?_m(n,t):gm(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Ec.encode(new Ec(t,mr.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function gm(e,t){let n=t;t instanceof ni&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function _m(e,t){return Ve(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=uo(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const u=l;e.write(u)}}catch(u){a={error:u}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function mM(e,t="stream"){return(t==="stream"?mm:ym).writeAll(e).toUint8Array(!0)}var yM=Object.create,K0=Object.defineProperty,gM=Object.getOwnPropertyDescriptor,_M=Object.getOwnPropertyNames,vM=Object.getPrototypeOf,bM=Object.prototype.hasOwnProperty,wM=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),SM=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of _M(t))!bM.call(e,i)&&i!==n&&K0(e,i,{get:()=>t[i],enumerable:!(r=gM(t,i))||r.enumerable});return e},EM=(e,t,n)=>(n=e!=null?yM(vM(e)):{},SM(!e||!e.__esModule?K0(n,"default",{value:e,enumerable:!0}):n,e)),IM=wM((e,t)=>{t.exports=Worker}),TM=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(TM||{}),AM=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(AM||{}),xM=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(xM||{}),RM=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(RM||{}),NM=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(NM||{}),BM=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(BM||{}),OM=class{constructor(t=2){this.level=t}log(t){t.level>=this.level&&console.log(t)}},DM=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.MAX_ARROW_ERROR=255]="MAX_ARROW_ERROR",e[e.DUCKDB_WASM_RETRY=256]="DUCKDB_WASM_RETRY",e))(DM||{}),FM=class{constructor(t,n){this._bindings=t,this._conn=n}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}async query(t){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:t});let n=await this._bindings.runQuery(this._conn,t),r=Gi.from(n);return console.assert(r.isSync(),"Reader is not sync"),console.assert(r.isFile(),"Reader is not file"),new ni(r)}async send(t,n=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:t});let r=await this._bindings.startPendingQuery(this._conn,t,n);for(;r==null;)r=await this._bindings.pollPendingQuery(this._conn);let i=new Q0(this._bindings,this._conn,r),s=await Gi.from(i);return console.assert(s.isAsync()),console.assert(s.isStream()),s}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(t){return await this._bindings.getTableNames(this._conn,t)}async prepare(t){let n=await this._bindings.createPrepared(this._conn,t);return new LM(this._bindings,this._conn,n)}async insertArrowTable(t,n){let r=mM(t,"stream");await this.insertArrowFromIPCStream(r,n)}async insertArrowFromIPCStream(t,n){await this._bindings.insertArrowFromIPCStream(this._conn,t,n)}async insertCSVFromPath(t,n){await this._bindings.insertCSVFromPath(this._conn,t,n)}async insertJSONFromPath(t,n){await this._bindings.insertJSONFromPath(this._conn,t,n)}},Q0=class{constructor(t,n,r){this.db=t,this.conn=n,this.header=r,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let t=null;for(this._inFlight!=null&&(t=await this._inFlight,this._inFlight=null);t==null;)t=await this.db.fetchQueryResults(this.conn);return this._depleted=t.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:t}}[Symbol.asyncIterator](){return this}},LM=class{constructor(t,n,r){this.bindings=t,this.connectionId=n,this.statementId=r}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...t){let n=await this.bindings.runPrepared(this.connectionId,this.statementId,t),r=Gi.from(n);return console.assert(r.isSync()),console.assert(r.isFile()),new ni(r)}async send(...t){let n=await this.bindings.sendPrepared(this.connectionId,this.statementId,t),r=new Q0(this.bindings,this.connectionId,n),i=await Gi.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}},MM=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(MM||{}),CM=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(CM||{}),fn=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function rf(e){switch(e.typeId){case B.Binary:return{sqlType:"binary"};case B.Bool:return{sqlType:"bool"};case B.Date:return{sqlType:"date"};case B.DateDay:return{sqlType:"date32[d]"};case B.DateMillisecond:return{sqlType:"date64[ms]"};case B.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case B.Float:return{sqlType:"float"};case B.Float16:return{sqlType:"float16"};case B.Float32:return{sqlType:"float32"};case B.Float64:return{sqlType:"float64"};case B.Int:return{sqlType:"int32"};case B.Int16:return{sqlType:"int16"};case B.Int32:return{sqlType:"int32"};case B.Int64:return{sqlType:"int64"};case B.Uint16:return{sqlType:"uint16"};case B.Uint32:return{sqlType:"uint32"};case B.Uint64:return{sqlType:"uint64"};case B.Uint8:return{sqlType:"uint8"};case B.IntervalDayTime:return{sqlType:"interval[dt]"};case B.IntervalYearMonth:return{sqlType:"interval[m]"};case B.List:return{sqlType:"list",valueType:rf(e.valueType)};case B.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case B.Null:return{sqlType:"null"};case B.Utf8:return{sqlType:"utf8"};case B.Struct:return{sqlType:"struct",fields:e.children.map(t=>vm(t.name,t.type))};case B.Map:{let t=e;return{sqlType:"map",keyType:rf(t.keyType),valueType:rf(t.valueType)}}case B.Time:return{sqlType:"time[s]"};case B.TimeMicrosecond:return{sqlType:"time[us]"};case B.TimeMillisecond:return{sqlType:"time[ms]"};case B.TimeNanosecond:return{sqlType:"time[ns]"};case B.TimeSecond:return{sqlType:"time[s]"};case B.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case B.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case B.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case B.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case B.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function vm(e,t){let n=rf(t);return n.name=e,n}var kM=new TextEncoder,UM=class{constructor(t,n=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=t,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),n!=null&&this.attach(n)}get logger(){return this._logger}attach(t){this._worker=t,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((n,r)=>{this._workerShutdownResolver=n})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(t,n=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let r=this._nextMessageId++;return this._pendingRequests.set(r,t),this._worker.postMessage({messageId:r,type:t.type,data:t.data},n),await t.promise}onMessage(t){var n;let r=t.data;switch(r.type){case"PROGRESS_UPDATE":{for(let s of this._onExecutionProgress)s(r.data);return}case"LOG":{this._logger.log(r.data);return}case"INSTANTIATE_PROGRESS":{for(let s of this._onInstantiationProgress)s(r.data);return}}let i=this._pendingRequests.get(r.requestId);if(!i){console.warn("unassociated response: [".concat(r.requestId,", ").concat(r.type.toString(),"]"));return}if(this._pendingRequests.delete(r.requestId),r.type=="ERROR"){let s=new Error(r.data.message);s.name=r.data.name,(n=Object.getOwnPropertyDescriptor(s,"stack"))!=null&&n.writable&&(s.stack=r.data.stack),i.promiseRejecter(s);return}switch(i.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(r.type=="OK"){i.promiseResolver(r.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],r.type=="OK"){i.promiseResolver(r.data);return}break;case"GLOB_FILE_INFOS":if(r.type=="FILE_INFOS"){i.promiseResolver(r.data);return}break;case"GET_VERSION":if(r.type=="VERSION_STRING"){i.promiseResolver(r.data);return}break;case"GET_FEATURE_FLAGS":if(r.type=="FEATURE_FLAGS"){i.promiseResolver(r.data);return}break;case"GET_TABLE_NAMES":if(r.type=="TABLE_NAMES"){i.promiseResolver(r.data);return}break;case"TOKENIZE":if(r.type=="SCRIPT_TOKENS"){i.promiseResolver(r.data);return}break;case"COPY_FILE_TO_BUFFER":if(r.type=="FILE_BUFFER"){i.promiseResolver(r.data);return}break;case"EXPORT_FILE_STATISTICS":if(r.type=="FILE_STATISTICS"){i.promiseResolver(r.data);return}break;case"CONNECT":if(r.type=="CONNECTION_INFO"){i.promiseResolver(r.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(r.type=="QUERY_RESULT"){i.promiseResolver(r.data);return}break;case"SEND_PREPARED":if(r.type=="QUERY_RESULT_HEADER"){i.promiseResolver(r.data);return}break;case"START_PENDING_QUERY":if(r.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(r.data);return}break;case"POLL_PENDING_QUERY":if(r.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(r.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],r.type=="SUCCESS"){i.promiseResolver(r.data);return}break;case"FETCH_QUERY_RESULTS":if(r.type=="QUERY_RESULT_CHUNK"){i.promiseResolver(r.data);return}break;case"CREATE_PREPARED":if(r.type=="PREPARED_STATEMENT_ID"){i.promiseResolver(r.data);return}break}i.promiseRejecter(new Error("unexpected response type: ".concat(r.type.toString())))}onError(t){console.error(t),console.error("error in duckdb worker: ".concat(t.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let t=new fn("RESET",null);return await this.postTask(t)}async ping(){let t=new fn("PING",null);await this.postTask(t)}async dropFile(t){let n=new fn("DROP_FILE",t);return await this.postTask(n)}async dropFiles(){let t=new fn("DROP_FILES",null);return await this.postTask(t)}async flushFiles(){let t=new fn("FLUSH_FILES",null);return await this.postTask(t)}async instantiate(t,n=null,r=i=>{}){this._onInstantiationProgress.push(r);let i=new fn("INSTANTIATE",[t,n]);return await this.postTask(i)}async getVersion(){let t=new fn("GET_VERSION",null);return await this.postTask(t)}async getFeatureFlags(){let t=new fn("GET_FEATURE_FLAGS",null);return await this.postTask(t)}async open(t){let n=new fn("OPEN",t);await this.postTask(n)}async tokenize(t){let n=new fn("TOKENIZE",t);return await this.postTask(n)}async connectInternal(){let t=new fn("CONNECT",null);return await this.postTask(t)}async connect(){let t=await this.connectInternal();return new FM(this,t)}async disconnect(t){let n=new fn("DISCONNECT",t);await this.postTask(n)}async runQuery(t,n){let r=new fn("RUN_QUERY",[t,n]);return await this.postTask(r)}async startPendingQuery(t,n,r=!1){let i=new fn("START_PENDING_QUERY",[t,n,r]);return await this.postTask(i)}async pollPendingQuery(t){let n=new fn("POLL_PENDING_QUERY",t);return await this.postTask(n)}async cancelPendingQuery(t){let n=new fn("CANCEL_PENDING_QUERY",t);return await this.postTask(n)}async fetchQueryResults(t){let n=new fn("FETCH_QUERY_RESULTS",t);return await this.postTask(n)}async getTableNames(t,n){let r=new fn("GET_TABLE_NAMES",[t,n]);return await this.postTask(r)}async createPrepared(t,n){let r=new fn("CREATE_PREPARED",[t,n]);return await this.postTask(r)}async closePrepared(t,n){let r=new fn("CLOSE_PREPARED",[t,n]);await this.postTask(r)}async runPrepared(t,n,r){let i=new fn("RUN_PREPARED",[t,n,r]);return await this.postTask(i)}async sendPrepared(t,n,r){let i=new fn("SEND_PREPARED",[t,n,r]);return await this.postTask(i)}async globFiles(t){let n=new fn("GLOB_FILE_INFOS",t);return await this.postTask(n)}async registerFileText(t,n){let r=kM.encode(n);await this.registerFileBuffer(t,r)}async registerFileURL(t,n,r,i){n===void 0&&(n=t);let s=new fn("REGISTER_FILE_URL",[t,n,r,i]);await this.postTask(s)}async registerEmptyFileBuffer(t){}async registerFileBuffer(t,n){let r=new fn("REGISTER_FILE_BUFFER",[t,n]);await this.postTask(r,[n.buffer])}async registerFileHandle(t,n,r,i){let s=new fn("REGISTER_FILE_HANDLE",[t,n,r,i]);await this.postTask(s,[])}async registerOPFSFileName(t){let n=new fn("REGISTER_OPFS_FILE_NAME",[t]);await this.postTask(n,[])}async collectFileStatistics(t,n){let r=new fn("COLLECT_FILE_STATISTICS",[t,n]);await this.postTask(r,[])}async exportFileStatistics(t){let n=new fn("EXPORT_FILE_STATISTICS",t);return await this.postTask(n,[])}async copyFileToBuffer(t){let n=new fn("COPY_FILE_TO_BUFFER",t);return await this.postTask(n)}async copyFileToPath(t,n){let r=new fn("COPY_FILE_TO_PATH",[t,n]);await this.postTask(r)}async insertArrowFromIPCStream(t,n,r){if(n.length==0)return;let i=new fn("INSERT_ARROW_FROM_IPC_STREAM",[t,n,r]);await this.postTask(i,[n.buffer])}async insertCSVFromPath(t,n,r){if(r.columns!==void 0){let s=[];for(let a in r.columns){let o=r.columns[a];s.push(vm(a,o))}r.columnsFlat=s,delete r.columns}let i=new fn("IMPORT_CSV_FROM_PATH",[t,n,r]);await this.postTask(i)}async insertJSONFromPath(t,n,r){if(r.columns!==void 0){let s=[];for(let a in r.columns){let o=r.columns[a];s.push(vm(a,o))}r.columnsFlat=s,delete r.columns}let i=new fn("IMPORT_JSON_FROM_PATH",[t,n,r]);await this.postTask(i)}};function PM(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}PM();var $M=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))($M||{}),VM=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),zM=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),GM=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),jM=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),bm={name:"@duckdb/duckdb-wasm",version:"1.30.0"},YM=bm.name,WM=bm.version,wm=bm.version.split(".");wm[0],wm[1],wm[2];var HM=()=>typeof navigator>"u";function qM(){let e="https://cdn.jsdelivr.net/npm/".concat(YM,"@").concat(WM,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Sm=null,Em=null,Im=null,Tm=null,Am=null;async function XM(){return Sm==null&&(Sm=typeof BigInt64Array<"u"),Em==null&&(Em=await zM()),Im==null&&(Im=await jM()),Tm==null&&(Tm=await GM()),Am==null&&(Am=await VM()),{bigInt64Array:Sm,crossOriginIsolated:HM()||globalThis.crossOriginIsolated||!1,wasmExceptions:Em,wasmSIMD:Tm,wasmThreads:Im,wasmBulkMemory:Am}}async function KM(e){let t=await XM();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}EM(IM());class J0{constructor(t="/data"){this.basePath=t,this.db=null,this.conn=null,this.umapData=null,this.tsneData=null,this.geneCache=new Map,this.loadedChunks=new Set}async initialize(){try{const t=qM(),n=await KM(t),r=URL.createObjectURL(new Blob([`importScripts("${n.mainWorker}");`],{type:"text/javascript"})),i=new Worker(r),s=new OM;this.db=new UM(s,i),await this.db.instantiate(n.mainModule),this.conn=await this.db.connect(),await this.loadEssentialData()}catch(t){throw console.error("Failed to initialize data manager:",t),new Error(`Initialization failed: ${t.message}`)}}async loadEssentialData(){const t=[{name:"umap.parquet",path:`${this.basePath}/umap_complete.parquet`,required:!0},{name:"tsne.parquet",path:`${this.basePath}/tsne_complete.parquet`,required:!1},{name:"gene_locations.parquet",path:`${this.basePath}/gene_locations.parquet`,required:!0},{name:"gene_stats.parquet",path:`${this.basePath}/gene_stats.parquet`,required:!0},{name:"cells.parquet",path:`${this.basePath}/cells.parquet`,required:!0},{name:"metadata.parquet",path:`${this.basePath}/metadata.parquet`,required:!1},{name:"genes.parquet",path:`${this.basePath}/genes.parquet`,required:!0}];for(const s of t)try{const a=await fetch(s.path);if(!a.ok){if(s.required)throw new Error(`Failed to load required file: ${s.name} (${a.status} ${a.statusText})`);console.log(`Optional file ${s.name} not available, skipping...`);continue}const o=await a.arrayBuffer();await this.db.registerFileBuffer(s.name,new Uint8Array(o))}catch(a){if(s.required)throw a;console.log(`Optional file ${s.name} not available:`,a.message)}let n=new Map;try{try{(await this.conn.query('SELECT * FROM "metadata.parquet"')).toArray().map(o=>o.toJSON()).forEach(o=>{n.set(o.cell_id,o)})}catch{console.log("metadata.parquet not found, trying cells.parquet..."),(await this.conn.query('SELECT * FROM "cells.parquet"')).toArray().map(l=>l.toJSON()).forEach(l=>{n.set(l.cell_id,l)})}}catch(s){console.warn("Could not load cell metadata:",s)}const i=(await this.conn.query('SELECT * FROM "umap.parquet"')).toArray().map(s=>s.toJSON());this.umapData=i.map(s=>{const a=n.get(s.cell_id)||{};return{...s,...a}});try{const s=await this.conn.query('SELECT * FROM "tsne.parquet"');this.tsneData=s.toArray().map(a=>{const o=a.toJSON(),l=n.get(o.cell_id)||{};return{...o,...l}})}catch{console.log("tSNE data not available"),this.tsneData=null}}async getReductionData(t="umap"){if(t==="umap"){if(!this.umapData)throw new Error("UMAP data not loaded");return this.umapData}else if(t==="tsne"){if(!this.tsneData)throw new Error("tSNE data not available");return this.tsneData}else throw new Error(`Unknown reduction type: ${t}`)}async searchGenes(t){if(!t||t.length<1)return[];try{const i=(await this.conn.query(`
98
+ ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new si(n,r.map(i=>new wi(n,i)))}slice(t,n){const r=this.schema;[t,n]=Pb({length:this.numRows},t,n);const i=Wb(this.data,this._offsets,t,n);return new si(r,i.map(s=>new wi(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=sn({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Bn(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new Bn([sn({type:new Fa,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,u)=>this.getChildAt(u));[s[t],o[t]]=[a,n],[r,i]=Em(r,o)}return new si(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new si(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,u)=>{const[d,h]=o,y=n.findIndex(S=>S.name===l.name);return~y?h[y]=u:d.push(u),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new si(...Em(s,a))}}rw=Symbol.toStringTag,si[rw]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Hd(hm),e.get=Hd(vi.getVisitFn(D.Struct)),e.set=Hb(Gi.getVisitFn(D.Struct)),e.indexOf=qb(qd.getVisitFn(D.Struct)),"Table"))(si.prototype);var iw;let wi=class _u{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof On))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=sn({nullCount:0,type:new ri(this.schema.fields),children:this.schema.fields.map(n=>sn({type:n.type,nullCount:0}))})]=t,!(this.data instanceof Un))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=sw(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,d)=>(l.children[d]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[d]=nr.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new On(r),o=sn({type:new ri(r),length:s,children:i,nullCount:0});[this.schema,this.data]=sw(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=aw(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return vi.visit(this.data,t)}at(t){return this.get(lm(t,this.numRows))}set(t,n){return Gi.visit(this.data,t,n)}indexOf(t,n){return qd.visit(this.data,t,n)}[Symbol.iterator](){return pm.visit(new Bn([this.data]))}toArray(){return[...this]}concat(...t){return new si(this.schema,[this,...t])}slice(t,n){const[r]=new Bn([this.data]).slice(t,n).data;return new _u(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new Bn([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new Bn([sn({type:new Fa,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new On(s,new Map(this.schema.metadata)),i=sn({type:new ri(s),children:a})}return new _u(r,i)}select(t){const n=this.schema.select(t),r=new ri(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new _u(n,sn({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=sn({type:new ri(n.fields),length:this.numRows,children:r});return new _u(n,i)}};iw=Symbol.toStringTag,wi[iw]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(wi.prototype);function sw(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const u=t[o];(!u||u.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=u==null?void 0:u._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:sn({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),sn({type:new ri(i),length:n,children:s})]}function aw(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const u of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])aw(o.children,u==null?void 0:u.children,n);if(ce.isDictionary(o)){const{id:u}=o;if(!n.has(u))l!=null&&l.dictionary&&n.set(u,l.dictionary);else if(n.get(u)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class Im extends wi{constructor(t){const n=t.fields.map(i=>sn({type:i.type})),r=sn({type:new ri(t.fields),nullCount:0,children:n});super(t,r)}}let ka=class Xs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new Xs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Rn),(n||new Xs).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Sr.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):bn.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Or).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,Sr.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,bn.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return Xs.startMessage(t),Xs.addVersion(t,n),Xs.addHeaderType(t,r),Xs.addHeader(t,i),Xs.addBodyLength(t,s),Xs.addCustomMetadata(t,a),Xs.endMessage(t)}};class NM extends tn{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return _0.startNull(n),_0.endNull(n)}visitInt(t,n){return Bi.startInt(n),Bi.addBitWidth(n,t.bitWidth),Bi.addIsSigned(n,t.isSigned),Bi.endInt(n)}visitFloat(t,n){return Rs.startFloatingPoint(n),Rs.addPrecision(n,t.precision),Rs.endFloatingPoint(n)}visitBinary(t,n){return h0.startBinary(n),h0.endBinary(n)}visitLargeBinary(t,n){return m0.startLargeBinary(n),m0.endLargeBinary(n)}visitBool(t,n){return p0.startBool(n),p0.endBool(n)}visitUtf8(t,n){return v0.startUtf8(n),v0.endUtf8(n)}visitLargeUtf8(t,n){return y0.startLargeUtf8(n),y0.endLargeUtf8(n)}visitDecimal(t,n){return Qo.startDecimal(n),Qo.addScale(n,t.scale),Qo.addPrecision(n,t.precision),Qo.addBitWidth(n,t.bitWidth),Qo.endDecimal(n)}visitDate(t,n){return Sd.startDate(n),Sd.addUnit(n,t.unit),Sd.endDate(n)}visitTime(t,n){return $i.startTime(n),$i.addUnit(n,t.unit),$i.addBitWidth(n,t.bitWidth),$i.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return Vi.startTimestamp(n),Vi.addUnit(n,t.unit),r!==void 0&&Vi.addTimezone(n,r),Vi.endTimestamp(n)}visitInterval(t,n){return Bs.startInterval(n),Bs.addUnit(n,t.unit),Bs.endInterval(n)}visitDuration(t,n){return Ed.startDuration(n),Ed.addUnit(n,t.unit),Ed.endDuration(n)}visitList(t,n){return g0.startList(n),g0.endList(n)}visitStruct(t,n){return yo.startStruct_(n),yo.endStruct_(n)}visitUnion(t,n){_i.startTypeIdsVector(n,t.typeIds.length);const r=_i.createTypeIdsVector(n,t.typeIds);return _i.startUnion(n),_i.addMode(n,t.mode),_i.addTypeIds(n,r),_i.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return la.startDictionaryEncoding(n),la.addId(n,BigInt(t.id)),la.addIsOrdered(n,t.isOrdered),r!==void 0&&la.addIndexType(n,r),la.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return Id.startFixedSizeBinary(n),Id.addByteWidth(n,t.byteWidth),Id.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Td.startFixedSizeList(n),Td.addListSize(n,t.listSize),Td.endFixedSizeList(n)}visitMap(t,n){return Ad.startMap(n),Ad.addKeysSorted(n,t.keysSorted),Ad.endMap(n)}}const Tm=new NM;function RM(e,t=new Map){return new On(OM(e,t),ef(e.metadata),t)}function ow(e){return new Di(e.count,cw(e.columns),uw(e.columns))}function BM(e){return new Fs(ow(e.data),e.id,e.isDelta)}function OM(e,t){return(e.fields||[]).filter(Boolean).map(n=>nr.fromJSON(n,t))}function lw(e,t){return(e.children||[]).filter(Boolean).map(n=>nr.fromJSON(n,t))}function cw(e){return(e||[]).reduce((t,n)=>[...t,new Ua(n.count,DM(n.VALIDITY)),...cw(n.children)],[])}function uw(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new Ls(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new Ls(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new Ls(t.length,i.OFFSET.length)),i.DATA&&t.push(new Ls(t.length,i.DATA.length)),t=uw(i.children,t)}return t}function DM(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function FM(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=fw(e,lw(e,t)),i=new nr(e.name,a,e.nullable,ef(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?dw(r):new xc,o=new tl(t.get(n),r,n,s.isOrdered),i=new nr(e.name,o,e.nullable,ef(e.metadata))):(r=(r=s.indexType)?dw(r):new xc,t.set(n,a=fw(e,lw(e,t))),o=new tl(a,r,n,s.isOrdered),i=new nr(e.name,o,e.nullable,ef(e.metadata))),i||null}function ef(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function dw(e){return new go(e.isSigned,e.bitWidth)}function fw(e,t){const n=e.type.name;switch(n){case"NONE":return new Fa;case"null":return new Fa;case"binary":return new Nd;case"largebinary":return new Rd;case"utf8":return new Bd;case"largeutf8":return new Od;case"bool":return new Dd;case"list":return new Pd((t||[])[0]);case"struct":return new ri(t||[]);case"struct_":return new ri(t||[])}switch(n){case"int":{const r=e.type;return new go(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new xd(Xr[r.precision])}case"decimal":{const r=e.type;return new Fd(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new Ld(Pi[r.unit])}case"time":{const r=e.type;return new Md(xe[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Cd(xe[r.unit],r.timezone)}case"interval":{const r=e.type;return new kd(xs[r.unit])}case"duration":{const r=e.type;return new Ud(xe[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new $d(qr[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Vd(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new zd(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Gd((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var LM=u0,MM=qo;class ai{static fromJSON(t,n){const r=new ai(0,Sr.V5,n);return r._createHeader=CM(t,n),r}static decode(t){t=new MM(un(t));const n=ka.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new ai(r,i,s);return a._createHeader=kM(n,s),a}static encode(t){const n=new LM;let r=-1;return t.isSchema()?r=On.encode(n,t.header()):t.isRecordBatch()?r=Di.encode(n,t.header()):t.isDictionaryBatch()&&(r=Fs.encode(n,t.header())),ka.startMessage(n),ka.addVersion(n,Sr.V5),ka.addHeader(n,r),ka.addHeaderType(n,t.headerType),ka.addBodyLength(n,BigInt(t.bodyLength)),ka.finishMessageBuffer(n,ka.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof On)return new ai(0,Sr.V5,bn.Schema,t);if(t instanceof Di)return new ai(n,Sr.V5,bn.RecordBatch,t);if(t instanceof Fs)return new ai(n,Sr.V5,bn.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===bn.Schema}isRecordBatch(){return this.headerType===bn.RecordBatch}isDictionaryBatch(){return this.headerType===bn.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=Hn(t)}}class Di{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=Hn(t)}}class Fs{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,n,r=!1){this._data=t,this._isDelta=r,this._id=Hn(n)}}class Ls{constructor(t,n){this.offset=Hn(t),this.length=Hn(n)}}class Ua{constructor(t,n){this.length=Hn(t),this.nullCount=Hn(n)}}function CM(e,t){return(()=>{switch(t){case bn.Schema:return On.fromJSON(e);case bn.RecordBatch:return Di.fromJSON(e);case bn.DictionaryBatch:return Fs.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${bn[t]}, type: ${t} }`)})}function kM(e,t){return(()=>{switch(t){case bn.Schema:return On.decode(e.header(new Os),new Map,e.version());case bn.RecordBatch:return Di.decode(e.header(new oa),e.version());case bn.DictionaryBatch:return Fs.decode(e.header(new Xo),e.version())}throw new Error(`Unrecognized Message type: { name: ${bn[t]}, type: ${t} }`)})}nr.encode=qM,nr.decode=WM,nr.fromJSON=FM,On.encode=HM,On.decode=UM,On.fromJSON=RM,Di.encode=XM,Di.decode=PM,Di.fromJSON=ow,Fs.encode=KM,Fs.decode=$M,Fs.fromJSON=BM,Ua.encode=QM,Ua.decode=zM,Ls.encode=JM,Ls.decode=VM;function UM(e,t=new Map,n=Sr.V5){const r=YM(e,t);return new On(r,nf(e),t,n)}function PM(e,t=Sr.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new Di(e.length(),GM(e),jM(e,t))}function $M(e,t=Sr.V5){return new Fs(Di.decode(e.data(),t),e.id(),e.isDelta())}function VM(e){return new Ls(e.offset(),e.length())}function zM(e){return new Ua(e.length(),e.nullCount())}function GM(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Ua.decode(n));return t}function jM(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<Sr.V4&&(r.bb_pos+=8*(i+1)),n[++s]=Ls.decode(r));return n}function YM(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=nr.decode(r,t));return n}function hw(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=nr.decode(r,t));return n}function WM(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=mw(e,hw(e,t)),r=new nr(e.name(),i,e.nullable(),nf(e))):t.has(n=Hn(o.id()))?(s=(s=o.indexType())?pw(s):new xc,a=new tl(t.get(n),s,n,o.isOrdered()),r=new nr(e.name(),a,e.nullable(),nf(e))):(s=(s=o.indexType())?pw(s):new xc,t.set(n,i=mw(e,hw(e,t))),a=new tl(i,s,n,o.isOrdered()),r=new nr(e.name(),a,e.nullable(),nf(e))),r||null}function nf(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function pw(e){return new go(e.isSigned(),e.bitWidth())}function mw(e,t){const n=e.typeType();switch(n){case Jn.NONE:return new Fa;case Jn.Null:return new Fa;case Jn.Binary:return new Nd;case Jn.LargeBinary:return new Rd;case Jn.Utf8:return new Bd;case Jn.LargeUtf8:return new Od;case Jn.Bool:return new Dd;case Jn.List:return new Pd((t||[])[0]);case Jn.Struct_:return new ri(t||[])}switch(n){case Jn.Int:{const r=e.type(new Bi);return new go(r.isSigned(),r.bitWidth())}case Jn.FloatingPoint:{const r=e.type(new Rs);return new xd(r.precision())}case Jn.Decimal:{const r=e.type(new Qo);return new Fd(r.scale(),r.precision(),r.bitWidth())}case Jn.Date:{const r=e.type(new Sd);return new Ld(r.unit())}case Jn.Time:{const r=e.type(new $i);return new Md(r.unit(),r.bitWidth())}case Jn.Timestamp:{const r=e.type(new Vi);return new Cd(r.unit(),r.timezone())}case Jn.Interval:{const r=e.type(new Bs);return new kd(r.unit())}case Jn.Duration:{const r=e.type(new Ed);return new Ud(r.unit())}case Jn.Union:{const r=e.type(new _i);return new $d(r.mode(),r.typeIdsArray()||[],t||[])}case Jn.FixedSizeBinary:{const r=e.type(new Id);return new Vd(r.byteWidth())}case Jn.FixedSizeList:{const r=e.type(new Td);return new zd(r.listSize(),(t||[])[0])}case Jn.Map:{const r=e.type(new Ad);return new Gd((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${Jn[n]}" (${n})`)}function HM(e,t){const n=t.fields.map(s=>nr.encode(e,s));Os.startFieldsVector(e,n.length);const r=Os.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?Os.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return Or.startKeyValue(e),Or.addKey(e,o),Or.addValue(e,l),Or.endKeyValue(e)})):-1;return Os.startSchema(e),Os.addFields(e,r),Os.addEndianness(e,ZM?Ko.Little:Ko.Big),i!==-1&&Os.addCustomMetadata(e,i),Os.endSchema(e)}function qM(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;ce.isDictionary(s)?(a=s.dictionary.typeId,i=Tm.visit(s,e),r=Tm.visit(s.dictionary,e)):r=Tm.visit(s,e);const o=(s.children||[]).map(d=>nr.encode(e,d)),l=zi.createChildrenVector(e,o),u=t.metadata&&t.metadata.size>0?zi.createCustomMetadataVector(e,[...t.metadata].map(([d,h])=>{const y=e.createString(`${d}`),S=e.createString(`${h}`);return Or.startKeyValue(e),Or.addKey(e,y),Or.addValue(e,S),Or.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),zi.startField(e),zi.addType(e,r),zi.addTypeType(e,a),zi.addChildren(e,l),zi.addNullable(e,!!t.nullable),n!==-1&&zi.addName(e,n),i!==-1&&zi.addDictionary(e,i),u!==-1&&zi.addCustomMetadata(e,u),zi.endField(e)}function XM(e,t){const n=t.nodes||[],r=t.buffers||[];oa.startNodesVector(e,n.length);for(const a of n.slice().reverse())Ua.encode(e,a);const i=e.endVector();oa.startBuffersVector(e,r.length);for(const a of r.slice().reverse())Ls.encode(e,a);const s=e.endVector();return oa.startRecordBatch(e),oa.addLength(e,BigInt(t.length)),oa.addNodes(e,i),oa.addBuffers(e,s),oa.endRecordBatch(e)}function KM(e,t){const n=Di.encode(e,t.data);return Xo.startDictionaryBatch(e),Xo.addId(e,BigInt(t.id)),Xo.addIsDelta(e,t.isDelta),Xo.addData(e,n),Xo.endDictionaryBatch(e)}function QM(e,t){return f0.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function JM(e,t){return d0.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const ZM=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),Am=e=>`Expected ${bn[e]} Message in stream, but was null or length 0.`,xm=e=>`Header pointer of flatbuffer-encoded ${bn[e]} Message is null or length 0.`,yw=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,gw=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class _w{constructor(t){this.source=t instanceof Jd?t:new Jd(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?ur:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Am(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=un(this.source.read(t));if(n.byteLength<t)throw new Error(gw(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=bn.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(xm(n));return i}readMetadataLength(){const t=this.source.read(rf),n=t&&new qo(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return ur;if(n.byteLength<t)throw new Error(yw(t,n.byteLength));return{done:!1,value:ai.decode(n)}}}class tC{constructor(t,n){this.source=t instanceof ll?t:e0(t)?new Zd(t,n):new ll(t)}[Symbol.asyncIterator](){return this}next(){return Ge(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?ur:t})}throw(t){return Ge(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Ge(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Ge(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Am(t));return n.value})}readMessageBody(t){return Ge(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=un(yield this.source.read(t));if(n.byteLength<t)throw new Error(gw(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Ge(this,arguments,void 0,function*(t=!1){const n=bn.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(xm(n));return i})}readMetadataLength(){return Ge(this,void 0,void 0,function*(){const t=yield this.source.read(rf),n=t&&new qo(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Ge(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return ur;if(n.byteLength<t)throw new Error(yw(t,n.byteLength));return{done:!1,value:ai.decode(n)}})}}class eC extends _w{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Zb?t:new Zb(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ai.fromJSON(t.schema,bn.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:ai.fromJSON(n,bn.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:ai.fromJSON(n,bn.RecordBatch)}}return this._body=[],ur}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Am(t));return n.value}readSchema(){const t=bn.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(xm(t));return r}}const rf=4,Nm="ARROW1",Fc=new Uint8Array(Nm.length);for(let e=0;e<Nm.length;e+=1)Fc[e]=Nm.codePointAt(e);function Rm(e,t=0){for(let n=-1,r=Fc.length;++n<r;)if(Fc[n]!==e[t+n])return!1;return!0}const Lc=Fc.length,vw=Lc+rf,nC=Lc*2+rf;class ji extends gm{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return mo(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Ui.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Ui.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof ji?t:Xp(t)?aC(t):e0(t)?cC(t):mo(t)?Ge(this,void 0,void 0,function*(){return yield ji.from(yield t)}):n0(t)||Kp(t)||r0(t)||Ho(t)?lC(new ll(t)):oC(new Jd(t))}static readAll(t){return t instanceof ji?t.isSync()?Iw(t):Tw(t):Xp(t)||ArrayBuffer.isView(t)||Sc(t)||t0(t)?Iw(t):Tw(t)}}class sf extends ji{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ts(this,arguments,function*(){yield Qe(yield*md(po(this[Symbol.iterator]())))})}}class af extends ji{constructor(t){super(t),this._impl=t}readAll(){return Ge(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=po(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class bw extends sf{constructor(t){super(t),this._impl=t}}class rC extends af{constructor(t){super(t),this._impl=t}}class ww{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=sn({type:new ri(this.schema.fields),length:t.length,children:r});return new wi(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),u=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new Bn(u)):new Bn(u)).memoize()}_loadVectors(t,n,r){return new nw(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class of extends ww{constructor(t,n){super(n),this._reader=Xp(t)?new eC(this._handle=t):new _w(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Ew(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):ur}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):ur}next(){if(this.closed)return ur;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Im(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class lf extends ww{constructor(t,n){super(n),this._reader=new tC(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Ge(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return Ge(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ew(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Ge(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):ur})}return(t){return Ge(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):ur})}next(){return Ge(this,void 0,void 0,function*(){if(this.closed)return ur;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Im(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Ge(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Sw extends of{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof tw?t:new tw(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(bn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(bn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-vw,r=t.readInt32(n),i=t.readAt(n-r,r);return Rc.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class iC extends lf{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof Zd?t:new Zd(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Ge(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return Ge(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(bn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return Ge(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(bn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return Ge(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-vw,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Rc.decode(i)})}_readNextMessageAndValidate(t){return Ge(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class sC extends of{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new _M(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function Ew(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*Iw(e){const t=ji.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Tw(e){return Ts(this,arguments,function*(){const n=yield Qe(ji.from(e));try{if(!(yield Qe(n.open({autoDestroy:!1}))).closed)do yield yield Qe(n);while(!(yield Qe(n.reset().open())).closed)}finally{yield Qe(n.cancel())}})}function aC(e){return new sf(new sC(e))}function oC(e){const t=e.peek(Lc+7&-8);return t&&t.byteLength>=4?Rm(t)?new bw(new Sw(e.read())):new sf(new of(e)):new sf(new of((function*(){})()))}function lC(e){return Ge(this,void 0,void 0,function*(){const t=yield e.peek(Lc+7&-8);return t&&t.byteLength>=4?Rm(t)?new bw(new Sw(yield e.read())):new af(new lf(e)):new af(new lf((function(){return Ts(this,arguments,function*(){})})()))})}function cC(e){return Ge(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new Zd(e,t);return t>=nC&&Rm(yield n.readAt(0,Lc+7&-8))?new rC(new iC(n)):new af(new lf(n))})}class dr extends tn{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof wi?s.data.children:s.data),r=new dr;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof Bn)return this.visitMany(t.data),this;const{type:n}=t;if(!ce.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(ce.isUnion(n))this.nodes.push(new Ua(r,0));else{const{nullCount:i}=t;ce.isNull(n)||fs.call(this,i<=0?new Uint8Array(0):Yd(t.offset,r,t.nullBitmap)),this.nodes.push(new Ua(r,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function fs(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Ls(this._byteLength,t)),this._byteLength+=t,this}function uC(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(fs.call(this,i),n.mode===qr.Sparse)return Om.call(this,e);if(n.mode===qr.Dense){if(e.offset<=0)return fs.call(this,s),Om.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let u,d,h=-1;++h<r;)(u=i[h])!==void 0&&((d=o[u])===void 0&&(d=o[u]=s[h]),a[h]=s[h]-d,l[u]=((t=l[u])!==null&&t!==void 0?t:0)+1);fs.call(this,a),this.visitMany(e.children.map((u,d)=>{const h=n.typeIds[d],y=o[h],S=l[h];return u.slice(y,Math.min(r,S))}))}}return this}function dC(e){let t;return e.nullCount>=e.length?fs.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?fs.call(this,Yd(e.offset,e.length,t)):fs.call(this,Wd(e.values))}function ha(e){return fs.call(this,e.values.subarray(0,e.length*e.stride))}function cf(e){const{length:t,values:n,valueOffsets:r}=e,i=Hn(r[0]),s=Hn(r[t]),a=Math.min(s-i,n.byteLength-i);return fs.call(this,o0(-i,t+1,r)),fs.call(this,n.subarray(i,i+a)),this}function Bm(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return fs.call(this,o0(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Om(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}dr.prototype.visitBool=dC,dr.prototype.visitInt=ha,dr.prototype.visitFloat=ha,dr.prototype.visitUtf8=cf,dr.prototype.visitLargeUtf8=cf,dr.prototype.visitBinary=cf,dr.prototype.visitLargeBinary=cf,dr.prototype.visitFixedSizeBinary=ha,dr.prototype.visitDate=ha,dr.prototype.visitTimestamp=ha,dr.prototype.visitTime=ha,dr.prototype.visitDecimal=ha,dr.prototype.visitList=Bm,dr.prototype.visitStruct=Om,dr.prototype.visitUnion=uC,dr.prototype.visitInterval=ha,dr.prototype.visitDuration=ha,dr.prototype.visitFixedSizeList=Bm,dr.prototype.visitMap=Bm;class Aw extends gm{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Qd,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,gi(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return mo(t)?t.then(n=>this.writeAll(n)):Ho(t)?Mm(this,t):Lm(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof Qd?this._sink=t:(this._sink=new Qd,t&&GF(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&jF(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!Sm(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof si&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof wi&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Sm(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof wi?t instanceof Im||this._writeRecordBatch(t):t instanceof si?this.writeAll(t.batches):Sc(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=ai.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===bn.RecordBatch?this._recordBatchBlocks.push(new Ma(o,t.bodyLength,this._position)):t.headerType===bn.DictionaryBatch&&this._dictionaryBlocks.push(new Ma(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=un(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(ai.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Fc)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=dr.assemble(t),a=new Di(t.numRows,r,i),o=ai.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=dr.assemble(new Bn([t])),l=new Di(t.length,s,a),u=new Fs(l,n,r),d=ai.from(u,i);return this._writeMessage(d)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[u,d]of a.entries())this._writeDictionaryBatch(d,i,u>0);else if(l<a.length)for(const u of a.slice(l))this._writeDictionaryBatch(u,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class Dm extends Aw{static writeAll(t,n){const r=new Dm(n);return mo(t)?t.then(i=>r.writeAll(i)):Ho(t)?Mm(r,t):Lm(r,t)}}class Fm extends Aw{static writeAll(t){const n=new Fm;return mo(t)?t.then(r=>n.writeAll(r)):Ho(t)?Mm(n,t):Lm(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Rc.encode(new Rc(t,Sr.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Lm(e,t){let n=t;t instanceof si&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Mm(e,t){return Ge(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=po(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const u=l;e.write(u)}}catch(u){a={error:u}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function fC(e,t="stream"){return(t==="stream"?Dm:Fm).writeAll(e).toUint8Array(!0)}var hC=Object.create,xw=Object.defineProperty,pC=Object.getOwnPropertyDescriptor,mC=Object.getOwnPropertyNames,yC=Object.getPrototypeOf,gC=Object.prototype.hasOwnProperty,_C=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vC=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mC(t))!gC.call(e,i)&&i!==n&&xw(e,i,{get:()=>t[i],enumerable:!(r=pC(t,i))||r.enumerable});return e},bC=(e,t,n)=>(n=e!=null?hC(yC(e)):{},vC(!e||!e.__esModule?xw(n,"default",{value:e,enumerable:!0}):n,e)),wC=_C((e,t)=>{t.exports=Worker}),SC=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(SC||{}),EC=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(EC||{}),IC=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(IC||{}),TC=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(TC||{}),AC=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(AC||{}),xC=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(xC||{}),NC=class{constructor(t=2){this.level=t}log(t){t.level>=this.level&&console.log(t)}},RC=(e=>(e[e.SUCCESS=0]="SUCCESS",e[e.MAX_ARROW_ERROR=255]="MAX_ARROW_ERROR",e[e.DUCKDB_WASM_RETRY=256]="DUCKDB_WASM_RETRY",e))(RC||{}),BC=class{constructor(t,n){this._bindings=t,this._conn=n}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}async query(t){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:t});let n=await this._bindings.runQuery(this._conn,t),r=ji.from(n);return console.assert(r.isSync(),"Reader is not sync"),console.assert(r.isFile(),"Reader is not file"),new si(r)}async send(t,n=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:t});let r=await this._bindings.startPendingQuery(this._conn,t,n);for(;r==null;)r=await this._bindings.pollPendingQuery(this._conn);let i=new Nw(this._bindings,this._conn,r),s=await ji.from(i);return console.assert(s.isAsync()),console.assert(s.isStream()),s}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(t){return await this._bindings.getTableNames(this._conn,t)}async prepare(t){let n=await this._bindings.createPrepared(this._conn,t);return new OC(this._bindings,this._conn,n)}async insertArrowTable(t,n){let r=fC(t,"stream");await this.insertArrowFromIPCStream(r,n)}async insertArrowFromIPCStream(t,n){await this._bindings.insertArrowFromIPCStream(this._conn,t,n)}async insertCSVFromPath(t,n){await this._bindings.insertCSVFromPath(this._conn,t,n)}async insertJSONFromPath(t,n){await this._bindings.insertJSONFromPath(this._conn,t,n)}},Nw=class{constructor(t,n,r){this.db=t,this.conn=n,this.header=r,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let t=null;for(this._inFlight!=null&&(t=await this._inFlight,this._inFlight=null);t==null;)t=await this.db.fetchQueryResults(this.conn);return this._depleted=t.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:t}}[Symbol.asyncIterator](){return this}},OC=class{constructor(t,n,r){this.bindings=t,this.connectionId=n,this.statementId=r}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...t){let n=await this.bindings.runPrepared(this.connectionId,this.statementId,t),r=ji.from(n);return console.assert(r.isSync()),console.assert(r.isFile()),new si(r)}async send(...t){let n=await this.bindings.sendPrepared(this.connectionId,this.statementId,t),r=new Nw(this.bindings,this.connectionId,n),i=await ji.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}},DC=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(DC||{}),FC=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(FC||{}),mn=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function uf(e){switch(e.typeId){case D.Binary:return{sqlType:"binary"};case D.Bool:return{sqlType:"bool"};case D.Date:return{sqlType:"date"};case D.DateDay:return{sqlType:"date32[d]"};case D.DateMillisecond:return{sqlType:"date64[ms]"};case D.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case D.Float:return{sqlType:"float"};case D.Float16:return{sqlType:"float16"};case D.Float32:return{sqlType:"float32"};case D.Float64:return{sqlType:"float64"};case D.Int:return{sqlType:"int32"};case D.Int16:return{sqlType:"int16"};case D.Int32:return{sqlType:"int32"};case D.Int64:return{sqlType:"int64"};case D.Uint16:return{sqlType:"uint16"};case D.Uint32:return{sqlType:"uint32"};case D.Uint64:return{sqlType:"uint64"};case D.Uint8:return{sqlType:"uint8"};case D.IntervalDayTime:return{sqlType:"interval[dt]"};case D.IntervalYearMonth:return{sqlType:"interval[m]"};case D.List:return{sqlType:"list",valueType:uf(e.valueType)};case D.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case D.Null:return{sqlType:"null"};case D.Utf8:return{sqlType:"utf8"};case D.Struct:return{sqlType:"struct",fields:e.children.map(t=>Cm(t.name,t.type))};case D.Map:{let t=e;return{sqlType:"map",keyType:uf(t.keyType),valueType:uf(t.valueType)}}case D.Time:return{sqlType:"time[s]"};case D.TimeMicrosecond:return{sqlType:"time[us]"};case D.TimeMillisecond:return{sqlType:"time[ms]"};case D.TimeNanosecond:return{sqlType:"time[ns]"};case D.TimeSecond:return{sqlType:"time[s]"};case D.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case D.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case D.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case D.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case D.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Cm(e,t){let n=uf(t);return n.name=e,n}var LC=new TextEncoder,MC=class{constructor(t,n=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=t,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),n!=null&&this.attach(n)}get logger(){return this._logger}attach(t){this._worker=t,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((n,r)=>{this._workerShutdownResolver=n})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(t,n=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let r=this._nextMessageId++;return this._pendingRequests.set(r,t),this._worker.postMessage({messageId:r,type:t.type,data:t.data},n),await t.promise}onMessage(t){var n;let r=t.data;switch(r.type){case"PROGRESS_UPDATE":{for(let s of this._onExecutionProgress)s(r.data);return}case"LOG":{this._logger.log(r.data);return}case"INSTANTIATE_PROGRESS":{for(let s of this._onInstantiationProgress)s(r.data);return}}let i=this._pendingRequests.get(r.requestId);if(!i){console.warn("unassociated response: [".concat(r.requestId,", ").concat(r.type.toString(),"]"));return}if(this._pendingRequests.delete(r.requestId),r.type=="ERROR"){let s=new Error(r.data.message);s.name=r.data.name,(n=Object.getOwnPropertyDescriptor(s,"stack"))!=null&&n.writable&&(s.stack=r.data.stack),i.promiseRejecter(s);return}switch(i.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(r.type=="OK"){i.promiseResolver(r.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],r.type=="OK"){i.promiseResolver(r.data);return}break;case"GLOB_FILE_INFOS":if(r.type=="FILE_INFOS"){i.promiseResolver(r.data);return}break;case"GET_VERSION":if(r.type=="VERSION_STRING"){i.promiseResolver(r.data);return}break;case"GET_FEATURE_FLAGS":if(r.type=="FEATURE_FLAGS"){i.promiseResolver(r.data);return}break;case"GET_TABLE_NAMES":if(r.type=="TABLE_NAMES"){i.promiseResolver(r.data);return}break;case"TOKENIZE":if(r.type=="SCRIPT_TOKENS"){i.promiseResolver(r.data);return}break;case"COPY_FILE_TO_BUFFER":if(r.type=="FILE_BUFFER"){i.promiseResolver(r.data);return}break;case"EXPORT_FILE_STATISTICS":if(r.type=="FILE_STATISTICS"){i.promiseResolver(r.data);return}break;case"CONNECT":if(r.type=="CONNECTION_INFO"){i.promiseResolver(r.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(r.type=="QUERY_RESULT"){i.promiseResolver(r.data);return}break;case"SEND_PREPARED":if(r.type=="QUERY_RESULT_HEADER"){i.promiseResolver(r.data);return}break;case"START_PENDING_QUERY":if(r.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(r.data);return}break;case"POLL_PENDING_QUERY":if(r.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(r.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],r.type=="SUCCESS"){i.promiseResolver(r.data);return}break;case"FETCH_QUERY_RESULTS":if(r.type=="QUERY_RESULT_CHUNK"){i.promiseResolver(r.data);return}break;case"CREATE_PREPARED":if(r.type=="PREPARED_STATEMENT_ID"){i.promiseResolver(r.data);return}break}i.promiseRejecter(new Error("unexpected response type: ".concat(r.type.toString())))}onError(t){console.error(t),console.error("error in duckdb worker: ".concat(t.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let t=new mn("RESET",null);return await this.postTask(t)}async ping(){let t=new mn("PING",null);await this.postTask(t)}async dropFile(t){let n=new mn("DROP_FILE",t);return await this.postTask(n)}async dropFiles(){let t=new mn("DROP_FILES",null);return await this.postTask(t)}async flushFiles(){let t=new mn("FLUSH_FILES",null);return await this.postTask(t)}async instantiate(t,n=null,r=i=>{}){this._onInstantiationProgress.push(r);let i=new mn("INSTANTIATE",[t,n]);return await this.postTask(i)}async getVersion(){let t=new mn("GET_VERSION",null);return await this.postTask(t)}async getFeatureFlags(){let t=new mn("GET_FEATURE_FLAGS",null);return await this.postTask(t)}async open(t){let n=new mn("OPEN",t);await this.postTask(n)}async tokenize(t){let n=new mn("TOKENIZE",t);return await this.postTask(n)}async connectInternal(){let t=new mn("CONNECT",null);return await this.postTask(t)}async connect(){let t=await this.connectInternal();return new BC(this,t)}async disconnect(t){let n=new mn("DISCONNECT",t);await this.postTask(n)}async runQuery(t,n){let r=new mn("RUN_QUERY",[t,n]);return await this.postTask(r)}async startPendingQuery(t,n,r=!1){let i=new mn("START_PENDING_QUERY",[t,n,r]);return await this.postTask(i)}async pollPendingQuery(t){let n=new mn("POLL_PENDING_QUERY",t);return await this.postTask(n)}async cancelPendingQuery(t){let n=new mn("CANCEL_PENDING_QUERY",t);return await this.postTask(n)}async fetchQueryResults(t){let n=new mn("FETCH_QUERY_RESULTS",t);return await this.postTask(n)}async getTableNames(t,n){let r=new mn("GET_TABLE_NAMES",[t,n]);return await this.postTask(r)}async createPrepared(t,n){let r=new mn("CREATE_PREPARED",[t,n]);return await this.postTask(r)}async closePrepared(t,n){let r=new mn("CLOSE_PREPARED",[t,n]);await this.postTask(r)}async runPrepared(t,n,r){let i=new mn("RUN_PREPARED",[t,n,r]);return await this.postTask(i)}async sendPrepared(t,n,r){let i=new mn("SEND_PREPARED",[t,n,r]);return await this.postTask(i)}async globFiles(t){let n=new mn("GLOB_FILE_INFOS",t);return await this.postTask(n)}async registerFileText(t,n){let r=LC.encode(n);await this.registerFileBuffer(t,r)}async registerFileURL(t,n,r,i){n===void 0&&(n=t);let s=new mn("REGISTER_FILE_URL",[t,n,r,i]);await this.postTask(s)}async registerEmptyFileBuffer(t){}async registerFileBuffer(t,n){let r=new mn("REGISTER_FILE_BUFFER",[t,n]);await this.postTask(r,[n.buffer])}async registerFileHandle(t,n,r,i){let s=new mn("REGISTER_FILE_HANDLE",[t,n,r,i]);await this.postTask(s,[])}async registerOPFSFileName(t){let n=new mn("REGISTER_OPFS_FILE_NAME",[t]);await this.postTask(n,[])}async collectFileStatistics(t,n){let r=new mn("COLLECT_FILE_STATISTICS",[t,n]);await this.postTask(r,[])}async exportFileStatistics(t){let n=new mn("EXPORT_FILE_STATISTICS",t);return await this.postTask(n,[])}async copyFileToBuffer(t){let n=new mn("COPY_FILE_TO_BUFFER",t);return await this.postTask(n)}async copyFileToPath(t,n){let r=new mn("COPY_FILE_TO_PATH",[t,n]);await this.postTask(r)}async insertArrowFromIPCStream(t,n,r){if(n.length==0)return;let i=new mn("INSERT_ARROW_FROM_IPC_STREAM",[t,n,r]);await this.postTask(i,[n.buffer])}async insertCSVFromPath(t,n,r){if(r.columns!==void 0){let s=[];for(let a in r.columns){let o=r.columns[a];s.push(Cm(a,o))}r.columnsFlat=s,delete r.columns}let i=new mn("IMPORT_CSV_FROM_PATH",[t,n,r]);await this.postTask(i)}async insertJSONFromPath(t,n,r){if(r.columns!==void 0){let s=[];for(let a in r.columns){let o=r.columns[a];s.push(Cm(a,o))}r.columnsFlat=s,delete r.columns}let i=new mn("IMPORT_JSON_FROM_PATH",[t,n,r]);await this.postTask(i)}};function CC(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}CC();var kC=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(kC||{}),UC=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),PC=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),$C=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),VC=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),km={name:"@duckdb/duckdb-wasm",version:"1.30.0"},zC=km.name,GC=km.version,Um=km.version.split(".");Um[0],Um[1],Um[2];var jC=()=>typeof navigator>"u";function YC(){let e="https://cdn.jsdelivr.net/npm/".concat(zC,"@").concat(GC,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Pm=null,$m=null,Vm=null,zm=null,Gm=null;async function WC(){return Pm==null&&(Pm=typeof BigInt64Array<"u"),$m==null&&($m=await PC()),Vm==null&&(Vm=await VC()),zm==null&&(zm=await $C()),Gm==null&&(Gm=await UC()),{bigInt64Array:Pm,crossOriginIsolated:jC()||globalThis.crossOriginIsolated||!1,wasmExceptions:$m,wasmSIMD:zm,wasmThreads:Vm,wasmBulkMemory:Gm}}async function HC(e){let t=await WC();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}bC(wC());class jm{constructor(t="/data"){this.basePath=t,this.db=null,this.conn=null,this.umapData=null,this.tsneData=null,this.geneCache=new Map,this.loadedChunks=new Set}async initialize(){try{const t=YC(),n=await HC(t),r=URL.createObjectURL(new Blob([`importScripts("${n.mainWorker}");`],{type:"text/javascript"})),i=new Worker(r),s=new NC;this.db=new MC(s,i),await this.db.instantiate(n.mainModule),this.conn=await this.db.connect(),await this.loadEssentialData()}catch(t){throw console.error("Failed to initialize data manager:",t),new Error(`Initialization failed: ${t.message}`)}}async loadEssentialData(){const t=[{name:"umap.parquet",path:`${this.basePath}/umap_complete.parquet`,required:!0},{name:"tsne.parquet",path:`${this.basePath}/tsne_complete.parquet`,required:!1},{name:"gene_locations.parquet",path:`${this.basePath}/gene_locations.parquet`,required:!0},{name:"gene_stats.parquet",path:`${this.basePath}/gene_stats.parquet`,required:!0},{name:"cells.parquet",path:`${this.basePath}/cells.parquet`,required:!0},{name:"metadata.parquet",path:`${this.basePath}/metadata.parquet`,required:!1},{name:"genes.parquet",path:`${this.basePath}/genes.parquet`,required:!0}];for(const s of t)try{console.log(s.path);const a=await fetch(s.path);if(!a.ok){if(s.required)throw new Error(`Failed to load required file: ${s.name} (${a.status} ${a.statusText})`);console.log(`Optional file ${s.name} not available, skipping...`);continue}const o=await a.arrayBuffer();await this.db.registerFileBuffer(s.name,new Uint8Array(o))}catch(a){if(s.required)throw a;console.log(`Optional file ${s.name} not available:`,a.message)}let n=new Map;try{try{(await this.conn.query('SELECT * FROM "metadata.parquet"')).toArray().map(o=>o.toJSON()).forEach(o=>{n.set(o.cell_id,o)})}catch{console.log("metadata.parquet not found, trying cells.parquet..."),(await this.conn.query('SELECT * FROM "cells.parquet"')).toArray().map(l=>l.toJSON()).forEach(l=>{n.set(l.cell_id,l)})}}catch(s){console.warn("Could not load cell metadata:",s)}const i=(await this.conn.query('SELECT * FROM "umap.parquet"')).toArray().map(s=>s.toJSON());this.umapData=i.map(s=>{const a=n.get(s.cell_id)||{};return{...s,...a}});try{const s=await this.conn.query('SELECT * FROM "tsne.parquet"');this.tsneData=s.toArray().map(a=>{const o=a.toJSON(),l=n.get(o.cell_id)||{};return{...o,...l}})}catch{console.log("tSNE data not available"),this.tsneData=null}}async getReductionData(t="umap"){if(t==="umap"){if(!this.umapData)throw new Error("UMAP data not loaded");return this.umapData}else if(t==="tsne"){if(!this.tsneData)throw new Error("tSNE data not available");return this.tsneData}else throw new Error(`Unknown reduction type: ${t}`)}async searchGenes(t){if(!t||t.length<1)return[];try{const i=(await this.conn.query(`
99
99
  DESCRIBE "gene_stats.parquet"
100
100
  `)).toArray().map(o=>o.toJSON()).map(o=>o.column_name);let s=["gene_name"];return i.includes("mean_expr")&&s.push("mean_expr"),i.includes("total_expr")&&s.push("total_expr"),i.includes("pct_cells")&&s.push("pct_cells"),i.includes("n_cells_expressing")&&s.push("n_cells_expressing"),(await this.conn.query(`
101
101
  SELECT ${s.join(", ")}
@@ -115,13 +115,13 @@
115
115
  SELECT location, is_precomputed
116
116
  FROM "gene_locations.parquet"
117
117
  WHERE gene_name = '${t}'
118
- `)).toArray();if(a.length===0)throw new Error(`Gene ${t} not found in dataset`);const o=a[0].toJSON(),l=o.location,u=o.is_precomputed,f=performance.now();let p;if(u){const T=await fetch(`${this.basePath}/${l}`);if(!T.ok)throw new Error(`Failed to load gene file: ${T.statusText}`);const U=await T.arrayBuffer(),J=`gene_${t.replace(/[^a-zA-Z0-9]/g,"_")}.parquet`;await this.db.registerFileBuffer(J,new Uint8Array(U)),p=(await this.conn.query(`
119
- SELECT cell_id, expression FROM "${J}"
120
- `)).toArray().map(X=>X.toJSON())}else{const T=l.split("/").pop();if(!this.loadedChunks.has(T)){const J=await fetch(`${this.basePath}/${l}`);if(!J.ok)throw new Error(`Failed to load chunk file: ${J.statusText}`);const lt=await J.arrayBuffer();await this.db.registerFileBuffer(T,new Uint8Array(lt)),this.loadedChunks.add(T)}p=(await this.conn.query(`
118
+ `)).toArray();if(a.length===0)throw new Error(`Gene ${t} not found in dataset`);const o=a[0].toJSON(),l=o.location,u=o.is_precomputed,d=performance.now();let h;if(u){const S=await fetch(`${this.basePath}/${l}`);if(!S.ok)throw new Error(`Failed to load gene file: ${S.statusText}`);const M=await S.arrayBuffer(),H=`gene_${t.replace(/[^a-zA-Z0-9]/g,"_")}.parquet`;await this.db.registerFileBuffer(H,new Uint8Array(M)),h=(await this.conn.query(`
119
+ SELECT cell_id, expression FROM "${H}"
120
+ `)).toArray().map(j=>j.toJSON())}else{const S=l.split("/").pop();if(!this.loadedChunks.has(S)){const H=await fetch(`${this.basePath}/${l}`);if(!H.ok)throw new Error(`Failed to load chunk file: ${H.statusText}`);const nt=await H.arrayBuffer();await this.db.registerFileBuffer(S,new Uint8Array(nt)),this.loadedChunks.add(S)}h=(await this.conn.query(`
121
121
  SELECT cell_id, expression
122
- FROM "${T}"
122
+ FROM "${S}"
123
123
  WHERE gene_id = ${i}
124
- `)).toArray().map(J=>J.toJSON())}const E=performance.now()-f;return this.geneCache.set(t,p),p}catch(n){throw console.error(`Failed to load gene ${t}:`,n),n}}hasTsne(){return this.tsneData!==null}getCellCount(){return this.umapData?this.umapData.length:0}clearCache(){this.geneCache.clear()}}const QM={class:"gene-coexpression-viewer"},JM={class:"viewer-left"},ZM={class:"controls-panel"},tC={class:"controls-header"},eC={class:"reduction-selector"},nC=["disabled"],rC=["disabled"],iC={class:"genes-section"},sC={class:"genes-input-group"},aC={class:"gene-input-wrapper"},oC={for:"gene1-select"},lC=["disabled"],cC={id:"gene1-list"},uC=["value"],dC={class:"gene-input-wrapper"},fC={for:"gene2-select"},hC=["disabled"],pC={id:"gene2-list"},mC=["value"],yC=["disabled"],gC={key:0},_C={key:1},vC={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{"margin-right":"8px","vertical-align":"-2px"}},bC={key:0,class:"loading-overlay"},wC={key:1,class:"error-panel"},SC={key:2,class:"stats-panel"},EC={class:"stat-item"},IC={class:"stat-value"},TC={class:"stat-item"},AC={class:"stat-value"},xC={class:"stat-item"},RC={class:"stat-value"},NC={class:"stat-item"},BC={class:"stat-value"},OC={class:"viewer-right"},DC={key:0,class:"chart-container"},FC={key:0,class:"chart-loading"},LC={key:1,style:{position:"relative",width:"100%",height:"100%"}},MC=["title","aria-expanded"],CC={key:0,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},kC={key:1,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},UC={key:1,class:"floating-mixer-panel"},PC={class:"floating-gradient-container"},$C={class:"gradient-labels"},VC={class:"y-axis-label"},zC={class:"x-axis-label"},GC={class:"boost-control"},jC={class:"tooltip-header"},YC={class:"tooltip-value"},WC={key:1,class:"legend-container"},HC={class:"legend"},qC={class:"legend-item"},XC={class:"legend-item"},KC=["title"],QC={class:"legend-item"},JC=["title"],ZC={class:"legend-item"},tk={key:2,class:"empty-state"},ek=so({__name:"GeneCoexpressionViewer",props:{dataPath:{type:String,default:"/data"},gene1:{type:[String,null],default:null},gene2:{type:[String,null],default:null}},emits:["update:Vars"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(null),s=c.ref(null),a=c.ref(null),o=c.ref(null),l=c.ref(null),u=c.ref(null),f=c.ref({x:0,y:0}),p=c.ref([]),E=c.ref(null),T=c.ref({w:0,h:0}),U=c.ref(!0),J=c.ref("Initializing data viewer..."),lt=c.ref(null),X=c.ref("umap"),Kt=c.ref(!1),Jt=c.ref(!1),ue=c.ref(n.gene1||""),Wt=c.ref(n.gene2||""),le=c.ref(n.gene1||""),$t=c.ref(n.gene2||""),yn=c.ref([]),Ge=c.ref([]),ce=c.ref([]),Qt=c.ref(null),at=c.ref(null),ct=c.ref("#ff0000"),m=c.ref("#0000ff"),F=c.ref("#FF00FF"),h=c.ref("#CCCCCC"),L=c.ref(1),$=c.ref({totalCells:0,gene1Expressing:0,gene1Pct:0,gene2Expressing:0,gene2Pct:0,coexpressing:0,coexpressPct:0});c.watch(()=>n.gene1,Ht=>{const tt=Ht||"";tt!==le.value&&tt!==ue.value&&(ue.value=tt,le.value=tt,tt&&$t.value&&ce.value.length>0&&ne())}),c.watch(()=>n.gene2,Ht=>{const tt=Ht||"";tt!==$t.value&&tt!==Wt.value&&(Wt.value=tt,$t.value=tt,tt&&le.value&&ce.value.length>0&&ne())}),c.watch(le,Ht=>{Ht&&Ht!==n.gene1&&r("update:Vars","selectedGene1",Ht)}),c.watch($t,Ht=>{Ht&&Ht!==n.gene2&&r("update:Vars","selectedGene2",Ht)});const D=c.computed(()=>ue.value.trim()&&Wt.value.trim()&&ue.value.trim()!==Wt.value.trim()),z=c.computed(()=>$.value.totalCells>0),Z=c.computed(()=>z.value);let _t=null;const wt=Ht=>{clearTimeout(_t),_t=setTimeout(()=>qt(Ht),300)};c.onMounted(async()=>{try{J.value="Loading data manager...",o.value=new J0(n.dataPath),await o.value.initialize(),Kt.value=o.value.hasTsne(),await st(),U.value=!1,J.value="",Ye(),n.gene1&&n.gene2&&(le.value=n.gene1,$t.value=n.gene2,ue.value=n.gene1,Wt.value=n.gene2,await ne())}catch(Ht){console.error("Failed to initialize:",Ht),lt.value=`Failed to load data: ${Ht.message}. Please check that your data files are in the correct location.`,U.value=!1}}),c.onBeforeUnmount(()=>{E.value&&E.value.disconnect(),a.value&&a.value.destroy()}),c.watch(X,async()=>{!U.value&&ce.value.length>0&&D.value&&(await st(),await ne())}),c.watch(Jt,async Ht=>{Ht&&Z.value&&(await c.nextTick(),cr())});async function st(){try{const Ht=await o.value.getReductionData(X.value);ce.value=Ht,$.value.totalCells=Ht.length}catch(Ht){console.error("Failed to load reduction data:",Ht),lt.value=`Failed to load ${X.value.toUpperCase()} data: ${Ht.message}`}}async function qt(Ht){const tt=Ht===1?ue.value:Wt.value;if(tt.length<2){(Ht===1?yn:Ge).value=[];return}try{const Mn=(await o.value.searchGenes(tt)).map(Mr=>Mr.gene_name).slice(0,20);(Ht===1?yn:Ge).value=Mn}catch(te){console.error("Gene search failed:",te)}}async function ne(){if(!D.value){lt.value="Please select two different genes";return}try{U.value=!0,lt.value=null,le.value=ue.value,$t.value=Wt.value,J.value=`Loading ${le.value} expression...`,Qt.value=await o.value.getGeneExpression(le.value),J.value=`Loading ${$t.value} expression...`,at.value=await o.value.getGeneExpression($t.value),J.value="Rendering visualization...",l.value=null,u.value=null,U.value=!1,J.value="",await c.nextTick(),await Yn()}catch(Ht){console.error("Visualization failed:",Ht),lt.value=`Failed to visualize: ${Ht.message}`,U.value=!1}}function Zt(Ht){const tt=parseInt(Ht.slice(1,3),16)/255,te=parseInt(Ht.slice(3,5),16)/255,Mn=parseInt(Ht.slice(5,7),16)/255;return[tt,te,Mn]}function Ye(){var tt,te;const Ht=(te=(tt=i.value)==null?void 0:tt.parentElement)==null?void 0:te.parentElement;Ht&&(E.value=new ResizeObserver(async()=>{!i.value||!Z.value||await Yn()}),E.value.observe(Ht))}async function Yn(){if(await c.nextTick(),!i.value)throw new Error("Chart canvas is not available");const Ht=new Map(Qt.value.map(kt=>[kt.cell_id,kt.expression])),tt=new Map(at.value.map(kt=>[kt.cell_id,kt.expression])),te=Qt.value.map(kt=>kt.expression),Mn=at.value.map(kt=>kt.expression),Mr=Math.max(...te),li=Math.max(...Mn),g=.1,Qn=kt=>Math.max(0,Math.min(255,Math.round(kt))),Rr=kt=>(Math.max(kt[0]??0,kt[1]??0,kt[2]??0)<=1?kt.map(vn=>vn*255):kt).map(Qn),Xe=ce.value.map(kt=>{const nn=Ht.get(kt.cell_id)||0,kn=tt.get(kt.cell_id)||0,vn=Mr>0?Math.min(nn/Mr,1):0,rn=li>0?Math.min(kn/li,1):0,Br=nn>g,_r=kn>g,[Xr,Kr,Xt]=Rr(Zt(h.value)),[he,gn,bn]=Rr(Zt(ct.value)),[sr,wn,$n]=Rr(Zt(m.value)),[Qr,Jr,Vr]=Rr(Zt(F.value));let Zn=Xr*(1-vn)*(1-rn),tr=Kr*(1-vn)*(1-rn),dr=Xt*(1-vn)*(1-rn);if(Zn+=he*vn*(1-rn),tr+=gn*vn*(1-rn),dr+=bn*vn*(1-rn),Zn+=sr*(1-vn)*rn,tr+=wn*(1-vn)*rn,dr+=$n*(1-vn)*rn,vn>0&&rn>0){const kr=vn*rn,zr=(he+sr)/2,Ji=(gn+wn)/2,va=(bn+$n)/2;Zn+=zr*kr,tr+=Ji*kr,dr+=va*kr;const hs=Math.pow(kr,2)*L.value,ps=1+hs;Zn=(Zn+Qr*hs)/ps,tr=(tr+Jr*hs)/ps,dr=(dr+Vr*hs)/ps}let fr=0,Cr=1;Br&&_r?(fr=3,Cr=.9):Br?(fr=2,Cr=.8):_r&&(fr=1,Cr=.8);const ui=`rgb(${Qn(Zn)}, ${Qn(tr)}, ${Qn(dr)})`;return{...kt,x:X.value==="umap"?kt.umap_1:kt.tsne_1,y:X.value==="umap"?kt.umap_2:kt.tsne_2,color:ui,zIndex:fr,opacity:Cr,expr1:nn,expr2:kn,norm1:vn,norm2:rn,cell_id:kt.cell_id,cell_type:kt.cell_type||"Unknown"}});Xe.sort((kt,nn)=>kt.zIndex-nn.zIndex),p.value=Xe;const zs=Xe.filter(kt=>kt.expr1>g&&kt.expr2<=g).length,Un=Xe.filter(kt=>kt.expr2>g&&kt.expr1<=g).length,Li=Xe.filter(kt=>kt.expr1>g&&kt.expr2>g).length;$.value={totalCells:Xe.length,gene1Expressing:zs,gene1Pct:(zs/Xe.length*100).toFixed(1),gene2Expressing:Un,gene2Pct:(Un/Xe.length*100).toFixed(1),coexpressing:Li,coexpressPct:(Li/Xe.length*100).toFixed(1)};const ke=i.value,Mi=ke.parentElement.getBoundingClientRect(),H=0,bt=Math.max(1,Math.floor(Mi.width-H)),Ft=Math.max(1,Math.floor(Mi.height-H));if(ke.width=bt,ke.height=Ft,ke.style.width=`${bt}px`,ke.style.height=`${Ft}px`,T.value={w:bt,h:Ft},a.value){try{a.value.destroy()}catch{}a.value=null}try{a.value||(a.value=Np(ke))}catch(kt){console.error("WebGL not supported, fallback to 2D:",kt),_n(Xe);return}const Ut=a.value,fe=Ra(Xe,kt=>kt.x),De=Ra(Xe,kt=>kt.y),Ue=(fe[1]-fe[0])*.05,Fe=(De[1]-De[0])*.05;fe[0]-=Ue,fe[1]+=Ue,De[0]-=Fe,De[1]+=Fe;const Pn=ea().domain(fe).range([-1,1]),Rn=ea().domain(De).range([-1,1]),on=[],hn=[];Xe.forEach(kt=>{if(on.push(Pn(kt.x),Rn(kt.y)),kt.color.startsWith("#")){const nn=Zt(kt.color);hn.push(...nn,kt.opacity)}else{const nn=kt.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);nn?hn.push(parseInt(nn[1])/255,parseInt(nn[2])/255,parseInt(nn[3])/255,kt.opacity):hn.push(.8,.8,.8,kt.opacity)}});const ur=Ut({frag:`
124
+ `)).toArray().map(H=>H.toJSON())}const y=performance.now()-d;return this.geneCache.set(t,h),h}catch(n){throw console.error(`Failed to load gene ${t}:`,n),n}}async executeCustomQuery(t,n=[]){if(!isValidQuery(t,n))throw new Error("Invalid query - security check failed");try{return(await db.query(t)).toArray()}catch(r){throw console.error("Query execution failed:",r),r}}isValidQuery(t,n){const r=t.toLowerCase().trim();return!(!r.startsWith("select")||["insert","update","delete","drop","alter","create","grant"].some(a=>r.includes(a))||r.includes("parquet_scan")&&!/parquet_scan\(['"]s3:\/\/your-allowed-bucket\//.test(t)||(t.match(/\(/g)||[]).length>4)}hasTsne(){return this.tsneData!==null}getCellCount(){return this.umapData?this.umapData.length:0}clearCache(){this.geneCache.clear()}}const qC={class:"gene-coexpression-viewer"},XC={class:"viewer-left"},KC={class:"controls-panel"},QC={class:"controls-header"},JC={class:"reduction-selector"},ZC=["disabled"],tk=["disabled"],ek={class:"genes-section"},nk={class:"genes-input-group"},rk={class:"gene-input-wrapper"},ik={for:"gene1-select"},sk=["disabled"],ak={id:"gene1-list"},ok=["value"],lk={class:"gene-input-wrapper"},ck={for:"gene2-select"},uk=["disabled"],dk={id:"gene2-list"},fk=["value"],hk=["disabled"],pk={key:0},mk={key:1},yk={width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",style:{"margin-right":"8px","vertical-align":"-2px"}},gk={key:0,class:"loading-overlay"},_k={key:1,class:"error-panel"},vk={key:2,class:"stats-panel"},bk={class:"stat-item"},wk={class:"stat-value"},Sk={class:"stat-item"},Ek={class:"stat-value"},Ik={class:"stat-item"},Tk={class:"stat-value"},Ak={class:"stat-item"},xk={class:"stat-value"},Nk={class:"viewer-right"},Rk={key:0,class:"chart-container"},Bk={key:0,class:"chart-loading"},Ok={key:1,style:{position:"relative",width:"100%",height:"100%"}},Dk=["title","aria-expanded"],Fk={key:0,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Lk={key:1,width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Mk={key:1,class:"floating-mixer-panel"},Ck={class:"floating-gradient-container"},kk={class:"gradient-labels"},Uk={class:"y-axis-label"},Pk={class:"x-axis-label"},$k={class:"boost-control"},Vk={class:"tooltip-header"},zk={class:"tooltip-value"},Gk={key:1,class:"legend-container"},jk={class:"legend"},Yk={class:"legend-item"},Wk={class:"legend-item"},Hk=["title"],qk={class:"legend-item"},Xk=["title"],Kk={class:"legend-item"},Qk={key:2,class:"empty-state"},Jk=ea({__name:"GeneCoexpressionViewer",props:{dataPath:{type:String,default:"/data"},gene1:{type:[String,null],default:null},gene2:{type:[String,null],default:null}},emits:["update:Vars"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(null),s=c.ref(null),a=c.ref(null),o=c.ref(null),l=c.ref(null),u=c.ref(null),d=c.ref({x:0,y:0}),h=c.ref([]),y=c.ref(null),S=c.ref({w:0,h:0}),M=c.ref(!0),H=c.ref("Initializing data viewer..."),nt=c.ref(null),j=c.ref("umap"),$t=c.ref(!1),Ct=c.ref(!1),Zt=c.ref(n.gene1||""),Lt=c.ref(n.gene2||""),ie=c.ref(n.gene1||""),xt=c.ref(n.gene2||""),on=c.ref([]),ge=c.ref([]),ne=c.ref([]),Qt=c.ref(null),rt=c.ref(null),ot=c.ref("#ff0000"),m=c.ref("#0000ff"),T=c.ref("#FF00FF"),p=c.ref("#CCCCCC"),L=c.ref(1),C=c.ref({totalCells:0,gene1Expressing:0,gene1Pct:0,gene2Expressing:0,gene2Pct:0,coexpressing:0,coexpressPct:0});c.watch(()=>n.gene1,qt=>{const et=qt||"";et!==ie.value&&et!==Zt.value&&(Zt.value=et,ie.value=et,et&&xt.value&&ne.value.length>0&&re())}),c.watch(()=>n.gene2,qt=>{const et=qt||"";et!==xt.value&&et!==Lt.value&&(Lt.value=et,xt.value=et,et&&ie.value&&ne.value.length>0&&re())}),c.watch(ie,qt=>{qt&&qt!==n.gene1&&r("update:Vars","selectedGene1",qt)}),c.watch(xt,qt=>{qt&&qt!==n.gene2&&r("update:Vars","selectedGene2",qt)});const R=c.computed(()=>Zt.value.trim()&&Lt.value.trim()&&Zt.value.trim()!==Lt.value.trim()),U=c.computed(()=>C.value.totalCells>0),tt=c.computed(()=>U.value);let ht=null;const ut=qt=>{clearTimeout(ht),ht=setTimeout(()=>Jt(qt),300)};c.onMounted(async()=>{try{H.value="Loading data manager...",o.value=new jm(n.dataPath),await o.value.initialize(),$t.value=o.value.hasTsne(),await J(),M.value=!1,H.value="",fe(),n.gene1&&n.gene2&&(ie.value=n.gene1,xt.value=n.gene2,Zt.value=n.gene1,Lt.value=n.gene2,await re())}catch(qt){console.error("Failed to initialize:",qt),nt.value=`Failed to load data: ${qt.message}. Please check that your data files are in the correct location.`,M.value=!1}}),c.onBeforeUnmount(()=>{y.value&&y.value.disconnect(),a.value&&a.value.destroy()}),c.watch(j,async()=>{!M.value&&ne.value.length>0&&R.value&&(await J(),await re())}),c.watch(Ct,async qt=>{qt&&tt.value&&(await c.nextTick(),Kn())});async function J(){try{const qt=await o.value.getReductionData(j.value);ne.value=qt,C.value.totalCells=qt.length}catch(qt){console.error("Failed to load reduction data:",qt),nt.value=`Failed to load ${j.value.toUpperCase()} data: ${qt.message}`}}async function Jt(qt){const et=qt===1?Zt.value:Lt.value;if(et.length<2){(qt===1?on:ge).value=[];return}try{const gn=(await o.value.searchGenes(et)).map(_n=>_n.gene_name).slice(0,20);(qt===1?on:ge).value=gn}catch(te){console.error("Gene search failed:",te)}}async function re(){if(!R.value){nt.value="Please select two different genes";return}try{M.value=!0,nt.value=null,ie.value=Zt.value,xt.value=Lt.value,H.value=`Loading ${ie.value} expression...`,Qt.value=await o.value.getGeneExpression(ie.value),H.value=`Loading ${xt.value} expression...`,rt.value=await o.value.getGeneExpression(xt.value),H.value="Rendering visualization...",l.value=null,u.value=null,M.value=!1,H.value="",await c.nextTick(),await En()}catch(qt){console.error("Visualization failed:",qt),nt.value=`Failed to visualize: ${qt.message}`,M.value=!1}}function Rt(qt){const et=parseInt(qt.slice(1,3),16)/255,te=parseInt(qt.slice(3,5),16)/255,gn=parseInt(qt.slice(5,7),16)/255;return[et,te,gn]}function fe(){var et,te;const qt=(te=(et=i.value)==null?void 0:et.parentElement)==null?void 0:te.parentElement;qt&&(y.value=new ResizeObserver(async()=>{!i.value||!tt.value||await En()}),y.value.observe(qt))}async function En(){if(await c.nextTick(),!i.value)throw new Error("Chart canvas is not available");const qt=new Map(Qt.value.map(zt=>[zt.cell_id,zt.expression])),et=new Map(rt.value.map(zt=>[zt.cell_id,zt.expression])),te=Qt.value.map(zt=>zt.expression),gn=rt.value.map(zt=>zt.expression),_n=Math.max(...te),tr=Math.max(...gn),_=.1,Qn=zt=>Math.max(0,Math.min(255,Math.round(zt))),Ir=zt=>(Math.max(zt[0]??0,zt[1]??0,zt[2]??0)<=1?zt.map(An=>An*255):zt).map(Qn),Ye=ne.value.map(zt=>{const nn=qt.get(zt.cell_id)||0,Gn=et.get(zt.cell_id)||0,An=_n>0?Math.min(nn/_n,1):0,rn=tr>0?Math.min(Gn/tr,1):0,Cr=nn>_,Tr=Gn>_,[Jr,Zr,ee]=Ir(Rt(p.value)),[me,Sn,xn]=Ir(Rt(ot.value)),[hr,Nn,Yn]=Ir(Rt(m.value)),[ti,ei,Wr]=Ir(Rt(T.value));let or=Jr*(1-An)*(1-rn),lr=Zr*(1-An)*(1-rn),_r=ee*(1-An)*(1-rn);if(or+=me*An*(1-rn),lr+=Sn*An*(1-rn),_r+=xn*An*(1-rn),or+=hr*(1-An)*rn,lr+=Nn*(1-An)*rn,_r+=Yn*(1-An)*rn,An>0&&rn>0){const zr=An*rn,Hr=(me+hr)/2,ts=(Sn+Nn)/2,Sa=(xn+Yn)/2;or+=Hr*zr,lr+=ts*zr,_r+=Sa*zr;const ys=Math.pow(zr,2)*L.value,gs=1+ys;or=(or+ti*ys)/gs,lr=(lr+ei*ys)/gs,_r=(_r+Wr*ys)/gs}let vr=0,Vr=1;Cr&&Tr?(vr=3,Vr=.9):Cr?(vr=2,Vr=.8):Tr&&(vr=1,Vr=.8);const hi=`rgb(${Qn(or)}, ${Qn(lr)}, ${Qn(_r)})`;return{...zt,x:j.value==="umap"?zt.umap_1:zt.tsne_1,y:j.value==="umap"?zt.umap_2:zt.tsne_2,color:hi,zIndex:vr,opacity:Vr,expr1:nn,expr2:Gn,norm1:An,norm2:rn,cell_id:zt.cell_id,cell_type:zt.cell_type||"Unknown"}});Ye.sort((zt,nn)=>zt.zIndex-nn.zIndex),h.value=Ye;const Zi=Ye.filter(zt=>zt.expr1>_&&zt.expr2<=_).length,Tn=Ye.filter(zt=>zt.expr2>_&&zt.expr1<=_).length,di=Ye.filter(zt=>zt.expr1>_&&zt.expr2>_).length;C.value={totalCells:Ye.length,gene1Expressing:Zi,gene1Pct:(Zi/Ye.length*100).toFixed(1),gene2Expressing:Tn,gene2Pct:(Tn/Ye.length*100).toFixed(1),coexpressing:di,coexpressPct:(di/Ye.length*100).toFixed(1)};const he=i.value,Ci=he.parentElement.getBoundingClientRect(),X=0,wt=Math.max(1,Math.floor(Ci.width-X)),kt=Math.max(1,Math.floor(Ci.height-X));if(he.width=wt,he.height=kt,he.style.width=`${wt}px`,he.style.height=`${kt}px`,S.value={w:wt,h:kt},a.value){try{a.value.destroy()}catch{}a.value=null}try{a.value||(a.value=Wp(he))}catch(zt){console.error("WebGL not supported, fallback to 2D:",zt),hn(Ye);return}const Gt=a.value,pe=na(Ye,zt=>zt.x),Me=na(Ye,zt=>zt.y),$e=(pe[1]-pe[0])*.05,Ce=(Me[1]-Me[0])*.05;pe[0]-=$e,pe[1]+=$e,Me[0]-=Ce,Me[1]+=Ce;const jn=cs().domain(pe).range([-1,1]),Mn=cs().domain(Me).range([-1,1]),ln=[],vn=[];Ye.forEach(zt=>{if(ln.push(jn(zt.x),Mn(zt.y)),zt.color.startsWith("#")){const nn=Rt(zt.color);vn.push(...nn,zt.opacity)}else{const nn=zt.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);nn?vn.push(parseInt(nn[1])/255,parseInt(nn[2])/255,parseInt(nn[3])/255,zt.opacity):vn.push(.8,.8,.8,zt.opacity)}});const gr=Gt({frag:`
125
125
  precision mediump float;
126
126
  varying vec4 vColor;
127
127
  void main() {
@@ -143,7 +143,7 @@
143
143
  gl_Position = vec4(pos, 0, 1);
144
144
  gl_PointSize = pointSize;
145
145
  vColor = color;
146
- }`,attributes:{position:on,color:hn},uniforms:{pointSize:Ut.prop("pointSize"),scale:Ut.prop("scale"),translate:Ut.prop("translate")},count:Xe.length,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),ci=Rp().scaleExtent([.5,10]).filter(kt=>kt.type!=="wheel").on("zoom",kt=>{kt.sourceEvent&&kt.sourceEvent.type!=="wheel"&&(l.value=kt.transform,Ke())});Gr(ke).call(ci),ke.addEventListener("wheel",kt=>{kt.preventDefault();const nn=ke.getBoundingClientRect(),kn=kt.clientX-nn.left,vn=kt.clientY-nn.top,rn=l.value||xi,Br=kn/ke.width*2-1,_r=-(vn/ke.height*2-1),Xr=2*rn.x/ke.width,Kr=-(2*rn.y)/ke.height,Xt=(Br-Xr)/rn.k,he=(_r-Kr)/rn.k,gn=-kt.deltaY*.002,bn=Math.max(.5,Math.min(10,rn.k*Math.pow(2,gn))),sr=Br-Xt*bn,wn=_r-he*bn,$n=sr*ke.width/2,Qr=-(wn*ke.height)/2,Jr=xi.translate($n,Qr).scale(bn);l.value=Jr,Ke(),Gr(ke).property("__zoom",Jr)},{passive:!1}),ke.addEventListener("mousemove",kt=>{const nn=ke.getBoundingClientRect(),kn=kt.clientX-nn.left,vn=kt.clientY-nn.top,rn=l.value||xi,Br=kn/ke.width*2-1,_r=-(vn/ke.height*2-1),Xr=10/rn.k;let Kr=null,Xt=Xr,he=-1;p.value.forEach((gn,bn)=>{const sr=Pn(gn.x),wn=Rn(gn.y),$n=2*rn.x/ke.width,Qr=-(2*rn.y)/ke.height,Jr=sr*rn.k+$n,Vr=wn*rn.k+Qr,Zn=Jr-Br,tr=Vr-_r,dr=Math.sqrt(Zn*Zn+tr*tr);dr<Xt&&(Xt=dr,Kr=gn,he=bn)}),Kr?(u.value=Kr,f.value={x:kt.clientX+15,y:kt.clientY-10},Cn(he,rn)):(u.value=null,Ke())}),ke.addEventListener("mouseleave",()=>{u.value=null,Ke()});function Ke(){Ut.clear({color:[1,1,1,1],depth:1});let kt=1,nn=[0,0],kn=3;if(l.value){const{k:vn,x:rn,y:Br}=l.value;kt=vn,nn=[2*rn/ke.width,-(2*Br)/ke.height],kn=Math.max(2,3*vn)}ur({scale:kt,translate:nn,pointSize:kn})}function Cn(kt,nn){Ke();const kn=p.value[kt],vn=Pn(kn.x),rn=Rn(kn.y);Ut({frag:`
146
+ }`,attributes:{position:ln,color:vn},uniforms:{pointSize:Gt.prop("pointSize"),scale:Gt.prop("scale"),translate:Gt.prop("translate")},count:Ye.length,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),fi=Yp().scaleExtent([.5,10]).filter(zt=>zt.type!=="wheel").on("zoom",zt=>{zt.sourceEvent&&zt.sourceEvent.type!=="wheel"&&(l.value=zt.transform,Ke())});Pr(he).call(fi),he.addEventListener("wheel",zt=>{zt.preventDefault();const nn=he.getBoundingClientRect(),Gn=zt.clientX-nn.left,An=zt.clientY-nn.top,rn=l.value||Ri,Cr=Gn/he.width*2-1,Tr=-(An/he.height*2-1),Jr=2*rn.x/he.width,Zr=-(2*rn.y)/he.height,ee=(Cr-Jr)/rn.k,me=(Tr-Zr)/rn.k,Sn=-zt.deltaY*.002,xn=Math.max(.5,Math.min(10,rn.k*Math.pow(2,Sn))),hr=Cr-ee*xn,Nn=Tr-me*xn,Yn=hr*he.width/2,ti=-(Nn*he.height)/2,ei=Ri.translate(Yn,ti).scale(xn);l.value=ei,Ke(),Pr(he).property("__zoom",ei)},{passive:!1}),he.addEventListener("mousemove",zt=>{const nn=he.getBoundingClientRect(),Gn=zt.clientX-nn.left,An=zt.clientY-nn.top,rn=l.value||Ri,Cr=Gn/he.width*2-1,Tr=-(An/he.height*2-1),Jr=10/rn.k;let Zr=null,ee=Jr,me=-1;h.value.forEach((Sn,xn)=>{const hr=jn(Sn.x),Nn=Mn(Sn.y),Yn=2*rn.x/he.width,ti=-(2*rn.y)/he.height,ei=hr*rn.k+Yn,Wr=Nn*rn.k+ti,or=ei-Cr,lr=Wr-Tr,_r=Math.sqrt(or*or+lr*lr);_r<ee&&(ee=_r,Zr=Sn,me=xn)}),Zr?(u.value=Zr,d.value={x:zt.clientX+15,y:zt.clientY-10},zn(me,rn)):(u.value=null,Ke())}),he.addEventListener("mouseleave",()=>{u.value=null,Ke()});function Ke(){Gt.clear({color:[1,1,1,1],depth:1});let zt=1,nn=[0,0],Gn=3;if(l.value){const{k:An,x:rn,y:Cr}=l.value;zt=An,nn=[2*rn/he.width,-(2*Cr)/he.height],Gn=Math.max(2,3*An)}gr({scale:zt,translate:nn,pointSize:Gn})}function zn(zt,nn){Ke();const Gn=h.value[zt],An=jn(Gn.x),rn=Mn(Gn.y);Gt({frag:`
147
147
  precision mediump float;
148
148
  varying vec4 vColor;
149
149
  void main() {
@@ -168,7 +168,7 @@
168
168
  gl_Position = vec4(pos, 0, 1);
169
169
  gl_PointSize = pointSize;
170
170
  vColor = color;
171
- }`,attributes:{position:[vn,rn],color:(()=>{if(kn.color.startsWith("#"))return[...Zt(kn.color),kn.opacity];const _r=kn.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return _r?[parseInt(_r[1])/255,parseInt(_r[2])/255,parseInt(_r[3])/255,kn.opacity]:[.8,.8,.8,kn.opacity]})()},uniforms:{pointSize:Math.max(12,8*nn.k),scale:nn.k,translate:[2*nn.x/ke.width,-(2*nn.y)/ke.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}Ke(),await c.nextTick(),cr()}function _n(Ht){const tt=i.value,te=tt.getContext("2d"),Mr=tt.parentElement.getBoundingClientRect();tt.width=Math.max(1,Math.floor(Mr.width)),tt.height=Math.max(300,Math.floor(Mr.height));const li=Ra(Ht,Xe=>Xe.x),g=Ra(Ht,Xe=>Xe.y),Qn=ea().domain(li).range([20,tt.width-20]),Rr=ea().domain(g).range([tt.height-20,20]);te.clearRect(0,0,tt.width,tt.height),Ht.forEach(Xe=>{te.fillStyle=Xe.color,te.globalAlpha=Xe.opacity,te.beginPath(),te.arc(Qn(Xe.x),Rr(Xe.y),2,0,2*Math.PI),te.fill()}),te.globalAlpha=1}function cr(){if(!s.value)return;const Ht=s.value,tt=Ht.getContext("2d"),te=Math.max(Ht.width||150,Ht.height||150);Ht.width!==te&&(Ht.width=te),Ht.height!==te&&(Ht.height=te);const Mn=tt.createImageData(te,te),Mr=Mn.data,li=Un=>Math.max(0,Math.min(255,Math.round(Un))),g=Un=>(Math.max(Un[0]??0,Un[1]??0,Un[2]??0)<=1?Un.map(Nr=>Nr*255):Un).map(li),Qn=g(Zt(h.value)),Rr=g(Zt(ct.value)),Xe=g(Zt(m.value)),zs=g(Zt(F.value));for(let Un=0;Un<te;Un++)for(let Li=0;Li<te;Li++){const ke=Li/(te-1),Nr=(te-1-Un)/(te-1);let Mi=Qn[0]*(1-ke)*(1-Nr),H=Qn[1]*(1-ke)*(1-Nr),bt=Qn[2]*(1-ke)*(1-Nr);if(Mi+=Rr[0]*ke*(1-Nr),H+=Rr[1]*ke*(1-Nr),bt+=Rr[2]*ke*(1-Nr),Mi+=Xe[0]*(1-ke)*Nr,H+=Xe[1]*(1-ke)*Nr,bt+=Xe[2]*(1-ke)*Nr,ke>0&&Nr>0){const Ut=ke*Nr,fe=(Rr[0]+Xe[0])/2,De=(Rr[1]+Xe[1])/2,Ue=(Rr[2]+Xe[2])/2;Mi+=fe*Ut,H+=De*Ut,bt+=Ue*Ut;const Fe=Math.pow(Ut,2)*L.value,Pn=1+Fe;Mi=(Mi+zs[0]*Fe)/Pn,H=(H+zs[1]*Fe)/Pn,bt=(bt+zs[2]*Fe)/Pn}const Ft=(Un*te+Li)*4;Mr[Ft]=li(Mi),Mr[Ft+1]=li(H),Mr[Ft+2]=li(bt),Mr[Ft+3]=255}tt.putImageData(Mn,0,0)}function Fr(Ht){const tt={};Ht.cell_type&&(tt.cell_type=Ht.cell_type),tt[le.value]=Ht.expr1,tt[$t.value]=Ht.expr2;const te=new Set(["cell_id","umap_1","umap_2","tsne_1","tsne_2","x","y","color","zIndex","opacity","expr1","expr2","norm1","norm2"]);return Object.keys(Ht).forEach(Mn=>{!te.has(Mn)&&Ht[Mn]!==null&&Ht[Mn]!==void 0&&(tt[Mn]=Ht[Mn])}),tt}function Si(Ht){return Ht===le.value?{color:ct.value}:Ht===$t.value?{color:m.value}:{}}function gr(Ht){return Ht.split("_").map(tt=>tt.charAt(0).toUpperCase()+tt.slice(1)).join(" ")}function qr(Ht,tt){return typeof tt=="number"?Ht===le.value||Ht===$t.value?tt.toFixed(3):tt<.01&&tt>0?tt.toExponential(2):Math.abs(tt)>1e3?tt.toLocaleString():tt.toFixed(2):tt}async function Lr(){Z.value&&await Yn(),await c.nextTick(),Jt.value&&cr()}return(Ht,tt)=>(c.openBlock(),c.createElementBlock("div",QM,[c.createElementVNode("div",JM,[c.createElementVNode("div",ZM,[c.createElementVNode("div",tC,[tt[14]||(tt[14]=c.createElementVNode("h3",null,"Gene Co-expression Analysis",-1)),c.createElementVNode("div",eC,[tt[13]||(tt[13]=c.createElementVNode("label",{for:"reduction-select"},"Visualization:",-1)),c.withDirectives(c.createElementVNode("select",{id:"reduction-select","onUpdate:modelValue":tt[0]||(tt[0]=te=>X.value=te),disabled:U.value},[tt[12]||(tt[12]=c.createElementVNode("option",{value:"umap"},"UMAP",-1)),c.createElementVNode("option",{value:"tsne",disabled:!Kt.value}," tSNE "+c.toDisplayString(Kt.value?"":"(not available)"),9,rC)],8,nC),[[c.vModelSelect,X.value]])])]),c.createElementVNode("div",iC,[c.createElementVNode("div",sC,[c.createElementVNode("div",aC,[c.createElementVNode("label",oC,[tt[15]||(tt[15]=c.createElementVNode("span",{class:"gene-number"},"Gene 1",-1)),le.value?(c.openBlock(),c.createElementBlock("span",{key:0,class:"selected-gene",style:c.normalizeStyle({color:ct.value})},c.toDisplayString(le.value),5)):c.createCommentVNode("",!0)]),c.withDirectives(c.createElementVNode("input",{id:"gene1-select","onUpdate:modelValue":tt[1]||(tt[1]=te=>ue.value=te),type:"text",placeholder:"Enter gene name (e.g., CDH9)",onInput:tt[2]||(tt[2]=te=>wt(1)),disabled:U.value,list:"gene1-list",autocomplete:"off",class:"gene-input"},null,40,lC),[[c.vModelText,ue.value]]),c.createElementVNode("datalist",cC,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(yn.value,te=>(c.openBlock(),c.createElementBlock("option",{key:te,value:te},null,8,uC))),128))])]),tt[17]||(tt[17]=c.createElementVNode("div",{class:"vs-separator"},[c.createElementVNode("span",null,"vs")],-1)),c.createElementVNode("div",dC,[c.createElementVNode("label",fC,[tt[16]||(tt[16]=c.createElementVNode("span",{class:"gene-number"},"Gene 2",-1)),$t.value?(c.openBlock(),c.createElementBlock("span",{key:0,class:"selected-gene",style:c.normalizeStyle({color:m.value})},c.toDisplayString($t.value),5)):c.createCommentVNode("",!0)]),c.withDirectives(c.createElementVNode("input",{id:"gene2-select","onUpdate:modelValue":tt[3]||(tt[3]=te=>Wt.value=te),type:"text",placeholder:"Enter gene name (e.g., TAC1)",onInput:tt[4]||(tt[4]=te=>wt(2)),disabled:U.value,list:"gene2-list",autocomplete:"off",class:"gene-input"},null,40,hC),[[c.vModelText,Wt.value]]),c.createElementVNode("datalist",pC,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(Ge.value,te=>(c.openBlock(),c.createElementBlock("option",{key:te,value:te},null,8,mC))),128))])])]),c.createElementVNode("button",{onClick:ne,disabled:!D.value||U.value,class:"visualize-btn"},[U.value?(c.openBlock(),c.createElementBlock("span",gC,[...tt[18]||(tt[18]=[c.createElementVNode("span",{class:"btn-spinner"},null,-1),c.createTextVNode("Loading...",-1)])])):(c.openBlock(),c.createElementBlock("span",_C,[(c.openBlock(),c.createElementBlock("svg",vC,[...tt[19]||(tt[19]=[c.createElementVNode("circle",{cx:"11",cy:"11",r:"8"},null,-1),c.createElementVNode("path",{d:"m21 21-4.35-4.35"},null,-1)])])),tt[20]||(tt[20]=c.createTextVNode(" Visualize Co-expression ",-1))]))],8,yC)])]),U.value&&!o.value?(c.openBlock(),c.createElementBlock("div",bC,[tt[21]||(tt[21]=c.createElementVNode("div",{class:"spinner"},null,-1)),c.createElementVNode("p",null,c.toDisplayString(J.value),1)])):c.createCommentVNode("",!0),lt.value?(c.openBlock(),c.createElementBlock("div",wC,[tt[22]||(tt[22]=c.createElementVNode("strong",null,"⚠️ Error:",-1)),c.createTextVNode(" "+c.toDisplayString(lt.value)+" ",1),c.createElementVNode("button",{onClick:tt[5]||(tt[5]=te=>lt.value=null),class:"dismiss-btn"},"Dismiss")])):c.createCommentVNode("",!0),z.value?(c.openBlock(),c.createElementBlock("div",SC,[c.createElementVNode("div",EC,[tt[23]||(tt[23]=c.createElementVNode("span",{class:"stat-label"},"Total cells:",-1)),c.createElementVNode("span",IC,c.toDisplayString($.value.totalCells.toLocaleString()),1)]),c.createElementVNode("div",TC,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:ct.value})},c.toDisplayString(le.value)+" expressing:",5),c.createElementVNode("span",AC,c.toDisplayString($.value.gene1Expressing.toLocaleString())+" ("+c.toDisplayString($.value.gene1Pct)+"%)",1)]),c.createElementVNode("div",xC,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:m.value})},c.toDisplayString($t.value)+" expressing:",5),c.createElementVNode("span",RC,c.toDisplayString($.value.gene2Expressing.toLocaleString())+" ("+c.toDisplayString($.value.gene2Pct)+"%)",1)]),c.createElementVNode("div",NC,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:F.value})},"Co-expressing:",4),c.createElementVNode("span",BC,c.toDisplayString($.value.coexpressing.toLocaleString())+" ("+c.toDisplayString($.value.coexpressPct)+"%)",1)])])):c.createCommentVNode("",!0)]),c.createElementVNode("div",OC,[Z.value||U.value&&o.value?(c.openBlock(),c.createElementBlock("div",DC,[U.value&&o.value?(c.openBlock(),c.createElementBlock("div",FC,[tt[24]||(tt[24]=c.createElementVNode("div",{class:"small-spinner"},null,-1)),c.createElementVNode("p",null,c.toDisplayString(J.value),1)])):(c.openBlock(),c.createElementBlock("div",LC,[c.createElementVNode("canvas",{ref_key:"chartCanvas",ref:i},null,512),Z.value||U.value&&o.value?(c.openBlock(),c.createElementBlock("button",{key:0,class:"floating-mixer-toggle",onClick:tt[6]||(tt[6]=te=>Jt.value=!Jt.value),title:Jt.value?"Hide Color Mixing Guide":"Open Color Mixing Guide","aria-expanded":Jt.value.toString()},[Jt.value?(c.openBlock(),c.createElementBlock("svg",kC,[...tt[26]||(tt[26]=[c.createElementVNode("path",{d:"M6 9l6 6 6-6"},null,-1)])])):(c.openBlock(),c.createElementBlock("svg",CC,[...tt[25]||(tt[25]=[c.createElementVNode("path",{d:"M18 15l-6-6-6 6"},null,-1)])]))],8,MC)):c.createCommentVNode("",!0),Jt.value&&(Z.value||U.value&&o.value)?(c.openBlock(),c.createElementBlock("div",UC,[tt[30]||(tt[30]=c.createElementVNode("div",{class:"floating-mixer-header"},[c.createElementVNode("span",null,"Color Mixing Guide")],-1)),c.createElementVNode("div",PC,[c.createElementVNode("div",null,[c.createElementVNode("canvas",{ref_key:"gradientCanvas",ref:s,class:"gradient-canvas",width:"150",height:"150",onClick:cr},null,512),c.createElementVNode("div",$C,[c.createElementVNode("div",VC,c.toDisplayString($t.value||"Gene 2")+" Expression ",1),c.createElementVNode("div",zC,c.toDisplayString(le.value||"Gene 1")+" Expression ",1),tt[27]||(tt[27]=c.createElementVNode("div",{class:"axis-arrow x-arrow-right"},"→",-1)),tt[28]||(tt[28]=c.createElementVNode("div",{class:"axis-arrow y-arrow-top"},"↑",-1))])]),c.createElementVNode("div",GC,[tt[29]||(tt[29]=c.createElementVNode("label",{for:"boost-slider",class:"boost-label"},"Boost",-1)),c.withDirectives(c.createElementVNode("input",{id:"boost-slider",type:"range","onUpdate:modelValue":tt[7]||(tt[7]=te=>L.value=te),min:"0.1",max:"100",step:"0.1",onInput:Lr,class:"boost-slider-vertical",orient:"vertical"},null,544),[[c.vModelText,L.value,void 0,{number:!0}]])])])])):c.createCommentVNode("",!0),u.value?(c.openBlock(),c.createElementBlock("div",{key:2,class:"tooltip",style:c.normalizeStyle({left:f.value.x+"px",top:f.value.y+"px"})},[c.createElementVNode("div",jC,"ID: "+c.toDisplayString(u.value.cell_id),1),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(Fr(u.value),(te,Mn)=>(c.openBlock(),c.createElementBlock("div",{key:Mn,class:"tooltip-row"},[c.createElementVNode("span",{class:"tooltip-label",style:c.normalizeStyle(Si(Mn))},c.toDisplayString(gr(Mn))+":",5),c.createElementVNode("span",YC,c.toDisplayString(qr(Mn,te)),1)]))),128))],4)):c.createCommentVNode("",!0)]))])):c.createCommentVNode("",!0),z.value?(c.openBlock(),c.createElementBlock("div",WC,[c.createElementVNode("div",HC,[c.createElementVNode("div",qC,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":tt[8]||(tt[8]=te=>h.value=te),class:"color-picker",onChange:Lr,title:"Choose color for no expression"},null,544),[[c.vModelText,h.value]]),tt[31]||(tt[31]=c.createElementVNode("span",null,"None",-1))]),c.createElementVNode("div",XC,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":tt[9]||(tt[9]=te=>ct.value=te),class:"color-picker",onChange:Lr,title:`Choose color for ${le.value} only`},null,40,KC),[[c.vModelText,ct.value]]),c.createElementVNode("span",null,c.toDisplayString(le.value)+" only",1)]),c.createElementVNode("div",QC,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":tt[10]||(tt[10]=te=>m.value=te),class:"color-picker",onChange:Lr,title:`Choose color for ${$t.value} only`},null,40,JC),[[c.vModelText,m.value]]),c.createElementVNode("span",null,c.toDisplayString($t.value)+" only",1)]),c.createElementVNode("div",ZC,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":tt[11]||(tt[11]=te=>F.value=te),class:"color-picker",onChange:Lr,title:"Choose color for co-expression"},null,544),[[c.vModelText,F.value]]),tt[32]||(tt[32]=c.createElementVNode("span",null,"Both",-1))])])])):c.createCommentVNode("",!0),!Z.value&&!U.value&&!lt.value?(c.openBlock(),c.createElementBlock("div",tk,[...tt[33]||(tt[33]=[c.createElementVNode("div",{class:"empty-icon"},"🔬",-1),c.createElementVNode("h3",null,"Ready to visualize gene co-expression",-1),c.createElementVNode("p",null,"Select two genes and a dimension reduction method to get started",-1)])])):c.createCommentVNode("",!0)])]))}},[["__scopeId","data-v-3993e9a4"]]),nk={class:"gene-coexpression-wrap"},rk=so(c.defineComponent({inheritAttrs:!1,__name:"GeneExpressionViewer",setup(e){const t=ac(),n=g_();return c.computed(()=>c.unref(t.s3Url)),(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",nk,[c.createVNode(ek,{gene1:c.unref(n).selectedGene1??void 0,gene2:c.unref(n).selectedGene2??void 0,"onUpdate:Vars":c.unref(n).setSelection,"data-path":"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/humandrg/v2"},null,8,["gene1","gene2","onUpdate:Vars"])])],64))}}),[["__scopeId","data-v-df43f151"]]),ik={class:"umap-comparison-dashboard"},sk={key:0,class:"loading-container"},ak={key:1,class:"error-container"},ok={key:2,class:"dashboard"},lk={class:"both-pannels"},ck={class:"panel"},uk={class:"controls"},dk={class:"label"},fk=["value"],hk={class:"canvas-container"},pk={class:"legend-header"},mk=["title"],yk={key:0},gk={key:1},_k={class:"legend-items"},vk=["onClick"],bk={key:0,class:"legend-x"},wk={class:"legend-label"},Sk={class:"tooltip-header"},Ek={class:"tooltip-value"},Ik={class:"panel"},Tk={class:"controls"},Ak={class:"label"},xk={class:"gene-input-wrapper"},Rk={id:"gene-suggestions"},Nk=["value"],Bk=["disabled"],Ok={class:"canvas-container"},Dk={key:0,class:"loading-overlay"},Fk={key:0,class:"legend"},Lk=so({__name:"SideBySide",props:{dataPath:{type:String,default:"/data"},metadataColumn:{type:String,default:null},gene:{type:String,default:null}},emits:["update:Vars"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(null),s=c.ref(null),a=c.ref(null),o=c.ref(null),l=c.ref(null),u=c.ref(xi),f=c.ref(null),p=c.ref(null),E=c.ref([]),T=c.ref([]),U=c.ref(null),J=c.ref(!0),lt=c.ref({x:0,y:0}),X=c.ref(!1),Kt=c.ref(!1),Jt=c.ref(!0),ue=c.ref(null),Wt=c.ref([]),le=c.ref([]),$t=c.ref(n.metadataColumn||""),yn=c.ref([]),Ge=c.ref(new Set),ce=c.ref(""),Qt=c.ref(n.gene||""),at=c.ref([]),ct=c.ref(!1);let m=null;c.watch(()=>n.metadataColumn,H=>{H&&H!==$t.value&&($t.value=H,Wt.value.length>0&&g())}),c.watch(()=>n.gene,H=>{H&&H!==Qt.value&&(Qt.value=H,ce.value=H,Wt.value.length>0&&Un())}),c.watch($t,H=>{H&&r("update:Vars","selectedMetadataColumn",H)}),c.watch(Qt,H=>{H&&r("update:Vars","selectedGene",H)});function F(H){const bt=parseInt(H.slice(1,3),16)/255,Ft=parseInt(H.slice(3,5),16)/255,Ut=parseInt(H.slice(5,7),16)/255;return[bt,Ft,Ut]}function h(){if(st.length>0&&(st.forEach(H=>{try{H.destroy()}catch(bt){console.warn("Error destroying texture:",bt)}}),st=[]),i.value&&qt.length>0&&(qt.forEach(({event:H,handler:bt})=>{i.value.removeEventListener(H,bt)}),qt=[]),o.value){try{o.value.destroy()}catch(H){console.warn("Error destroying regl:",H)}o.value=null,_t=null}}function L(){if(s.value&&cr.length>0&&(cr.forEach(({event:H,handler:bt})=>{s.value.removeEventListener(H,bt)}),cr=[]),l.value){try{l.value.destroy()}catch(H){console.warn("Error destroying right regl:",H)}l.value=null,_n=null}}let $=!1,D=null,z=null,Z=null,_t=null,wt=[],st=[],qt=[],ne=!1,Zt=null,Ye=null,Yn=null,_n=null,cr=[];const Fr=c.computed(()=>{if(!U.value)return null;let H=E.value.find(bt=>bt.cell_id===U.value);return!H&&T.value.length>0&&(H=T.value.find(bt=>bt.cell_id===U.value)),H});c.onMounted(async()=>{try{a.value=new J0(n.dataPath),await a.value.initialize();const H=await a.value.getReductionData("umap");if(Wt.value=H,H.length>0){const bt=H[0],Ft=Object.keys(bt).filter(Ut=>!["cell_id","umap_1","umap_2","tsne_1","tsne_2"].includes(Ut));le.value=Ft,Ft.length>0&&(n.metadataColumn&&Ft.includes(n.metadataColumn)?$t.value=n.metadataColumn:$t.value||($t.value=Ft.includes("Atlas_annotation")?"Atlas_annotation":Ft[0]))}Jt.value=!1,await c.nextTick(),Si(),$t.value&&g(),n.gene&&(Qt.value=n.gene,ce.value=n.gene,await Un())}catch(H){console.error("Failed to initialize:",H),ue.value=`Failed to load data: ${H.message}`,Jt.value=!1}}),c.onBeforeUnmount(()=>{f.value&&f.value.disconnect(),p.value&&p.value.disconnect(),h(),L()});function Si(){i.value&&(f.value=new ResizeObserver(()=>{!Kt.value&&$t.value&&g()}),f.value.observe(i.value.closest(".panel"))),s.value&&(p.value=new ResizeObserver(()=>{Qt.value&&Un()}),p.value.observe(s.value.closest(".panel")))}function gr(){clearTimeout(m),m=setTimeout(async()=>{if(ce.value.length<2){at.value=[];return}try{const H=await a.value.searchGenes(ce.value);at.value=H.map(bt=>bt.gene_name).slice(0,20)}catch(H){console.error("Gene search failed:",H)}},300)}async function qr(){ce.value.trim()&&(Qt.value=ce.value,await Un())}function Lr(H,bt,Ft){const Ut=new Map;H.forEach(Ue=>{const Fe=Ue[bt];Fe!=null&&(Ut.has(Fe)||Ut.set(Fe,[]),Ut.get(Fe).push(Ue))});const fe=[];Ut.forEach((Ue,Fe)=>{if(Ue.length===0)return;const Pn=Ue.reduce((on,hn)=>on+hn.x,0)/Ue.length,Rn=Ue.reduce((on,hn)=>on+hn.y,0)/Ue.length;fe.push({text:String(Fe),x:Pn,y:Rn,color:Ft(Fe),count:Ue.length})});const De=.3;for(let Ue=0;Ue<fe.length;Ue++)for(let Fe=Ue+1;Fe<fe.length;Fe++){const Pn=fe[Ue].x-fe[Fe].x,Rn=fe[Ue].y-fe[Fe].y,on=Math.sqrt(Pn*Pn+Rn*Rn);if(on<De&&on>0){const hn=(De-on)/2,ur=Math.atan2(Rn,Pn);fe[Ue].x+=Math.cos(ur)*hn,fe[Ue].y+=Math.sin(ur)*hn,fe[Fe].x-=Math.cos(ur)*hn,fe[Fe].y-=Math.sin(ur)*hn}}return fe}function Ht(H,bt){bt.value=new Set(H)}function tt(H){const bt=Ge;bt.value.has(H)?bt.value.delete(H):bt.value.add(H),Mn(),_n&&Qt.value&&Mr()}function te(){Kt.value=!0,X.value=!X.value,setTimeout(()=>{Kt.value=!1},350)}function Mn(){if(!_t||!z||!Z||!i.value)return;const bt=[],Ft=[];E.value.forEach(Ut=>{const fe=String(Ut[$t.value]);if(bt.push(z(Ut.x),Z(Ut.y)),Ge.value.has(fe)){const De=rs(Ut.color).rgb();Ft.push(De.r/255,De.g/255,De.b/255,.8)}else Ft.push(.85,.85,.85,.3)}),D=_t({frag:`
171
+ }`,attributes:{position:[An,rn],color:(()=>{if(Gn.color.startsWith("#"))return[...Rt(Gn.color),Gn.opacity];const Tr=Gn.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return Tr?[parseInt(Tr[1])/255,parseInt(Tr[2])/255,parseInt(Tr[3])/255,Gn.opacity]:[.8,.8,.8,Gn.opacity]})()},uniforms:{pointSize:Math.max(12,8*nn.k),scale:nn.k,translate:[2*nn.x/he.width,-(2*nn.y)/he.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}Ke(),await c.nextTick(),Kn()}function hn(qt){const et=i.value,te=et.getContext("2d"),_n=et.parentElement.getBoundingClientRect();et.width=Math.max(1,Math.floor(_n.width)),et.height=Math.max(300,Math.floor(_n.height));const tr=na(qt,Ye=>Ye.x),_=na(qt,Ye=>Ye.y),Qn=cs().domain(tr).range([20,et.width-20]),Ir=cs().domain(_).range([et.height-20,20]);te.clearRect(0,0,et.width,et.height),qt.forEach(Ye=>{te.fillStyle=Ye.color,te.globalAlpha=Ye.opacity,te.beginPath(),te.arc(Qn(Ye.x),Ir(Ye.y),2,0,2*Math.PI),te.fill()}),te.globalAlpha=1}function Kn(){if(!s.value)return;const qt=s.value,et=qt.getContext("2d"),te=Math.max(qt.width||150,qt.height||150);qt.width!==te&&(qt.width=te),qt.height!==te&&(qt.height=te);const gn=et.createImageData(te,te),_n=gn.data,tr=Tn=>Math.max(0,Math.min(255,Math.round(Tn))),_=Tn=>(Math.max(Tn[0]??0,Tn[1]??0,Tn[2]??0)<=1?Tn.map(Mr=>Mr*255):Tn).map(tr),Qn=_(Rt(p.value)),Ir=_(Rt(ot.value)),Ye=_(Rt(m.value)),Zi=_(Rt(T.value));for(let Tn=0;Tn<te;Tn++)for(let di=0;di<te;di++){const he=di/(te-1),Mr=(te-1-Tn)/(te-1);let Ci=Qn[0]*(1-he)*(1-Mr),X=Qn[1]*(1-he)*(1-Mr),wt=Qn[2]*(1-he)*(1-Mr);if(Ci+=Ir[0]*he*(1-Mr),X+=Ir[1]*he*(1-Mr),wt+=Ir[2]*he*(1-Mr),Ci+=Ye[0]*(1-he)*Mr,X+=Ye[1]*(1-he)*Mr,wt+=Ye[2]*(1-he)*Mr,he>0&&Mr>0){const Gt=he*Mr,pe=(Ir[0]+Ye[0])/2,Me=(Ir[1]+Ye[1])/2,$e=(Ir[2]+Ye[2])/2;Ci+=pe*Gt,X+=Me*Gt,wt+=$e*Gt;const Ce=Math.pow(Gt,2)*L.value,jn=1+Ce;Ci=(Ci+Zi[0]*Ce)/jn,X=(X+Zi[1]*Ce)/jn,wt=(wt+Zi[2]*Ce)/jn}const kt=(Tn*te+di)*4;_n[kt]=tr(Ci),_n[kt+1]=tr(X),_n[kt+2]=tr(wt),_n[kt+3]=255}et.putImageData(gn,0,0)}function pn(qt){const et={};qt.cell_type&&(et.cell_type=qt.cell_type),et[ie.value]=qt.expr1,et[xt.value]=qt.expr2;const te=new Set(["cell_id","umap_1","umap_2","tsne_1","tsne_2","x","y","color","zIndex","opacity","expr1","expr2","norm1","norm2"]);return Object.keys(qt).forEach(gn=>{!te.has(gn)&&qt[gn]!==null&&qt[gn]!==void 0&&(et[gn]=qt[gn])}),et}function yn(qt){return qt===ie.value?{color:ot.value}:qt===xt.value?{color:m.value}:{}}function In(qt){return qt.split("_").map(et=>et.charAt(0).toUpperCase()+et.slice(1)).join(" ")}function ir(qt,et){return typeof et=="number"?qt===ie.value||qt===xt.value?et.toFixed(3):et<.01&&et>0?et.toExponential(2):Math.abs(et)>1e3?et.toLocaleString():et.toFixed(2):et}async function sr(){tt.value&&await En(),await c.nextTick(),Ct.value&&Kn()}return(qt,et)=>(c.openBlock(),c.createElementBlock("div",qC,[c.createElementVNode("div",XC,[c.createElementVNode("div",KC,[c.createElementVNode("div",QC,[et[14]||(et[14]=c.createElementVNode("h3",null,"Gene Co-expression Analysis",-1)),c.createElementVNode("div",JC,[et[13]||(et[13]=c.createElementVNode("label",{for:"reduction-select"},"Visualization:",-1)),c.withDirectives(c.createElementVNode("select",{id:"reduction-select","onUpdate:modelValue":et[0]||(et[0]=te=>j.value=te),disabled:M.value},[et[12]||(et[12]=c.createElementVNode("option",{value:"umap"},"UMAP",-1)),c.createElementVNode("option",{value:"tsne",disabled:!$t.value}," tSNE "+c.toDisplayString($t.value?"":"(not available)"),9,tk)],8,ZC),[[c.vModelSelect,j.value]])])]),c.createElementVNode("div",ek,[c.createElementVNode("div",nk,[c.createElementVNode("div",rk,[c.createElementVNode("label",ik,[et[15]||(et[15]=c.createElementVNode("span",{class:"gene-number"},"Gene 1",-1)),ie.value?(c.openBlock(),c.createElementBlock("span",{key:0,class:"selected-gene",style:c.normalizeStyle({color:ot.value})},c.toDisplayString(ie.value),5)):c.createCommentVNode("",!0)]),c.withDirectives(c.createElementVNode("input",{id:"gene1-select","onUpdate:modelValue":et[1]||(et[1]=te=>Zt.value=te),type:"text",placeholder:"Enter gene name (e.g., CDH9)",onInput:et[2]||(et[2]=te=>ut(1)),disabled:M.value,list:"gene1-list",autocomplete:"off",class:"gene-input"},null,40,sk),[[c.vModelText,Zt.value]]),c.createElementVNode("datalist",ak,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(on.value,te=>(c.openBlock(),c.createElementBlock("option",{key:te,value:te},null,8,ok))),128))])]),et[17]||(et[17]=c.createElementVNode("div",{class:"vs-separator"},[c.createElementVNode("span",null,"vs")],-1)),c.createElementVNode("div",lk,[c.createElementVNode("label",ck,[et[16]||(et[16]=c.createElementVNode("span",{class:"gene-number"},"Gene 2",-1)),xt.value?(c.openBlock(),c.createElementBlock("span",{key:0,class:"selected-gene",style:c.normalizeStyle({color:m.value})},c.toDisplayString(xt.value),5)):c.createCommentVNode("",!0)]),c.withDirectives(c.createElementVNode("input",{id:"gene2-select","onUpdate:modelValue":et[3]||(et[3]=te=>Lt.value=te),type:"text",placeholder:"Enter gene name (e.g., TAC1)",onInput:et[4]||(et[4]=te=>ut(2)),disabled:M.value,list:"gene2-list",autocomplete:"off",class:"gene-input"},null,40,uk),[[c.vModelText,Lt.value]]),c.createElementVNode("datalist",dk,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(ge.value,te=>(c.openBlock(),c.createElementBlock("option",{key:te,value:te},null,8,fk))),128))])])]),c.createElementVNode("button",{onClick:re,disabled:!R.value||M.value,class:"visualize-btn"},[M.value?(c.openBlock(),c.createElementBlock("span",pk,[...et[18]||(et[18]=[c.createElementVNode("span",{class:"btn-spinner"},null,-1),c.createTextVNode("Loading...",-1)])])):(c.openBlock(),c.createElementBlock("span",mk,[(c.openBlock(),c.createElementBlock("svg",yk,[...et[19]||(et[19]=[c.createElementVNode("circle",{cx:"11",cy:"11",r:"8"},null,-1),c.createElementVNode("path",{d:"m21 21-4.35-4.35"},null,-1)])])),et[20]||(et[20]=c.createTextVNode(" Visualize Co-expression ",-1))]))],8,hk)])]),M.value&&!o.value?(c.openBlock(),c.createElementBlock("div",gk,[et[21]||(et[21]=c.createElementVNode("div",{class:"spinner"},null,-1)),c.createElementVNode("p",null,c.toDisplayString(H.value),1)])):c.createCommentVNode("",!0),nt.value?(c.openBlock(),c.createElementBlock("div",_k,[et[22]||(et[22]=c.createElementVNode("strong",null,"⚠️ Error:",-1)),c.createTextVNode(" "+c.toDisplayString(nt.value)+" ",1),c.createElementVNode("button",{onClick:et[5]||(et[5]=te=>nt.value=null),class:"dismiss-btn"},"Dismiss")])):c.createCommentVNode("",!0),U.value?(c.openBlock(),c.createElementBlock("div",vk,[c.createElementVNode("div",bk,[et[23]||(et[23]=c.createElementVNode("span",{class:"stat-label"},"Total cells:",-1)),c.createElementVNode("span",wk,c.toDisplayString(C.value.totalCells.toLocaleString()),1)]),c.createElementVNode("div",Sk,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:ot.value})},c.toDisplayString(ie.value)+" expressing:",5),c.createElementVNode("span",Ek,c.toDisplayString(C.value.gene1Expressing.toLocaleString())+" ("+c.toDisplayString(C.value.gene1Pct)+"%)",1)]),c.createElementVNode("div",Ik,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:m.value})},c.toDisplayString(xt.value)+" expressing:",5),c.createElementVNode("span",Tk,c.toDisplayString(C.value.gene2Expressing.toLocaleString())+" ("+c.toDisplayString(C.value.gene2Pct)+"%)",1)]),c.createElementVNode("div",Ak,[c.createElementVNode("span",{class:"stat-label",style:c.normalizeStyle({color:T.value})},"Co-expressing:",4),c.createElementVNode("span",xk,c.toDisplayString(C.value.coexpressing.toLocaleString())+" ("+c.toDisplayString(C.value.coexpressPct)+"%)",1)])])):c.createCommentVNode("",!0)]),c.createElementVNode("div",Nk,[tt.value||M.value&&o.value?(c.openBlock(),c.createElementBlock("div",Rk,[M.value&&o.value?(c.openBlock(),c.createElementBlock("div",Bk,[et[24]||(et[24]=c.createElementVNode("div",{class:"small-spinner"},null,-1)),c.createElementVNode("p",null,c.toDisplayString(H.value),1)])):(c.openBlock(),c.createElementBlock("div",Ok,[c.createElementVNode("canvas",{ref_key:"chartCanvas",ref:i},null,512),tt.value||M.value&&o.value?(c.openBlock(),c.createElementBlock("button",{key:0,class:"floating-mixer-toggle",onClick:et[6]||(et[6]=te=>Ct.value=!Ct.value),title:Ct.value?"Hide Color Mixing Guide":"Open Color Mixing Guide","aria-expanded":Ct.value.toString()},[Ct.value?(c.openBlock(),c.createElementBlock("svg",Lk,[...et[26]||(et[26]=[c.createElementVNode("path",{d:"M6 9l6 6 6-6"},null,-1)])])):(c.openBlock(),c.createElementBlock("svg",Fk,[...et[25]||(et[25]=[c.createElementVNode("path",{d:"M18 15l-6-6-6 6"},null,-1)])]))],8,Dk)):c.createCommentVNode("",!0),Ct.value&&(tt.value||M.value&&o.value)?(c.openBlock(),c.createElementBlock("div",Mk,[et[30]||(et[30]=c.createElementVNode("div",{class:"floating-mixer-header"},[c.createElementVNode("span",null,"Color Mixing Guide")],-1)),c.createElementVNode("div",Ck,[c.createElementVNode("div",null,[c.createElementVNode("canvas",{ref_key:"gradientCanvas",ref:s,class:"gradient-canvas",width:"150",height:"150",onClick:Kn},null,512),c.createElementVNode("div",kk,[c.createElementVNode("div",Uk,c.toDisplayString(xt.value||"Gene 2")+" Expression ",1),c.createElementVNode("div",Pk,c.toDisplayString(ie.value||"Gene 1")+" Expression ",1),et[27]||(et[27]=c.createElementVNode("div",{class:"axis-arrow x-arrow-right"},"→",-1)),et[28]||(et[28]=c.createElementVNode("div",{class:"axis-arrow y-arrow-top"},"↑",-1))])]),c.createElementVNode("div",$k,[et[29]||(et[29]=c.createElementVNode("label",{for:"boost-slider",class:"boost-label"},"Boost",-1)),c.withDirectives(c.createElementVNode("input",{id:"boost-slider",type:"range","onUpdate:modelValue":et[7]||(et[7]=te=>L.value=te),min:"0.1",max:"100",step:"0.1",onInput:sr,class:"boost-slider-vertical",orient:"vertical"},null,544),[[c.vModelText,L.value,void 0,{number:!0}]])])])])):c.createCommentVNode("",!0),u.value?(c.openBlock(),c.createElementBlock("div",{key:2,class:"tooltip",style:c.normalizeStyle({left:d.value.x+"px",top:d.value.y+"px"})},[c.createElementVNode("div",Vk,"ID: "+c.toDisplayString(u.value.cell_id),1),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(pn(u.value),(te,gn)=>(c.openBlock(),c.createElementBlock("div",{key:gn,class:"tooltip-row"},[c.createElementVNode("span",{class:"tooltip-label",style:c.normalizeStyle(yn(gn))},c.toDisplayString(In(gn))+":",5),c.createElementVNode("span",zk,c.toDisplayString(ir(gn,te)),1)]))),128))],4)):c.createCommentVNode("",!0)]))])):c.createCommentVNode("",!0),U.value?(c.openBlock(),c.createElementBlock("div",Gk,[c.createElementVNode("div",jk,[c.createElementVNode("div",Yk,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":et[8]||(et[8]=te=>p.value=te),class:"color-picker",onChange:sr,title:"Choose color for no expression"},null,544),[[c.vModelText,p.value]]),et[31]||(et[31]=c.createElementVNode("span",null,"None",-1))]),c.createElementVNode("div",Wk,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":et[9]||(et[9]=te=>ot.value=te),class:"color-picker",onChange:sr,title:`Choose color for ${ie.value} only`},null,40,Hk),[[c.vModelText,ot.value]]),c.createElementVNode("span",null,c.toDisplayString(ie.value)+" only",1)]),c.createElementVNode("div",qk,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":et[10]||(et[10]=te=>m.value=te),class:"color-picker",onChange:sr,title:`Choose color for ${xt.value} only`},null,40,Xk),[[c.vModelText,m.value]]),c.createElementVNode("span",null,c.toDisplayString(xt.value)+" only",1)]),c.createElementVNode("div",Kk,[c.withDirectives(c.createElementVNode("input",{type:"color","onUpdate:modelValue":et[11]||(et[11]=te=>T.value=te),class:"color-picker",onChange:sr,title:"Choose color for co-expression"},null,544),[[c.vModelText,T.value]]),et[32]||(et[32]=c.createElementVNode("span",null,"Both",-1))])])])):c.createCommentVNode("",!0),!tt.value&&!M.value&&!nt.value?(c.openBlock(),c.createElementBlock("div",Qk,[...et[33]||(et[33]=[c.createElementVNode("div",{class:"empty-icon"},"🔬",-1),c.createElementVNode("h3",null,"Ready to visualize gene co-expression",-1),c.createElementVNode("p",null,"Select two genes and a dimension reduction method to get started",-1)])])):c.createCommentVNode("",!0)])]))}},[["__scopeId","data-v-46f5915c"]]),Zk={class:"gene-coexpression-wrap"},tU=ea(c.defineComponent({inheritAttrs:!1,__name:"GeneExpressionViewer",setup(e){const t=Vo(),n=up();return c.computed(()=>c.unref(t.s3Url)),(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",Zk,[c.createVNode(Jk,{gene1:c.unref(n).selectedGene1??void 0,gene2:c.unref(n).selectedGene2??void 0,"onUpdate:Vars":c.unref(n).setSelection,"data-path":"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/humandrg/v2"},null,8,["gene1","gene2","onUpdate:Vars"])])],64))}}),[["__scopeId","data-v-a0ddc478"]]),eU={class:"umap-comparison-dashboard"},nU={key:0,class:"loading-container"},rU={key:1,class:"error-container"},iU={key:2,class:"dashboard"},sU={class:"both-pannels"},aU={class:"panel"},oU={class:"controls"},lU={class:"label"},cU=["value"],uU={class:"canvas-container"},dU={class:"legend-header"},fU=["title"],hU={key:0},pU={key:1},mU={class:"legend-items"},yU=["onClick"],gU={key:0,class:"legend-x"},_U={class:"legend-label"},vU={class:"tooltip-header"},bU={class:"tooltip-value"},wU={class:"panel"},SU={class:"controls"},EU={class:"label"},IU={class:"gene-input-wrapper"},TU={id:"gene-suggestions"},AU=["value"],xU=["disabled"],NU={class:"canvas-container"},RU={key:0,class:"loading-overlay"},BU={key:0,class:"legend"},OU=ea({__name:"SideBySide",props:{dataPath:{type:String,default:"/data"},metadataColumn:{type:String,default:null},gene:{type:String,default:null}},emits:["update:Vars"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(null),s=c.ref(null),a=c.ref(null),o=c.ref(null),l=c.ref(null),u=c.ref(Ri),d=c.ref(null),h=c.ref(null),y=c.ref([]),S=c.ref([]),M=c.ref(null),H=c.ref(!0),nt=c.ref({x:0,y:0}),j=c.ref(!1),$t=c.ref(!1),Ct=c.ref(!0),Zt=c.ref(null),Lt=c.ref([]),ie=c.ref([]),xt=c.ref(n.metadataColumn||""),on=c.ref([]),ge=c.ref(new Set),ne=c.ref(""),Qt=c.ref(n.gene||""),rt=c.ref([]),ot=c.ref(!1);let m=null;c.watch(()=>n.metadataColumn,X=>{X&&X!==xt.value&&(xt.value=X,Lt.value.length>0&&_())}),c.watch(()=>n.gene,X=>{X&&X!==Qt.value&&(Qt.value=X,ne.value=X,Lt.value.length>0&&Tn())}),c.watch(xt,X=>{X&&r("update:Vars","selectedMetadataColumn",X)}),c.watch(Qt,X=>{X&&r("update:Vars","selectedGene",X)});function T(X){const wt=parseInt(X.slice(1,3),16)/255,kt=parseInt(X.slice(3,5),16)/255,Gt=parseInt(X.slice(5,7),16)/255;return[wt,kt,Gt]}function p(){if(J.length>0&&(J.forEach(X=>{try{X.destroy()}catch(wt){console.warn("Error destroying texture:",wt)}}),J=[]),i.value&&Jt.length>0&&(Jt.forEach(({event:X,handler:wt})=>{i.value.removeEventListener(X,wt)}),Jt=[]),o.value){try{o.value.destroy()}catch(X){console.warn("Error destroying regl:",X)}o.value=null,ht=null}}function L(){if(s.value&&Kn.length>0&&(Kn.forEach(({event:X,handler:wt})=>{s.value.removeEventListener(X,wt)}),Kn=[]),l.value){try{l.value.destroy()}catch(X){console.warn("Error destroying right regl:",X)}l.value=null,hn=null}}let C=!1,R=null,U=null,tt=null,ht=null,ut=[],J=[],Jt=[],re=!1,Rt=null,fe=null,En=null,hn=null,Kn=[];const pn=c.computed(()=>{if(!M.value)return null;let X=y.value.find(wt=>wt.cell_id===M.value);return!X&&S.value.length>0&&(X=S.value.find(wt=>wt.cell_id===M.value)),X});c.onMounted(async()=>{try{a.value=new jm(n.dataPath),await a.value.initialize();const X=await a.value.getReductionData("umap");if(Lt.value=X,X.length>0){const wt=X[0],kt=Object.keys(wt).filter(Gt=>!["cell_id","umap_1","umap_2","tsne_1","tsne_2"].includes(Gt));ie.value=kt,kt.length>0&&(n.metadataColumn&&kt.includes(n.metadataColumn)?xt.value=n.metadataColumn:xt.value||(xt.value=kt.includes("Atlas_annotation")?"Atlas_annotation":kt[0]))}Ct.value=!1,await c.nextTick(),yn(),xt.value&&_(),n.gene&&(Qt.value=n.gene,ne.value=n.gene,await Tn())}catch(X){console.error("Failed to initialize:",X),Zt.value=`Failed to load data: ${X.message}`,Ct.value=!1}}),c.onBeforeUnmount(()=>{d.value&&d.value.disconnect(),h.value&&h.value.disconnect(),p(),L()});function yn(){i.value&&(d.value=new ResizeObserver(()=>{!$t.value&&xt.value&&_()}),d.value.observe(i.value.closest(".panel"))),s.value&&(h.value=new ResizeObserver(()=>{Qt.value&&Tn()}),h.value.observe(s.value.closest(".panel")))}function In(){clearTimeout(m),m=setTimeout(async()=>{if(ne.value.length<2){rt.value=[];return}try{const X=await a.value.searchGenes(ne.value);rt.value=X.map(wt=>wt.gene_name).slice(0,20)}catch(X){console.error("Gene search failed:",X)}},300)}async function ir(){ne.value.trim()&&(Qt.value=ne.value,await Tn())}function sr(X,wt,kt){const Gt=new Map;X.forEach($e=>{const Ce=$e[wt];Ce!=null&&(Gt.has(Ce)||Gt.set(Ce,[]),Gt.get(Ce).push($e))});const pe=[];Gt.forEach(($e,Ce)=>{if($e.length===0)return;const jn=$e.reduce((ln,vn)=>ln+vn.x,0)/$e.length,Mn=$e.reduce((ln,vn)=>ln+vn.y,0)/$e.length;pe.push({text:String(Ce),x:jn,y:Mn,color:kt(Ce),count:$e.length})});const Me=.3;for(let $e=0;$e<pe.length;$e++)for(let Ce=$e+1;Ce<pe.length;Ce++){const jn=pe[$e].x-pe[Ce].x,Mn=pe[$e].y-pe[Ce].y,ln=Math.sqrt(jn*jn+Mn*Mn);if(ln<Me&&ln>0){const vn=(Me-ln)/2,gr=Math.atan2(Mn,jn);pe[$e].x+=Math.cos(gr)*vn,pe[$e].y+=Math.sin(gr)*vn,pe[Ce].x-=Math.cos(gr)*vn,pe[Ce].y-=Math.sin(gr)*vn}}return pe}function qt(X,wt){wt.value=new Set(X)}function et(X){const wt=ge;wt.value.has(X)?wt.value.delete(X):wt.value.add(X),gn(),hn&&Qt.value&&_n()}function te(){$t.value=!0,j.value=!j.value,setTimeout(()=>{$t.value=!1},350)}function gn(){if(!ht||!U||!tt||!i.value)return;const wt=[],kt=[];y.value.forEach(Gt=>{const pe=String(Gt[xt.value]);if(wt.push(U(Gt.x),tt(Gt.y)),ge.value.has(pe)){const Me=ss(Gt.color).rgb();kt.push(Me.r/255,Me.g/255,Me.b/255,.8)}else kt.push(.85,.85,.85,.3)}),R=ht({frag:`
172
172
  precision mediump float;
173
173
  varying vec4 vColor;
174
174
  void main() {
@@ -190,7 +190,7 @@
190
190
  gl_Position = vec4(pos, 0, 1);
191
191
  gl_PointSize = pointSize;
192
192
  vColor = color;
193
- }`,attributes:{position:bt,color:Ft},uniforms:{pointSize:_t.prop("pointSize"),scale:_t.prop("scale"),translate:_t.prop("translate")},count:bt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),Xe()}function Mr(){if(!_n||!Ye||!Yn||!s.value)return;const bt=[],Ft=[];T.value.forEach(Ut=>{const fe=String(Ut[$t.value]);if(bt.push(Ye(Ut.x),Yn(Ut.y)),Ge.value.has(fe)){const De=rs(Ut.color).rgb();Ft.push(De.r/255,De.g/255,De.b/255,.8)}else Ft.push(.85,.85,.85,.3)}),Zt=_n({frag:`
193
+ }`,attributes:{position:wt,color:kt},uniforms:{pointSize:ht.prop("pointSize"),scale:ht.prop("scale"),translate:ht.prop("translate")},count:wt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),Ye()}function _n(){if(!hn||!fe||!En||!s.value)return;const wt=[],kt=[];S.value.forEach(Gt=>{const pe=String(Gt[xt.value]);if(wt.push(fe(Gt.x),En(Gt.y)),ge.value.has(pe)){const Me=ss(Gt.color).rgb();kt.push(Me.r/255,Me.g/255,Me.b/255,.8)}else kt.push(.85,.85,.85,.3)}),Rt=hn({frag:`
194
194
  precision mediump float;
195
195
  varying vec4 vColor;
196
196
  void main() {
@@ -212,7 +212,7 @@
212
212
  gl_Position = vec4(pos, 0, 1);
213
213
  gl_PointSize = pointSize;
214
214
  vColor = color;
215
- }`,attributes:{position:bt,color:Ft},uniforms:{pointSize:_n.prop("pointSize"),scale:_n.prop("scale"),translate:_n.prop("translate")},count:bt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),Qn()}function li(H,bt){if(!H||!_t||!z||!Z||wt.length===0)return;const Ft=bt||xi;st.forEach(Ut=>{try{Ut.destroy()}catch{}}),st=[],wt.forEach(Ut=>{if(!Ge.value.has(Ut.text))return;const fe=z(Ut.x),De=Z(Ut.y),Ue=2*Ft.x/H.width,Fe=-(2*Ft.y)/H.height,Pn=(fe*Ft.k+Ue+1)/2*H.width,Rn=(1-(De*Ft.k+Fe))/2*H.height;if(Pn<-100||Pn>H.width+100||Rn<-100||Rn>H.height+100)return;const ci=Math.round(Math.max(11,Math.min(18,12*Ft.k))),Ke=document.createElement("canvas"),Cn=Ke.getContext("2d",{willReadFrequently:!0});Cn.font=`600 ${ci}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;const nn=Cn.measureText(Ut.text).width,kn=ci,vn=4;Ke.width=nn+vn*2,Ke.height=kn+vn*2,Cn.font=`600 ${ci}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,Cn.textAlign="center",Cn.textBaseline="middle",Cn.fillStyle="rgba(255, 255, 255, 0.85)",Cn.fillRect(0,0,Ke.width,Ke.height),Cn.strokeStyle=Ut.color,Cn.lineWidth=2,Cn.strokeRect(0,0,Ke.width,Ke.height),Cn.fillStyle=Ut.color,Cn.fillText(Ut.text,Ke.width/2,Ke.height/2);const rn=_t.texture({data:Ke,mag:"linear",min:"linear"});st.push(rn);const Br=Ke.width/H.width*2,_r=Ke.height/H.height*2;_t({frag:`
215
+ }`,attributes:{position:wt,color:kt},uniforms:{pointSize:hn.prop("pointSize"),scale:hn.prop("scale"),translate:hn.prop("translate")},count:wt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}),Qn()}function tr(X,wt){if(!X||!ht||!U||!tt||ut.length===0)return;const kt=wt||Ri;J.forEach(Gt=>{try{Gt.destroy()}catch{}}),J=[],ut.forEach(Gt=>{if(!ge.value.has(Gt.text))return;const pe=U(Gt.x),Me=tt(Gt.y),$e=2*kt.x/X.width,Ce=-(2*kt.y)/X.height,jn=(pe*kt.k+$e+1)/2*X.width,Mn=(1-(Me*kt.k+Ce))/2*X.height;if(jn<-100||jn>X.width+100||Mn<-100||Mn>X.height+100)return;const fi=Math.round(Math.max(11,Math.min(18,12*kt.k))),Ke=document.createElement("canvas"),zn=Ke.getContext("2d",{willReadFrequently:!0});zn.font=`600 ${fi}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`;const nn=zn.measureText(Gt.text).width,Gn=fi,An=4;Ke.width=nn+An*2,Ke.height=Gn+An*2,zn.font=`600 ${fi}px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,zn.textAlign="center",zn.textBaseline="middle",zn.fillStyle="rgba(255, 255, 255, 0.85)",zn.fillRect(0,0,Ke.width,Ke.height),zn.strokeStyle=Gt.color,zn.lineWidth=2,zn.strokeRect(0,0,Ke.width,Ke.height),zn.fillStyle=Gt.color,zn.fillText(Gt.text,Ke.width/2,Ke.height/2);const rn=ht.texture({data:Ke,mag:"linear",min:"linear"});J.push(rn);const Cr=Ke.width/X.width*2,Tr=Ke.height/X.height*2;ht({frag:`
216
216
  precision mediump float;
217
217
  varying vec2 vUv;
218
218
  uniform sampler2D texture;
@@ -230,7 +230,7 @@
230
230
  vec2 pos = offset + position * size + translate;
231
231
  gl_Position = vec4(pos, 0, 1);
232
232
  vUv = uv;
233
- }`,attributes:{position:[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]],uv:[[0,1],[1,1],[0,0],[1,0]]},uniforms:{texture:rn,offset:[fe*Ft.k+2*Ft.x/H.width,De*Ft.k-2*Ft.y/H.height],size:[Br,_r],translate:[0,0]},primitive:"triangle strip",count:4,depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1}}})()})}async function g(){await c.nextTick();const H=i.value;if(!H||!Wt.value.length)return;h();const Ft=H.parentElement.getBoundingClientRect(),Ut=Math.floor(Ft.width),fe=Math.floor(Ft.height);H.width=Ut,H.height=fe;const De=[...new Set(Wt.value.map(Xt=>Xt[$t.value]).filter(Xt=>Xt!=null))],Ue=_v(DD).domain(De);yn.value=De.map(Xt=>({label:String(Xt),color:Ue(Xt)})),Ht(De.map(Xt=>String(Xt)),Ge);const Fe=Wt.value.map(Xt=>({...Xt,x:Xt.umap_1,y:Xt.umap_2,color:Ue(Xt[$t.value])||"#cccccc",opacity:.8}));E.value=Fe,wt=Lr(Fe,$t.value,Ue);try{o.value=Np(H)}catch(Xt){console.error("WebGL not supported:",Xt);return}const Rn=o.value;_t=Rn;const on=Ra(Fe,Xt=>Xt.x),hn=Ra(Fe,Xt=>Xt.y),ur=(on[1]-on[0])*.05,ci=(hn[1]-hn[0])*.05;on[0]-=ur,on[1]+=ur,hn[0]-=ci,hn[1]+=ci;const Ke=ea().domain(on).range([-1,1]),Cn=ea().domain(hn).range([-1,1]);z=Ke,Z=Cn;const kt=[],nn=[];Fe.forEach(Xt=>{const he=String(Xt[$t.value]);if(kt.push(Ke(Xt.x),Cn(Xt.y)),Ge.value.has(he)){const gn=rs(Xt.color).rgb();nn.push(gn.r/255,gn.g/255,gn.b/255,.8)}else nn.push(.85,.85,.85,.3)}),D=Rn({frag:`
233
+ }`,attributes:{position:[[-.5,-.5],[.5,-.5],[-.5,.5],[.5,.5]],uv:[[0,1],[1,1],[0,0],[1,0]]},uniforms:{texture:rn,offset:[pe*kt.k+2*kt.x/X.width,Me*kt.k-2*kt.y/X.height],size:[Cr,Tr],translate:[0,0]},primitive:"triangle strip",count:4,depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1}}})()})}async function _(){await c.nextTick();const X=i.value;if(!X||!Lt.value.length)return;p();const kt=X.parentElement.getBoundingClientRect(),Gt=Math.floor(kt.width),pe=Math.floor(kt.height);X.width=Gt,X.height=pe;const Me=[...new Set(Lt.value.map(ee=>ee[xt.value]).filter(ee=>ee!=null))],$e=bc(zp).domain(Me);on.value=Me.map(ee=>({label:String(ee),color:$e(ee)})),qt(Me.map(ee=>String(ee)),ge);const Ce=Lt.value.map(ee=>({...ee,x:ee.umap_1,y:ee.umap_2,color:$e(ee[xt.value])||"#cccccc",opacity:.8}));y.value=Ce,ut=sr(Ce,xt.value,$e);try{o.value=Wp(X)}catch(ee){console.error("WebGL not supported:",ee);return}const Mn=o.value;ht=Mn;const ln=na(Ce,ee=>ee.x),vn=na(Ce,ee=>ee.y),gr=(ln[1]-ln[0])*.05,fi=(vn[1]-vn[0])*.05;ln[0]-=gr,ln[1]+=gr,vn[0]-=fi,vn[1]+=fi;const Ke=cs().domain(ln).range([-1,1]),zn=cs().domain(vn).range([-1,1]);U=Ke,tt=zn;const zt=[],nn=[];Ce.forEach(ee=>{const me=String(ee[xt.value]);if(zt.push(Ke(ee.x),zn(ee.y)),ge.value.has(me)){const Sn=ss(ee.color).rgb();nn.push(Sn.r/255,Sn.g/255,Sn.b/255,.8)}else nn.push(.85,.85,.85,.3)}),R=Mn({frag:`
234
234
  precision mediump float;
235
235
  varying vec4 vColor;
236
236
  void main() {
@@ -252,7 +252,7 @@
252
252
  gl_Position = vec4(pos, 0, 1);
253
253
  gl_PointSize = pointSize;
254
254
  vColor = color;
255
- }`,attributes:{position:kt,color:nn},uniforms:{pointSize:Rn.prop("pointSize"),scale:Rn.prop("scale"),translate:Rn.prop("translate")},count:kt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}});const vn=Rp().scaleExtent([.5,10]).filter(Xt=>Xt.type!=="wheel").on("zoom",Xt=>{Xt.sourceEvent&&Xt.sourceEvent.type!=="wheel"&&(u.value=Xt.transform,Xe(),l.value&&Qt.value&&Qn())});Gr(H).call(vn);let rn=0;const Br=16,_r=Xt=>{Xt.preventDefault();const he=H.getBoundingClientRect(),gn=Xt.clientX-he.left,bn=Xt.clientY-he.top,sr=u.value||xi,wn=gn/H.width*2-1,$n=-(bn/H.height*2-1),Qr=2*sr.x/H.width,Jr=-(2*sr.y)/H.height,Vr=(wn-Qr)/sr.k,Zn=($n-Jr)/sr.k,tr=-Xt.deltaY*.002,dr=Math.max(.5,Math.min(10,sr.k*Math.pow(2,tr))),fr=wn-Vr*dr,Cr=$n-Zn*dr,ui=fr*H.width/2,kr=-(Cr*H.height)/2,zr=xi.translate(ui,kr).scale(dr);u.value=zr,Xe(),Gr(H).property("__zoom",zr),s.value&&l.value&&Qt.value&&(Gr(s.value).property("__zoom",zr),Qn())},Xr=Xt=>{const he=Date.now();if(he-rn<Br)return;rn=he;const gn=H.getBoundingClientRect(),bn=Xt.clientX-gn.left,sr=Xt.clientY-gn.top,wn=u.value||xi,$n=bn/H.width*2-1,Qr=-(sr/H.height*2-1),Jr=.02;let Vr=null,Zn=Jr;if(E.value.forEach((tr,dr)=>{const fr=Ke(tr.x),Cr=Cn(tr.y),ui=2*wn.x/H.width,kr=-(2*wn.y)/H.height,zr=fr*wn.k+ui,Ji=Cr*wn.k+kr,va=zr-$n,hs=Ji-Qr,ps=Math.sqrt(va*va+hs*hs);ps<Zn&&(Zn=ps,Vr=tr)}),Vr){U.value=Vr.cell_id,J.value=!0;const tr=Ke(Vr.x),dr=Cn(Vr.y),fr=2*wn.x/H.width,Cr=-(2*wn.y)/H.height,ui=(tr*wn.k+fr+1)/2*H.width,kr=(1-(dr*wn.k+Cr))/2*H.height,zr=H.getBoundingClientRect();lt.value={x:zr.left+ui+15,y:zr.top+kr-10}}else U.value=null;Xe(),l.value&&Qt.value&&Qn()},Kr=()=>{U.value=null,Xe(),l.value&&Qt.value&&Qn()};H.addEventListener("wheel",_r,{passive:!1}),H.addEventListener("mousemove",Xr),H.addEventListener("mouseleave",Kr),qt=[{event:"wheel",handler:_r},{event:"mousemove",handler:Xr},{event:"mouseleave",handler:Kr}],Xe()}function Qn(){!s.value||!_n||ne||(ne=!0,requestAnimationFrame(()=>{const H=s.value;_n.clear({color:[.97,.98,.99,1],depth:1});let bt=1,Ft=[0,0],Ut=3;if(u.value){const{k:fe,x:De,y:Ue}=u.value;bt=fe,Ft=[2*De/H.width,-(2*Ue)/H.height],Ut=Math.max(2,3*fe)}if(Zt({scale:bt,translate:Ft,pointSize:Ut}),U.value){const fe=T.value.findIndex(De=>De.cell_id===U.value);if(fe!==-1){const De=T.value[fe],Ue=String(De[$t.value]);if(Ge.value.has(Ue)){Rr(fe,u.value);const Fe=T.value[fe],Pn=Ye(Fe.x),Rn=Yn(Fe.y),on=u.value,hn=2*on.x/H.width,ur=-(2*on.y)/H.height;(Pn*on.k+hn+1)/2*H.width,(1-(Rn*on.k+ur))/2*H.height,H.getBoundingClientRect()}}}ne=!1}))}function Rr(H,bt){if(!s.value||!_n||!Ye||!Yn)return;const Ft=s.value,Ut=T.value[H],fe=Ye(Ut.x),De=Yn(Ut.y);_n({frag:`
255
+ }`,attributes:{position:zt,color:nn},uniforms:{pointSize:Mn.prop("pointSize"),scale:Mn.prop("scale"),translate:Mn.prop("translate")},count:zt.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}});const An=Yp().scaleExtent([.5,10]).filter(ee=>ee.type!=="wheel").on("zoom",ee=>{ee.sourceEvent&&ee.sourceEvent.type!=="wheel"&&(u.value=ee.transform,Ye(),l.value&&Qt.value&&Qn())});Pr(X).call(An);let rn=0;const Cr=16,Tr=ee=>{ee.preventDefault();const me=X.getBoundingClientRect(),Sn=ee.clientX-me.left,xn=ee.clientY-me.top,hr=u.value||Ri,Nn=Sn/X.width*2-1,Yn=-(xn/X.height*2-1),ti=2*hr.x/X.width,ei=-(2*hr.y)/X.height,Wr=(Nn-ti)/hr.k,or=(Yn-ei)/hr.k,lr=-ee.deltaY*.002,_r=Math.max(.5,Math.min(10,hr.k*Math.pow(2,lr))),vr=Nn-Wr*_r,Vr=Yn-or*_r,hi=vr*X.width/2,zr=-(Vr*X.height)/2,Hr=Ri.translate(hi,zr).scale(_r);u.value=Hr,Ye(),Pr(X).property("__zoom",Hr),s.value&&l.value&&Qt.value&&(Pr(s.value).property("__zoom",Hr),Qn())},Jr=ee=>{const me=Date.now();if(me-rn<Cr)return;rn=me;const Sn=X.getBoundingClientRect(),xn=ee.clientX-Sn.left,hr=ee.clientY-Sn.top,Nn=u.value||Ri,Yn=xn/X.width*2-1,ti=-(hr/X.height*2-1),ei=.02;let Wr=null,or=ei;if(y.value.forEach((lr,_r)=>{const vr=Ke(lr.x),Vr=zn(lr.y),hi=2*Nn.x/X.width,zr=-(2*Nn.y)/X.height,Hr=vr*Nn.k+hi,ts=Vr*Nn.k+zr,Sa=Hr-Yn,ys=ts-ti,gs=Math.sqrt(Sa*Sa+ys*ys);gs<or&&(or=gs,Wr=lr)}),Wr){M.value=Wr.cell_id,H.value=!0;const lr=Ke(Wr.x),_r=zn(Wr.y),vr=2*Nn.x/X.width,Vr=-(2*Nn.y)/X.height,hi=(lr*Nn.k+vr+1)/2*X.width,zr=(1-(_r*Nn.k+Vr))/2*X.height,Hr=X.getBoundingClientRect();nt.value={x:Hr.left+hi+15,y:Hr.top+zr-10}}else M.value=null;Ye(),l.value&&Qt.value&&Qn()},Zr=()=>{M.value=null,Ye(),l.value&&Qt.value&&Qn()};X.addEventListener("wheel",Tr,{passive:!1}),X.addEventListener("mousemove",Jr),X.addEventListener("mouseleave",Zr),Jt=[{event:"wheel",handler:Tr},{event:"mousemove",handler:Jr},{event:"mouseleave",handler:Zr}],Ye()}function Qn(){!s.value||!hn||re||(re=!0,requestAnimationFrame(()=>{const X=s.value;hn.clear({color:[.97,.98,.99,1],depth:1});let wt=1,kt=[0,0],Gt=3;if(u.value){const{k:pe,x:Me,y:$e}=u.value;wt=pe,kt=[2*Me/X.width,-(2*$e)/X.height],Gt=Math.max(2,3*pe)}if(Rt({scale:wt,translate:kt,pointSize:Gt}),M.value){const pe=S.value.findIndex(Me=>Me.cell_id===M.value);if(pe!==-1){const Me=S.value[pe],$e=String(Me[xt.value]);if(ge.value.has($e)){Ir(pe,u.value);const Ce=S.value[pe],jn=fe(Ce.x),Mn=En(Ce.y),ln=u.value,vn=2*ln.x/X.width,gr=-(2*ln.y)/X.height;(jn*ln.k+vn+1)/2*X.width,(1-(Mn*ln.k+gr))/2*X.height,X.getBoundingClientRect()}}}re=!1}))}function Ir(X,wt){if(!s.value||!hn||!fe||!En)return;const kt=s.value,Gt=S.value[X],pe=fe(Gt.x),Me=En(Gt.y);hn({frag:`
256
256
  precision mediump float;
257
257
  varying vec4 vColor;
258
258
  void main() {
@@ -277,7 +277,7 @@
277
277
  gl_Position = vec4(pos, 0, 1);
278
278
  gl_PointSize = pointSize;
279
279
  vColor = color;
280
- }`,attributes:{position:[fe,De],color:(()=>{if(Ut.color.startsWith("#"))return[...F(Ut.color),Ut.opacity];const Fe=Ut.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return Fe?[parseInt(Fe[1])/255,parseInt(Fe[2])/255,parseInt(Fe[3])/255,Ut.opacity]:[.8,.8,.8,Ut.opacity]})()},uniforms:{pointSize:Math.max(12,8*bt.k),scale:bt.k,translate:[2*bt.x/Ft.width,-(2*bt.y)/Ft.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}function Xe(){!i.value||!_t||$||($=!0,requestAnimationFrame(()=>{const H=i.value;_t.clear({color:[.97,.98,.99,1],depth:1});let bt=1,Ft=[0,0],Ut=3;if(u.value){const{k:fe,x:De,y:Ue}=u.value;bt=fe,Ft=[2*De/H.width,-(2*Ue)/H.height],Ut=Math.max(2,3*fe)}if(D({scale:bt,translate:Ft,pointSize:Ut}),li(H,u.value),U.value){const fe=E.value.findIndex(De=>De.cell_id===U.value);if(fe!==-1){const De=E.value[fe],Ue=String(De[$t.value]);if(Ge.value.has(Ue)){zs(fe,u.value);const Fe=E.value[fe],Pn=z(Fe.x),Rn=Z(Fe.y),on=u.value,hn=2*on.x/H.width,ur=-(2*on.y)/H.height,ci=(Pn*on.k+hn+1)/2*H.width,Ke=(1-(Rn*on.k+ur))/2*H.height,Cn=H.getBoundingClientRect();lt.value={x:Cn.left+ci+15,y:Cn.top+Ke-10}}}}$=!1}))}function zs(H,bt){if(!i.value||!_t||!z||!Z)return;const Ft=i.value,Ut=E.value[H],fe=z(Ut.x),De=Z(Ut.y);_t({frag:`
280
+ }`,attributes:{position:[pe,Me],color:(()=>{if(Gt.color.startsWith("#"))return[...T(Gt.color),Gt.opacity];const Ce=Gt.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return Ce?[parseInt(Ce[1])/255,parseInt(Ce[2])/255,parseInt(Ce[3])/255,Gt.opacity]:[.8,.8,.8,Gt.opacity]})()},uniforms:{pointSize:Math.max(12,8*wt.k),scale:wt.k,translate:[2*wt.x/kt.width,-(2*wt.y)/kt.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}function Ye(){!i.value||!ht||C||(C=!0,requestAnimationFrame(()=>{const X=i.value;ht.clear({color:[.97,.98,.99,1],depth:1});let wt=1,kt=[0,0],Gt=3;if(u.value){const{k:pe,x:Me,y:$e}=u.value;wt=pe,kt=[2*Me/X.width,-(2*$e)/X.height],Gt=Math.max(2,3*pe)}if(R({scale:wt,translate:kt,pointSize:Gt}),tr(X,u.value),M.value){const pe=y.value.findIndex(Me=>Me.cell_id===M.value);if(pe!==-1){const Me=y.value[pe],$e=String(Me[xt.value]);if(ge.value.has($e)){Zi(pe,u.value);const Ce=y.value[pe],jn=U(Ce.x),Mn=tt(Ce.y),ln=u.value,vn=2*ln.x/X.width,gr=-(2*ln.y)/X.height,fi=(jn*ln.k+vn+1)/2*X.width,Ke=(1-(Mn*ln.k+gr))/2*X.height,zn=X.getBoundingClientRect();nt.value={x:zn.left+fi+15,y:zn.top+Ke-10}}}}C=!1}))}function Zi(X,wt){if(!i.value||!ht||!U||!tt)return;const kt=i.value,Gt=y.value[X],pe=U(Gt.x),Me=tt(Gt.y);ht({frag:`
281
281
  precision mediump float;
282
282
  varying vec4 vColor;
283
283
  void main() {
@@ -302,7 +302,7 @@
302
302
  gl_Position = vec4(pos, 0, 1);
303
303
  gl_PointSize = pointSize;
304
304
  vColor = color;
305
- }`,attributes:{position:[fe,De],color:(()=>{if(Ut.color.startsWith("#"))return[...F(Ut.color),Ut.opacity];const Fe=Ut.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return Fe?[parseInt(Fe[1])/255,parseInt(Fe[2])/255,parseInt(Fe[3])/255,Ut.opacity]:[.8,.8,.8,Ut.opacity]})()},uniforms:{pointSize:Math.max(12,8*bt.k),scale:bt.k,translate:[2*bt.x/Ft.width,-(2*bt.y)/Ft.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}async function Un(){if(!Qt.value)return;await c.nextTick();const H=s.value;if(!H||!Wt.value.length)return;L();const Ft=H.parentElement.getBoundingClientRect(),Ut=Math.floor(Ft.width),fe=Math.floor(Ft.height);if(H.width=Ut,H.height=fe,Ge.value.size===0&&$t.value){const De=[...new Set(Wt.value.map(Ue=>Ue[$t.value]).filter(Ue=>Ue!=null))];Ht(De.map(Ue=>String(Ue)),Ge)}try{ct.value=!0;const De=await a.value.getGeneExpression(Qt.value);ct.value=!1;const Ue=new Map(De.map(he=>[he.cell_id,he.expression])),Fe=De.map(he=>he.expression),Pn=Math.max(...Fe),Rn=Wt.value.map(he=>{const gn=Ue.get(he.cell_id)||0,bn=Pn>0?Math.min(gn/Pn,1):0,sr=Math.round(200*(1-bn)+0*bn),wn=Math.round(200*(1-bn)+0*bn),$n=Math.round(200*(1-bn)+255*bn);return{...he,x:he.umap_1,y:he.umap_2,expr:gn,norm:bn,color:`rgb(${sr}, ${wn}, ${$n})`,originalColor:`rgb(${sr}, ${wn}, ${$n})`,opacity:.8}});Rn.sort((he,gn)=>he.norm-gn.norm),T.value=Rn;try{l.value&&l.value.destroy(),l.value=Np(H)}catch(he){console.error("WebGL not supported:",he);return}const on=l.value;_n=on;const hn=Ra(Rn,he=>he.x),ur=Ra(Rn,he=>he.y),ci=(hn[1]-hn[0])*.05,Ke=(ur[1]-ur[0])*.05;hn[0]-=ci,hn[1]+=ci,ur[0]-=Ke,ur[1]+=Ke;const Cn=ea().domain(hn).range([-1,1]),kt=ea().domain(ur).range([-1,1]);Ye=Cn,Yn=kt;const nn=[],kn=[];Rn.forEach(he=>{const gn=String(he[$t.value]);if(nn.push(Cn(he.x),kt(he.y)),Ge.value.has(gn)){const bn=rs(he.color).rgb();kn.push(bn.r/255,bn.g/255,bn.b/255,.8)}else kn.push(.85,.85,.85,.3)}),Zt=on({frag:`
305
+ }`,attributes:{position:[pe,Me],color:(()=>{if(Gt.color.startsWith("#"))return[...T(Gt.color),Gt.opacity];const Ce=Gt.color.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return Ce?[parseInt(Ce[1])/255,parseInt(Ce[2])/255,parseInt(Ce[3])/255,Gt.opacity]:[.8,.8,.8,Gt.opacity]})()},uniforms:{pointSize:Math.max(12,8*wt.k),scale:wt.k,translate:[2*wt.x/kt.width,-(2*wt.y)/kt.height]},count:1,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}})()}async function Tn(){if(!Qt.value)return;await c.nextTick();const X=s.value;if(!X||!Lt.value.length)return;L();const kt=X.parentElement.getBoundingClientRect(),Gt=Math.floor(kt.width),pe=Math.floor(kt.height);if(X.width=Gt,X.height=pe,ge.value.size===0&&xt.value){const Me=[...new Set(Lt.value.map($e=>$e[xt.value]).filter($e=>$e!=null))];qt(Me.map($e=>String($e)),ge)}try{ot.value=!0;const Me=await a.value.getGeneExpression(Qt.value);ot.value=!1;const $e=new Map(Me.map(me=>[me.cell_id,me.expression])),Ce=Me.map(me=>me.expression),jn=Math.max(...Ce),Mn=Lt.value.map(me=>{const Sn=$e.get(me.cell_id)||0,xn=jn>0?Math.min(Sn/jn,1):0,hr=Math.round(200*(1-xn)+0*xn),Nn=Math.round(200*(1-xn)+0*xn),Yn=Math.round(200*(1-xn)+255*xn);return{...me,x:me.umap_1,y:me.umap_2,expr:Sn,norm:xn,color:`rgb(${hr}, ${Nn}, ${Yn})`,originalColor:`rgb(${hr}, ${Nn}, ${Yn})`,opacity:.8}});Mn.sort((me,Sn)=>me.norm-Sn.norm),S.value=Mn;try{l.value&&l.value.destroy(),l.value=Wp(X)}catch(me){console.error("WebGL not supported:",me);return}const ln=l.value;hn=ln;const vn=na(Mn,me=>me.x),gr=na(Mn,me=>me.y),fi=(vn[1]-vn[0])*.05,Ke=(gr[1]-gr[0])*.05;vn[0]-=fi,vn[1]+=fi,gr[0]-=Ke,gr[1]+=Ke;const zn=cs().domain(vn).range([-1,1]),zt=cs().domain(gr).range([-1,1]);fe=zn,En=zt;const nn=[],Gn=[];Mn.forEach(me=>{const Sn=String(me[xt.value]);if(nn.push(zn(me.x),zt(me.y)),ge.value.has(Sn)){const xn=ss(me.color).rgb();Gn.push(xn.r/255,xn.g/255,xn.b/255,.8)}else Gn.push(.85,.85,.85,.3)}),Rt=ln({frag:`
306
306
  precision mediump float;
307
307
  varying vec4 vColor;
308
308
  void main() {
@@ -324,7 +324,7 @@
324
324
  gl_Position = vec4(pos, 0, 1);
325
325
  gl_PointSize = pointSize;
326
326
  vColor = color;
327
- }`,attributes:{position:nn,color:kn},uniforms:{pointSize:on.prop("pointSize"),scale:on.prop("scale"),translate:on.prop("translate")},count:nn.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}});const rn=Rp().scaleExtent([.5,10]).filter(he=>he.type!=="wheel").on("zoom",he=>{he.sourceEvent&&he.sourceEvent.type!=="wheel"&&(u.value=he.transform,Qn(),o.value&&$t.value&&(Gr(i.value).property("__zoom",he.transform),Xe()))});Gr(H).call(rn);let Br=0;const _r=16,Xr=he=>{he.preventDefault();const gn=H.getBoundingClientRect(),bn=he.clientX-gn.left,sr=he.clientY-gn.top,wn=u.value||xi,$n=bn/H.width*2-1,Qr=-(sr/H.height*2-1),Jr=2*wn.x/H.width,Vr=-(2*wn.y)/H.height,Zn=($n-Jr)/wn.k,tr=(Qr-Vr)/wn.k,dr=-he.deltaY*.002,fr=Math.max(.5,Math.min(10,wn.k*Math.pow(2,dr))),Cr=$n-Zn*fr,ui=Qr-tr*fr,kr=Cr*H.width/2,zr=-(ui*H.height)/2,Ji=xi.translate(kr,zr).scale(fr);u.value=Ji,Qn(),Gr(H).property("__zoom",Ji),i.value&&o.value&&$t.value&&(Gr(i.value).property("__zoom",Ji),Xe())},Kr=he=>{const gn=Date.now();if(gn-Br<_r)return;Br=gn;const bn=H.getBoundingClientRect(),sr=he.clientX-bn.left,wn=he.clientY-bn.top,$n=u.value||xi,Qr=sr/H.width*2-1,Jr=-(wn/H.height*2-1),Vr=.02;let Zn=null,tr=Vr,dr=-1;if(T.value.forEach((fr,Cr)=>{const ui=Cn(fr.x),kr=kt(fr.y),zr=2*$n.x/H.width,Ji=-(2*$n.y)/H.height,va=ui*$n.k+zr,hs=kr*$n.k+Ji,ps=va-Qr,th=hs-Jr,eh=Math.sqrt(ps*ps+th*th);eh<tr&&(tr=eh,Zn=fr,dr=Cr)}),Zn){U.value=Zn.cell_id,J.value=!1;const fr=Cn(Zn.x),Cr=kt(Zn.y),ui=2*$n.x/H.width,kr=-(2*$n.y)/H.height,zr=(fr*$n.k+ui+1)/2*H.width,Ji=(1-(Cr*$n.k+kr))/2*H.height,va=H.getBoundingClientRect()}else U.value=null;Qn(),o.value&&$t.value&&Xe()},Xt=()=>{U.value=null,Qn(),o.value&&$t.value&&Xe()};H.addEventListener("wheel",Xr,{passive:!1}),H.addEventListener("mousemove",Kr),H.addEventListener("mouseleave",Xt),cr=[{event:"wheel",handler:Xr},{event:"mousemove",handler:Kr},{event:"mouseleave",handler:Xt}],Qn()}catch(De){console.error("Failed to render gene UMAP:",De),ct.value=!1}}function Li(H){const bt={},Ft=new Set(["cell_id","umap_1","umap_2","tsne_1","tsne_2","x","y","color","opacity","expr","norm"]);return Object.keys(H).forEach(Ut=>{!Ft.has(Ut)&&H[Ut]!==null&&H[Ut]!==void 0&&(bt[Ut]=H[Ut])}),bt}function ke(H){return{}}function Nr(H){return H.split("_").map(bt=>bt.charAt(0).toUpperCase()+bt.slice(1)).join(" ")}c.ref("#ff0000"),c.ref("#0000ff");function Mi(H,bt){return typeof bt=="number"?H===Qt.value||H===$t.value?bt.toFixed(3):bt<.01&&bt>0?bt.toExponential(2):Math.abs(bt)>1e3?bt.toLocaleString():bt.toFixed(2):bt}return(H,bt)=>(c.openBlock(),c.createElementBlock("div",ik,[Jt.value?(c.openBlock(),c.createElementBlock("div",sk,[...bt[2]||(bt[2]=[c.createElementVNode("div",{class:"spinner"},null,-1),c.createElementVNode("p",{class:"loading-text"},"Loading UMAP data...",-1)])])):ue.value?(c.openBlock(),c.createElementBlock("div",ak,[bt[3]||(bt[3]=c.createElementVNode("strong",null,"⚠️ Error:",-1)),c.createTextVNode(" "+c.toDisplayString(ue.value),1)])):(c.openBlock(),c.createElementBlock("div",ok,[bt[11]||(bt[11]=c.createElementVNode("div",{class:"filter-placeholder"},null,-1)),c.createElementVNode("div",lk,[c.createElementVNode("div",ck,[bt[6]||(bt[6]=c.createElementVNode("div",{class:"header"},[c.createElementVNode("h3",{class:"title"},"Cell Metadata")],-1)),c.createElementVNode("div",uk,[c.createElementVNode("label",dk,[bt[4]||(bt[4]=c.createTextVNode(" Select metadata: ",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":bt[0]||(bt[0]=Ft=>$t.value=Ft),onChange:g,class:"select"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(le.value,Ft=>(c.openBlock(),c.createElementBlock("option",{key:Ft,value:Ft},c.toDisplayString(Ft),9,fk))),128))],544),[[c.vModelSelect,$t.value]])])]),c.createElementVNode("div",hk,[c.createElementVNode("canvas",{ref_key:"leftCanvas",ref:i},null,512)]),yn.value.length>0?(c.openBlock(),c.createElementBlock("div",{key:0,class:c.normalizeClass(["legend",{"legend-expanded":X.value}])},[c.createElementVNode("div",pk,[bt[5]||(bt[5]=c.createElementVNode("div",{class:"legend-title"},"Legend",-1)),c.createElementVNode("button",{class:"legend-toggle",onClick:c.withModifiers(te,["stop"]),title:X.value?"Collapse":"Expand"},[X.value?(c.openBlock(),c.createElementBlock("span",yk,"▼")):(c.openBlock(),c.createElementBlock("span",gk,"▲"))],8,mk)]),c.createElementVNode("div",_k,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(yn.value,(Ft,Ut)=>(c.openBlock(),c.createElementBlock("div",{key:Ut,class:"legend-item",onClick:fe=>tt(Ft.label)},[c.createElementVNode("div",{class:c.normalizeClass(["legend-color",{"legend-color-hidden":!Ge.value.has(Ft.label)}]),style:c.normalizeStyle({background:Ft.color,borderColor:Ft.color})},[Ge.value.has(Ft.label)?c.createCommentVNode("",!0):(c.openBlock(),c.createElementBlock("span",bk,"✕"))],6),c.createElementVNode("span",wk,c.toDisplayString(Ft.label),1)],8,vk))),128))])],2)):c.createCommentVNode("",!0),Fr.value?(c.openBlock(),c.createElementBlock("div",{key:1,class:"tooltip",style:c.normalizeStyle({left:lt.value.x+"px",top:lt.value.y+"px"})},[c.createElementVNode("div",Sk,c.toDisplayString(Fr.value.cell_id),1),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(Li(Fr.value),(Ft,Ut)=>(c.openBlock(),c.createElementBlock("div",{key:Ut,class:"tooltip-row"},[c.createElementVNode("span",{class:"tooltip-label",style:c.normalizeStyle(ke())},c.toDisplayString(Nr(Ut))+":",5),c.createElementVNode("span",Ek,c.toDisplayString(Mi(Ut,Ft)),1)]))),128))],4)):c.createCommentVNode("",!0)]),c.createElementVNode("div",Ik,[bt[10]||(bt[10]=c.createElementVNode("div",{class:"header"},[c.createElementVNode("h3",{class:"title"},"Assay RNA (Gene Expression)")],-1)),c.createElementVNode("div",Tk,[c.createElementVNode("label",Ak,[bt[7]||(bt[7]=c.createTextVNode(" Select gene: ",-1)),c.createElementVNode("div",xk,[c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":bt[1]||(bt[1]=Ft=>ce.value=Ft),type:"text",placeholder:"Enter gene name (e.g., CDH9)",class:"gene-input",list:"gene-suggestions",onInput:gr},null,544),[[c.vModelText,ce.value]]),c.createElementVNode("datalist",Rk,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(at.value,Ft=>(c.openBlock(),c.createElementBlock("option",{key:Ft,value:Ft},null,8,Nk))),128))]),c.createElementVNode("button",{onClick:qr,disabled:!ce.value.trim()||ct.value,class:"visualize-btn"},c.toDisplayString(ct.value?"Loading...":"Visualize"),9,Bk)])])]),c.createElementVNode("div",Ok,[ct.value?(c.openBlock(),c.createElementBlock("div",Dk,[...bt[8]||(bt[8]=[c.createElementVNode("div",{class:"small-spinner"},null,-1),c.createElementVNode("p",null,"Loading gene expression...",-1)])])):c.createCommentVNode("",!0),c.createElementVNode("canvas",{ref_key:"rightCanvas",ref:s},null,512)]),Qt.value&&!ct.value?(c.openBlock(),c.createElementBlock("div",Fk,[...bt[9]||(bt[9]=[c.createElementVNode("div",{class:"legend-title"},"Expression Level",-1),c.createElementVNode("div",{class:"gradient-bar"},[c.createElementVNode("div",{class:"gradient-fill"}),c.createElementVNode("div",{class:"gradient-labels"},[c.createElementVNode("span",null,"Low"),c.createElementVNode("span",null,"High")])],-1)])])):c.createCommentVNode("",!0)])])]))]))}},[["__scopeId","data-v-753ae090"]]),Mk={class:"side-by-side-wrap"},Ck=so(c.defineComponent({inheritAttrs:!1,__name:"SideBySide",setup(e){const t=ac(),n=g_();return c.computed(()=>c.unref(t.s3Url)),(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",Mk,[c.createVNode(Lk,{gene:c.unref(n).selectedGene??void 0,metadataColumn:c.unref(n).selectedMetadataColumn??void 0,"onUpdate:Vars":i[0]||(i[0]=(s,a)=>c.unref(n).setSelection(s,a)),"data-path":"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/humandrg/v2"},null,8,["gene","metadataColumn"])])],64))}}),[["__scopeId","data-v-a101b836"]]);function ze(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(f){try{u(r.next(f))}catch(p){a(p)}}function l(f){try{u(r.throw(f))}catch(p){a(p)}}function u(f){f.done?s(f.value):i(f.value).then(o,l)}u((r=r.apply(e,t||[])).next())})}function Z0(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Je(e){return this instanceof Je?(this.v=e,this):new Je(e)}function Ds(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(T){return function(U){return Promise.resolve(U).then(T,p)}}function o(T,U){r[T]&&(i[T]=function(J){return new Promise(function(lt,X){s.push([T,J,lt,X])>1||l(T,J)})},U&&(i[T]=U(i[T])))}function l(T,U){try{u(r[T](U))}catch(J){E(s[0][3],J)}}function u(T){T.value instanceof Je?Promise.resolve(T.value.v).then(f,p):E(s[0][2],T)}function f(T){l("next",T)}function p(T){l("throw",T)}function E(T,U){T(U),s.shift(),s.length&&l(s[0][0],s[0][1])}}function sf(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:Je(e[i](a)),done:!1}:s?s(a):a}:s}}function go(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Z0=="function"?Z0(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(u){s({value:u,done:o})},a)}}const kk=new TextDecoder("utf-8"),xm=e=>kk.decode(e),Uk=new TextEncoder,Rm=e=>Uk.encode(e),Pk=e=>typeof e=="number",tw=e=>typeof e=="boolean",Tr=e=>typeof e=="function",_i=e=>e!=null&&Object(e)===e,_o=e=>_i(e)&&Tr(e.then),Nc=e=>_i(e)&&Tr(e[Symbol.iterator]),ol=e=>_i(e)&&Tr(e[Symbol.asyncIterator]),Nm=e=>_i(e)&&_i(e.schema),ew=e=>_i(e)&&"done"in e&&"value"in e,nw=e=>_i(e)&&Tr(e.stat)&&Pk(e.fd),rw=e=>_i(e)&&Bm(e.body),af=e=>"_getDOMStream"in e&&"_getNodeStream"in e,$k=e=>_i(e)&&Tr(e.abort)&&Tr(e.getWriter)&&!af(e),Bm=e=>_i(e)&&Tr(e.cancel)&&Tr(e.getReader)&&!af(e),Vk=e=>_i(e)&&Tr(e.end)&&Tr(e.write)&&tw(e.writable)&&!af(e),iw=e=>_i(e)&&Tr(e.read)&&Tr(e.pipe)&&tw(e.readable)&&!af(e),zk=e=>_i(e)&&Tr(e.clear)&&Tr(e.bytes)&&Tr(e.position)&&Tr(e.setPosition)&&Tr(e.capacity)&&Tr(e.getBufferIdentifier)&&Tr(e.createLong),Om=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Gk(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,u=0,f=e.length;++l<f;){if(a=t[u],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++u]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++u]=o);continue}t[u]=new Uint8Array(a.buffer,n,r-n+s)}return t}function sw(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function Fs(e,t){const n=Gk(e),r=n.reduce((f,p)=>f+p.byteLength,0);let i,s,a,o=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,r);for(const f=n.length;++l<f;){if(i=n[l],s=i.subarray(0,Math.min(i.length,u-o)),u<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?sw(a,s,o):a=s;break}sw(a||(a=new Uint8Array(u)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function Gn(e,t){let n=ew(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Rm(n)),n instanceof ArrayBuffer?new e(n):n instanceof Om?new e(n):zk(n)?Gn(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const Bc=e=>Gn(Int32Array,e),aw=e=>Gn(BigInt64Array,e),un=e=>Gn(Uint8Array,e),Dm=e=>(e.next(),e);function*jk(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Om?n(t):Nc(t)?t:n(t);return yield*Dm((function*(i){let s=null;do s=i.next(yield Gn(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const Yk=e=>jk(Uint8Array,e);function ow(e,t){return Ds(this,arguments,function*(){if(_o(t))return yield Je(yield Je(yield*sf(go(ow(e,yield Je(t))))));const n=function(s){return Ds(this,arguments,function*(){yield yield Je(yield Je(s))})},r=function(s){return Ds(this,arguments,function*(){yield Je(yield*sf(go(Dm((function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)})(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Om?n(t):Nc(t)?r(t):ol(t)?t:n(t);return yield Je(yield*sf(go(Dm((function(s){return Ds(this,arguments,function*(){let a=null;do a=yield Je(s.next(yield yield Je(Gn(e,a))));while(!a.done)})})(i[Symbol.asyncIterator]()))))),yield Je(new e)})}const Wk=e=>ow(Uint8Array,e);function lw(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function Hk(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const ji={fromIterable(e){return of(qk(e))},fromAsyncIterable(e){return of(Xk(e))},fromDOMStream(e){return of(Kk(e))},fromNodeStream(e){return of(Jk(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},of=e=>(e.next(),e);function*qk(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Fs(r,a)[0]:([i,r,o]=Fs(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const u=Yk(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?u.next():u.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(f){(n=!0)&&typeof u.throw=="function"&&u.throw(f)}finally{n===!1&&typeof u.return=="function"&&u.return(null)}return null}function Xk(e){return Ds(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Fs(r,a)[0]:([i,r,o]=Fs(r,a),i)}({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0});const u=Wk(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield Je(u.next()):yield Je(u.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield Je(l()));while(a<o);while(!t)}catch(f){(n=!0)&&typeof u.throw=="function"&&(yield Je(u.throw(f)))}finally{n===!1&&typeof u.return=="function"&&(yield Je(u.return(new Uint8Array(0))))}return yield Je(null)})}function Kk(e){return Ds(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Fs(r,a)[0]:([i,r,o]=Fs(r,a),i)}({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0});const u=new Qk(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield Je(u.read()):yield Je(u.read(a-o)),!t&&i.byteLength>0&&(r.push(un(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield Je(l()));while(a<o);while(!t)}catch(f){(n=!0)&&(yield Je(u.cancel(f)))}finally{n===!1?yield Je(u.cancel()):e.locked&&u.releaseLock()}return yield Je(null)})}class Qk{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return ze(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return ze(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=un(n)),n})}}const Fm=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Jk(e){return Ds(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],u;function f(){return s==="peek"?Fs(l,a)[0]:([u,l,o]=Fs(l,a),u)}if({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0},e.isTTY)return yield yield Je(new Uint8Array(0)),yield Je(null);try{t[0]=Fm(e,"end"),t[1]=Fm(e,"error");do{if(t[2]=Fm(e,"readable"),[n,i]=yield Je(Promise.race(t.map(E=>E[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(u=un(e.read(a-o)),u.byteLength<a-o&&(u=un(e.read()))):u=un(e.read()),u.byteLength>0&&(l.push(u),o+=u.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield Je(f()));while(a<o)}while(!r)}finally{yield Je(p(t,n==="error"?i:null))}return yield Je(null);function p(E,T){return u=l=null,new Promise((U,J)=>{for(const[lt,X]of E)e.off(lt,X);try{const lt=e.destroy;lt&&lt.call(e,T),T=void 0}catch(lt){T=lt||T}finally{T!=null?J(T):U()}})}})}var yr;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(yr||(yr={}));var Wr;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Wr||(Wr={}));var Hr;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Hr||(Hr={}));var Yi;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Yi||(Yi={}));var Re;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(Re||(Re={}));var Ls;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Ls||(Ls={}));const Lm=2,Ms=4,da=4,Tn=4,ka=new Int32Array(2),cw=new Float32Array(ka.buffer),uw=new Float64Array(ka.buffer),lf=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Mm;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Mm||(Mm={}));let ll=class kI{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new kI(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return ka[0]=this.readInt32(t),cw[0]}readFloat64(t){return ka[lf?0:1]=this.readInt32(t),ka[lf?1:0]=this.readInt32(t+4),uw[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){cw[0]=n,this.writeInt32(t,ka[0])}writeFloat64(t,n){uw[0]=n,this.writeInt32(t,ka[lf?0:1]),this.writeInt32(t+4,ka[lf?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Ms+da)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<da;n++)t+=String.fromCharCode(this.readInt8(this.position_+Ms+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=Ms;const i=this.bytes_.subarray(t,t+r);return n===Mm.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+Ms}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=da)throw new Error("FlatBuffers: file identifier must be length "+da);for(let n=0;n<da;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Ms+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},dw=class UI{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=ll.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=UI.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=ll.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(Ms,0),this.writeInt32(this.offset()-t+Ms)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*Lm;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let u=Lm;u<s;u+=Lm)if(this.bb.readInt16(o+u)!=this.bb.readInt16(l+u))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?Tn:0;if(n){const s=n;if(this.prep(this.minalign,Ms+da+i),s.length!=da)throw new TypeError("FlatBuffers: file identifier must be length "+da);for(let a=da-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Ms+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(Ms,t*n),this.prep(r,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var cf;(function(e){e[e.BUFFER=0]="BUFFER"})(cf||(cf={}));var uf;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(uf||(uf={}));class Ua{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Ua).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Tn),(n||new Ua).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):uf.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):cf.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,uf.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,cf.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Ua.startBodyCompression(t),Ua.addCodec(t,n),Ua.addMethod(t,r),Ua.endBodyCompression(t)}}class fw{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let hw=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},fa=class Ig{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new Ig).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Tn),(n||new Ig).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new hw).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new fw).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Ua).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},cl=class Tg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new Tg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Tn),(n||new Tg).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new fa).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var ul;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(ul||(ul={}));var df;(function(e){e[e.DenseArray=0]="DenseArray"})(df||(df={}));class Oi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Oi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Tn),(n||new Oi).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Oi.startInt(t),Oi.addBitWidth(t,n),Oi.addIsSigned(t,r),Oi.endInt(t)}}class ha{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new ha).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Tn),(n||new ha).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Oi).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):df.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,df.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Ar{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new Ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Tn),(n||new Ar).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return Ar.startKeyValue(t),Ar.addKey(t,n),Ar.addValue(t,r),Ar.endKeyValue(t)}}let pw=class hu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new hu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Tn),(n||new hu).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return hu.startBinary(t),hu.endBinary(t)}},mw=class pu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new pu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Tn),(n||new pu).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return pu.startBool(t),pu.endBool(t)}},ff=class Yl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new Yl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Tn),(n||new Yl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Yi.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Yi.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return Yl.startDate(t),Yl.addUnit(t,n),Yl.endDate(t)}},dl=class Ja{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new Ja).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Tn),(n||new Ja).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return Ja.startDecimal(t),Ja.addPrecision(t,n),Ja.addScale(t,r),Ja.addBitWidth(t,i),Ja.endDecimal(t)}},hf=class Wl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new Wl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Tn),(n||new Wl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Re.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Re.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Wl.startDuration(t),Wl.addUnit(t,n),Wl.endDuration(t)}},pf=class Hl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new Hl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Tn),(n||new Hl).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return Hl.startFixedSizeBinary(t),Hl.addByteWidth(t,n),Hl.endFixedSizeBinary(t)}},mf=class ql{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new ql).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Tn),(n||new ql).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return ql.startFixedSizeList(t),ql.addListSize(t,n),ql.endFixedSizeList(t)}};class Cs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new Cs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Tn),(n||new Cs).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Hr.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Hr.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return Cs.startFloatingPoint(t),Cs.addPrecision(t,n),Cs.endFloatingPoint(t)}}class ks{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new ks).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Tn),(n||new ks).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ls.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Ls.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return ks.startInterval(t),ks.addUnit(t,n),ks.endInterval(t)}}let yw=class mu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new mu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Tn),(n||new mu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return mu.startLargeBinary(t),mu.endLargeBinary(t)}},gw=class yu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new yu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Tn),(n||new yu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return yu.startLargeUtf8(t),yu.endLargeUtf8(t)}},_w=class gu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new gu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Tn),(n||new gu).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return gu.startList(t),gu.endList(t)}},yf=class Xl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new Xl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Tn),(n||new Xl).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return Xl.startMap(t),Xl.addKeysSorted(t,n),Xl.endMap(t)}},vw=class _u{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new _u).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Tn),(n||new _u).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return _u.startNull(t),_u.endNull(t)}};class vo{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new vo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Tn),(n||new vo).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return vo.startStruct_(t),vo.endStruct_(t)}}class Wi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new Wi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Tn),(n||new Wi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Re.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Re.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return Wi.startTime(t),Wi.addUnit(t,n),Wi.addBitWidth(t,r),Wi.endTime(t)}}class Hi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new Hi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Tn),(n||new Hi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Re.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Re.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return Hi.startTimestamp(t),Hi.addUnit(t,n),Hi.addTimezone(t,r),Hi.endTimestamp(t)}}class vi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new vi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Tn),(n||new vi).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Wr.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Wr.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return vi.startUnion(t),vi.addMode(t,n),vi.addTypeIds(t,r),vi.endUnion(t)}}let bw=class vu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new vu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Tn),(n||new vu).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return vu.startUtf8(t),vu.endUtf8(t)}};var Hn;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(Hn||(Hn={}));let qi=class Fh{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new Fh).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Tn),(n||new Fh).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Hn.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new ha).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Fh).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new Ar).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,Hn.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},Us=class Aa{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Aa).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Tn),(n||new Aa).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ul.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new qi).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ar).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,ul.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Aa.startSchema(t),Aa.addEndianness(t,n),Aa.addFields(t,r),Aa.addCustomMetadata(t,i),Aa.addFeatures(t,s),Aa.endSchema(t)}};var mn;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(mn||(mn={}));var O;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(O||(O={}));var pa;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(pa||(pa={}));const Zk=void 0;function Oc(e){if(e===null)return"null";if(e===Zk)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>Oc(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function jn(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function ww(e,t){return jn(e/t)+jn(e%t)/jn(t)}const tU=Symbol.for("isArrowBigNum");function us(e,...t){return t.length===0?Object.setPrototypeOf(Gn(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}us.prototype[tU]=!0,us.prototype.toJSON=function(){return`"${Fc(this)}"`},us.prototype.valueOf=function(e){return Sw(this,e)},us.prototype.toString=function(){return Fc(this)},us.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Sw(this);case"string":return Fc(this);case"default":return rU(this)}return Fc(this)};function fl(...e){return us.apply(this,e)}function hl(...e){return us.apply(this,e)}function Dc(...e){return us.apply(this,e)}Object.setPrototypeOf(fl.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(hl.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Dc.prototype,Object.create(Uint32Array.prototype)),Object.assign(fl.prototype,us.prototype,{constructor:fl,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(hl.prototype,us.prototype,{constructor:hl,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Dc.prototype,us.prototype,{constructor:Dc,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const eU=BigInt(4294967296)*BigInt(4294967296),nU=eU-BigInt(1);function Sw(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),u=0;if(o){for(const f of a)l|=(f^nU)*(BigInt(1)<<BigInt(64*u++));l*=BigInt(-1),l-=BigInt(1)}else for(const f of a)l|=f*(BigInt(1)<<BigInt(64*u++));if(typeof t=="number"){const f=BigInt(Math.pow(10,t)),p=l/f,E=l%f;return jn(p)+jn(E)/jn(f)}return jn(l)}function Fc(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Cm(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Cm(e);t=t.slice();let n=1;for(let r=0;r<t.length;r++){const i=t[r],s=~i+n;t[r]=s,n&=i===0?1:0}return`-${Cm(t)}`}function rU(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Fc(e)}function Cm(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class km{static new(t,n){switch(n){case!0:return new fl(t);case!1:return new hl(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new fl(t)}return t.byteLength===16?new Dc(t):new hl(t)}static signed(t){return new fl(t)}static unsigned(t){return new hl(t)}static decimal(t){return new Dc(t)}constructor(t,n){return km.new(t,n)}}var Ew,Iw,Tw,Aw,xw,Rw,Nw,Bw,Ow,Dw,Fw,Lw,Mw,Cw,kw,Uw,Pw,$w,Vw,zw,Gw,jw;class oe{static isNull(t){return(t==null?void 0:t.typeId)===O.Null}static isInt(t){return(t==null?void 0:t.typeId)===O.Int}static isFloat(t){return(t==null?void 0:t.typeId)===O.Float}static isBinary(t){return(t==null?void 0:t.typeId)===O.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===O.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===O.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===O.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===O.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===O.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===O.Date}static isTime(t){return(t==null?void 0:t.typeId)===O.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===O.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===O.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===O.Duration}static isList(t){return(t==null?void 0:t.typeId)===O.List}static isStruct(t){return(t==null?void 0:t.typeId)===O.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===O.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===O.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===O.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===O.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===O.Dictionary}static isDenseUnion(t){return oe.isUnion(t)&&t.mode===Wr.Dense}static isSparseUnion(t){return oe.isUnion(t)&&t.mode===Wr.Sparse}constructor(t){this.typeId=t}}Ew=Symbol.toStringTag,oe[Ew]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(oe.prototype);class Pa extends oe{constructor(){super(O.Null)}toString(){return"Null"}}Iw=Symbol.toStringTag,Pa[Iw]=(e=>e[Symbol.toStringTag]="Null")(Pa.prototype);class bo extends oe{constructor(t,n){super(O.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}Tw=Symbol.toStringTag,bo[Tw]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(bo.prototype);class Lc extends bo{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Lc.prototype,"ArrayType",{value:Int32Array});class gf extends oe{constructor(t){super(O.Float),this.precision=t}get ArrayType(){switch(this.precision){case Hr.HALF:return Uint16Array;case Hr.SINGLE:return Float32Array;case Hr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Aw=Symbol.toStringTag,gf[Aw]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(gf.prototype);class _f extends oe{constructor(){super(O.Binary)}toString(){return"Binary"}}xw=Symbol.toStringTag,_f[xw]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(_f.prototype);class vf extends oe{constructor(){super(O.LargeBinary)}toString(){return"LargeBinary"}}Rw=Symbol.toStringTag,vf[Rw]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(vf.prototype);class bf extends oe{constructor(){super(O.Utf8)}toString(){return"Utf8"}}Nw=Symbol.toStringTag,bf[Nw]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(bf.prototype);class wf extends oe{constructor(){super(O.LargeUtf8)}toString(){return"LargeUtf8"}}Bw=Symbol.toStringTag,wf[Bw]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(wf.prototype);class Sf extends oe{constructor(){super(O.Bool)}toString(){return"Bool"}}Ow=Symbol.toStringTag,Sf[Ow]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Sf.prototype);class Ef extends oe{constructor(t,n,r=128){super(O.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Dw=Symbol.toStringTag,Ef[Dw]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Ef.prototype);class If extends oe{constructor(t){super(O.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Yi[this.unit]}>`}get ArrayType(){return this.unit===Yi.DAY?Int32Array:BigInt64Array}}Fw=Symbol.toStringTag,If[Fw]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(If.prototype);class Tf extends oe{constructor(t,n){super(O.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${Re[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Lw=Symbol.toStringTag,Tf[Lw]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(Tf.prototype);class Af extends oe{constructor(t,n){super(O.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${Re[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Mw=Symbol.toStringTag,Af[Mw]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Af.prototype);class xf extends oe{constructor(t){super(O.Interval),this.unit=t}toString(){return`Interval<${Ls[this.unit]}>`}}Cw=Symbol.toStringTag,xf[Cw]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(xf.prototype);class Rf extends oe{constructor(t){super(O.Duration),this.unit=t}toString(){return`Duration<${Re[this.unit]}>`}}kw=Symbol.toStringTag,Rf[kw]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(Rf.prototype);class Nf extends oe{constructor(t){super(O.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}Uw=Symbol.toStringTag,Nf[Uw]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Nf.prototype);class ii extends oe{constructor(t){super(O.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Pw=Symbol.toStringTag,ii[Pw]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(ii.prototype);class Bf extends oe{constructor(t,n,r){super(O.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}$w=Symbol.toStringTag,Bf[$w]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Bf.prototype);class Of extends oe{constructor(t){super(O.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Vw=Symbol.toStringTag,Of[Vw]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Of.prototype);class Df extends oe{constructor(t,n){super(O.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}zw=Symbol.toStringTag,Df[zw]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Df.prototype);class Ff extends oe{constructor(t,n=!1){var r,i,s;if(super(O.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Gw=Symbol.toStringTag,Ff[Gw]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Ff.prototype);const iU=(e=>()=>++e)(-1);class pl extends oe{constructor(t,n,r,i){super(O.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?iU():jn(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}jw=Symbol.toStringTag,pl[jw]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(pl.prototype);function ma(e){const t=e;switch(e.typeId){case O.Decimal:return e.bitWidth/32;case O.Interval:return 1+t.unit;case O.FixedSizeList:return t.listSize;case O.FixedSizeBinary:return t.byteWidth;default:return 1}}class en{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return sU(this,t,n)}getVisitFnByTypeId(t,n=!0){return ml(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function sU(e,t,n=!0){return typeof t=="number"?ml(e,t,n):typeof t=="string"&&t in O?ml(e,O[t],n):t&&t instanceof oe?ml(e,Yw(t),n):t!=null&&t.type&&t.type instanceof oe?ml(e,Yw(t.type),n):ml(e,O.NONE,n)}function ml(e,t,n=!0){let r=null;switch(t){case O.Null:r=e.visitNull;break;case O.Bool:r=e.visitBool;break;case O.Int:r=e.visitInt;break;case O.Int8:r=e.visitInt8||e.visitInt;break;case O.Int16:r=e.visitInt16||e.visitInt;break;case O.Int32:r=e.visitInt32||e.visitInt;break;case O.Int64:r=e.visitInt64||e.visitInt;break;case O.Uint8:r=e.visitUint8||e.visitInt;break;case O.Uint16:r=e.visitUint16||e.visitInt;break;case O.Uint32:r=e.visitUint32||e.visitInt;break;case O.Uint64:r=e.visitUint64||e.visitInt;break;case O.Float:r=e.visitFloat;break;case O.Float16:r=e.visitFloat16||e.visitFloat;break;case O.Float32:r=e.visitFloat32||e.visitFloat;break;case O.Float64:r=e.visitFloat64||e.visitFloat;break;case O.Utf8:r=e.visitUtf8;break;case O.LargeUtf8:r=e.visitLargeUtf8;break;case O.Binary:r=e.visitBinary;break;case O.LargeBinary:r=e.visitLargeBinary;break;case O.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case O.Date:r=e.visitDate;break;case O.DateDay:r=e.visitDateDay||e.visitDate;break;case O.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case O.Timestamp:r=e.visitTimestamp;break;case O.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case O.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case O.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case O.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case O.Time:r=e.visitTime;break;case O.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case O.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case O.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case O.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case O.Decimal:r=e.visitDecimal;break;case O.List:r=e.visitList;break;case O.Struct:r=e.visitStruct;break;case O.Union:r=e.visitUnion;break;case O.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case O.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case O.Dictionary:r=e.visitDictionary;break;case O.Interval:r=e.visitInterval;break;case O.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case O.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case O.Duration:r=e.visitDuration;break;case O.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case O.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case O.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case O.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case O.FixedSizeList:r=e.visitFixedSizeList;break;case O.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${O[t]}'`)}function Yw(e){switch(e.typeId){case O.Null:return O.Null;case O.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?O.Int8:O.Uint8;case 16:return n?O.Int16:O.Uint16;case 32:return n?O.Int32:O.Uint32;case 64:return n?O.Int64:O.Uint64}return O.Int}case O.Float:switch(e.precision){case Hr.HALF:return O.Float16;case Hr.SINGLE:return O.Float32;case Hr.DOUBLE:return O.Float64}return O.Float;case O.Binary:return O.Binary;case O.LargeBinary:return O.LargeBinary;case O.Utf8:return O.Utf8;case O.LargeUtf8:return O.LargeUtf8;case O.Bool:return O.Bool;case O.Decimal:return O.Decimal;case O.Time:switch(e.unit){case Re.SECOND:return O.TimeSecond;case Re.MILLISECOND:return O.TimeMillisecond;case Re.MICROSECOND:return O.TimeMicrosecond;case Re.NANOSECOND:return O.TimeNanosecond}return O.Time;case O.Timestamp:switch(e.unit){case Re.SECOND:return O.TimestampSecond;case Re.MILLISECOND:return O.TimestampMillisecond;case Re.MICROSECOND:return O.TimestampMicrosecond;case Re.NANOSECOND:return O.TimestampNanosecond}return O.Timestamp;case O.Date:switch(e.unit){case Yi.DAY:return O.DateDay;case Yi.MILLISECOND:return O.DateMillisecond}return O.Date;case O.Interval:switch(e.unit){case Ls.DAY_TIME:return O.IntervalDayTime;case Ls.YEAR_MONTH:return O.IntervalYearMonth}return O.Interval;case O.Duration:switch(e.unit){case Re.SECOND:return O.DurationSecond;case Re.MILLISECOND:return O.DurationMillisecond;case Re.MICROSECOND:return O.DurationMicrosecond;case Re.NANOSECOND:return O.DurationNanosecond}return O.Duration;case O.Map:return O.Map;case O.List:return O.List;case O.Struct:return O.Struct;case O.Union:switch(e.mode){case Wr.Dense:return O.DenseUnion;case Wr.Sparse:return O.SparseUnion}return O.Union;case O.FixedSizeBinary:return O.FixedSizeBinary;case O.FixedSizeList:return O.FixedSizeList;case O.Dictionary:return O.Dictionary}throw new Error(`Unrecognized type '${O[e.typeId]}'`)}en.prototype.visitInt8=null,en.prototype.visitInt16=null,en.prototype.visitInt32=null,en.prototype.visitInt64=null,en.prototype.visitUint8=null,en.prototype.visitUint16=null,en.prototype.visitUint32=null,en.prototype.visitUint64=null,en.prototype.visitFloat16=null,en.prototype.visitFloat32=null,en.prototype.visitFloat64=null,en.prototype.visitDateDay=null,en.prototype.visitDateMillisecond=null,en.prototype.visitTimestampSecond=null,en.prototype.visitTimestampMillisecond=null,en.prototype.visitTimestampMicrosecond=null,en.prototype.visitTimestampNanosecond=null,en.prototype.visitTimeSecond=null,en.prototype.visitTimeMillisecond=null,en.prototype.visitTimeMicrosecond=null,en.prototype.visitTimeNanosecond=null,en.prototype.visitDenseUnion=null,en.prototype.visitSparseUnion=null,en.prototype.visitIntervalDayTime=null,en.prototype.visitIntervalYearMonth=null,en.prototype.visitDuration=null,en.prototype.visitDurationSecond=null,en.prototype.visitDurationMillisecond=null,en.prototype.visitDurationMicrosecond=null,en.prototype.visitDurationNanosecond=null;const Ww=new Float64Array(1),yl=new Uint32Array(Ww.buffer);function Hw(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function aU(e){if(e!==e)return 32256;Ww[0]=e;const t=(yl[1]&2147483648)>>16&65535;let n=yl[1]&2146435072,r=0;return n>=1089470464?yl[0]>0?n=31744:(n=(n&2080374784)>>16,r=(yl[1]&1048575)>>10):n<=1056964608?(r=1048576+(yl[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(yl[1]&1048575)+512>>10),t|n|r&65535}class Ne extends en{}function Ce(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const oU=(e,t,n)=>{e[t]=Math.floor(n/864e5)},qw=(e,t,n,r)=>{if(n+1<t.length){const i=jn(t[n]),s=jn(t[n+1]);e.set(r.subarray(0,s-i),i)}},lU=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},ya=({values:e},t,n)=>{e[t]=n},Um=({values:e},t,n)=>{e[t]=n},Xw=({values:e},t,n)=>{e[t]=aU(n)},cU=(e,t,n)=>{switch(e.type.precision){case Hr.HALF:return Xw(e,t,n);case Hr.SINGLE:case Hr.DOUBLE:return Um(e,t,n)}},Kw=({values:e},t,n)=>{oU(e,t,n.valueOf())},Qw=({values:e},t,n)=>{e[t]=BigInt(n)},uU=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Jw=({values:e,valueOffsets:t},n,r)=>qw(e,t,n,r),Zw=({values:e,valueOffsets:t},n,r)=>qw(e,t,n,Rm(r)),dU=(e,t,n)=>{e.type.unit===Yi.DAY?Kw(e,t,n):Qw(e,t,n)},t1=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},e1=({values:e},t,n)=>{e[t]=BigInt(n)},n1=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},r1=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},fU=(e,t,n)=>{switch(e.type.unit){case Re.SECOND:return t1(e,t,n);case Re.MILLISECOND:return e1(e,t,n);case Re.MICROSECOND:return n1(e,t,n);case Re.NANOSECOND:return r1(e,t,n)}},i1=({values:e},t,n)=>{e[t]=n},s1=({values:e},t,n)=>{e[t]=n},a1=({values:e},t,n)=>{e[t]=n},o1=({values:e},t,n)=>{e[t]=n},hU=(e,t,n)=>{switch(e.type.unit){case Re.SECOND:return i1(e,t,n);case Re.MILLISECOND:return s1(e,t,n);case Re.MICROSECOND:return a1(e,t,n);case Re.NANOSECOND:return o1(e,t,n)}},pU=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},mU=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Xi.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},yU=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Xi.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const u of l)if(s(r,a,u),++a>=o)break},gU=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),_U=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),vU=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),bU=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),wU=(e,t,n)=>{const r=e.type.children.map(s=>Xi.getVisitFn(s.type)),i=n instanceof Map?vU(t,n):n instanceof An?_U(t,n):Array.isArray(n)?gU(t,n):bU(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},SU=(e,t,n)=>{e.type.mode===Wr.Dense?l1(e,t,n):c1(e,t,n)},l1=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Xi.visit(i,e.valueOffsets[t],n)},c1=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Xi.visit(i,t,n)},EU=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},IU=(e,t,n)=>{e.type.unit===Ls.DAY_TIME?u1(e,t,n):d1(e,t,n)},u1=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},d1=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},f1=({values:e},t,n)=>{e[t]=n},h1=({values:e},t,n)=>{e[t]=n},p1=({values:e},t,n)=>{e[t]=n},m1=({values:e},t,n)=>{e[t]=n},TU=(e,t,n)=>{switch(e.type.unit){case Re.SECOND:return f1(e,t,n);case Re.MILLISECOND:return h1(e,t,n);case Re.MICROSECOND:return p1(e,t,n);case Re.NANOSECOND:return m1(e,t,n)}},AU=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Xi.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};Ne.prototype.visitBool=Ce(lU),Ne.prototype.visitInt=Ce(ya),Ne.prototype.visitInt8=Ce(ya),Ne.prototype.visitInt16=Ce(ya),Ne.prototype.visitInt32=Ce(ya),Ne.prototype.visitInt64=Ce(ya),Ne.prototype.visitUint8=Ce(ya),Ne.prototype.visitUint16=Ce(ya),Ne.prototype.visitUint32=Ce(ya),Ne.prototype.visitUint64=Ce(ya),Ne.prototype.visitFloat=Ce(cU),Ne.prototype.visitFloat16=Ce(Xw),Ne.prototype.visitFloat32=Ce(Um),Ne.prototype.visitFloat64=Ce(Um),Ne.prototype.visitUtf8=Ce(Zw),Ne.prototype.visitLargeUtf8=Ce(Zw),Ne.prototype.visitBinary=Ce(Jw),Ne.prototype.visitLargeBinary=Ce(Jw),Ne.prototype.visitFixedSizeBinary=Ce(uU),Ne.prototype.visitDate=Ce(dU),Ne.prototype.visitDateDay=Ce(Kw),Ne.prototype.visitDateMillisecond=Ce(Qw),Ne.prototype.visitTimestamp=Ce(fU),Ne.prototype.visitTimestampSecond=Ce(t1),Ne.prototype.visitTimestampMillisecond=Ce(e1),Ne.prototype.visitTimestampMicrosecond=Ce(n1),Ne.prototype.visitTimestampNanosecond=Ce(r1),Ne.prototype.visitTime=Ce(hU),Ne.prototype.visitTimeSecond=Ce(i1),Ne.prototype.visitTimeMillisecond=Ce(s1),Ne.prototype.visitTimeMicrosecond=Ce(a1),Ne.prototype.visitTimeNanosecond=Ce(o1),Ne.prototype.visitDecimal=Ce(pU),Ne.prototype.visitList=Ce(mU),Ne.prototype.visitStruct=Ce(wU),Ne.prototype.visitUnion=Ce(SU),Ne.prototype.visitDenseUnion=Ce(l1),Ne.prototype.visitSparseUnion=Ce(c1),Ne.prototype.visitDictionary=Ce(EU),Ne.prototype.visitInterval=Ce(IU),Ne.prototype.visitIntervalDayTime=Ce(u1),Ne.prototype.visitIntervalYearMonth=Ce(d1),Ne.prototype.visitDuration=Ce(TU),Ne.prototype.visitDurationSecond=Ce(f1),Ne.prototype.visitDurationMillisecond=Ce(h1),Ne.prototype.visitDurationMicrosecond=Ce(p1),Ne.prototype.visitDurationNanosecond=Ce(m1),Ne.prototype.visitFixedSizeList=Ce(AU),Ne.prototype.visitMap=Ce(yU);const Xi=new Ne,ds=Symbol.for("parent"),gl=Symbol.for("rowIndex");class Pm{constructor(t,n){return this[ds]=t,this[gl]=n,new Proxy(this,new RU)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[gl],n=this[ds],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=bi.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Oc(t)}: ${Oc(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new xU(this[ds],this[gl])}}class xU{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,bi.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Pm.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ds]:{writable:!0,enumerable:!1,configurable:!1,value:null},[gl]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class RU{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ds].type.children.map(n=>n.name)}has(t,n){return t[ds].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ds].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[ds].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=bi.visit(t[ds].children[r],t[gl]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ds].type.children.findIndex(s=>s.name===n);return i!==-1?(Xi.visit(t[ds].children[i],t[gl],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class be extends en{}function Be(e){return(t,n)=>t.getValid(n)?e(t,n):null}const NU=(e,t)=>864e5*e[t],BU=(e,t)=>null,y1=(e,t,n)=>{if(n+1>=t.length)return null;const r=jn(t[n]),i=jn(t[n+1]);return e.subarray(r,i)},OU=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},g1=({values:e},t)=>NU(e,t),_1=({values:e},t)=>jn(e[t]),$a=({stride:e,values:t},n)=>t[e*n],DU=({stride:e,values:t},n)=>Hw(t[e*n]),v1=({values:e},t)=>e[t],FU=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),b1=({values:e,valueOffsets:t},n)=>y1(e,t,n),w1=({values:e,valueOffsets:t},n)=>{const r=y1(e,t,n);return r!==null?xm(r):null},LU=({values:e},t)=>e[t],MU=({type:e,values:t},n)=>e.precision!==Hr.HALF?t[n]:Hw(t[n]),CU=(e,t)=>e.type.unit===Yi.DAY?g1(e,t):_1(e,t),S1=({values:e},t)=>1e3*jn(e[t]),E1=({values:e},t)=>jn(e[t]),I1=({values:e},t)=>ww(e[t],BigInt(1e3)),T1=({values:e},t)=>ww(e[t],BigInt(1e6)),kU=(e,t)=>{switch(e.type.unit){case Re.SECOND:return S1(e,t);case Re.MILLISECOND:return E1(e,t);case Re.MICROSECOND:return I1(e,t);case Re.NANOSECOND:return T1(e,t)}},A1=({values:e},t)=>e[t],x1=({values:e},t)=>e[t],R1=({values:e},t)=>e[t],N1=({values:e},t)=>e[t],UU=(e,t)=>{switch(e.type.unit){case Re.SECOND:return A1(e,t);case Re.MILLISECOND:return x1(e,t);case Re.MICROSECOND:return R1(e,t);case Re.NANOSECOND:return N1(e,t)}},PU=({values:e,stride:t},n)=>km.decimal(e.subarray(t*n,t*(n+1))),$U=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,o=i[0].slice(s,a-s);return new An([o])},VU=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new Vm(a.slice(i,s-i))},zU=(e,t)=>new Pm(e,t),GU=(e,t)=>e.type.mode===Wr.Dense?B1(e,t):O1(e,t),B1=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return bi.visit(r,e.valueOffsets[t])},O1=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return bi.visit(r,t)},jU=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},YU=(e,t)=>e.type.unit===Ls.DAY_TIME?D1(e,t):F1(e,t),D1=({values:e},t)=>e.subarray(2*t,2*(t+1)),F1=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},L1=({values:e},t)=>e[t],M1=({values:e},t)=>e[t],C1=({values:e},t)=>e[t],k1=({values:e},t)=>e[t],WU=(e,t)=>{switch(e.type.unit){case Re.SECOND:return L1(e,t);case Re.MILLISECOND:return M1(e,t);case Re.MICROSECOND:return C1(e,t);case Re.NANOSECOND:return k1(e,t)}},HU=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new An([i])};be.prototype.visitNull=Be(BU),be.prototype.visitBool=Be(OU),be.prototype.visitInt=Be(LU),be.prototype.visitInt8=Be($a),be.prototype.visitInt16=Be($a),be.prototype.visitInt32=Be($a),be.prototype.visitInt64=Be(v1),be.prototype.visitUint8=Be($a),be.prototype.visitUint16=Be($a),be.prototype.visitUint32=Be($a),be.prototype.visitUint64=Be(v1),be.prototype.visitFloat=Be(MU),be.prototype.visitFloat16=Be(DU),be.prototype.visitFloat32=Be($a),be.prototype.visitFloat64=Be($a),be.prototype.visitUtf8=Be(w1),be.prototype.visitLargeUtf8=Be(w1),be.prototype.visitBinary=Be(b1),be.prototype.visitLargeBinary=Be(b1),be.prototype.visitFixedSizeBinary=Be(FU),be.prototype.visitDate=Be(CU),be.prototype.visitDateDay=Be(g1),be.prototype.visitDateMillisecond=Be(_1),be.prototype.visitTimestamp=Be(kU),be.prototype.visitTimestampSecond=Be(S1),be.prototype.visitTimestampMillisecond=Be(E1),be.prototype.visitTimestampMicrosecond=Be(I1),be.prototype.visitTimestampNanosecond=Be(T1),be.prototype.visitTime=Be(UU),be.prototype.visitTimeSecond=Be(A1),be.prototype.visitTimeMillisecond=Be(x1),be.prototype.visitTimeMicrosecond=Be(R1),be.prototype.visitTimeNanosecond=Be(N1),be.prototype.visitDecimal=Be(PU),be.prototype.visitList=Be($U),be.prototype.visitStruct=Be(zU),be.prototype.visitUnion=Be(GU),be.prototype.visitDenseUnion=Be(B1),be.prototype.visitSparseUnion=Be(O1),be.prototype.visitDictionary=Be(jU),be.prototype.visitInterval=Be(YU),be.prototype.visitIntervalDayTime=Be(D1),be.prototype.visitIntervalYearMonth=Be(F1),be.prototype.visitDuration=Be(WU),be.prototype.visitDurationSecond=Be(L1),be.prototype.visitDurationMillisecond=Be(M1),be.prototype.visitDurationMicrosecond=Be(C1),be.prototype.visitDurationNanosecond=Be(k1),be.prototype.visitFixedSizeList=Be(HU),be.prototype.visitMap=Be(VU);const bi=new be,_l=Symbol.for("keys"),vl=Symbol.for("vals"),bl=Symbol.for("kKeysAsStrings"),$m=Symbol.for("_kKeysAsStrings");class Vm{constructor(t){return this[_l]=new An([t.children[0]]).memoize(),this[vl]=t.children[1],new Proxy(this,new XU)}get[bl](){return this[$m]||(this[$m]=Array.from(this[_l].toArray(),String))}[Symbol.iterator](){return new qU(this[_l],this[vl])}get size(){return this[_l].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[_l],n=this[vl],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=bi.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Oc(t)}: ${Oc(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class qU{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),bi.visit(this.vals,t)]})}}class XU{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[bl]}has(t,n){return t[bl].includes(n)}getOwnPropertyDescriptor(t,n){if(t[bl].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[bl].indexOf(n);if(r!==-1){const i=bi.visit(Reflect.get(t,vl),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[bl].indexOf(n);return i!==-1?(Xi.visit(Reflect.get(t,vl),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(Vm.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[_l]:{writable:!0,enumerable:!1,configurable:!1,value:null},[vl]:{writable:!0,enumerable:!1,configurable:!1,value:null},[$m]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let U1;function P1(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(U1=s,s=a,a=U1),a>i&&(a=i),r?r(e,s,a):[s,a]}const zm=(e,t)=>e<0?t+e:e,$1=e=>e!==e;function wl(e){if(typeof e!="object"||e===null)return $1(e)?$1:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?Hk(e,t):!1:e instanceof Map?QU(e):Array.isArray(e)?KU(e):e instanceof An?JU(e):ZU(e,!0)}function KU(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=wl(e[n]);return Lf(t)}function QU(e){let t=-1;const n=[];for(const r of e.values())n[++t]=wl(r);return Lf(n)}function JU(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=wl(e.get(n));return Lf(t)}function ZU(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=wl(e[n[i]]);return Lf(r,n)}function Lf(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return t3(e,n);case Map:return V1(e,n,n.keys());case Vm:case Pm:case Object:case void 0:return V1(e,n,t||Object.keys(n))}return n instanceof An?e3(e,n):!1}}function t3(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function e3(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function V1(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),u=r.next(),f=i.next();for(;a<o&&!u.done&&!f.done&&!l.done&&!(u.value!==f.value||!e[a](l.value));++a,u=r.next(),f=i.next(),l=s.next());return a===o&&u.done&&f.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function z1(e,t,n,r){return(n&1<<r)!==0}function n3(e,t,n,r){return(n&1<<r)>>r}function Mf(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):Cf(new Gm(n,e,t,null,z1)).subarray(0,r)),i}return n}function Cf(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class Gm{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function jm(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new Gm(e,t,n-t,e,n3))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return jm(e,t,i)+jm(e,r,n)+r3(e,i>>3,r-i>>3)}function r3(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=Ym(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=Ym(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=Ym(s.getUint8(i)),i+=1;return r}function Ym(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const i3=-1;class Fn{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return oe.isSparseUnion(t)?this.children.some(n=>n.nullable):oe.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(oe.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=i3&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-jm(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof Fn?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=ma(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(oe.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Wr.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(oe.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Wr.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,u=1<<l%8,f=l>>3;(!s||s.byteLength<=f)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Mf(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const p=s[f];r=(p&u)!==0,s[f]=n?p|u:p&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new Fn(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===O.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Mf(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[pa.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[pa.TYPE])&&(a[pa.TYPE]=s.subarray(t,t+n)),(s=a[pa.OFFSET])&&(a[pa.OFFSET]=s.subarray(t,t+n+1))||(s=a[pa.DATA])&&(a[pa.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}Fn.prototype.children=Object.freeze([]);class Mc extends en{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new Fn(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=Bc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=aw(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=Bc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.data),s=un(t.nullBitmap),a=aw(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=un(t.nullBitmap),a=Bc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=un(t.nullBitmap),{length:a=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=Gn(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(oe.isSparseUnion(n))return new Fn(n,r,a,o,[void 0,void 0,void 0,s],i);const l=Bc(t.valueOffsets);return new Fn(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.indices.ArrayType,t.data),{["dictionary"]:a=new An([new Mc().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=un(t.nullBitmap),s=Gn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Mc().visit({type:n.valueType})}=t,s=un(t.nullBitmap),{["length"]:a=i.length/ma(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new Fn(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Mc().visit({type:n.childType})}=t,s=un(t.nullBitmap),a=Bc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Fn(n,r,o,l,[a,void 0,s],[i])}}const s3=new Mc;function an(e){return s3.visit(e)}class G1{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function a3(e){return e.some(t=>t.nullable)}function j1(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Y1(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function W1(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:u}=o;if(l>=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(o);continue}const f=Math.max(0,n-l),p=Math.min(r-l,u);i.push(o.slice(f,p-f))}return i.length===0&&i.push(e[0].slice(0,0)),i}function Wm(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function Hm(e,t){return e.getValid(t)}function kf(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return Wm(r,this._offsets,n,t)}}function H1(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=Wm(s,this._offsets,r,n);return t=void 0,a}}function q1(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let u=i-1,f=r.length;++u<f;){const p=r[u];if(~(o=e(p,t,a)))return l+o;a=0,l+=p.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):Wm(s,this._offsets,i,n);return t=void 0,a}}class we extends en{}function o3(e,t){return t===null&&e.length>0?0:-1}function l3(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new Gm(n,e.offset+(t||0),e.length,n,z1)){if(!i)return r;++r}return-1}function $e(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case O.Union:break;case O.Dictionary:break;default:return l3(e,n)}const r=bi.getVisitFn(e),i=wl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function X1(e,t,n){const r=bi.getVisitFn(e),i=wl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}we.prototype.visitNull=o3,we.prototype.visitBool=$e,we.prototype.visitInt=$e,we.prototype.visitInt8=$e,we.prototype.visitInt16=$e,we.prototype.visitInt32=$e,we.prototype.visitInt64=$e,we.prototype.visitUint8=$e,we.prototype.visitUint16=$e,we.prototype.visitUint32=$e,we.prototype.visitUint64=$e,we.prototype.visitFloat=$e,we.prototype.visitFloat16=$e,we.prototype.visitFloat32=$e,we.prototype.visitFloat64=$e,we.prototype.visitUtf8=$e,we.prototype.visitLargeUtf8=$e,we.prototype.visitBinary=$e,we.prototype.visitLargeBinary=$e,we.prototype.visitFixedSizeBinary=$e,we.prototype.visitDate=$e,we.prototype.visitDateDay=$e,we.prototype.visitDateMillisecond=$e,we.prototype.visitTimestamp=$e,we.prototype.visitTimestampSecond=$e,we.prototype.visitTimestampMillisecond=$e,we.prototype.visitTimestampMicrosecond=$e,we.prototype.visitTimestampNanosecond=$e,we.prototype.visitTime=$e,we.prototype.visitTimeSecond=$e,we.prototype.visitTimeMillisecond=$e,we.prototype.visitTimeMicrosecond=$e,we.prototype.visitTimeNanosecond=$e,we.prototype.visitDecimal=$e,we.prototype.visitList=$e,we.prototype.visitStruct=$e,we.prototype.visitUnion=$e,we.prototype.visitDenseUnion=X1,we.prototype.visitSparseUnion=X1,we.prototype.visitDictionary=$e,we.prototype.visitInterval=$e,we.prototype.visitIntervalDayTime=$e,we.prototype.visitIntervalYearMonth=$e,we.prototype.visitDuration=$e,we.prototype.visitDurationSecond=$e,we.prototype.visitDurationMillisecond=$e,we.prototype.visitDurationMicrosecond=$e,we.prototype.visitDurationNanosecond=$e,we.prototype.visitFixedSizeList=$e,we.prototype.visitMap=$e;const Uf=new we;class Se extends en{}function Oe(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(oe.isInt(t)&&t.bitWidth!==64||oe.isTime(t)&&t.bitWidth!==64||oe.isFloat(t)&&t.precision!==Hr.HALF))return new G1(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new G1(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new c3(s)})}class c3{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}Se.prototype.visitNull=Oe,Se.prototype.visitBool=Oe,Se.prototype.visitInt=Oe,Se.prototype.visitInt8=Oe,Se.prototype.visitInt16=Oe,Se.prototype.visitInt32=Oe,Se.prototype.visitInt64=Oe,Se.prototype.visitUint8=Oe,Se.prototype.visitUint16=Oe,Se.prototype.visitUint32=Oe,Se.prototype.visitUint64=Oe,Se.prototype.visitFloat=Oe,Se.prototype.visitFloat16=Oe,Se.prototype.visitFloat32=Oe,Se.prototype.visitFloat64=Oe,Se.prototype.visitUtf8=Oe,Se.prototype.visitLargeUtf8=Oe,Se.prototype.visitBinary=Oe,Se.prototype.visitLargeBinary=Oe,Se.prototype.visitFixedSizeBinary=Oe,Se.prototype.visitDate=Oe,Se.prototype.visitDateDay=Oe,Se.prototype.visitDateMillisecond=Oe,Se.prototype.visitTimestamp=Oe,Se.prototype.visitTimestampSecond=Oe,Se.prototype.visitTimestampMillisecond=Oe,Se.prototype.visitTimestampMicrosecond=Oe,Se.prototype.visitTimestampNanosecond=Oe,Se.prototype.visitTime=Oe,Se.prototype.visitTimeSecond=Oe,Se.prototype.visitTimeMillisecond=Oe,Se.prototype.visitTimeMicrosecond=Oe,Se.prototype.visitTimeNanosecond=Oe,Se.prototype.visitDecimal=Oe,Se.prototype.visitList=Oe,Se.prototype.visitStruct=Oe,Se.prototype.visitUnion=Oe,Se.prototype.visitDenseUnion=Oe,Se.prototype.visitSparseUnion=Oe,Se.prototype.visitDictionary=Oe,Se.prototype.visitInterval=Oe,Se.prototype.visitIntervalDayTime=Oe,Se.prototype.visitIntervalYearMonth=Oe,Se.prototype.visitDuration=Oe,Se.prototype.visitDurationSecond=Oe,Se.prototype.visitDurationMillisecond=Oe,Se.prototype.visitDurationMicrosecond=Oe,Se.prototype.visitDurationNanosecond=Oe,Se.prototype.visitFixedSizeList=Oe,Se.prototype.visitMap=Oe;const qm=new Se;var K1;const Q1={},J1={};class An{constructor(t){var n,r,i;const s=t[0]instanceof An?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof Fn)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:u}=Q1[a.typeId],f=s[0];this.isValid=p=>Hm(f,p),this.get=p=>o(f,p),this.set=(p,E)=>l(f,p,E),this.indexOf=p=>u(f,p),this._offsets=[0,f.length];break}default:Object.setPrototypeOf(this,J1[a.typeId]),this._offsets=Y1(s);break}this.data=s,this.type=a,this.stride=ma(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return a3(this.data)}get nullCount(){return j1(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${O[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(zm(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return qm.visit(this)}concat(...t){return new An(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new An(P1(this,t,n,({data:r,_offsets:i},s,a)=>W1(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case O.Int:case O.Float:case O.Decimal:case O.Time:case O.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new An(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return oe.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(oe.isDictionary(this.type)){const t=new Pf(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new An(n)}return new Pf(this)}unmemoize(){if(oe.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new An(n)}return this}}K1=Symbol.toStringTag,An[K1]=(e=>{e.type=oe.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(O).map(n=>O[n]).filter(n=>typeof n=="number"&&n!==O.NONE);for(const n of t){const r=bi.getVisitFnByTypeId(n),i=Xi.getVisitFnByTypeId(n),s=Uf.getVisitFnByTypeId(n);Q1[n]={get:r,set:i,indexOf:s},J1[n]=Object.create(e,{isValid:{value:kf(Hm)},get:{value:kf(bi.getVisitFnByTypeId(n))},set:{value:H1(Xi.getVisitFnByTypeId(n))},indexOf:{value:q1(Uf.getVisitFnByTypeId(n))}})}return"Vector"})(An.prototype);class Pf extends An{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new Pf(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new An(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Xm{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Di{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Di).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Tn),(n||new Di).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yr.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Us).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Xm).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new Xm).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Ar).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yr.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class xn{constructor(t=[],n,r,i=yr.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=Km(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new xn(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new xn(n,this.metadata)}assign(...t){const n=t[0]instanceof xn?t[0]:Array.isArray(t[0])?new xn(t[0]):new xn(t),r=[...this.fields],i=$f($f(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(u=>u.name===o.name);return~l?(r[l]=o.clone({metadata:$f($f(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=Km(s,new Map);return new xn([...r,...s],i,new Map([...this.dictionaries,...a]))}}xn.prototype.fields=null,xn.prototype.metadata=null,xn.prototype.dictionaries=null;class Kn{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new Kn(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],Kn.new(n,r,i,s)}}Kn.prototype.type=null,Kn.prototype.name=null,Kn.prototype.nullable=null,Kn.prototype.metadata=null;function $f(e,t){return new Map([...e||new Map,...t||new Map])}function Km(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(oe.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&Km(i.children,t)}return t}var u3=dw,d3=ll;class Cc{static decode(t){t=new d3(un(t));const n=Di.getRootAsFooter(t),r=xn.decode(n.schema(),new Map,n.version());return new f3(r,n)}static encode(t){const n=new u3,r=xn.encode(n,t.schema);Di.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Va.encode(n,a);const i=n.endVector();Di.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Va.encode(n,a);const s=n.endVector();return Di.startFooter(n),Di.addSchema(n,r),Di.addVersion(n,yr.V5),Di.addRecordBatches(n,i),Di.addDictionaries(n,s),Di.finishFooterBuffer(n,Di.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=yr.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class f3 extends Cc{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Va.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Va.decode(n)}return null}}class Va{static decode(t){return new Va(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return Xm.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=jn(r),this.bodyLength=jn(n)}}const xr=Object.freeze({done:!0,value:void 0});class Z1{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Qm{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class h3 extends Qm{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return ze(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(xr);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ji.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ji.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return ze(this,void 0,void 0,function*(){return yield this.abort(t),xr})}return(t){return ze(this,void 0,void 0,function*(){return yield this.close(),xr})}read(t){return ze(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return ze(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(xr)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Vf extends h3{write(t){if((t=un(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?xm(this.toUint8Array(!0)):this.toUint8Array(!1).then(xm)}toUint8Array(t=!1){return t?Fs(this._values)[0]:ze(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,u=go(this),f;f=yield u.next(),n=f.done,!n;l=!0){s=f.value,l=!1;const p=s;a.push(p),o+=p.byteLength}}catch(p){r={error:p}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Fs(a,o)[0]})}}class zf{constructor(t){t&&(this.source=new p3(ji.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Sl{constructor(t){t instanceof Sl?this.source=t.source:t instanceof Vf?this.source=new wo(ji.fromAsyncIterable(t)):iw(t)?this.source=new wo(ji.fromNodeStream(t)):Bm(t)?this.source=new wo(ji.fromDOMStream(t)):rw(t)?this.source=new wo(ji.fromDOMStream(t.body)):Nc(t)?this.source=new wo(ji.fromIterable(t)):_o(t)?this.source=new wo(ji.fromAsyncIterable(t)):ol(t)&&(this.source=new wo(ji.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class p3{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||xr)}return(t){return Object.create(this.source.return&&this.source.return(t)||xr)}}class wo{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return ze(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return ze(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return ze(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return ze(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return ze(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||xr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return ze(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||xr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class tS extends zf{constructor(t,n){super(),this.position=0,this.buffer=un(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class Gf extends Sl{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=ze(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return ze(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return ze(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return ze(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),u=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<u.byteLength;)({bytesRead:o}=yield n.read(u,a,u.byteLength-a,s));return u}return null})}readAt(t,n){return ze(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return ze(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return ze(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return ze(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const m3=65536;function El(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Il=8,Jm=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class eS{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?m3:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${El(this.buffer[1])} ${El(this.buffer[0])}`}}class Ln extends eS{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return Ln.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Ln.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new Ln(n);for(let s=0;s<r;){const a=Il<r-s?Il:r-s,o=new Ln(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new Ln(new Uint32Array([Jm[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Ln.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Ln(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Ln(new Uint32Array(t.buffer)).plus(n)}}class Ki extends eS{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return Ki.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Ki.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new Ki(n);for(let a=r?1:0;a<i;){const o=Il<i-a?Il:i-a,l=new Ki(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),u=new Ki(new Uint32Array([Jm[o],0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Ki.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Ki(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Ki(new Uint32Array(t.buffer)).plus(n)}}class Ps{constructor(t){this.buffer=t}high(){return new Ki(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Ki(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){const n=new Ln(new Uint32Array([this.buffer[3],0])),r=new Ln(new Uint32Array([this.buffer[2],0])),i=new Ln(new Uint32Array([this.buffer[1],0])),s=new Ln(new Uint32Array([this.buffer[0],0])),a=new Ln(new Uint32Array([t.buffer[3],0])),o=new Ln(new Uint32Array([t.buffer[2],0])),l=new Ln(new Uint32Array([t.buffer[1],0])),u=new Ln(new Uint32Array([t.buffer[0],0]));let f=Ln.multiply(s,u);this.buffer[0]=f.low();const p=new Ln(new Uint32Array([f.high(),0]));return f=Ln.multiply(i,u),p.plus(f),f=Ln.multiply(s,l),p.plus(f),this.buffer[1]=p.low(),this.buffer[3]=p.lessThan(f)?1:0,this.buffer[2]=p.high(),new Ln(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ln.multiply(r,u)).plus(Ln.multiply(i,l)).plus(Ln.multiply(s,o)),this.buffer[3]+=Ln.multiply(n,u).plus(Ln.multiply(r,l)).plus(Ln.multiply(i,o)).plus(Ln.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${El(this.buffer[3])} ${El(this.buffer[2])} ${El(this.buffer[1])} ${El(this.buffer[0])}`}static multiply(t,n){return new Ps(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Ps(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return Ps.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return Ps.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new Ps(n);for(let a=r?1:0;a<i;){const o=Il<i-a?Il:i-a,l=new Ps(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),u=new Ps(new Uint32Array([Jm[o],0,0,0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)Ps.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class nS extends en{constructor(t,n,r,i,s=yr.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof Kn?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return an({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<yr.V5&&this.readNullBitmap(t,r),t.mode===Wr.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class y3 extends nS{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):Cf(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return Gn(Uint8Array,Gn(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return Gn(Uint8Array,Gn(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return oe.isTimestamp(t)||(oe.isInt(t)||oe.isTime(t))&&t.bitWidth===64||oe.isDuration(t)||oe.isDate(t)&&t.unit===Yi.MILLISECOND?Gn(Uint8Array,Ki.convertArray(r[n])):oe.isDecimal(t)?Gn(Uint8Array,Ps.convertArray(r[n])):oe.isBinary(t)||oe.isLargeBinary(t)||oe.isFixedSizeBinary(t)?g3(r[n]):oe.isBool(t)?Cf(r[n]):oe.isUtf8(t)||oe.isLargeUtf8(t)?Rm(r[n].join("")):Gn(Uint8Array,Gn(t.ArrayType,r[n].map(i=>+i)))}}function g3(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class Ee extends en{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function si(e,t){return t instanceof e.constructor}function So(e,t){return e===t||si(e,t)}function ga(e,t){return e===t||si(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function jf(e,t){return e===t||si(e,t)&&e.precision===t.precision}function _3(e,t){return e===t||si(e,t)&&e.byteWidth===t.byteWidth}function Zm(e,t){return e===t||si(e,t)&&e.unit===t.unit}function kc(e,t){return e===t||si(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Uc(e,t){return e===t||si(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function v3(e,t){return e===t||si(e,t)&&e.children.length===t.children.length&&za.compareManyFields(e.children,t.children)}function b3(e,t){return e===t||si(e,t)&&e.children.length===t.children.length&&za.compareManyFields(e.children,t.children)}function ty(e,t){return e===t||si(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&za.compareManyFields(e.children,t.children)}function w3(e,t){return e===t||si(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&za.visit(e.indices,t.indices)&&za.visit(e.dictionary,t.dictionary)}function ey(e,t){return e===t||si(e,t)&&e.unit===t.unit}function Pc(e,t){return e===t||si(e,t)&&e.unit===t.unit}function S3(e,t){return e===t||si(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&za.compareManyFields(e.children,t.children)}function E3(e,t){return e===t||si(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&za.compareManyFields(e.children,t.children)}Ee.prototype.visitNull=So,Ee.prototype.visitBool=So,Ee.prototype.visitInt=ga,Ee.prototype.visitInt8=ga,Ee.prototype.visitInt16=ga,Ee.prototype.visitInt32=ga,Ee.prototype.visitInt64=ga,Ee.prototype.visitUint8=ga,Ee.prototype.visitUint16=ga,Ee.prototype.visitUint32=ga,Ee.prototype.visitUint64=ga,Ee.prototype.visitFloat=jf,Ee.prototype.visitFloat16=jf,Ee.prototype.visitFloat32=jf,Ee.prototype.visitFloat64=jf,Ee.prototype.visitUtf8=So,Ee.prototype.visitLargeUtf8=So,Ee.prototype.visitBinary=So,Ee.prototype.visitLargeBinary=So,Ee.prototype.visitFixedSizeBinary=_3,Ee.prototype.visitDate=Zm,Ee.prototype.visitDateDay=Zm,Ee.prototype.visitDateMillisecond=Zm,Ee.prototype.visitTimestamp=kc,Ee.prototype.visitTimestampSecond=kc,Ee.prototype.visitTimestampMillisecond=kc,Ee.prototype.visitTimestampMicrosecond=kc,Ee.prototype.visitTimestampNanosecond=kc,Ee.prototype.visitTime=Uc,Ee.prototype.visitTimeSecond=Uc,Ee.prototype.visitTimeMillisecond=Uc,Ee.prototype.visitTimeMicrosecond=Uc,Ee.prototype.visitTimeNanosecond=Uc,Ee.prototype.visitDecimal=So,Ee.prototype.visitList=v3,Ee.prototype.visitStruct=b3,Ee.prototype.visitUnion=ty,Ee.prototype.visitDenseUnion=ty,Ee.prototype.visitSparseUnion=ty,Ee.prototype.visitDictionary=w3,Ee.prototype.visitInterval=ey,Ee.prototype.visitIntervalDayTime=ey,Ee.prototype.visitIntervalYearMonth=ey,Ee.prototype.visitDuration=Pc,Ee.prototype.visitDurationSecond=Pc,Ee.prototype.visitDurationMillisecond=Pc,Ee.prototype.visitDurationMicrosecond=Pc,Ee.prototype.visitDurationNanosecond=Pc,Ee.prototype.visitFixedSizeList=S3,Ee.prototype.visitMap=E3;const za=new Ee;function ny(e,t){return za.compareSchemas(e,t)}function ry(e,t){return I3(e,t.map(n=>n.data.concat()))}function I3(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((p,E)=>Math.max(p,E.length),0)};let s=0,a=0,o=-1;const l=t.length;let u,f=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)f[o]=u=t[o].shift(),a=Math.min(a,u?u.length:a);Number.isFinite(a)&&(f=T3(n,a,f,t,i),a>0&&(r[s++]=an({type:new ii(n),length:a,nullCount:0,children:f.slice()})))}return[e=e.assign(n),r.map(p=>new wi(e,p))]}function T3(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const u=n[o],f=u==null?void 0:u.length;if(f>=t)f===t?n[o]=u:(n[o]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(u.slice(t,f-t))));else{const p=e[o];e[o]=p.clone({nullable:!0}),n[o]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:an({type:p.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var rS;class ai{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new xn([]),this._offsets=[0],this;let i,s;t[0]instanceof xn&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof wi)return[l];if(l instanceof ai)return l.batches;if(l instanceof Fn){if(l.type instanceof ii)return[new wi(new xn(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>a(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>a(u));if(typeof l=="object"){const u=Object.keys(l),f=u.map(T=>new An([l[T]])),p=i??new xn(u.map((T,U)=>new Kn(String(T),f[U].type,f[U].nullable))),[,E]=ry(p,f);return E.length===0?[new wi(l)]:E}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new xn([]),!(i instanceof xn))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof wi))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!ny(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Y1(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=j1(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(zm(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?qm.visit(new An(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
327
+ }`,attributes:{position:nn,color:Gn},uniforms:{pointSize:ln.prop("pointSize"),scale:ln.prop("scale"),translate:ln.prop("translate")},count:nn.length/2,primitive:"points",depth:{enable:!1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:"src alpha",dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}});const rn=Yp().scaleExtent([.5,10]).filter(me=>me.type!=="wheel").on("zoom",me=>{me.sourceEvent&&me.sourceEvent.type!=="wheel"&&(u.value=me.transform,Qn(),o.value&&xt.value&&(Pr(i.value).property("__zoom",me.transform),Ye()))});Pr(X).call(rn);let Cr=0;const Tr=16,Jr=me=>{me.preventDefault();const Sn=X.getBoundingClientRect(),xn=me.clientX-Sn.left,hr=me.clientY-Sn.top,Nn=u.value||Ri,Yn=xn/X.width*2-1,ti=-(hr/X.height*2-1),ei=2*Nn.x/X.width,Wr=-(2*Nn.y)/X.height,or=(Yn-ei)/Nn.k,lr=(ti-Wr)/Nn.k,_r=-me.deltaY*.002,vr=Math.max(.5,Math.min(10,Nn.k*Math.pow(2,_r))),Vr=Yn-or*vr,hi=ti-lr*vr,zr=Vr*X.width/2,Hr=-(hi*X.height)/2,ts=Ri.translate(zr,Hr).scale(vr);u.value=ts,Qn(),Pr(X).property("__zoom",ts),i.value&&o.value&&xt.value&&(Pr(i.value).property("__zoom",ts),Ye())},Zr=me=>{const Sn=Date.now();if(Sn-Cr<Tr)return;Cr=Sn;const xn=X.getBoundingClientRect(),hr=me.clientX-xn.left,Nn=me.clientY-xn.top,Yn=u.value||Ri,ti=hr/X.width*2-1,ei=-(Nn/X.height*2-1),Wr=.02;let or=null,lr=Wr,_r=-1;if(S.value.forEach((vr,Vr)=>{const hi=zn(vr.x),zr=zt(vr.y),Hr=2*Yn.x/X.width,ts=-(2*Yn.y)/X.height,Sa=hi*Yn.k+Hr,ys=zr*Yn.k+ts,gs=Sa-ti,ah=ys-ei,oh=Math.sqrt(gs*gs+ah*ah);oh<lr&&(lr=oh,or=vr,_r=Vr)}),or){M.value=or.cell_id,H.value=!1;const vr=zn(or.x),Vr=zt(or.y),hi=2*Yn.x/X.width,zr=-(2*Yn.y)/X.height,Hr=(vr*Yn.k+hi+1)/2*X.width,ts=(1-(Vr*Yn.k+zr))/2*X.height,Sa=X.getBoundingClientRect()}else M.value=null;Qn(),o.value&&xt.value&&Ye()},ee=()=>{M.value=null,Qn(),o.value&&xt.value&&Ye()};X.addEventListener("wheel",Jr,{passive:!1}),X.addEventListener("mousemove",Zr),X.addEventListener("mouseleave",ee),Kn=[{event:"wheel",handler:Jr},{event:"mousemove",handler:Zr},{event:"mouseleave",handler:ee}],Qn()}catch(Me){console.error("Failed to render gene UMAP:",Me),ot.value=!1}}function di(X){const wt={},kt=new Set(["cell_id","umap_1","umap_2","tsne_1","tsne_2","x","y","color","opacity","expr","norm"]);return Object.keys(X).forEach(Gt=>{!kt.has(Gt)&&X[Gt]!==null&&X[Gt]!==void 0&&(wt[Gt]=X[Gt])}),wt}function he(X){return{}}function Mr(X){return X.split("_").map(wt=>wt.charAt(0).toUpperCase()+wt.slice(1)).join(" ")}c.ref("#ff0000"),c.ref("#0000ff");function Ci(X,wt){return typeof wt=="number"?X===Qt.value||X===xt.value?wt.toFixed(3):wt<.01&&wt>0?wt.toExponential(2):Math.abs(wt)>1e3?wt.toLocaleString():wt.toFixed(2):wt}return(X,wt)=>(c.openBlock(),c.createElementBlock("div",eU,[Ct.value?(c.openBlock(),c.createElementBlock("div",nU,[...wt[2]||(wt[2]=[c.createElementVNode("div",{class:"spinner"},null,-1),c.createElementVNode("p",{class:"loading-text"},"Loading UMAP data...",-1)])])):Zt.value?(c.openBlock(),c.createElementBlock("div",rU,[wt[3]||(wt[3]=c.createElementVNode("strong",null,"⚠️ Error:",-1)),c.createTextVNode(" "+c.toDisplayString(Zt.value),1)])):(c.openBlock(),c.createElementBlock("div",iU,[wt[11]||(wt[11]=c.createElementVNode("div",{class:"filter-placeholder"},null,-1)),c.createElementVNode("div",sU,[c.createElementVNode("div",aU,[wt[6]||(wt[6]=c.createElementVNode("div",{class:"header"},[c.createElementVNode("h3",{class:"title"},"Cell Metadata")],-1)),c.createElementVNode("div",oU,[c.createElementVNode("label",lU,[wt[4]||(wt[4]=c.createTextVNode(" Select metadata: ",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":wt[0]||(wt[0]=kt=>xt.value=kt),onChange:_,class:"select"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(ie.value,kt=>(c.openBlock(),c.createElementBlock("option",{key:kt,value:kt},c.toDisplayString(kt),9,cU))),128))],544),[[c.vModelSelect,xt.value]])])]),c.createElementVNode("div",uU,[c.createElementVNode("canvas",{ref_key:"leftCanvas",ref:i},null,512)]),on.value.length>0?(c.openBlock(),c.createElementBlock("div",{key:0,class:c.normalizeClass(["legend",{"legend-expanded":j.value}])},[c.createElementVNode("div",dU,[wt[5]||(wt[5]=c.createElementVNode("div",{class:"legend-title"},"Legend",-1)),c.createElementVNode("button",{class:"legend-toggle",onClick:c.withModifiers(te,["stop"]),title:j.value?"Collapse":"Expand"},[j.value?(c.openBlock(),c.createElementBlock("span",hU,"▼")):(c.openBlock(),c.createElementBlock("span",pU,"▲"))],8,fU)]),c.createElementVNode("div",mU,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(on.value,(kt,Gt)=>(c.openBlock(),c.createElementBlock("div",{key:Gt,class:"legend-item",onClick:pe=>et(kt.label)},[c.createElementVNode("div",{class:c.normalizeClass(["legend-color",{"legend-color-hidden":!ge.value.has(kt.label)}]),style:c.normalizeStyle({background:kt.color,borderColor:kt.color})},[ge.value.has(kt.label)?c.createCommentVNode("",!0):(c.openBlock(),c.createElementBlock("span",gU,"✕"))],6),c.createElementVNode("span",_U,c.toDisplayString(kt.label),1)],8,yU))),128))])],2)):c.createCommentVNode("",!0),pn.value?(c.openBlock(),c.createElementBlock("div",{key:1,class:"tooltip",style:c.normalizeStyle({left:nt.value.x+"px",top:nt.value.y+"px"})},[c.createElementVNode("div",vU,c.toDisplayString(pn.value.cell_id),1),(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(di(pn.value),(kt,Gt)=>(c.openBlock(),c.createElementBlock("div",{key:Gt,class:"tooltip-row"},[c.createElementVNode("span",{class:"tooltip-label",style:c.normalizeStyle(he())},c.toDisplayString(Mr(Gt))+":",5),c.createElementVNode("span",bU,c.toDisplayString(Ci(Gt,kt)),1)]))),128))],4)):c.createCommentVNode("",!0)]),c.createElementVNode("div",wU,[wt[10]||(wt[10]=c.createElementVNode("div",{class:"header"},[c.createElementVNode("h3",{class:"title"},"Assay RNA (Gene Expression)")],-1)),c.createElementVNode("div",SU,[c.createElementVNode("label",EU,[wt[7]||(wt[7]=c.createTextVNode(" Select gene: ",-1)),c.createElementVNode("div",IU,[c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":wt[1]||(wt[1]=kt=>ne.value=kt),type:"text",placeholder:"Enter gene name (e.g., CDH9)",class:"gene-input",list:"gene-suggestions",onInput:In},null,544),[[c.vModelText,ne.value]]),c.createElementVNode("datalist",TU,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(rt.value,kt=>(c.openBlock(),c.createElementBlock("option",{key:kt,value:kt},null,8,AU))),128))]),c.createElementVNode("button",{onClick:ir,disabled:!ne.value.trim()||ot.value,class:"visualize-btn"},c.toDisplayString(ot.value?"Loading...":"Visualize"),9,xU)])])]),c.createElementVNode("div",NU,[ot.value?(c.openBlock(),c.createElementBlock("div",RU,[...wt[8]||(wt[8]=[c.createElementVNode("div",{class:"small-spinner"},null,-1),c.createElementVNode("p",null,"Loading gene expression...",-1)])])):c.createCommentVNode("",!0),c.createElementVNode("canvas",{ref_key:"rightCanvas",ref:s},null,512)]),Qt.value&&!ot.value?(c.openBlock(),c.createElementBlock("div",BU,[...wt[9]||(wt[9]=[c.createElementVNode("div",{class:"legend-title"},"Expression Level",-1),c.createElementVNode("div",{class:"gradient-bar"},[c.createElementVNode("div",{class:"gradient-fill"}),c.createElementVNode("div",{class:"gradient-labels"},[c.createElementVNode("span",null,"Low"),c.createElementVNode("span",null,"High")])],-1)])])):c.createCommentVNode("",!0)])])]))]))}},[["__scopeId","data-v-4785ac4d"]]),DU={class:"side-by-side-wrap"},FU=ea(c.defineComponent({inheritAttrs:!1,__name:"SideBySide",setup(e){const t=Vo(),n=up();return c.computed(()=>c.unref(t.s3Url)),(r,i)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(r.$slots,"default",{},void 0,!0),c.createElementVNode("div",DU,[c.createVNode(OU,{gene:c.unref(n).selectedGene??void 0,metadataColumn:c.unref(n).selectedMetadataColumn??void 0,"onUpdate:Vars":i[0]||(i[0]=(s,a)=>c.unref(n).setSelection(s,a)),"data-path":"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/humandrg/v2"},null,8,["gene","metadataColumn"])])],64))}}),[["__scopeId","data-v-4f3db12b"]]),LU={class:"violin-plot-container"},MU={key:0,class:"loading-container"},CU={key:1,class:"error-container"},kU={key:2,class:"dashboard"},UU={class:"content-layout"},PU={class:"controls"},$U={class:"label"},VU=["value"],zU={class:"label gene-expression-label"},GU={class:"gene-input-wrapper"},jU={id:"gene-suggestions"},YU=["value"],WU=["disabled"],HU={class:"label"},qU={class:"plot-type-toggle"},XU={class:"checkbox-label"},KU={class:"plot-container"},QU={key:0,class:"loading-overlay"},JU=ea({__name:"ViolinPlot",props:{dataPath:{type:String,default:"/data"},metadataColumn:{type:String,default:null},gene:{type:String,default:null}},emits:["update:Vars"],setup(e,{emit:t}){const n=e,r=t,i=c.ref(null),s=c.ref(null),a=c.ref(null),o=c.ref(!0),l=c.ref(null),u=c.ref(!1),d=c.ref([]),h=c.ref([]),y=c.ref(n.metadataColumn||""),S=c.ref("gene"),M=c.ref(n.gene||""),H=c.ref(n.gene||""),nt=c.ref([]),j=c.ref("violin"),$t=c.ref(!1),Ct=c.ref([]);let Zt=null;c.watch(()=>n.metadataColumn,m=>{m&&m!==y.value&&(y.value=m,d.value.length>0&&ge())}),c.watch(()=>n.gene,m=>{m&&m!==H.value&&(H.value=m,M.value=m,d.value.length>0&&ne())}),c.watch(y,m=>{m&&r("update:Vars","selectedMetadataColumn",m)}),c.watch(H,m=>{m&&r("update:Vars","selectedGene",m)}),c.watch(j,()=>{Ct.value.length>0&&(Qt(Ct.value),$t.value&&rt(Ct.value))});let Lt=null;const ie=()=>{clearTimeout(Lt),Lt=setTimeout(()=>{Ct.value.length>0&&(Qt(Ct.value),$t.value&&rt(Ct.value))},100)};c.onMounted(async()=>{window.addEventListener("resize",ie);try{a.value=new jm(n.dataPath),await a.value.initialize();const m=await a.value.getReductionData("umap");if(d.value=m,m.length>0){const T=m[0],p=Object.keys(T).filter(L=>!["cell_id","umap_1","umap_2","tsne_1","tsne_2"].includes(L));h.value=p,p.length>0&&(n.metadataColumn&&p.includes(n.metadataColumn)?y.value=n.metadataColumn:y.value||(y.value=p.includes("Atlas_annotation")?"Atlas_annotation":p[0]))}o.value=!1,await c.nextTick(),n.gene&&(H.value=n.gene,M.value=n.gene,S.value="gene",await ne())}catch(m){console.error("Failed to initialize:",m),l.value=`Failed to load data: ${m.message}`,o.value=!1}}),c.onBeforeUnmount(()=>{Zt&&clearTimeout(Zt),Lt&&clearTimeout(Lt),window.removeEventListener("resize",ie);const m=s.value;m&&m.getContext("2d").clearRect(0,0,m.width,m.height)});function xt(){clearTimeout(Zt),Zt=setTimeout(async()=>{if(M.value.length<2){nt.value=[];return}try{const m=await a.value.searchGenes(M.value);nt.value=m.map(T=>T.gene_name).slice(0,20)}catch(m){console.error("Gene search failed:",m)}},300)}async function on(){M.value.trim()&&(H.value=M.value.trim().toUpperCase(),await ne())}async function ge(){H.value&&await ne()}async function ne(){if(!(!H.value||!y.value))try{u.value=!0;const m=await a.value.getGeneExpression(H.value);u.value=!1;const T=new Map(m.map(C=>[C.cell_id,C.expression])),p=new Map;d.value.forEach(C=>{const R=C[y.value],U=T.get(C.cell_id)||0;p.has(R)||p.set(R,[]),p.get(R).push(U)});const L=Array.from(p.entries()).map(([C,R])=>({category:String(C),values:R}));Ct.value=L,await c.nextTick(),Qt(L),$t.value&&rt(L)}catch(m){console.error("Failed to render violin plot:",m),l.value=`Failed to load gene data: ${m.message}`,u.value=!1}}function Qt(m){const T=Pr(i.value);if(T.selectAll("*").remove(),!m||m.length===0)return;const L=T.node().parentElement.getBoundingClientRect(),C=L.width,R=L.height,U={top:40,right:40,bottom:80,left:80},tt=C-U.left-U.right,ht=R-U.top-U.bottom;T.attr("width",C).attr("height",R).attr("viewBox",null).attr("preserveAspectRatio",null);const ut=T.append("g").attr("transform",`translate(${U.left},${U.top})`),J=Pv().domain(m.map(pn=>pn.category)).range([0,tt]).padding(.2),Jt=m.flatMap(pn=>pn.values),re=na(Jt),Rt=cs().domain(re).range([ht,0]).nice(),fe=bc(zp);function En(pn,yn){return function(In){return yn.map(ir=>[ir,_R(In,sr=>pn(ir-sr))])}}function hn(pn){return function(yn){return Math.abs(yn/=pn)<=1?.75*(1-yn*yn)/pn:0}}m.forEach(pn=>{const yn=pn.category,In=pn.values.filter(tr=>tr!=null&&!isNaN(tr));if(In.length===0)return;const ir=In.slice().sort(oo),sr=vR(ir),qt=hp(ir,.25),et=hp(ir,.75),te=fp(ir),gn=Wu(ir),_n=J(yn)+J.bandwidth()/2;if(j.value==="violin"){const tr=lR(In),_=In.length,Qn=1.06*tr*Math.pow(_,-1/5),Ir=Rt.ticks(50),Ye=En(hn(Qn),Ir)(In),Zi=Wu(Ye,he=>he[1]),Tn=cs().domain([0,Zi]).range([0,J.bandwidth()/2]);T.property("__scales__",{xScale:J,yScale:Rt,margin:U,width:C,height:R});const di=xF().x0(he=>J(yn)+J.bandwidth()/2-Tn(he[1])).x1(he=>J(yn)+J.bandwidth()/2+Tn(he[1])).y(he=>Rt(he[0])).curve(RF);ut.append("path").datum(Ye).attr("d",di).attr("fill",fe(yn)).attr("opacity",.7).attr("stroke",fe(yn)).attr("stroke-width",1.5),ut.append("line").attr("x1",_n-5).attr("x2",_n+5).attr("y1",Rt(sr)).attr("y2",Rt(sr)).attr("stroke","white").attr("stroke-width",3),ut.append("rect").attr("x",_n-3).attr("y",Rt(et)).attr("width",6).attr("height",Rt(qt)-Rt(et)).attr("fill","white").attr("stroke","#333").attr("stroke-width",1)}else{const tr=Math.min(J.bandwidth()*.6,80),_=tr*.5;T.property("__scales__",{xScale:J,yScale:Rt,margin:U,width:C,height:R}),ut.append("line").attr("x1",_n).attr("x2",_n).attr("y1",Rt(te)).attr("y2",Rt(qt)).attr("stroke",fe(yn)).attr("stroke-width",2),ut.append("line").attr("x1",_n).attr("x2",_n).attr("y1",Rt(et)).attr("y2",Rt(gn)).attr("stroke",fe(yn)).attr("stroke-width",2),ut.append("line").attr("x1",_n-_/2).attr("x2",_n+_/2).attr("y1",Rt(te)).attr("y2",Rt(te)).attr("stroke",fe(yn)).attr("stroke-width",2),ut.append("line").attr("x1",_n-_/2).attr("x2",_n+_/2).attr("y1",Rt(gn)).attr("y2",Rt(gn)).attr("stroke",fe(yn)).attr("stroke-width",2),ut.append("rect").attr("x",_n-tr/2).attr("y",Rt(et)).attr("width",tr).attr("height",Rt(qt)-Rt(et)).attr("fill",fe(yn)).attr("opacity",.7).attr("stroke",fe(yn)).attr("stroke-width",2),ut.append("line").attr("x1",_n-tr/2).attr("x2",_n+tr/2).attr("y1",Rt(sr)).attr("y2",Rt(sr)).attr("stroke","white").attr("stroke-width",2.5)}}),ut.append("g").attr("transform",`translate(0,${ht})`).call(xR(J)).selectAll("text").attr("transform","rotate(-45)").style("text-anchor","end").style("font-size","12px"),ut.append("g").call(NR(Rt)).selectAll("text").style("font-size","12px"),ut.append("text").attr("x",tt/2).attr("y",ht+U.bottom-10).attr("text-anchor","middle").style("font-size","14px").style("font-weight","600").text(y.value);const Kn=`${H.value} Expression`;ut.append("text").attr("transform","rotate(-90)").attr("x",-ht/2).attr("y",-U.left+20).attr("text-anchor","middle").style("font-size","14px").style("font-weight","600").text(Kn),T.append("text").attr("x",C/2).attr("y",20).attr("text-anchor","middle").style("font-size","16px").style("font-weight","700").text(`Violin Plot: ${Kn} by ${y.value}`)}function rt(m){if(!m||m.length===0)return;const T=s.value;if(!T)return;const L=Pr(i.value).property("__scales__");if(!L){console.warn("Scales not found on SVG");return}const{xScale:C,yScale:R,margin:U,width:tt,height:ht}=L,ut=window.devicePixelRatio||1;T.width=tt*ut,T.height=ht*ut,T.style.width=`${tt}px`,T.style.height=`${ht}px`;const J=T.getContext("2d");J.scale(ut,ut),J.clearRect(0,0,tt,ht),J.save(),J.translate(U.left,U.top);const Jt=bc(zp);m.forEach(re=>{const Rt=re.category,fe=re.values.filter(pn=>pn!=null&&!isNaN(pn));if(fe.length===0)return;const En=C(Rt)+C.bandwidth()/2,hn=C.bandwidth()*.35,Kn=Jt(Rt);J.fillStyle=Kn,J.strokeStyle="white",J.lineWidth=.3,J.globalAlpha=.4,fe.forEach(pn=>{const yn=En+(Math.random()-.5)*hn,In=R(pn);J.beginPath(),J.arc(yn,In,1.5,0,Math.PI*2),J.fill(),J.stroke()})}),J.restore()}function ot(){if(Ct.value.length>0)if($t.value)rt(Ct.value);else{const m=s.value;m&&m.getContext("2d").clearRect(0,0,m.width,m.height)}}return(m,T)=>(c.openBlock(),c.createElementBlock("div",LU,[o.value?(c.openBlock(),c.createElementBlock("div",MU,[...T[5]||(T[5]=[c.createElementVNode("div",{class:"spinner"},null,-1),c.createElementVNode("p",{class:"loading-text"},"Loading data...",-1)])])):l.value?(c.openBlock(),c.createElementBlock("div",CU,[T[6]||(T[6]=c.createElementVNode("strong",null,"� Error:",-1)),c.createTextVNode(" "+c.toDisplayString(l.value),1)])):(c.openBlock(),c.createElementBlock("div",kU,[T[12]||(T[12]=c.createElementVNode("div",{class:"header"},[c.createElementVNode("h3",{class:"title"},"Gene Expression Distribution")],-1)),c.createElementVNode("div",UU,[c.createElementVNode("div",PU,[c.createElementVNode("label",$U,[T[7]||(T[7]=c.createTextVNode(" X-axis (Metadata): ",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":T[0]||(T[0]=p=>y.value=p),onChange:ge,class:"select"},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(h.value,p=>(c.openBlock(),c.createElementBlock("option",{key:p,value:p},c.toDisplayString(p),9,VU))),128))],544),[[c.vModelSelect,y.value]])]),c.createElementVNode("label",zU,[T[8]||(T[8]=c.createTextVNode(" Gene Expression ",-1)),c.createElementVNode("div",GU,[c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":T[1]||(T[1]=p=>M.value=p),type:"text",placeholder:"Enter gene name (e.g., CDH9)",class:"gene-input",list:"gene-suggestions",onInput:xt},null,544),[[c.vModelText,M.value]]),c.createElementVNode("datalist",jU,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(nt.value,p=>(c.openBlock(),c.createElementBlock("option",{key:p,value:p},null,8,YU))),128))]),c.createElementVNode("button",{onClick:on,disabled:!M.value.trim()||u.value,class:"visualize-btn"},c.toDisplayString(u.value?"Loading...":"Visualize"),9,WU)])]),c.createElementVNode("label",HU,[T[9]||(T[9]=c.createTextVNode(" Plot Type: ",-1)),c.createElementVNode("div",qU,[c.createElementVNode("button",{onClick:T[2]||(T[2]=p=>j.value="violin"),class:c.normalizeClass([{active:j.value==="violin"},"toggle-btn"])}," Violin ",2),c.createElementVNode("button",{onClick:T[3]||(T[3]=p=>j.value="box"),class:c.normalizeClass([{active:j.value==="box"},"toggle-btn"])}," Box ",2)])]),c.createElementVNode("label",XU,[c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":T[4]||(T[4]=p=>$t.value=p),type:"checkbox",class:"checkbox",onChange:ot},null,544),[[c.vModelCheckbox,$t.value]]),T[10]||(T[10]=c.createTextVNode(" Show data points ",-1))])]),c.createElementVNode("div",KU,[u.value?(c.openBlock(),c.createElementBlock("div",QU,[...T[11]||(T[11]=[c.createElementVNode("div",{class:"small-spinner"},null,-1),c.createElementVNode("p",null,"Loading data...",-1)])])):c.createCommentVNode("",!0),(c.openBlock(),c.createElementBlock("svg",{ref_key:"violinSvg",ref:i,class:"violin-svg"},null,512)),c.createElementVNode("canvas",{ref_key:"dataPointsCanvas",ref:s,class:"data-points-canvas"},null,512)])])]))]))}},[["__scopeId","data-v-ad8f4896"]]),ZU={class:"gene-x-expression-wrap"},t3=ea(c.defineComponent({inheritAttrs:!1,__name:"GeneXDistribution",setup(e){const t=Vo(),n=up();c.computed(()=>c.unref(t.s3Url));function r(i,s){i==="selectedGene"?n.setSelection("selectedGeneX",s):n.setSelection(i,s)}return(i,s)=>(c.openBlock(),c.createElementBlock(c.Fragment,null,[c.renderSlot(i.$slots,"default",{},void 0,!0),c.createElementVNode("div",ZU,[c.createVNode(JU,{gene:c.unref(n).selectedGeneX??void 0,metadataColumn:c.unref(n).selectedMetadataColumn??void 0,"onUpdate:Vars":r,"data-path":"https://temp-precision-dashboard-data.s3.us-east-1.amazonaws.com/humandrg/v2"},null,8,["gene","metadataColumn"])])],64))}}),[["__scopeId","data-v-89106955"]]);function je(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(d){try{u(r.next(d))}catch(h){a(h)}}function l(d){try{u(r.throw(d))}catch(h){a(h)}}function u(d){d.done?s(d.value):i(d.value).then(o,l)}u((r=r.apply(e,t||[])).next())})}function Rw(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Je(e){return this instanceof Je?(this.v=e,this):new Je(e)}function Ms(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(S){return function(M){return Promise.resolve(M).then(S,h)}}function o(S,M){r[S]&&(i[S]=function(H){return new Promise(function(nt,j){s.push([S,H,nt,j])>1||l(S,H)})},M&&(i[S]=M(i[S])))}function l(S,M){try{u(r[S](M))}catch(H){y(s[0][3],H)}}function u(S){S.value instanceof Je?Promise.resolve(S.value.v).then(d,h):y(s[0][2],S)}function d(S){l("next",S)}function h(S){l("throw",S)}function y(S,M){S(M),s.shift(),s.length&&l(s[0][0],s[0][1])}}function df(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:Je(e[i](a)),done:!1}:s?s(a):a}:s}}function bo(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Rw=="function"?Rw(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(u){s({value:u,done:o})},a)}}const e3=new TextDecoder("utf-8"),Ym=e=>e3.decode(e),n3=new TextEncoder,Wm=e=>n3.encode(e),r3=e=>typeof e=="number",Bw=e=>typeof e=="boolean",Dr=e=>typeof e=="function",Si=e=>e!=null&&Object(e)===e,wo=e=>Si(e)&&Dr(e.then),Mc=e=>Si(e)&&Dr(e[Symbol.iterator]),dl=e=>Si(e)&&Dr(e[Symbol.asyncIterator]),Hm=e=>Si(e)&&Si(e.schema),Ow=e=>Si(e)&&"done"in e&&"value"in e,Dw=e=>Si(e)&&Dr(e.stat)&&r3(e.fd),Fw=e=>Si(e)&&qm(e.body),ff=e=>"_getDOMStream"in e&&"_getNodeStream"in e,i3=e=>Si(e)&&Dr(e.abort)&&Dr(e.getWriter)&&!ff(e),qm=e=>Si(e)&&Dr(e.cancel)&&Dr(e.getReader)&&!ff(e),s3=e=>Si(e)&&Dr(e.end)&&Dr(e.write)&&Bw(e.writable)&&!ff(e),Lw=e=>Si(e)&&Dr(e.read)&&Dr(e.pipe)&&Bw(e.readable)&&!ff(e),a3=e=>Si(e)&&Dr(e.clear)&&Dr(e.bytes)&&Dr(e.position)&&Dr(e.setPosition)&&Dr(e.capacity)&&Dr(e.getBufferIdentifier)&&Dr(e.createLong),Xm=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function o3(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,u=0,d=e.length;++l<d;){if(a=t[u],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++u]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++u]=o);continue}t[u]=new Uint8Array(a.buffer,n,r-n+s)}return t}function Mw(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function Cs(e,t){const n=o3(e),r=n.reduce((d,h)=>d+h.byteLength,0);let i,s,a,o=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=n.length;++l<d;){if(i=n[l],s=i.subarray(0,Math.min(i.length,u-o)),u<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?Mw(a,s,o):a=s;break}Mw(a||(a=new Uint8Array(u)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function qn(e,t){let n=Ow(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Wm(n)),n instanceof ArrayBuffer?new e(n):n instanceof Xm?new e(n):a3(n)?qn(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const Cc=e=>qn(Int32Array,e),Cw=e=>qn(BigInt64Array,e),dn=e=>qn(Uint8Array,e),Km=e=>(e.next(),e);function*l3(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Xm?n(t):Mc(t)?t:n(t);return yield*Km((function*(i){let s=null;do s=i.next(yield qn(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const c3=e=>l3(Uint8Array,e);function kw(e,t){return Ms(this,arguments,function*(){if(wo(t))return yield Je(yield Je(yield*df(bo(kw(e,yield Je(t))))));const n=function(s){return Ms(this,arguments,function*(){yield yield Je(yield Je(s))})},r=function(s){return Ms(this,arguments,function*(){yield Je(yield*df(bo(Km((function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)})(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Xm?n(t):Mc(t)?r(t):dl(t)?t:n(t);return yield Je(yield*df(bo(Km((function(s){return Ms(this,arguments,function*(){let a=null;do a=yield Je(s.next(yield yield Je(qn(e,a))));while(!a.done)})})(i[Symbol.asyncIterator]()))))),yield Je(new e)})}const u3=e=>kw(Uint8Array,e);function Uw(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function d3(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const Yi={fromIterable(e){return hf(f3(e))},fromAsyncIterable(e){return hf(h3(e))},fromDOMStream(e){return hf(p3(e))},fromNodeStream(e){return hf(y3(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},hf=e=>(e.next(),e);function*f3(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Cs(r,a)[0]:([i,r,o]=Cs(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const u=c3(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?u.next():u.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(d){(n=!0)&&typeof u.throw=="function"&&u.throw(d)}finally{n===!1&&typeof u.return=="function"&&u.return(null)}return null}function h3(e){return Ms(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Cs(r,a)[0]:([i,r,o]=Cs(r,a),i)}({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0});const u=u3(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield Je(u.next()):yield Je(u.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield Je(l()));while(a<o);while(!t)}catch(d){(n=!0)&&typeof u.throw=="function"&&(yield Je(u.throw(d)))}finally{n===!1&&typeof u.return=="function"&&(yield Je(u.return(new Uint8Array(0))))}return yield Je(null)})}function p3(e){return Ms(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?Cs(r,a)[0]:([i,r,o]=Cs(r,a),i)}({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0});const u=new m3(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield Je(u.read()):yield Je(u.read(a-o)),!t&&i.byteLength>0&&(r.push(dn(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield Je(l()));while(a<o);while(!t)}catch(d){(n=!0)&&(yield Je(u.cancel(d)))}finally{n===!1?yield Je(u.cancel()):e.locked&&u.releaseLock()}return yield Je(null)})}class m3{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return je(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return je(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=dn(n)),n})}}const Qm=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function y3(e){return Ms(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],u;function d(){return s==="peek"?Cs(l,a)[0]:([u,l,o]=Cs(l,a),u)}if({cmd:s,size:a}=(yield yield Je(null))||{cmd:"read",size:0},e.isTTY)return yield yield Je(new Uint8Array(0)),yield Je(null);try{t[0]=Qm(e,"end"),t[1]=Qm(e,"error");do{if(t[2]=Qm(e,"readable"),[n,i]=yield Je(Promise.race(t.map(y=>y[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(u=dn(e.read(a-o)),u.byteLength<a-o&&(u=dn(e.read()))):u=dn(e.read()),u.byteLength>0&&(l.push(u),o+=u.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield Je(d()));while(a<o)}while(!r)}finally{yield Je(h(t,n==="error"?i:null))}return yield Je(null);function h(y,S){return u=l=null,new Promise((M,H)=>{for(const[nt,j]of y)e.off(nt,j);try{const nt=e.destroy;nt&&nt.call(e,S),S=void 0}catch(nt){S=nt||S}finally{S!=null?H(S):M()}})}})}var Er;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(Er||(Er={}));var Kr;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Kr||(Kr={}));var Qr;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Qr||(Qr={}));var Wi;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Wi||(Wi={}));var Oe;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(Oe||(Oe={}));var ks;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(ks||(ks={}));const Jm=2,Us=4,pa=4,Dn=4,Pa=new Int32Array(2),Pw=new Float32Array(Pa.buffer),$w=new Float64Array(Pa.buffer),pf=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Zm;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Zm||(Zm={}));let fl=class hT{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new hT(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Pa[0]=this.readInt32(t),Pw[0]}readFloat64(t){return Pa[pf?0:1]=this.readInt32(t),Pa[pf?1:0]=this.readInt32(t+4),$w[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){Pw[0]=n,this.writeInt32(t,Pa[0])}writeFloat64(t,n){$w[0]=n,this.writeInt32(t,Pa[pf?0:1]),this.writeInt32(t+4,Pa[pf?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+Us+pa)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<pa;n++)t+=String.fromCharCode(this.readInt8(this.position_+Us+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=Us;const i=this.bytes_.subarray(t,t+r);return n===Zm.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+Us}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=pa)throw new Error("FlatBuffers: file identifier must be length "+pa);for(let n=0;n<pa;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+Us+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},Vw=class pT{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=fl.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=pT.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=fl.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(Us,0),this.writeInt32(this.offset()-t+Us)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*Jm;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let u=Jm;u<s;u+=Jm)if(this.bb.readInt16(o+u)!=this.bb.readInt16(l+u))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?Dn:0;if(n){const s=n;if(this.prep(this.minalign,Us+pa+i),s.length!=pa)throw new TypeError("FlatBuffers: file identifier must be length "+pa);for(let a=pa-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,Us+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(Us,t*n),this.prep(r,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var mf;(function(e){e[e.BUFFER=0]="BUFFER"})(mf||(mf={}));var yf;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(yf||(yf={}));class $a{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new $a).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Dn),(n||new $a).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):yf.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):mf.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,yf.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,mf.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return $a.startBodyCompression(t),$a.addCodec(t,n),$a.addMethod(t,r),$a.endBodyCompression(t)}}class zw{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Gw=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},ma=class zg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new zg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Dn),(n||new zg).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Gw).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new zw).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new $a).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},hl=class Gg{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new Gg).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Dn),(n||new Gg).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new ma).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var pl;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(pl||(pl={}));var gf;(function(e){e[e.DenseArray=0]="DenseArray"})(gf||(gf={}));class Fi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Fi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Dn),(n||new Fi).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Fi.startInt(t),Fi.addBitWidth(t,n),Fi.addIsSigned(t,r),Fi.endInt(t)}}class ya{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new ya).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Dn),(n||new ya).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Fi).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):gf.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,gf.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Fr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new Fr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Dn),(n||new Fr).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return Fr.startKeyValue(t),Fr.addKey(t,n),Fr.addValue(t,r),Fr.endKeyValue(t)}}let jw=class vu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new vu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Dn),(n||new vu).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return vu.startBinary(t),vu.endBinary(t)}},Yw=class bu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new bu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Dn),(n||new bu).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return bu.startBool(t),bu.endBool(t)}},_f=class Xl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new Xl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Dn),(n||new Xl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Wi.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Wi.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return Xl.startDate(t),Xl.addUnit(t,n),Xl.endDate(t)}},ml=class to{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new to).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Dn),(n||new to).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return to.startDecimal(t),to.addPrecision(t,n),to.addScale(t,r),to.addBitWidth(t,i),to.endDecimal(t)}},vf=class Kl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new Kl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Dn),(n||new Kl).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Oe.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Oe.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Kl.startDuration(t),Kl.addUnit(t,n),Kl.endDuration(t)}},bf=class Ql{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new Ql).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Dn),(n||new Ql).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return Ql.startFixedSizeBinary(t),Ql.addByteWidth(t,n),Ql.endFixedSizeBinary(t)}},wf=class Jl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new Jl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Dn),(n||new Jl).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return Jl.startFixedSizeList(t),Jl.addListSize(t,n),Jl.endFixedSizeList(t)}};class Ps{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new Ps).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Dn),(n||new Ps).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Qr.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Qr.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return Ps.startFloatingPoint(t),Ps.addPrecision(t,n),Ps.endFloatingPoint(t)}}class $s{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new $s).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Dn),(n||new $s).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):ks.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,ks.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return $s.startInterval(t),$s.addUnit(t,n),$s.endInterval(t)}}let Ww=class wu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new wu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Dn),(n||new wu).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return wu.startLargeBinary(t),wu.endLargeBinary(t)}},Hw=class Su{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new Su).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Dn),(n||new Su).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return Su.startLargeUtf8(t),Su.endLargeUtf8(t)}},qw=class Eu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new Eu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Dn),(n||new Eu).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Eu.startList(t),Eu.endList(t)}},Sf=class Zl{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new Zl).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Dn),(n||new Zl).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return Zl.startMap(t),Zl.addKeysSorted(t,n),Zl.endMap(t)}},Xw=class Iu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new Iu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Dn),(n||new Iu).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Iu.startNull(t),Iu.endNull(t)}};class So{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new So).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Dn),(n||new So).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return So.startStruct_(t),So.endStruct_(t)}}class Hi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new Hi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Dn),(n||new Hi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Oe.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Oe.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return Hi.startTime(t),Hi.addUnit(t,n),Hi.addBitWidth(t,r),Hi.endTime(t)}}class qi{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new qi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Dn),(n||new qi).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Oe.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,Oe.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return qi.startTimestamp(t),qi.addUnit(t,n),qi.addTimezone(t,r),qi.endTimestamp(t)}}class Ei{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new Ei).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Dn),(n||new Ei).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Kr.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Kr.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return Ei.startUnion(t),Ei.addMode(t,n),Ei.addTypeIds(t,r),Ei.endUnion(t)}}let Kw=class Tu{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new Tu).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Dn),(n||new Tu).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Tu.startUtf8(t),Tu.endUtf8(t)}};var Zn;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(Zn||(Zn={}));let Xi=class Ph{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new Ph).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Dn),(n||new Ph).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Zn.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new ya).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Ph).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new Fr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,Zn.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},Vs=class Ra{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Ra).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Dn),(n||new Ra).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):pl.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Xi).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Fr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,pl.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Ra.startSchema(t),Ra.addEndianness(t,n),Ra.addFields(t,r),Ra.addCustomMetadata(t,i),Ra.addFeatures(t,s),Ra.endSchema(t)}};var wn;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(wn||(wn={}));var F;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(F||(F={}));var ga;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(ga||(ga={}));const g3=void 0;function kc(e){if(e===null)return"null";if(e===g3)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>kc(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function Xn(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function Qw(e,t){return Xn(e/t)+Xn(e%t)/Xn(t)}const _3=Symbol.for("isArrowBigNum");function hs(e,...t){return t.length===0?Object.setPrototypeOf(qn(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}hs.prototype[_3]=!0,hs.prototype.toJSON=function(){return`"${Pc(this)}"`},hs.prototype.valueOf=function(e){return Jw(this,e)},hs.prototype.toString=function(){return Pc(this)},hs.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Jw(this);case"string":return Pc(this);case"default":return w3(this)}return Pc(this)};function yl(...e){return hs.apply(this,e)}function gl(...e){return hs.apply(this,e)}function Uc(...e){return hs.apply(this,e)}Object.setPrototypeOf(yl.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(gl.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Uc.prototype,Object.create(Uint32Array.prototype)),Object.assign(yl.prototype,hs.prototype,{constructor:yl,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(gl.prototype,hs.prototype,{constructor:gl,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Uc.prototype,hs.prototype,{constructor:Uc,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const v3=BigInt(4294967296)*BigInt(4294967296),b3=v3-BigInt(1);function Jw(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),u=0;if(o){for(const d of a)l|=(d^b3)*(BigInt(1)<<BigInt(64*u++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*u++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),h=l/d,y=l%d;return Xn(h)+Xn(y)/Xn(d)}return Xn(l)}function Pc(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return ty(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ty(e);t=t.slice();let n=1;for(let r=0;r<t.length;r++){const i=t[r],s=~i+n;t[r]=s,n&=i===0?1:0}return`-${ty(t)}`}function w3(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Pc(e)}function ty(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class ey{static new(t,n){switch(n){case!0:return new yl(t);case!1:return new gl(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new yl(t)}return t.byteLength===16?new Uc(t):new gl(t)}static signed(t){return new yl(t)}static unsigned(t){return new gl(t)}static decimal(t){return new Uc(t)}constructor(t,n){return ey.new(t,n)}}var Zw,t1,e1,n1,r1,i1,s1,a1,o1,l1,c1,u1,d1,f1,h1,p1,m1,y1,g1,_1,v1,b1;class ue{static isNull(t){return(t==null?void 0:t.typeId)===F.Null}static isInt(t){return(t==null?void 0:t.typeId)===F.Int}static isFloat(t){return(t==null?void 0:t.typeId)===F.Float}static isBinary(t){return(t==null?void 0:t.typeId)===F.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===F.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===F.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===F.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===F.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===F.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===F.Date}static isTime(t){return(t==null?void 0:t.typeId)===F.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===F.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===F.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===F.Duration}static isList(t){return(t==null?void 0:t.typeId)===F.List}static isStruct(t){return(t==null?void 0:t.typeId)===F.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===F.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===F.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===F.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===F.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===F.Dictionary}static isDenseUnion(t){return ue.isUnion(t)&&t.mode===Kr.Dense}static isSparseUnion(t){return ue.isUnion(t)&&t.mode===Kr.Sparse}constructor(t){this.typeId=t}}Zw=Symbol.toStringTag,ue[Zw]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(ue.prototype);class Va extends ue{constructor(){super(F.Null)}toString(){return"Null"}}t1=Symbol.toStringTag,Va[t1]=(e=>e[Symbol.toStringTag]="Null")(Va.prototype);class Eo extends ue{constructor(t,n){super(F.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}e1=Symbol.toStringTag,Eo[e1]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(Eo.prototype);class $c extends Eo{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty($c.prototype,"ArrayType",{value:Int32Array});class Ef extends ue{constructor(t){super(F.Float),this.precision=t}get ArrayType(){switch(this.precision){case Qr.HALF:return Uint16Array;case Qr.SINGLE:return Float32Array;case Qr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}n1=Symbol.toStringTag,Ef[n1]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(Ef.prototype);class If extends ue{constructor(){super(F.Binary)}toString(){return"Binary"}}r1=Symbol.toStringTag,If[r1]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(If.prototype);class Tf extends ue{constructor(){super(F.LargeBinary)}toString(){return"LargeBinary"}}i1=Symbol.toStringTag,Tf[i1]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Tf.prototype);class Af extends ue{constructor(){super(F.Utf8)}toString(){return"Utf8"}}s1=Symbol.toStringTag,Af[s1]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Af.prototype);class xf extends ue{constructor(){super(F.LargeUtf8)}toString(){return"LargeUtf8"}}a1=Symbol.toStringTag,xf[a1]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(xf.prototype);class Nf extends ue{constructor(){super(F.Bool)}toString(){return"Bool"}}o1=Symbol.toStringTag,Nf[o1]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Nf.prototype);class Rf extends ue{constructor(t,n,r=128){super(F.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}l1=Symbol.toStringTag,Rf[l1]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Rf.prototype);class Bf extends ue{constructor(t){super(F.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Wi[this.unit]}>`}get ArrayType(){return this.unit===Wi.DAY?Int32Array:BigInt64Array}}c1=Symbol.toStringTag,Bf[c1]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(Bf.prototype);class Of extends ue{constructor(t,n){super(F.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${Oe[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}u1=Symbol.toStringTag,Of[u1]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(Of.prototype);class Df extends ue{constructor(t,n){super(F.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${Oe[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}d1=Symbol.toStringTag,Df[d1]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Df.prototype);class Ff extends ue{constructor(t){super(F.Interval),this.unit=t}toString(){return`Interval<${ks[this.unit]}>`}}f1=Symbol.toStringTag,Ff[f1]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Ff.prototype);class Lf extends ue{constructor(t){super(F.Duration),this.unit=t}toString(){return`Duration<${Oe[this.unit]}>`}}h1=Symbol.toStringTag,Lf[h1]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(Lf.prototype);class Mf extends ue{constructor(t){super(F.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}p1=Symbol.toStringTag,Mf[p1]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Mf.prototype);class oi extends ue{constructor(t){super(F.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}m1=Symbol.toStringTag,oi[m1]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(oi.prototype);class Cf extends ue{constructor(t,n,r){super(F.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}y1=Symbol.toStringTag,Cf[y1]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Cf.prototype);class kf extends ue{constructor(t){super(F.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}g1=Symbol.toStringTag,kf[g1]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(kf.prototype);class Uf extends ue{constructor(t,n){super(F.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}_1=Symbol.toStringTag,Uf[_1]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Uf.prototype);class Pf extends ue{constructor(t,n=!1){var r,i,s;if(super(F.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}v1=Symbol.toStringTag,Pf[v1]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Pf.prototype);const S3=(e=>()=>++e)(-1);class _l extends ue{constructor(t,n,r,i){super(F.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?S3():Xn(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}b1=Symbol.toStringTag,_l[b1]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(_l.prototype);function _a(e){const t=e;switch(e.typeId){case F.Decimal:return e.bitWidth/32;case F.Interval:return 1+t.unit;case F.FixedSizeList:return t.listSize;case F.FixedSizeBinary:return t.byteWidth;default:return 1}}class en{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return E3(this,t,n)}getVisitFnByTypeId(t,n=!0){return vl(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function E3(e,t,n=!0){return typeof t=="number"?vl(e,t,n):typeof t=="string"&&t in F?vl(e,F[t],n):t&&t instanceof ue?vl(e,w1(t),n):t!=null&&t.type&&t.type instanceof ue?vl(e,w1(t.type),n):vl(e,F.NONE,n)}function vl(e,t,n=!0){let r=null;switch(t){case F.Null:r=e.visitNull;break;case F.Bool:r=e.visitBool;break;case F.Int:r=e.visitInt;break;case F.Int8:r=e.visitInt8||e.visitInt;break;case F.Int16:r=e.visitInt16||e.visitInt;break;case F.Int32:r=e.visitInt32||e.visitInt;break;case F.Int64:r=e.visitInt64||e.visitInt;break;case F.Uint8:r=e.visitUint8||e.visitInt;break;case F.Uint16:r=e.visitUint16||e.visitInt;break;case F.Uint32:r=e.visitUint32||e.visitInt;break;case F.Uint64:r=e.visitUint64||e.visitInt;break;case F.Float:r=e.visitFloat;break;case F.Float16:r=e.visitFloat16||e.visitFloat;break;case F.Float32:r=e.visitFloat32||e.visitFloat;break;case F.Float64:r=e.visitFloat64||e.visitFloat;break;case F.Utf8:r=e.visitUtf8;break;case F.LargeUtf8:r=e.visitLargeUtf8;break;case F.Binary:r=e.visitBinary;break;case F.LargeBinary:r=e.visitLargeBinary;break;case F.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case F.Date:r=e.visitDate;break;case F.DateDay:r=e.visitDateDay||e.visitDate;break;case F.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case F.Timestamp:r=e.visitTimestamp;break;case F.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case F.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case F.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case F.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case F.Time:r=e.visitTime;break;case F.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case F.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case F.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case F.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case F.Decimal:r=e.visitDecimal;break;case F.List:r=e.visitList;break;case F.Struct:r=e.visitStruct;break;case F.Union:r=e.visitUnion;break;case F.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case F.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case F.Dictionary:r=e.visitDictionary;break;case F.Interval:r=e.visitInterval;break;case F.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case F.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case F.Duration:r=e.visitDuration;break;case F.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case F.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case F.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case F.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case F.FixedSizeList:r=e.visitFixedSizeList;break;case F.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${F[t]}'`)}function w1(e){switch(e.typeId){case F.Null:return F.Null;case F.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?F.Int8:F.Uint8;case 16:return n?F.Int16:F.Uint16;case 32:return n?F.Int32:F.Uint32;case 64:return n?F.Int64:F.Uint64}return F.Int}case F.Float:switch(e.precision){case Qr.HALF:return F.Float16;case Qr.SINGLE:return F.Float32;case Qr.DOUBLE:return F.Float64}return F.Float;case F.Binary:return F.Binary;case F.LargeBinary:return F.LargeBinary;case F.Utf8:return F.Utf8;case F.LargeUtf8:return F.LargeUtf8;case F.Bool:return F.Bool;case F.Decimal:return F.Decimal;case F.Time:switch(e.unit){case Oe.SECOND:return F.TimeSecond;case Oe.MILLISECOND:return F.TimeMillisecond;case Oe.MICROSECOND:return F.TimeMicrosecond;case Oe.NANOSECOND:return F.TimeNanosecond}return F.Time;case F.Timestamp:switch(e.unit){case Oe.SECOND:return F.TimestampSecond;case Oe.MILLISECOND:return F.TimestampMillisecond;case Oe.MICROSECOND:return F.TimestampMicrosecond;case Oe.NANOSECOND:return F.TimestampNanosecond}return F.Timestamp;case F.Date:switch(e.unit){case Wi.DAY:return F.DateDay;case Wi.MILLISECOND:return F.DateMillisecond}return F.Date;case F.Interval:switch(e.unit){case ks.DAY_TIME:return F.IntervalDayTime;case ks.YEAR_MONTH:return F.IntervalYearMonth}return F.Interval;case F.Duration:switch(e.unit){case Oe.SECOND:return F.DurationSecond;case Oe.MILLISECOND:return F.DurationMillisecond;case Oe.MICROSECOND:return F.DurationMicrosecond;case Oe.NANOSECOND:return F.DurationNanosecond}return F.Duration;case F.Map:return F.Map;case F.List:return F.List;case F.Struct:return F.Struct;case F.Union:switch(e.mode){case Kr.Dense:return F.DenseUnion;case Kr.Sparse:return F.SparseUnion}return F.Union;case F.FixedSizeBinary:return F.FixedSizeBinary;case F.FixedSizeList:return F.FixedSizeList;case F.Dictionary:return F.Dictionary}throw new Error(`Unrecognized type '${F[e.typeId]}'`)}en.prototype.visitInt8=null,en.prototype.visitInt16=null,en.prototype.visitInt32=null,en.prototype.visitInt64=null,en.prototype.visitUint8=null,en.prototype.visitUint16=null,en.prototype.visitUint32=null,en.prototype.visitUint64=null,en.prototype.visitFloat16=null,en.prototype.visitFloat32=null,en.prototype.visitFloat64=null,en.prototype.visitDateDay=null,en.prototype.visitDateMillisecond=null,en.prototype.visitTimestampSecond=null,en.prototype.visitTimestampMillisecond=null,en.prototype.visitTimestampMicrosecond=null,en.prototype.visitTimestampNanosecond=null,en.prototype.visitTimeSecond=null,en.prototype.visitTimeMillisecond=null,en.prototype.visitTimeMicrosecond=null,en.prototype.visitTimeNanosecond=null,en.prototype.visitDenseUnion=null,en.prototype.visitSparseUnion=null,en.prototype.visitIntervalDayTime=null,en.prototype.visitIntervalYearMonth=null,en.prototype.visitDuration=null,en.prototype.visitDurationSecond=null,en.prototype.visitDurationMillisecond=null,en.prototype.visitDurationMicrosecond=null,en.prototype.visitDurationNanosecond=null;const S1=new Float64Array(1),bl=new Uint32Array(S1.buffer);function E1(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function I3(e){if(e!==e)return 32256;S1[0]=e;const t=(bl[1]&2147483648)>>16&65535;let n=bl[1]&2146435072,r=0;return n>=1089470464?bl[0]>0?n=31744:(n=(n&2080374784)>>16,r=(bl[1]&1048575)>>10):n<=1056964608?(r=1048576+(bl[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(bl[1]&1048575)+512>>10),t|n|r&65535}class De extends en{}function Pe(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const T3=(e,t,n)=>{e[t]=Math.floor(n/864e5)},I1=(e,t,n,r)=>{if(n+1<t.length){const i=Xn(t[n]),s=Xn(t[n+1]);e.set(r.subarray(0,s-i),i)}},A3=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},va=({values:e},t,n)=>{e[t]=n},ny=({values:e},t,n)=>{e[t]=n},T1=({values:e},t,n)=>{e[t]=I3(n)},x3=(e,t,n)=>{switch(e.type.precision){case Qr.HALF:return T1(e,t,n);case Qr.SINGLE:case Qr.DOUBLE:return ny(e,t,n)}},A1=({values:e},t,n)=>{T3(e,t,n.valueOf())},x1=({values:e},t,n)=>{e[t]=BigInt(n)},N3=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},N1=({values:e,valueOffsets:t},n,r)=>I1(e,t,n,r),R1=({values:e,valueOffsets:t},n,r)=>I1(e,t,n,Wm(r)),R3=(e,t,n)=>{e.type.unit===Wi.DAY?A1(e,t,n):x1(e,t,n)},B1=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},O1=({values:e},t,n)=>{e[t]=BigInt(n)},D1=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},F1=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},B3=(e,t,n)=>{switch(e.type.unit){case Oe.SECOND:return B1(e,t,n);case Oe.MILLISECOND:return O1(e,t,n);case Oe.MICROSECOND:return D1(e,t,n);case Oe.NANOSECOND:return F1(e,t,n)}},L1=({values:e},t,n)=>{e[t]=n},M1=({values:e},t,n)=>{e[t]=n},C1=({values:e},t,n)=>{e[t]=n},k1=({values:e},t,n)=>{e[t]=n},O3=(e,t,n)=>{switch(e.type.unit){case Oe.SECOND:return L1(e,t,n);case Oe.MILLISECOND:return M1(e,t,n);case Oe.MICROSECOND:return C1(e,t,n);case Oe.NANOSECOND:return k1(e,t,n)}},D3=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},F3=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Ki.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},L3=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Ki.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const u of l)if(s(r,a,u),++a>=o)break},M3=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),C3=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),k3=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),U3=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),P3=(e,t,n)=>{const r=e.type.children.map(s=>Ki.getVisitFn(s.type)),i=n instanceof Map?k3(t,n):n instanceof Fn?C3(t,n):Array.isArray(n)?M3(t,n):U3(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},$3=(e,t,n)=>{e.type.mode===Kr.Dense?U1(e,t,n):P1(e,t,n)},U1=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ki.visit(i,e.valueOffsets[t],n)},P1=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ki.visit(i,t,n)},V3=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},z3=(e,t,n)=>{e.type.unit===ks.DAY_TIME?$1(e,t,n):V1(e,t,n)},$1=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},V1=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},z1=({values:e},t,n)=>{e[t]=n},G1=({values:e},t,n)=>{e[t]=n},j1=({values:e},t,n)=>{e[t]=n},Y1=({values:e},t,n)=>{e[t]=n},G3=(e,t,n)=>{switch(e.type.unit){case Oe.SECOND:return z1(e,t,n);case Oe.MILLISECOND:return G1(e,t,n);case Oe.MICROSECOND:return j1(e,t,n);case Oe.NANOSECOND:return Y1(e,t,n)}},j3=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Ki.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};De.prototype.visitBool=Pe(A3),De.prototype.visitInt=Pe(va),De.prototype.visitInt8=Pe(va),De.prototype.visitInt16=Pe(va),De.prototype.visitInt32=Pe(va),De.prototype.visitInt64=Pe(va),De.prototype.visitUint8=Pe(va),De.prototype.visitUint16=Pe(va),De.prototype.visitUint32=Pe(va),De.prototype.visitUint64=Pe(va),De.prototype.visitFloat=Pe(x3),De.prototype.visitFloat16=Pe(T1),De.prototype.visitFloat32=Pe(ny),De.prototype.visitFloat64=Pe(ny),De.prototype.visitUtf8=Pe(R1),De.prototype.visitLargeUtf8=Pe(R1),De.prototype.visitBinary=Pe(N1),De.prototype.visitLargeBinary=Pe(N1),De.prototype.visitFixedSizeBinary=Pe(N3),De.prototype.visitDate=Pe(R3),De.prototype.visitDateDay=Pe(A1),De.prototype.visitDateMillisecond=Pe(x1),De.prototype.visitTimestamp=Pe(B3),De.prototype.visitTimestampSecond=Pe(B1),De.prototype.visitTimestampMillisecond=Pe(O1),De.prototype.visitTimestampMicrosecond=Pe(D1),De.prototype.visitTimestampNanosecond=Pe(F1),De.prototype.visitTime=Pe(O3),De.prototype.visitTimeSecond=Pe(L1),De.prototype.visitTimeMillisecond=Pe(M1),De.prototype.visitTimeMicrosecond=Pe(C1),De.prototype.visitTimeNanosecond=Pe(k1),De.prototype.visitDecimal=Pe(D3),De.prototype.visitList=Pe(F3),De.prototype.visitStruct=Pe(P3),De.prototype.visitUnion=Pe($3),De.prototype.visitDenseUnion=Pe(U1),De.prototype.visitSparseUnion=Pe(P1),De.prototype.visitDictionary=Pe(V3),De.prototype.visitInterval=Pe(z3),De.prototype.visitIntervalDayTime=Pe($1),De.prototype.visitIntervalYearMonth=Pe(V1),De.prototype.visitDuration=Pe(G3),De.prototype.visitDurationSecond=Pe(z1),De.prototype.visitDurationMillisecond=Pe(G1),De.prototype.visitDurationMicrosecond=Pe(j1),De.prototype.visitDurationNanosecond=Pe(Y1),De.prototype.visitFixedSizeList=Pe(j3),De.prototype.visitMap=Pe(L3);const Ki=new De,ps=Symbol.for("parent"),wl=Symbol.for("rowIndex");class ry{constructor(t,n){return this[ps]=t,this[wl]=n,new Proxy(this,new W3)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[wl],n=this[ps],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=Ii.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${kc(t)}: ${kc(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Y3(this[ps],this[wl])}}class Y3{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Ii.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(ry.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ps]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wl]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class W3{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ps].type.children.map(n=>n.name)}has(t,n){return t[ps].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ps].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[ps].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Ii.visit(t[ps].children[r],t[wl]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ps].type.children.findIndex(s=>s.name===n);return i!==-1?(Ki.visit(t[ps].children[i],t[wl],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class Ee extends en{}function Fe(e){return(t,n)=>t.getValid(n)?e(t,n):null}const H3=(e,t)=>864e5*e[t],q3=(e,t)=>null,W1=(e,t,n)=>{if(n+1>=t.length)return null;const r=Xn(t[n]),i=Xn(t[n+1]);return e.subarray(r,i)},X3=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},H1=({values:e},t)=>H3(e,t),q1=({values:e},t)=>Xn(e[t]),za=({stride:e,values:t},n)=>t[e*n],K3=({stride:e,values:t},n)=>E1(t[e*n]),X1=({values:e},t)=>e[t],Q3=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),K1=({values:e,valueOffsets:t},n)=>W1(e,t,n),Q1=({values:e,valueOffsets:t},n)=>{const r=W1(e,t,n);return r!==null?Ym(r):null},J3=({values:e},t)=>e[t],Z3=({type:e,values:t},n)=>e.precision!==Qr.HALF?t[n]:E1(t[n]),tP=(e,t)=>e.type.unit===Wi.DAY?H1(e,t):q1(e,t),J1=({values:e},t)=>1e3*Xn(e[t]),Z1=({values:e},t)=>Xn(e[t]),tS=({values:e},t)=>Qw(e[t],BigInt(1e3)),eS=({values:e},t)=>Qw(e[t],BigInt(1e6)),eP=(e,t)=>{switch(e.type.unit){case Oe.SECOND:return J1(e,t);case Oe.MILLISECOND:return Z1(e,t);case Oe.MICROSECOND:return tS(e,t);case Oe.NANOSECOND:return eS(e,t)}},nS=({values:e},t)=>e[t],rS=({values:e},t)=>e[t],iS=({values:e},t)=>e[t],sS=({values:e},t)=>e[t],nP=(e,t)=>{switch(e.type.unit){case Oe.SECOND:return nS(e,t);case Oe.MILLISECOND:return rS(e,t);case Oe.MICROSECOND:return iS(e,t);case Oe.NANOSECOND:return sS(e,t)}},rP=({values:e,stride:t},n)=>ey.decimal(e.subarray(t*n,t*(n+1))),iP=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,o=i[0].slice(s,a-s);return new Fn([o])},sP=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new sy(a.slice(i,s-i))},aP=(e,t)=>new ry(e,t),oP=(e,t)=>e.type.mode===Kr.Dense?aS(e,t):oS(e,t),aS=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Ii.visit(r,e.valueOffsets[t])},oS=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Ii.visit(r,t)},lP=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},cP=(e,t)=>e.type.unit===ks.DAY_TIME?lS(e,t):cS(e,t),lS=({values:e},t)=>e.subarray(2*t,2*(t+1)),cS=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},uS=({values:e},t)=>e[t],dS=({values:e},t)=>e[t],fS=({values:e},t)=>e[t],hS=({values:e},t)=>e[t],uP=(e,t)=>{switch(e.type.unit){case Oe.SECOND:return uS(e,t);case Oe.MILLISECOND:return dS(e,t);case Oe.MICROSECOND:return fS(e,t);case Oe.NANOSECOND:return hS(e,t)}},dP=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new Fn([i])};Ee.prototype.visitNull=Fe(q3),Ee.prototype.visitBool=Fe(X3),Ee.prototype.visitInt=Fe(J3),Ee.prototype.visitInt8=Fe(za),Ee.prototype.visitInt16=Fe(za),Ee.prototype.visitInt32=Fe(za),Ee.prototype.visitInt64=Fe(X1),Ee.prototype.visitUint8=Fe(za),Ee.prototype.visitUint16=Fe(za),Ee.prototype.visitUint32=Fe(za),Ee.prototype.visitUint64=Fe(X1),Ee.prototype.visitFloat=Fe(Z3),Ee.prototype.visitFloat16=Fe(K3),Ee.prototype.visitFloat32=Fe(za),Ee.prototype.visitFloat64=Fe(za),Ee.prototype.visitUtf8=Fe(Q1),Ee.prototype.visitLargeUtf8=Fe(Q1),Ee.prototype.visitBinary=Fe(K1),Ee.prototype.visitLargeBinary=Fe(K1),Ee.prototype.visitFixedSizeBinary=Fe(Q3),Ee.prototype.visitDate=Fe(tP),Ee.prototype.visitDateDay=Fe(H1),Ee.prototype.visitDateMillisecond=Fe(q1),Ee.prototype.visitTimestamp=Fe(eP),Ee.prototype.visitTimestampSecond=Fe(J1),Ee.prototype.visitTimestampMillisecond=Fe(Z1),Ee.prototype.visitTimestampMicrosecond=Fe(tS),Ee.prototype.visitTimestampNanosecond=Fe(eS),Ee.prototype.visitTime=Fe(nP),Ee.prototype.visitTimeSecond=Fe(nS),Ee.prototype.visitTimeMillisecond=Fe(rS),Ee.prototype.visitTimeMicrosecond=Fe(iS),Ee.prototype.visitTimeNanosecond=Fe(sS),Ee.prototype.visitDecimal=Fe(rP),Ee.prototype.visitList=Fe(iP),Ee.prototype.visitStruct=Fe(aP),Ee.prototype.visitUnion=Fe(oP),Ee.prototype.visitDenseUnion=Fe(aS),Ee.prototype.visitSparseUnion=Fe(oS),Ee.prototype.visitDictionary=Fe(lP),Ee.prototype.visitInterval=Fe(cP),Ee.prototype.visitIntervalDayTime=Fe(lS),Ee.prototype.visitIntervalYearMonth=Fe(cS),Ee.prototype.visitDuration=Fe(uP),Ee.prototype.visitDurationSecond=Fe(uS),Ee.prototype.visitDurationMillisecond=Fe(dS),Ee.prototype.visitDurationMicrosecond=Fe(fS),Ee.prototype.visitDurationNanosecond=Fe(hS),Ee.prototype.visitFixedSizeList=Fe(dP),Ee.prototype.visitMap=Fe(sP);const Ii=new Ee,Sl=Symbol.for("keys"),El=Symbol.for("vals"),Il=Symbol.for("kKeysAsStrings"),iy=Symbol.for("_kKeysAsStrings");class sy{constructor(t){return this[Sl]=new Fn([t.children[0]]).memoize(),this[El]=t.children[1],new Proxy(this,new hP)}get[Il](){return this[iy]||(this[iy]=Array.from(this[Sl].toArray(),String))}[Symbol.iterator](){return new fP(this[Sl],this[El])}get size(){return this[Sl].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Sl],n=this[El],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Ii.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${kc(t)}: ${kc(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class fP{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Ii.visit(this.vals,t)]})}}class hP{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Il]}has(t,n){return t[Il].includes(n)}getOwnPropertyDescriptor(t,n){if(t[Il].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[Il].indexOf(n);if(r!==-1){const i=Ii.visit(Reflect.get(t,El),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[Il].indexOf(n);return i!==-1?(Ki.visit(Reflect.get(t,El),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(sy.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Sl]:{writable:!0,enumerable:!1,configurable:!1,value:null},[El]:{writable:!0,enumerable:!1,configurable:!1,value:null},[iy]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let pS;function mS(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(pS=s,s=a,a=pS),a>i&&(a=i),r?r(e,s,a):[s,a]}const ay=(e,t)=>e<0?t+e:e,yS=e=>e!==e;function Tl(e){if(typeof e!="object"||e===null)return yS(e)?yS:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?d3(e,t):!1:e instanceof Map?mP(e):Array.isArray(e)?pP(e):e instanceof Fn?yP(e):gP(e,!0)}function pP(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Tl(e[n]);return $f(t)}function mP(e){let t=-1;const n=[];for(const r of e.values())n[++t]=Tl(r);return $f(n)}function yP(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Tl(e.get(n));return $f(t)}function gP(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=Tl(e[n[i]]);return $f(r,n)}function $f(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return _P(e,n);case Map:return gS(e,n,n.keys());case sy:case ry:case Object:case void 0:return gS(e,n,t||Object.keys(n))}return n instanceof Fn?vP(e,n):!1}}function _P(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function vP(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function gS(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),u=r.next(),d=i.next();for(;a<o&&!u.done&&!d.done&&!l.done&&!(u.value!==d.value||!e[a](l.value));++a,u=r.next(),d=i.next(),l=s.next());return a===o&&u.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function _S(e,t,n,r){return(n&1<<r)!==0}function bP(e,t,n,r){return(n&1<<r)>>r}function Vf(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):zf(new oy(n,e,t,null,_S)).subarray(0,r)),i}return n}function zf(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class oy{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function ly(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new oy(e,t,n-t,e,bP))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return ly(e,t,i)+ly(e,r,n)+wP(e,i>>3,r-i>>3)}function wP(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=cy(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=cy(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=cy(s.getUint8(i)),i+=1;return r}function cy(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const SP=-1;class $n{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return ue.isSparseUnion(t)?this.children.some(n=>n.nullable):ue.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(ue.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=SP&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-ly(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof $n?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=_a(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(ue.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Kr.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(ue.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Kr.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,u=1<<l%8,d=l>>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Vf(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[d];r=(h&u)!==0,s[d]=n?h|u:h&~u}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new $n(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===F.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Vf(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[ga.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[ga.TYPE])&&(a[ga.TYPE]=s.subarray(t,t+n)),(s=a[ga.OFFSET])&&(a[ga.OFFSET]=s.subarray(t,t+n+1))||(s=a[ga.DATA])&&(a[ga.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}$n.prototype.children=Object.freeze([]);class Vc extends en{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new $n(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.data),s=dn(t.nullBitmap),a=Cc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.data),s=dn(t.nullBitmap),a=Cw(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.data),s=dn(t.nullBitmap),a=Cc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.data),s=dn(t.nullBitmap),a=Cw(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=dn(t.nullBitmap),a=Cc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=dn(t.nullBitmap),{length:a=i.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=qn(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(ue.isSparseUnion(n))return new $n(n,r,a,o,[void 0,void 0,void 0,s],i);const l=Cc(t.valueOffsets);return new $n(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.indices.ArrayType,t.data),{["dictionary"]:a=new Fn([new Vc().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=dn(t.nullBitmap),s=qn(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Vc().visit({type:n.valueType})}=t,s=dn(t.nullBitmap),{["length"]:a=i.length/_a(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new $n(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Vc().visit({type:n.childType})}=t,s=dn(t.nullBitmap),a=Cc(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new $n(n,r,o,l,[a,void 0,s],[i])}}const EP=new Vc;function an(e){return EP.visit(e)}class vS{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function IP(e){return e.some(t=>t.nullable)}function bS(e){return e.reduce((t,n)=>t+n.nullCount,0)}function wS(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function SS(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:u}=o;if(l>=r)break;if(n>=l+u)continue;if(l>=n&&l+u<=r){i.push(o);continue}const d=Math.max(0,n-l),h=Math.min(r-l,u);i.push(o.slice(d,h-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function uy(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function dy(e,t){return e.getValid(t)}function Gf(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return uy(r,this._offsets,n,t)}}function ES(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=uy(s,this._offsets,r,n);return t=void 0,a}}function IS(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let u=i-1,d=r.length;++u<d;){const h=r[u];if(~(o=e(h,t,a)))return l+o;a=0,l+=h.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):uy(s,this._offsets,i,n);return t=void 0,a}}class Ie extends en{}function TP(e,t){return t===null&&e.length>0?0:-1}function AP(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new oy(n,e.offset+(t||0),e.length,n,_S)){if(!i)return r;++r}return-1}function ze(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case F.Union:break;case F.Dictionary:break;default:return AP(e,n)}const r=Ii.getVisitFn(e),i=Tl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function TS(e,t,n){const r=Ii.getVisitFn(e),i=Tl(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}Ie.prototype.visitNull=TP,Ie.prototype.visitBool=ze,Ie.prototype.visitInt=ze,Ie.prototype.visitInt8=ze,Ie.prototype.visitInt16=ze,Ie.prototype.visitInt32=ze,Ie.prototype.visitInt64=ze,Ie.prototype.visitUint8=ze,Ie.prototype.visitUint16=ze,Ie.prototype.visitUint32=ze,Ie.prototype.visitUint64=ze,Ie.prototype.visitFloat=ze,Ie.prototype.visitFloat16=ze,Ie.prototype.visitFloat32=ze,Ie.prototype.visitFloat64=ze,Ie.prototype.visitUtf8=ze,Ie.prototype.visitLargeUtf8=ze,Ie.prototype.visitBinary=ze,Ie.prototype.visitLargeBinary=ze,Ie.prototype.visitFixedSizeBinary=ze,Ie.prototype.visitDate=ze,Ie.prototype.visitDateDay=ze,Ie.prototype.visitDateMillisecond=ze,Ie.prototype.visitTimestamp=ze,Ie.prototype.visitTimestampSecond=ze,Ie.prototype.visitTimestampMillisecond=ze,Ie.prototype.visitTimestampMicrosecond=ze,Ie.prototype.visitTimestampNanosecond=ze,Ie.prototype.visitTime=ze,Ie.prototype.visitTimeSecond=ze,Ie.prototype.visitTimeMillisecond=ze,Ie.prototype.visitTimeMicrosecond=ze,Ie.prototype.visitTimeNanosecond=ze,Ie.prototype.visitDecimal=ze,Ie.prototype.visitList=ze,Ie.prototype.visitStruct=ze,Ie.prototype.visitUnion=ze,Ie.prototype.visitDenseUnion=TS,Ie.prototype.visitSparseUnion=TS,Ie.prototype.visitDictionary=ze,Ie.prototype.visitInterval=ze,Ie.prototype.visitIntervalDayTime=ze,Ie.prototype.visitIntervalYearMonth=ze,Ie.prototype.visitDuration=ze,Ie.prototype.visitDurationSecond=ze,Ie.prototype.visitDurationMillisecond=ze,Ie.prototype.visitDurationMicrosecond=ze,Ie.prototype.visitDurationNanosecond=ze,Ie.prototype.visitFixedSizeList=ze,Ie.prototype.visitMap=ze;const jf=new Ie;class Te extends en{}function Le(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(ue.isInt(t)&&t.bitWidth!==64||ue.isTime(t)&&t.bitWidth!==64||ue.isFloat(t)&&t.precision!==Qr.HALF))return new vS(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new vS(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new xP(s)})}class xP{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}Te.prototype.visitNull=Le,Te.prototype.visitBool=Le,Te.prototype.visitInt=Le,Te.prototype.visitInt8=Le,Te.prototype.visitInt16=Le,Te.prototype.visitInt32=Le,Te.prototype.visitInt64=Le,Te.prototype.visitUint8=Le,Te.prototype.visitUint16=Le,Te.prototype.visitUint32=Le,Te.prototype.visitUint64=Le,Te.prototype.visitFloat=Le,Te.prototype.visitFloat16=Le,Te.prototype.visitFloat32=Le,Te.prototype.visitFloat64=Le,Te.prototype.visitUtf8=Le,Te.prototype.visitLargeUtf8=Le,Te.prototype.visitBinary=Le,Te.prototype.visitLargeBinary=Le,Te.prototype.visitFixedSizeBinary=Le,Te.prototype.visitDate=Le,Te.prototype.visitDateDay=Le,Te.prototype.visitDateMillisecond=Le,Te.prototype.visitTimestamp=Le,Te.prototype.visitTimestampSecond=Le,Te.prototype.visitTimestampMillisecond=Le,Te.prototype.visitTimestampMicrosecond=Le,Te.prototype.visitTimestampNanosecond=Le,Te.prototype.visitTime=Le,Te.prototype.visitTimeSecond=Le,Te.prototype.visitTimeMillisecond=Le,Te.prototype.visitTimeMicrosecond=Le,Te.prototype.visitTimeNanosecond=Le,Te.prototype.visitDecimal=Le,Te.prototype.visitList=Le,Te.prototype.visitStruct=Le,Te.prototype.visitUnion=Le,Te.prototype.visitDenseUnion=Le,Te.prototype.visitSparseUnion=Le,Te.prototype.visitDictionary=Le,Te.prototype.visitInterval=Le,Te.prototype.visitIntervalDayTime=Le,Te.prototype.visitIntervalYearMonth=Le,Te.prototype.visitDuration=Le,Te.prototype.visitDurationSecond=Le,Te.prototype.visitDurationMillisecond=Le,Te.prototype.visitDurationMicrosecond=Le,Te.prototype.visitDurationNanosecond=Le,Te.prototype.visitFixedSizeList=Le,Te.prototype.visitMap=Le;const fy=new Te;var AS;const xS={},NS={};class Fn{constructor(t){var n,r,i;const s=t[0]instanceof Fn?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof $n)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:u}=xS[a.typeId],d=s[0];this.isValid=h=>dy(d,h),this.get=h=>o(d,h),this.set=(h,y)=>l(d,h,y),this.indexOf=h=>u(d,h),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,NS[a.typeId]),this._offsets=wS(s);break}this.data=s,this.type=a,this.stride=_a(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return IP(this.data)}get nullCount(){return bS(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${F[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(ay(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return fy.visit(this)}concat(...t){return new Fn(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new Fn(mS(this,t,n,({data:r,_offsets:i},s,a)=>SS(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case F.Int:case F.Float:case F.Decimal:case F.Time:case F.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new Fn(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return ue.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(ue.isDictionary(this.type)){const t=new Yf(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new Fn(n)}return new Yf(this)}unmemoize(){if(ue.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new Fn(n)}return this}}AS=Symbol.toStringTag,Fn[AS]=(e=>{e.type=ue.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(F).map(n=>F[n]).filter(n=>typeof n=="number"&&n!==F.NONE);for(const n of t){const r=Ii.getVisitFnByTypeId(n),i=Ki.getVisitFnByTypeId(n),s=jf.getVisitFnByTypeId(n);xS[n]={get:r,set:i,indexOf:s},NS[n]=Object.create(e,{isValid:{value:Gf(dy)},get:{value:Gf(Ii.getVisitFnByTypeId(n))},set:{value:ES(Ki.getVisitFnByTypeId(n))},indexOf:{value:IS(jf.getVisitFnByTypeId(n))}})}return"Vector"})(Fn.prototype);class Yf extends Fn{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new Yf(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Fn(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class hy{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Li{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Li).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Dn),(n||new Li).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Er.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Vs).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new hy).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new hy).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Fr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,Er.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class Ln{constructor(t=[],n,r,i=Er.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=py(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new Ln(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new Ln(n,this.metadata)}assign(...t){const n=t[0]instanceof Ln?t[0]:Array.isArray(t[0])?new Ln(t[0]):new Ln(t),r=[...this.fields],i=Wf(Wf(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(u=>u.name===o.name);return~l?(r[l]=o.clone({metadata:Wf(Wf(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=py(s,new Map);return new Ln([...r,...s],i,new Map([...this.dictionaries,...a]))}}Ln.prototype.fields=null,Ln.prototype.metadata=null,Ln.prototype.dictionaries=null;class rr{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new rr(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],rr.new(n,r,i,s)}}rr.prototype.type=null,rr.prototype.name=null,rr.prototype.nullable=null,rr.prototype.metadata=null;function Wf(e,t){return new Map([...e||new Map,...t||new Map])}function py(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(ue.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&py(i.children,t)}return t}var NP=Vw,RP=fl;class zc{static decode(t){t=new RP(dn(t));const n=Li.getRootAsFooter(t),r=Ln.decode(n.schema(),new Map,n.version());return new BP(r,n)}static encode(t){const n=new NP,r=Ln.encode(n,t.schema);Li.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Ga.encode(n,a);const i=n.endVector();Li.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Ga.encode(n,a);const s=n.endVector();return Li.startFooter(n),Li.addSchema(n,r),Li.addVersion(n,Er.V5),Li.addRecordBatches(n,i),Li.addDictionaries(n,s),Li.finishFooterBuffer(n,Li.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=Er.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class BP extends zc{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Ga.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Ga.decode(n)}return null}}class Ga{static decode(t){return new Ga(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return hy.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=Xn(r),this.bodyLength=Xn(n)}}const Lr=Object.freeze({done:!0,value:void 0});class RS{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class my{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class OP extends my{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return je(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Lr);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Yi.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Yi.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return je(this,void 0,void 0,function*(){return yield this.abort(t),Lr})}return(t){return je(this,void 0,void 0,function*(){return yield this.close(),Lr})}read(t){return je(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return je(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(Lr)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Hf extends OP{write(t){if((t=dn(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Ym(this.toUint8Array(!0)):this.toUint8Array(!1).then(Ym)}toUint8Array(t=!1){return t?Cs(this._values)[0]:je(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,u=bo(this),d;d=yield u.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const h=s;a.push(h),o+=h.byteLength}}catch(h){r={error:h}}finally{try{!l&&!n&&(i=u.return)&&(yield i.call(u))}finally{if(r)throw r.error}}return Cs(a,o)[0]})}}class qf{constructor(t){t&&(this.source=new DP(Yi.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class Al{constructor(t){t instanceof Al?this.source=t.source:t instanceof Hf?this.source=new Io(Yi.fromAsyncIterable(t)):Lw(t)?this.source=new Io(Yi.fromNodeStream(t)):qm(t)?this.source=new Io(Yi.fromDOMStream(t)):Fw(t)?this.source=new Io(Yi.fromDOMStream(t.body)):Mc(t)?this.source=new Io(Yi.fromIterable(t)):wo(t)?this.source=new Io(Yi.fromAsyncIterable(t)):dl(t)&&(this.source=new Io(Yi.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class DP{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Lr)}return(t){return Object.create(this.source.return&&this.source.return(t)||Lr)}}class Io{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return je(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return je(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return je(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return je(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return je(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||Lr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return je(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||Lr;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class BS extends qf{constructor(t,n){super(),this.position=0,this.buffer=dn(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class Xf extends Al{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=je(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return je(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return je(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return je(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),u=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<u.byteLength;)({bytesRead:o}=yield n.read(u,a,u.byteLength-a,s));return u}return null})}readAt(t,n){return je(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return je(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return je(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return je(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const FP=65536;function xl(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Nl=8,yy=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class OS{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?FP:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${xl(this.buffer[1])} ${xl(this.buffer[0])}`}}class Vn extends OS{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return Vn.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Vn.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new Vn(n);for(let s=0;s<r;){const a=Nl<r-s?Nl:r-s,o=new Vn(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new Vn(new Uint32Array([yy[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Vn.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Vn(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Vn(new Uint32Array(t.buffer)).plus(n)}}class Qi extends OS{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return Qi.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Qi.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new Qi(n);for(let a=r?1:0;a<i;){const o=Nl<i-a?Nl:i-a,l=new Qi(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),u=new Qi(new Uint32Array([yy[o],0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Qi.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Qi(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Qi(new Uint32Array(t.buffer)).plus(n)}}class zs{constructor(t){this.buffer=t}high(){return new Qi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Qi(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){const n=new Vn(new Uint32Array([this.buffer[3],0])),r=new Vn(new Uint32Array([this.buffer[2],0])),i=new Vn(new Uint32Array([this.buffer[1],0])),s=new Vn(new Uint32Array([this.buffer[0],0])),a=new Vn(new Uint32Array([t.buffer[3],0])),o=new Vn(new Uint32Array([t.buffer[2],0])),l=new Vn(new Uint32Array([t.buffer[1],0])),u=new Vn(new Uint32Array([t.buffer[0],0]));let d=Vn.multiply(s,u);this.buffer[0]=d.low();const h=new Vn(new Uint32Array([d.high(),0]));return d=Vn.multiply(i,u),h.plus(d),d=Vn.multiply(s,l),h.plus(d),this.buffer[1]=h.low(),this.buffer[3]=h.lessThan(d)?1:0,this.buffer[2]=h.high(),new Vn(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Vn.multiply(r,u)).plus(Vn.multiply(i,l)).plus(Vn.multiply(s,o)),this.buffer[3]+=Vn.multiply(n,u).plus(Vn.multiply(r,l)).plus(Vn.multiply(i,o)).plus(Vn.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${xl(this.buffer[3])} ${xl(this.buffer[2])} ${xl(this.buffer[1])} ${xl(this.buffer[0])}`}static multiply(t,n){return new zs(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new zs(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return zs.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return zs.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new zs(n);for(let a=r?1:0;a<i;){const o=Nl<i-a?Nl:i-a,l=new zs(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),u=new zs(new Uint32Array([yy[o],0,0,0]));s.times(u),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)zs.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class DS extends en{constructor(t,n,r,i,s=Er.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof rr?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return an({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<Er.V5&&this.readNullBitmap(t,r),t.mode===Kr.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return an({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class LP extends DS{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):zf(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return qn(Uint8Array,qn(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return qn(Uint8Array,qn(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return ue.isTimestamp(t)||(ue.isInt(t)||ue.isTime(t))&&t.bitWidth===64||ue.isDuration(t)||ue.isDate(t)&&t.unit===Wi.MILLISECOND?qn(Uint8Array,Qi.convertArray(r[n])):ue.isDecimal(t)?qn(Uint8Array,zs.convertArray(r[n])):ue.isBinary(t)||ue.isLargeBinary(t)||ue.isFixedSizeBinary(t)?MP(r[n]):ue.isBool(t)?zf(r[n]):ue.isUtf8(t)||ue.isLargeUtf8(t)?Wm(r[n].join("")):qn(Uint8Array,qn(t.ArrayType,r[n].map(i=>+i)))}}function MP(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class Ae extends en{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function li(e,t){return t instanceof e.constructor}function To(e,t){return e===t||li(e,t)}function ba(e,t){return e===t||li(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Kf(e,t){return e===t||li(e,t)&&e.precision===t.precision}function CP(e,t){return e===t||li(e,t)&&e.byteWidth===t.byteWidth}function gy(e,t){return e===t||li(e,t)&&e.unit===t.unit}function Gc(e,t){return e===t||li(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function jc(e,t){return e===t||li(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function kP(e,t){return e===t||li(e,t)&&e.children.length===t.children.length&&ja.compareManyFields(e.children,t.children)}function UP(e,t){return e===t||li(e,t)&&e.children.length===t.children.length&&ja.compareManyFields(e.children,t.children)}function _y(e,t){return e===t||li(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&ja.compareManyFields(e.children,t.children)}function PP(e,t){return e===t||li(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&ja.visit(e.indices,t.indices)&&ja.visit(e.dictionary,t.dictionary)}function vy(e,t){return e===t||li(e,t)&&e.unit===t.unit}function Yc(e,t){return e===t||li(e,t)&&e.unit===t.unit}function $P(e,t){return e===t||li(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&ja.compareManyFields(e.children,t.children)}function VP(e,t){return e===t||li(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&ja.compareManyFields(e.children,t.children)}Ae.prototype.visitNull=To,Ae.prototype.visitBool=To,Ae.prototype.visitInt=ba,Ae.prototype.visitInt8=ba,Ae.prototype.visitInt16=ba,Ae.prototype.visitInt32=ba,Ae.prototype.visitInt64=ba,Ae.prototype.visitUint8=ba,Ae.prototype.visitUint16=ba,Ae.prototype.visitUint32=ba,Ae.prototype.visitUint64=ba,Ae.prototype.visitFloat=Kf,Ae.prototype.visitFloat16=Kf,Ae.prototype.visitFloat32=Kf,Ae.prototype.visitFloat64=Kf,Ae.prototype.visitUtf8=To,Ae.prototype.visitLargeUtf8=To,Ae.prototype.visitBinary=To,Ae.prototype.visitLargeBinary=To,Ae.prototype.visitFixedSizeBinary=CP,Ae.prototype.visitDate=gy,Ae.prototype.visitDateDay=gy,Ae.prototype.visitDateMillisecond=gy,Ae.prototype.visitTimestamp=Gc,Ae.prototype.visitTimestampSecond=Gc,Ae.prototype.visitTimestampMillisecond=Gc,Ae.prototype.visitTimestampMicrosecond=Gc,Ae.prototype.visitTimestampNanosecond=Gc,Ae.prototype.visitTime=jc,Ae.prototype.visitTimeSecond=jc,Ae.prototype.visitTimeMillisecond=jc,Ae.prototype.visitTimeMicrosecond=jc,Ae.prototype.visitTimeNanosecond=jc,Ae.prototype.visitDecimal=To,Ae.prototype.visitList=kP,Ae.prototype.visitStruct=UP,Ae.prototype.visitUnion=_y,Ae.prototype.visitDenseUnion=_y,Ae.prototype.visitSparseUnion=_y,Ae.prototype.visitDictionary=PP,Ae.prototype.visitInterval=vy,Ae.prototype.visitIntervalDayTime=vy,Ae.prototype.visitIntervalYearMonth=vy,Ae.prototype.visitDuration=Yc,Ae.prototype.visitDurationSecond=Yc,Ae.prototype.visitDurationMillisecond=Yc,Ae.prototype.visitDurationMicrosecond=Yc,Ae.prototype.visitDurationNanosecond=Yc,Ae.prototype.visitFixedSizeList=$P,Ae.prototype.visitMap=VP;const ja=new Ae;function by(e,t){return ja.compareSchemas(e,t)}function wy(e,t){return zP(e,t.map(n=>n.data.concat()))}function zP(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((h,y)=>Math.max(h,y.length),0)};let s=0,a=0,o=-1;const l=t.length;let u,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=u=t[o].shift(),a=Math.min(a,u?u.length:a);Number.isFinite(a)&&(d=GP(n,a,d,t,i),a>0&&(r[s++]=an({type:new oi(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(h=>new Ti(e,h))]}function GP(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const u=n[o],d=u==null?void 0:u.length;if(d>=t)d===t?n[o]=u:(n[o]=u.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(u.slice(t,d-t))));else{const h=e[o];e[o]=h.clone({nullable:!0}),n[o]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:an({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var FS;class ci{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new Ln([]),this._offsets=[0],this;let i,s;t[0]instanceof Ln&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof Ti)return[l];if(l instanceof ci)return l.batches;if(l instanceof $n){if(l.type instanceof oi)return[new Ti(new Ln(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>a(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>a(u));if(typeof l=="object"){const u=Object.keys(l),d=u.map(S=>new Fn([l[S]])),h=i??new Ln(u.map((S,M)=>new rr(String(S),d[M].type,d[M].nullable))),[,y]=wy(h,d);return y.length===0?[new Ti(l)]:y}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new Ln([]),!(i instanceof Ln))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof Ti))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!by(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??wS(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=bS(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(ay(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?fy.visit(new Fn(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
328
328
  ${this.toArray().join(`,
329
329
  `)}
330
- ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new ai(n,r.map(i=>new wi(n,i)))}slice(t,n){const r=this.schema;[t,n]=P1({length:this.numRows},t,n);const i=W1(this.data,this._offsets,t,n);return new ai(r,i.map(s=>new wi(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=an({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new An(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new An([an({type:new Pa,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,u)=>this.getChildAt(u));[s[t],o[t]]=[a,n],[r,i]=ry(r,o)}return new ai(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new ai(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,u)=>{const[f,p]=o,E=n.findIndex(T=>T.name===l.name);return~E?p[E]=u:f.push(u),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new ai(...ry(s,a))}}rS=Symbol.toStringTag,ai[rS]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=kf(Hm),e.get=kf(bi.getVisitFn(O.Struct)),e.set=H1(Xi.getVisitFn(O.Struct)),e.indexOf=q1(Uf.getVisitFn(O.Struct)),"Table"))(ai.prototype);var iS;let wi=class bu{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof xn))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=an({nullCount:0,type:new ii(this.schema.fields),children:this.schema.fields.map(n=>an({type:n.type,nullCount:0}))})]=t,!(this.data instanceof Fn))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=sS(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,f)=>(l.children[f]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[f]=Kn.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new xn(r),o=an({type:new ii(r),length:s,children:i,nullCount:0});[this.schema,this.data]=sS(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=aS(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return bi.visit(this.data,t)}at(t){return this.get(zm(t,this.numRows))}set(t,n){return Xi.visit(this.data,t,n)}indexOf(t,n){return Uf.visit(this.data,t,n)}[Symbol.iterator](){return qm.visit(new An([this.data]))}toArray(){return[...this]}concat(...t){return new ai(this.schema,[this,...t])}slice(t,n){const[r]=new An([this.data]).slice(t,n).data;return new bu(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new An([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new An([an({type:new Pa,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new xn(s,new Map(this.schema.metadata)),i=an({type:new ii(s),children:a})}return new bu(r,i)}select(t){const n=this.schema.select(t),r=new ii(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new bu(n,an({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=an({type:new ii(n.fields),length:this.numRows,children:r});return new bu(n,i)}};iS=Symbol.toStringTag,wi[iS]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(wi.prototype);function sS(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const u=t[o];(!u||u.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=u==null?void 0:u._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:an({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),an({type:new ii(i),length:n,children:s})]}function aS(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const u of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])aS(o.children,u==null?void 0:u.children,n);if(oe.isDictionary(o)){const{id:u}=o;if(!n.has(u))l!=null&&l.dictionary&&n.set(u,l.dictionary);else if(n.get(u)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class iy extends wi{constructor(t){const n=t.fields.map(i=>an({type:i.type})),r=an({type:new ii(t.fields),nullCount:0,children:n});super(t,r)}}let Ga=class qs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new qs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Tn),(n||new qs).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yr.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):mn.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Ar).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yr.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,mn.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return qs.startMessage(t),qs.addVersion(t,n),qs.addHeaderType(t,r),qs.addHeader(t,i),qs.addBodyLength(t,s),qs.addCustomMetadata(t,a),qs.endMessage(t)}};class A3 extends en{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return vw.startNull(n),vw.endNull(n)}visitInt(t,n){return Oi.startInt(n),Oi.addBitWidth(n,t.bitWidth),Oi.addIsSigned(n,t.isSigned),Oi.endInt(n)}visitFloat(t,n){return Cs.startFloatingPoint(n),Cs.addPrecision(n,t.precision),Cs.endFloatingPoint(n)}visitBinary(t,n){return pw.startBinary(n),pw.endBinary(n)}visitLargeBinary(t,n){return yw.startLargeBinary(n),yw.endLargeBinary(n)}visitBool(t,n){return mw.startBool(n),mw.endBool(n)}visitUtf8(t,n){return bw.startUtf8(n),bw.endUtf8(n)}visitLargeUtf8(t,n){return gw.startLargeUtf8(n),gw.endLargeUtf8(n)}visitDecimal(t,n){return dl.startDecimal(n),dl.addScale(n,t.scale),dl.addPrecision(n,t.precision),dl.addBitWidth(n,t.bitWidth),dl.endDecimal(n)}visitDate(t,n){return ff.startDate(n),ff.addUnit(n,t.unit),ff.endDate(n)}visitTime(t,n){return Wi.startTime(n),Wi.addUnit(n,t.unit),Wi.addBitWidth(n,t.bitWidth),Wi.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return Hi.startTimestamp(n),Hi.addUnit(n,t.unit),r!==void 0&&Hi.addTimezone(n,r),Hi.endTimestamp(n)}visitInterval(t,n){return ks.startInterval(n),ks.addUnit(n,t.unit),ks.endInterval(n)}visitDuration(t,n){return hf.startDuration(n),hf.addUnit(n,t.unit),hf.endDuration(n)}visitList(t,n){return _w.startList(n),_w.endList(n)}visitStruct(t,n){return vo.startStruct_(n),vo.endStruct_(n)}visitUnion(t,n){vi.startTypeIdsVector(n,t.typeIds.length);const r=vi.createTypeIdsVector(n,t.typeIds);return vi.startUnion(n),vi.addMode(n,t.mode),vi.addTypeIds(n,r),vi.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return ha.startDictionaryEncoding(n),ha.addId(n,BigInt(t.id)),ha.addIsOrdered(n,t.isOrdered),r!==void 0&&ha.addIndexType(n,r),ha.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return pf.startFixedSizeBinary(n),pf.addByteWidth(n,t.byteWidth),pf.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return mf.startFixedSizeList(n),mf.addListSize(n,t.listSize),mf.endFixedSizeList(n)}visitMap(t,n){return yf.startMap(n),yf.addKeysSorted(n,t.keysSorted),yf.endMap(n)}}const sy=new A3;function x3(e,t=new Map){return new xn(N3(e,t),Yf(e.metadata),t)}function oS(e){return new Fi(e.count,cS(e.columns),uS(e.columns))}function R3(e){return new $s(oS(e.data),e.id,e.isDelta)}function N3(e,t){return(e.fields||[]).filter(Boolean).map(n=>Kn.fromJSON(n,t))}function lS(e,t){return(e.children||[]).filter(Boolean).map(n=>Kn.fromJSON(n,t))}function cS(e){return(e||[]).reduce((t,n)=>[...t,new ja(n.count,B3(n.VALIDITY)),...cS(n.children)],[])}function uS(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new Vs(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new Vs(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new Vs(t.length,i.OFFSET.length)),i.DATA&&t.push(new Vs(t.length,i.DATA.length)),t=uS(i.children,t)}return t}function B3(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function O3(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=fS(e,lS(e,t)),i=new Kn(e.name,a,e.nullable,Yf(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?dS(r):new Lc,o=new pl(t.get(n),r,n,s.isOrdered),i=new Kn(e.name,o,e.nullable,Yf(e.metadata))):(r=(r=s.indexType)?dS(r):new Lc,t.set(n,a=fS(e,lS(e,t))),o=new pl(a,r,n,s.isOrdered),i=new Kn(e.name,o,e.nullable,Yf(e.metadata))),i||null}function Yf(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function dS(e){return new bo(e.isSigned,e.bitWidth)}function fS(e,t){const n=e.type.name;switch(n){case"NONE":return new Pa;case"null":return new Pa;case"binary":return new _f;case"largebinary":return new vf;case"utf8":return new bf;case"largeutf8":return new wf;case"bool":return new Sf;case"list":return new Nf((t||[])[0]);case"struct":return new ii(t||[]);case"struct_":return new ii(t||[])}switch(n){case"int":{const r=e.type;return new bo(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new gf(Hr[r.precision])}case"decimal":{const r=e.type;return new Ef(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new If(Yi[r.unit])}case"time":{const r=e.type;return new Tf(Re[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Af(Re[r.unit],r.timezone)}case"interval":{const r=e.type;return new xf(Ls[r.unit])}case"duration":{const r=e.type;return new Rf(Re[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Bf(Wr[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Of(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Df(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Ff((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var D3=dw,F3=ll;class oi{static fromJSON(t,n){const r=new oi(0,yr.V5,n);return r._createHeader=L3(t,n),r}static decode(t){t=new F3(un(t));const n=Ga.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new oi(r,i,s);return a._createHeader=M3(n,s),a}static encode(t){const n=new D3;let r=-1;return t.isSchema()?r=xn.encode(n,t.header()):t.isRecordBatch()?r=Fi.encode(n,t.header()):t.isDictionaryBatch()&&(r=$s.encode(n,t.header())),Ga.startMessage(n),Ga.addVersion(n,yr.V5),Ga.addHeader(n,r),Ga.addHeaderType(n,t.headerType),Ga.addBodyLength(n,BigInt(t.bodyLength)),Ga.finishMessageBuffer(n,Ga.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof xn)return new oi(0,yr.V5,mn.Schema,t);if(t instanceof Fi)return new oi(n,yr.V5,mn.RecordBatch,t);if(t instanceof $s)return new oi(n,yr.V5,mn.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===mn.Schema}isRecordBatch(){return this.headerType===mn.RecordBatch}isDictionaryBatch(){return this.headerType===mn.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=jn(t)}}class Fi{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=jn(t)}}class $s{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,n,r=!1){this._data=t,this._isDelta=r,this._id=jn(n)}}class Vs{constructor(t,n){this.offset=jn(t),this.length=jn(n)}}class ja{constructor(t,n){this.length=jn(t),this.nullCount=jn(n)}}function L3(e,t){return(()=>{switch(t){case mn.Schema:return xn.fromJSON(e);case mn.RecordBatch:return Fi.fromJSON(e);case mn.DictionaryBatch:return $s.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${mn[t]}, type: ${t} }`)})}function M3(e,t){return(()=>{switch(t){case mn.Schema:return xn.decode(e.header(new Us),new Map,e.version());case mn.RecordBatch:return Fi.decode(e.header(new fa),e.version());case mn.DictionaryBatch:return $s.decode(e.header(new cl),e.version())}throw new Error(`Unrecognized Message type: { name: ${mn[t]}, type: ${t} }`)})}Kn.encode=W3,Kn.decode=j3,Kn.fromJSON=O3,xn.encode=Y3,xn.decode=C3,xn.fromJSON=x3,Fi.encode=H3,Fi.decode=k3,Fi.fromJSON=oS,$s.encode=q3,$s.decode=U3,$s.fromJSON=R3,ja.encode=X3,ja.decode=$3,Vs.encode=K3,Vs.decode=P3;function C3(e,t=new Map,n=yr.V5){const r=G3(e,t);return new xn(r,Wf(e),t,n)}function k3(e,t=yr.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new Fi(e.length(),V3(e),z3(e,t))}function U3(e,t=yr.V5){return new $s(Fi.decode(e.data(),t),e.id(),e.isDelta())}function P3(e){return new Vs(e.offset(),e.length())}function $3(e){return new ja(e.length(),e.nullCount())}function V3(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=ja.decode(n));return t}function z3(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<yr.V4&&(r.bb_pos+=8*(i+1)),n[++s]=Vs.decode(r));return n}function G3(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=Kn.decode(r,t));return n}function hS(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=Kn.decode(r,t));return n}function j3(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=mS(e,hS(e,t)),r=new Kn(e.name(),i,e.nullable(),Wf(e))):t.has(n=jn(o.id()))?(s=(s=o.indexType())?pS(s):new Lc,a=new pl(t.get(n),s,n,o.isOrdered()),r=new Kn(e.name(),a,e.nullable(),Wf(e))):(s=(s=o.indexType())?pS(s):new Lc,t.set(n,i=mS(e,hS(e,t))),a=new pl(i,s,n,o.isOrdered()),r=new Kn(e.name(),a,e.nullable(),Wf(e))),r||null}function Wf(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function pS(e){return new bo(e.isSigned(),e.bitWidth())}function mS(e,t){const n=e.typeType();switch(n){case Hn.NONE:return new Pa;case Hn.Null:return new Pa;case Hn.Binary:return new _f;case Hn.LargeBinary:return new vf;case Hn.Utf8:return new bf;case Hn.LargeUtf8:return new wf;case Hn.Bool:return new Sf;case Hn.List:return new Nf((t||[])[0]);case Hn.Struct_:return new ii(t||[])}switch(n){case Hn.Int:{const r=e.type(new Oi);return new bo(r.isSigned(),r.bitWidth())}case Hn.FloatingPoint:{const r=e.type(new Cs);return new gf(r.precision())}case Hn.Decimal:{const r=e.type(new dl);return new Ef(r.scale(),r.precision(),r.bitWidth())}case Hn.Date:{const r=e.type(new ff);return new If(r.unit())}case Hn.Time:{const r=e.type(new Wi);return new Tf(r.unit(),r.bitWidth())}case Hn.Timestamp:{const r=e.type(new Hi);return new Af(r.unit(),r.timezone())}case Hn.Interval:{const r=e.type(new ks);return new xf(r.unit())}case Hn.Duration:{const r=e.type(new hf);return new Rf(r.unit())}case Hn.Union:{const r=e.type(new vi);return new Bf(r.mode(),r.typeIdsArray()||[],t||[])}case Hn.FixedSizeBinary:{const r=e.type(new pf);return new Of(r.byteWidth())}case Hn.FixedSizeList:{const r=e.type(new mf);return new Df(r.listSize(),(t||[])[0])}case Hn.Map:{const r=e.type(new yf);return new Ff((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${Hn[n]}" (${n})`)}function Y3(e,t){const n=t.fields.map(s=>Kn.encode(e,s));Us.startFieldsVector(e,n.length);const r=Us.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?Us.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return Ar.startKeyValue(e),Ar.addKey(e,o),Ar.addValue(e,l),Ar.endKeyValue(e)})):-1;return Us.startSchema(e),Us.addFields(e,r),Us.addEndianness(e,Q3?ul.Little:ul.Big),i!==-1&&Us.addCustomMetadata(e,i),Us.endSchema(e)}function W3(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;oe.isDictionary(s)?(a=s.dictionary.typeId,i=sy.visit(s,e),r=sy.visit(s.dictionary,e)):r=sy.visit(s,e);const o=(s.children||[]).map(f=>Kn.encode(e,f)),l=qi.createChildrenVector(e,o),u=t.metadata&&t.metadata.size>0?qi.createCustomMetadataVector(e,[...t.metadata].map(([f,p])=>{const E=e.createString(`${f}`),T=e.createString(`${p}`);return Ar.startKeyValue(e),Ar.addKey(e,E),Ar.addValue(e,T),Ar.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),qi.startField(e),qi.addType(e,r),qi.addTypeType(e,a),qi.addChildren(e,l),qi.addNullable(e,!!t.nullable),n!==-1&&qi.addName(e,n),i!==-1&&qi.addDictionary(e,i),u!==-1&&qi.addCustomMetadata(e,u),qi.endField(e)}function H3(e,t){const n=t.nodes||[],r=t.buffers||[];fa.startNodesVector(e,n.length);for(const a of n.slice().reverse())ja.encode(e,a);const i=e.endVector();fa.startBuffersVector(e,r.length);for(const a of r.slice().reverse())Vs.encode(e,a);const s=e.endVector();return fa.startRecordBatch(e),fa.addLength(e,BigInt(t.length)),fa.addNodes(e,i),fa.addBuffers(e,s),fa.endRecordBatch(e)}function q3(e,t){const n=Fi.encode(e,t.data);return cl.startDictionaryBatch(e),cl.addId(e,BigInt(t.id)),cl.addIsDelta(e,t.isDelta),cl.addData(e,n),cl.endDictionaryBatch(e)}function X3(e,t){return hw.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function K3(e,t){return fw.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Q3=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),ay=e=>`Expected ${mn[e]} Message in stream, but was null or length 0.`,oy=e=>`Header pointer of flatbuffer-encoded ${mn[e]} Message is null or length 0.`,yS=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,gS=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class _S{constructor(t){this.source=t instanceof zf?t:new zf(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?xr:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(ay(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=un(this.source.read(t));if(n.byteLength<t)throw new Error(gS(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=mn.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(oy(n));return i}readMetadataLength(){const t=this.source.read(Hf),n=t&&new ll(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return xr;if(n.byteLength<t)throw new Error(yS(t,n.byteLength));return{done:!1,value:oi.decode(n)}}}class J3{constructor(t,n){this.source=t instanceof Sl?t:nw(t)?new Gf(t,n):new Sl(t)}[Symbol.asyncIterator](){return this}next(){return ze(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?xr:t})}throw(t){return ze(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return ze(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return ze(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(ay(t));return n.value})}readMessageBody(t){return ze(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=un(yield this.source.read(t));if(n.byteLength<t)throw new Error(gS(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return ze(this,arguments,void 0,function*(t=!1){const n=mn.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(oy(n));return i})}readMetadataLength(){return ze(this,void 0,void 0,function*(){const t=yield this.source.read(Hf),n=t&&new ll(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return ze(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return xr;if(n.byteLength<t)throw new Error(yS(t,n.byteLength));return{done:!1,value:oi.decode(n)}})}}class Z3 extends _S{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Z1?t:new Z1(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:oi.fromJSON(t.schema,mn.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:oi.fromJSON(n,mn.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:oi.fromJSON(n,mn.RecordBatch)}}return this._body=[],xr}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(ay(t));return n.value}readSchema(){const t=mn.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(oy(t));return r}}const Hf=4,ly="ARROW1",$c=new Uint8Array(ly.length);for(let e=0;e<ly.length;e+=1)$c[e]=ly.codePointAt(e);function cy(e,t=0){for(let n=-1,r=$c.length;++n<r;)if($c[n]!==e[t+n])return!1;return!0}const Vc=$c.length,vS=Vc+Hf,tP=Vc*2+Hf;class Qi extends Qm{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return _o(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return ji.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ji.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Qi?t:Nm(t)?iP(t):nw(t)?oP(t):_o(t)?ze(this,void 0,void 0,function*(){return yield Qi.from(yield t)}):rw(t)||Bm(t)||iw(t)||ol(t)?aP(new Sl(t)):sP(new zf(t))}static readAll(t){return t instanceof Qi?t.isSync()?IS(t):TS(t):Nm(t)||ArrayBuffer.isView(t)||Nc(t)||ew(t)?IS(t):TS(t)}}class qf extends Qi{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ds(this,arguments,function*(){yield Je(yield*sf(go(this[Symbol.iterator]())))})}}class Xf extends Qi{constructor(t){super(t),this._impl=t}readAll(){return ze(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=go(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class bS extends qf{constructor(t){super(t),this._impl=t}}class eP extends Xf{constructor(t){super(t),this._impl=t}}class wS{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=an({type:new ii(this.schema.fields),length:t.length,children:r});return new wi(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),u=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new An(u)):new An(u)).memoize()}_loadVectors(t,n,r){return new nS(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class Kf extends wS{constructor(t,n){super(n),this._reader=Nm(t)?new Z3(this._handle=t):new _S(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=ES(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):xr}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):xr}next(){if(this.closed)return xr;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new iy(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Qf extends wS{constructor(t,n){super(n),this._reader=new J3(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return ze(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return ze(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ES(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return ze(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):xr})}return(t){return ze(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):xr})}next(){return ze(this,void 0,void 0,function*(){if(this.closed)return xr;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new iy(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return ze(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class SS extends Kf{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof tS?t:new tS(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(mn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(mn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-vS,r=t.readInt32(n),i=t.readAt(n-r,r);return Cc.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class nP extends Qf{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof Gf?t:new Gf(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return ze(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return ze(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(mn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return ze(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(mn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return ze(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-vS,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Cc.decode(i)})}_readNextMessageAndValidate(t){return ze(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class rP extends Kf{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new y3(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function ES(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*IS(e){const t=Qi.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function TS(e){return Ds(this,arguments,function*(){const t=yield Je(Qi.from(e));try{if(!(yield Je(t.open({autoDestroy:!1}))).closed)do yield yield Je(t);while(!(yield Je(t.reset().open())).closed)}finally{yield Je(t.cancel())}})}function iP(e){return new qf(new rP(e))}function sP(e){const t=e.peek(Vc+7&-8);return t&&t.byteLength>=4?cy(t)?new bS(new SS(e.read())):new qf(new Kf(e)):new qf(new Kf((function*(){})()))}function aP(e){return ze(this,void 0,void 0,function*(){const t=yield e.peek(Vc+7&-8);return t&&t.byteLength>=4?cy(t)?new bS(new SS(yield e.read())):new Xf(new Qf(e)):new Xf(new Qf((function(){return Ds(this,arguments,function*(){})})()))})}function oP(e){return ze(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new Gf(e,t);return t>=tP&&cy(yield n.readAt(0,Vc+7&-8))?new eP(new nP(n)):new Xf(new Qf(n))})}class ir extends en{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof wi?s.data.children:s.data),r=new ir;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof An)return this.visitMany(t.data),this;const{type:n}=t;if(!oe.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(oe.isUnion(n))this.nodes.push(new ja(r,0));else{const{nullCount:i}=t;oe.isNull(n)||fs.call(this,i<=0?new Uint8Array(0):Mf(t.offset,r,t.nullBitmap)),this.nodes.push(new ja(r,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function fs(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Vs(this._byteLength,t)),this._byteLength+=t,this}function lP(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(fs.call(this,i),n.mode===Wr.Sparse)return dy.call(this,e);if(n.mode===Wr.Dense){if(e.offset<=0)return fs.call(this,s),dy.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let u,f,p=-1;++p<r;)(u=i[p])!==void 0&&((f=o[u])===void 0&&(f=o[u]=s[p]),a[p]=s[p]-f,l[u]=((t=l[u])!==null&&t!==void 0?t:0)+1);fs.call(this,a),this.visitMany(e.children.map((u,f)=>{const p=n.typeIds[f],E=o[p],T=l[p];return u.slice(E,Math.min(r,T))}))}}return this}function cP(e){let t;return e.nullCount>=e.length?fs.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?fs.call(this,Mf(e.offset,e.length,t)):fs.call(this,Cf(e.values))}function _a(e){return fs.call(this,e.values.subarray(0,e.length*e.stride))}function Jf(e){const{length:t,values:n,valueOffsets:r}=e,i=jn(r[0]),s=jn(r[t]),a=Math.min(s-i,n.byteLength-i);return fs.call(this,lw(-i,t+1,r)),fs.call(this,n.subarray(i,i+a)),this}function uy(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return fs.call(this,lw(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function dy(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}ir.prototype.visitBool=cP,ir.prototype.visitInt=_a,ir.prototype.visitFloat=_a,ir.prototype.visitUtf8=Jf,ir.prototype.visitLargeUtf8=Jf,ir.prototype.visitBinary=Jf,ir.prototype.visitLargeBinary=Jf,ir.prototype.visitFixedSizeBinary=_a,ir.prototype.visitDate=_a,ir.prototype.visitTimestamp=_a,ir.prototype.visitTime=_a,ir.prototype.visitDecimal=_a,ir.prototype.visitList=uy,ir.prototype.visitStruct=dy,ir.prototype.visitUnion=lP,ir.prototype.visitInterval=_a,ir.prototype.visitDuration=_a,ir.prototype.visitFixedSizeList=uy,ir.prototype.visitMap=uy;class AS extends Qm{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Vf,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,_i(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return _o(t)?t.then(n=>this.writeAll(n)):ol(t)?my(this,t):py(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof Vf?this._sink=t:(this._sink=new Vf,t&&$k(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Vk(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!ny(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof ai&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof wi&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!ny(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof wi?t instanceof iy||this._writeRecordBatch(t):t instanceof ai?this.writeAll(t.batches):Nc(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=oi.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===mn.RecordBatch?this._recordBatchBlocks.push(new Va(o,t.bodyLength,this._position)):t.headerType===mn.DictionaryBatch&&this._dictionaryBlocks.push(new Va(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=un(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(oi.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write($c)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=ir.assemble(t),a=new Fi(t.numRows,r,i),o=oi.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=ir.assemble(new An([t])),l=new Fi(t.length,s,a),u=new $s(l,n,r),f=oi.from(u,i);return this._writeMessage(f)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[u,f]of a.entries())this._writeDictionaryBatch(f,i,u>0);else if(l<a.length)for(const u of a.slice(l))this._writeDictionaryBatch(u,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class fy extends AS{static writeAll(t,n){const r=new fy(n);return _o(t)?t.then(i=>r.writeAll(i)):ol(t)?my(r,t):py(r,t)}}class hy extends AS{static writeAll(t){const n=new hy;return _o(t)?t.then(r=>n.writeAll(r)):ol(t)?my(n,t):py(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Cc.encode(new Cc(t,yr.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function py(e,t){let n=t;t instanceof ai&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function my(e,t){return ze(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=go(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const u=l;e.write(u)}}catch(u){a={error:u}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function uP(e,t="stream"){return(t==="stream"?fy:hy).writeAll(e).toUint8Array(!0)}var dP=Object.create,xS=Object.defineProperty,fP=Object.getOwnPropertyDescriptor,hP=Object.getOwnPropertyNames,pP=Object.getPrototypeOf,mP=Object.prototype.hasOwnProperty,yP=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gP=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of hP(t))!mP.call(e,i)&&i!==n&&xS(e,i,{get:()=>t[i],enumerable:!(r=fP(t,i))||r.enumerable});return e},_P=(e,t,n)=>(n=e!=null?dP(pP(e)):{},gP(!e||!e.__esModule?xS(n,"default",{value:e,enumerable:!0}):n,e)),vP=yP((e,t)=>{t.exports=Worker}),RS=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(RS||{}),NS=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(NS||{}),BS=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(BS||{}),OS=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(OS||{}),DS=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(DS||{}),FS=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(FS||{}),bP=class{log(e){}},wP=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function SP(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function EP(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function IP(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function TP(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var LS=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(LS||{}),MS=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Qi.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new ai(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new yy(this._bindings,this._conn,n),i=await Qi.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new CS(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=uP(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},yy=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},CS=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Qi.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new ai(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new yy(this.bindings,this.connectionId,t),r=await Qi.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},kS=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(kS||{}),US=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(US||{}),dn=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function Zf(e){switch(e.typeId){case O.Binary:return{sqlType:"binary"};case O.Bool:return{sqlType:"bool"};case O.Date:return{sqlType:"date"};case O.DateDay:return{sqlType:"date32[d]"};case O.DateMillisecond:return{sqlType:"date64[ms]"};case O.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case O.Float:return{sqlType:"float"};case O.Float16:return{sqlType:"float16"};case O.Float32:return{sqlType:"float32"};case O.Float64:return{sqlType:"float64"};case O.Int:return{sqlType:"int32"};case O.Int16:return{sqlType:"int16"};case O.Int32:return{sqlType:"int32"};case O.Int64:return{sqlType:"int64"};case O.Uint16:return{sqlType:"uint16"};case O.Uint32:return{sqlType:"uint32"};case O.Uint64:return{sqlType:"uint64"};case O.Uint8:return{sqlType:"uint8"};case O.IntervalDayTime:return{sqlType:"interval[dt]"};case O.IntervalYearMonth:return{sqlType:"interval[m]"};case O.List:return{sqlType:"list",valueType:Zf(e.valueType)};case O.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case O.Null:return{sqlType:"null"};case O.Utf8:return{sqlType:"utf8"};case O.Struct:return{sqlType:"struct",fields:e.children.map(t=>gy(t.name,t.type))};case O.Map:{let t=e;return{sqlType:"map",keyType:Zf(t.keyType),valueType:Zf(t.valueType)}}case O.Time:return{sqlType:"time[s]"};case O.TimeMicrosecond:return{sqlType:"time[us]"};case O.TimeMillisecond:return{sqlType:"time[ms]"};case O.TimeNanosecond:return{sqlType:"time[ns]"};case O.TimeSecond:return{sqlType:"time[s]"};case O.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case O.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case O.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case O.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case O.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function gy(e,t){let n=Zf(t);return n.name=e,n}var AP=new TextEncoder,xP=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new dn("RESET",null);return await this.postTask(e)}async ping(){let e=new dn("PING",null);await this.postTask(e)}async dropFile(e){let t=new dn("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new dn("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new dn("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new dn("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new dn("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new dn("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new dn("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new dn("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new dn("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new MS(this,e)}async disconnect(e){let t=new dn("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new dn("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new dn("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new dn("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new dn("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new dn("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new dn("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new dn("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new dn("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new dn("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new dn("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new dn("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=AP.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new dn("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new dn("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new dn("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new dn("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new dn("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new dn("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new dn("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new dn("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new dn("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(gy(s,a))}n.columnsFlat=i,delete n.columns}let r=new dn("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(gy(s,a))}n.columnsFlat=i,delete n.columns}let r=new dn("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function RP(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}RP();var PS=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(PS||{}),NP=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},BP=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),OP=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),DP=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),FP=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),_y={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},$S=_y.name,VS=_y.version,vy=_y.version.split("."),LP=vy[0],MP=vy[1],CP=vy[2],by=()=>typeof navigator>"u",zS=()=>by()?"node":navigator.userAgent,kP=()=>zS().includes("Firefox"),UP=()=>/^((?!chrome|android).)*safari/i.test(zS());function PP(){let e="https://cdn.jsdelivr.net/npm/".concat($S,"@").concat(VS,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var wy=null,Sy=null,Ey=null,Iy=null,Ty=null;async function GS(){return wy==null&&(wy=typeof BigInt64Array<"u"),Sy==null&&(Sy=await OP()),Ey==null&&(Ey=await FP()),Iy==null&&(Iy=await DP()),Ty==null&&(Ty=await BP()),{bigInt64Array:wy,crossOriginIsolated:by()||globalThis.crossOriginIsolated||!1,wasmExceptions:Sy,wasmSIMD:Iy,wasmThreads:Ey,wasmBulkMemory:Ty}}async function $P(e){let t=await GS();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var VP=_P(vP());async function zP(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new VP.default(r)}const GP=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:xP,AsyncDuckDBConnection:MS,AsyncDuckDBDispatcher:NP,AsyncPreparedStatement:CS,AsyncResultStreamIterator:yy,ConsoleLogger:wP,DuckDBAccessMode:RS,DuckDBDataProtocol:PS,LogEvent:DS,LogLevel:BS,LogOrigin:FS,LogTopic:OS,PACKAGE_NAME:$S,PACKAGE_VERSION:VS,PACKAGE_VERSION_MAJOR:LP,PACKAGE_VERSION_MINOR:MP,PACKAGE_VERSION_PATCH:CP,StatusCode:LS,TokenType:NS,VoidLogger:bP,WorkerRequestType:kS,WorkerResponseType:US,WorkerTask:dn,createWorker:zP,getJsDelivrBundles:PP,getLogEventLabel:EP,getLogLevelLabel:SP,getLogOriginLabel:TP,getLogTopicLabel:IP,getPlatformFeatures:GS,isFirefox:kP,isNode:by,isSafari:UP,selectBundle:$P},Symbol.toStringTag,{value:"Module"}));async function jP(){var e,t,n;const r="@aws-amplify/auth";let i;try{i=await import(r)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:s}=i,a=await s();return{token:((n=(t=(e=a==null?void 0:a.tokens)==null?void 0:e.idToken)==null?void 0:t.toString)==null?void 0:n.call(t))??null,provider:"amplify"}}const jS=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:jP},Symbol.toStringTag,{value:"Module"}));Ii.DataExplorer=wR,Ii.GeneExpression=rk,Ii.ProportionPlot=TR,Ii.SideBySide=Ck,Ii.UMAP=ER,Object.defineProperty(Ii,Symbol.toStringTag,{value:"Module"})}));
330
+ ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new ci(n,r.map(i=>new Ti(n,i)))}slice(t,n){const r=this.schema;[t,n]=mS({length:this.numRows},t,n);const i=SS(this.data,this._offsets,t,n);return new ci(r,i.map(s=>new Ti(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=an({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Fn(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new Fn([an({type:new Va,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,u)=>this.getChildAt(u));[s[t],o[t]]=[a,n],[r,i]=wy(r,o)}return new ci(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new ci(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,u)=>{const[d,h]=o,y=n.findIndex(S=>S.name===l.name);return~y?h[y]=u:d.push(u),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new ci(...wy(s,a))}}FS=Symbol.toStringTag,ci[FS]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=Gf(dy),e.get=Gf(Ii.getVisitFn(F.Struct)),e.set=ES(Ki.getVisitFn(F.Struct)),e.indexOf=IS(jf.getVisitFn(F.Struct)),"Table"))(ci.prototype);var LS;let Ti=class Au{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Ln))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=an({nullCount:0,type:new oi(this.schema.fields),children:this.schema.fields.map(n=>an({type:n.type,nullCount:0}))})]=t,!(this.data instanceof $n))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=MS(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,u,d)=>(l.children[d]=n[u],l.length=Math.max(l.length,n[u].length),l.fields[d]=rr.new({name:u,type:n[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new Ln(r),o=an({type:new oi(r),length:s,children:i,nullCount:0});[this.schema,this.data]=MS(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=CS(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Ii.visit(this.data,t)}at(t){return this.get(ay(t,this.numRows))}set(t,n){return Ki.visit(this.data,t,n)}indexOf(t,n){return jf.visit(this.data,t,n)}[Symbol.iterator](){return fy.visit(new Fn([this.data]))}toArray(){return[...this]}concat(...t){return new ci(this.schema,[this,...t])}slice(t,n){const[r]=new Fn([this.data]).slice(t,n).data;return new Au(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new Fn([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new Fn([an({type:new Va,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new Ln(s,new Map(this.schema.metadata)),i=an({type:new oi(s),children:a})}return new Au(r,i)}select(t){const n=this.schema.select(t),r=new oi(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new Au(n,an({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=an({type:new oi(n.fields),length:this.numRows,children:r});return new Au(n,i)}};LS=Symbol.toStringTag,Ti[LS]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ti.prototype);function MS(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const u=t[o];(!u||u.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=u==null?void 0:u._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:an({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),an({type:new oi(i),length:n,children:s})]}function CS(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const u of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])CS(o.children,u==null?void 0:u.children,n);if(ue.isDictionary(o)){const{id:u}=o;if(!n.has(u))l!=null&&l.dictionary&&n.set(u,l.dictionary);else if(n.get(u)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class Sy extends Ti{constructor(t){const n=t.fields.map(i=>an({type:i.type})),r=an({type:new oi(t.fields),nullCount:0,children:n});super(t,r)}}let Ya=class Ks{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new Ks).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Dn),(n||new Ks).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Er.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):wn.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new Fr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,Er.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,wn.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return Ks.startMessage(t),Ks.addVersion(t,n),Ks.addHeaderType(t,r),Ks.addHeader(t,i),Ks.addBodyLength(t,s),Ks.addCustomMetadata(t,a),Ks.endMessage(t)}};class jP extends en{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return Xw.startNull(n),Xw.endNull(n)}visitInt(t,n){return Fi.startInt(n),Fi.addBitWidth(n,t.bitWidth),Fi.addIsSigned(n,t.isSigned),Fi.endInt(n)}visitFloat(t,n){return Ps.startFloatingPoint(n),Ps.addPrecision(n,t.precision),Ps.endFloatingPoint(n)}visitBinary(t,n){return jw.startBinary(n),jw.endBinary(n)}visitLargeBinary(t,n){return Ww.startLargeBinary(n),Ww.endLargeBinary(n)}visitBool(t,n){return Yw.startBool(n),Yw.endBool(n)}visitUtf8(t,n){return Kw.startUtf8(n),Kw.endUtf8(n)}visitLargeUtf8(t,n){return Hw.startLargeUtf8(n),Hw.endLargeUtf8(n)}visitDecimal(t,n){return ml.startDecimal(n),ml.addScale(n,t.scale),ml.addPrecision(n,t.precision),ml.addBitWidth(n,t.bitWidth),ml.endDecimal(n)}visitDate(t,n){return _f.startDate(n),_f.addUnit(n,t.unit),_f.endDate(n)}visitTime(t,n){return Hi.startTime(n),Hi.addUnit(n,t.unit),Hi.addBitWidth(n,t.bitWidth),Hi.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return qi.startTimestamp(n),qi.addUnit(n,t.unit),r!==void 0&&qi.addTimezone(n,r),qi.endTimestamp(n)}visitInterval(t,n){return $s.startInterval(n),$s.addUnit(n,t.unit),$s.endInterval(n)}visitDuration(t,n){return vf.startDuration(n),vf.addUnit(n,t.unit),vf.endDuration(n)}visitList(t,n){return qw.startList(n),qw.endList(n)}visitStruct(t,n){return So.startStruct_(n),So.endStruct_(n)}visitUnion(t,n){Ei.startTypeIdsVector(n,t.typeIds.length);const r=Ei.createTypeIdsVector(n,t.typeIds);return Ei.startUnion(n),Ei.addMode(n,t.mode),Ei.addTypeIds(n,r),Ei.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return ya.startDictionaryEncoding(n),ya.addId(n,BigInt(t.id)),ya.addIsOrdered(n,t.isOrdered),r!==void 0&&ya.addIndexType(n,r),ya.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return bf.startFixedSizeBinary(n),bf.addByteWidth(n,t.byteWidth),bf.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return wf.startFixedSizeList(n),wf.addListSize(n,t.listSize),wf.endFixedSizeList(n)}visitMap(t,n){return Sf.startMap(n),Sf.addKeysSorted(n,t.keysSorted),Sf.endMap(n)}}const Ey=new jP;function YP(e,t=new Map){return new Ln(HP(e,t),Qf(e.metadata),t)}function kS(e){return new Mi(e.count,PS(e.columns),$S(e.columns))}function WP(e){return new Gs(kS(e.data),e.id,e.isDelta)}function HP(e,t){return(e.fields||[]).filter(Boolean).map(n=>rr.fromJSON(n,t))}function US(e,t){return(e.children||[]).filter(Boolean).map(n=>rr.fromJSON(n,t))}function PS(e){return(e||[]).reduce((t,n)=>[...t,new Wa(n.count,qP(n.VALIDITY)),...PS(n.children)],[])}function $S(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new js(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new js(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new js(t.length,i.OFFSET.length)),i.DATA&&t.push(new js(t.length,i.DATA.length)),t=$S(i.children,t)}return t}function qP(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function XP(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=zS(e,US(e,t)),i=new rr(e.name,a,e.nullable,Qf(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?VS(r):new $c,o=new _l(t.get(n),r,n,s.isOrdered),i=new rr(e.name,o,e.nullable,Qf(e.metadata))):(r=(r=s.indexType)?VS(r):new $c,t.set(n,a=zS(e,US(e,t))),o=new _l(a,r,n,s.isOrdered),i=new rr(e.name,o,e.nullable,Qf(e.metadata))),i||null}function Qf(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function VS(e){return new Eo(e.isSigned,e.bitWidth)}function zS(e,t){const n=e.type.name;switch(n){case"NONE":return new Va;case"null":return new Va;case"binary":return new If;case"largebinary":return new Tf;case"utf8":return new Af;case"largeutf8":return new xf;case"bool":return new Nf;case"list":return new Mf((t||[])[0]);case"struct":return new oi(t||[]);case"struct_":return new oi(t||[])}switch(n){case"int":{const r=e.type;return new Eo(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new Ef(Qr[r.precision])}case"decimal":{const r=e.type;return new Rf(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new Bf(Wi[r.unit])}case"time":{const r=e.type;return new Of(Oe[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Df(Oe[r.unit],r.timezone)}case"interval":{const r=e.type;return new Ff(ks[r.unit])}case"duration":{const r=e.type;return new Lf(Oe[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Cf(Kr[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new kf(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Uf(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Pf((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var KP=Vw,QP=fl;class ui{static fromJSON(t,n){const r=new ui(0,Er.V5,n);return r._createHeader=JP(t,n),r}static decode(t){t=new QP(dn(t));const n=Ya.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new ui(r,i,s);return a._createHeader=ZP(n,s),a}static encode(t){const n=new KP;let r=-1;return t.isSchema()?r=Ln.encode(n,t.header()):t.isRecordBatch()?r=Mi.encode(n,t.header()):t.isDictionaryBatch()&&(r=Gs.encode(n,t.header())),Ya.startMessage(n),Ya.addVersion(n,Er.V5),Ya.addHeader(n,r),Ya.addHeaderType(n,t.headerType),Ya.addBodyLength(n,BigInt(t.bodyLength)),Ya.finishMessageBuffer(n,Ya.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof Ln)return new ui(0,Er.V5,wn.Schema,t);if(t instanceof Mi)return new ui(n,Er.V5,wn.RecordBatch,t);if(t instanceof Gs)return new ui(n,Er.V5,wn.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===wn.Schema}isRecordBatch(){return this.headerType===wn.RecordBatch}isDictionaryBatch(){return this.headerType===wn.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=Xn(t)}}class Mi{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=Xn(t)}}class Gs{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,n,r=!1){this._data=t,this._isDelta=r,this._id=Xn(n)}}class js{constructor(t,n){this.offset=Xn(t),this.length=Xn(n)}}class Wa{constructor(t,n){this.length=Xn(t),this.nullCount=Xn(n)}}function JP(e,t){return(()=>{switch(t){case wn.Schema:return Ln.fromJSON(e);case wn.RecordBatch:return Mi.fromJSON(e);case wn.DictionaryBatch:return Gs.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${wn[t]}, type: ${t} }`)})}function ZP(e,t){return(()=>{switch(t){case wn.Schema:return Ln.decode(e.header(new Vs),new Map,e.version());case wn.RecordBatch:return Mi.decode(e.header(new ma),e.version());case wn.DictionaryBatch:return Gs.decode(e.header(new hl),e.version())}throw new Error(`Unrecognized Message type: { name: ${wn[t]}, type: ${t} }`)})}rr.encode=u$,rr.decode=l$,rr.fromJSON=XP,Ln.encode=c$,Ln.decode=t$,Ln.fromJSON=YP,Mi.encode=d$,Mi.decode=e$,Mi.fromJSON=kS,Gs.encode=f$,Gs.decode=n$,Gs.fromJSON=WP,Wa.encode=h$,Wa.decode=i$,js.encode=p$,js.decode=r$;function t$(e,t=new Map,n=Er.V5){const r=o$(e,t);return new Ln(r,Jf(e),t,n)}function e$(e,t=Er.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new Mi(e.length(),s$(e),a$(e,t))}function n$(e,t=Er.V5){return new Gs(Mi.decode(e.data(),t),e.id(),e.isDelta())}function r$(e){return new js(e.offset(),e.length())}function i$(e){return new Wa(e.length(),e.nullCount())}function s$(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Wa.decode(n));return t}function a$(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<Er.V4&&(r.bb_pos+=8*(i+1)),n[++s]=js.decode(r));return n}function o$(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=rr.decode(r,t));return n}function GS(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=rr.decode(r,t));return n}function l$(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=YS(e,GS(e,t)),r=new rr(e.name(),i,e.nullable(),Jf(e))):t.has(n=Xn(o.id()))?(s=(s=o.indexType())?jS(s):new $c,a=new _l(t.get(n),s,n,o.isOrdered()),r=new rr(e.name(),a,e.nullable(),Jf(e))):(s=(s=o.indexType())?jS(s):new $c,t.set(n,i=YS(e,GS(e,t))),a=new _l(i,s,n,o.isOrdered()),r=new rr(e.name(),a,e.nullable(),Jf(e))),r||null}function Jf(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function jS(e){return new Eo(e.isSigned(),e.bitWidth())}function YS(e,t){const n=e.typeType();switch(n){case Zn.NONE:return new Va;case Zn.Null:return new Va;case Zn.Binary:return new If;case Zn.LargeBinary:return new Tf;case Zn.Utf8:return new Af;case Zn.LargeUtf8:return new xf;case Zn.Bool:return new Nf;case Zn.List:return new Mf((t||[])[0]);case Zn.Struct_:return new oi(t||[])}switch(n){case Zn.Int:{const r=e.type(new Fi);return new Eo(r.isSigned(),r.bitWidth())}case Zn.FloatingPoint:{const r=e.type(new Ps);return new Ef(r.precision())}case Zn.Decimal:{const r=e.type(new ml);return new Rf(r.scale(),r.precision(),r.bitWidth())}case Zn.Date:{const r=e.type(new _f);return new Bf(r.unit())}case Zn.Time:{const r=e.type(new Hi);return new Of(r.unit(),r.bitWidth())}case Zn.Timestamp:{const r=e.type(new qi);return new Df(r.unit(),r.timezone())}case Zn.Interval:{const r=e.type(new $s);return new Ff(r.unit())}case Zn.Duration:{const r=e.type(new vf);return new Lf(r.unit())}case Zn.Union:{const r=e.type(new Ei);return new Cf(r.mode(),r.typeIdsArray()||[],t||[])}case Zn.FixedSizeBinary:{const r=e.type(new bf);return new kf(r.byteWidth())}case Zn.FixedSizeList:{const r=e.type(new wf);return new Uf(r.listSize(),(t||[])[0])}case Zn.Map:{const r=e.type(new Sf);return new Pf((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${Zn[n]}" (${n})`)}function c$(e,t){const n=t.fields.map(s=>rr.encode(e,s));Vs.startFieldsVector(e,n.length);const r=Vs.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?Vs.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return Fr.startKeyValue(e),Fr.addKey(e,o),Fr.addValue(e,l),Fr.endKeyValue(e)})):-1;return Vs.startSchema(e),Vs.addFields(e,r),Vs.addEndianness(e,m$?pl.Little:pl.Big),i!==-1&&Vs.addCustomMetadata(e,i),Vs.endSchema(e)}function u$(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;ue.isDictionary(s)?(a=s.dictionary.typeId,i=Ey.visit(s,e),r=Ey.visit(s.dictionary,e)):r=Ey.visit(s,e);const o=(s.children||[]).map(d=>rr.encode(e,d)),l=Xi.createChildrenVector(e,o),u=t.metadata&&t.metadata.size>0?Xi.createCustomMetadataVector(e,[...t.metadata].map(([d,h])=>{const y=e.createString(`${d}`),S=e.createString(`${h}`);return Fr.startKeyValue(e),Fr.addKey(e,y),Fr.addValue(e,S),Fr.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Xi.startField(e),Xi.addType(e,r),Xi.addTypeType(e,a),Xi.addChildren(e,l),Xi.addNullable(e,!!t.nullable),n!==-1&&Xi.addName(e,n),i!==-1&&Xi.addDictionary(e,i),u!==-1&&Xi.addCustomMetadata(e,u),Xi.endField(e)}function d$(e,t){const n=t.nodes||[],r=t.buffers||[];ma.startNodesVector(e,n.length);for(const a of n.slice().reverse())Wa.encode(e,a);const i=e.endVector();ma.startBuffersVector(e,r.length);for(const a of r.slice().reverse())js.encode(e,a);const s=e.endVector();return ma.startRecordBatch(e),ma.addLength(e,BigInt(t.length)),ma.addNodes(e,i),ma.addBuffers(e,s),ma.endRecordBatch(e)}function f$(e,t){const n=Mi.encode(e,t.data);return hl.startDictionaryBatch(e),hl.addId(e,BigInt(t.id)),hl.addIsDelta(e,t.isDelta),hl.addData(e,n),hl.endDictionaryBatch(e)}function h$(e,t){return Gw.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function p$(e,t){return zw.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const m$=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),Iy=e=>`Expected ${wn[e]} Message in stream, but was null or length 0.`,Ty=e=>`Header pointer of flatbuffer-encoded ${wn[e]} Message is null or length 0.`,WS=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,HS=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class qS{constructor(t){this.source=t instanceof qf?t:new qf(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?Lr:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Iy(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=dn(this.source.read(t));if(n.byteLength<t)throw new Error(HS(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=wn.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Ty(n));return i}readMetadataLength(){const t=this.source.read(Zf),n=t&&new fl(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return Lr;if(n.byteLength<t)throw new Error(WS(t,n.byteLength));return{done:!1,value:ui.decode(n)}}}class y${constructor(t,n){this.source=t instanceof Al?t:Dw(t)?new Xf(t,n):new Al(t)}[Symbol.asyncIterator](){return this}next(){return je(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?Lr:t})}throw(t){return je(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return je(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return je(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Iy(t));return n.value})}readMessageBody(t){return je(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=dn(yield this.source.read(t));if(n.byteLength<t)throw new Error(HS(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return je(this,arguments,void 0,function*(t=!1){const n=wn.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Ty(n));return i})}readMetadataLength(){return je(this,void 0,void 0,function*(){const t=yield this.source.read(Zf),n=t&&new fl(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return je(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return Lr;if(n.byteLength<t)throw new Error(WS(t,n.byteLength));return{done:!1,value:ui.decode(n)}})}}class g$ extends qS{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof RS?t:new RS(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:ui.fromJSON(t.schema,wn.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:ui.fromJSON(n,wn.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:ui.fromJSON(n,wn.RecordBatch)}}return this._body=[],Lr}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(Iy(t));return n.value}readSchema(){const t=wn.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(Ty(t));return r}}const Zf=4,Ay="ARROW1",Wc=new Uint8Array(Ay.length);for(let e=0;e<Ay.length;e+=1)Wc[e]=Ay.codePointAt(e);function xy(e,t=0){for(let n=-1,r=Wc.length;++n<r;)if(Wc[n]!==e[t+n])return!1;return!0}const Hc=Wc.length,XS=Hc+Zf,_$=Hc*2+Zf;class Ji extends my{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return wo(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Yi.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Yi.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Ji?t:Hm(t)?S$(t):Dw(t)?T$(t):wo(t)?je(this,void 0,void 0,function*(){return yield Ji.from(yield t)}):Fw(t)||qm(t)||Lw(t)||dl(t)?I$(new Al(t)):E$(new qf(t))}static readAll(t){return t instanceof Ji?t.isSync()?tE(t):eE(t):Hm(t)||ArrayBuffer.isView(t)||Mc(t)||Ow(t)?tE(t):eE(t)}}class th extends Ji{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ms(this,arguments,function*(){yield Je(yield*df(bo(this[Symbol.iterator]())))})}}class eh extends Ji{constructor(t){super(t),this._impl=t}readAll(){return je(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=bo(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const u=i;s.push(u)}}catch(u){n={error:u}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class KS extends th{constructor(t){super(t),this._impl=t}}class v$ extends eh{constructor(t){super(t),this._impl=t}}class QS{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=an({type:new oi(this.schema.fields),length:t.length,children:r});return new Ti(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),u=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new Fn(u)):new Fn(u)).memoize()}_loadVectors(t,n,r){return new DS(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class nh extends QS{constructor(t,n){super(n),this._reader=Hm(t)?new g$(this._handle=t):new qS(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=ZS(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Lr}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Lr}next(){if(this.closed)return Lr;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Sy(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class rh extends QS{constructor(t,n){super(n),this._reader=new y$(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return je(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return je(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=ZS(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return je(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Lr})}return(t){return je(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Lr})}next(){return je(this,void 0,void 0,function*(){if(this.closed)return Lr;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Sy(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return je(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class JS extends nh{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof BS?t:new BS(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(wn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(wn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-XS,r=t.readInt32(n),i=t.readAt(n-r,r);return zc.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class b$ extends rh{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof Xf?t:new Xf(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return je(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return je(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(wn.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return je(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(wn.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return je(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-XS,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return zc.decode(i)})}_readNextMessageAndValidate(t){return je(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class w$ extends nh{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new LP(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function ZS(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*tE(e){const t=Ji.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function eE(e){return Ms(this,arguments,function*(){const t=yield Je(Ji.from(e));try{if(!(yield Je(t.open({autoDestroy:!1}))).closed)do yield yield Je(t);while(!(yield Je(t.reset().open())).closed)}finally{yield Je(t.cancel())}})}function S$(e){return new th(new w$(e))}function E$(e){const t=e.peek(Hc+7&-8);return t&&t.byteLength>=4?xy(t)?new KS(new JS(e.read())):new th(new nh(e)):new th(new nh((function*(){})()))}function I$(e){return je(this,void 0,void 0,function*(){const t=yield e.peek(Hc+7&-8);return t&&t.byteLength>=4?xy(t)?new KS(new JS(yield e.read())):new eh(new rh(e)):new eh(new rh((function(){return Ms(this,arguments,function*(){})})()))})}function T$(e){return je(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new Xf(e,t);return t>=_$&&xy(yield n.readAt(0,Hc+7&-8))?new v$(new b$(n)):new eh(new rh(n))})}class fr extends en{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Ti?s.data.children:s.data),r=new fr;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof Fn)return this.visitMany(t.data),this;const{type:n}=t;if(!ue.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(ue.isUnion(n))this.nodes.push(new Wa(r,0));else{const{nullCount:i}=t;ue.isNull(n)||ms.call(this,i<=0?new Uint8Array(0):Vf(t.offset,r,t.nullBitmap)),this.nodes.push(new Wa(r,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function ms(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new js(this._byteLength,t)),this._byteLength+=t,this}function A$(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(ms.call(this,i),n.mode===Kr.Sparse)return Ry.call(this,e);if(n.mode===Kr.Dense){if(e.offset<=0)return ms.call(this,s),Ry.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let u,d,h=-1;++h<r;)(u=i[h])!==void 0&&((d=o[u])===void 0&&(d=o[u]=s[h]),a[h]=s[h]-d,l[u]=((t=l[u])!==null&&t!==void 0?t:0)+1);ms.call(this,a),this.visitMany(e.children.map((u,d)=>{const h=n.typeIds[d],y=o[h],S=l[h];return u.slice(y,Math.min(r,S))}))}}return this}function x$(e){let t;return e.nullCount>=e.length?ms.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?ms.call(this,Vf(e.offset,e.length,t)):ms.call(this,zf(e.values))}function wa(e){return ms.call(this,e.values.subarray(0,e.length*e.stride))}function ih(e){const{length:t,values:n,valueOffsets:r}=e,i=Xn(r[0]),s=Xn(r[t]),a=Math.min(s-i,n.byteLength-i);return ms.call(this,Uw(-i,t+1,r)),ms.call(this,n.subarray(i,i+a)),this}function Ny(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return ms.call(this,Uw(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Ry(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}fr.prototype.visitBool=x$,fr.prototype.visitInt=wa,fr.prototype.visitFloat=wa,fr.prototype.visitUtf8=ih,fr.prototype.visitLargeUtf8=ih,fr.prototype.visitBinary=ih,fr.prototype.visitLargeBinary=ih,fr.prototype.visitFixedSizeBinary=wa,fr.prototype.visitDate=wa,fr.prototype.visitTimestamp=wa,fr.prototype.visitTime=wa,fr.prototype.visitDecimal=wa,fr.prototype.visitList=Ny,fr.prototype.visitStruct=Ry,fr.prototype.visitUnion=A$,fr.prototype.visitInterval=wa,fr.prototype.visitDuration=wa,fr.prototype.visitFixedSizeList=Ny,fr.prototype.visitMap=Ny;class nE extends my{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Hf,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Si(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return wo(t)?t.then(n=>this.writeAll(n)):dl(t)?Fy(this,t):Dy(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof Hf?this._sink=t:(this._sink=new Hf,t&&i3(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&s3(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!by(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof ci&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof Ti&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!by(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof Ti?t instanceof Sy||this._writeRecordBatch(t):t instanceof ci?this.writeAll(t.batches):Mc(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=ui.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===wn.RecordBatch?this._recordBatchBlocks.push(new Ga(o,t.bodyLength,this._position)):t.headerType===wn.DictionaryBatch&&this._dictionaryBlocks.push(new Ga(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=dn(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(ui.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Wc)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=fr.assemble(t),a=new Mi(t.numRows,r,i),o=ui.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=fr.assemble(new Fn([t])),l=new Mi(t.length,s,a),u=new Gs(l,n,r),d=ui.from(u,i);return this._writeMessage(d)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[u,d]of a.entries())this._writeDictionaryBatch(d,i,u>0);else if(l<a.length)for(const u of a.slice(l))this._writeDictionaryBatch(u,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class By extends nE{static writeAll(t,n){const r=new By(n);return wo(t)?t.then(i=>r.writeAll(i)):dl(t)?Fy(r,t):Dy(r,t)}}class Oy extends nE{static writeAll(t){const n=new Oy;return wo(t)?t.then(r=>n.writeAll(r)):dl(t)?Fy(n,t):Dy(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=zc.encode(new zc(t,Er.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Dy(e,t){let n=t;t instanceof ci&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Fy(e,t){return je(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=bo(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const u=l;e.write(u)}}catch(u){a={error:u}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function N$(e,t="stream"){return(t==="stream"?By:Oy).writeAll(e).toUint8Array(!0)}var R$=Object.create,rE=Object.defineProperty,B$=Object.getOwnPropertyDescriptor,O$=Object.getOwnPropertyNames,D$=Object.getPrototypeOf,F$=Object.prototype.hasOwnProperty,L$=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),M$=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of O$(t))!F$.call(e,i)&&i!==n&&rE(e,i,{get:()=>t[i],enumerable:!(r=B$(t,i))||r.enumerable});return e},C$=(e,t,n)=>(n=e!=null?R$(D$(e)):{},M$(!e||!e.__esModule?rE(n,"default",{value:e,enumerable:!0}):n,e)),k$=L$((e,t)=>{t.exports=Worker}),iE=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(iE||{}),sE=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(sE||{}),aE=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(aE||{}),oE=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(oE||{}),lE=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(lE||{}),cE=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(cE||{}),U$=class{log(e){}},P$=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function $$(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function V$(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function z$(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function G$(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var uE=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(uE||{}),dE=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Ji.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new ci(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new Ly(this._bindings,this._conn,n),i=await Ji.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new fE(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=N$(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},Ly=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},fE=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Ji.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new ci(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Ly(this.bindings,this.connectionId,t),r=await Ji.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},hE=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(hE||{}),pE=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(pE||{}),fn=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function sh(e){switch(e.typeId){case F.Binary:return{sqlType:"binary"};case F.Bool:return{sqlType:"bool"};case F.Date:return{sqlType:"date"};case F.DateDay:return{sqlType:"date32[d]"};case F.DateMillisecond:return{sqlType:"date64[ms]"};case F.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case F.Float:return{sqlType:"float"};case F.Float16:return{sqlType:"float16"};case F.Float32:return{sqlType:"float32"};case F.Float64:return{sqlType:"float64"};case F.Int:return{sqlType:"int32"};case F.Int16:return{sqlType:"int16"};case F.Int32:return{sqlType:"int32"};case F.Int64:return{sqlType:"int64"};case F.Uint16:return{sqlType:"uint16"};case F.Uint32:return{sqlType:"uint32"};case F.Uint64:return{sqlType:"uint64"};case F.Uint8:return{sqlType:"uint8"};case F.IntervalDayTime:return{sqlType:"interval[dt]"};case F.IntervalYearMonth:return{sqlType:"interval[m]"};case F.List:return{sqlType:"list",valueType:sh(e.valueType)};case F.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case F.Null:return{sqlType:"null"};case F.Utf8:return{sqlType:"utf8"};case F.Struct:return{sqlType:"struct",fields:e.children.map(t=>My(t.name,t.type))};case F.Map:{let t=e;return{sqlType:"map",keyType:sh(t.keyType),valueType:sh(t.valueType)}}case F.Time:return{sqlType:"time[s]"};case F.TimeMicrosecond:return{sqlType:"time[us]"};case F.TimeMillisecond:return{sqlType:"time[ms]"};case F.TimeNanosecond:return{sqlType:"time[ns]"};case F.TimeSecond:return{sqlType:"time[s]"};case F.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case F.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case F.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case F.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case F.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function My(e,t){let n=sh(t);return n.name=e,n}var j$=new TextEncoder,Y$=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new fn("RESET",null);return await this.postTask(e)}async ping(){let e=new fn("PING",null);await this.postTask(e)}async dropFile(e){let t=new fn("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new fn("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new fn("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new fn("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new fn("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new fn("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new fn("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new fn("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new fn("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new dE(this,e)}async disconnect(e){let t=new fn("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new fn("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new fn("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new fn("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new fn("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new fn("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new fn("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new fn("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new fn("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new fn("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new fn("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new fn("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=j$.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new fn("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new fn("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new fn("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new fn("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new fn("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new fn("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new fn("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new fn("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new fn("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(My(s,a))}n.columnsFlat=i,delete n.columns}let r=new fn("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(My(s,a))}n.columnsFlat=i,delete n.columns}let r=new fn("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function W$(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}W$();var mE=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(mE||{}),H$=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},q$=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),X$=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),K$=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),Q$=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Cy={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},yE=Cy.name,gE=Cy.version,ky=Cy.version.split("."),J$=ky[0],Z$=ky[1],t8=ky[2],Uy=()=>typeof navigator>"u",_E=()=>Uy()?"node":navigator.userAgent,e8=()=>_E().includes("Firefox"),n8=()=>/^((?!chrome|android).)*safari/i.test(_E());function r8(){let e="https://cdn.jsdelivr.net/npm/".concat(yE,"@").concat(gE,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Py=null,$y=null,Vy=null,zy=null,Gy=null;async function vE(){return Py==null&&(Py=typeof BigInt64Array<"u"),$y==null&&($y=await X$()),Vy==null&&(Vy=await Q$()),zy==null&&(zy=await K$()),Gy==null&&(Gy=await q$()),{bigInt64Array:Py,crossOriginIsolated:Uy()||globalThis.crossOriginIsolated||!1,wasmExceptions:$y,wasmSIMD:zy,wasmThreads:Vy,wasmBulkMemory:Gy}}async function i8(e){let t=await vE();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var s8=C$(k$());async function a8(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new s8.default(r)}const o8=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:Y$,AsyncDuckDBConnection:dE,AsyncDuckDBDispatcher:H$,AsyncPreparedStatement:fE,AsyncResultStreamIterator:Ly,ConsoleLogger:P$,DuckDBAccessMode:iE,DuckDBDataProtocol:mE,LogEvent:lE,LogLevel:aE,LogOrigin:cE,LogTopic:oE,PACKAGE_NAME:yE,PACKAGE_VERSION:gE,PACKAGE_VERSION_MAJOR:J$,PACKAGE_VERSION_MINOR:Z$,PACKAGE_VERSION_PATCH:t8,StatusCode:uE,TokenType:sE,VoidLogger:U$,WorkerRequestType:hE,WorkerResponseType:pE,WorkerTask:fn,createWorker:a8,getJsDelivrBundles:r8,getLogEventLabel:V$,getLogLevelLabel:$$,getLogOriginLabel:G$,getLogTopicLabel:z$,getPlatformFeatures:vE,isFirefox:e8,isNode:Uy,isSafari:n8,selectBundle:i8},Symbol.toStringTag,{value:"Module"}));async function l8(){var e,t,n;const r="@aws-amplify/auth";let i;try{i=await import(r)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:s}=i,a=await s();return{token:((n=(t=(e=a==null?void 0:a.tokens)==null?void 0:e.idToken)==null?void 0:t.toString)==null?void 0:n.call(t))??null,provider:"amplify"}}const bE=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:l8},Symbol.toStringTag,{value:"Module"}));pi.DataExplorer=QN,pi.GeneExpression=tU,pi.GeneXDistribution=t3,pi.ProportionPlot=eR,pi.SideBySide=FU,pi.UMAP=ZN,Object.defineProperty(pi,Symbol.toStringTag,{value:"Module"})}));