precision-dashwidgets 0.1.2 → 0.2.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,21 +1,17 @@
1
- (function(Xt,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue"),require("element-plus"),require("pinia"),require("@aws-amplify/auth")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia","@aws-amplify/auth"],f):(Xt=typeof globalThis<"u"?globalThis:Xt||self,f(Xt["precision-dashwidgets"]={},Xt.Vue,Xt.ElementPlus,Xt.Pinia,Xt.aws_amplify_auth))})(this,(function(Xt,f,_u,bu,vu){"use strict";/*! Element Plus Icons Vue v2.3.2 */var wu=f.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(f.openBlock(),f.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[f.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"})]))}}),Iu=wu;function gt(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function ze(e){return function t(n){return arguments.length===0||gt(n)?t:e.apply(this,arguments)}}function Ye(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return gt(n)?t:ze(function(i){return e(n,i)});default:return gt(n)&&gt(r)?t:gt(n)?ze(function(i){return e(i,r)}):gt(r)?ze(function(i){return e(n,i)}):e(n,r)}}}function Su(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return gt(n)?t:Ye(function(s,o){return e(n,s,o)});case 2:return gt(n)&&gt(r)?t:gt(n)?Ye(function(s,o){return e(s,r,o)}):gt(r)?Ye(function(s,o){return e(n,s,o)}):ze(function(s){return e(n,r,s)});default:return gt(n)&&gt(r)&&gt(i)?t:gt(n)&&gt(r)?Ye(function(s,o){return e(s,o,i)}):gt(n)&&gt(i)?Ye(function(s,o){return e(s,r,o)}):gt(r)&&gt(i)?Ye(function(s,o){return e(n,s,o)}):gt(n)?ze(function(s){return e(s,r,i)}):gt(r)?ze(function(s){return e(n,s,i)}):gt(i)?ze(function(s){return e(n,r,s)}):e(n,r,i)}}}const Eu=Number.isInteger||function(e){return e<<0===e};function Tu(e,t){var n=e<0?t.length+e:e;return t[n]}var Au=Ye(function(e,t){return t==null||t!==t?e:t});function Nu(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];Eu(i)?n=Tu(i,n):n=n[i]}return n}var Ru=Su(function(e,t,n){return Au(e,Nu(t,n))});const Bu=bu.defineStore("duckdb",()=>{const e=f.ref(null),t=f.ref(!1),n=f.ref(!1),r=f.ref(""),i=f.ref(new Map),s=f.ref(new Map),o=f.ref(new Map),a=f.computed(()=>t.value&&!r.value),c=f.computed(()=>R=>i.value.get(R)),l=f.computed(()=>R=>{const B=i.value.get(R);return B&&!B.isLoading&&!B.error}),u=f.computed(()=>s.value.size),d=f.computed(()=>s.value.size>0),y=async()=>{if(t.value||n.value)return e.value;n.value=!0,r.value="";try{const R=await Promise.resolve().then(()=>z_),B={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"}},N=await R.selectBundle(B),V=new Worker(N.mainWorker),j=new R.ConsoleLogger(R.LogLevel.WARNING);return e.value=new R.AsyncDuckDB(j,V),await e.value.instantiate(N.mainModule),t.value=!0,e.value}catch(R){throw console.error("Failed to initialize DuckDB:",R),r.value=`Failed to initialize DuckDB: ${R.message}`,R}finally{n.value=!1}},m=async(R=null)=>{a.value||await y();const B=await e.value.connect(),N=R||`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return s.value.set(N,{connection:B,viewerId:N,createdAt:new Date}),{connection:B,connectionId:N}},b=async R=>{const B=s.value.get(R);B&&(await B.connection.close(),s.value.delete(R),T(R),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},T=R=>{for(const[B,N]of o.value)N.delete(R),N.size===0&&console.log(`File ${B} is no longer used by any viewers`)},S=(R,B)=>{o.value.has(R)||o.value.set(R,new Set),o.value.get(R).add(B)},_=async R=>{const B=i.value.get(R);if(B&&B.tableName)try{const N=await e.value.connect();await N.query(`DROP TABLE IF EXISTS ${B.tableName};`),await N.close()}catch(N){console.warn(`Failed to drop table ${B.tableName}:`,N)}i.value.delete(R),o.value.delete(R)},W=async(R,B,N="my_data",V={},j=null,G=null)=>{const lt=G||R,bt=i.value.get(lt);if(bt&&!bt.isLoading&&!bt.error)return j&&S(lt,j),bt.tableName;a.value||await y(),i.value.set(lt,{tableName:N,fileType:B,fileUrl:R,isLoading:!0,error:null});try{const ut=await fetch(R);if(!ut.ok)throw new Error(`Failed to fetch file: ${ut.status} ${ut.statusText}`);let g;if(B==="csv"){const v=await ut.text(),I=await new Blob([v],{type:"text/csv"}).arrayBuffer();g=new Uint8Array(I)}else{const v=await ut.arrayBuffer();g=new Uint8Array(v)}const w=`${G||N}.${B}`;await e.value.registerFileBuffer(w,g);const h=await e.value.connect();try{let v;if(B==="csv"){const E={header:!0,delimiter:",",...V};v=`
2
- CREATE OR REPLACE TABLE ${N} AS
3
- SELECT * FROM read_csv('${w}', header=${E.header}, delim='${E.delimiter}');
4
- `}else if(B==="parquet")v=`
5
- CREATE OR REPLACE TABLE ${N} AS
6
- SELECT * FROM read_parquet('${w}');
7
- `;else throw new Error(`Unsupported file type: ${B}`);await h.query(v);const I=(await h.query(`SELECT COUNT(*) as count FROM ${N};`)).toArray()[0].count;return i.value.set(lt,{tableName:N,fileType:B,fileUrl:R,isLoading:!1,error:null,rowCount:I,loadedAt:new Date}),j&&S(lt,j),N}finally{await h.close()}}catch(ut){throw i.value.set(lt,{tableName:N,fileType:B,fileUrl:R,isLoading:!1,error:ut.message}),ut}},Z=async(R,B)=>{const N=s.value.get(B);if(!N)throw new Error(`Connection not found: ${B}`);return(await N.connection.query(R)).toArray().map(V=>{const j={};for(const[G,lt]of Object.entries(V))j[G]=lt;return j})},It=async()=>{for(const[R,B]of s.value)try{await B.connection.close(),console.log(`Closed connection: ${R}`)}catch(N){console.warn(`Error closing connection ${R}:`,N)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(R){console.warn("Error terminating DuckDB:",R)}e.value=null}t.value=!1,i.value.clear(),o.value.clear(),r.value=""};return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:o,isReady:a,getLoadedFile:c,isFileLoaded:l,activeConnectionCount:u,hasActiveConnections:d,initDuckDB:y,createConnection:m,closeConnection:b,cleanupViewerFileUsage:T,trackFileUsage:S,unloadFile:_,loadFile:W,executeQuery:Z,cleanup:async(R=!1)=>{R||s.value.size===0?await It():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},performGlobalCleanup:It,getConnectionInfo:()=>{const R=[];for(const[B,N]of s.value)R.push({connectionId:B,viewerId:N.viewerId,createdAt:N.createdAt});return R},getFileUsageInfo:()=>{const R=[];for(const[B,N]of o.value){const V=i.value.get(B);R.push({fileId:B,tableName:V?.tableName,fileType:V?.fileType,fileUrl:V?.fileUrl,rowCount:V?.rowCount,loadedAt:V?.loadedAt,usedByViewers:Array.from(N)})}return R}}}),Dn=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Ou={class:"dashboard-container"},Du={class:"dashboard-header"},Lu={class:"dashboard-content"},Fu={key:0,class:"query-panel"},Mu={class:"query-examples"},Uu=["onClick"],xu={key:1,class:"results-panel"},Cu={class:"results-controls"},$u={class:"left-controls"},ku={class:"right-controls"},Pu={key:0,class:"table-container"},Vu={class:"results-table"},zu={key:0,class:"bottom-pagination"},Yu={key:1,class:"json-container"},ju={key:2,class:"error-panel"},qu={__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}},setup(e){const t=e,n=Bu(),r=f.ref({header:!0,dynamicTyping:!0,delimiter:","}),i=f.ref(!1),s=f.ref(!1),o=f.ref(t.url),a=f.ref("my_data"),c=f.ref(""),l=f.ref(null),u=f.ref(""),d=f.ref("table"),y=f.ref(1),m=f.ref(50),b=f.ref(null);f.watch(()=>t.url,async w=>{if(o.value=w,w)try{await B(),await V()}catch{console.error("file can not be loaded")}},{immediate:!0});const T=f.computed(()=>n.isReady&&b.value&&!i.value),S=f.computed(()=>i.value?"Loading...":n.isInitializing?"Initializing...":n.isReady?T.value?"Connected":"Not Connected":"Not Ready"),_=f.computed(()=>!l.value||!Array.isArray(l.value)||l.value.length===0?[]:Object.keys(l.value[0]||{})),W=f.computed(()=>!l.value||!Array.isArray(l.value)?0:Math.ceil(l.value.length/m.value)),Z=f.computed(()=>{if(!l.value||!Array.isArray(l.value))return[];const w=(y.value-1)*m.value,h=w+m.value;return l.value.slice(w,h)}),It=f.computed(()=>[{name:"Show All",query:"SELECT * FROM data LIMIT 100;"},{name:"Count Rows",query:"SELECT COUNT(*) as row_count FROM data;"},{name:"Group By",query:`SELECT
1
+ (function(te,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("element-plus"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia"],h):(te=typeof globalThis<"u"?globalThis:te||self,h(te["precision-dashwidgets"]={},te.Vue,te.ElementPlus,te.Pinia))})(this,function(te,h,Pc,Vc){"use strict";/*! Element Plus Icons Vue v2.3.2 */var zc=h.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(h.openBlock(),h.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[h.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"})]))}}),jc=zc;function ft(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Ce(e){return function t(n){return arguments.length===0||ft(n)?t:e.apply(this,arguments)}}function ke(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:Ce(function(i){return e(n,i)});default:return ft(n)&&ft(r)?t:ft(n)?Ce(function(i){return e(i,r)}):ft(r)?Ce(function(i){return e(n,i)}):e(n,r)}}}function Yc(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:ke(function(s,a){return e(n,s,a)});case 2:return ft(n)&&ft(r)?t:ft(n)?ke(function(s,a){return e(s,r,a)}):ft(r)?ke(function(s,a){return e(n,s,a)}):Ce(function(s){return e(n,r,s)});default:return ft(n)&&ft(r)&&ft(i)?t:ft(n)&&ft(r)?ke(function(s,a){return e(s,a,i)}):ft(n)&&ft(i)?ke(function(s,a){return e(s,r,a)}):ft(r)&&ft(i)?ke(function(s,a){return e(n,s,a)}):ft(n)?Ce(function(s){return e(s,r,i)}):ft(r)?Ce(function(s){return e(n,s,i)}):ft(i)?Ce(function(s){return e(n,r,s)}):e(n,r,i)}}}const Wc=Number.isInteger||function(e){return e<<0===e};function qc(e,t){var n=e<0?t.length+e:e;return t[n]}var Gc=ke(function(e,t){return t==null||t!==t?e:t});function Hc(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];Wc(i)?n=qc(i,n):n=n[i]}return n}var Kc=Yc(function(e,t,n){return Gc(e,Hc(t,n))});const js=Vc.defineStore("duckdb",()=>{const e=h.ref(null),t=h.ref(!1),n=h.ref(!1),r=h.ref(""),i=h.ref(new Map),s=h.ref(new Map),a=h.ref(new Map);let o=null;const l=h.computed(()=>t.value&&!r.value),c=h.computed(()=>R=>i.value.get(R)),d=h.computed(()=>R=>{const F=i.value.get(R);return F&&!F.isLoading&&!F.error}),y=h.computed(()=>s.value.size),_=h.computed(()=>s.value.size>0),v=async()=>{if(typeof window>"u"||typeof Worker>"u"){const R="DuckDB can only be initialized in the browser.";throw r.value=R,new Error(R)}return e.value?e.value:o?(await o,e.value):(n.value=!0,r.value="",o=(async()=>{try{const R=await Promise.resolve().then(()=>bb),F={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"}},p=await R.selectBundle(F),g=new Worker(p.mainWorker),u=new R.ConsoleLogger(R.LogLevel.WARNING);return e.value=new R.AsyncDuckDB(u,g),await e.value.instantiate(p.mainModule),t.value=!0,e.value}catch(R){throw r.value=`Failed to initialize DuckDB: ${(R==null?void 0:R.message)||R}`,e.value=null,R}finally{n.value=!1,o=null}})(),await o,e.value)},E=async R=>{e.value||await v();const F=await e.value.connect(),p=R||`conn_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;return s.value.set(p,{connection:F,viewerId:p,createdAt:new Date}),{connection:F,connectionId:p}},T=async R=>{const F=s.value.get(R);F&&(await F.connection.close(),s.value.delete(R),N(R),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},N=R=>{for(const[F,p]of a.value)p.delete(R),p.size===0&&console.log(`File ${F} is no longer used by any viewers`)},B=(R,F)=>{a.value.has(R)||a.value.set(R,new Set),a.value.get(R).add(F)},Q=async R=>{const F=i.value.get(R);if(F&&F.tableName)try{const p=await e.value.connect();await p.query(`DROP TABLE IF EXISTS ${F.tableName};`),await p.close()}catch(p){console.warn(`Failed to drop table ${F.tableName}:`,p)}i.value.delete(R),a.value.delete(R)},it=async(R,F,p="my_data",g={},u=null,m=null)=>{const b=m||R,w=i.value.get(b);if(w&&!w.isLoading&&!w.error)return u&&B(b,u),w.tableName;l.value||await v(),i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!0,error:null});try{const I=await fetch(R);if(!I.ok)throw new Error(`Failed to fetch file: ${I.status} ${I.statusText}`);let S;if(F==="csv"){const M=await I.text(),J=await new Blob([M],{type:"text/csv"}).arrayBuffer();S=new Uint8Array(J)}else{const M=await I.arrayBuffer();S=new Uint8Array(M)}const O=`${m||p}.${F}`;await e.value.registerFileBuffer(O,S);const A=await e.value.connect();try{let M;if(F==="csv"){const st={header:!0,delimiter:",",...g};M=`
2
+ CREATE OR REPLACE TABLE ${p} AS
3
+ SELECT * FROM read_csv('${O}', header=${st.header}, delim='${st.delimiter}');
4
+ `}else if(F==="parquet")M=`
5
+ CREATE OR REPLACE TABLE ${p} AS
6
+ SELECT * FROM read_parquet('${O}');
7
+ `;else throw new Error(`Unsupported file type: ${F}`);await A.query(M);const J=(await A.query(`SELECT COUNT(*) as count FROM ${p};`)).toArray()[0].count;return i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!1,error:null,rowCount:J,loadedAt:new Date}),u&&B(b,u),p}finally{await A.close()}}catch(I){throw i.value.set(b,{tableName:p,fileType:F,fileUrl:R,isLoading:!1,error:I.message}),I}},mt=async(R,F)=>{const p=s.value.get(F);if(!p)throw new Error(`Connection not found: ${F}`);return(await p.connection.query(R)).toArray().map(g=>{const u={};for(const[m,b]of Object.entries(g))u[m]=b;return u})},bt=async()=>{for(const[R,F]of s.value)try{await F.connection.close(),console.log(`Closed connection: ${R}`)}catch(p){console.warn(`Error closing connection ${R}:`,p)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(R){console.warn("Error terminating DuckDB:",R)}e.value=null}t.value=!1,i.value.clear(),a.value.clear(),r.value=""},gt=async(R=!1)=>{R||s.value.size===0?await bt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},It=()=>{const R=[];for(const[F,p]of s.value)R.push({connectionId:F,viewerId:p.viewerId,createdAt:p.createdAt});return R},$t=()=>{const R=[];for(const[F,p]of a.value){const g=i.value.get(F);R.push({fileId:F,tableName:g==null?void 0:g.tableName,fileType:g==null?void 0:g.fileType,fileUrl:g==null?void 0:g.fileUrl,rowCount:g==null?void 0:g.rowCount,loadedAt:g==null?void 0:g.loadedAt,usedByViewers:Array.from(p)})}return R},dt=h.ref(null),ht=h.ref(0);function Zt(R){return`"${String(R).replace(/"/g,'""')}"`}return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:a,sharedResultName:dt,sharedVersion:ht,isReady:l,getLoadedFile:c,isFileLoaded:d,activeConnectionCount:y,hasActiveConnections:_,initDuckDB:v,createConnection:E,closeConnection:T,cleanupViewerFileUsage:N,trackFileUsage:B,unloadFile:Q,loadFile:it,executeQuery:mt,cleanup:gt,performGlobalCleanup:bt,getConnectionInfo:It,getFileUsageInfo:$t,publishViewFromQuery:async(R,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE VIEW ${Zt(R)} AS ${F}`),dt.value=R,ht.value++},publishTableFromQuery:async(R,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE TABLE ${Zt(R)} AS ${F}`),dt.value=R,ht.value++}}}),Sn=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Qc={class:"dashboard-container"},Xc={class:"dashboard-header"},Jc={class:"dashboard-content"},Zc={key:0,class:"query-panel"},tu={class:"query-examples"},eu=["onClick"],nu={key:1,class:"results-panel"},ru={class:"results-controls"},iu={class:"left-controls"},su={class:"right-controls"},au={key:0,class:"table-container"},ou={class:"results-table"},lu={key:0,class:"bottom-pagination"},cu={key:1,class:"json-container"},uu={key:2,class:"error-panel"},hu={__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=js(),s=h.ref({header:!0,dynamicTyping:!0,delimiter:","}),a=h.ref(!1),o=h.ref(!1),l=h.ref(n.url),c=h.ref("my_data"),d=h.ref(""),y=h.ref(null),_=h.ref(""),v=h.ref("table"),E=h.ref(1),T=h.ref(50),N=h.ref(null);h.watch(()=>n.url,async m=>{if(l.value=m,m)try{await $t(),await ht()}catch{console.error("file can not be loaded")}},{immediate:!0});const B=h.computed(()=>i.isReady&&N.value&&!a.value),Q=h.computed(()=>a.value?"Loading...":i.isInitializing?"Initializing...":i.isReady?B.value?"Connected":"Not Connected":"Not Ready"),it=h.computed(()=>!y.value||!Array.isArray(y.value)||y.value.length===0?[]:Object.keys(y.value[0]||{})),mt=h.computed(()=>!y.value||!Array.isArray(y.value)?0:Math.ceil(y.value.length/T.value)),bt=h.computed(()=>{if(!y.value||!Array.isArray(y.value))return[];const m=(E.value-1)*T.value,b=m+T.value;return y.value.slice(m,b)}),gt=h.computed(()=>[{name:"Show All",query:"SELECT * FROM data LIMIT 100;"},{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);"}]);f.computed(()=>({viewerId:t.viewerId,fileId:t.fileId,connectionId:b.value,tableName:a.value,isConnected:T.value,activeConnections:n.activeConnectionCount,hasActiveConnections:n.hasActiveConnections}));const R=async()=>{try{const{connection:w,connectionId:h}=await n.createConnection(t.viewerId);b.value=h,o.value&&(await B(),V())}catch(w){console.error("Failed to initialize viewer:",w),u.value=`Failed to initialize: ${w.message}`}},B=async()=>{if(!o.value){u.value="Please provide a valid S3 URL";return}const w=t.fileId||o.value,h=n.getLoadedFile(w);if(h&&!h.isLoading&&!h.error){a.value=h.tableName,lt("SELECT * FROM data LIMIT 10;");return}i.value=!0,u.value="";try{const v=t.fileId?`file_${t.fileId}`:`data_${Date.now()}`,I=await n.loadFile(o.value,t.fileType,v,r.value,t.viewerId,t.fileId);a.value=I,lt("SELECT * FROM data LIMIT 10;")}catch{}finally{i.value=!1}},N=w=>!a.value||!w?w:w.replace(/\bFROM\s+data\b/gi,`FROM ${a.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${a.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${a.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${a.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${a.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${a.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${a.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${a.value})`),V=async()=>{if(!c.value||!b.value){u.value="Please provide a valid SQL query";return}if(!a.value){u.value="No data table loaded";return}s.value=!0,u.value="",y.value=1;try{const w=N(c.value.trim());l.value=await n.executeQuery(w,b.value)}catch(w){console.error("Query execution failed:",w),u.value=`Query execution failed: ${w.message}`,l.value=null}finally{s.value=!1}},j=w=>{y.value=w},G=w=>{m.value=w,y.value=1},lt=w=>{c.value=w},bt=w=>w==null?"NULL":typeof w=="number"?Number.isInteger(w)?w.toString():w.toFixed(4):typeof w=="string"&&w.length>100?w.substring(0,100)+"...":w.toString(),ut=()=>{if(!l.value||l.value.length===0)return;const w=Object.keys(l.value[0]),h=[w.join(","),...l.value.map(A=>w.map(D=>{const K=A[D],ft=K==null?"":K.toString();return ft.includes(",")?`"${ft}"`:ft}).join(","))].join(`
14
- `),v=new Blob([h],{type:"text/csv"}),I=URL.createObjectURL(v),E=document.createElement("a");E.href=I,E.download="query-results.csv",E.click(),URL.revokeObjectURL(I)},g=()=>{u.value=""};return f.onMounted(async()=>{await R()}),f.onUnmounted(async()=>{b.value&&(n.activeConnectionCount,n.loadedFiles.size,await n.closeConnection(b.value),n.activeConnectionCount,n.loadedFiles.size)}),(w,h)=>{const v=f.resolveComponent("bf-button"),I=f.resolveComponent("el-pagination");return f.openBlock(),f.createElementBlock("div",Ou,[f.createElementVNode("header",Du,[h[3]||(h[3]=f.createElementVNode("h1",null,"Data Explorer",-1)),f.createElementVNode("div",{class:f.normalizeClass(["status-indicator",{connected:T.value,loading:i.value}])},f.toDisplayString(S.value),3)]),f.createElementVNode("div",Lu,[T.value?(f.openBlock(),f.createElementBlock("div",Fu,[h[5]||(h[5]=f.createElementVNode("h3",null,"SQL Query",-1)),f.createElementVNode("div",Mu,[h[4]||(h[4]=f.createElementVNode("span",null,"Quick queries:",-1)),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(It.value,E=>(f.openBlock(),f.createElementBlock("button",{key:E.name,onClick:A=>lt(E.query),class:"example-btn"},f.toDisplayString(E.name),9,Uu))),128))]),f.withDirectives(f.createElementVNode("textarea",{"onUpdate:modelValue":h[0]||(h[0]=E=>c.value=E),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[f.vModelText,c.value]]),f.createVNode(v,{onClick:V,disabled:s.value||!c.value},{default:f.withCtx(()=>[f.createTextVNode(f.toDisplayString(s.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):f.createCommentVNode("",!0),l.value?(f.openBlock(),f.createElementBlock("div",xu,[f.createElementVNode("h3",null,"Results ("+f.toDisplayString(l.value.length)+" rows)",1),f.createElementVNode("div",Cu,[f.createElementVNode("div",$u,[f.createVNode(v,{class:"secondary",onClick:ut},{default:f.withCtx(()=>[...h[6]||(h[6]=[f.createTextVNode("Export to CSV",-1)])]),_:1})]),f.createElementVNode("div",ku,[d.value==="table"&&W.value>1?(f.openBlock(),f.createBlock(I,{key:0,"current-page":y.value,"onUpdate:currentPage":h[1]||(h[1]=E=>y.value=E),"page-size":m.value,total:l.value.length,layout:"prev, pager, next",onCurrentChange:j,class:"results-pagination"},null,8,["current-page","page-size","total"])):f.createCommentVNode("",!0)])]),h[7]||(h[7]=f.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),d.value==="table"?(f.openBlock(),f.createElementBlock("div",Pu,[f.createElementVNode("table",Vu,[f.createElementVNode("thead",null,[f.createElementVNode("tr",null,[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(_.value,E=>(f.openBlock(),f.createElementBlock("th",{key:E},f.toDisplayString(E),1))),128))])]),f.createElementVNode("tbody",null,[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(Z.value,(E,A)=>(f.openBlock(),f.createElementBlock("tr",{key:A},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(_.value,D=>(f.openBlock(),f.createElementBlock("td",{key:D},f.toDisplayString(bt(E[D])),1))),128))]))),128))])]),W.value>1?(f.openBlock(),f.createElementBlock("div",zu,[f.createVNode(I,{"current-page":y.value,"onUpdate:currentPage":h[2]||(h[2]=E=>y.value=E),"page-size":m.value,total:l.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:j,onSizeChange:G},null,8,["current-page","page-size","total"])])):f.createCommentVNode("",!0)])):(f.openBlock(),f.createElementBlock("div",Yu,[f.createElementVNode("pre",null,f.toDisplayString(JSON.stringify(l.value.slice(0,100),null,2)),1)]))])):f.createCommentVNode("",!0),u.value?(f.openBlock(),f.createElementBlock("div",ju,[h[8]||(h[8]=f.createElementVNode("h3",null,"Error",-1)),f.createElementVNode("p",null,f.toDisplayString(u.value),1),f.createElementVNode("button",{onClick:g,class:"clear-error-btn"},"Clear")])):f.createCommentVNode("",!0)])])}}},Gu=Dn(qu,[["__scopeId","data-v-6635a757"]]),Wu={class:"app-container"},Hu=f.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=f.ref([]),r=f.ref(""),i=f.ref("parquet"),s=f.ref("");f.onMounted(async()=>{if(t.srcUrl){r.value=t.srcUrl,i.value=t.srcFileType??(t.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),s.value=t.srcFileId??"url_"+btoa(t.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const l=Ru("",["content","id"],t.pkg);if(!l||!t.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await a(l);const u=n.value?.[0]?.content?.id;if(!u){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}s.value=u,r.value=await c(l,u);const d=t.pkg?.content?.packageType;i.value=d==="CSV"?"csv":"parquet"}catch(u){console.error(u)}});async function o(){const{useGetToken:l}=await Promise.resolve().then(()=>cu);return l()}async function a(l){const u=await o(),d=`${t.apiUrl}/packages/${l}/view?api_key=${u}`,y=await fetch(d);if(!y.ok)throw new Error(`view failed: ${y.status}`);n.value=await y.json()}async function c(l,u){const d=await o(),y=`${t.apiUrl}/packages/${l}/files/${u}?api_key=${d}`,m=await fetch(y);if(!m.ok)throw new Error(`file url failed: ${m.status}`);return(await m.json()).url}return(l,u)=>(f.openBlock(),f.createElementBlock("div",Wu,[f.createVNode(Gu,{url:r.value,"file-type":i.value,"file-id":s.value},null,8,["url","file-type","file-id"])]))}}),Ku=Dn(Hu,[["__scopeId","data-v-0974a90e"]]);var Qu={value:()=>{}};function Di(){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 hr(n)}function hr(e){this._=e}function Xu(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}})}hr.prototype=Di.prototype={constructor:hr,on:function(e,t){var n=this._,r=Xu(e+"",n),i,s=-1,o=r.length;if(arguments.length<2){for(;++s<o;)if((i=(e=r[s]).type)&&(i=Ju(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<o;)if(i=(e=r[s]).type)n[i]=no(n[i],e.name,t);else if(t==null)for(i in n)n[i]=no(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 hr(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 Ju(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function no(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Qu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Li="http://www.w3.org/1999/xhtml";const ro={svg:"http://www.w3.org/2000/svg",xhtml:Li,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function dr(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),ro.hasOwnProperty(t)?{space:ro[t],local:e}:e}function Zu(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Li&&t.documentElement.namespaceURI===Li?t.createElement(e):t.createElementNS(n,e)}}function th(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function io(e){var t=dr(e);return(t.local?th:Zu)(t)}function eh(){}function Fi(e){return e==null?eh:function(){return this.querySelector(e)}}function nh(e){typeof e!="function"&&(e=Fi(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=new Array(o),c,l,u=0;u<o;++u)(c=s[u])&&(l=e.call(c,c.__data__,u,s))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new kt(r,this._parents)}function rh(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ih(){return[]}function so(e){return e==null?ih:function(){return this.querySelectorAll(e)}}function sh(e){return function(){return rh(e.apply(this,arguments))}}function oh(e){typeof e=="function"?e=sh(e):e=so(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var o=t[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new kt(r,i)}function oo(e){return function(){return this.matches(e)}}function ao(e){return function(t){return t.matches(e)}}var ah=Array.prototype.find;function lh(e){return function(){return ah.call(this.children,e)}}function ch(){return this.firstElementChild}function uh(e){return this.select(e==null?ch:lh(typeof e=="function"?e:ao(e)))}var hh=Array.prototype.filter;function dh(){return Array.from(this.children)}function fh(e){return function(){return hh.call(this.children,e)}}function ph(e){return this.selectAll(e==null?dh:fh(typeof e=="function"?e:ao(e)))}function yh(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new kt(r,this._parents)}function lo(e){return new Array(e.length)}function mh(){return new kt(this._enter||this._groups.map(lo),this._parents)}function fr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}fr.prototype={constructor:fr,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 gh(e){return function(){return e}}function _h(e,t,n,r,i,s){for(var o=0,a,c=t.length,l=s.length;o<l;++o)(a=t[o])?(a.__data__=s[o],r[o]=a):n[o]=new fr(e,s[o]);for(;o<c;++o)(a=t[o])&&(i[o]=a)}function bh(e,t,n,r,i,s,o){var a,c,l=new Map,u=t.length,d=s.length,y=new Array(u),m;for(a=0;a<u;++a)(c=t[a])&&(y[a]=m=o.call(c,c.__data__,a,t)+"",l.has(m)?i[a]=c:l.set(m,c));for(a=0;a<d;++a)m=o.call(e,s[a],a,s)+"",(c=l.get(m))?(r[a]=c,c.__data__=s[a],l.delete(m)):n[a]=new fr(e,s[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(y[a])===c&&(i[a]=c)}function vh(e){return e.__data__}function wh(e,t){if(!arguments.length)return Array.from(this,vh);var n=t?bh:_h,r=this._parents,i=this._groups;typeof e!="function"&&(e=gh(e));for(var s=i.length,o=new Array(s),a=new Array(s),c=new Array(s),l=0;l<s;++l){var u=r[l],d=i[l],y=d.length,m=Ih(e.call(u,u&&u.__data__,l,r)),b=m.length,T=a[l]=new Array(b),S=o[l]=new Array(b),_=c[l]=new Array(y);n(u,d,T,S,_,m,t);for(var W=0,Z=0,It,R;W<b;++W)if(It=T[W]){for(W>=Z&&(Z=W+1);!(R=S[Z])&&++Z<b;);It._next=R||null}}return o=new kt(o,r),o._enter=a,o._exit=c,o}function Ih(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Sh(){return new kt(this._exit||this._groups.map(lo),this._parents)}function Eh(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 Th(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,o=Math.min(i,s),a=new Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,y=a[c]=new Array(d),m,b=0;b<d;++b)(m=l[b]||u[b])&&(y[b]=m);for(;c<i;++c)a[c]=n[c];return new kt(a,this._parents)}function Ah(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],o;--i>=0;)(o=r[i])&&(s&&o.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(o,s),s=o);return this}function Nh(e){e||(e=Rh);function t(d,y){return d&&y?e(d.__data__,y.__data__):!d-!y}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var o=n[s],a=o.length,c=i[s]=new Array(a),l,u=0;u<a;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new kt(i,this._parents).order()}function Rh(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Bh(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Oh(){return Array.from(this)}function Dh(){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 o=r[i];if(o)return o}return null}function Lh(){let e=0;for(const t of this)++e;return e}function Fh(){return!this.node()}function Mh(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,o=i.length,a;s<o;++s)(a=i[s])&&e.call(a,a.__data__,s,i);return this}function Uh(e){return function(){this.removeAttribute(e)}}function xh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ch(e,t){return function(){this.setAttribute(e,t)}}function $h(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function kh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Ph(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 Vh(e,t){var n=dr(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?xh:Uh:typeof t=="function"?n.local?Ph:kh:n.local?$h:Ch)(n,t))}function co(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function zh(e){return function(){this.style.removeProperty(e)}}function Yh(e,t,n){return function(){this.style.setProperty(e,t,n)}}function jh(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function qh(e,t,n){return arguments.length>1?this.each((t==null?zh:typeof t=="function"?jh:Yh)(e,t,n??"")):nn(this.node(),e)}function nn(e,t){return e.style.getPropertyValue(t)||co(e).getComputedStyle(e,null).getPropertyValue(t)}function Gh(e){return function(){delete this[e]}}function Wh(e,t){return function(){this[e]=t}}function Hh(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Kh(e,t){return arguments.length>1?this.each((t==null?Gh:typeof t=="function"?Hh:Wh)(e,t)):this.node()[e]}function uo(e){return e.trim().split(/^|\s+/)}function Mi(e){return e.classList||new ho(e)}function ho(e){this._node=e,this._names=uo(e.getAttribute("class")||"")}ho.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 fo(e,t){for(var n=Mi(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function po(e,t){for(var n=Mi(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Qh(e){return function(){fo(this,e)}}function Xh(e){return function(){po(this,e)}}function Jh(e,t){return function(){(t.apply(this,arguments)?fo:po)(this,e)}}function Zh(e,t){var n=uo(e+"");if(arguments.length<2){for(var r=Mi(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?Jh:t?Qh:Xh)(n,t))}function td(){this.textContent=""}function ed(e){return function(){this.textContent=e}}function nd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function rd(e){return arguments.length?this.each(e==null?td:(typeof e=="function"?nd:ed)(e)):this.node().textContent}function id(){this.innerHTML=""}function sd(e){return function(){this.innerHTML=e}}function od(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ad(e){return arguments.length?this.each(e==null?id:(typeof e=="function"?od:sd)(e)):this.node().innerHTML}function ld(){this.nextSibling&&this.parentNode.appendChild(this)}function cd(){return this.each(ld)}function ud(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function hd(){return this.each(ud)}function dd(e){var t=typeof e=="function"?e:io(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function fd(){return null}function pd(e,t){var n=typeof e=="function"?e:io(e),r=t==null?fd:typeof t=="function"?t:Fi(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function yd(){var e=this.parentNode;e&&e.removeChild(this)}function md(){return this.each(yd)}function gd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function _d(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function bd(e){return this.select(e?_d:gd)}function vd(e){return arguments.length?this.property("__data__",e):this.node().__data__}function wd(e){return function(t){e.call(this,t,this.__data__)}}function Id(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 Sd(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 Ed(e,t,n){return function(){var r=this.__on,i,s=wd(t);if(r){for(var o=0,a=r.length;o<a;++o)if((i=r[o]).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 Td(e,t,n){var r=Id(e+""),i,s=r.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(i=0,u=a[c];i<s;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(a=t?Ed:Sd,i=0;i<s;++i)this.each(a(r[i],t,n));return this}function yo(e,t,n){var r=co(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 Ad(e,t){return function(){return yo(this,e,t)}}function Nd(e,t){return function(){return yo(this,e,t.apply(this,arguments))}}function Rd(e,t){return this.each((typeof t=="function"?Nd:Ad)(e,t))}function*Bd(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,o;i<s;++i)(o=r[i])&&(yield o)}var mo=[null];function kt(e,t){this._groups=e,this._parents=t}function Ln(){return new kt([[document.documentElement]],mo)}function Od(){return this}kt.prototype=Ln.prototype={constructor:kt,select:nh,selectAll:oh,selectChild:uh,selectChildren:ph,filter:yh,data:wh,enter:mh,exit:Sh,join:Eh,merge:Th,selection:Od,order:Ah,sort:Nh,call:Bh,nodes:Oh,node:Dh,size:Lh,empty:Fh,each:Mh,attr:Vh,style:qh,property:Kh,classed:Zh,text:rd,html:ad,raise:cd,lower:hd,append:dd,insert:pd,remove:md,clone:bd,datum:vd,on:Td,dispatch:Rd,[Symbol.iterator]:Bd};function me(e){return typeof e=="string"?new kt([[document.querySelector(e)]],[document.documentElement]):new kt([[e]],mo)}function Dd(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Oe(e,t){if(e=Dd(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 Ui={capture:!0,passive:!1};function xi(e){e.preventDefault(),e.stopImmediatePropagation()}function Ld(e){var t=e.document.documentElement,n=me(e).on("dragstart.drag",xi,Ui);"onselectstart"in t?n.on("selectstart.drag",xi,Ui):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Fd(e,t){var n=e.document.documentElement,r=me(e).on("dragstart.drag",null);t&&(r.on("click.drag",xi,Ui),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 Ci(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function go(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Fn(){}var Mn=.7,pr=1/Mn,rn="\\s*([+-]?\\d+)\\s*",Un="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",re="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Md=/^#([0-9a-f]{3,8})$/,Ud=new RegExp(`^rgb\\(${rn},${rn},${rn}\\)$`),xd=new RegExp(`^rgb\\(${re},${re},${re}\\)$`),Cd=new RegExp(`^rgba\\(${rn},${rn},${rn},${Un}\\)$`),$d=new RegExp(`^rgba\\(${re},${re},${re},${Un}\\)$`),kd=new RegExp(`^hsl\\(${Un},${re},${re}\\)$`),Pd=new RegExp(`^hsla\\(${Un},${re},${re},${Un}\\)$`),_o={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};Ci(Fn,xn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:bo,formatHex:bo,formatHex8:Vd,formatHsl:zd,formatRgb:vo,toString:vo});function bo(){return this.rgb().formatHex()}function Vd(){return this.rgb().formatHex8()}function zd(){return To(this).formatHsl()}function vo(){return this.rgb().formatRgb()}function xn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Md.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?wo(t):n===3?new Mt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?yr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?yr(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=Ud.exec(e))?new Mt(t[1],t[2],t[3],1):(t=xd.exec(e))?new Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Cd.exec(e))?yr(t[1],t[2],t[3],t[4]):(t=$d.exec(e))?yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kd.exec(e))?Eo(t[1],t[2]/100,t[3]/100,1):(t=Pd.exec(e))?Eo(t[1],t[2]/100,t[3]/100,t[4]):_o.hasOwnProperty(e)?wo(_o[e]):e==="transparent"?new Mt(NaN,NaN,NaN,0):null}function wo(e){return new Mt(e>>16&255,e>>8&255,e&255,1)}function yr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Mt(e,t,n,r)}function Yd(e){return e instanceof Fn||(e=xn(e)),e?(e=e.rgb(),new Mt(e.r,e.g,e.b,e.opacity)):new Mt}function $i(e,t,n,r){return arguments.length===1?Yd(e):new Mt(e,t,n,r??1)}function Mt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ci(Mt,$i,go(Fn,{brighter(e){return e=e==null?pr:Math.pow(pr,e),new Mt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Mn:Math.pow(Mn,e),new Mt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Mt(je(this.r),je(this.g),je(this.b),mr(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:Io,formatHex:Io,formatHex8:jd,formatRgb:So,toString:So}));function Io(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}`}function jd(){return`#${qe(this.r)}${qe(this.g)}${qe(this.b)}${qe((isNaN(this.opacity)?1:this.opacity)*255)}`}function So(){const e=mr(this.opacity);return`${e===1?"rgb(":"rgba("}${je(this.r)}, ${je(this.g)}, ${je(this.b)}${e===1?")":`, ${e})`}`}function mr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function je(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qe(e){return e=je(e),(e<16?"0":"")+e.toString(16)}function Eo(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Jt(e,t,n,r)}function To(e){if(e instanceof Jt)return new Jt(e.h,e.s,e.l,e.opacity);if(e instanceof Fn||(e=xn(e)),!e)return new Jt;if(e instanceof Jt)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),o=NaN,a=s-i,c=(s+i)/2;return a?(t===s?o=(n-r)/a+(n<r)*6:n===s?o=(r-t)/a+2:o=(t-n)/a+4,a/=c<.5?s+i:2-s-i,o*=60):a=c>0&&c<1?0:o,new Jt(o,a,c,e.opacity)}function qd(e,t,n,r){return arguments.length===1?To(e):new Jt(e,t,n,r??1)}function Jt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ci(Jt,qd,go(Fn,{brighter(e){return e=e==null?pr:Math.pow(pr,e),new Jt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Mn:Math.pow(Mn,e),new Jt(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 Mt(ki(e>=240?e-240:e+120,i,r),ki(e,i,r),ki(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Jt(Ao(this.h),gr(this.s),gr(this.l),mr(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=mr(this.opacity);return`${e===1?"hsl(":"hsla("}${Ao(this.h)}, ${gr(this.s)*100}%, ${gr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ao(e){return e=(e||0)%360,e<0?e+360:e}function gr(e){return Math.max(0,Math.min(1,e||0))}function ki(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 No=e=>()=>e;function Gd(e,t){return function(n){return e+n*t}}function Wd(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 Hd(e){return(e=+e)==1?Ro:function(t,n){return n-t?Wd(t,n,e):No(isNaN(t)?n:t)}}function Ro(e,t){var n=t-e;return n?Gd(e,n):No(isNaN(e)?t:e)}const Bo=(function e(t){var n=Hd(t);function r(i,s){var o=n((i=$i(i)).r,(s=$i(s)).r),a=n(i.g,s.g),c=n(i.b,s.b),l=Ro(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=a(u),i.b=c(u),i.opacity=l(u),i+""}}return r.gamma=e,r})(1);function De(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Pi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Vi=new RegExp(Pi.source,"g");function Kd(e){return function(){return e}}function Qd(e){return function(t){return e(t)+""}}function Xd(e,t){var n=Pi.lastIndex=Vi.lastIndex=0,r,i,s,o=-1,a=[],c=[];for(e=e+"",t=t+"";(r=Pi.exec(e))&&(i=Vi.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),a[o]?a[o]+=s:a[++o]=s),(r=r[0])===(i=i[0])?a[o]?a[o]+=i:a[++o]=i:(a[++o]=null,c.push({i:o,x:De(r,i)})),n=Vi.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?c[0]?Qd(c[0].x):Kd(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}var Oo=180/Math.PI,Do={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Lo(e,t,n,r,i,s){var o,a,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*Oo,skewX:Math.atan(c)*Oo,scaleX:o,scaleY:a}}var _r;function Jd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Do:Lo(t.a,t.b,t.c,t.d,t.e,t.f)}function Zd(e){return e==null||(_r||(_r=document.createElementNS("http://www.w3.org/2000/svg","g")),_r.setAttribute("transform",e),!(e=_r.transform.baseVal.consolidate()))?Do:(e=e.matrix,Lo(e.a,e.b,e.c,e.d,e.e,e.f))}function Fo(e,t,n,r){function i(l){return l.length?l.pop()+" ":""}function s(l,u,d,y,m,b){if(l!==d||u!==y){var T=m.push("translate(",null,t,null,n);b.push({i:T-4,x:De(l,d)},{i:T-2,x:De(u,y)})}else(d||y)&&m.push("translate("+d+t+y+n)}function o(l,u,d,y){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),y.push({i:d.push(i(d)+"rotate(",null,r)-2,x:De(l,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(l,u,d,y){l!==u?y.push({i:d.push(i(d)+"skewX(",null,r)-2,x:De(l,u)}):u&&d.push(i(d)+"skewX("+u+r)}function c(l,u,d,y,m,b){if(l!==d||u!==y){var T=m.push(i(m)+"scale(",null,",",null,")");b.push({i:T-4,x:De(l,d)},{i:T-2,x:De(u,y)})}else(d!==1||y!==1)&&m.push(i(m)+"scale("+d+","+y+")")}return function(l,u){var d=[],y=[];return l=e(l),u=e(u),s(l.translateX,l.translateY,u.translateX,u.translateY,d,y),o(l.rotate,u.rotate,d,y),a(l.skewX,u.skewX,d,y),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,y),l=u=null,function(m){for(var b=-1,T=y.length,S;++b<T;)d[(S=y[b]).i]=S.x(m);return d.join("")}}}var tf=Fo(Jd,"px, ","px)","deg)"),ef=Fo(Zd,", ",")",")"),nf=1e-12;function Mo(e){return((e=Math.exp(e))+1/e)/2}function rf(e){return((e=Math.exp(e))-1/e)/2}function sf(e){return((e=Math.exp(2*e))-1)/(e+1)}const of=(function e(t,n,r){function i(s,o){var a=s[0],c=s[1],l=s[2],u=o[0],d=o[1],y=o[2],m=u-a,b=d-c,T=m*m+b*b,S,_;if(T<nf)_=Math.log(y/l)/t,S=function(N){return[a+N*m,c+N*b,l*Math.exp(t*N*_)]};else{var W=Math.sqrt(T),Z=(y*y-l*l+r*T)/(2*l*n*W),It=(y*y-l*l-r*T)/(2*y*n*W),R=Math.log(Math.sqrt(Z*Z+1)-Z),B=Math.log(Math.sqrt(It*It+1)-It);_=(B-R)/t,S=function(N){var V=N*_,j=Mo(R),G=l/(n*W)*(j*sf(t*V+R)-rf(R));return[a+G*m,c+G*b,l*j/Mo(t*V+R)]}}return S.duration=_*1e3*t/Math.SQRT2,S}return i.rho=function(s){var o=Math.max(.001,+s),a=o*o,c=a*a;return e(o,a,c)},i})(Math.SQRT2,2,4);var sn=0,Cn=0,$n=0,Uo=1e3,br,kn,vr=0,Ge=0,wr=0,Pn=typeof performance=="object"&&performance.now?performance:Date,xo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function zi(){return Ge||(xo(af),Ge=Pn.now()+wr)}function af(){Ge=0}function Ir(){this._call=this._time=this._next=null}Ir.prototype=Co.prototype={constructor:Ir,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?zi():+n)+(t==null?0:+t),!this._next&&kn!==this&&(kn?kn._next=this:br=this,kn=this),this._call=e,this._time=n,Yi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yi())}};function Co(e,t,n){var r=new Ir;return r.restart(e,t,n),r}function lf(){zi(),++sn;for(var e=br,t;e;)(t=Ge-e._time)>=0&&e._call.call(void 0,t),e=e._next;--sn}function $o(){Ge=(vr=Pn.now())+wr,sn=Cn=0;try{lf()}finally{sn=0,uf(),Ge=0}}function cf(){var e=Pn.now(),t=e-vr;t>Uo&&(wr-=t,vr=e)}function uf(){for(var e,t=br,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:br=n);kn=e,Yi(r)}function Yi(e){if(!sn){Cn&&(Cn=clearTimeout(Cn));var t=e-Ge;t>24?(e<1/0&&(Cn=setTimeout($o,e-Pn.now()-wr)),$n&&($n=clearInterval($n))):($n||(vr=Pn.now(),$n=setInterval(cf,Uo)),sn=1,xo($o))}}function ko(e,t,n){var r=new Ir;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var hf=Di("start","end","cancel","interrupt"),df=[],Po=0,Vo=1,ji=2,Sr=3,zo=4,qi=5,Er=6;function Tr(e,t,n,r,i,s){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;ff(e,n,{name:t,index:r,group:i,on:hf,tween:df,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Po})}function Gi(e,t){var n=Zt(e,t);if(n.state>Po)throw new Error("too late; already scheduled");return n}function ie(e,t){var n=Zt(e,t);if(n.state>Sr)throw new Error("too late; already running");return n}function Zt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function ff(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Co(s,0,n.time);function s(l){n.state=Vo,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,d,y,m;if(n.state!==Vo)return c();for(u in r)if(m=r[u],m.name===n.name){if(m.state===Sr)return ko(o);m.state===zo?(m.state=Er,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<t&&(m.state=Er,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(ko(function(){n.state===Sr&&(n.state=zo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=ji,n.on.call("start",e,e.__data__,n.index,n.group),n.state===ji){for(n.state=Sr,i=new Array(y=n.tween.length),u=0,d=-1;u<y;++u)(m=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(i[++d]=m);i.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=qi,1),d=-1,y=i.length;++d<y;)i[d].call(e,u);n.state===qi&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Er,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function Ar(e,t){var n=e.__transition,r,i,s=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){s=!1;continue}i=r.state>ji&&r.state<qi,r.state=Er,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}s&&delete e.__transition}}function pf(e){return this.each(function(){Ar(this,e)})}function yf(e,t){var n,r;return function(){var i=ie(this,e),s=i.tween;if(s!==n){r=n=s;for(var o=0,a=r.length;o<a;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function mf(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ie(this,e),o=s.tween;if(o!==r){i=(r=o).slice();for(var a={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=a;break}c===l&&i.push(a)}s.tween=i}}function gf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Zt(this.node(),n).tween,i=0,s=r.length,o;i<s;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?yf:mf)(n,e,t))}function Wi(e,t,n){var r=e._id;return e.each(function(){var i=ie(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Zt(i,r).value[t]}}function Yo(e,t){var n;return(typeof t=="number"?De:t instanceof xn?Bo:(n=xn(t))?(t=n,Bo):Xd)(e,t)}function _f(e){return function(){this.removeAttribute(e)}}function bf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function vf(e,t,n){var r,i=n+"",s;return function(){var o=this.getAttribute(e);return o===i?null:o===r?s:s=t(r=o,n)}}function wf(e,t,n){var r,i=n+"",s;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?s:s=t(r=o,n)}}function If(e,t,n){var r,i,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=a+"",o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a)))}}function Sf(e,t,n){var r,i,s;return function(){var o,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=a+"",o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a)))}}function Ef(e,t){var n=dr(e),r=n==="transform"?ef:Yo;return this.attrTween(e,typeof t=="function"?(n.local?Sf:If)(n,r,Wi(this,"attr."+e,t)):t==null?(n.local?bf:_f)(n):(n.local?wf:vf)(n,r,t))}function Tf(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Af(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Nf(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Af(e,s)),n}return i._value=t,i}function Rf(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Tf(e,s)),n}return i._value=t,i}function Bf(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=dr(e);return this.tween(n,(r.local?Nf:Rf)(r,t))}function Of(e,t){return function(){Gi(this,e).delay=+t.apply(this,arguments)}}function Df(e,t){return t=+t,function(){Gi(this,e).delay=t}}function Lf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Of:Df)(t,e)):Zt(this.node(),t).delay}function Ff(e,t){return function(){ie(this,e).duration=+t.apply(this,arguments)}}function Mf(e,t){return t=+t,function(){ie(this,e).duration=t}}function Uf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ff:Mf)(t,e)):Zt(this.node(),t).duration}function xf(e,t){if(typeof t!="function")throw new Error;return function(){ie(this,e).ease=t}}function Cf(e){var t=this._id;return arguments.length?this.each(xf(t,e)):Zt(this.node(),t).ease}function $f(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ie(this,e).ease=n}}function kf(e){if(typeof e!="function")throw new Error;return this.each($f(this._id,e))}function Pf(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],o=s.length,a=r[i]=[],c,l=0;l<o;++l)(c=s[l])&&e.call(c,c.__data__,l,s)&&a.push(c);return new ge(r,this._parents,this._name,this._id)}function Vf(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),o=new Array(r),a=0;a<s;++a)for(var c=t[a],l=n[a],u=c.length,d=o[a]=new Array(u),y,m=0;m<u;++m)(y=c[m]||l[m])&&(d[m]=y);for(;a<r;++a)o[a]=t[a];return new ge(o,this._parents,this._name,this._id)}function zf(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 Yf(e,t,n){var r,i,s=zf(t)?Gi:ie;return function(){var o=s(this,e),a=o.on;a!==r&&(i=(r=a).copy()).on(t,n),o.on=i}}function jf(e,t){var n=this._id;return arguments.length<2?Zt(this.node(),n).on.on(e):this.each(Yf(n,e,t))}function qf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Gf(){return this.on("end.remove",qf(this._id))}function Wf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Fi(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a=r[o],c=a.length,l=s[o]=new Array(c),u,d,y=0;y<c;++y)(u=a[y])&&(d=e.call(u,u.__data__,y,a))&&("__data__"in u&&(d.__data__=u.__data__),l[y]=d,Tr(l[y],t,n,y,l,Zt(u,n)));return new ge(s,this._parents,t,n)}function Hf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=so(e));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var c=r[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var y=e.call(u,u.__data__,d,c),m,b=Zt(u,n),T=0,S=y.length;T<S;++T)(m=y[T])&&Tr(m,t,n,T,y,b);s.push(y),o.push(u)}return new ge(s,o,t,n)}var Kf=Ln.prototype.constructor;function Qf(){return new Kf(this._groups,this._parents)}function Xf(e,t){var n,r,i;return function(){var s=nn(this,e),o=(this.style.removeProperty(e),nn(this,e));return s===o?null:s===n&&o===r?i:i=t(n=s,r=o)}}function jo(e){return function(){this.style.removeProperty(e)}}function Jf(e,t,n){var r,i=n+"",s;return function(){var o=nn(this,e);return o===i?null:o===r?s:s=t(r=o,n)}}function Zf(e,t,n){var r,i,s;return function(){var o=nn(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),nn(this,e))),o===c?null:o===r&&c===i?s:(i=c,s=t(r=o,a))}}function tp(e,t){var n,r,i,s="style."+t,o="end."+s,a;return function(){var c=ie(this,e),l=c.on,u=c.value[s]==null?a||(a=jo(t)):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ep(e,t,n){var r=(e+="")=="transform"?tf:Yo;return t==null?this.styleTween(e,Xf(e,r)).on("end.style."+e,jo(e)):typeof t=="function"?this.styleTween(e,Zf(e,r,Wi(this,"style."+e,t))).each(tp(this._id,e)):this.styleTween(e,Jf(e,r,t),n).on("end.style."+e,null)}function np(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function rp(e,t,n){var r,i;function s(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&np(e,o,n)),r}return s._value=t,s}function ip(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,rp(e,t,n??""))}function sp(e){return function(){this.textContent=e}}function op(e){return function(){var t=e(this);this.textContent=t??""}}function ap(e){return this.tween("text",typeof e=="function"?op(Wi(this,"text",e)):sp(e==null?"":e+""))}function lp(e){return function(t){this.textContent=e.call(this,t)}}function cp(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&lp(i)),t}return r._value=e,r}function up(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,cp(e))}function hp(){for(var e=this._name,t=this._id,n=qo(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,c,l=0;l<a;++l)if(c=o[l]){var u=Zt(c,t);Tr(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new ge(r,this._parents,e,n)}function dp(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,o){var a={value:o},c={value:function(){--i===0&&s()}};n.each(function(){var l=ie(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),i===0&&s()})}var fp=0;function ge(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function qo(){return++fp}var _e=Ln.prototype;ge.prototype={constructor:ge,select:Wf,selectAll:Hf,selectChild:_e.selectChild,selectChildren:_e.selectChildren,filter:Pf,merge:Vf,selection:Qf,transition:hp,call:_e.call,nodes:_e.nodes,node:_e.node,size:_e.size,empty:_e.empty,each:_e.each,on:jf,attr:Ef,attrTween:Bf,style:ep,styleTween:ip,text:ap,textTween:up,remove:Gf,tween:gf,delay:Lf,duration:Uf,ease:Cf,easeVarying:kf,end:dp,[Symbol.iterator]:_e[Symbol.iterator]};function pp(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var yp={time:null,delay:0,duration:250,ease:pp};function mp(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 gp(e){var t,n;e instanceof ge?(t=e._id,e=e._name):(t=qo(),(n=yp).time=zi(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,c,l=0;l<a;++l)(c=o[l])&&Tr(c,e,t,l,o,n||mp(c,t));return new ge(r,this._parents,e,t)}Ln.prototype.interrupt=pf,Ln.prototype.transition=gp;const Nr=e=>()=>e;function _p(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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 Rr=new be(1,0,0);be.prototype;function Hi(e){e.stopImmediatePropagation()}function Vn(e){e.preventDefault(),e.stopImmediatePropagation()}function bp(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function vp(){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 Go(){return this.__zoom||Rr}function wp(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ip(){return navigator.maxTouchPoints||"ontouchstart"in this}function Sp(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],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>s?(s+o)/2:Math.min(0,s)||Math.max(0,o))}function Ep(){var e=bp,t=vp,n=Sp,r=wp,i=Ip,s=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,c=of,l=Di("start","zoom","end"),u,d,y,m=500,b=150,T=0,S=10;function _(g){g.property("__zoom",Go).on("wheel.zoom",V,{passive:!1}).on("mousedown.zoom",j).on("dblclick.zoom",G).filter(i).on("touchstart.zoom",lt).on("touchmove.zoom",bt).on("touchend.zoom touchcancel.zoom",ut).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(g,w,h,v){var I=g.selection?g.selection():g;I.property("__zoom",Go),g!==I?R(g,w,h,v):I.interrupt().each(function(){B(this,arguments).event(v).start().zoom(null,typeof w=="function"?w.apply(this,arguments):w).end()})},_.scaleBy=function(g,w,h,v){_.scaleTo(g,function(){var I=this.__zoom.k,E=typeof w=="function"?w.apply(this,arguments):w;return I*E},h,v)},_.scaleTo=function(g,w,h,v){_.transform(g,function(){var I=t.apply(this,arguments),E=this.__zoom,A=h==null?It(I):typeof h=="function"?h.apply(this,arguments):h,D=E.invert(A),K=typeof w=="function"?w.apply(this,arguments):w;return n(Z(W(E,K),A,D),I,o)},h,v)},_.translateBy=function(g,w,h,v){_.transform(g,function(){return n(this.__zoom.translate(typeof w=="function"?w.apply(this,arguments):w,typeof h=="function"?h.apply(this,arguments):h),t.apply(this,arguments),o)},null,v)},_.translateTo=function(g,w,h,v,I){_.transform(g,function(){var E=t.apply(this,arguments),A=this.__zoom,D=v==null?It(E):typeof v=="function"?v.apply(this,arguments):v;return n(Rr.translate(D[0],D[1]).scale(A.k).translate(typeof w=="function"?-w.apply(this,arguments):-w,typeof h=="function"?-h.apply(this,arguments):-h),E,o)},v,I)};function W(g,w){return w=Math.max(s[0],Math.min(s[1],w)),w===g.k?g:new be(w,g.x,g.y)}function Z(g,w,h){var v=w[0]-h[0]*g.k,I=w[1]-h[1]*g.k;return v===g.x&&I===g.y?g:new be(g.k,v,I)}function It(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function R(g,w,h,v){g.on("start.zoom",function(){B(this,arguments).event(v).start()}).on("interrupt.zoom end.zoom",function(){B(this,arguments).event(v).end()}).tween("zoom",function(){var I=this,E=arguments,A=B(I,E).event(v),D=t.apply(I,E),K=h==null?It(D):typeof h=="function"?h.apply(I,E):h,ft=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),tt=I.__zoom,ct=typeof w=="function"?w.apply(I,E):w,wt=c(tt.invert(K).concat(ft/tt.k),ct.invert(K).concat(ft/ct.k));return function(nt){if(nt===1)nt=ct;else{var mt=wt(nt),Bt=ft/mt[2];nt=new be(Bt,K[0]-mt[0]*Bt,K[1]-mt[1]*Bt)}A.zoom(null,nt)}})}function B(g,w,h){return!h&&g.__zooming||new N(g,w)}function N(g,w){this.that=g,this.args=w,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,w),this.taps=0}N.prototype={event:function(g){return g&&(this.sourceEvent=g),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(g,w){return this.mouse&&g!=="mouse"&&(this.mouse[1]=w.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=w.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=w.invert(this.touch1[0])),this.that.__zoom=w,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var w=me(this.that).datum();l.call(g,this.that,new _p(g,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:l}),w)}};function V(g,...w){if(!e.apply(this,arguments))return;var h=B(this,w).event(g),v=this.__zoom,I=Math.max(s[0],Math.min(s[1],v.k*Math.pow(2,r.apply(this,arguments)))),E=Oe(g);if(h.wheel)(h.mouse[0][0]!==E[0]||h.mouse[0][1]!==E[1])&&(h.mouse[1]=v.invert(h.mouse[0]=E)),clearTimeout(h.wheel);else{if(v.k===I)return;h.mouse=[E,v.invert(E)],Ar(this),h.start()}Vn(g),h.wheel=setTimeout(A,b),h.zoom("mouse",n(Z(W(v,I),h.mouse[0],h.mouse[1]),h.extent,o));function A(){h.wheel=null,h.end()}}function j(g,...w){if(y||!e.apply(this,arguments))return;var h=g.currentTarget,v=B(this,w,!0).event(g),I=me(g.view).on("mousemove.zoom",K,!0).on("mouseup.zoom",ft,!0),E=Oe(g,h),A=g.clientX,D=g.clientY;Ld(g.view),Hi(g),v.mouse=[E,this.__zoom.invert(E)],Ar(this),v.start();function K(tt){if(Vn(tt),!v.moved){var ct=tt.clientX-A,wt=tt.clientY-D;v.moved=ct*ct+wt*wt>T}v.event(tt).zoom("mouse",n(Z(v.that.__zoom,v.mouse[0]=Oe(tt,h),v.mouse[1]),v.extent,o))}function ft(tt){I.on("mousemove.zoom mouseup.zoom",null),Fd(tt.view,v.moved),Vn(tt),v.event(tt).end()}}function G(g,...w){if(e.apply(this,arguments)){var h=this.__zoom,v=Oe(g.changedTouches?g.changedTouches[0]:g,this),I=h.invert(v),E=h.k*(g.shiftKey?.5:2),A=n(Z(W(h,E),v,I),t.apply(this,w),o);Vn(g),a>0?me(this).transition().duration(a).call(R,A,v,g):me(this).call(_.transform,A,v,g)}}function lt(g,...w){if(e.apply(this,arguments)){var h=g.touches,v=h.length,I=B(this,w,g.changedTouches.length===v).event(g),E,A,D,K;for(Hi(g),A=0;A<v;++A)D=h[A],K=Oe(D,this),K=[K,this.__zoom.invert(K),D.identifier],I.touch0?!I.touch1&&I.touch0[2]!==K[2]&&(I.touch1=K,I.taps=0):(I.touch0=K,E=!0,I.taps=1+!!u);u&&(u=clearTimeout(u)),E&&(I.taps<2&&(d=K[0],u=setTimeout(function(){u=null},m)),Ar(this),I.start())}}function bt(g,...w){if(this.__zooming){var h=B(this,w).event(g),v=g.changedTouches,I=v.length,E,A,D,K;for(Vn(g),E=0;E<I;++E)A=v[E],D=Oe(A,this),h.touch0&&h.touch0[2]===A.identifier?h.touch0[0]=D:h.touch1&&h.touch1[2]===A.identifier&&(h.touch1[0]=D);if(A=h.that.__zoom,h.touch1){var ft=h.touch0[0],tt=h.touch0[1],ct=h.touch1[0],wt=h.touch1[1],nt=(nt=ct[0]-ft[0])*nt+(nt=ct[1]-ft[1])*nt,mt=(mt=wt[0]-tt[0])*mt+(mt=wt[1]-tt[1])*mt;A=W(A,Math.sqrt(nt/mt)),D=[(ft[0]+ct[0])/2,(ft[1]+ct[1])/2],K=[(tt[0]+wt[0])/2,(tt[1]+wt[1])/2]}else if(h.touch0)D=h.touch0[0],K=h.touch0[1];else return;h.zoom("touch",n(Z(A,D,K),h.extent,o))}}function ut(g,...w){if(this.__zooming){var h=B(this,w).event(g),v=g.changedTouches,I=v.length,E,A;for(Hi(g),y&&clearTimeout(y),y=setTimeout(function(){y=null},m),E=0;E<I;++E)A=v[E],h.touch0&&h.touch0[2]===A.identifier?delete h.touch0:h.touch1&&h.touch1[2]===A.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&&(A=Oe(A,this),Math.hypot(d[0]-A[0],d[1]-A[1])<S)){var D=me(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return _.wheelDelta=function(g){return arguments.length?(r=typeof g=="function"?g:Nr(+g),_):r},_.filter=function(g){return arguments.length?(e=typeof g=="function"?g:Nr(!!g),_):e},_.touchable=function(g){return arguments.length?(i=typeof g=="function"?g:Nr(!!g),_):i},_.extent=function(g){return arguments.length?(t=typeof g=="function"?g:Nr([[+g[0][0],+g[0][1]],[+g[1][0],+g[1][1]]]),_):t},_.scaleExtent=function(g){return arguments.length?(s[0]=+g[0],s[1]=+g[1],_):[s[0],s[1]]},_.translateExtent=function(g){return arguments.length?(o[0][0]=+g[0][0],o[1][0]=+g[1][0],o[0][1]=+g[0][1],o[1][1]=+g[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(g){return arguments.length?(n=g,_):n},_.duration=function(g){return arguments.length?(a=+g,_):a},_.interpolate=function(g){return arguments.length?(c=g,_):c},_.on=function(){var g=l.on.apply(l,arguments);return g===l?_:g},_.clickDistance=function(g){return arguments.length?(T=(g=+g)*g,_):Math.sqrt(T)},_.tapDistance=function(g){return arguments.length?(S=+g,_):S},_}const Tp=f.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random",validator:e=>["random","gradient","single","species","sex","Type"].includes(e)},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}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=f.ref(null),i=f.ref(null),s=f.ref(null),o=f.ref(null);let a=null,c=null,l=null,u=[],d=null,y=null,m=null,b=0,T=0,S=1;function _(h){if(!h||h.length<7)return[1,0,0];const v=parseInt(h.slice(1,3),16)/255,I=parseInt(h.slice(3,5),16)/255,E=parseInt(h.slice(5,7),16)/255;return[v,I,E].some(Number.isNaN)?[1,0,0]:[v,I,E]}const W=(h,v,I)=>h+(v-h)*I;function Z(h,v){const I=h.parentElement;I&&(S=window.devicePixelRatio||1,b=I.clientWidth||800,T=I.clientHeight||400,h.style.width=`${b}px`,h.style.height=`${T}px`,h.width=Math.round(b*S),h.height=Math.round(T*S),v.viewport(0,0,h.width,h.height))}function It(h,v,I,E,A){if(!I)return{x:0,y:0};const D=h/E*2,K=-(v/A*2),ft=n.metaData?.row_groups?.[0]?.columns?.[0]?.meta_data?.statistics,tt=2/Math.max(1e-9,(ft?.max_value??1)-(ft?.min_value??-1)),ct=I.x/E*2-1,wt=-I.y/A*2+1,nt=I.k*tt,mt=(D-ct-1)/nt,Bt=(K-wt+1)/nt;return{x:mt,y:Bt}}function R(h,v,I,E,A,D){if(!h.length||!E)return null;const K=It(v,I,E,A,D);let ft=1/0,tt=null;for(const ct of h){const wt=ct.x-K.x,nt=ct.y-K.y,mt=Math.hypot(wt,nt),Bt=3/(E.k/2);mt<ft&&mt<Bt&&(ft=mt,tt=ct)}return tt&&o.value&&(o.value.innerHTML=`
15
- Mouse: (${v.toFixed(2)}, ${I.toFixed(2)})<br/>
16
- Data: (${K.x.toFixed(2)}, ${K.y.toFixed(2)})<br/>
17
- Scale: ${E.k.toFixed(2)}
18
- `),tt}function B(h,v,I,E,A){const D=_(I),K=_(E),ft=_(A),tt=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(_),ct=new Map,wt=[];for(let nt=0;nt<n.data.length;nt++){const mt=n.data[nt],Bt=mt[0],en=mt[1],En=Math.round(Math.sqrt(Bt*Bt+en*en)*10)/10;ct.has(mt[5])||ct.set(mt[5],tt[nt%tt.length]);let Re;switch(v){case"random":Re=[Math.random(),Math.random(),Math.random()];break;case"gradient":{const Tn=(Bt+50)/100;Re=[W(D[0],K[0],Tn),W(D[1],K[1],Tn),W(D[2],K[2],Tn)];break}case"single":Re=[...ft];break;case"Type":Re=[...ct.get(mt[5])||[1,1,1]];break;default:Re=[Math.random(),Math.random(),Math.random()]}wt.push({x:Bt,y:en,rawX:Bt,rawY:en,color:Re,id:nt,species:mt[4],value:En,label:`Point ${nt+1}: (${parseFloat(Bt).toFixed(2)}, ${parseFloat(en).toFixed(2)})`,category:En<25?"Near":En<50?"Medium":"Far"})}return wt}function N(h){const v={preserveDrawingBuffer:!0,antialias:!0,alpha:!0},I=h.getContext("webgl",v)||h.getContext("experimental-webgl",v);return I?(I.clearColor(0,0,0,1),I.enable(I.BLEND),I.blendFunc(I.SRC_ALPHA,I.ONE_MINUS_SRC_ALPHA),I.disable(I.DEPTH_TEST),I):(console.error("WebGL not supported"),null)}function V(h,v,I){const E=h.createShader(h.VERTEX_SHADER);if(h.shaderSource(E,v),h.compileShader(E),!h.getShaderParameter(E,h.COMPILE_STATUS))return console.error("Vertex shader error:",h.getShaderInfoLog(E)),null;const A=h.createShader(h.FRAGMENT_SHADER);if(h.shaderSource(A,I),h.compileShader(A),!h.getShaderParameter(A,h.COMPILE_STATUS))return console.error("Fragment shader error:",h.getShaderInfoLog(A)),null;const D=h.createProgram();return h.attachShader(D,E),h.attachShader(D,A),h.linkProgram(D),h.getProgramParameter(D,h.LINK_STATUS)?(h.validateProgram(D),h.getProgramParameter(D,h.VALIDATE_STATUS)?D:(console.error("Program validate error:",h.getProgramInfoLog(D)),null)):(console.error("Program link error:",h.getProgramInfoLog(D)),null)}function j(h,v,I){if(!I.length)return null;const E=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,E);const A=new Float32Array(I.flatMap(nt=>[nt.x,nt.y]));h.bufferData(h.ARRAY_BUFFER,A,h.STATIC_DRAW);const D=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,D);const K=new Float32Array(I.flatMap(nt=>nt.color));h.bufferData(h.ARRAY_BUFFER,K,h.STATIC_DRAW);const ft=h.getAttribLocation(v,"a_position"),tt=h.getAttribLocation(v,"a_color"),ct=h.getUniformLocation(v,"u_viewMatrix"),wt=h.getUniformLocation(v,"u_pointSize");return ft===-1||tt===-1||!ct||!wt?(console.error("Failed to lookup attrib/uniform locations"),null):{program:v,positionBuffer:E,colorBuffer:D,positionAttributeLocation:ft,colorAttributeLocation:tt,viewMatrixLocation:ct,pointSizeLocation:wt,count:I.length}}function G(h,v,I,E,A=null){if(!h||!v||!I)return;const{program:D,positionBuffer:K,colorBuffer:ft,positionAttributeLocation:tt,colorAttributeLocation:ct,viewMatrixLocation:wt,pointSizeLocation:nt,count:mt}=v;h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.useProgram(D),h.enableVertexAttribArray(tt),h.bindBuffer(h.ARRAY_BUFFER,K),h.vertexAttribPointer(tt,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(ct),h.bindBuffer(h.ARRAY_BUFFER,ft),h.vertexAttribPointer(ct,3,h.FLOAT,!1,0,0);const Bt=h.canvas.clientWidth,en=h.canvas.clientHeight,En=n.metaData?.row_groups?.[0]?.columns?.[0]?.meta_data?.statistics,Re=n.metaData?.row_groups?.[0]?.columns?.[1]?.meta_data?.statistics,Tn=Number(En?.min_value??-1),uu=Number(En?.max_value??1),hu=Number(Re?.min_value??-1),du=Number(Re?.max_value??1),j_=(Tn+uu)/2,q_=(hu+du)/2,G_=Math.max(1e-9,uu-Tn),W_=Math.max(1e-9,du-hu),H_=2/Math.max(G_,W_),K_=I.x/Bt*2-1,Q_=-I.y/en*2+1,Bi=I.k*H_,X_=K_-Bi*j_,J_=Q_-Bi*q_,Z_=new Float32Array([Bi,0,0,0,0,Bi,0,0,0,0,1,0,X_,J_,0,1]);if(h.uniformMatrix4fv(wt,!1,Z_),h.uniform1f(nt,E*Math.sqrt(I.k)*S),h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),h.drawArrays(h.POINTS,0,mt),A){const fu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,fu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([A.x,A.y]),h.STATIC_DRAW),h.vertexAttribPointer(tt,2,h.FLOAT,!1,0,0);const pu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,pu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,1,.5]),h.STATIC_DRAW),h.vertexAttribPointer(ct,3,h.FLOAT,!1,0,0),h.uniform1f(nt,E*Math.sqrt(I.k)*2.5*S),h.drawArrays(h.POINTS,0,1);const yu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,yu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([1,.8,.2]),h.STATIC_DRAW),h.vertexAttribPointer(ct,3,h.FLOAT,!1,0,0),h.uniform1f(nt,E*Math.sqrt(I.k)*3*S),h.drawArrays(h.POINTS,0,1),h.deleteBuffer(fu),h.deleteBuffer(pu),h.deleteBuffer(yu)}}function lt(){!i.value||!r.value||(a=N(i.value),!a)||(Z(i.value,a),c=V(a,`
13
+ LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);h.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:N.value,tableName:c.value,isConnected:B.value,activeConnections:i.activeConnectionCount,hasActiveConnections:i.hasActiveConnections}));const It=async()=>{try{const{connection:m,connectionId:b}=await i.createConnection(n.viewerId);N.value=b,l.value&&(await $t(),ht())}catch(m){console.error("Failed to initialize viewer:",m),_.value=`Failed to initialize: ${m.message}`}},$t=async()=>{if(!l.value){_.value="Please provide a valid S3 URL";return}const m=n.fileId||l.value,b=i.getLoadedFile(m);if(b&&!b.isLoading&&!b.error){c.value=b.tableName,F("SELECT * FROM data LIMIT 10;");return}a.value=!0,_.value="";try{const w=n.fileId?`file_${n.fileId}`:`data_${Date.now()}`,I=await i.loadFile(l.value,n.fileType,w,s.value,n.viewerId,n.fileId);c.value=I,F("SELECT * FROM data LIMIT 10;")}catch{}finally{a.value=!1}},dt=m=>!c.value||!m?m:m.replace(/\bFROM\s+data\b/gi,`FROM ${c.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${c.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${c.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${c.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${c.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${c.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${c.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${c.value})`),ht=async()=>{if(!d.value||!N.value){_.value="Please provide a valid SQL query";return}if(!c.value){_.value="No data table loaded";return}o.value=!0,_.value="",E.value=1;try{const m=dt(d.value.trim());y.value=await i.executeQuery(m,N.value),await i.publishViewFromQuery("umap_result",m,N.value),r("query-results",{results:y.value,query:m})}catch(m){console.error("Query execution failed:",m),_.value=`Query execution failed: ${m.message}`,y.value=null}finally{o.value=!1}},Zt=m=>{E.value=m},R=m=>{T.value=m,E.value=1},F=m=>{d.value=m},p=m=>m==null?"NULL":typeof m=="number"?Number.isInteger(m)?m.toString():m.toFixed(4):typeof m=="string"&&m.length>100?m.substring(0,100)+"...":m.toString(),g=()=>{if(!y.value||y.value.length===0)return;const m=Object.keys(y.value[0]),b=[m.join(","),...y.value.map(O=>m.map(A=>{const M=O[A],J=M==null?"":M.toString();return J.includes(",")?`"${J}"`:J}).join(","))].join(`
14
+ `),w=new Blob([b],{type:"text/csv"}),I=URL.createObjectURL(w),S=document.createElement("a");S.href=I,S.download="query-results.csv",S.click(),URL.revokeObjectURL(I)},u=()=>{_.value=""};return h.onMounted(async()=>{await It()}),h.onUnmounted(async()=>{N.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(N.value),i.activeConnectionCount,i.loadedFiles.size)}),(m,b)=>{const w=h.resolveComponent("bf-button"),I=h.resolveComponent("el-pagination");return h.openBlock(),h.createElementBlock("div",Qc,[h.createElementVNode("header",Xc,[b[3]||(b[3]=h.createElementVNode("h1",null,"Data Explorer",-1)),h.createElementVNode("div",{class:h.normalizeClass(["status-indicator",{connected:B.value,loading:a.value}])},h.toDisplayString(Q.value),3)]),h.createElementVNode("div",Jc,[B.value?(h.openBlock(),h.createElementBlock("div",Zc,[b[5]||(b[5]=h.createElementVNode("h3",null,"SQL Query",-1)),h.createElementVNode("div",tu,[b[4]||(b[4]=h.createElementVNode("span",null,"Quick queries:",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(gt.value,S=>(h.openBlock(),h.createElementBlock("button",{key:S.name,onClick:O=>F(S.query),class:"example-btn"},h.toDisplayString(S.name),9,eu))),128))]),h.withDirectives(h.createElementVNode("textarea",{"onUpdate:modelValue":b[0]||(b[0]=S=>d.value=S),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[h.vModelText,d.value]]),h.createVNode(w,{onClick:ht,disabled:o.value||!d.value},{default:h.withCtx(()=>[h.createTextVNode(h.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):h.createCommentVNode("",!0),y.value?(h.openBlock(),h.createElementBlock("div",nu,[h.createElementVNode("h3",null,"Results ("+h.toDisplayString(y.value.length)+" rows)",1),h.createElementVNode("div",ru,[h.createElementVNode("div",iu,[h.createVNode(w,{class:"secondary",onClick:g},{default:h.withCtx(()=>[...b[6]||(b[6]=[h.createTextVNode("Export to CSV",-1)])]),_:1})]),h.createElementVNode("div",su,[v.value==="table"&&mt.value>1?(h.openBlock(),h.createBlock(I,{key:0,"current-page":E.value,"onUpdate:currentPage":b[1]||(b[1]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:"prev, pager, next",onCurrentChange:Zt,class:"results-pagination"},null,8,["current-page","page-size","total"])):h.createCommentVNode("",!0)])]),b[7]||(b[7]=h.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),v.value==="table"?(h.openBlock(),h.createElementBlock("div",au,[h.createElementVNode("table",ou,[h.createElementVNode("thead",null,[h.createElementVNode("tr",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,S=>(h.openBlock(),h.createElementBlock("th",{key:S},h.toDisplayString(S),1))),128))])]),h.createElementVNode("tbody",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(bt.value,(S,O)=>(h.openBlock(),h.createElementBlock("tr",{key:O},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,A=>(h.openBlock(),h.createElementBlock("td",{key:A},h.toDisplayString(p(S[A])),1))),128))]))),128))])]),mt.value>1?(h.openBlock(),h.createElementBlock("div",lu,[h.createVNode(I,{"current-page":E.value,"onUpdate:currentPage":b[2]||(b[2]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:Zt,onSizeChange:R},null,8,["current-page","page-size","total"])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.createElementBlock("div",cu,[h.createElementVNode("pre",null,h.toDisplayString(JSON.stringify(y.value.slice(0,100),null,2)),1)]))])):h.createCommentVNode("",!0),_.value?(h.openBlock(),h.createElementBlock("div",uu,[b[8]||(b[8]=h.createElementVNode("h3",null,"Error",-1)),h.createElementVNode("p",null,h.toDisplayString(_.value),1),h.createElementVNode("button",{onClick:u,class:"clear-error-btn"},"Clear")])):h.createCommentVNode("",!0)])])}}},du=Sn(hu,[["__scopeId","data-v-6d7b972b"]]),fu={class:"app-container"},pu=h.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=h.ref([]),s=h.ref(""),a=h.ref("parquet"),o=h.ref("");h.onMounted(async()=>{var v,E,T,N,B;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),o.value=n.srcFileId??"url_"+btoa(n.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const _=Kc("",["content","id"],n.pkg);if(!_||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await d(_);const Q=(T=(E=(v=i.value)==null?void 0:v[0])==null?void 0:E.content)==null?void 0:T.id;if(!Q){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=Q,s.value=await y(_,Q);const it=(B=(N=n.pkg)==null?void 0:N.content)==null?void 0:B.packageType;a.value=it==="CSV"?"csv":"parquet"}catch(Q){console.error(Q)}});function l(_){r("queryResults",_)}async function c(){const{useGetToken:_}=await Promise.resolve().then(()=>Bc);return _()}async function d(_){const v=await c(),E=`${n.apiUrl}/packages/${_}/view?api_key=${v}`,T=await fetch(E);if(!T.ok)throw new Error(`view failed: ${T.status}`);i.value=await T.json()}async function y(_,v){const E=await c(),T=`${n.apiUrl}/packages/${_}/files/${v}?api_key=${E}`,N=await fetch(T);if(!N.ok)throw new Error(`file url failed: ${N.status}`);return(await N.json()).url}return(_,v)=>(h.openBlock(),h.createElementBlock("div",fu,[h.createVNode(du,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:v[0]||(v[0]=E=>l(E))},null,8,["url","file-type","file-id"])]))}}),yu=Sn(pu,[["__scopeId","data-v-d6dbc8b5"]]);var mu={value:()=>{}};function vi(){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 sr(n)}function sr(e){this._=e}function bu(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}})}sr.prototype=vi.prototype={constructor:sr,on:function(e,t){var n=this._,r=bu(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=gu(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]=Ys(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ys(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 sr(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 gu(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ys(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=mu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var wi="http://www.w3.org/1999/xhtml";const Ws={svg:"http://www.w3.org/2000/svg",xhtml:wi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ar(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ws.hasOwnProperty(t)?{space:Ws[t],local:e}:e}function _u(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===wi&&t.documentElement.namespaceURI===wi?t.createElement(e):t.createElementNS(n,e)}}function vu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qs(e){var t=ar(e);return(t.local?vu:_u)(t)}function wu(){}function Ii(e){return e==null?wu:function(){return this.querySelector(e)}}function Iu(e){typeof e!="function"&&(e=Ii(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,c,d=0;d<a;++d)(l=s[d])&&(c=e.call(l,l.__data__,d,s))&&("__data__"in l&&(c.__data__=l.__data__),o[d]=c);return new xt(r,this._parents)}function Su(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Eu(){return[]}function Gs(e){return e==null?Eu:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return Su(e.apply(this,arguments))}}function Au(e){typeof e=="function"?e=Tu(e):e=Gs(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,c=0;c<o;++c)(l=a[c])&&(r.push(e.call(l,l.__data__,c,a)),i.push(l));return new xt(r,i)}function Hs(e){return function(){return this.matches(e)}}function Ks(e){return function(t){return t.matches(e)}}var Nu=Array.prototype.find;function Bu(e){return function(){return Nu.call(this.children,e)}}function Ru(){return this.firstElementChild}function Ou(e){return this.select(e==null?Ru:Bu(typeof e=="function"?e:Ks(e)))}var Du=Array.prototype.filter;function Fu(){return Array.from(this.children)}function Mu(e){return function(){return Du.call(this.children,e)}}function Lu(e){return this.selectAll(e==null?Fu:Mu(typeof e=="function"?e:Ks(e)))}function xu(e){typeof e!="function"&&(e=Hs(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,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new xt(r,this._parents)}function Qs(e){return new Array(e.length)}function Uu(){return new xt(this._enter||this._groups.map(Qs),this._parents)}function or(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}or.prototype={constructor:or,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 Cu(e){return function(){return e}}function ku(e,t,n,r,i,s){for(var a=0,o,l=t.length,c=s.length;a<c;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new or(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function $u(e,t,n,r,i,s,a){var o,l,c=new Map,d=t.length,y=s.length,_=new Array(d),v;for(o=0;o<d;++o)(l=t[o])&&(_[o]=v=a.call(l,l.__data__,o,t)+"",c.has(v)?i[o]=l:c.set(v,l));for(o=0;o<y;++o)v=a.call(e,s[o],o,s)+"",(l=c.get(v))?(r[o]=l,l.__data__=s[o],c.delete(v)):n[o]=new or(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&c.get(_[o])===l&&(i[o]=l)}function Pu(e){return e.__data__}function Vu(e,t){if(!arguments.length)return Array.from(this,Pu);var n=t?$u:ku,r=this._parents,i=this._groups;typeof e!="function"&&(e=Cu(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),c=0;c<s;++c){var d=r[c],y=i[c],_=y.length,v=zu(e.call(d,d&&d.__data__,c,r)),E=v.length,T=o[c]=new Array(E),N=a[c]=new Array(E),B=l[c]=new Array(_);n(d,y,T,N,B,v,t);for(var Q=0,it=0,mt,bt;Q<E;++Q)if(mt=T[Q]){for(Q>=it&&(it=Q+1);!(bt=N[it])&&++it<E;);mt._next=bt||null}}return a=new xt(a,r),a._enter=o,a._exit=l,a}function zu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ju(){return new xt(this._exit||this._groups.map(Qs),this._parents)}function Yu(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 Wu(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 c=n[l],d=r[l],y=c.length,_=o[l]=new Array(y),v,E=0;E<y;++E)(v=c[E]||d[E])&&(_[E]=v);for(;l<i;++l)o[l]=n[l];return new xt(o,this._parents)}function qu(){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 Gu(e){e||(e=Hu);function t(y,_){return y&&_?e(y.__data__,_.__data__):!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),c,d=0;d<o;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new xt(i,this._parents).order()}function Hu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ku(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qu(){return Array.from(this)}function Xu(){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 Ju(){let e=0;for(const t of this)++e;return e}function Zu(){return!this.node()}function th(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 eh(e){return function(){this.removeAttribute(e)}}function nh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t){return function(){this.setAttribute(e,t)}}function ih(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ah(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 oh(e,t){var n=ar(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?nh:eh:typeof t=="function"?n.local?ah:sh:n.local?ih:rh)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lh(e){return function(){this.style.removeProperty(e)}}function ch(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uh(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hh(e,t,n){return arguments.length>1?this.each((t==null?lh:typeof t=="function"?uh:ch)(e,t,n??"")):Qe(this.node(),e)}function Qe(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function dh(e){return function(){delete this[e]}}function fh(e,t){return function(){this[e]=t}}function ph(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yh(e,t){return arguments.length>1?this.each((t==null?dh:typeof t=="function"?ph:fh)(e,t)):this.node()[e]}function Js(e){return e.trim().split(/^|\s+/)}function Si(e){return e.classList||new Zs(e)}function Zs(e){this._node=e,this._names=Js(e.getAttribute("class")||"")}Zs.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 ta(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function ea(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mh(e){return function(){ta(this,e)}}function bh(e){return function(){ea(this,e)}}function gh(e,t){return function(){(t.apply(this,arguments)?ta:ea)(this,e)}}function _h(e,t){var n=Js(e+"");if(arguments.length<2){for(var r=Si(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?gh:t?mh:bh)(n,t))}function vh(){this.textContent=""}function wh(e){return function(){this.textContent=e}}function Ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sh(e){return arguments.length?this.each(e==null?vh:(typeof e=="function"?Ih:wh)(e)):this.node().textContent}function Eh(){this.innerHTML=""}function Th(e){return function(){this.innerHTML=e}}function Ah(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Nh(e){return arguments.length?this.each(e==null?Eh:(typeof e=="function"?Ah:Th)(e)):this.node().innerHTML}function Bh(){this.nextSibling&&this.parentNode.appendChild(this)}function Rh(){return this.each(Bh)}function Oh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dh(){return this.each(Oh)}function Fh(e){var t=typeof e=="function"?e:qs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mh(){return null}function Lh(e,t){var n=typeof e=="function"?e:qs(e),r=t==null?Mh:typeof t=="function"?t:Ii(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function xh(){var e=this.parentNode;e&&e.removeChild(this)}function Uh(){return this.each(xh)}function Ch(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $h(e){return this.select(e?kh:Ch)}function Ph(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vh(e){return function(t){e.call(this,t,this.__data__)}}function zh(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 jh(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 Yh(e,t,n){return function(){var r=this.__on,i,s=Vh(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 Wh(e,t,n){var r=zh(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,d;l<c;++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?Yh:jh,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function na(e,t,n){var r=Xs(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 qh(e,t){return function(){return na(this,e,t)}}function Gh(e,t){return function(){return na(this,e,t.apply(this,arguments))}}function Hh(e,t){return this.each((typeof t=="function"?Gh:qh)(e,t))}function*Kh(){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 ra=[null];function xt(e,t){this._groups=e,this._parents=t}function En(){return new xt([[document.documentElement]],ra)}function Qh(){return this}xt.prototype=En.prototype={constructor:xt,select:Iu,selectAll:Au,selectChild:Ou,selectChildren:Lu,filter:xu,data:Vu,enter:Uu,exit:ju,join:Yu,merge:Wu,selection:Qh,order:qu,sort:Gu,call:Ku,nodes:Qu,node:Xu,size:Ju,empty:Zu,each:th,attr:oh,style:hh,property:yh,classed:_h,text:Sh,html:Nh,raise:Rh,lower:Dh,append:Fh,insert:Lh,remove:Uh,clone:$h,datum:Ph,on:Wh,dispatch:Hh,[Symbol.iterator]:Kh};function pe(e){return typeof e=="string"?new xt([[document.querySelector(e)]],[document.documentElement]):new xt([[e]],ra)}function Xh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=Xh(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 Ei={capture:!0,passive:!1};function Ti(e){e.preventDefault(),e.stopImmediatePropagation()}function Jh(e){var t=e.document.documentElement,n=pe(e).on("dragstart.drag",Ti,Ei);"onselectstart"in t?n.on("selectstart.drag",Ti,Ei):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zh(e,t){var n=e.document.documentElement,r=pe(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ti,Ei),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 Ai(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ia(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Tn(){}var An=.7,lr=1/An,Xe="\\s*([+-]?\\d+)\\s*",Nn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",td=/^#([0-9a-f]{3,8})$/,ed=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),nd=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),rd=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Nn}\\)$`),id=new RegExp(`^rgba\\(${ee},${ee},${ee},${Nn}\\)$`),sd=new RegExp(`^hsl\\(${Nn},${ee},${ee}\\)$`),ad=new RegExp(`^hsla\\(${Nn},${ee},${ee},${Nn}\\)$`),sa={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};Ai(Tn,Bn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:od,formatHsl:ld,formatRgb:oa,toString:oa});function aa(){return this.rgb().formatHex()}function od(){return this.rgb().formatHex8()}function ld(){return da(this).formatHsl()}function oa(){return this.rgb().formatRgb()}function Bn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=td.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?la(t):n===3?new Ot(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?cr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?cr(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=ed.exec(e))?new Ot(t[1],t[2],t[3],1):(t=nd.exec(e))?new Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rd.exec(e))?cr(t[1],t[2],t[3],t[4]):(t=id.exec(e))?cr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sd.exec(e))?ha(t[1],t[2]/100,t[3]/100,1):(t=ad.exec(e))?ha(t[1],t[2]/100,t[3]/100,t[4]):sa.hasOwnProperty(e)?la(sa[e]):e==="transparent"?new Ot(NaN,NaN,NaN,0):null}function la(e){return new Ot(e>>16&255,e>>8&255,e&255,1)}function cr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ot(e,t,n,r)}function cd(e){return e instanceof Tn||(e=Bn(e)),e?(e=e.rgb(),new Ot(e.r,e.g,e.b,e.opacity)):new Ot}function Ni(e,t,n,r){return arguments.length===1?cd(e):new Ot(e,t,n,r??1)}function Ot(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ai(Ot,Ni,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ot(Pe(this.r),Pe(this.g),Pe(this.b),ur(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:ca,formatHex:ca,formatHex8:ud,formatRgb:ua,toString:ua}));function ca(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function ud(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function ua(){const e=ur(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function ur(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function ha(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ht(e,t,n,r)}function da(e){if(e instanceof Ht)return new Ht(e.h,e.s,e.l,e.opacity);if(e instanceof Tn||(e=Bn(e)),!e)return new Ht;if(e instanceof Ht)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 Ht(a,o,l,e.opacity)}function hd(e,t,n,r){return arguments.length===1?da(e):new Ht(e,t,n,r??1)}function Ht(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ai(Ht,hd,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ht(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ht(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 Ot(Bi(e>=240?e-240:e+120,i,r),Bi(e,i,r),Bi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ht(fa(this.h),hr(this.s),hr(this.l),ur(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=ur(this.opacity);return`${e===1?"hsl(":"hsla("}${fa(this.h)}, ${hr(this.s)*100}%, ${hr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fa(e){return e=(e||0)%360,e<0?e+360:e}function hr(e){return Math.max(0,Math.min(1,e||0))}function Bi(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 pa=e=>()=>e;function dd(e,t){return function(n){return e+n*t}}function fd(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 pd(e){return(e=+e)==1?ya:function(t,n){return n-t?fd(t,n,e):pa(isNaN(t)?n:t)}}function ya(e,t){var n=t-e;return n?dd(e,n):pa(isNaN(e)?t:e)}const ma=function e(t){var n=pd(t);function r(i,s){var a=n((i=Ni(i)).r,(s=Ni(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=ya(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=e,r}(1);function Ne(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Ri=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oi=new RegExp(Ri.source,"g");function yd(e){return function(){return e}}function md(e){return function(t){return e(t)+""}}function bd(e,t){var n=Ri.lastIndex=Oi.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Ri.exec(e))&&(i=Oi.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:Ne(r,i)})),n=Oi.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?md(l[0].x):yd(t):(t=l.length,function(c){for(var d=0,y;d<t;++d)o[(y=l[d]).i]=y.x(c);return o.join("")})}var ba=180/Math.PI,ga={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _a(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)*ba,skewX:Math.atan(l)*ba,scaleX:a,scaleY:o}}var dr;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ga:_a(t.a,t.b,t.c,t.d,t.e,t.f)}function _d(e){return e==null||(dr||(dr=document.createElementNS("http://www.w3.org/2000/svg","g")),dr.setAttribute("transform",e),!(e=dr.transform.baseVal.consolidate()))?ga:(e=e.matrix,_a(e.a,e.b,e.c,e.d,e.e,e.f))}function va(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function s(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push("translate(",null,t,null,n);E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y||_)&&v.push("translate("+y+t+_+n)}function a(c,d,y,_){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),_.push({i:y.push(i(y)+"rotate(",null,r)-2,x:Ne(c,d)})):d&&y.push(i(y)+"rotate("+d+r)}function o(c,d,y,_){c!==d?_.push({i:y.push(i(y)+"skewX(",null,r)-2,x:Ne(c,d)}):d&&y.push(i(y)+"skewX("+d+r)}function l(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push(i(v)+"scale(",null,",",null,")");E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y!==1||_!==1)&&v.push(i(v)+"scale("+y+","+_+")")}return function(c,d){var y=[],_=[];return c=e(c),d=e(d),s(c.translateX,c.translateY,d.translateX,d.translateY,y,_),a(c.rotate,d.rotate,y,_),o(c.skewX,d.skewX,y,_),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,y,_),c=d=null,function(v){for(var E=-1,T=_.length,N;++E<T;)y[(N=_[E]).i]=N.x(v);return y.join("")}}}var vd=va(gd,"px, ","px)","deg)"),wd=va(_d,", ",")",")"),Id=1e-12;function wa(e){return((e=Math.exp(e))+1/e)/2}function Sd(e){return((e=Math.exp(e))-1/e)/2}function Ed(e){return((e=Math.exp(2*e))-1)/(e+1)}const Td=function e(t,n,r){function i(s,a){var o=s[0],l=s[1],c=s[2],d=a[0],y=a[1],_=a[2],v=d-o,E=y-l,T=v*v+E*E,N,B;if(T<Id)B=Math.log(_/c)/t,N=function(It){return[o+It*v,l+It*E,c*Math.exp(t*It*B)]};else{var Q=Math.sqrt(T),it=(_*_-c*c+r*T)/(2*c*n*Q),mt=(_*_-c*c-r*T)/(2*_*n*Q),bt=Math.log(Math.sqrt(it*it+1)-it),gt=Math.log(Math.sqrt(mt*mt+1)-mt);B=(gt-bt)/t,N=function(It){var $t=It*B,dt=wa(bt),ht=c/(n*Q)*(dt*Ed(t*$t+bt)-Sd(bt));return[o+ht*v,l+ht*E,c*dt/wa(t*$t+bt)]}}return N.duration=B*1e3*t/Math.SQRT2,N}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 Je=0,Rn=0,On=0,Ia=1e3,fr,Dn,pr=0,ze=0,yr=0,Fn=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Di(){return ze||(Sa(Ad),ze=Fn.now()+yr)}function Ad(){ze=0}function mr(){this._call=this._time=this._next=null}mr.prototype=Ea.prototype={constructor:mr,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Di():+n)+(t==null?0:+t),!this._next&&Dn!==this&&(Dn?Dn._next=this:fr=this,Dn=this),this._call=e,this._time=n,Fi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fi())}};function Ea(e,t,n){var r=new mr;return r.restart(e,t,n),r}function Nd(){Di(),++Je;for(var e=fr,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Je}function Ta(){ze=(pr=Fn.now())+yr,Je=Rn=0;try{Nd()}finally{Je=0,Rd(),ze=0}}function Bd(){var e=Fn.now(),t=e-pr;t>Ia&&(yr-=t,pr=e)}function Rd(){for(var e,t=fr,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:fr=n);Dn=e,Fi(r)}function Fi(e){if(!Je){Rn&&(Rn=clearTimeout(Rn));var t=e-ze;t>24?(e<1/0&&(Rn=setTimeout(Ta,e-Fn.now()-yr)),On&&(On=clearInterval(On))):(On||(pr=Fn.now(),On=setInterval(Bd,Ia)),Je=1,Sa(Ta))}}function Aa(e,t,n){var r=new mr;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Od=vi("start","end","cancel","interrupt"),Dd=[],Na=0,Ba=1,Mi=2,br=3,Ra=4,Li=5,gr=6;function _r(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Fd(e,n,{name:t,index:r,group:i,on:Od,tween:Dd,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Na})}function xi(e,t){var n=Kt(e,t);if(n.state>Na)throw new Error("too late; already scheduled");return n}function ne(e,t){var n=Kt(e,t);if(n.state>br)throw new Error("too late; already running");return n}function Kt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fd(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ea(s,0,n.time);function s(c){n.state=Ba,n.timer.restart(a,n.delay,n.time),n.delay<=c&&a(c-n.delay)}function a(c){var d,y,_,v;if(n.state!==Ba)return l();for(d in r)if(v=r[d],v.name===n.name){if(v.state===br)return Aa(a);v.state===Ra?(v.state=gr,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[d]):+d<t&&(v.state=gr,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[d])}if(Aa(function(){n.state===br&&(n.state=Ra,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=Mi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Mi){for(n.state=br,i=new Array(_=n.tween.length),d=0,y=-1;d<_;++d)(v=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++y]=v);i.length=y+1}}function o(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Li,1),y=-1,_=i.length;++y<_;)i[y].call(e,d);n.state===Li&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=gr,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function vr(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>Mi&&r.state<Li,r.state=gr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Md(e){return this.each(function(){vr(this,e)})}function Ld(e,t){var n,r;return function(){var i=ne(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 xd(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ne(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=o;break}l===c&&i.push(o)}s.tween=i}}function Ud(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Kt(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?Ld:xd)(n,e,t))}function Ui(e,t,n){var r=e._id;return e.each(function(){var i=ne(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Kt(i,r).value[t]}}function Oa(e,t){var n;return(typeof t=="number"?Ne:t instanceof Bn?ma:(n=Bn(t))?(t=n,ma):bd)(e,t)}function Cd(e){return function(){this.removeAttribute(e)}}function kd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $d(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 Pd(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 Vd(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 zd(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 jd(e,t){var n=ar(e),r=n==="transform"?wd:Oa;return this.attrTween(e,typeof t=="function"?(n.local?zd:Vd)(n,r,Ui(this,"attr."+e,t)):t==null?(n.local?kd:Cd)(n):(n.local?Pd:$d)(n,r,t))}function Yd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Wd(e,s)),n}return i._value=t,i}function Gd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Yd(e,s)),n}return i._value=t,i}function Hd(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=ar(e);return this.tween(n,(r.local?qd:Gd)(r,t))}function Kd(e,t){return function(){xi(this,e).delay=+t.apply(this,arguments)}}function Qd(e,t){return t=+t,function(){xi(this,e).delay=t}}function Xd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kd:Qd)(t,e)):Kt(this.node(),t).delay}function Jd(e,t){return function(){ne(this,e).duration=+t.apply(this,arguments)}}function Zd(e,t){return t=+t,function(){ne(this,e).duration=t}}function tf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jd:Zd)(t,e)):Kt(this.node(),t).duration}function ef(e,t){if(typeof t!="function")throw new Error;return function(){ne(this,e).ease=t}}function nf(e){var t=this._id;return arguments.length?this.each(ef(t,e)):Kt(this.node(),t).ease}function rf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ne(this,e).ease=n}}function sf(e){if(typeof e!="function")throw new Error;return this.each(rf(this._id,e))}function af(e){typeof e!="function"&&(e=Hs(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,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new ye(r,this._parents,this._name,this._id)}function of(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],c=n[o],d=l.length,y=a[o]=new Array(d),_,v=0;v<d;++v)(_=l[v]||c[v])&&(y[v]=_);for(;o<r;++o)a[o]=t[o];return new ye(a,this._parents,this._name,this._id)}function lf(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 cf(e,t,n){var r,i,s=lf(t)?xi:ne;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function uf(e,t){var n=this._id;return arguments.length<2?Kt(this.node(),n).on.on(e):this.each(cf(n,e,t))}function hf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function df(){return this.on("end.remove",hf(this._id))}function ff(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ii(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,c=s[a]=new Array(l),d,y,_=0;_<l;++_)(d=o[_])&&(y=e.call(d,d.__data__,_,o))&&("__data__"in d&&(y.__data__=d.__data__),c[_]=y,_r(c[_],t,n,_,c,Kt(d,n)));return new ye(s,this._parents,t,n)}function pf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gs(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],c=l.length,d,y=0;y<c;++y)if(d=l[y]){for(var _=e.call(d,d.__data__,y,l),v,E=Kt(d,n),T=0,N=_.length;T<N;++T)(v=_[T])&&_r(v,t,n,T,_,E);s.push(_),a.push(d)}return new ye(s,a,t,n)}var yf=En.prototype.constructor;function mf(){return new yf(this._groups,this._parents)}function bf(e,t){var n,r,i;return function(){var s=Qe(this,e),a=(this.style.removeProperty(e),Qe(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function Da(e){return function(){this.style.removeProperty(e)}}function gf(e,t,n){var r,i=n+"",s;return function(){var a=Qe(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function _f(e,t,n){var r,i,s;return function(){var a=Qe(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Qe(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function vf(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=ne(this,e),c=l.on,d=l.value[s]==null?o||(o=Da(t)):void 0;(c!==n||i!==d)&&(r=(n=c).copy()).on(a,i=d),l.on=r}}function wf(e,t,n){var r=(e+="")=="transform"?vd:Oa;return t==null?this.styleTween(e,bf(e,r)).on("end.style."+e,Da(e)):typeof t=="function"?this.styleTween(e,_f(e,r,Ui(this,"style."+e,t))).each(vf(this._id,e)):this.styleTween(e,gf(e,r,t),n).on("end.style."+e,null)}function If(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Sf(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&If(e,a,n)),r}return s._value=t,s}function Ef(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,Sf(e,t,n??""))}function Tf(e){return function(){this.textContent=e}}function Af(e){return function(){var t=e(this);this.textContent=t??""}}function Nf(e){return this.tween("text",typeof e=="function"?Af(Ui(this,"text",e)):Tf(e==null?"":e+""))}function Bf(e){return function(t){this.textContent=e.call(this,t)}}function Rf(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Bf(i)),t}return r._value=e,r}function Of(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,Rf(e))}function Df(){for(var e=this._name,t=this._id,n=Fa(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)if(l=a[c]){var d=Kt(l,t);_r(l,e,n,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ye(r,this._parents,e,n)}function Ff(){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 c=ne(this,r),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),c.on=t}),i===0&&s()})}var Mf=0;function ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fa(){return++Mf}var me=En.prototype;ye.prototype={constructor:ye,select:ff,selectAll:pf,selectChild:me.selectChild,selectChildren:me.selectChildren,filter:af,merge:of,selection:mf,transition:Df,call:me.call,nodes:me.nodes,node:me.node,size:me.size,empty:me.empty,each:me.each,on:uf,attr:jd,attrTween:Hd,style:wf,styleTween:Ef,text:Nf,textTween:Of,remove:df,tween:Ud,delay:Xd,duration:tf,ease:nf,easeVarying:sf,end:Ff,[Symbol.iterator]:me[Symbol.iterator]};function Lf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xf={time:null,delay:0,duration:250,ease:Lf};function Uf(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 Cf(e){var t,n;e instanceof ye?(t=e._id,e=e._name):(t=Fa(),(n=xf).time=Di(),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,c=0;c<o;++c)(l=a[c])&&_r(l,e,t,c,a,n||Uf(l,t));return new ye(r,this._parents,e,t)}En.prototype.interrupt=Md,En.prototype.transition=Cf;const wr=e=>()=>e;function kf(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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 Ir=new be(1,0,0);be.prototype;function Ci(e){e.stopImmediatePropagation()}function Mn(e){e.preventDefault(),e.stopImmediatePropagation()}function $f(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Pf(){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 Ma(){return this.__zoom||Ir}function Vf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zf(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(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 Yf(){var e=$f,t=Pf,n=jf,r=Vf,i=zf,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Td,c=vi("start","zoom","end"),d,y,_,v=500,E=150,T=0,N=10;function B(p){p.property("__zoom",Ma).on("wheel.zoom",$t,{passive:!1}).on("mousedown.zoom",dt).on("dblclick.zoom",ht).filter(i).on("touchstart.zoom",Zt).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}B.transform=function(p,g,u,m){var b=p.selection?p.selection():p;b.property("__zoom",Ma),p!==b?bt(p,g,u,m):b.interrupt().each(function(){gt(this,arguments).event(m).start().zoom(null,typeof g=="function"?g.apply(this,arguments):g).end()})},B.scaleBy=function(p,g,u,m){B.scaleTo(p,function(){var b=this.__zoom.k,w=typeof g=="function"?g.apply(this,arguments):g;return b*w},u,m)},B.scaleTo=function(p,g,u,m){B.transform(p,function(){var b=t.apply(this,arguments),w=this.__zoom,I=u==null?mt(b):typeof u=="function"?u.apply(this,arguments):u,S=w.invert(I),O=typeof g=="function"?g.apply(this,arguments):g;return n(it(Q(w,O),I,S),b,a)},u,m)},B.translateBy=function(p,g,u,m){B.transform(p,function(){return n(this.__zoom.translate(typeof g=="function"?g.apply(this,arguments):g,typeof u=="function"?u.apply(this,arguments):u),t.apply(this,arguments),a)},null,m)},B.translateTo=function(p,g,u,m,b){B.transform(p,function(){var w=t.apply(this,arguments),I=this.__zoom,S=m==null?mt(w):typeof m=="function"?m.apply(this,arguments):m;return n(Ir.translate(S[0],S[1]).scale(I.k).translate(typeof g=="function"?-g.apply(this,arguments):-g,typeof u=="function"?-u.apply(this,arguments):-u),w,a)},m,b)};function Q(p,g){return g=Math.max(s[0],Math.min(s[1],g)),g===p.k?p:new be(g,p.x,p.y)}function it(p,g,u){var m=g[0]-u[0]*p.k,b=g[1]-u[1]*p.k;return m===p.x&&b===p.y?p:new be(p.k,m,b)}function mt(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function bt(p,g,u,m){p.on("start.zoom",function(){gt(this,arguments).event(m).start()}).on("interrupt.zoom end.zoom",function(){gt(this,arguments).event(m).end()}).tween("zoom",function(){var b=this,w=arguments,I=gt(b,w).event(m),S=t.apply(b,w),O=u==null?mt(S):typeof u=="function"?u.apply(b,w):u,A=Math.max(S[1][0]-S[0][0],S[1][1]-S[0][1]),M=b.__zoom,J=typeof g=="function"?g.apply(b,w):g,st=l(M.invert(O).concat(A/M.k),J.invert(O).concat(A/J.k));return function(ct){if(ct===1)ct=J;else{var St=st(ct),Ke=A/St[2];ct=new be(Ke,O[0]-St[0]*Ke,O[1]-St[1]*Ke)}I.zoom(null,ct)}})}function gt(p,g,u){return!u&&p.__zooming||new It(p,g)}function It(p,g){this.that=p,this.args=g,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,g),this.taps=0}It.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,g){return this.mouse&&p!=="mouse"&&(this.mouse[1]=g.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=g.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=g.invert(this.touch1[0])),this.that.__zoom=g,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var g=pe(this.that).datum();c.call(p,this.that,new kf(p,{sourceEvent:this.sourceEvent,target:B,transform:this.that.__zoom,dispatch:c}),g)}};function $t(p,...g){if(!e.apply(this,arguments))return;var u=gt(this,g).event(p),m=this.__zoom,b=Math.max(s[0],Math.min(s[1],m.k*Math.pow(2,r.apply(this,arguments)))),w=$e(p);if(u.wheel)(u.mouse[0][0]!==w[0]||u.mouse[0][1]!==w[1])&&(u.mouse[1]=m.invert(u.mouse[0]=w)),clearTimeout(u.wheel);else{if(m.k===b)return;u.mouse=[w,m.invert(w)],vr(this),u.start()}Mn(p),u.wheel=setTimeout(I,E),u.zoom("mouse",n(it(Q(m,b),u.mouse[0],u.mouse[1]),u.extent,a));function I(){u.wheel=null,u.end()}}function dt(p,...g){if(_||!e.apply(this,arguments))return;var u=p.currentTarget,m=gt(this,g,!0).event(p),b=pe(p.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",A,!0),w=$e(p,u),I=p.clientX,S=p.clientY;Jh(p.view),Ci(p),m.mouse=[w,this.__zoom.invert(w)],vr(this),m.start();function O(M){if(Mn(M),!m.moved){var J=M.clientX-I,st=M.clientY-S;m.moved=J*J+st*st>T}m.event(M).zoom("mouse",n(it(m.that.__zoom,m.mouse[0]=$e(M,u),m.mouse[1]),m.extent,a))}function A(M){b.on("mousemove.zoom mouseup.zoom",null),Zh(M.view,m.moved),Mn(M),m.event(M).end()}}function ht(p,...g){if(e.apply(this,arguments)){var u=this.__zoom,m=$e(p.changedTouches?p.changedTouches[0]:p,this),b=u.invert(m),w=u.k*(p.shiftKey?.5:2),I=n(it(Q(u,w),m,b),t.apply(this,g),a);Mn(p),o>0?pe(this).transition().duration(o).call(bt,I,m,p):pe(this).call(B.transform,I,m,p)}}function Zt(p,...g){if(e.apply(this,arguments)){var u=p.touches,m=u.length,b=gt(this,g,p.changedTouches.length===m).event(p),w,I,S,O;for(Ci(p),I=0;I<m;++I)S=u[I],O=$e(S,this),O=[O,this.__zoom.invert(O),S.identifier],b.touch0?!b.touch1&&b.touch0[2]!==O[2]&&(b.touch1=O,b.taps=0):(b.touch0=O,w=!0,b.taps=1+!!d);d&&(d=clearTimeout(d)),w&&(b.taps<2&&(y=O[0],d=setTimeout(function(){d=null},v)),vr(this),b.start())}}function R(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I,S,O;for(Mn(p),w=0;w<b;++w)I=m[w],S=$e(I,this),u.touch0&&u.touch0[2]===I.identifier?u.touch0[0]=S:u.touch1&&u.touch1[2]===I.identifier&&(u.touch1[0]=S);if(I=u.that.__zoom,u.touch1){var A=u.touch0[0],M=u.touch0[1],J=u.touch1[0],st=u.touch1[1],ct=(ct=J[0]-A[0])*ct+(ct=J[1]-A[1])*ct,St=(St=st[0]-M[0])*St+(St=st[1]-M[1])*St;I=Q(I,Math.sqrt(ct/St)),S=[(A[0]+J[0])/2,(A[1]+J[1])/2],O=[(M[0]+st[0])/2,(M[1]+st[1])/2]}else if(u.touch0)S=u.touch0[0],O=u.touch0[1];else return;u.zoom("touch",n(it(I,S,O),u.extent,a))}}function F(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I;for(Ci(p),_&&clearTimeout(_),_=setTimeout(function(){_=null},v),w=0;w<b;++w)I=m[w],u.touch0&&u.touch0[2]===I.identifier?delete u.touch0:u.touch1&&u.touch1[2]===I.identifier&&delete u.touch1;if(u.touch1&&!u.touch0&&(u.touch0=u.touch1,delete u.touch1),u.touch0)u.touch0[1]=this.__zoom.invert(u.touch0[0]);else if(u.end(),u.taps===2&&(I=$e(I,this),Math.hypot(y[0]-I[0],y[1]-I[1])<N)){var S=pe(this).on("dblclick.zoom");S&&S.apply(this,arguments)}}}return B.wheelDelta=function(p){return arguments.length?(r=typeof p=="function"?p:wr(+p),B):r},B.filter=function(p){return arguments.length?(e=typeof p=="function"?p:wr(!!p),B):e},B.touchable=function(p){return arguments.length?(i=typeof p=="function"?p:wr(!!p),B):i},B.extent=function(p){return arguments.length?(t=typeof p=="function"?p:wr([[+p[0][0],+p[0][1]],[+p[1][0],+p[1][1]]]),B):t},B.scaleExtent=function(p){return arguments.length?(s[0]=+p[0],s[1]=+p[1],B):[s[0],s[1]]},B.translateExtent=function(p){return arguments.length?(a[0][0]=+p[0][0],a[1][0]=+p[1][0],a[0][1]=+p[0][1],a[1][1]=+p[1][1],B):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},B.constrain=function(p){return arguments.length?(n=p,B):n},B.duration=function(p){return arguments.length?(o=+p,B):o},B.interpolate=function(p){return arguments.length?(l=p,B):l},B.on=function(){var p=c.on.apply(c,arguments);return p===c?B:p},B.clickDistance=function(p){return arguments.length?(T=(p=+p)*p,B):Math.sqrt(T)},B.tapDistance=function(p){return arguments.length?(N=+p,B):N},B}const Wf=h.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}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=h.ref(null),i=h.ref(null),s=h.ref(null),a=h.ref(null);let o=null,l=null,c=null,d=[],y=null,_=null,v=null,E=0,T=0,N=1;h.watch(()=>n.colorMap,g,{deep:!0});function B(u){if(!u||u.length<7)return[1,0,0];const m=parseInt(u.slice(1,3),16)/255,b=parseInt(u.slice(3,5),16)/255,w=parseInt(u.slice(5,7),16)/255;return[m,b,w].some(Number.isNaN)?[1,0,0]:[m,b,w]}const Q=(u,m,b)=>u+(m-u)*b;function it(u,m){const b=u.parentElement;b&&(N=window.devicePixelRatio||1,E=b.clientWidth||800,T=b.clientHeight||400,u.style.width=`${E}px`,u.style.height=`${T}px`,u.width=Math.round(E*N),u.height=Math.round(T*N),m.viewport(0,0,u.width,u.height))}function mt(u,m){var Hn,Kn,Qn,Rc,Oc,Dc,Fc,Mc,Lc,xc,Uc,Cc;const b=(Dc=(Oc=(Rc=(Qn=(Kn=(Hn=n.metaData)==null?void 0:Hn.row_groups)==null?void 0:Kn[0])==null?void 0:Qn.columns)==null?void 0:Rc[0])==null?void 0:Oc.meta_data)==null?void 0:Dc.statistics,w=(Cc=(Uc=(xc=(Lc=(Mc=(Fc=n.metaData)==null?void 0:Fc.row_groups)==null?void 0:Mc[0])==null?void 0:Lc.columns)==null?void 0:xc[1])==null?void 0:Uc.meta_data)==null?void 0:Cc.statistics,I=Number((b==null?void 0:b.min_value)??-1),S=Number((b==null?void 0:b.max_value)??1),O=Number((w==null?void 0:w.min_value)??-1),A=Number((w==null?void 0:w.max_value)??1),M=(I+S)/2,J=(O+A)/2,st=Math.max(1e-9,S-I),ct=Math.max(1e-9,A-O),St=2/Math.max(st,ct),Ke=y.x/u*2-1,gi=-y.y/m*2+1,Gn=y.k*St,$s=Ke-Gn*M,Ps=gi-Gn*J;return{s:Gn,tx:$s,ty:Ps}}function bt(u,m,b,w){const{s:I,tx:S,ty:O}=mt(b,w),A=u/b*2-1,M=-(m/w*2-1),J=(A-S)/I,st=(M-O)/I;return{x:J,y:st}}function gt(u,m,b,w,I){if(!u.length||!y)return null;const S=bt(m,b,w,I);let O=1/0,A=null;for(const M of u){const J=M.x-S.x,st=M.y-S.y,ct=Math.hypot(J,st),St=3/(y.k/2);ct<O&&ct<St&&(O=ct,A=M)}return A}function It(){const u=[];for(let m=0;m<n.data.length;m++){const b=n.data[m],w=Number(b[0]),I=Number(b[1]);u.push({x:w,y:I,rawX:w,rawY:I,color:[.5,.5,.5],id:m})}return u}function $t(u,m,b){const w=u.createShader(u.VERTEX_SHADER);if(u.shaderSource(w,m),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))return console.error("Vertex shader error:",u.getShaderInfoLog(w)),null;const I=u.createShader(u.FRAGMENT_SHADER);if(u.shaderSource(I,b),u.compileShader(I),!u.getShaderParameter(I,u.COMPILE_STATUS))return console.error("Fragment shader error:",u.getShaderInfoLog(I)),null;const S=u.createProgram();return u.attachShader(S,w),u.attachShader(S,I),u.linkProgram(S),u.getProgramParameter(S,u.LINK_STATUS)?(u.validateProgram(S),u.getProgramParameter(S,u.VALIDATE_STATUS)?S:(console.error("Program validate error:",u.getProgramInfoLog(S)),null)):(console.error("Program link error:",u.getProgramInfoLog(S)),null)}function dt(u,m,b){if(!b.length)return null;const w=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,w);const I=new Float32Array(b.flatMap(ct=>[ct.x,ct.y]));u.bufferData(u.ARRAY_BUFFER,I,u.STATIC_DRAW);const S=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,S);const O=new Float32Array(b.flatMap(ct=>ct.color));u.bufferData(u.ARRAY_BUFFER,O,u.STATIC_DRAW);const A=u.getAttribLocation(m,"a_position"),M=u.getAttribLocation(m,"a_color"),J=u.getUniformLocation(m,"u_viewMatrix"),st=u.getUniformLocation(m,"u_pointSize");return{program:m,positionBuffer:w,colorBuffer:S,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:b.length}}function ht(u,m,b,w=null){if(!u||!m||!y)return;const{program:I,positionBuffer:S,colorBuffer:O,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:ct}=m;u.clearColor(0,0,0,1),u.clear(u.COLOR_BUFFER_BIT),u.useProgram(I),u.enableVertexAttribArray(A),u.bindBuffer(u.ARRAY_BUFFER,S),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0),u.enableVertexAttribArray(M),u.bindBuffer(u.ARRAY_BUFFER,O),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0);const St=u.canvas.clientWidth,Ke=u.canvas.clientHeight,{s:gi,tx:Gn,ty:$s}=mt(St,Ke),Ps=new Float32Array([gi,0,0,0,0,gi,0,0,0,0,1,0,Gn,$s,0,1]);if(u.uniformMatrix4fv(J,!1,Ps),u.uniform1f(st,Math.max(1.5,b*Math.sqrt(y.k)*N)),u.enable(u.BLEND),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawArrays(u.POINTS,0,ct),w){const Hn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Hn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([w.x,w.y]),u.STATIC_DRAW),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0);const Kn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Kn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,1,.5]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(2.5,b*Math.sqrt(y.k)*2.5*N)),u.drawArrays(u.POINTS,0,1);const Qn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Qn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,.8,.2]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(3,b*Math.sqrt(y.k)*3*N)),u.drawArrays(u.POINTS,0,1),u.deleteBuffer(Hn),u.deleteBuffer(Kn),u.deleteBuffer(Qn)}}function Zt(){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}it(i.value,o),l=$t(o,`
19
15
  attribute vec2 a_position;
20
16
  attribute vec3 a_color;
21
17
  uniform mat4 u_viewMatrix;
@@ -33,17 +29,14 @@
33
29
  float dist = length(gl_PointCoord.xy - vec2(0.5));
34
30
  if (dist > 0.5) discard;
35
31
  float alpha = 1.0;
36
- if (dist > 0.4) {
37
- alpha = 1.0 - (dist - 0.4) * 2.0;
38
- }
32
+ if (dist > 0.4) { alpha = 1.0 - (dist - 0.4) * 2.0; }
39
33
  gl_FragColor = vec4(v_color, alpha);
40
34
  }
41
- `),!c)||(a.useProgram(c),u=B(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),l=j(a,c,u),l&&(d=Rr.translate(b/2,T/2).scale(1),y=Ep().scaleExtent([.1,100]).on("zoom",h=>{if(d=h.transform,G(a,l,d,2,m),o.value){const[v,I]=Oe(h,i.value),E=It(v,I,d,b,T);o.value.innerHTML=`Scale: ${d.k.toFixed(2)}<br/>Translation: (${d.x.toFixed(0)}, ${d.y.toFixed(0)})<br/>Data at cursor: (${E.x.toFixed(2)}, ${E.y.toFixed(2)})`}}),me(i.value).call(y),requestAnimationFrame(()=>G(a,l,d,2,null)),bt()))}function bt(){!i.value||!s.value||(i.value.addEventListener("mousemove",ut),i.value.addEventListener("mouseleave",g))}function ut(h){if(!i.value)return;const v=i.value.getBoundingClientRect(),I=h.clientX-v.left,E=h.clientY-v.top,A=R(u,I,E,d,b,T);if(A){const D=s.value;D.style.left=`${h.clientX+15}px`,D.style.top=`${h.clientY-15}px`,D.style.opacity="1",D.innerHTML=`
42
- <strong>${A.label}</strong><br/>
43
- Species: ${A.species}<br/>
44
- Distance: ${A.value.toFixed(2)}<br/>
45
- Category: ${A.category}
46
- `,m=A,G(a,l,d,2,m)}else s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,G(a,l,d,2,null))}function g(){s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,G(a,l,d,2,null))}function w(){!i.value||!a||(Z(i.value,a),G(a,l,d,2,m))}return f.watch(()=>n.forceRegenerate,()=>{!a||!c||(u=B(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer)),l=j(a,c,u),d=Rr,i.value&&y&&me(i.value).call(y.transform,d),G(a,l,d,2,null))}),f.watch(()=>n.data,()=>{lt()}),f.watch(()=>n.colorMode,()=>{if(!a||!l||!u.length)return;let h=0;const v=n.metaData?.schema||[];for(let A=0;A<v.length;A++)if(v[A].name===n.colorMode){h=A-1;break}const I=new Float32Array(n.data.flatMap(A=>n.colorMap.get(A[h])));a.deleteBuffer(l.colorBuffer);const E=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,E),a.bufferData(a.ARRAY_BUFFER,I,a.STATIC_DRAW),l.colorBuffer=E,G(a,l,d,2,m)}),f.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],()=>{if(["species","sex"].includes(n.colorMode)||!a||!l)return;u=B(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),a.deleteBuffer(l.colorBuffer);const h=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,h);const v=new Float32Array(u.flatMap(I=>I.color));a.bufferData(a.ARRAY_BUFFER,v,a.STATIC_DRAW),l.colorBuffer=h,G(a,l,d,2,m)}),f.watch(()=>n.pointCount,h=>{!a||!c||Math.abs(h-u.length)<=10||(u=B(h,n.colorMode,n.startColor,n.endColor,n.singleColor),l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer)),l=j(a,c,u),G(a,l,d,2,null))}),f.onMounted(()=>{window.addEventListener("resize",w)}),f.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",ut),i.value.removeEventListener("mouseleave",g)),window.removeEventListener("resize",w),a&&l&&(a.deleteBuffer(l.positionBuffer),a.deleteBuffer(l.colorBuffer),c&&a.deleteProgram(c))}),(h,v)=>(f.openBlock(),f.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),f.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),f.withDirectives(f.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:o},null,512),[[f.vShow,!1]])],512))}}),Ap=Dn(Tp,[["__scopeId","data-v-4779cd2a"]]),Np={class:"control-panel"},Rp={class:"color-option"},Bp=["value"],Op={class:"color-option"},Dp={class:"legend"},Lp={class:"legend-label"},Fp=f.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"},options:{type:Array,default:["Type","Species"]},colorScheme:{type:Map,default:new Map},colorMapMap:{type:Map,default:new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate"],setup(e,{emit:t}){const n=e,r=t,i=f.ref(n.pointCount),s=f.ref(n.colorMode),o=f.ref(n.startColor),a=f.ref(n.endColor),c=f.ref(n.singleColor);function l(d){const y=Math.round(d[0]*255),m=Math.round(d[1]*255),b=Math.round(d[2]*255);return`rgb(${y}, ${m}, ${b})`}function u(){r("updateColorMap",[s.value,n.colorMapMap.get(s.value)]),r("update:colorMode",s.value),r("update:startColor",o.value),r("update:endColor",a.value),r("update:singleColor",c.value)}return f.watch(()=>n.pointCount,d=>{i.value=d}),f.watch(()=>n.colorMode,d=>{s.value=d}),f.watch(()=>n.startColor,d=>{o.value=d}),f.watch(()=>n.endColor,d=>{a.value=d}),f.watch(()=>n.singleColor,d=>{c.value=d}),f.watch(()=>s.value,d=>{u()}),f.watch(i,d=>{r("update:pointCount",d)}),(d,y)=>(f.openBlock(),f.createElementBlock("div",Np,[y[3]||(y[3]=f.createElementVNode("h3",null,"Color Controls",-1)),f.createElementVNode("div",Rp,[y[1]||(y[1]=f.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),f.withDirectives(f.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":y[0]||(y[0]=m=>s.value=m)},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(n.colorMapMap,([m,b],T)=>(f.openBlock(),f.createElementBlock("option",{key:m,value:m},f.toDisplayString(m),9,Bp))),128))],512),[[f.vModelSelect,s.value]])]),f.createElementVNode("div",Op,[f.createElementVNode("div",Dp,[y[2]||(y[2]=f.createElementVNode("h4",null," Legend",-1)),(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(e.colorScheme,(m,b)=>(f.openBlock(),f.createElementBlock("div",{class:"legend-item",key:b},[f.createElementVNode("div",{class:"legend-color",style:f.normalizeStyle({backgroundColor:l(m[1])})},null,4),f.createElementVNode("div",Lp,f.toDisplayString(m[0]),1)]))),128))])])]))}}),Mp=Dn(Fp,[["__scopeId","data-v-0a5cce16"]]),Wo=["BOOLEAN","INT32","INT64","INT96","FLOAT","DOUBLE","BYTE_ARRAY","FIXED_LEN_BYTE_ARRAY"],We=["PLAIN","GROUP_VAR_INT","PLAIN_DICTIONARY","RLE","BIT_PACKED","DELTA_BINARY_PACKED","DELTA_LENGTH_BYTE_ARRAY","DELTA_BYTE_ARRAY","RLE_DICTIONARY","BYTE_STREAM_SPLIT"],Up=["REQUIRED","OPTIONAL","REPEATED"],xp=["UTF8","MAP","MAP_KEY_VALUE","LIST","ENUM","DECIMAL","DATE","TIME_MILLIS","TIME_MICROS","TIMESTAMP_MILLIS","TIMESTAMP_MICROS","UINT_8","UINT_16","UINT_32","UINT_64","INT_8","INT_16","INT_32","INT_64","JSON","BSON","INTERVAL"],Cp=["UNCOMPRESSED","SNAPPY","GZIP","LZO","BROTLI","LZ4","ZSTD","LZ4_RAW"],Ho=["DATA_PAGE","INDEX_PAGE","DICTIONARY_PAGE","DATA_PAGE_V2"],Ko={timestampFromMilliseconds(e){return new Date(Number(e))},timestampFromMicroseconds(e){return new Date(Number(e/1000n))},timestampFromNanoseconds(e){return new Date(Number(e/1000000n))},dateFromDays(e){return new Date(e*864e5)}};function Qo(e,t,n,r){if(t&&n.endsWith("_DICTIONARY")){let i=e;e instanceof Uint8Array&&!(t instanceof Uint8Array)&&(i=new t.constructor(e.length));for(let s=0;s<e.length;s++)i[s]=t[e[s]];return i}else return Xo(e,r)}function Xo(e,t){const{element:n,parsers:r,utf8:i=!0}=t,{type:s,converted_type:o,logical_type:a}=n;if(o==="DECIMAL"){const c=10**-(n.scale||0),l=new Array(e.length);for(let u=0;u<l.length;u++)e[0]instanceof Uint8Array?l[u]=Jo(e[u])*c:l[u]=Number(e[u])*c;return l}if(!o&&s==="INT96"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromNanoseconds($p(e[l]));return c}if(o==="DATE"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.dateFromDays(e[l]);return c}if(o==="TIMESTAMP_MILLIS"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromMilliseconds(e[l]);return c}if(o==="TIMESTAMP_MICROS"){const c=new Array(e.length);for(let l=0;l<c.length;l++)c[l]=r.timestampFromMicroseconds(e[l]);return c}if(o==="JSON"){const c=new TextDecoder;return e.map(l=>JSON.parse(c.decode(l)))}if(o==="BSON")throw new Error("parquet bson not supported");if(o==="INTERVAL")throw new Error("parquet interval not supported");if(o==="UTF8"||a?.type==="STRING"||i&&s==="BYTE_ARRAY"){const c=new TextDecoder,l=new Array(e.length);for(let u=0;u<l.length;u++)l[u]=e[u]&&c.decode(e[u]);return l}if(o==="UINT_64"||a?.type==="INTEGER"&&a.bitWidth===64&&!a.isSigned){if(e instanceof BigInt64Array)return new BigUint64Array(e.buffer,e.byteOffset,e.length);const c=new BigUint64Array(e.length);for(let l=0;l<c.length;l++)c[l]=BigInt(e[l]);return c}if(o==="UINT_32"||a?.type==="INTEGER"&&a.bitWidth===32&&!a.isSigned){if(e instanceof Int32Array)return new Uint32Array(e.buffer,e.byteOffset,e.length);const c=new Uint32Array(e.length);for(let l=0;l<c.length;l++)c[l]=e[l];return c}if(a?.type==="FLOAT16")return Array.from(e).map(Zo);if(a?.type==="TIMESTAMP"){const{unit:c}=a;let l=r.timestampFromMilliseconds;c==="MICROS"&&(l=r.timestampFromMicroseconds),c==="NANOS"&&(l=r.timestampFromNanoseconds);const u=new Array(e.length);for(let d=0;d<u.length;d++)u[d]=l(e[d]);return u}return e}function Jo(e){let t=0;for(const r of e)t=t*256+r;const n=e.length*8;return t>=2**(n-1)&&(t-=2**n),t}function $p(e){const t=(e>>64n)-2440588n,n=e&0xffffffffffffffffn;return t*86400000000000n+n}function Zo(e){if(!e)return;const t=e[1]<<8|e[0],n=t>>15?-1:1,r=t>>10&31,i=t&1023;return r===0?n*2**-14*(i/1024):r===31?i?NaN:n*(1/0):n*2**(r-15)*(1+i/1024)}function ta(e,t,n){const r=e[t],i=[];let s=1;if(r.num_children)for(;i.length<r.num_children;){const o=e[t+s],a=ta(e,t+s,[...n,o.name]);s+=a.count,i.push(a)}return{count:s,element:r,children:i,path:n}}function ea(e,t){let n=ta(e,0,[]);const r=[n];for(const i of t){const s=n.children.find(o=>o.element.name===i);if(!s)throw new Error(`parquet schema element not found: ${t}`);r.push(s),n=s}return r}function na(e){let t=0;for(const{element:n}of e)n.repetition_type==="REPEATED"&&t++;return t}function Ki(e){let t=0;for(const{element:n}of e.slice(1))n.repetition_type!=="REQUIRED"&&t++;return t}function kp(e){if(!e||e.element.converted_type!=="LIST"||e.children.length>1)return!1;const t=e.children[0];return!(t.children.length>1||t.element.repetition_type!=="REPEATED")}function Pp(e){if(!e||e.element.converted_type!=="MAP"||e.children.length>1)return!1;const t=e.children[0];return!(t.children.length!==2||t.element.repetition_type!=="REPEATED"||t.children.find(n=>n.element.name==="key")?.element.repetition_type==="REPEATED"||t.children.find(n=>n.element.name==="value")?.element.repetition_type==="REPEATED")}function Vp(e){if(e.length!==2)return!1;const[,t]=e;return!(t.element.repetition_type==="REPEATED"||t.children.length)}const At={STOP:0,TRUE:1,FALSE:2,BYTE:3,I16:4,I32:5,I64:6,DOUBLE:7,BINARY:8,LIST:9,STRUCT:12};function ra(e){let t=0;const n={};for(;e.offset<e.view.byteLength;){const[r,i,s]=sa(e,t);if(t=s,r===At.STOP)break;n[`field_${i}`]=Br(e,r)}return n}function Br(e,t){switch(t){case At.TRUE:return!0;case At.FALSE:return!1;case At.BYTE:return e.view.getInt8(e.offset++);case At.I16:case At.I32:return Yp(e);case At.I64:return Qi(e);case At.DOUBLE:{const n=e.view.getFloat64(e.offset,!0);return e.offset+=8,n}case At.BINARY:{const n=He(e),r=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n);return e.offset+=n,r}case At.LIST:{const[n,r]=jp(e),i=n===At.TRUE||n===At.FALSE,s=new Array(r);for(let o=0;o<r;o++)s[o]=i?Br(e,At.BYTE)===1:Br(e,n);return s}case At.STRUCT:{const n={};let r=0;for(;;){let i,s;if([i,s,r]=sa(e,r),i===At.STOP)break;n[`field_${s}`]=Br(e,i)}return n}default:throw new Error(`thrift unhandled type: ${t}`)}}function He(e){let t=0,n=0;for(;;){const r=e.view.getUint8(e.offset++);if(t|=(r&127)<<n,!(r&128))return t;n+=7}}function zp(e){let t=0n,n=0n;for(;;){const r=e.view.getUint8(e.offset++);if(t|=BigInt(r&127)<<n,!(r&128))return t;n+=7n}}function Yp(e){const t=He(e);return t>>>1^-(t&1)}function Qi(e){const t=zp(e);return t>>1n^-(t&1n)}function ia(e){return e&15}function sa(e,t){const n=e.view.getUint8(e.offset++);if((n&15)===At.STOP)return[0,0,t];const r=n>>4;let i;if(r)i=t+r;else throw new Error("non-delta field id not supported");return[ia(n),i,i]}function jp(e){const t=e.view.getUint8(e.offset++),n=t>>4,r=ia(t);if(n===15){const i=He(e);return[r,i]}return[r,n]}const qp=1<<19;async function Gp(e,{parsers:t,initialFetchSize:n=qp}={}){if(!e||!(e.byteLength>=0))throw new Error("parquet expected AsyncBuffer");const r=Math.max(0,e.byteLength-n),i=await e.slice(r,e.byteLength),s=new DataView(i);if(s.getUint32(i.byteLength-4,!0)!==827474256)throw new Error("parquet file invalid (footer != PAR1)");const o=s.getUint32(i.byteLength-8,!0);if(o>e.byteLength-8)throw new Error(`parquet metadata length ${o} exceeds available buffer ${e.byteLength-8}`);if(o+8>n){const a=e.byteLength-o-8,c=await e.slice(a,r),l=new ArrayBuffer(o+8),u=new Uint8Array(l);return u.set(new Uint8Array(c)),u.set(new Uint8Array(i),r-a),Xi(l,{parsers:t})}else return Xi(i,{parsers:t})}function Xi(e,{parsers:t}={}){if(!(e instanceof ArrayBuffer))throw new Error("parquet expected ArrayBuffer");const n=new DataView(e);if(t={...Ko,...t},n.byteLength<8)throw new Error("parquet file is too short");if(n.getUint32(n.byteLength-4,!0)!==827474256)throw new Error("parquet file invalid (footer != PAR1)");const r=n.byteLength-8,i=n.getUint32(r,!0);if(i>n.byteLength-8)throw new Error(`parquet metadata length ${i} exceeds available buffer ${n.byteLength-8}`);const s=r-i,o=ra({view:n,offset:s}),a=new TextDecoder;function c(S){return S&&a.decode(S)}const l=o.field_1,u=o.field_2.map(S=>({type:Wo[S.field_1],type_length:S.field_2,repetition_type:Up[S.field_3],name:c(S.field_4),num_children:S.field_5,converted_type:xp[S.field_6],scale:S.field_7,precision:S.field_8,field_id:S.field_9,logical_type:Hp(S.field_10)})),d=u.filter(S=>S.type),y=o.field_3,m=o.field_4.map(S=>({columns:S.field_1.map((_,W)=>({file_path:c(_.field_1),file_offset:_.field_2,meta_data:_.field_3&&{type:Wo[_.field_3.field_1],encodings:_.field_3.field_2?.map(Z=>We[Z]),path_in_schema:_.field_3.field_3.map(c),codec:Cp[_.field_3.field_4],num_values:_.field_3.field_5,total_uncompressed_size:_.field_3.field_6,total_compressed_size:_.field_3.field_7,key_value_metadata:_.field_3.field_8,data_page_offset:_.field_3.field_9,index_page_offset:_.field_3.field_10,dictionary_page_offset:_.field_3.field_11,statistics:Kp(_.field_3.field_12,d[W],t),encoding_stats:_.field_3.field_13?.map(Z=>({page_type:Ho[Z.field_1],encoding:We[Z.field_2],count:Z.field_3})),bloom_filter_offset:_.field_3.field_14,bloom_filter_length:_.field_3.field_15,size_statistics:_.field_3.field_16&&{unencoded_byte_array_data_bytes:_.field_3.field_16.field_1,repetition_level_histogram:_.field_3.field_16.field_2,definition_level_histogram:_.field_3.field_16.field_3}},offset_index_offset:_.field_4,offset_index_length:_.field_5,column_index_offset:_.field_6,column_index_length:_.field_7,crypto_metadata:_.field_8,encrypted_column_metadata:_.field_9})),total_byte_size:S.field_2,num_rows:S.field_3,sorting_columns:S.field_4?.map(_=>({column_idx:_.field_1,descending:_.field_2,nulls_first:_.field_3})),file_offset:S.field_5,total_compressed_size:S.field_6,ordinal:S.field_7})),b=o.field_5?.map(S=>({key:c(S.field_1),value:c(S.field_2)})),T=c(o.field_6);return{version:l,schema:u,num_rows:y,row_groups:m,key_value_metadata:b,created_by:T,metadata_length:i}}function Wp({schema:e}){return ea(e,[])[0]}function Hp(e){return e?.field_1?{type:"STRING"}:e?.field_2?{type:"MAP"}:e?.field_3?{type:"LIST"}:e?.field_4?{type:"ENUM"}:e?.field_5?{type:"DECIMAL",scale:e.field_5.field_1,precision:e.field_5.field_2}:e?.field_6?{type:"DATE"}:e?.field_7?{type:"TIME",isAdjustedToUTC:e.field_7.field_1,unit:oa(e.field_7.field_2)}:e?.field_8?{type:"TIMESTAMP",isAdjustedToUTC:e.field_8.field_1,unit:oa(e.field_8.field_2)}:e?.field_10?{type:"INTEGER",bitWidth:e.field_10.field_1,isSigned:e.field_10.field_2}:e?.field_11?{type:"NULL"}:e?.field_12?{type:"JSON"}:e?.field_13?{type:"BSON"}:e?.field_14?{type:"UUID"}:e?.field_15?{type:"FLOAT16"}:e}function oa(e){if(e.field_1)return"MILLIS";if(e.field_2)return"MICROS";if(e.field_3)return"NANOS";throw new Error("parquet time unit required")}function Kp(e,t,n){return e&&{max:Or(e.field_1,t,n),min:Or(e.field_2,t,n),null_count:e.field_3,distinct_count:e.field_4,max_value:Or(e.field_5,t,n),min_value:Or(e.field_6,t,n),is_max_value_exact:e.field_7,is_min_value_exact:e.field_8}}function Or(e,t,n){const{type:r,converted_type:i,logical_type:s}=t;if(e===void 0)return e;if(r==="BOOLEAN")return e[0]===1;if(r==="BYTE_ARRAY")return new TextDecoder().decode(e);const o=new DataView(e.buffer,e.byteOffset,e.byteLength);return r==="FLOAT"&&o.byteLength===4?o.getFloat32(0,!0):r==="DOUBLE"&&o.byteLength===8?o.getFloat64(0,!0):r==="INT32"&&i==="DATE"?n.dateFromDays(o.getInt32(0,!0)):r==="INT64"&&i==="TIMESTAMP_MILLIS"?n.timestampFromMilliseconds(o.getBigInt64(0,!0)):r==="INT64"&&i==="TIMESTAMP_MICROS"?n.timestampFromMicroseconds(o.getBigInt64(0,!0)):r==="INT64"&&s?.type==="TIMESTAMP"&&s?.unit==="NANOS"?n.timestampFromNanoseconds(o.getBigInt64(0,!0)):r==="INT64"&&s?.type==="TIMESTAMP"&&s?.unit==="MICROS"?n.timestampFromMicroseconds(o.getBigInt64(0,!0)):r==="INT64"&&s?.type==="TIMESTAMP"?n.timestampFromMilliseconds(o.getBigInt64(0,!0)):r==="INT32"&&o.byteLength===4?o.getInt32(0,!0):r==="INT64"&&o.byteLength===8?o.getBigInt64(0,!0):i==="DECIMAL"?Jo(e)*10**-(t.scale||0):s?.type==="FLOAT16"?Zo(e):e}function Ji(e,t){for(let n=0;n<t.length;n+=1e4)e.push(...t.slice(n,n+1e4))}function aa(e){if(!e)return[];if(e.length===1)return e[0];const t=[];for(const n of e)Ji(t,n);return t}const Qp=1<<25;function Xp({metadata:e,rowStart:t=0,rowEnd:n=1/0,columns:r}){if(!e)throw new Error("parquetPlan requires metadata");const i=[],s=[];let o=0;for(const a of e.row_groups){const c=Number(a.num_rows),l=o+c;if(c>0&&l>=t&&o<n){const u=[];for(const{file_path:b,meta_data:T}of a.columns){if(b)throw new Error("parquet file_path not supported");if(!T)throw new Error("parquet column metadata is undefined");(!r||r.includes(T.path_in_schema[0]))&&u.push(la(T))}const d=Math.max(t-o,0),y=Math.min(n-o,c);i.push({ranges:u,rowGroup:a,groupStart:o,groupRows:c,selectStart:d,selectEnd:y});const m=u[u.length-1]?.endByte-u[0]?.startByte;if(!r&&m<Qp)s.push({startByte:u[0].startByte,endByte:u[u.length-1].endByte});else if(u.length)Ji(s,u);else if(r?.length)throw new Error(`parquet columns not found: ${r.join(", ")}`)}o=l}return isFinite(n)||(n=o),{metadata:e,rowStart:t,rowEnd:n,columns:r,fetches:s,groups:i}}function la({dictionary_page_offset:e,data_page_offset:t,total_compressed_size:n}){const r=e||t;return{startByte:Number(r),endByte:Number(r+n)}}function Jp(e,{fetches:t}){const n=t.map(({startByte:r,endByte:i})=>e.slice(r,i));return{byteLength:e.byteLength,slice(r,i=e.byteLength){const s=t.findIndex(({startByte:o,endByte:a})=>o<=r&&i<=a);if(s<0)throw new Error(`no prefetch for range [${r}, ${i}]`);if(t[s].startByte!==r||t[s].endByte!==i){const o=r-t[s].startByte,a=i-t[s].startByte;return n[s]instanceof Promise?n[s].then(c=>c.slice(o,a)):n[s].slice(o,a)}else return n[s]}}}function ca(e,t,n,r,i){const s=t?.length||n.length;if(!s)return r;const o=Ki(i),a=i.map(({element:b})=>b.repetition_type);let c=0;const l=[e];let u=e,d=0,y=0,m=0;if(n[0])for(;d<a.length-2&&m<n[0];)d++,a[d]!=="REQUIRED"&&(u=u.at(-1),l.push(u),y++),a[d]==="REPEATED"&&m++;for(let b=0;b<s;b++){const T=t?.length?t[b]:o,S=n[b];for(;d&&(S<m||a[d]!=="REPEATED");)a[d]!=="REQUIRED"&&(l.pop(),y--),a[d]==="REPEATED"&&m--,d--;for(u=l.at(-1);(d<a.length-2||a[d+1]==="REPEATED")&&(y<T||a[d+1]==="REQUIRED");){if(d++,a[d]!=="REQUIRED"){const _=[];u.push(_),u=_,l.push(_),y++}a[d]==="REPEATED"&&m++}T===o?u.push(r[c++]):d===a.length-2?u.push(null):u.push([])}if(!e.length)for(let b=0;b<o;b++){const T=[];u.push(T),u=T}return e}function zn(e,t,n=0){const r=t.path.join("."),i=t.element.repetition_type==="OPTIONAL",s=i?n+1:n;if(kp(t)){let o=t.children[0],a=s;o.children.length===1&&(o=o.children[0],a++),zn(e,o,a);const c=o.path.join("."),l=e.get(c);if(!l)throw new Error("parquet list column missing values");i&&Dr(l,n),e.set(r,l),e.delete(c);return}if(Pp(t)){const o=t.children[0].element.name;zn(e,t.children[0].children[0],s+1),zn(e,t.children[0].children[1],s+1);const a=e.get(`${r}.${o}.key`),c=e.get(`${r}.${o}.value`);if(!a)throw new Error("parquet map column missing keys");if(!c)throw new Error("parquet map column missing values");if(a.length!==c.length)throw new Error("parquet map column key/value length mismatch");const l=ua(a,c,s);i&&Dr(l,n),e.delete(`${r}.${o}.key`),e.delete(`${r}.${o}.value`),e.set(r,l);return}if(t.children.length){const o=t.element.repetition_type==="REQUIRED"?n:n+1,a={};for(const l of t.children){zn(e,l,o);const u=e.get(l.path.join("."));if(!u)throw new Error("parquet struct missing child data");a[l.element.name]=u}for(const l of t.children)e.delete(l.path.join("."));const c=ha(a,o);i&&Dr(c,n),e.set(r,c)}}function Dr(e,t){for(let n=0;n<e.length;n++)t?Dr(e[n],t-1):e[n]=e[n][0]}function ua(e,t,n){const r=[];for(let i=0;i<e.length;i++)if(n)r.push(ua(e[i],t[i],n-1));else if(e[i]){const s={};for(let o=0;o<e[i].length;o++){const a=t[i][o];s[e[i][o]]=a===void 0?null:a}r.push(s)}else r.push(void 0);return r}function ha(e,t){const n=Object.keys(e),r=e[n[0]]?.length,i=[];for(let s=0;s<r;s++){const o={};for(const a of n){if(e[a].length!==r)throw new Error("parquet struct parsing error");o[a]=e[a][s]}t?i.push(ha(o,t-1)):i.push(o)}return i}function Yn(e,t,n){const r=n instanceof Int32Array,i=He(e),s=He(e);He(e);let o=Qi(e),a=0;n[a++]=r?Number(o):o;const c=i/s;for(;a<t;){const l=Qi(e),u=new Uint8Array(s);for(let d=0;d<s;d++)u[d]=e.view.getUint8(e.offset++);for(let d=0;d<s&&a<t;d++){const y=BigInt(u[d]);if(y){let m=0n,b=c;const T=(1n<<y)-1n;for(;b&&a<t;){let S=BigInt(e.view.getUint8(e.offset))>>m&T;for(m+=y;m>=8;)m-=8n,e.offset++,m&&(S|=BigInt(e.view.getUint8(e.offset))<<y-m&T);const _=l+S;o+=_,n[a++]=r?Number(o):o,b--}b&&(e.offset+=Math.ceil((b*Number(y)+Number(m))/8))}else for(let m=0;m<c&&a<t;m++)o+=l,n[a++]=r?Number(o):o}}}function da(e,t,n){const r=new Int32Array(t);Yn(e,t,r);for(let i=0;i<t;i++)n[i]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,r[i]),e.offset+=r[i]}function Zp(e,t,n){const r=new Int32Array(t);Yn(e,t,r);const i=new Int32Array(t);Yn(e,t,i);for(let s=0;s<t;s++){const o=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,i[s]);r[s]?(n[s]=new Uint8Array(r[s]+i[s]),n[s].set(n[s-1].subarray(0,r[s])),n[s].set(o,r[s])):n[s]=o,e.offset+=i[s]}}function Lr(e){return 32-Math.clz32(e)}function Le(e,t,n,r){r===void 0&&(r=e.view.getUint32(e.offset,!0),e.offset+=4);const i=e.offset;let s=0;for(;s<n.length;){const o=He(e);if(o&1)s=ey(e,o,t,n,s);else{const a=o>>>1;ty(e,a,t,n,s),s+=a}}e.offset=i+r}function ty(e,t,n,r,i){const s=n+7>>3;let o=0;for(let a=0;a<s;a++)o|=e.view.getUint8(e.offset++)<<(a<<3);for(let a=0;a<t;a++)r[i+a]=o}function ey(e,t,n,r,i){let s=t>>1<<3;const o=(1<<n)-1;let a=0;if(e.offset<e.view.byteLength)a=e.view.getUint8(e.offset++);else if(o)throw new Error(`parquet bitpack offset ${e.offset} out of range`);let c=8,l=0;for(;s;)l>8?(l-=8,c-=8,a>>>=8):c-l<n?(a|=e.view.getUint8(e.offset)<<c,e.offset++,c+=8):(i<r.length&&(r[i++]=a>>l&o),s--,l+=n);return i}function fa(e,t,n,r){const i=ny(n,r),s=new Uint8Array(t*i);for(let o=0;o<i;o++)for(let a=0;a<t;a++)s[a*i+o]=e.view.getUint8(e.offset++);if(n==="FLOAT")return new Float32Array(s.buffer);if(n==="DOUBLE")return new Float64Array(s.buffer);if(n==="INT32")return new Int32Array(s.buffer);if(n==="INT64")return new BigInt64Array(s.buffer);if(n==="FIXED_LEN_BYTE_ARRAY"){const o=new Array(t);for(let a=0;a<t;a++)o[a]=s.subarray(a*i,(a+1)*i);return o}throw new Error(`parquet byte_stream_split unsupported type: ${n}`)}function ny(e,t){switch(e){case"INT32":case"FLOAT":return 4;case"INT64":case"DOUBLE":return 8;case"FIXED_LEN_BYTE_ARRAY":if(!t)throw new Error("parquet byteWidth missing type_length");return t;default:throw new Error(`parquet unsupported type: ${e}`)}}function Zi(e,t,n,r){if(n===0)return[];if(t==="BOOLEAN")return ry(e,n);if(t==="INT32")return iy(e,n);if(t==="INT64")return sy(e,n);if(t==="INT96")return oy(e,n);if(t==="FLOAT")return ay(e,n);if(t==="DOUBLE")return ly(e,n);if(t==="BYTE_ARRAY")return cy(e,n);if(t==="FIXED_LEN_BYTE_ARRAY"){if(!r)throw new Error("parquet missing fixed length");return uy(e,n,r)}else throw new Error(`parquet unhandled type: ${t}`)}function ry(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.offset+(r/8|0),s=r%8,o=e.view.getUint8(i);n[r]=(o&1<<s)!==0}return e.offset+=Math.ceil(t/8),n}function iy(e,t){const n=(e.view.byteOffset+e.offset)%4?new Int32Array(Fr(e.view.buffer,e.view.byteOffset+e.offset,t*4)):new Int32Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*4,n}function sy(e,t){const n=(e.view.byteOffset+e.offset)%8?new BigInt64Array(Fr(e.view.buffer,e.view.byteOffset+e.offset,t*8)):new BigInt64Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*8,n}function oy(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.view.getBigInt64(e.offset+r*12,!0),s=e.view.getInt32(e.offset+r*12+8,!0);n[r]=BigInt(s)<<64n|i}return e.offset+=t*12,n}function ay(e,t){const n=(e.view.byteOffset+e.offset)%4?new Float32Array(Fr(e.view.buffer,e.view.byteOffset+e.offset,t*4)):new Float32Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*4,n}function ly(e,t){const n=(e.view.byteOffset+e.offset)%8?new Float64Array(Fr(e.view.buffer,e.view.byteOffset+e.offset,t*8)):new Float64Array(e.view.buffer,e.view.byteOffset+e.offset,t);return e.offset+=t*8,n}function cy(e,t){const n=new Array(t);for(let r=0;r<t;r++){const i=e.view.getUint32(e.offset,!0);e.offset+=4,n[r]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,i),e.offset+=i}return n}function uy(e,t,n){const r=new Array(t);for(let i=0;i<t;i++)r[i]=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,n),e.offset+=n;return r}function Fr(e,t,n){const r=new ArrayBuffer(n);return new Uint8Array(r).set(new Uint8Array(e,t,n)),r}const hy=[0,255,65535,16777215,4294967295];function pa(e,t,n,r,i){for(let s=0;s<i;s++)n[r+s]=e[t+s]}function dy(e,t){const n=e.byteLength,r=t.byteLength;let i=0,s=0;for(;i<n;){const o=e[i];if(i++,o<128)break}if(r&&i>=n)throw new Error("invalid snappy length header");for(;i<n;){const o=e[i];let a=0;if(i++,i>=n)throw new Error("missing eof marker");if((o&3)===0){let c=(o>>>2)+1;if(c>60){if(i+3>=n)throw new Error("snappy error literal pos + 3 >= inputLength");const l=c-60;c=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),c=(c&hy[l])+1,i+=l}if(i+c>n)throw new Error("snappy error literal exceeds input length");pa(e,i,t,s,c),i+=c,s+=c}else{let c=0;switch(o&3){case 1:a=(o>>>2&7)+4,c=e[i]+(o>>>5<<8),i++;break;case 2:if(n<=i+1)throw new Error("snappy error end of input");a=(o>>>2)+1,c=e[i]+(e[i+1]<<8),i+=2;break;case 3:if(n<=i+3)throw new Error("snappy error end of input");a=(o>>>2)+1,c=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),i+=4;break}if(c===0||isNaN(c))throw new Error(`invalid offset ${c} pos ${i} inputLength ${n}`);if(c>s)throw new Error("cannot copy from before start of buffer");pa(t,s-c,t,s,a),s+=a}}if(s!==r)throw new Error("premature end of input")}function fy(e,t,{type:n,element:r,schemaPath:i}){const s=new DataView(e.buffer,e.byteOffset,e.byteLength),o={view:s,offset:0};let a;const c=py(o,t,i),{definitionLevels:l,numNulls:u}=yy(o,t,i),d=t.num_values-u;if(t.encoding==="PLAIN")a=Zi(o,n,d,r.type_length);else if(t.encoding==="PLAIN_DICTIONARY"||t.encoding==="RLE_DICTIONARY"||t.encoding==="RLE"){const y=n==="BOOLEAN"?1:s.getUint8(o.offset++);y?(a=new Array(d),n==="BOOLEAN"?(Le(o,y,a),a=a.map(m=>!!m)):Le(o,y,a,s.byteLength-o.offset)):a=new Uint8Array(d)}else if(t.encoding==="BYTE_STREAM_SPLIT")a=fa(o,d,n,r.type_length);else if(t.encoding==="DELTA_BINARY_PACKED")a=n==="INT32"?new Int32Array(d):new BigInt64Array(d),Yn(o,d,a);else if(t.encoding==="DELTA_LENGTH_BYTE_ARRAY")a=new Array(d),da(o,d,a);else throw new Error(`parquet unsupported encoding: ${t.encoding}`);return{definitionLevels:l,repetitionLevels:c,dataPage:a}}function py(e,t,n){if(n.length>1){const r=na(n);if(r){const i=new Array(t.num_values);return Le(e,Lr(r),i),i}}return[]}function yy(e,t,n){const r=Ki(n);if(!r)return{definitionLevels:[],numNulls:0};const i=new Array(t.num_values);Le(e,Lr(r),i);let s=t.num_values;for(const o of i)o===r&&s--;return s===0&&(i.length=0),{definitionLevels:i,numNulls:s}}function ts(e,t,n,r){let i;const s=r?.[n];if(n==="UNCOMPRESSED")i=e;else if(s)i=s(e,t);else if(n==="SNAPPY")i=new Uint8Array(t),dy(e,i);else throw new Error(`parquet unsupported compression codec: ${n}`);if(i?.length!==t)throw new Error(`parquet decompressed page length ${i?.length} does not match header ${t}`);return i}function my(e,t,n){const r={view:new DataView(e.buffer,e.byteOffset,e.byteLength),offset:0},{type:i,element:s,schemaPath:o,codec:a,compressors:c}=n,l=t.data_page_header_v2;if(!l)throw new Error("parquet data page header v2 is undefined");const u=gy(r,l,o);r.offset=l.repetition_levels_byte_length;const d=_y(r,l,o),y=t.uncompressed_page_size-l.definition_levels_byte_length-l.repetition_levels_byte_length;let m=e.subarray(r.offset);l.is_compressed!==!1&&(m=ts(m,y,a,c));const b=new DataView(m.buffer,m.byteOffset,m.byteLength),T={view:b,offset:0};let S;const _=l.num_values-l.num_nulls;if(l.encoding==="PLAIN")S=Zi(T,i,_,s.type_length);else if(l.encoding==="RLE")S=new Array(_),Le(T,1,S),S=S.map(W=>!!W);else if(l.encoding==="PLAIN_DICTIONARY"||l.encoding==="RLE_DICTIONARY"){const W=b.getUint8(T.offset++);S=new Array(_),Le(T,W,S,y-1)}else if(l.encoding==="DELTA_BINARY_PACKED")S=i==="INT32"?new Int32Array(_):new BigInt64Array(_),Yn(T,_,S);else if(l.encoding==="DELTA_LENGTH_BYTE_ARRAY")S=new Array(_),da(T,_,S);else if(l.encoding==="DELTA_BYTE_ARRAY")S=new Array(_),Zp(T,_,S);else if(l.encoding==="BYTE_STREAM_SPLIT")S=fa(r,_,i,s.type_length);else throw new Error(`parquet unsupported encoding: ${l.encoding}`);return{definitionLevels:d,repetitionLevels:u,dataPage:S}}function gy(e,t,n){const r=na(n);if(!r)return[];const i=new Array(t.num_values);return Le(e,Lr(r),i,t.repetition_levels_byte_length),i}function _y(e,t,n){const r=Ki(n);if(r){const i=new Array(t.num_values);return Le(e,Lr(r),i,t.definition_levels_byte_length),i}}function by(e,{groupStart:t,selectStart:n,selectEnd:r},i,s){const{columnName:o}=i,a=[];let c,l,u=0;const d=s&&(()=>{l&&s({columnName:o,columnData:l,rowStart:t+u-l.length,rowEnd:t+u})});for(;u<r&&!(e.offset>=e.view.byteLength-1);){const y=vy(e);if(y.type==="DICTIONARY_PAGE")c=ya(e,y,i,c,void 0,0),c=Xo(c,i);else{const m=l?.length||0,b=ya(e,y,i,c,l,n-u);l===b?u+=b.length-m:(d?.(),a.push(b),u+=b.length,l=b)}}return d?.(),u>r&&l&&(a[a.length-1]=l.slice(0,r-(u-l.length))),a}function ya(e,t,n,r,i,s){const{type:o,element:a,schemaPath:c,codec:l,compressors:u}=n,d=new Uint8Array(e.view.buffer,e.view.byteOffset+e.offset,t.compressed_page_size);if(e.offset+=t.compressed_page_size,t.type==="DATA_PAGE"){const y=t.data_page_header;if(!y)throw new Error("parquet data page header is undefined");if(s>y.num_values&&Vp(c))return new Array(y.num_values);const m=ts(d,Number(t.uncompressed_page_size),l,u),{definitionLevels:b,repetitionLevels:T,dataPage:S}=fy(m,y,n);let _=Qo(S,r,y.encoding,n);if(T.length||b?.length){const W=Array.isArray(i)?i:[];return ca(W,b,T,_,c)}else{for(let W=2;W<c.length;W++)c[W].element.repetition_type!=="REQUIRED"&&(_=Array.from(_,Z=>[Z]));return _}}else if(t.type==="DATA_PAGE_V2"){const y=t.data_page_header_v2;if(!y)throw new Error("parquet data page header v2 is undefined");if(s>y.num_rows)return new Array(y.num_values);const{definitionLevels:m,repetitionLevels:b,dataPage:T}=my(d,t,n),S=Qo(T,r,y.encoding,n),_=Array.isArray(i)?i:[];return ca(_,m,b,S,c)}else if(t.type==="DICTIONARY_PAGE"){const y=t.dictionary_page_header;if(!y)throw new Error("parquet dictionary page header is undefined");const m=ts(d,Number(t.uncompressed_page_size),l,u),b={view:new DataView(m.buffer,m.byteOffset,m.byteLength),offset:0};return Zi(b,o,y.num_values,a.type_length)}else throw new Error(`parquet unsupported page type: ${t.type}`)}function vy(e){const t=ra(e),n=Ho[t.field_1],r=t.field_2,i=t.field_3,s=t.field_4,o=t.field_5&&{num_values:t.field_5.field_1,encoding:We[t.field_5.field_2],definition_level_encoding:We[t.field_5.field_3],repetition_level_encoding:We[t.field_5.field_4],statistics:t.field_5.field_5&&{max:t.field_5.field_5.field_1,min:t.field_5.field_5.field_2,null_count:t.field_5.field_5.field_3,distinct_count:t.field_5.field_5.field_4,max_value:t.field_5.field_5.field_5,min_value:t.field_5.field_5.field_6}},a=t.field_6,c=t.field_7&&{num_values:t.field_7.field_1,encoding:We[t.field_7.field_2],is_sorted:t.field_7.field_3},l=t.field_8&&{num_values:t.field_8.field_1,num_nulls:t.field_8.field_2,num_rows:t.field_8.field_3,encoding:We[t.field_8.field_4],definition_levels_byte_length:t.field_8.field_5,repetition_levels_byte_length:t.field_8.field_6,is_compressed:t.field_8.field_7===void 0?!0:t.field_8.field_7,statistics:t.field_8.field_8};return{type:n,uncompressed_page_size:r,compressed_page_size:i,crc:s,data_page_header:o,index_page_header:a,dictionary_page_header:c,data_page_header_v2:l}}function wy(e,{metadata:t,columns:n},r){const{file:i,compressors:s,utf8:o}=e,a=[],c={...Ko,...e.parsers};for(const{file_path:l,meta_data:u}of r.rowGroup.columns){if(l)throw new Error("parquet file_path not supported");if(!u)throw new Error("parquet column metadata is undefined");const d=u.path_in_schema[0];if(n&&!n.includes(d))continue;const{startByte:y,endByte:m}=la(u),b=m-y;if(b>1<<30){console.warn(`parquet skipping huge column "${u.path_in_schema}" ${b} bytes`);continue}const T=Promise.resolve(i.slice(y,m));a.push({pathInSchema:u.path_in_schema,data:T.then(S=>{const _=ea(t.schema,u.path_in_schema),W={view:new DataView(S),offset:0},Z={columnName:u.path_in_schema.join("."),type:u.type,element:_[_.length-1].element,schemaPath:_,codec:u.codec,parsers:c,compressors:s,utf8:o};return by(W,r,Z,e.onPage)})})}return{groupStart:r.groupStart,groupRows:r.groupRows,asyncColumns:a}}async function Iy({asyncColumns:e},t,n,r,i){const s=new Array(n),o=await Promise.all(e.map(({data:u})=>u.then(aa))),a=e.map(u=>u.pathInSchema[0]).filter(u=>!r||r.includes(u)),c=r??a,l=c.map(u=>e.findIndex(d=>d.pathInSchema[0]===u));for(let u=t;u<n;u++)if(i==="object"){const d={};for(let y=0;y<e.length;y++)d[e[y].pathInSchema[0]]=o[y][u];s[u]=d}else{const d=new Array(e.length);for(let y=0;y<c.length;y++)l[y]>=0&&(d[y]=o[l[y]][u]);s[u]=d}return s}function Sy(e,t){const{asyncColumns:n}=e,r=[];for(const i of t.children)if(i.children.length){const s=n.filter(c=>c.pathInSchema[0]===i.element.name);if(!s.length)continue;const o=new Map,a=Promise.all(s.map(c=>c.data.then(l=>{o.set(c.pathInSchema.join("."),aa(l))}))).then(()=>{zn(o,i);const c=o.get(i.path.join("."));if(!c)throw new Error("parquet column data not assembled");return[c]});r.push({pathInSchema:i.path,data:a})}else{const s=n.find(o=>o.pathInSchema[0]===i.element.name);s&&r.push(s)}return{...e,asyncColumns:r}}async function Ey(e){e.metadata??=await Gp(e.file);const t=Ty(e),{rowStart:n=0,rowEnd:r,columns:i,onChunk:s,onComplete:o,rowFormat:a}=e;if(!o&&!s){for(const{asyncColumns:u}of t)for(const{data:d}of u)await d;return}const c=Wp(e.metadata),l=t.map(u=>Sy(u,c));if(s)for(const u of l)for(const d of u.asyncColumns)d.data.then(y=>{let m=u.groupStart;for(const b of y)s({columnName:d.pathInSchema[0],columnData:b,rowStart:m,rowEnd:m+b.length}),m+=b.length});if(o){const u=[];for(const d of l){const y=Math.max(n-d.groupStart,0),m=Math.min((r??1/0)-d.groupStart,d.groupRows),b=await Iy(d,y,m,i,a);Ji(u,b.slice(y,m))}o(u)}else for(const{asyncColumns:u}of l)for(const{data:d}of u)await d}function Ty(e){if(!e.metadata)throw new Error("parquet requires metadata");const t=Xp(e);return e.file=Jp(e.file,t),t.groups.map(n=>wy(e,t,n))}const Ay={class:"app-container"},Ny=f.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=f.ref(5e3),r=f.ref("random"),i=f.ref("#ff0000"),s=f.ref("#0000ff"),o=f.ref("#4285f4"),a=f.ref(!1),c=f.ref(0),l=f.ref(""),u=f.ref(),d=f.ref(),y=f.ref(new Map),m=f.ref(new Map),b=f.ref([]);f.watch(()=>({srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:t.pkg?.content?.id||"",pkgType:t.pkg?.content?.packageType||"",apiUrl:t.apiUrl||""}),async({srcUrl:N,srcFileType:V,srcFileId:j,pkgId:G,pkgType:lt,apiUrl:bt})=>{try{if(u.value=void 0,d.value=void 0,N){const w=V??(N.toLowerCase().endsWith(".csv")?"csv":"parquet");await W(N,w,j);return}if(!G||!bt)return;await S(G,bt);const ut=b.value?.[0]?.content?.id;if(!ut){console.error("[UMAP Wrapper] No files returned from /view");return}const g=await _(G,ut,bt);await W(g,lt==="CSV"?"csv":"parquet",ut)}catch(ut){console.error("[UMAP Wrapper] Load failed:",ut?.message||ut)}},{immediate:!0});async function T(){const{useGetToken:N}=await Promise.resolve().then(()=>cu);return N()}async function S(N,V){const j=await T(),G=`${V}/packages/${N}/view?api_key=${j}`,lt=await fetch(G);if(!lt.ok)throw new Error(`view failed: ${lt.status}`);b.value=await lt.json()}async function _(N,V,j){const G=await T(),lt=`${j}/packages/${N}/files/${V}?api_key=${G}`,bt=await fetch(lt);if(!bt.ok)throw new Error(`file url failed: ${bt.status}`);return(await bt.json()).url}async function W(N,V,j){if(V==="csv")throw new Error("CSV not yet supported by UMAP wrapper. Provide a Parquet file.");const G=await fetch(N);if(!G.ok)throw new Error(`fetch failed: ${G.status}`);const lt=await G.arrayBuffer();await Ey({file:lt,onComplete:bt=>{d.value=Xi(lt);try{const ut=d.value?.key_value_metadata?.[0];ut?.key&&(r.value=ut.key)}catch{}u.value=bt}}),R()}function Z(){a.value=!a.value,c.value++}function It(N){try{if(!N||N.length<7)return[1,0,0];const V=parseInt(N.slice(1,3),16)/255,j=parseInt(N.slice(3,5),16)/255,G=parseInt(N.slice(5,7),16)/255;return Number.isNaN(V)||Number.isNaN(j)||Number.isNaN(G)?[1,0,0]:[V,j,G]}catch{return[1,0,0]}}function R(){if(!d.value)return;const N=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(It),V=d.value.key_value_metadata||[];for(let j=0;j<V.length-1;j++){const G=V[j].key,lt=JSON.parse(V[j].value);let bt=new Map,ut=0;for(const g of lt)bt.set(g,N[ut%N.length]),ut++;m.value.set(G,bt),m.value.get(G)||m.value.set(G,new Map)}}function B(N){l.value=N[0],y.value=N[1]}return(N,V)=>(f.openBlock(),f.createElementBlock("div",Ay,[(f.openBlock(),f.createBlock(Ap,{data:u.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:o.value,forceRegenerate:a.value,key:c.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),f.createVNode(Mp,{pointCount:n.value,"onUpdate:pointCount":V[0]||(V[0]=j=>n.value=j),colorMode:r.value,"onUpdate:colorMode":V[1]||(V[1]=j=>r.value=j),startColor:i.value,"onUpdate:startColor":V[2]||(V[2]=j=>i.value=j),endColor:s.value,"onUpdate:endColor":V[3]||(V[3]=j=>s.value=j),singleColor:o.value,"onUpdate:singleColor":V[4]||(V[4]=j=>o.value=j),"color-scheme":y.value,"color-map-map":m.value,onRegenerate:Z,onUpdateColorMap:B},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),Ry=Dn(Ny,[["__scopeId","data-v-2197517e"]]),By="dashboard:globalVars";function ma(e=!1){const t=f.inject(By,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const Oy={class:"data-explorer-wrap"},Dy={class:"data-explorer-info"},Ly=f.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=ma(),n=f.ref("Data Explorer"),r=f.computed(()=>f.unref(t.s3Url));return f.watchEffect(()=>{}),(i,s)=>{const o=f.resolveComponent("el-icon");return f.openBlock(),f.createElementBlock(f.Fragment,null,[f.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),f.createElementVNode("div",Oy,[f.createElementVNode("div",Dy,[f.createVNode(f.unref(_u.ElTooltip),{placement:"top-start"},{content:f.withCtx(()=>[...s[0]||(s[0]=[f.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:f.withCtx(()=>[f.createVNode(o,{color:"#8300BF"},{default:f.withCtx(()=>[f.createVNode(f.unref(Iu))]),_:1})]),_:1})]),f.createVNode(f.unref(Ku),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),ga=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Fy=ga(Ly,[["__scopeId","data-v-08f7f19e"]]),My={class:"umap-wrap"},Uy=ga(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=ma(),n=f.ref("Data Explorer"),r=f.computed(()=>f.unref(t?.s3Url));return(i,s)=>(f.openBlock(),f.createElementBlock(f.Fragment,null,[f.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),f.createElementVNode("div",My,[f.createVNode(f.unref(Ry),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function Y(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(u){try{l(r.next(u))}catch(d){o(d)}}function c(u){try{l(r.throw(u))}catch(d){o(d)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((r=r.apply(e,t||[])).next())})}function _a(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 q(e){return this instanceof q?(this.v=e,this):new q(e)}function se(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),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(m){return function(b){return Promise.resolve(b).then(m,d)}}function a(m,b){r[m]&&(i[m]=function(T){return new Promise(function(S,_){s.push([m,T,S,_])>1||c(m,T)})},b&&(i[m]=b(i[m])))}function c(m,b){try{l(r[m](b))}catch(T){y(s[0][3],T)}}function l(m){m.value instanceof q?Promise.resolve(m.value.v).then(u,d):y(s[0][2],m)}function u(m){c("next",m)}function d(m){c("throw",m)}function y(m,b){m(b),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Mr(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(o){return(n=!n)?{value:q(e[i](o)),done:!1}:s?s(o):o}:s}}function Ke(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 _a=="function"?_a(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(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}const xy=new TextDecoder("utf-8"),es=e=>xy.decode(e),Cy=new TextEncoder,ns=e=>Cy.encode(e),$y=e=>typeof e=="number",ba=e=>typeof e=="boolean",St=e=>typeof e=="function",Ut=e=>e!=null&&Object(e)===e,Qe=e=>Ut(e)&&St(e.then),jn=e=>Ut(e)&&St(e[Symbol.iterator]),on=e=>Ut(e)&&St(e[Symbol.asyncIterator]),rs=e=>Ut(e)&&Ut(e.schema),va=e=>Ut(e)&&"done"in e&&"value"in e,wa=e=>Ut(e)&&St(e.stat)&&$y(e.fd),Ia=e=>Ut(e)&&is(e.body),Ur=e=>"_getDOMStream"in e&&"_getNodeStream"in e,ky=e=>Ut(e)&&St(e.abort)&&St(e.getWriter)&&!Ur(e),is=e=>Ut(e)&&St(e.cancel)&&St(e.getReader)&&!Ur(e),Py=e=>Ut(e)&&St(e.end)&&St(e.write)&&ba(e.writable)&&!Ur(e),Sa=e=>Ut(e)&&St(e.read)&&St(e.pipe)&&ba(e.readable)&&!Ur(e),Vy=e=>Ut(e)&&St(e.clear)&&St(e.bytes)&&St(e.position)&&St(e.setPosition)&&St(e.capacity)&&St(e.getBufferIdentifier)&&St(e.createLong),ss=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function zy(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let o,a,c=0,l=0,u=e.length;++c<u;){if(o=t[l],a=e[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:n,byteLength:i}=o,{byteOffset:r,byteLength:s}=a,n+i<r||r+s<n){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,n,r-n+s)}return t}function Ea(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(o,n),e}function oe(e,t){const n=zy(e),r=n.reduce((u,d)=>u+d.byteLength,0);let i,s,o,a=0,c=-1;const l=Math.min(t||Number.POSITIVE_INFINITY,r);for(const u=n.length;++c<u;){if(i=n[c],s=i.subarray(0,Math.min(i.length,l-a)),l<=a+s.length){s.length<i.length?n[c]=i.subarray(s.length):s.length===i.length&&c++,o?Ea(o,s,a):o=s;break}Ea(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),n.slice(c),r-(o?o.byteLength:0)]}function ht(e,t){let n=va(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=ns(n)),n instanceof ArrayBuffer?new e(n):n instanceof ss?new e(n):Vy(n)?ht(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 qn=e=>ht(Int32Array,e),Ta=e=>ht(BigInt64Array,e),X=e=>ht(Uint8Array,e),os=e=>(e.next(),e);function*Yy(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ss?n(t):jn(t)?t:n(t);return yield*os((function*(i){let s=null;do s=i.next(yield ht(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const jy=e=>Yy(Uint8Array,e);function Aa(e,t){return se(this,arguments,function*(){if(Qe(t))return yield q(yield q(yield*Mr(Ke(Aa(e,yield q(t))))));const n=function(s){return se(this,arguments,function*(){yield yield q(yield q(s))})},r=function(s){return se(this,arguments,function*(){yield q(yield*Mr(Ke(os((function*(o){let a=null;do a=o.next(yield a?.value);while(!a.done)})(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ss?n(t):jn(t)?r(t):on(t)?t:n(t);return yield q(yield*Mr(Ke(os((function(s){return se(this,arguments,function*(){let o=null;do o=yield q(s.next(yield yield q(ht(e,o))));while(!o.done)})})(i[Symbol.asyncIterator]()))))),yield q(new e)})}const qy=e=>Aa(Uint8Array,e);function Na(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 Gy(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 Yt={fromIterable(e){return xr(Wy(e))},fromAsyncIterable(e){return xr(Hy(e))},fromDOMStream(e){return xr(Ky(e))},fromNodeStream(e){return xr(Xy(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')}},xr=e=>(e.next(),e);function*Wy(e){let t,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?oe(r,o)[0]:([i,r,a]=oe(r,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});const l=jy(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){(n=!0)&&typeof l.throw=="function"&&l.throw(u)}finally{n===!1&&typeof l.return=="function"&&l.return(null)}return null}function Hy(e){return se(this,arguments,function*(){let t,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?oe(r,o)[0]:([i,r,a]=oe(r,o),i)}({cmd:s,size:o}=(yield yield q(null))||{cmd:"read",size:0});const l=qy(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?yield q(l.next()):yield q(l.next(o-a)),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield q(c()));while(o<a);while(!t)}catch(u){(n=!0)&&typeof l.throw=="function"&&(yield q(l.throw(u)))}finally{n===!1&&typeof l.return=="function"&&(yield q(l.return(new Uint8Array(0))))}return yield q(null)})}function Ky(e){return se(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,o,a=0;function c(){return s==="peek"?oe(r,o)[0]:([i,r,a]=oe(r,o),i)}({cmd:s,size:o}=(yield yield q(null))||{cmd:"read",size:0});const l=new Qy(e);try{do if({done:t,value:i}=Number.isNaN(o-a)?yield q(l.read()):yield q(l.read(o-a)),!t&&i.byteLength>0&&(r.push(X(i)),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield q(c()));while(o<a);while(!t)}catch(u){(n=!0)&&(yield q(l.cancel(u)))}finally{n===!1?yield q(l.cancel()):e.locked&&l.releaseLock()}return yield q(null)})}class Qy{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 Y(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 Y(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=X(n)),n})}}const as=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Xy(e){return se(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,o,a=0,c=[],l;function u(){return s==="peek"?oe(c,o)[0]:([l,c,a]=oe(c,o),l)}if({cmd:s,size:o}=(yield yield q(null))||{cmd:"read",size:0},e.isTTY)return yield yield q(new Uint8Array(0)),yield q(null);try{t[0]=as(e,"end"),t[1]=as(e,"error");do{if(t[2]=as(e,"readable"),[n,i]=yield q(Promise.race(t.map(y=>y[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(o-a)?(l=X(e.read(o-a)),l.byteLength<o-a&&(l=X(e.read()))):l=X(e.read()),l.byteLength>0&&(c.push(l),a+=l.byteLength)),r||o<=a)do({cmd:s,size:o}=yield yield q(u()));while(o<a)}while(!r)}finally{yield q(d(t,n==="error"?i:null))}return yield q(null);function d(y,m){return l=c=null,new Promise((b,T)=>{for(const[S,_]of y)e.off(S,_);try{const S=e.destroy;S&&S.call(e,m),m=void 0}catch(S){m=S||m}finally{m!=null?T(m):b()}})}})}var vt;(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"})(vt||(vt={}));var Nt;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Nt||(Nt={}));var Rt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Rt||(Rt={}));var jt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(jt||(jt={}));var x;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(x||(x={}));var ae;(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"})(ae||(ae={}));const ls=2,le=4,ve=4,rt=4,Fe=new Int32Array(2),Ra=new Float32Array(Fe.buffer),Ba=new Float64Array(Fe.buffer),Cr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var cs;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(cs||(cs={}));let an=class mu{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new mu(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 Fe[0]=this.readInt32(t),Ra[0]}readFloat64(t){return Fe[Cr?0:1]=this.readInt32(t),Fe[Cr?1:0]=this.readInt32(t+4),Ba[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){Ra[0]=n,this.writeInt32(t,Fe[0])}writeFloat64(t,n){Ba[0]=n,this.writeInt32(t,Fe[Cr?0:1]),this.writeInt32(t+4,Fe[Cr?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+le+ve)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<ve;n++)t+=String.fromCharCode(this.readInt8(this.position_+le+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+=le;const i=this.bytes_.subarray(t,t+r);return n===cs.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)+le}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ve)throw new Error("FlatBuffers: file identifier must be length "+ve);for(let n=0;n<ve;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+le+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}},Oa=class gu{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=an.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=gu.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=an.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(le,0),this.writeInt32(this.offset()-t+le)}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)*ls;this.addInt16(s);let o=0;const a=this.space;t:for(n=0;n<this.vtables.length;n++){const c=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(c)){for(let l=ls;l<s;l+=ls)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[n];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-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?rt:0;if(n){const s=n;if(this.prep(this.minalign,le+ve+i),s.length!=ve)throw new TypeError("FlatBuffers: file identifier must be length "+ve);for(let o=ve-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,le+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(le,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 $r;(function(e){e[e.BUFFER=0]="BUFFER"})($r||($r={}));var kr;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(kr||(kr={}));class Me{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 Me).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+rt),(n||new Me).__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):kr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):$r.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,kr.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,$r.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Me.startBodyCompression(t),Me.addCodec(t,n),Me.addMethod(t,r),Me.endBodyCompression(t)}}class Da{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 La=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()}},we=class to{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 to).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+rt),(n||new to).__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 La).__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 Da).__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 Me).__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()}},ln=class eo{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 eo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+rt),(n||new eo).__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 we).__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 cn;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(cn||(cn={}));var Pr;(function(e){e[e.DenseArray=0]="DenseArray"})(Pr||(Pr={}));class Pt{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 Pt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+rt),(n||new Pt).__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 Pt.startInt(t),Pt.addBitWidth(t,n),Pt.addIsSigned(t,r),Pt.endInt(t)}}class Ie{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 Ie).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+rt),(n||new Ie).__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 Pt).__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):Pr.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,Pr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class Et{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 Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+rt),(n||new Et).__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 Et.startKeyValue(t),Et.addKey(t,n),Et.addValue(t,r),Et.endKeyValue(t)}}let Fa=class rr{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 rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+rt),(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return rr.startBinary(t),rr.endBinary(t)}},Ma=class ir{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 ir).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+rt),(n||new ir).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return ir.startBool(t),ir.endBool(t)}},Vr=class An{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 An).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+rt),(n||new An).__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):jt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,jt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return An.startDate(t),An.addUnit(t,n),An.endDate(t)}},un=class Ve{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 Ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+rt),(n||new Ve).__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 Ve.startDecimal(t),Ve.addPrecision(t,n),Ve.addScale(t,r),Ve.addBitWidth(t,i),Ve.endDecimal(t)}},zr=class Nn{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 Nn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+rt),(n||new Nn).__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):x.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,x.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return Nn.startDuration(t),Nn.addUnit(t,n),Nn.endDuration(t)}},Yr=class Rn{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 Rn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+rt),(n||new Rn).__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 Rn.startFixedSizeBinary(t),Rn.addByteWidth(t,n),Rn.endFixedSizeBinary(t)}},jr=class Bn{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 Bn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+rt),(n||new Bn).__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 Bn.startFixedSizeList(t),Bn.addListSize(t,n),Bn.endFixedSizeList(t)}};class ce{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 ce).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+rt),(n||new ce).__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):Rt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Rt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return ce.startFloatingPoint(t),ce.addPrecision(t,n),ce.endFloatingPoint(t)}}class ue{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 ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+rt),(n||new ue).__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):ae.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,ae.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return ue.startInterval(t),ue.addUnit(t,n),ue.endInterval(t)}}let Ua=class sr{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 sr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+rt),(n||new sr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return sr.startLargeBinary(t),sr.endLargeBinary(t)}},xa=class or{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 or).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+rt),(n||new or).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return or.startLargeUtf8(t),or.endLargeUtf8(t)}},Ca=class ar{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 ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+rt),(n||new ar).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return ar.startList(t),ar.endList(t)}},qr=class On{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 On).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+rt),(n||new On).__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 On.startMap(t),On.addKeysSorted(t,n),On.endMap(t)}},$a=class lr{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 lr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+rt),(n||new lr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return lr.startNull(t),lr.endNull(t)}};class Xe{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 Xe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+rt),(n||new Xe).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Xe.startStruct_(t),Xe.endStruct_(t)}}class qt{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 qt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+rt),(n||new qt).__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):x.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,x.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return qt.startTime(t),qt.addUnit(t,n),qt.addBitWidth(t,r),qt.endTime(t)}}class Gt{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 Gt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+rt),(n||new Gt).__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):x.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,x.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return Gt.startTimestamp(t),Gt.addUnit(t,n),Gt.addTimezone(t,r),Gt.endTimestamp(t)}}class xt{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 xt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+rt),(n||new xt).__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):Nt.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,Nt.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 xt.startUnion(t),xt.addMode(t,n),xt.addTypeIds(t,r),xt.endUnion(t)}}let ka=class cr{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 cr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+rt),(n||new cr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return cr.startUtf8(t),cr.endUtf8(t)}};var pt;(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"})(pt||(pt={}));let Wt=class Oi{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 Oi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+rt),(n||new Oi).__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):pt.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 Ie).__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 Oi).__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 Et).__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,pt.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()}},he=class Be{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 Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+rt),(n||new Be).__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):cn.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Wt).__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 Et).__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,cn.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 Be.startSchema(t),Be.addEndianness(t,n),Be.addFields(t,r),Be.addCustomMetadata(t,i),Be.addFeatures(t,s),Be.endSchema(t)}};var et;(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"})(et||(et={}));var p;(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"})(p||(p={}));var Se;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(Se||(Se={}));const Jy=void 0;function Gn(e){if(e===null)return"null";if(e===Jy)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=>Gn(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function dt(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 Pa(e,t){return dt(e/t)+dt(e%t)/dt(t)}const Zy=Symbol.for("isArrowBigNum");function te(e,...t){return t.length===0?Object.setPrototypeOf(ht(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}te.prototype[Zy]=!0,te.prototype.toJSON=function(){return`"${Hn(this)}"`},te.prototype.valueOf=function(e){return Va(this,e)},te.prototype.toString=function(){return Hn(this)},te.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return Va(this);case"string":return Hn(this);case"default":return nm(this)}return Hn(this)};function hn(...e){return te.apply(this,e)}function dn(...e){return te.apply(this,e)}function Wn(...e){return te.apply(this,e)}Object.setPrototypeOf(hn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(dn.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Wn.prototype,Object.create(Uint32Array.prototype)),Object.assign(hn.prototype,te.prototype,{constructor:hn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(dn.prototype,te.prototype,{constructor:dn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Wn.prototype,te.prototype,{constructor:Wn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const tm=BigInt(4294967296)*BigInt(4294967296),em=tm-BigInt(1);function Va(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,o=new BigUint64Array(n,r,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63);let c=BigInt(0),l=0;if(a){for(const u of o)c|=(u^em)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(const u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"){const u=BigInt(Math.pow(10,t)),d=c/u,y=c%u;return dt(d)+dt(y)/dt(u)}return dt(c)}function Hn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return us(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return us(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`-${us(t)}`}function nm(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Hn(e)}function us(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 o=r.length-1;do{for(n[0]=r[s=0];s<o;)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 hs{static new(t,n){switch(n){case!0:return new hn(t);case!1:return new dn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new hn(t)}return t.byteLength===16?new Wn(t):new dn(t)}static signed(t){return new hn(t)}static unsigned(t){return new dn(t)}static decimal(t){return new Wn(t)}constructor(t,n){return hs.new(t,n)}}var za,Ya,ja,qa,Ga,Wa,Ha,Ka,Qa,Xa,Ja,Za,tl,el,nl,rl,il,sl,ol,al,ll,cl;class O{static isNull(t){return t?.typeId===p.Null}static isInt(t){return t?.typeId===p.Int}static isFloat(t){return t?.typeId===p.Float}static isBinary(t){return t?.typeId===p.Binary}static isLargeBinary(t){return t?.typeId===p.LargeBinary}static isUtf8(t){return t?.typeId===p.Utf8}static isLargeUtf8(t){return t?.typeId===p.LargeUtf8}static isBool(t){return t?.typeId===p.Bool}static isDecimal(t){return t?.typeId===p.Decimal}static isDate(t){return t?.typeId===p.Date}static isTime(t){return t?.typeId===p.Time}static isTimestamp(t){return t?.typeId===p.Timestamp}static isInterval(t){return t?.typeId===p.Interval}static isDuration(t){return t?.typeId===p.Duration}static isList(t){return t?.typeId===p.List}static isStruct(t){return t?.typeId===p.Struct}static isUnion(t){return t?.typeId===p.Union}static isFixedSizeBinary(t){return t?.typeId===p.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===p.FixedSizeList}static isMap(t){return t?.typeId===p.Map}static isDictionary(t){return t?.typeId===p.Dictionary}static isDenseUnion(t){return O.isUnion(t)&&t.mode===Nt.Dense}static isSparseUnion(t){return O.isUnion(t)&&t.mode===Nt.Sparse}constructor(t){this.typeId=t}}za=Symbol.toStringTag,O[za]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(O.prototype);class Ue extends O{constructor(){super(p.Null)}toString(){return"Null"}}Ya=Symbol.toStringTag,Ue[Ya]=(e=>e[Symbol.toStringTag]="Null")(Ue.prototype);class Je extends O{constructor(t,n){super(p.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}`}}ja=Symbol.toStringTag,Je[ja]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(Je.prototype);class Kn extends Je{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Kn.prototype,"ArrayType",{value:Int32Array});class Gr extends O{constructor(t){super(p.Float),this.precision=t}get ArrayType(){switch(this.precision){case Rt.HALF:return Uint16Array;case Rt.SINGLE:return Float32Array;case Rt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}qa=Symbol.toStringTag,Gr[qa]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(Gr.prototype);class Wr extends O{constructor(){super(p.Binary)}toString(){return"Binary"}}Ga=Symbol.toStringTag,Wr[Ga]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Wr.prototype);class Hr extends O{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}}Wa=Symbol.toStringTag,Hr[Wa]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Hr.prototype);class Kr extends O{constructor(){super(p.Utf8)}toString(){return"Utf8"}}Ha=Symbol.toStringTag,Kr[Ha]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Kr.prototype);class Qr extends O{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}}Ka=Symbol.toStringTag,Qr[Ka]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(Qr.prototype);class Xr extends O{constructor(){super(p.Bool)}toString(){return"Bool"}}Qa=Symbol.toStringTag,Xr[Qa]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Xr.prototype);class Jr extends O{constructor(t,n,r=128){super(p.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}Xa=Symbol.toStringTag,Jr[Xa]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Jr.prototype);class Zr extends O{constructor(t){super(p.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${jt[this.unit]}>`}get ArrayType(){return this.unit===jt.DAY?Int32Array:BigInt64Array}}Ja=Symbol.toStringTag,Zr[Ja]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(Zr.prototype);class ti extends O{constructor(t,n){super(p.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${x[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Za=Symbol.toStringTag,ti[Za]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(ti.prototype);class ei extends O{constructor(t,n){super(p.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${x[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}tl=Symbol.toStringTag,ei[tl]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(ei.prototype);class ni extends O{constructor(t){super(p.Interval),this.unit=t}toString(){return`Interval<${ae[this.unit]}>`}}el=Symbol.toStringTag,ni[el]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(ni.prototype);class ri extends O{constructor(t){super(p.Duration),this.unit=t}toString(){return`Duration<${x[this.unit]}>`}}nl=Symbol.toStringTag,ri[nl]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(ri.prototype);class ii extends O{constructor(t){super(p.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}}rl=Symbol.toStringTag,ii[rl]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(ii.prototype);class Ot extends O{constructor(t){super(p.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}il=Symbol.toStringTag,Ot[il]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(Ot.prototype);class si extends O{constructor(t,n,r){super(p.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}sl=Symbol.toStringTag,si[sl]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(si.prototype);class oi extends O{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}ol=Symbol.toStringTag,oi[ol]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(oi.prototype);class ai extends O{constructor(t,n){super(p.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}>`}}al=Symbol.toStringTag,ai[al]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(ai.prototype);class li extends O{constructor(t,n=!1){var r,i,s;if(super(p.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t?.type)===null||r===void 0)&&r.children)){const o=(i=t?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");const a=(s=t?.type)===null||s===void 0?void 0:s.children[1];a&&(a.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(", ")}}>`}}ll=Symbol.toStringTag,li[ll]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(li.prototype);const rm=(e=>()=>++e)(-1);class fn extends O{constructor(t,n,r,i){super(p.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?rm():dt(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}>`}}cl=Symbol.toStringTag,fn[cl]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(fn.prototype);function Ee(e){const t=e;switch(e.typeId){case p.Decimal:return e.bitWidth/32;case p.Interval:return 1+t.unit;case p.FixedSizeList:return t.listSize;case p.FixedSizeBinary:return t.byteWidth;default:return 1}}class H{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 im(this,t,n)}getVisitFnByTypeId(t,n=!0){return pn(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 im(e,t,n=!0){return typeof t=="number"?pn(e,t,n):typeof t=="string"&&t in p?pn(e,p[t],n):t&&t instanceof O?pn(e,ul(t),n):t?.type&&t.type instanceof O?pn(e,ul(t.type),n):pn(e,p.NONE,n)}function pn(e,t,n=!0){let r=null;switch(t){case p.Null:r=e.visitNull;break;case p.Bool:r=e.visitBool;break;case p.Int:r=e.visitInt;break;case p.Int8:r=e.visitInt8||e.visitInt;break;case p.Int16:r=e.visitInt16||e.visitInt;break;case p.Int32:r=e.visitInt32||e.visitInt;break;case p.Int64:r=e.visitInt64||e.visitInt;break;case p.Uint8:r=e.visitUint8||e.visitInt;break;case p.Uint16:r=e.visitUint16||e.visitInt;break;case p.Uint32:r=e.visitUint32||e.visitInt;break;case p.Uint64:r=e.visitUint64||e.visitInt;break;case p.Float:r=e.visitFloat;break;case p.Float16:r=e.visitFloat16||e.visitFloat;break;case p.Float32:r=e.visitFloat32||e.visitFloat;break;case p.Float64:r=e.visitFloat64||e.visitFloat;break;case p.Utf8:r=e.visitUtf8;break;case p.LargeUtf8:r=e.visitLargeUtf8;break;case p.Binary:r=e.visitBinary;break;case p.LargeBinary:r=e.visitLargeBinary;break;case p.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case p.Date:r=e.visitDate;break;case p.DateDay:r=e.visitDateDay||e.visitDate;break;case p.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case p.Timestamp:r=e.visitTimestamp;break;case p.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case p.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case p.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case p.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case p.Time:r=e.visitTime;break;case p.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case p.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case p.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case p.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case p.Decimal:r=e.visitDecimal;break;case p.List:r=e.visitList;break;case p.Struct:r=e.visitStruct;break;case p.Union:r=e.visitUnion;break;case p.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case p.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case p.Dictionary:r=e.visitDictionary;break;case p.Interval:r=e.visitInterval;break;case p.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case p.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case p.Duration:r=e.visitDuration;break;case p.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case p.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case p.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case p.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case p.FixedSizeList:r=e.visitFixedSizeList;break;case p.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${p[t]}'`)}function ul(e){switch(e.typeId){case p.Null:return p.Null;case p.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?p.Int8:p.Uint8;case 16:return n?p.Int16:p.Uint16;case 32:return n?p.Int32:p.Uint32;case 64:return n?p.Int64:p.Uint64}return p.Int}case p.Float:switch(e.precision){case Rt.HALF:return p.Float16;case Rt.SINGLE:return p.Float32;case Rt.DOUBLE:return p.Float64}return p.Float;case p.Binary:return p.Binary;case p.LargeBinary:return p.LargeBinary;case p.Utf8:return p.Utf8;case p.LargeUtf8:return p.LargeUtf8;case p.Bool:return p.Bool;case p.Decimal:return p.Decimal;case p.Time:switch(e.unit){case x.SECOND:return p.TimeSecond;case x.MILLISECOND:return p.TimeMillisecond;case x.MICROSECOND:return p.TimeMicrosecond;case x.NANOSECOND:return p.TimeNanosecond}return p.Time;case p.Timestamp:switch(e.unit){case x.SECOND:return p.TimestampSecond;case x.MILLISECOND:return p.TimestampMillisecond;case x.MICROSECOND:return p.TimestampMicrosecond;case x.NANOSECOND:return p.TimestampNanosecond}return p.Timestamp;case p.Date:switch(e.unit){case jt.DAY:return p.DateDay;case jt.MILLISECOND:return p.DateMillisecond}return p.Date;case p.Interval:switch(e.unit){case ae.DAY_TIME:return p.IntervalDayTime;case ae.YEAR_MONTH:return p.IntervalYearMonth}return p.Interval;case p.Duration:switch(e.unit){case x.SECOND:return p.DurationSecond;case x.MILLISECOND:return p.DurationMillisecond;case x.MICROSECOND:return p.DurationMicrosecond;case x.NANOSECOND:return p.DurationNanosecond}return p.Duration;case p.Map:return p.Map;case p.List:return p.List;case p.Struct:return p.Struct;case p.Union:switch(e.mode){case Nt.Dense:return p.DenseUnion;case Nt.Sparse:return p.SparseUnion}return p.Union;case p.FixedSizeBinary:return p.FixedSizeBinary;case p.FixedSizeList:return p.FixedSizeList;case p.Dictionary:return p.Dictionary}throw new Error(`Unrecognized type '${p[e.typeId]}'`)}H.prototype.visitInt8=null,H.prototype.visitInt16=null,H.prototype.visitInt32=null,H.prototype.visitInt64=null,H.prototype.visitUint8=null,H.prototype.visitUint16=null,H.prototype.visitUint32=null,H.prototype.visitUint64=null,H.prototype.visitFloat16=null,H.prototype.visitFloat32=null,H.prototype.visitFloat64=null,H.prototype.visitDateDay=null,H.prototype.visitDateMillisecond=null,H.prototype.visitTimestampSecond=null,H.prototype.visitTimestampMillisecond=null,H.prototype.visitTimestampMicrosecond=null,H.prototype.visitTimestampNanosecond=null,H.prototype.visitTimeSecond=null,H.prototype.visitTimeMillisecond=null,H.prototype.visitTimeMicrosecond=null,H.prototype.visitTimeNanosecond=null,H.prototype.visitDenseUnion=null,H.prototype.visitSparseUnion=null,H.prototype.visitIntervalDayTime=null,H.prototype.visitIntervalYearMonth=null,H.prototype.visitDuration=null,H.prototype.visitDurationSecond=null,H.prototype.visitDurationMillisecond=null,H.prototype.visitDurationMicrosecond=null,H.prototype.visitDurationNanosecond=null;const hl=new Float64Array(1),yn=new Uint32Array(hl.buffer);function dl(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 sm(e){if(e!==e)return 32256;hl[0]=e;const t=(yn[1]&2147483648)>>16&65535;let n=yn[1]&2146435072,r=0;return n>=1089470464?yn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(yn[1]&1048575)>>10):n<=1056964608?(r=1048576+(yn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(yn[1]&1048575)+512>>10),t|n|r&65535}class C extends H{}function P(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const om=(e,t,n)=>{e[t]=Math.floor(n/864e5)},fl=(e,t,n,r)=>{if(n+1<t.length){const i=dt(t[n]),s=dt(t[n+1]);e.set(r.subarray(0,s-i),i)}},am=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Te=({values:e},t,n)=>{e[t]=n},ds=({values:e},t,n)=>{e[t]=n},pl=({values:e},t,n)=>{e[t]=sm(n)},lm=(e,t,n)=>{switch(e.type.precision){case Rt.HALF:return pl(e,t,n);case Rt.SINGLE:case Rt.DOUBLE:return ds(e,t,n)}},yl=({values:e},t,n)=>{om(e,t,n.valueOf())},ml=({values:e},t,n)=>{e[t]=BigInt(n)},cm=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},gl=({values:e,valueOffsets:t},n,r)=>fl(e,t,n,r),_l=({values:e,valueOffsets:t},n,r)=>fl(e,t,n,ns(r)),um=(e,t,n)=>{e.type.unit===jt.DAY?yl(e,t,n):ml(e,t,n)},bl=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},vl=({values:e},t,n)=>{e[t]=BigInt(n)},wl=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Il=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},hm=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return bl(e,t,n);case x.MILLISECOND:return vl(e,t,n);case x.MICROSECOND:return wl(e,t,n);case x.NANOSECOND:return Il(e,t,n)}},Sl=({values:e},t,n)=>{e[t]=n},El=({values:e},t,n)=>{e[t]=n},Tl=({values:e},t,n)=>{e[t]=n},Al=({values:e},t,n)=>{e[t]=n},dm=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return Sl(e,t,n);case x.MILLISECOND:return El(e,t,n);case x.MICROSECOND:return Tl(e,t,n);case x.NANOSECOND:return Al(e,t,n)}},fm=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},pm=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Ht.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[t],c=i[t+1];a<c;)s(r,a++,n[++o]);else for(let o=-1,a=i[t],c=i[t+1];a<c;)s(r,a++,n.get(++o))},ym=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Ht.getVisitFn(r);let{[t]:o,[t+1]:a}=i;const c=n instanceof Map?n.entries():Object.entries(n);for(const l of c)if(s(r,o,l),++o>=a)break},mm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),gm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),_m=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),bm=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),vm=(e,t,n)=>{const r=e.type.children.map(s=>Ht.getVisitFn(s.type)),i=n instanceof Map?_m(t,n):n instanceof it?gm(t,n):Array.isArray(n)?mm(t,n):bm(t,n);e.type.children.forEach((s,o)=>i(r[o],e.children[o],s,o))},wm=(e,t,n)=>{e.type.mode===Nt.Dense?Nl(e,t,n):Rl(e,t,n)},Nl=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ht.visit(i,e.valueOffsets[t],n)},Rl=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ht.visit(i,t,n)},Im=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Sm=(e,t,n)=>{e.type.unit===ae.DAY_TIME?Bl(e,t,n):Ol(e,t,n)},Bl=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ol=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Dl=({values:e},t,n)=>{e[t]=n},Ll=({values:e},t,n)=>{e[t]=n},Fl=({values:e},t,n)=>{e[t]=n},Ml=({values:e},t,n)=>{e[t]=n},Em=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return Dl(e,t,n);case x.MILLISECOND:return Ll(e,t,n);case x.MICROSECOND:return Fl(e,t,n);case x.NANOSECOND:return Ml(e,t,n)}},Tm=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Ht.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=t*r;++o<r;)s(i,a+o,n[o]);else for(let o=-1,a=t*r;++o<r;)s(i,a+o,n.get(o))};C.prototype.visitBool=P(am),C.prototype.visitInt=P(Te),C.prototype.visitInt8=P(Te),C.prototype.visitInt16=P(Te),C.prototype.visitInt32=P(Te),C.prototype.visitInt64=P(Te),C.prototype.visitUint8=P(Te),C.prototype.visitUint16=P(Te),C.prototype.visitUint32=P(Te),C.prototype.visitUint64=P(Te),C.prototype.visitFloat=P(lm),C.prototype.visitFloat16=P(pl),C.prototype.visitFloat32=P(ds),C.prototype.visitFloat64=P(ds),C.prototype.visitUtf8=P(_l),C.prototype.visitLargeUtf8=P(_l),C.prototype.visitBinary=P(gl),C.prototype.visitLargeBinary=P(gl),C.prototype.visitFixedSizeBinary=P(cm),C.prototype.visitDate=P(um),C.prototype.visitDateDay=P(yl),C.prototype.visitDateMillisecond=P(ml),C.prototype.visitTimestamp=P(hm),C.prototype.visitTimestampSecond=P(bl),C.prototype.visitTimestampMillisecond=P(vl),C.prototype.visitTimestampMicrosecond=P(wl),C.prototype.visitTimestampNanosecond=P(Il),C.prototype.visitTime=P(dm),C.prototype.visitTimeSecond=P(Sl),C.prototype.visitTimeMillisecond=P(El),C.prototype.visitTimeMicrosecond=P(Tl),C.prototype.visitTimeNanosecond=P(Al),C.prototype.visitDecimal=P(fm),C.prototype.visitList=P(pm),C.prototype.visitStruct=P(vm),C.prototype.visitUnion=P(wm),C.prototype.visitDenseUnion=P(Nl),C.prototype.visitSparseUnion=P(Rl),C.prototype.visitDictionary=P(Im),C.prototype.visitInterval=P(Sm),C.prototype.visitIntervalDayTime=P(Bl),C.prototype.visitIntervalYearMonth=P(Ol),C.prototype.visitDuration=P(Em),C.prototype.visitDurationSecond=P(Dl),C.prototype.visitDurationMillisecond=P(Ll),C.prototype.visitDurationMicrosecond=P(Fl),C.prototype.visitDurationNanosecond=P(Ml),C.prototype.visitFixedSizeList=P(Tm),C.prototype.visitMap=P(ym);const Ht=new C,ee=Symbol.for("parent"),mn=Symbol.for("rowIndex");class fs{constructor(t,n){return this[ee]=t,this[mn]=n,new Proxy(this,new Nm)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[mn],n=this[ee],r=n.type.children,i={};for(let s=-1,o=r.length;++s<o;)i[r[s].name]=Ct.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Gn(t)}: ${Gn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Am(this[ee],this[mn])}}class Am{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,Ct.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(fs.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ee]:{writable:!0,enumerable:!1,configurable:!1,value:null},[mn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class Nm{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ee].type.children.map(n=>n.name)}has(t,n){return t[ee].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[ee].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[ee].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Ct.visit(t[ee].children[r],t[mn]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[ee].type.children.findIndex(s=>s.name===n);return i!==-1?(Ht.visit(t[ee].children[i],t[mn],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class L extends H{}function $(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Rm=(e,t)=>864e5*e[t],Bm=(e,t)=>null,Ul=(e,t,n)=>{if(n+1>=t.length)return null;const r=dt(t[n]),i=dt(t[n+1]);return e.subarray(r,i)},Om=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},xl=({values:e},t)=>Rm(e,t),Cl=({values:e},t)=>dt(e[t]),xe=({stride:e,values:t},n)=>t[e*n],Dm=({stride:e,values:t},n)=>dl(t[e*n]),$l=({values:e},t)=>e[t],Lm=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),kl=({values:e,valueOffsets:t},n)=>Ul(e,t,n),Pl=({values:e,valueOffsets:t},n)=>{const r=Ul(e,t,n);return r!==null?es(r):null},Fm=({values:e},t)=>e[t],Mm=({type:e,values:t},n)=>e.precision!==Rt.HALF?t[n]:dl(t[n]),Um=(e,t)=>e.type.unit===jt.DAY?xl(e,t):Cl(e,t),Vl=({values:e},t)=>1e3*dt(e[t]),zl=({values:e},t)=>dt(e[t]),Yl=({values:e},t)=>Pa(e[t],BigInt(1e3)),jl=({values:e},t)=>Pa(e[t],BigInt(1e6)),xm=(e,t)=>{switch(e.type.unit){case x.SECOND:return Vl(e,t);case x.MILLISECOND:return zl(e,t);case x.MICROSECOND:return Yl(e,t);case x.NANOSECOND:return jl(e,t)}},ql=({values:e},t)=>e[t],Gl=({values:e},t)=>e[t],Wl=({values:e},t)=>e[t],Hl=({values:e},t)=>e[t],Cm=(e,t)=>{switch(e.type.unit){case x.SECOND:return ql(e,t);case x.MILLISECOND:return Gl(e,t);case x.MICROSECOND:return Wl(e,t);case x.NANOSECOND:return Hl(e,t)}},$m=({values:e,stride:t},n)=>hs.decimal(e.subarray(t*n,t*(n+1))),km=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:o}=n,a=i[0].slice(s,o-s);return new it([a])},Pm=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,o=r[0];return new ys(o.slice(i,s-i))},Vm=(e,t)=>new fs(e,t),zm=(e,t)=>e.type.mode===Nt.Dense?Kl(e,t):Ql(e,t),Kl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Ct.visit(r,e.valueOffsets[t])},Ql=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Ct.visit(r,t)},Ym=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},jm=(e,t)=>e.type.unit===ae.DAY_TIME?Xl(e,t):Jl(e,t),Xl=({values:e},t)=>e.subarray(2*t,2*(t+1)),Jl=({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},Zl=({values:e},t)=>e[t],tc=({values:e},t)=>e[t],ec=({values:e},t)=>e[t],nc=({values:e},t)=>e[t],qm=(e,t)=>{switch(e.type.unit){case x.SECOND:return Zl(e,t);case x.MILLISECOND:return tc(e,t);case x.MICROSECOND:return ec(e,t);case x.NANOSECOND:return nc(e,t)}},Gm=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new it([i])};L.prototype.visitNull=$(Bm),L.prototype.visitBool=$(Om),L.prototype.visitInt=$(Fm),L.prototype.visitInt8=$(xe),L.prototype.visitInt16=$(xe),L.prototype.visitInt32=$(xe),L.prototype.visitInt64=$($l),L.prototype.visitUint8=$(xe),L.prototype.visitUint16=$(xe),L.prototype.visitUint32=$(xe),L.prototype.visitUint64=$($l),L.prototype.visitFloat=$(Mm),L.prototype.visitFloat16=$(Dm),L.prototype.visitFloat32=$(xe),L.prototype.visitFloat64=$(xe),L.prototype.visitUtf8=$(Pl),L.prototype.visitLargeUtf8=$(Pl),L.prototype.visitBinary=$(kl),L.prototype.visitLargeBinary=$(kl),L.prototype.visitFixedSizeBinary=$(Lm),L.prototype.visitDate=$(Um),L.prototype.visitDateDay=$(xl),L.prototype.visitDateMillisecond=$(Cl),L.prototype.visitTimestamp=$(xm),L.prototype.visitTimestampSecond=$(Vl),L.prototype.visitTimestampMillisecond=$(zl),L.prototype.visitTimestampMicrosecond=$(Yl),L.prototype.visitTimestampNanosecond=$(jl),L.prototype.visitTime=$(Cm),L.prototype.visitTimeSecond=$(ql),L.prototype.visitTimeMillisecond=$(Gl),L.prototype.visitTimeMicrosecond=$(Wl),L.prototype.visitTimeNanosecond=$(Hl),L.prototype.visitDecimal=$($m),L.prototype.visitList=$(km),L.prototype.visitStruct=$(Vm),L.prototype.visitUnion=$(zm),L.prototype.visitDenseUnion=$(Kl),L.prototype.visitSparseUnion=$(Ql),L.prototype.visitDictionary=$(Ym),L.prototype.visitInterval=$(jm),L.prototype.visitIntervalDayTime=$(Xl),L.prototype.visitIntervalYearMonth=$(Jl),L.prototype.visitDuration=$(qm),L.prototype.visitDurationSecond=$(Zl),L.prototype.visitDurationMillisecond=$(tc),L.prototype.visitDurationMicrosecond=$(ec),L.prototype.visitDurationNanosecond=$(nc),L.prototype.visitFixedSizeList=$(Gm),L.prototype.visitMap=$(Pm);const Ct=new L,gn=Symbol.for("keys"),_n=Symbol.for("vals"),bn=Symbol.for("kKeysAsStrings"),ps=Symbol.for("_kKeysAsStrings");class ys{constructor(t){return this[gn]=new it([t.children[0]]).memoize(),this[_n]=t.children[1],new Proxy(this,new Hm)}get[bn](){return this[ps]||(this[ps]=Array.from(this[gn].toArray(),String))}[Symbol.iterator](){return new Wm(this[gn],this[_n])}get size(){return this[gn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[gn],n=this[_n],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Ct.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Gn(t)}: ${Gn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Wm{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),Ct.visit(this.vals,t)]})}}class Hm{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[bn]}has(t,n){return t[bn].includes(n)}getOwnPropertyDescriptor(t,n){if(t[bn].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[bn].indexOf(n);if(r!==-1){const i=Ct.visit(Reflect.get(t,_n),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[bn].indexOf(n);return i!==-1?(Ht.visit(Reflect.get(t,_n),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(ys.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[gn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[_n]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ps]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let rc;function ic(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(rc=s,s=o,o=rc),o>i&&(o=i),r?r(e,s,o):[s,o]}const ms=(e,t)=>e<0?t+e:e,sc=e=>e!==e;function vn(e){if(typeof e!="object"||e===null)return sc(e)?sc: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?Gy(e,t):!1:e instanceof Map?Qm(e):Array.isArray(e)?Km(e):e instanceof it?Xm(e):Jm(e,!0)}function Km(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=vn(e[n]);return ci(t)}function Qm(e){let t=-1;const n=[];for(const r of e.values())n[++t]=vn(r);return ci(n)}function Xm(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=vn(e.get(n));return ci(t)}function Jm(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]=vn(e[n[i]]);return ci(r,n)}function ci(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return Zm(e,n);case Map:return oc(e,n,n.keys());case ys:case fs:case Object:case void 0:return oc(e,n,t||Object.keys(n))}return n instanceof it?tg(e,n):!1}}function Zm(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 tg(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 oc(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 o=0;const a=e.length;let c=s.next(),l=r.next(),u=i.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!e[o](c.value));++o,l=r.next(),u=i.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function ac(e,t,n,r){return(n&1<<r)!==0}function eg(e,t,n,r){return(n&1<<r)>>r}function ui(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):hi(new gs(n,e,t,null,ac)).subarray(0,r)),i}return n}function hi(e){const t=[];let n=0,r=0,i=0;for(const o of e)o&&(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 gs{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 _s(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const o of new gs(e,t,n-t,e,eg))s+=o;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return _s(e,t,i)+_s(e,r,n)+ng(e,i>>3,r-i>>3)}function ng(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=bs(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=bs(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=bs(s.getUint8(i)),i+=1;return r}function bs(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 rg=-1;class ot{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 O.isSparseUnion(t)?this.children.some(n=>n.nullable):O.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((o,a)=>o+a.byteLength,t)}get nullCount(){if(O.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=rg&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-_s(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof ot?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ee(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){const{type:n}=this;if(O.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Nt.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(O.isUnion(i)){const s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===Nt.Dense?this.valueOffsets[t]:t;r=o.getValid(a),o.setValid(a,n)}else{let{nullBitmap:s}=this;const{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(ui(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const d=s[u];r=(d&l)!==0,s[u]=n?d|l:d&~l}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,o=this.children){return new ot(t,n,r,i,s,o,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?r:1,c=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===p.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(ui(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[Se.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:o}=this;return(s=o[Se.TYPE])&&(o[Se.TYPE]=s.subarray(t,t+n)),(s=o[Se.OFFSET])&&(o[Se.OFFSET]=s.subarray(t,t+n+1))||(s=o[Se.DATA])&&(o[Se.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),o}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}ot.prototype.children=Object.freeze([]);class Qn extends H{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new ot(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.data),s=X(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.data),s=X(t.nullBitmap),o=Ta(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.data),s=X(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.data),s=X(t.nullBitmap),o=Ta(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=X(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=X(t.nullBitmap),{length:o=i.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=ht(n.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(O.isSparseUnion(n))return new ot(n,r,o,a,[void 0,void 0,void 0,s],i);const c=qn(t.valueOffsets);return new ot(n,r,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.indices.ArrayType,t.data),{["dictionary"]:o=new it([new Qn().visit({type:n.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[void 0,s,i],[],o)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=X(t.nullBitmap),s=ht(n.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Qn().visit({type:n.valueType})}=t,s=X(t.nullBitmap),{["length"]:o=i.length/Ee(n),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new ot(n,r,o,a,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Qn().visit({type:n.childType})}=t,s=X(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new ot(n,r,a,c,[o,void 0,s],[i])}}const ig=new Qn;function Q(e){return ig.visit(e)}class lc{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 sg(e){return e.some(t=>t.nullable)}function cc(e){return e.reduce((t,n)=>t+n.nullCount,0)}function uc(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function hc(e,t,n,r){const i=[];for(let s=-1,o=e.length;++s<o;){const a=e[s],c=t[s],{length:l}=a;if(c>=r)break;if(n>=c+l)continue;if(c>=n&&c+l<=r){i.push(a);continue}const u=Math.max(0,n-c),d=Math.min(r-c,l);i.push(a.slice(u,d-u))}return i.length===0&&i.push(e[0].slice(0,0)),i}function vs(e,t,n,r){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return n<t[o]?r(e,i,n-t[i]):null;s=i+Math.trunc((o-i)*.5),n<t[s]?o=s:i=s}while(i<o)}function ws(e,t){return e.getValid(t)}function di(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return vs(r,this._offsets,n,t)}}function dc(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 o=vs(s,this._offsets,r,n);return t=void 0,o}}function fc(e){let t;function n(r,i,s){let o=s,a=0,c=0;for(let l=i-1,u=r.length;++l<u;){const d=r[l];if(~(a=e(d,t,o)))return c+a;o=0,c+=d.length}return-1}return function(r,i){t=r;const s=this.data,o=typeof i!="number"?n(s,0,0):vs(s,this._offsets,i,n);return t=void 0,o}}class F extends H{}function og(e,t){return t===null&&e.length>0?0:-1}function ag(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new gs(n,e.offset+(t||0),e.length,n,ac)){if(!i)return r;++r}return-1}function z(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case p.Union:break;case p.Dictionary:break;default:return ag(e,n)}const r=Ct.getVisitFn(e),i=vn(t);for(let s=(n||0)-1,o=e.length;++s<o;)if(i(r(e,s)))return s;return-1}function pc(e,t,n){const r=Ct.getVisitFn(e),i=vn(t);for(let s=(n||0)-1,o=e.length;++s<o;)if(i(r(e,s)))return s;return-1}F.prototype.visitNull=og,F.prototype.visitBool=z,F.prototype.visitInt=z,F.prototype.visitInt8=z,F.prototype.visitInt16=z,F.prototype.visitInt32=z,F.prototype.visitInt64=z,F.prototype.visitUint8=z,F.prototype.visitUint16=z,F.prototype.visitUint32=z,F.prototype.visitUint64=z,F.prototype.visitFloat=z,F.prototype.visitFloat16=z,F.prototype.visitFloat32=z,F.prototype.visitFloat64=z,F.prototype.visitUtf8=z,F.prototype.visitLargeUtf8=z,F.prototype.visitBinary=z,F.prototype.visitLargeBinary=z,F.prototype.visitFixedSizeBinary=z,F.prototype.visitDate=z,F.prototype.visitDateDay=z,F.prototype.visitDateMillisecond=z,F.prototype.visitTimestamp=z,F.prototype.visitTimestampSecond=z,F.prototype.visitTimestampMillisecond=z,F.prototype.visitTimestampMicrosecond=z,F.prototype.visitTimestampNanosecond=z,F.prototype.visitTime=z,F.prototype.visitTimeSecond=z,F.prototype.visitTimeMillisecond=z,F.prototype.visitTimeMicrosecond=z,F.prototype.visitTimeNanosecond=z,F.prototype.visitDecimal=z,F.prototype.visitList=z,F.prototype.visitStruct=z,F.prototype.visitUnion=z,F.prototype.visitDenseUnion=pc,F.prototype.visitSparseUnion=pc,F.prototype.visitDictionary=z,F.prototype.visitInterval=z,F.prototype.visitIntervalDayTime=z,F.prototype.visitIntervalYearMonth=z,F.prototype.visitDuration=z,F.prototype.visitDurationSecond=z,F.prototype.visitDurationMillisecond=z,F.prototype.visitDurationMicrosecond=z,F.prototype.visitDurationNanosecond=z,F.prototype.visitFixedSizeList=z,F.prototype.visitMap=z;const fi=new F;class M extends H{}function k(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(O.isInt(t)&&t.bitWidth!==64||O.isTime(t)&&t.bitWidth!==64||O.isFloat(t)&&t.precision!==Rt.HALF))return new lc(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new lc(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new lg(s)})}class lg{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}}M.prototype.visitNull=k,M.prototype.visitBool=k,M.prototype.visitInt=k,M.prototype.visitInt8=k,M.prototype.visitInt16=k,M.prototype.visitInt32=k,M.prototype.visitInt64=k,M.prototype.visitUint8=k,M.prototype.visitUint16=k,M.prototype.visitUint32=k,M.prototype.visitUint64=k,M.prototype.visitFloat=k,M.prototype.visitFloat16=k,M.prototype.visitFloat32=k,M.prototype.visitFloat64=k,M.prototype.visitUtf8=k,M.prototype.visitLargeUtf8=k,M.prototype.visitBinary=k,M.prototype.visitLargeBinary=k,M.prototype.visitFixedSizeBinary=k,M.prototype.visitDate=k,M.prototype.visitDateDay=k,M.prototype.visitDateMillisecond=k,M.prototype.visitTimestamp=k,M.prototype.visitTimestampSecond=k,M.prototype.visitTimestampMillisecond=k,M.prototype.visitTimestampMicrosecond=k,M.prototype.visitTimestampNanosecond=k,M.prototype.visitTime=k,M.prototype.visitTimeSecond=k,M.prototype.visitTimeMillisecond=k,M.prototype.visitTimeMicrosecond=k,M.prototype.visitTimeNanosecond=k,M.prototype.visitDecimal=k,M.prototype.visitList=k,M.prototype.visitStruct=k,M.prototype.visitUnion=k,M.prototype.visitDenseUnion=k,M.prototype.visitSparseUnion=k,M.prototype.visitDictionary=k,M.prototype.visitInterval=k,M.prototype.visitIntervalDayTime=k,M.prototype.visitIntervalYearMonth=k,M.prototype.visitDuration=k,M.prototype.visitDurationSecond=k,M.prototype.visitDurationMillisecond=k,M.prototype.visitDurationMicrosecond=k,M.prototype.visitDurationNanosecond=k,M.prototype.visitFixedSizeList=k,M.prototype.visitMap=k;const Is=new M;var yc;const mc={},gc={};class it{constructor(t){var n,r,i;const s=t[0]instanceof it?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof ot)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:c,indexOf:l}=mc[o.typeId],u=s[0];this.isValid=d=>ws(u,d),this.get=d=>a(u,d),this.set=(d,y)=>c(u,d,y),this.indexOf=d=>l(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,gc[o.typeId]),this._offsets=uc(s);break}this.data=s,this.type=o,this.stride=Ee(o),this.numChildren=(i=(r=o.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 sg(this.data)}get nullCount(){return cc(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${p[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(ms(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return Is.visit(this)}concat(...t){return new it(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new it(ic(this,t,n,({data:r,_offsets:i},s,o)=>hc(r,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case p.Int:case p.Float:case p.Decimal:case p.Time:case p.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{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 it(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return O.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(O.isDictionary(this.type)){const t=new pi(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new it(n)}return new pi(this)}unmemoize(){if(O.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 it(n)}return this}}yc=Symbol.toStringTag,it[yc]=(e=>{e.type=O.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(p).map(n=>p[n]).filter(n=>typeof n=="number"&&n!==p.NONE);for(const n of t){const r=Ct.getVisitFnByTypeId(n),i=Ht.getVisitFnByTypeId(n),s=fi.getVisitFnByTypeId(n);mc[n]={get:r,set:i,indexOf:s},gc[n]=Object.create(e,{isValid:{value:di(ws)},get:{value:di(Ct.getVisitFnByTypeId(n))},set:{value:dc(Ht.getVisitFnByTypeId(n))},indexOf:{value:fc(fi.getVisitFnByTypeId(n))}})}return"Vector"})(it.prototype);class pi extends it{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(o){const a=s[o];if(a!==void 0)return a;const c=n.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new pi(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new it(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class Ss{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 Vt{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 Vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+rt),(n||new Vt).__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):vt.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new he).__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 Ss).__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 Ss).__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 Et).__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,vt.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 st{constructor(t=[],n,r,i=vt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=Es(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 st(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new st(n,this.metadata)}assign(...t){const n=t[0]instanceof st?t[0]:Array.isArray(t[0])?new st(t[0]):new st(t),r=[...this.fields],i=yi(yi(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{const c=r.findIndex(l=>l.name===a.name);return~c?(r[c]=a.clone({metadata:yi(yi(new Map,r[c].metadata),a.metadata)}))&&!1:!0}),o=Es(s,new Map);return new st([...r,...s],i,new Map([...this.dictionaries,...o]))}}st.prototype.fields=null,st.prototype.metadata=null,st.prototype.dictionaries=null;class yt{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 yt(`${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],yt.new(n,r,i,s)}}yt.prototype.type=null,yt.prototype.name=null,yt.prototype.nullable=null,yt.prototype.metadata=null;function yi(e,t){return new Map([...e||new Map,...t||new Map])}function Es(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(O.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&&Es(i.children,t)}return t}var cg=Oa,ug=an;class Xn{static decode(t){t=new ug(X(t));const n=Vt.getRootAsFooter(t),r=st.decode(n.schema(),new Map,n.version());return new hg(r,n)}static encode(t){const n=new cg,r=st.encode(n,t.schema);Vt.startRecordBatchesVector(n,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())Ce.encode(n,o);const i=n.endVector();Vt.startDictionariesVector(n,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())Ce.encode(n,o);const s=n.endVector();return Vt.startFooter(n),Vt.addSchema(n,r),Vt.addVersion(n,vt.V5),Vt.addRecordBatches(n,i),Vt.addDictionaries(n,s),Vt.finishFooterBuffer(n,Vt.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=vt.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 hg extends Xn{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 Ce.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Ce.decode(n)}return null}}class Ce{static decode(t){return new Ce(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return Ss.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=dt(r),this.bodyLength=dt(n)}}const Tt=Object.freeze({done:!0,value:void 0});class _c{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class Ts{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 dg extends Ts{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Y(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(Tt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Yt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Yt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Y(this,void 0,void 0,function*(){return yield this.abort(t),Tt})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),Tt})}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(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(Tt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class mi extends dg{write(t){if((t=X(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?es(this.toUint8Array(!0)):this.toUint8Array(!1).then(es)}toUint8Array(t=!1){return t?oe(this._values)[0]:Y(this,void 0,void 0,function*(){var n,r,i,s;const o=[];let a=0;try{for(var c=!0,l=Ke(this),u;u=yield l.next(),n=u.done,!n;c=!0){s=u.value,c=!1;const d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!c&&!n&&(i=l.return)&&(yield i.call(l))}finally{if(r)throw r.error}}return oe(o,a)[0]})}}class gi{constructor(t){t&&(this.source=new fg(Yt.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 wn{constructor(t){t instanceof wn?this.source=t.source:t instanceof mi?this.source=new Ze(Yt.fromAsyncIterable(t)):Sa(t)?this.source=new Ze(Yt.fromNodeStream(t)):is(t)?this.source=new Ze(Yt.fromDOMStream(t)):Ia(t)?this.source=new Ze(Yt.fromDOMStream(t.body)):jn(t)?this.source=new Ze(Yt.fromIterable(t)):Qe(t)?this.source=new Ze(Yt.fromAsyncIterable(t)):on(t)&&(this.source=new Ze(Yt.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 fg{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)||Tt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Tt)}}class Ze{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Y(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Y(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||Tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Y(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||Tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class bc extends gi{constructor(t,n){super(),this.position=0,this.buffer=X(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 _i extends wn{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Y(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 Y(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 Y(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,o=0,a=0;const c=Math.min(r,s+Math.min(r-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield n.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,n){return Y(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),o=new Uint8Array(s-t);return(yield r.read(o,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Y(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const pg=65536;function In(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Sn=8,As=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class vc{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?pg: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`${In(this.buffer[1])} ${In(this.buffer[0])}`}}class at extends vc{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return at.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return at.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new at(n);for(let s=0;s<r;){const o=Sn<r-s?Sn:r-s,a=new at(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new at(new Uint32Array([As[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)at.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new at(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new at(new Uint32Array(t.buffer)).plus(n)}}class Kt extends vc{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 Kt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Kt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new Kt(n);for(let o=r?1:0;o<i;){const a=Sn<i-o?Sn:i-o,c=new Kt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new Kt(new Uint32Array([As[a],0]));s.times(l),s.plus(c),o+=a}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Kt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Kt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Kt(new Uint32Array(t.buffer)).plus(n)}}class de{constructor(t){this.buffer=t}high(){return new Kt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Kt(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 at(new Uint32Array([this.buffer[3],0])),r=new at(new Uint32Array([this.buffer[2],0])),i=new at(new Uint32Array([this.buffer[1],0])),s=new at(new Uint32Array([this.buffer[0],0])),o=new at(new Uint32Array([t.buffer[3],0])),a=new at(new Uint32Array([t.buffer[2],0])),c=new at(new Uint32Array([t.buffer[1],0])),l=new at(new Uint32Array([t.buffer[0],0]));let u=at.multiply(s,l);this.buffer[0]=u.low();const d=new at(new Uint32Array([u.high(),0]));return u=at.multiply(i,l),d.plus(u),u=at.multiply(s,c),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new at(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(at.multiply(r,l)).plus(at.multiply(i,c)).plus(at.multiply(s,a)),this.buffer[3]+=at.multiply(n,l).plus(at.multiply(r,c)).plus(at.multiply(i,a)).plus(at.multiply(s,o)).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`${In(this.buffer[3])} ${In(this.buffer[2])} ${In(this.buffer[1])} ${In(this.buffer[0])}`}static multiply(t,n){return new de(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new de(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return de.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return de.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new de(n);for(let o=r?1:0;o<i;){const a=Sn<i-o?Sn:i-o,c=new de(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new de(new Uint32Array([As[a],0,0,0]));s.times(l),s.plus(c),o+=a}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)de.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class wc extends H{constructor(t,n,r,i,s=vt.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 yt?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return Q({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({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 Q({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 Q({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 Q({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 Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({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 Q({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<vt.V5&&this.readNullBitmap(t,r),t.mode===Nt.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({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 Q({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({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 Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return Q({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 Q({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 yg extends wc{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):hi(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return ht(Uint8Array,ht(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return ht(Uint8Array,ht(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return O.isTimestamp(t)||(O.isInt(t)||O.isTime(t))&&t.bitWidth===64||O.isDuration(t)||O.isDate(t)&&t.unit===jt.MILLISECOND?ht(Uint8Array,Kt.convertArray(r[n])):O.isDecimal(t)?ht(Uint8Array,de.convertArray(r[n])):O.isBinary(t)||O.isLargeBinary(t)||O.isFixedSizeBinary(t)?mg(r[n]):O.isBool(t)?hi(r[n]):O.isUtf8(t)||O.isLargeUtf8(t)?ns(r[n].join("")):ht(Uint8Array,ht(t.ArrayType,r[n].map(i=>+i)))}}function mg(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 U extends H{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 Dt(e,t){return t instanceof e.constructor}function tn(e,t){return e===t||Dt(e,t)}function Ae(e,t){return e===t||Dt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function bi(e,t){return e===t||Dt(e,t)&&e.precision===t.precision}function gg(e,t){return e===t||Dt(e,t)&&e.byteWidth===t.byteWidth}function Ns(e,t){return e===t||Dt(e,t)&&e.unit===t.unit}function Jn(e,t){return e===t||Dt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Zn(e,t){return e===t||Dt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function _g(e,t){return e===t||Dt(e,t)&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function bg(e,t){return e===t||Dt(e,t)&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function Rs(e,t){return e===t||Dt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&$e.compareManyFields(e.children,t.children)}function vg(e,t){return e===t||Dt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&$e.visit(e.indices,t.indices)&&$e.visit(e.dictionary,t.dictionary)}function Bs(e,t){return e===t||Dt(e,t)&&e.unit===t.unit}function tr(e,t){return e===t||Dt(e,t)&&e.unit===t.unit}function wg(e,t){return e===t||Dt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function Ig(e,t){return e===t||Dt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}U.prototype.visitNull=tn,U.prototype.visitBool=tn,U.prototype.visitInt=Ae,U.prototype.visitInt8=Ae,U.prototype.visitInt16=Ae,U.prototype.visitInt32=Ae,U.prototype.visitInt64=Ae,U.prototype.visitUint8=Ae,U.prototype.visitUint16=Ae,U.prototype.visitUint32=Ae,U.prototype.visitUint64=Ae,U.prototype.visitFloat=bi,U.prototype.visitFloat16=bi,U.prototype.visitFloat32=bi,U.prototype.visitFloat64=bi,U.prototype.visitUtf8=tn,U.prototype.visitLargeUtf8=tn,U.prototype.visitBinary=tn,U.prototype.visitLargeBinary=tn,U.prototype.visitFixedSizeBinary=gg,U.prototype.visitDate=Ns,U.prototype.visitDateDay=Ns,U.prototype.visitDateMillisecond=Ns,U.prototype.visitTimestamp=Jn,U.prototype.visitTimestampSecond=Jn,U.prototype.visitTimestampMillisecond=Jn,U.prototype.visitTimestampMicrosecond=Jn,U.prototype.visitTimestampNanosecond=Jn,U.prototype.visitTime=Zn,U.prototype.visitTimeSecond=Zn,U.prototype.visitTimeMillisecond=Zn,U.prototype.visitTimeMicrosecond=Zn,U.prototype.visitTimeNanosecond=Zn,U.prototype.visitDecimal=tn,U.prototype.visitList=_g,U.prototype.visitStruct=bg,U.prototype.visitUnion=Rs,U.prototype.visitDenseUnion=Rs,U.prototype.visitSparseUnion=Rs,U.prototype.visitDictionary=vg,U.prototype.visitInterval=Bs,U.prototype.visitIntervalDayTime=Bs,U.prototype.visitIntervalYearMonth=Bs,U.prototype.visitDuration=tr,U.prototype.visitDurationSecond=tr,U.prototype.visitDurationMillisecond=tr,U.prototype.visitDurationMicrosecond=tr,U.prototype.visitDurationNanosecond=tr,U.prototype.visitFixedSizeList=wg,U.prototype.visitMap=Ig;const $e=new U;function Os(e,t){return $e.compareSchemas(e,t)}function Ds(e,t){return Sg(e,t.map(n=>n.data.concat()))}function Sg(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((d,y)=>Math.max(d,y.length),0)};let s=0,o=0,a=-1;const c=t.length;let l,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=Eg(n,o,u,t,i),o>0&&(r[s++]=Q({type:new Ot(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(d=>new $t(e,d))]}function Eg(e,t,n,r,i){var s;const o=(t+63&-64)>>3;for(let a=-1,c=r.length;++a<c;){const l=n[a],u=l?.length;if(u>=t)u===t?n[a]=l:(n[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,r[a].unshift(l.slice(t,u-t))));else{const d=e[a];e[a]=d.clone({nullable:!0}),n[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:Q({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var Ic;class Lt{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new st([]),this._offsets=[0],this;let i,s;t[0]instanceof st&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=c=>{if(c){if(c instanceof $t)return[c];if(c instanceof Lt)return c.batches;if(c instanceof ot){if(c.type instanceof Ot)return[new $t(new st(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){const l=Object.keys(c),u=l.map(m=>new it([c[m]])),d=i??new st(l.map((m,b)=>new yt(String(m),u[b].type,u[b].nullable))),[,y]=Ds(d,u);return y.length===0?[new $t(c)]:y}}}return[]},a=t.flatMap(c=>o(c));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new st([]),!(i instanceof st))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const c of a){if(!(c instanceof $t))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Os(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??uc(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=cc(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(ms(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?Is.visit(new it(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
35
+ `),l&&(o.useProgram(l),d=It(),c=dt(o,l,d),y=Ir.translate(E/2,T/2).scale(1),_=Yf().scaleExtent([.1,100]).on("zoom",u=>{y=u.transform,ht(o,c,2,v)}),pe(i.value).call(_),requestAnimationFrame(()=>ht(o,c,2,null)),i.value.addEventListener("mousemove",R),i.value.addEventListener("mouseleave",F))}}function R(u){if(!i.value)return;const m=i.value.getBoundingClientRect(),b=u.clientX-m.left,w=u.clientY-m.top,I=gt(d,b,w,E,T);if(I){const S=s.value;S.style.left=`${u.clientX+15}px`,S.style.top=`${u.clientY-15}px`,S.style.opacity="1",S.innerHTML=`<strong>(${I.rawX.toFixed(2)}, ${I.rawY.toFixed(2)})</strong>`,v=I,ht(o,c,2,v)}else s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function F(){s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function p(){!i.value||!o||(it(i.value,o),ht(o,c,2,v))}function g(){var O;if(!o||!c||!n.data.length)return;const u=(((O=n.metaData)==null?void 0:O.schema)||[]).findIndex(A=>(A==null?void 0:A.name)===n.colorMode),m=u>=0?u:-1,b=B(n.startColor),w=B(n.endColor);let I=[];if(n.colorMap&&n.colorMap.size>0&&m>=0)I=n.data.flatMap(A=>n.colorMap.get(A[m])||[.6,.6,.6]);else if(m>=0){const A=n.data.map(st=>Number(st[m])).filter(Number.isFinite),M=Math.min(...A),J=Math.max(...A)-M||1;I=n.data.flatMap(st=>{const ct=Number(st[m]),St=Math.max(0,Math.min(1,(ct-M)/J));return[Q(b[0],w[0],St),Q(b[1],w[1],St),Q(b[2],w[2],St)]})}else{const A=B(n.singleColor);I=n.data.flatMap(()=>A)}o.deleteBuffer(c.colorBuffer);const S=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,S),o.bufferData(o.ARRAY_BUFFER,new Float32Array(I),o.STATIC_DRAW),c.colorBuffer=S,ht(o,c,2,v)}return h.watch(()=>n.forceRegenerate,()=>{!o||!l||(d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),y=Ir,i.value&&_&&pe(i.value).call(_.transform,y),g(),ht(o,c,2,null))}),h.watch(()=>n.data,()=>{if(!o||!l){Zt();return}d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null)}),h.watch(()=>n.colorMode,g),h.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],g),h.watch(()=>n.pointCount,u=>{!o||!l||(d=It(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null))}),h.onMounted(()=>{window.addEventListener("resize",p)}),h.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",R),i.value.removeEventListener("mouseleave",F)),window.removeEventListener("resize",p),o&&c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer),l&&o.deleteProgram(l))}),(u,m)=>(h.openBlock(),h.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[h.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),h.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),h.withDirectives(h.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:a},null,512),[[h.vShow,!1]])],512))}}),qf=Sn(Wf,[["__scopeId","data-v-2c0af95e"]]),Gf={class:"control-panel"},Hf={class:"color-option"},Kf=["value"],Qf={key:0,class:"color-option"},Xf={class:"legend"},Jf={class:"legend-label"},Zf=h.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=h.ref(n.pointCount),s=h.ref(n.colorMode),a=h.ref(n.startColor),o=h.ref(n.endColor),l=h.ref(n.singleColor),c=h.computed(()=>n.colorMapMap instanceof Map?Array.from(n.colorMapMap.keys()):[]),d=h.computed(()=>n.colorMapMap instanceof Map?n.colorMapMap.get(s.value):void 0),y=h.computed(()=>d.value?Array.from(d.value.entries()):[]);function _(E){if(!E)return"rgb(150,150,150)";const[T,N,B]=E;return`rgb(${Math.round(T*255)}, ${Math.round(N*255)}, ${Math.round(B*255)})`}function v(){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 h.watch(()=>n.pointCount,E=>i.value=E),h.watch(()=>n.colorMode,E=>s.value=E),h.watch(()=>n.startColor,E=>a.value=E),h.watch(()=>n.endColor,E=>o.value=E),h.watch(()=>n.singleColor,E=>l.value=E),h.watch(s,v),h.watch(()=>n.colorMapMap,()=>{n.colorMapMap instanceof Map&&(s.value!=="random"&&!n.colorMapMap.has(s.value)&&(s.value="random"),v())}),(E,T)=>(h.openBlock(),h.createElementBlock("div",Gf,[T[4]||(T[4]=h.createElementVNode("h3",null,"Color Controls",-1)),h.createElementVNode("div",Hf,[T[2]||(T[2]=h.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),h.withDirectives(h.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":T[0]||(T[0]=N=>s.value=N)},[T[1]||(T[1]=h.createElementVNode("option",{value:"random"},"random",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(c.value,N=>(h.openBlock(),h.createElementBlock("option",{key:N,value:N},h.toDisplayString(N),9,Kf))),128))],512),[[h.vModelSelect,s.value]])]),y.value.length?(h.openBlock(),h.createElementBlock("div",Qf,[h.createElementVNode("div",Xf,[T[3]||(T[3]=h.createElementVNode("h4",null,"Legend",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(y.value,([N,B],Q)=>(h.openBlock(),h.createElementBlock("div",{class:"legend-item",key:`${N}-${Q}`},[h.createElementVNode("div",{class:"legend-color",style:h.normalizeStyle({backgroundColor:_(B)})},null,4),h.createElementVNode("div",Jf,h.toDisplayString(N),1)]))),128))])])):h.createCommentVNode("",!0)]))}}),tp=Sn(Zf,[["__scopeId","data-v-91c1f44e"]]),ep={class:"app-container"},ki="UMAP_1",$i="UMAP_2",np=h.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=h.ref(5e3),r=h.ref("random"),i=h.ref("#ff0000"),s=h.ref("#0000ff"),a=h.ref("#4285f4"),o=h.ref(!1),l=h.ref(0),c=h.ref([]),d=h.ref(null),y=h.ref(new Map),_=h.ref(new Map),v=h.ref([]),E=js(),T=h.ref(null),N=h.ref(null);h.watch(()=>{var p,g,u,m;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((g=(p=t.pkg)==null?void 0:p.content)==null?void 0:g.id)||"",pkgType:((m=(u=t.pkg)==null?void 0:u.content)==null?void 0:m.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:p,srcFileType:g,srcFileId:u,pkgId:m,pkgType:b,apiUrl:w})=>{var I,S,O;try{if(c.value=[],d.value=null,await B(),p){const A=g??(p.toLowerCase().endsWith(".csv")?"csv":"parquet");await Q(p,A,u||"umap_file"),await it();return}if(m&&w){await It(m,w);const A=(O=(S=(I=v.value)==null?void 0:I[0])==null?void 0:S.content)==null?void 0:O.id;if(!A)return;const M=await $t(m,A,w);await Q(M,b==="CSV"?"csv":"parquet",A),await it()}}catch(A){console.error("[UMAP Wrapper] Load failed:",(A==null?void 0:A.message)||A)}},{immediate:!0}),h.watch(n,async()=>{N.value&&T.value&&await mt()}),h.watch([()=>E.sharedVersion,()=>E.sharedResultName],async()=>{E.sharedResultName&&(await B(),N.value=E.sharedResultName,await it())});async function B(){if(T.value)return;const{connectionId:p}=await E.createConnection(`umap_${Date.now()}`);T.value=p}async function Q(p,g,u){const m=`umap_${u.replace(/[^a-zA-Z0-9_]/g,"_")}`;N.value=await E.loadFile(p,g,m,{},T.value,u)}async function it(){var b,w,I,S;if(!N.value||!T.value)return;const p=await F(N.value),g=p.filter(O=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(O.type)),u=p.some(O=>O.name===ki)?ki:((b=g[0])==null?void 0:b.name)||((w=p[0])==null?void 0:w.name),m=p.some(O=>O.name===$i)?$i:((I=g[1])==null?void 0:I.name)||((S=p[1])==null?void 0:S.name)||u;await mt(u,m,p.map(O=>O.name)),await bt(p,u,m)}async function mt(p=ki,g=$i,u){var O;if(!N.value||!T.value)return;const m=(u||(await F(N.value)).map(A=>A.name)).filter(A=>A!==p&&A!==g),b=`SELECT ${[`CAST(${dt(p)} AS DOUBLE) AS __x`,`CAST(${dt(g)} AS DOUBLE) AS __y`,...m.map(A=>dt(A))].join(", ")} FROM ${N.value} LIMIT ${n.value}`,w=await E.executeQuery(b,T.value);c.value=w.map(A=>[A.__x,A.__y,...m.map(M=>A[M])]);const I=`
36
+ SELECT min(${dt(p)}) AS xmin, max(${dt(p)}) AS xmax,
37
+ min(${dt(g)}) AS ymin, max(${dt(g)}) AS ymax
38
+ FROM ${N.value}
39
+ `,S=((O=await E.executeQuery(I,T.value))==null?void 0:O[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};d.value={schema:[{name:p},{name:g},...m.map(A=>({name:A}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:S.xmin,max_value:S.xmax}}},{meta_data:{statistics:{min_value:S.ymin,max_value:S.ymax}}}]}]}}async function bt(p,g,u){_.value=new Map;const m=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],b=w=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(w);for(const w of p){if(w.name===g||w.name===u){_.value.set(w.name,new Map);continue}if(b(w.type))_.value.set(w.name,new Map);else{const I=`SELECT DISTINCT ${dt(w.name)} AS v FROM ${N.value} LIMIT 10000`,S=(await E.executeQuery(I,T.value)).map(A=>A.v).filter(A=>A!=null),O=new Map;S.forEach((A,M)=>O.set(A,Zt(m[M%m.length]))),_.value.set(w.name,O)}}(d.value||(d.value={})).key_value_metadata=Array.from(_.value.keys()).map(w=>{var I;return{key:w,value:JSON.stringify(Array.from(((I=_.value.get(w))==null?void 0:I.keys())??[]))}}),r.value!=="random"&&!_.value.has(r.value)&&(r.value="random")}async function gt(){const{useGetToken:p}=await Promise.resolve().then(()=>Bc);return p()}async function It(p,g){const u=await gt(),m=`${g}/packages/${p}/view?api_key=${u}`,b=await fetch(m);if(!b.ok)throw new Error(`view failed: ${b.status}`);v.value=await b.json()}async function $t(p,g,u){const m=await gt(),b=`${u}/packages/${p}/files/${g}?api_key=${m}`,w=await fetch(b);if(!w.ok)throw new Error(`file url failed: ${w.status}`);return(await w.json()).url}function dt(p){return`"${p.replace(/"/g,'""')}"`}function ht(){o.value=!o.value,l.value++}function Zt(p){try{if(!p||p.length<7)return[1,0,0];const g=parseInt(p.slice(1,3),16)/255,u=parseInt(p.slice(3,5),16)/255,m=parseInt(p.slice(5,7),16)/255;return Number.isNaN(g)||Number.isNaN(u)||Number.isNaN(m)?[1,0,0]:[g,u,m]}catch{return[1,0,0]}}function R(p){y.value=p[1]}async function F(p){return(await E.executeQuery(`PRAGMA table_info(${p});`,T.value)).map(g=>({name:g.name,type:g.type}))}return h.onMounted(async()=>{await B()}),h.onBeforeUnmount(async()=>{T.value&&await E.closeConnection(T.value)}),(p,g)=>(h.openBlock(),h.createElementBlock("div",ep,[(h.openBlock(),h.createBlock(qf,{data:c.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),h.createVNode(tp,{pointCount:n.value,"onUpdate:pointCount":g[0]||(g[0]=u=>n.value=u),colorMode:r.value,"onUpdate:colorMode":g[1]||(g[1]=u=>r.value=u),startColor:i.value,"onUpdate:startColor":g[2]||(g[2]=u=>i.value=u),endColor:s.value,"onUpdate:endColor":g[3]||(g[3]=u=>s.value=u),singleColor:a.value,"onUpdate:singleColor":g[4]||(g[4]=u=>a.value=u),"color-scheme":y.value,"color-map-map":_.value,onRegenerate:ht,onUpdateColorMap:R},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),rp=Sn(np,[["__scopeId","data-v-244cd07d"]]),ip="dashboard:globalVars";function La(e=!1){const t=h.inject(ip,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const sp={class:"data-explorer-wrap"},ap={class:"data-explorer-info"},op=h.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t.s3Url));return h.watchEffect(()=>{}),(i,s)=>{const a=h.resolveComponent("el-icon");return h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",sp,[h.createElementVNode("div",ap,[h.createVNode(h.unref(Pc.ElTooltip),{placement:"top-start"},{content:h.withCtx(()=>[...s[0]||(s[0]=[h.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:h.withCtx(()=>[h.createVNode(a,{color:"#8300BF"},{default:h.withCtx(()=>[h.createVNode(h.unref(jc))]),_:1})]),_:1})]),h.createVNode(h.unref(yu),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),xa=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},lp=xa(op,[["__scopeId","data-v-08f7f19e"]]),cp={class:"umap-wrap"},up=xa(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t==null?void 0:t.s3Url));return(i,s)=>(h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",cp,[h.createVNode(h.unref(rp),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function Y(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{c(r.next(d))}catch(y){a(y)}}function l(d){try{c(r.throw(d))}catch(y){a(y)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((r=r.apply(e,t||[])).next())})}function Ua(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 W(e){return this instanceof W?(this.v=e,this):new W(e)}function re(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(v){return function(E){return Promise.resolve(E).then(v,y)}}function o(v,E){r[v]&&(i[v]=function(T){return new Promise(function(N,B){s.push([v,T,N,B])>1||l(v,T)})},E&&(i[v]=E(i[v])))}function l(v,E){try{c(r[v](E))}catch(T){_(s[0][3],T)}}function c(v){v.value instanceof W?Promise.resolve(v.value.v).then(d,y):_(s[0][2],v)}function d(v){l("next",v)}function y(v){l("throw",v)}function _(v,E){v(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Sr(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:W(e[i](a)),done:!1}:s?s(a):a}:s}}function je(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 Ua=="function"?Ua(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(c){s({value:c,done:o})},a)}}const hp=new TextDecoder("utf-8"),Pi=e=>hp.decode(e),dp=new TextEncoder,Vi=e=>dp.encode(e),fp=e=>typeof e=="number",Ca=e=>typeof e=="boolean",_t=e=>typeof e=="function",Dt=e=>e!=null&&Object(e)===e,Ye=e=>Dt(e)&&_t(e.then),Ln=e=>Dt(e)&&_t(e[Symbol.iterator]),Ze=e=>Dt(e)&&_t(e[Symbol.asyncIterator]),zi=e=>Dt(e)&&Dt(e.schema),ka=e=>Dt(e)&&"done"in e&&"value"in e,$a=e=>Dt(e)&&_t(e.stat)&&fp(e.fd),Pa=e=>Dt(e)&&ji(e.body),Er=e=>"_getDOMStream"in e&&"_getNodeStream"in e,pp=e=>Dt(e)&&_t(e.abort)&&_t(e.getWriter)&&!Er(e),ji=e=>Dt(e)&&_t(e.cancel)&&_t(e.getReader)&&!Er(e),yp=e=>Dt(e)&&_t(e.end)&&_t(e.write)&&Ca(e.writable)&&!Er(e),Va=e=>Dt(e)&&_t(e.read)&&_t(e.pipe)&&Ca(e.readable)&&!Er(e),mp=e=>Dt(e)&&_t(e.clear)&&_t(e.bytes)&&_t(e.position)&&_t(e.setPosition)&&_t(e.capacity)&&_t(e.getBufferIdentifier)&&_t(e.createLong),Yi=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function bp(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,c=0,d=e.length;++l<d;){if(a=t[c],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++c]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++c]=o);continue}t[c]=new Uint8Array(a.buffer,n,r-n+s)}return t}function za(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 ie(e,t){const n=bp(e),r=n.reduce((d,y)=>d+y.byteLength,0);let i,s,a,o=0,l=-1;const c=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,c-o)),c<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?za(a,s,o):a=s;break}za(a||(a=new Uint8Array(c)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function at(e,t){let n=ka(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Vi(n)),n instanceof ArrayBuffer?new e(n):n instanceof Yi?new e(n):mp(n)?at(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 xn=e=>at(Int32Array,e),ja=e=>at(BigInt64Array,e),H=e=>at(Uint8Array,e),Wi=e=>(e.next(),e);function*gp(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Yi?n(t):Ln(t)?t:n(t);return yield*Wi(function*(i){let s=null;do s=i.next(yield at(e,s));while(!s.done)}(r[Symbol.iterator]())),new e}const _p=e=>gp(Uint8Array,e);function Ya(e,t){return re(this,arguments,function*(){if(Ye(t))return yield W(yield W(yield*Sr(je(Ya(e,yield W(t))))));const n=function(s){return re(this,arguments,function*(){yield yield W(yield W(s))})},r=function(s){return re(this,arguments,function*(){yield W(yield*Sr(je(Wi(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 Yi?n(t):Ln(t)?r(t):Ze(t)?t:n(t);return yield W(yield*Sr(je(Wi(function(s){return re(this,arguments,function*(){let a=null;do a=yield W(s.next(yield yield W(at(e,a))));while(!a.done)})}(i[Symbol.asyncIterator]()))))),yield W(new e)})}const vp=e=>Ya(Uint8Array,e);function Wa(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 wp(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 Pt={fromIterable(e){return Tr(Ip(e))},fromAsyncIterable(e){return Tr(Sp(e))},fromDOMStream(e){return Tr(Ep(e))},fromNodeStream(e){return Tr(Ap(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')}},Tr=e=>(e.next(),e);function*Ip(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const c=_p(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?c.next():c.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 c.throw=="function"&&c.throw(d)}finally{n===!1&&typeof c.return=="function"&&c.return(null)}return null}function Sp(e){return re(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=vp(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.next()):yield W(c.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&(yield W(c.throw(d)))}finally{n===!1&&typeof c.return=="function"&&(yield W(c.return(new Uint8Array(0))))}return yield W(null)})}function Ep(e){return re(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=new Tp(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.read()):yield W(c.read(a-o)),!t&&i.byteLength>0&&(r.push(H(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&(yield W(c.cancel(d)))}finally{n===!1?yield W(c.cancel()):e.locked&&c.releaseLock()}return yield W(null)})}class Tp{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 Y(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 Y(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=H(n)),n})}}const qi=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Ap(e){return re(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],c;function d(){return s==="peek"?ie(l,a)[0]:([c,l,o]=ie(l,a),c)}if({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0},e.isTTY)return yield yield W(new Uint8Array(0)),yield W(null);try{t[0]=qi(e,"end"),t[1]=qi(e,"error");do{if(t[2]=qi(e,"readable"),[n,i]=yield W(Promise.race(t.map(_=>_[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(c=H(e.read(a-o)),c.byteLength<a-o&&(c=H(e.read()))):c=H(e.read()),c.byteLength>0&&(l.push(c),o+=c.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield W(d()));while(a<o)}while(!r)}finally{yield W(y(t,n==="error"?i:null))}return yield W(null);function y(_,v){return c=l=null,new Promise((E,T)=>{for(const[N,B]of _)e.off(N,B);try{const N=e.destroy;N&&N.call(e,v),v=void 0}catch(N){v=N||v}finally{v!=null?T(v):E()}})}})}var yt;(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"})(yt||(yt={}));var Et;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Et||(Et={}));var Tt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Tt||(Tt={}));var Vt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Vt||(Vt={}));var k;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var se;(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"})(se||(se={}));const Gi=2,ae=4,ge=4,Z=4,Be=new Int32Array(2),qa=new Float32Array(Be.buffer),Ga=new Float64Array(Be.buffer),Ar=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Hi;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Hi||(Hi={}));let tn=class kc{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new kc(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 Be[0]=this.readInt32(t),qa[0]}readFloat64(t){return Be[Ar?0:1]=this.readInt32(t),Be[Ar?1:0]=this.readInt32(t+4),Ga[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){qa[0]=n,this.writeInt32(t,Be[0])}writeFloat64(t,n){Ga[0]=n,this.writeInt32(t,Be[Ar?0:1]),this.writeInt32(t+4,Be[Ar?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+ae+ge)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<ge;n++)t+=String.fromCharCode(this.readInt8(this.position_+ae+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+=ae;const i=this.bytes_.subarray(t,t+r);return n===Hi.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)+ae}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ge)throw new Error("FlatBuffers: file identifier must be length "+ge);for(let n=0;n<ge;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+ae+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}},Ha=class $c{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=tn.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=$c.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=tn.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(ae,0),this.writeInt32(this.offset()-t+ae)}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)*Gi;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 c=Gi;c<s;c+=Gi)if(this.bb.readInt16(o+c)!=this.bb.readInt16(l+c))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?Z:0;if(n){const s=n;if(this.prep(this.minalign,ae+ge+i),s.length!=ge)throw new TypeError("FlatBuffers: file identifier must be length "+ge);for(let a=ge-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,ae+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(ae,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 Nr;(function(e){e[e.BUFFER=0]="BUFFER"})(Nr||(Nr={}));var Br;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Br||(Br={}));class Re{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 Re).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Z),(n||new Re).__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):Br.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Nr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Br.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,Nr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Re.startBodyCompression(t),Re.addCodec(t,n),Re.addMethod(t,r),Re.endBodyCompression(t)}}class Ka{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 Qa=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()}},_e=class Vs{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 Vs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Z),(n||new Vs).__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 Qa).__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 Ka).__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 Re).__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()}},en=class zs{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 zs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Z),(n||new zs).__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 _e).__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 nn;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(nn||(nn={}));var Rr;(function(e){e[e.DenseArray=0]="DenseArray"})(Rr||(Rr={}));class Ut{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 Ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Z),(n||new Ut).__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 Ut.startInt(t),Ut.addBitWidth(t,n),Ut.addIsSigned(t,r),Ut.endInt(t)}}class ve{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 ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Z),(n||new ve).__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 Ut).__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):Rr.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,Rr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class vt{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 vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Z),(n||new vt).__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 vt.startKeyValue(t),vt.addKey(t,n),vt.addValue(t,r),vt.endKeyValue(t)}}let Xa=class Xn{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 Xn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Z),(n||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Xn.startBinary(t),Xn.endBinary(t)}},Ja=class Jn{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 Jn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Z),(n||new Jn).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Jn.startBool(t),Jn.endBool(t)}},Or=class gn{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 gn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Z),(n||new gn).__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):Vt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Vt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return gn.startDate(t),gn.addUnit(t,n),gn.endDate(t)}},rn=class Ue{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 Ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Z),(n||new Ue).__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 Ue.startDecimal(t),Ue.addPrecision(t,n),Ue.addScale(t,r),Ue.addBitWidth(t,i),Ue.endDecimal(t)}},Dr=class _n{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 _n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Z),(n||new _n).__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):k.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,k.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return _n.startDuration(t),_n.addUnit(t,n),_n.endDuration(t)}},Fr=class vn{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 vn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Z),(n||new vn).__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 vn.startFixedSizeBinary(t),vn.addByteWidth(t,n),vn.endFixedSizeBinary(t)}},Mr=class wn{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 wn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Z),(n||new wn).__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 wn.startFixedSizeList(t),wn.addListSize(t,n),wn.endFixedSizeList(t)}};class oe{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 oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Z),(n||new oe).__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):Tt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Tt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return oe.startFloatingPoint(t),oe.addPrecision(t,n),oe.endFloatingPoint(t)}}class le{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 le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Z),(n||new le).__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):se.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,se.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return le.startInterval(t),le.addUnit(t,n),le.endInterval(t)}}let Za=class Zn{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 Zn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Z),(n||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Zn.startLargeBinary(t),Zn.endLargeBinary(t)}},to=class tr{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 tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Z),(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return tr.startLargeUtf8(t),tr.endLargeUtf8(t)}},eo=class er{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 er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Z),(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return er.startList(t),er.endList(t)}},Lr=class In{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 In).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Z),(n||new In).__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 In.startMap(t),In.addKeysSorted(t,n),In.endMap(t)}},no=class nr{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 nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Z),(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return nr.startNull(t),nr.endNull(t)}};class We{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 We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Z),(n||new We).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return We.startStruct_(t),We.endStruct_(t)}}class zt{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 zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Z),(n||new zt).__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):k.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,k.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return zt.startTime(t),zt.addUnit(t,n),zt.addBitWidth(t,r),zt.endTime(t)}}class jt{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 jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Z),(n||new jt).__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):k.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,k.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return jt.startTimestamp(t),jt.addUnit(t,n),jt.addTimezone(t,r),jt.endTimestamp(t)}}class Ft{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 Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Z),(n||new Ft).__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):Et.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,Et.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 Ft.startUnion(t),Ft.addMode(t,n),Ft.addTypeIds(t,r),Ft.endUnion(t)}}let ro=class rr{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 rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Z),(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return rr.startUtf8(t),rr.endUtf8(t)}};var lt;(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"})(lt||(lt={}));let Yt=class _i{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 _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Z),(n||new _i).__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):lt.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 ve).__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 _i).__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 vt).__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,lt.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()}},ce=class Ae{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 Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Z),(n||new Ae).__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):nn.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Yt).__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 vt).__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,nn.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 Ae.startSchema(t),Ae.addEndianness(t,n),Ae.addFields(t,r),Ae.addCustomMetadata(t,i),Ae.addFeatures(t,s),Ae.endSchema(t)}};var X;(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"})(X||(X={}));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 we;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(we||(we={}));const Np=void 0;function Un(e){if(e===null)return"null";if(e===Np)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=>Un(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function ot(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 io(e,t){return ot(e/t)+ot(e%t)/ot(t)}const Bp=Symbol.for("isArrowBigNum");function Qt(e,...t){return t.length===0?Object.setPrototypeOf(at(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Qt.prototype[Bp]=!0,Qt.prototype.toJSON=function(){return`"${kn(this)}"`},Qt.prototype.valueOf=function(e){return so(this,e)},Qt.prototype.toString=function(){return kn(this)},Qt.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return so(this);case"string":return kn(this);case"default":return Dp(this)}return kn(this)};function sn(...e){return Qt.apply(this,e)}function an(...e){return Qt.apply(this,e)}function Cn(...e){return Qt.apply(this,e)}Object.setPrototypeOf(sn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(an.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Cn.prototype,Object.create(Uint32Array.prototype)),Object.assign(sn.prototype,Qt.prototype,{constructor:sn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(an.prototype,Qt.prototype,{constructor:an,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Cn.prototype,Qt.prototype,{constructor:Cn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Rp=BigInt(4294967296)*BigInt(4294967296),Op=Rp-BigInt(1);function so(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),c=0;if(o){for(const d of a)l|=(d^Op)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*c++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),y=l/d,_=l%d;return ot(y)+ot(_)/ot(d)}return ot(l)}function kn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Ki(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ki(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`-${Ki(t)}`}function Dp(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:kn(e)}function Ki(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 Qi{static new(t,n){switch(n){case!0:return new sn(t);case!1:return new an(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new sn(t)}return t.byteLength===16?new Cn(t):new an(t)}static signed(t){return new sn(t)}static unsigned(t){return new an(t)}static decimal(t){return new Cn(t)}constructor(t,n){return Qi.new(t,n)}}var ao,oo,lo,co,uo,ho,fo,po,yo,mo,bo,go,_o,vo,wo,Io,So,Eo,To,Ao,No,Bo;class D{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 D.isUnion(t)&&t.mode===Et.Dense}static isSparseUnion(t){return D.isUnion(t)&&t.mode===Et.Sparse}constructor(t){this.typeId=t}}ao=Symbol.toStringTag,D[ao]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(D.prototype);class Oe extends D{constructor(){super(f.Null)}toString(){return"Null"}}oo=Symbol.toStringTag,Oe[oo]=(e=>e[Symbol.toStringTag]="Null")(Oe.prototype);class qe extends D{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}`}}lo=Symbol.toStringTag,qe[lo]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(qe.prototype);class $n extends qe{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty($n.prototype,"ArrayType",{value:Int32Array});class xr extends D{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Tt.HALF:return Uint16Array;case Tt.SINGLE:return Float32Array;case Tt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}co=Symbol.toStringTag,xr[co]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(xr.prototype);class Ur extends D{constructor(){super(f.Binary)}toString(){return"Binary"}}uo=Symbol.toStringTag,Ur[uo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Ur.prototype);class Cr extends D{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}}ho=Symbol.toStringTag,Cr[ho]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Cr.prototype);class kr extends D{constructor(){super(f.Utf8)}toString(){return"Utf8"}}fo=Symbol.toStringTag,kr[fo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(kr.prototype);class $r extends D{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}}po=Symbol.toStringTag,$r[po]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))($r.prototype);class Pr extends D{constructor(){super(f.Bool)}toString(){return"Bool"}}yo=Symbol.toStringTag,Pr[yo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Pr.prototype);class Vr extends D{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}]`}}mo=Symbol.toStringTag,Vr[mo]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Vr.prototype);class zr extends D{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Vt[this.unit]}>`}get ArrayType(){return this.unit===Vt.DAY?Int32Array:BigInt64Array}}bo=Symbol.toStringTag,zr[bo]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(zr.prototype);class jr extends D{constructor(t,n){super(f.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}go=Symbol.toStringTag,jr[go]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(jr.prototype);class Yr extends D{constructor(t,n){super(f.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}_o=Symbol.toStringTag,Yr[_o]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Yr.prototype);class Wr extends D{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${se[this.unit]}>`}}vo=Symbol.toStringTag,Wr[vo]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Wr.prototype);class qr extends D{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${k[this.unit]}>`}}wo=Symbol.toStringTag,qr[wo]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(qr.prototype);class Gr extends D{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}}Io=Symbol.toStringTag,Gr[Io]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Gr.prototype);class At extends D{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}So=Symbol.toStringTag,At[So]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(At.prototype);class Hr extends D{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(" | ")}>`}}Eo=Symbol.toStringTag,Hr[Eo]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Hr.prototype);class Kr extends D{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}To=Symbol.toStringTag,Kr[To]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Kr.prototype);class Qr extends D{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}>`}}Ao=Symbol.toStringTag,Qr[Ao]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Qr.prototype);class Xr extends D{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(", ")}}>`}}No=Symbol.toStringTag,Xr[No]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Xr.prototype);const Fp=(e=>()=>++e)(-1);class on extends D{constructor(t,n,r,i){super(f.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?Fp():ot(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}>`}}Bo=Symbol.toStringTag,on[Bo]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(on.prototype);function Ie(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 q{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 Mp(this,t,n)}getVisitFnByTypeId(t,n=!0){return ln(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 Mp(e,t,n=!0){return typeof t=="number"?ln(e,t,n):typeof t=="string"&&t in f?ln(e,f[t],n):t&&t instanceof D?ln(e,Ro(t),n):t!=null&&t.type&&t.type instanceof D?ln(e,Ro(t.type),n):ln(e,f.NONE,n)}function ln(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 Ro(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 Tt.HALF:return f.Float16;case Tt.SINGLE:return f.Float32;case Tt.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 k.SECOND:return f.TimeSecond;case k.MILLISECOND:return f.TimeMillisecond;case k.MICROSECOND:return f.TimeMicrosecond;case k.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(e.unit){case k.SECOND:return f.TimestampSecond;case k.MILLISECOND:return f.TimestampMillisecond;case k.MICROSECOND:return f.TimestampMicrosecond;case k.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(e.unit){case Vt.DAY:return f.DateDay;case Vt.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(e.unit){case se.DAY_TIME:return f.IntervalDayTime;case se.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(e.unit){case k.SECOND:return f.DurationSecond;case k.MILLISECOND:return f.DurationMillisecond;case k.MICROSECOND:return f.DurationMicrosecond;case k.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 Et.Dense:return f.DenseUnion;case Et.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]}'`)}q.prototype.visitInt8=null,q.prototype.visitInt16=null,q.prototype.visitInt32=null,q.prototype.visitInt64=null,q.prototype.visitUint8=null,q.prototype.visitUint16=null,q.prototype.visitUint32=null,q.prototype.visitUint64=null,q.prototype.visitFloat16=null,q.prototype.visitFloat32=null,q.prototype.visitFloat64=null,q.prototype.visitDateDay=null,q.prototype.visitDateMillisecond=null,q.prototype.visitTimestampSecond=null,q.prototype.visitTimestampMillisecond=null,q.prototype.visitTimestampMicrosecond=null,q.prototype.visitTimestampNanosecond=null,q.prototype.visitTimeSecond=null,q.prototype.visitTimeMillisecond=null,q.prototype.visitTimeMicrosecond=null,q.prototype.visitTimeNanosecond=null,q.prototype.visitDenseUnion=null,q.prototype.visitSparseUnion=null,q.prototype.visitIntervalDayTime=null,q.prototype.visitIntervalYearMonth=null,q.prototype.visitDuration=null,q.prototype.visitDurationSecond=null,q.prototype.visitDurationMillisecond=null,q.prototype.visitDurationMicrosecond=null,q.prototype.visitDurationNanosecond=null;const Oo=new Float64Array(1),cn=new Uint32Array(Oo.buffer);function Do(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 Lp(e){if(e!==e)return 32256;Oo[0]=e;const t=(cn[1]&2147483648)>>16&65535;let n=cn[1]&2146435072,r=0;return n>=1089470464?cn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(cn[1]&1048575)>>10):n<=1056964608?(r=1048576+(cn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(cn[1]&1048575)+512>>10),t|n|r&65535}class $ extends q{}function z(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const xp=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Fo=(e,t,n,r)=>{if(n+1<t.length){const i=ot(t[n]),s=ot(t[n+1]);e.set(r.subarray(0,s-i),i)}},Up=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Se=({values:e},t,n)=>{e[t]=n},Xi=({values:e},t,n)=>{e[t]=n},Mo=({values:e},t,n)=>{e[t]=Lp(n)},Cp=(e,t,n)=>{switch(e.type.precision){case Tt.HALF:return Mo(e,t,n);case Tt.SINGLE:case Tt.DOUBLE:return Xi(e,t,n)}},Lo=({values:e},t,n)=>{xp(e,t,n.valueOf())},xo=({values:e},t,n)=>{e[t]=BigInt(n)},kp=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Uo=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,r),Co=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,Vi(r)),$p=(e,t,n)=>{e.type.unit===Vt.DAY?Lo(e,t,n):xo(e,t,n)},ko=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},$o=({values:e},t,n)=>{e[t]=BigInt(n)},Po=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Vo=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Pp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return ko(e,t,n);case k.MILLISECOND:return $o(e,t,n);case k.MICROSECOND:return Po(e,t,n);case k.NANOSECOND:return Vo(e,t,n)}},zo=({values:e},t,n)=>{e[t]=n},jo=({values:e},t,n)=>{e[t]=n},Yo=({values:e},t,n)=>{e[t]=n},Wo=({values:e},t,n)=>{e[t]=n},Vp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return zo(e,t,n);case k.MILLISECOND:return jo(e,t,n);case k.MICROSECOND:return Yo(e,t,n);case k.NANOSECOND:return Wo(e,t,n)}},zp=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},jp=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Wt.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))},Yp=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Wt.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const c of l)if(s(r,a,c),++a>=o)break},Wp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),qp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),Gp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),Hp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),Kp=(e,t,n)=>{const r=e.type.children.map(s=>Wt.getVisitFn(s.type)),i=n instanceof Map?Gp(t,n):n instanceof tt?qp(t,n):Array.isArray(n)?Wp(t,n):Hp(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},Qp=(e,t,n)=>{e.type.mode===Et.Dense?qo(e,t,n):Go(e,t,n)},qo=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,e.valueOffsets[t],n)},Go=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,t,n)},Xp=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Jp=(e,t,n)=>{e.type.unit===se.DAY_TIME?Ho(e,t,n):Ko(e,t,n)},Ho=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ko=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Qo=({values:e},t,n)=>{e[t]=n},Xo=({values:e},t,n)=>{e[t]=n},Jo=({values:e},t,n)=>{e[t]=n},Zo=({values:e},t,n)=>{e[t]=n},Zp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return Qo(e,t,n);case k.MILLISECOND:return Xo(e,t,n);case k.MICROSECOND:return Jo(e,t,n);case k.NANOSECOND:return Zo(e,t,n)}},ty=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Wt.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))};$.prototype.visitBool=z(Up),$.prototype.visitInt=z(Se),$.prototype.visitInt8=z(Se),$.prototype.visitInt16=z(Se),$.prototype.visitInt32=z(Se),$.prototype.visitInt64=z(Se),$.prototype.visitUint8=z(Se),$.prototype.visitUint16=z(Se),$.prototype.visitUint32=z(Se),$.prototype.visitUint64=z(Se),$.prototype.visitFloat=z(Cp),$.prototype.visitFloat16=z(Mo),$.prototype.visitFloat32=z(Xi),$.prototype.visitFloat64=z(Xi),$.prototype.visitUtf8=z(Co),$.prototype.visitLargeUtf8=z(Co),$.prototype.visitBinary=z(Uo),$.prototype.visitLargeBinary=z(Uo),$.prototype.visitFixedSizeBinary=z(kp),$.prototype.visitDate=z($p),$.prototype.visitDateDay=z(Lo),$.prototype.visitDateMillisecond=z(xo),$.prototype.visitTimestamp=z(Pp),$.prototype.visitTimestampSecond=z(ko),$.prototype.visitTimestampMillisecond=z($o),$.prototype.visitTimestampMicrosecond=z(Po),$.prototype.visitTimestampNanosecond=z(Vo),$.prototype.visitTime=z(Vp),$.prototype.visitTimeSecond=z(zo),$.prototype.visitTimeMillisecond=z(jo),$.prototype.visitTimeMicrosecond=z(Yo),$.prototype.visitTimeNanosecond=z(Wo),$.prototype.visitDecimal=z(zp),$.prototype.visitList=z(jp),$.prototype.visitStruct=z(Kp),$.prototype.visitUnion=z(Qp),$.prototype.visitDenseUnion=z(qo),$.prototype.visitSparseUnion=z(Go),$.prototype.visitDictionary=z(Xp),$.prototype.visitInterval=z(Jp),$.prototype.visitIntervalDayTime=z(Ho),$.prototype.visitIntervalYearMonth=z(Ko),$.prototype.visitDuration=z(Zp),$.prototype.visitDurationSecond=z(Qo),$.prototype.visitDurationMillisecond=z(Xo),$.prototype.visitDurationMicrosecond=z(Jo),$.prototype.visitDurationNanosecond=z(Zo),$.prototype.visitFixedSizeList=z(ty),$.prototype.visitMap=z(Yp);const Wt=new $,Xt=Symbol.for("parent"),un=Symbol.for("rowIndex");class Ji{constructor(t,n){return this[Xt]=t,this[un]=n,new Proxy(this,new ny)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[un],n=this[Xt],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=Mt.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ey(this[Xt],this[un])}}class ey{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,Mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Ji.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Xt]:{writable:!0,enumerable:!1,configurable:!1,value:null},[un]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class ny{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Xt].type.children.map(n=>n.name)}has(t,n){return t[Xt].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[Xt].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[Xt].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Mt.visit(t[Xt].children[r],t[un]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[Xt].type.children.findIndex(s=>s.name===n);return i!==-1?(Wt.visit(t[Xt].children[i],t[un],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class L extends q{}function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const ry=(e,t)=>864e5*e[t],iy=(e,t)=>null,tl=(e,t,n)=>{if(n+1>=t.length)return null;const r=ot(t[n]),i=ot(t[n+1]);return e.subarray(r,i)},sy=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},el=({values:e},t)=>ry(e,t),nl=({values:e},t)=>ot(e[t]),De=({stride:e,values:t},n)=>t[e*n],ay=({stride:e,values:t},n)=>Do(t[e*n]),rl=({values:e},t)=>e[t],oy=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),il=({values:e,valueOffsets:t},n)=>tl(e,t,n),sl=({values:e,valueOffsets:t},n)=>{const r=tl(e,t,n);return r!==null?Pi(r):null},ly=({values:e},t)=>e[t],cy=({type:e,values:t},n)=>e.precision!==Tt.HALF?t[n]:Do(t[n]),uy=(e,t)=>e.type.unit===Vt.DAY?el(e,t):nl(e,t),al=({values:e},t)=>1e3*ot(e[t]),ol=({values:e},t)=>ot(e[t]),ll=({values:e},t)=>io(e[t],BigInt(1e3)),cl=({values:e},t)=>io(e[t],BigInt(1e6)),hy=(e,t)=>{switch(e.type.unit){case k.SECOND:return al(e,t);case k.MILLISECOND:return ol(e,t);case k.MICROSECOND:return ll(e,t);case k.NANOSECOND:return cl(e,t)}},ul=({values:e},t)=>e[t],hl=({values:e},t)=>e[t],dl=({values:e},t)=>e[t],fl=({values:e},t)=>e[t],dy=(e,t)=>{switch(e.type.unit){case k.SECOND:return ul(e,t);case k.MILLISECOND:return hl(e,t);case k.MICROSECOND:return dl(e,t);case k.NANOSECOND:return fl(e,t)}},fy=({values:e,stride:t},n)=>Qi.decimal(e.subarray(t*n,t*(n+1))),py=(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 tt([o])},yy=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new ts(a.slice(i,s-i))},my=(e,t)=>new Ji(e,t),by=(e,t)=>e.type.mode===Et.Dense?pl(e,t):yl(e,t),pl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,e.valueOffsets[t])},yl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,t)},gy=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},_y=(e,t)=>e.type.unit===se.DAY_TIME?ml(e,t):bl(e,t),ml=({values:e},t)=>e.subarray(2*t,2*(t+1)),bl=({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},gl=({values:e},t)=>e[t],_l=({values:e},t)=>e[t],vl=({values:e},t)=>e[t],wl=({values:e},t)=>e[t],vy=(e,t)=>{switch(e.type.unit){case k.SECOND:return gl(e,t);case k.MILLISECOND:return _l(e,t);case k.MICROSECOND:return vl(e,t);case k.NANOSECOND:return wl(e,t)}},wy=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new tt([i])};L.prototype.visitNull=P(iy),L.prototype.visitBool=P(sy),L.prototype.visitInt=P(ly),L.prototype.visitInt8=P(De),L.prototype.visitInt16=P(De),L.prototype.visitInt32=P(De),L.prototype.visitInt64=P(rl),L.prototype.visitUint8=P(De),L.prototype.visitUint16=P(De),L.prototype.visitUint32=P(De),L.prototype.visitUint64=P(rl),L.prototype.visitFloat=P(cy),L.prototype.visitFloat16=P(ay),L.prototype.visitFloat32=P(De),L.prototype.visitFloat64=P(De),L.prototype.visitUtf8=P(sl),L.prototype.visitLargeUtf8=P(sl),L.prototype.visitBinary=P(il),L.prototype.visitLargeBinary=P(il),L.prototype.visitFixedSizeBinary=P(oy),L.prototype.visitDate=P(uy),L.prototype.visitDateDay=P(el),L.prototype.visitDateMillisecond=P(nl),L.prototype.visitTimestamp=P(hy),L.prototype.visitTimestampSecond=P(al),L.prototype.visitTimestampMillisecond=P(ol),L.prototype.visitTimestampMicrosecond=P(ll),L.prototype.visitTimestampNanosecond=P(cl),L.prototype.visitTime=P(dy),L.prototype.visitTimeSecond=P(ul),L.prototype.visitTimeMillisecond=P(hl),L.prototype.visitTimeMicrosecond=P(dl),L.prototype.visitTimeNanosecond=P(fl),L.prototype.visitDecimal=P(fy),L.prototype.visitList=P(py),L.prototype.visitStruct=P(my),L.prototype.visitUnion=P(by),L.prototype.visitDenseUnion=P(pl),L.prototype.visitSparseUnion=P(yl),L.prototype.visitDictionary=P(gy),L.prototype.visitInterval=P(_y),L.prototype.visitIntervalDayTime=P(ml),L.prototype.visitIntervalYearMonth=P(bl),L.prototype.visitDuration=P(vy),L.prototype.visitDurationSecond=P(gl),L.prototype.visitDurationMillisecond=P(_l),L.prototype.visitDurationMicrosecond=P(vl),L.prototype.visitDurationNanosecond=P(wl),L.prototype.visitFixedSizeList=P(wy),L.prototype.visitMap=P(yy);const Mt=new L,hn=Symbol.for("keys"),dn=Symbol.for("vals"),fn=Symbol.for("kKeysAsStrings"),Zi=Symbol.for("_kKeysAsStrings");class ts{constructor(t){return this[hn]=new tt([t.children[0]]).memoize(),this[dn]=t.children[1],new Proxy(this,new Sy)}get[fn](){return this[Zi]||(this[Zi]=Array.from(this[hn].toArray(),String))}[Symbol.iterator](){return new Iy(this[hn],this[dn])}get size(){return this[hn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[hn],n=this[dn],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Mt.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Iy{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),Mt.visit(this.vals,t)]})}}class Sy{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[fn]}has(t,n){return t[fn].includes(n)}getOwnPropertyDescriptor(t,n){if(t[fn].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[fn].indexOf(n);if(r!==-1){const i=Mt.visit(Reflect.get(t,dn),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[fn].indexOf(n);return i!==-1?(Wt.visit(Reflect.get(t,dn),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(ts.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[hn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[dn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Zi]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Il;function Sl(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&&(Il=s,s=a,a=Il),a>i&&(a=i),r?r(e,s,a):[s,a]}const es=(e,t)=>e<0?t+e:e,El=e=>e!==e;function pn(e){if(typeof e!="object"||e===null)return El(e)?El: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?wp(e,t):!1:e instanceof Map?Ty(e):Array.isArray(e)?Ey(e):e instanceof tt?Ay(e):Ny(e,!0)}function Ey(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e[n]);return Jr(t)}function Ty(e){let t=-1;const n=[];for(const r of e.values())n[++t]=pn(r);return Jr(n)}function Ay(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e.get(n));return Jr(t)}function Ny(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]=pn(e[n[i]]);return Jr(r,n)}function Jr(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return By(e,n);case Map:return Tl(e,n,n.keys());case ts:case Ji:case Object:case void 0:return Tl(e,n,t||Object.keys(n))}return n instanceof tt?Ry(e,n):!1}}function By(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 Ry(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 Tl(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(),c=r.next(),d=i.next();for(;a<o&&!c.done&&!d.done&&!l.done&&!(c.value!==d.value||!e[a](l.value));++a,c=r.next(),d=i.next(),l=s.next());return a===o&&c.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function Al(e,t,n,r){return(n&1<<r)!==0}function Oy(e,t,n,r){return(n&1<<r)>>r}function Zr(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):ti(new ns(n,e,t,null,Al)).subarray(0,r)),i}return n}function ti(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 ns{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 rs(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new ns(e,t,n-t,e,Oy))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return rs(e,t,i)+rs(e,r,n)+Dy(e,i>>3,r-i>>3)}function Dy(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+=is(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=is(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=is(s.getUint8(i)),i+=1;return r}function is(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 Fy=-1;class nt{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 D.isSparseUnion(t)?this.children.some(n=>n.nullable):D.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(D.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=Fy&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-rs(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 nt?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ie(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(D.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Et.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(D.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Et.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,c=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(Zr(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const y=s[d];r=(y&c)!==0,s[d]=n?y|c:y&~c}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 nt(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(Zr(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[we.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[we.TYPE])&&(a[we.TYPE]=s.subarray(t,t+n)),(s=a[we.OFFSET])&&(a[we.OFFSET]=s.subarray(t,t+n+1))||(s=a[we.DATA])&&(a[we.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}nt.prototype.children=Object.freeze([]);class Pn extends q{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new nt(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=H(t.nullBitmap),{length:a=i.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=at(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(D.isSparseUnion(n))return new nt(n,r,a,o,[void 0,void 0,void 0,s],i);const l=xn(t.valueOffsets);return new nt(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.indices.ArrayType,t.data),{["dictionary"]:a=new tt([new Pn().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.valueType})}=t,s=H(t.nullBitmap),{["length"]:a=i.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.childType})}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}}const My=new Pn;function G(e){return My.visit(e)}class Nl{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 Ly(e){return e.some(t=>t.nullable)}function Bl(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Rl(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function Ol(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:c}=o;if(l>=r)break;if(n>=l+c)continue;if(l>=n&&l+c<=r){i.push(o);continue}const d=Math.max(0,n-l),y=Math.min(r-l,c);i.push(o.slice(d,y-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function ss(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 as(e,t){return e.getValid(t)}function ei(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return ss(r,this._offsets,n,t)}}function Dl(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=ss(s,this._offsets,r,n);return t=void 0,a}}function Fl(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let c=i-1,d=r.length;++c<d;){const y=r[c];if(~(o=e(y,t,a)))return l+o;a=0,l+=y.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):ss(s,this._offsets,i,n);return t=void 0,a}}class x extends q{}function xy(e,t){return t===null&&e.length>0?0:-1}function Uy(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new ns(n,e.offset+(t||0),e.length,n,Al)){if(!i)return r;++r}return-1}function j(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 Uy(e,n)}const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function Ml(e,t,n){const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}x.prototype.visitNull=xy,x.prototype.visitBool=j,x.prototype.visitInt=j,x.prototype.visitInt8=j,x.prototype.visitInt16=j,x.prototype.visitInt32=j,x.prototype.visitInt64=j,x.prototype.visitUint8=j,x.prototype.visitUint16=j,x.prototype.visitUint32=j,x.prototype.visitUint64=j,x.prototype.visitFloat=j,x.prototype.visitFloat16=j,x.prototype.visitFloat32=j,x.prototype.visitFloat64=j,x.prototype.visitUtf8=j,x.prototype.visitLargeUtf8=j,x.prototype.visitBinary=j,x.prototype.visitLargeBinary=j,x.prototype.visitFixedSizeBinary=j,x.prototype.visitDate=j,x.prototype.visitDateDay=j,x.prototype.visitDateMillisecond=j,x.prototype.visitTimestamp=j,x.prototype.visitTimestampSecond=j,x.prototype.visitTimestampMillisecond=j,x.prototype.visitTimestampMicrosecond=j,x.prototype.visitTimestampNanosecond=j,x.prototype.visitTime=j,x.prototype.visitTimeSecond=j,x.prototype.visitTimeMillisecond=j,x.prototype.visitTimeMicrosecond=j,x.prototype.visitTimeNanosecond=j,x.prototype.visitDecimal=j,x.prototype.visitList=j,x.prototype.visitStruct=j,x.prototype.visitUnion=j,x.prototype.visitDenseUnion=Ml,x.prototype.visitSparseUnion=Ml,x.prototype.visitDictionary=j,x.prototype.visitInterval=j,x.prototype.visitIntervalDayTime=j,x.prototype.visitIntervalYearMonth=j,x.prototype.visitDuration=j,x.prototype.visitDurationSecond=j,x.prototype.visitDurationMillisecond=j,x.prototype.visitDurationMicrosecond=j,x.prototype.visitDurationNanosecond=j,x.prototype.visitFixedSizeList=j,x.prototype.visitMap=j;const ni=new x;class U extends q{}function V(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(D.isInt(t)&&t.bitWidth!==64||D.isTime(t)&&t.bitWidth!==64||D.isFloat(t)&&t.precision!==Tt.HALF))return new Nl(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Nl(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new Cy(s)})}class Cy{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}}U.prototype.visitNull=V,U.prototype.visitBool=V,U.prototype.visitInt=V,U.prototype.visitInt8=V,U.prototype.visitInt16=V,U.prototype.visitInt32=V,U.prototype.visitInt64=V,U.prototype.visitUint8=V,U.prototype.visitUint16=V,U.prototype.visitUint32=V,U.prototype.visitUint64=V,U.prototype.visitFloat=V,U.prototype.visitFloat16=V,U.prototype.visitFloat32=V,U.prototype.visitFloat64=V,U.prototype.visitUtf8=V,U.prototype.visitLargeUtf8=V,U.prototype.visitBinary=V,U.prototype.visitLargeBinary=V,U.prototype.visitFixedSizeBinary=V,U.prototype.visitDate=V,U.prototype.visitDateDay=V,U.prototype.visitDateMillisecond=V,U.prototype.visitTimestamp=V,U.prototype.visitTimestampSecond=V,U.prototype.visitTimestampMillisecond=V,U.prototype.visitTimestampMicrosecond=V,U.prototype.visitTimestampNanosecond=V,U.prototype.visitTime=V,U.prototype.visitTimeSecond=V,U.prototype.visitTimeMillisecond=V,U.prototype.visitTimeMicrosecond=V,U.prototype.visitTimeNanosecond=V,U.prototype.visitDecimal=V,U.prototype.visitList=V,U.prototype.visitStruct=V,U.prototype.visitUnion=V,U.prototype.visitDenseUnion=V,U.prototype.visitSparseUnion=V,U.prototype.visitDictionary=V,U.prototype.visitInterval=V,U.prototype.visitIntervalDayTime=V,U.prototype.visitIntervalYearMonth=V,U.prototype.visitDuration=V,U.prototype.visitDurationSecond=V,U.prototype.visitDurationMillisecond=V,U.prototype.visitDurationMicrosecond=V,U.prototype.visitDurationNanosecond=V,U.prototype.visitFixedSizeList=V,U.prototype.visitMap=V;const os=new U;var Ll;const xl={},Ul={};class tt{constructor(t){var n,r,i;const s=t[0]instanceof tt?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof nt)))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:c}=xl[a.typeId],d=s[0];this.isValid=y=>as(d,y),this.get=y=>o(d,y),this.set=(y,_)=>l(d,y,_),this.indexOf=y=>c(d,y),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,Ul[a.typeId]),this._offsets=Rl(s);break}this.data=s,this.type=a,this.stride=Ie(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 Ly(this.data)}get nullCount(){return Bl(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(es(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return os.visit(this)}concat(...t){return new tt(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new tt(Sl(this,t,n,({data:r,_offsets:i},s,a)=>Ol(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 tt(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return D.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(D.isDictionary(this.type)){const t=new ri(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new tt(n)}return new ri(this)}unmemoize(){if(D.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 tt(n)}return this}}Ll=Symbol.toStringTag,tt[Ll]=(e=>{e.type=D.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=Mt.getVisitFnByTypeId(n),i=Wt.getVisitFnByTypeId(n),s=ni.getVisitFnByTypeId(n);xl[n]={get:r,set:i,indexOf:s},Ul[n]=Object.create(e,{isValid:{value:ei(as)},get:{value:ei(Mt.getVisitFnByTypeId(n))},set:{value:Dl(Wt.getVisitFnByTypeId(n))},indexOf:{value:Fl(ni.getVisitFnByTypeId(n))}})}return"Vector"})(tt.prototype);class ri extends tt{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 ri(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new tt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class ls{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 Ct{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 Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Z),(n||new Ct).__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):yt.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new ce).__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 ls).__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 ls).__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 vt).__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,yt.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 et{constructor(t=[],n,r,i=yt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=cs(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 et(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new et(n,this.metadata)}assign(...t){const n=t[0]instanceof et?t[0]:Array.isArray(t[0])?new et(t[0]):new et(t),r=[...this.fields],i=ii(ii(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(c=>c.name===o.name);return~l?(r[l]=o.clone({metadata:ii(ii(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=cs(s,new Map);return new et([...r,...s],i,new Map([...this.dictionaries,...a]))}}et.prototype.fields=null,et.prototype.metadata=null,et.prototype.dictionaries=null;class ut{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 ut(`${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],ut.new(n,r,i,s)}}ut.prototype.type=null,ut.prototype.name=null,ut.prototype.nullable=null,ut.prototype.metadata=null;function ii(e,t){return new Map([...e||new Map,...t||new Map])}function cs(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(D.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&&cs(i.children,t)}return t}var ky=Ha,$y=tn;class Vn{static decode(t){t=new $y(H(t));const n=Ct.getRootAsFooter(t),r=et.decode(n.schema(),new Map,n.version());return new Py(r,n)}static encode(t){const n=new ky,r=et.encode(n,t.schema);Ct.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Fe.encode(n,a);const i=n.endVector();Ct.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Fe.encode(n,a);const s=n.endVector();return Ct.startFooter(n),Ct.addSchema(n,r),Ct.addVersion(n,yt.V5),Ct.addRecordBatches(n,i),Ct.addDictionaries(n,s),Ct.finishFooterBuffer(n,Ct.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=yt.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 Py extends Vn{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 Fe.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Fe.decode(n)}return null}}class Fe{static decode(t){return new Fe(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return ls.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=ot(r),this.bodyLength=ot(n)}}const wt=Object.freeze({done:!0,value:void 0});class Cl{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class us{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 Vy extends us{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Y(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(wt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Pt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Pt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Y(this,void 0,void 0,function*(){return yield this.abort(t),wt})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),wt})}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(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(wt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class si extends Vy{write(t){if((t=H(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Pi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Pi)}toUint8Array(t=!1){return t?ie(this._values)[0]:Y(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,c=je(this),d;d=yield c.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const y=s;a.push(y),o+=y.byteLength}}catch(y){r={error:y}}finally{try{!l&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}return ie(a,o)[0]})}}class ai{constructor(t){t&&(this.source=new zy(Pt.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 yn{constructor(t){t instanceof yn?this.source=t.source:t instanceof si?this.source=new Ge(Pt.fromAsyncIterable(t)):Va(t)?this.source=new Ge(Pt.fromNodeStream(t)):ji(t)?this.source=new Ge(Pt.fromDOMStream(t)):Pa(t)?this.source=new Ge(Pt.fromDOMStream(t.body)):Ln(t)?this.source=new Ge(Pt.fromIterable(t)):Ye(t)?this.source=new Ge(Pt.fromAsyncIterable(t)):Ze(t)&&(this.source=new Ge(Pt.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 zy{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)||wt)}return(t){return Object.create(this.source.return&&this.source.return(t)||wt)}}class Ge{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Y(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Y(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Y(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class kl extends ai{constructor(t,n){super(),this.position=0,this.buffer=H(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 oi extends yn{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Y(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 Y(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 Y(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)),c=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<c.byteLength;)({bytesRead:o}=yield n.read(c,a,c.byteLength-a,s));return c}return null})}readAt(t,n){return Y(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 Y(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const jy=65536;function mn(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const bn=8,hs=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class $l{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?jy: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`${mn(this.buffer[1])} ${mn(this.buffer[0])}`}}class rt extends $l{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return rt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return rt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new rt(n);for(let s=0;s<r;){const a=bn<r-s?bn:r-s,o=new rt(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new rt(new Uint32Array([hs[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;)rt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new rt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new rt(new Uint32Array(t.buffer)).plus(n)}}class qt extends $l{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 qt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return qt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new qt(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new qt(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),c=new qt(new Uint32Array([hs[o],0]));s.times(c),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;)qt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new qt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new qt(new Uint32Array(t.buffer)).plus(n)}}class ue{constructor(t){this.buffer=t}high(){return new qt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new qt(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 rt(new Uint32Array([this.buffer[3],0])),r=new rt(new Uint32Array([this.buffer[2],0])),i=new rt(new Uint32Array([this.buffer[1],0])),s=new rt(new Uint32Array([this.buffer[0],0])),a=new rt(new Uint32Array([t.buffer[3],0])),o=new rt(new Uint32Array([t.buffer[2],0])),l=new rt(new Uint32Array([t.buffer[1],0])),c=new rt(new Uint32Array([t.buffer[0],0]));let d=rt.multiply(s,c);this.buffer[0]=d.low();const y=new rt(new Uint32Array([d.high(),0]));return d=rt.multiply(i,c),y.plus(d),d=rt.multiply(s,l),y.plus(d),this.buffer[1]=y.low(),this.buffer[3]=y.lessThan(d)?1:0,this.buffer[2]=y.high(),new rt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(rt.multiply(r,c)).plus(rt.multiply(i,l)).plus(rt.multiply(s,o)),this.buffer[3]+=rt.multiply(n,c).plus(rt.multiply(r,l)).plus(rt.multiply(i,o)).plus(rt.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`${mn(this.buffer[3])} ${mn(this.buffer[2])} ${mn(this.buffer[1])} ${mn(this.buffer[0])}`}static multiply(t,n){return new ue(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new ue(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return ue.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return ue.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new ue(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new ue(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),c=new ue(new Uint32Array([hs[o],0,0,0]));s.times(c),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;)ue.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class Pl extends q{constructor(t,n,r,i,s=yt.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 ut?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return G({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({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 G({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 G({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 G({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 G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({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 G({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<yt.V5&&this.readNullBitmap(t,r),t.mode===Et.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({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 G({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({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 G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({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 G({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 Yy extends Pl{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):ti(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return D.isTimestamp(t)||(D.isInt(t)||D.isTime(t))&&t.bitWidth===64||D.isDuration(t)||D.isDate(t)&&t.unit===Vt.MILLISECOND?at(Uint8Array,qt.convertArray(r[n])):D.isDecimal(t)?at(Uint8Array,ue.convertArray(r[n])):D.isBinary(t)||D.isLargeBinary(t)||D.isFixedSizeBinary(t)?Wy(r[n]):D.isBool(t)?ti(r[n]):D.isUtf8(t)||D.isLargeUtf8(t)?Vi(r[n].join("")):at(Uint8Array,at(t.ArrayType,r[n].map(i=>+i)))}}function Wy(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 C extends q{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 Nt(e,t){return t instanceof e.constructor}function He(e,t){return e===t||Nt(e,t)}function Ee(e,t){return e===t||Nt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function li(e,t){return e===t||Nt(e,t)&&e.precision===t.precision}function qy(e,t){return e===t||Nt(e,t)&&e.byteWidth===t.byteWidth}function ds(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function zn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function jn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Gy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Hy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function fs(e,t){return e===t||Nt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&Me.compareManyFields(e.children,t.children)}function Ky(e,t){return e===t||Nt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Me.visit(e.indices,t.indices)&&Me.visit(e.dictionary,t.dictionary)}function ps(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Yn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Qy(e,t){return e===t||Nt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Xy(e,t){return e===t||Nt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}C.prototype.visitNull=He,C.prototype.visitBool=He,C.prototype.visitInt=Ee,C.prototype.visitInt8=Ee,C.prototype.visitInt16=Ee,C.prototype.visitInt32=Ee,C.prototype.visitInt64=Ee,C.prototype.visitUint8=Ee,C.prototype.visitUint16=Ee,C.prototype.visitUint32=Ee,C.prototype.visitUint64=Ee,C.prototype.visitFloat=li,C.prototype.visitFloat16=li,C.prototype.visitFloat32=li,C.prototype.visitFloat64=li,C.prototype.visitUtf8=He,C.prototype.visitLargeUtf8=He,C.prototype.visitBinary=He,C.prototype.visitLargeBinary=He,C.prototype.visitFixedSizeBinary=qy,C.prototype.visitDate=ds,C.prototype.visitDateDay=ds,C.prototype.visitDateMillisecond=ds,C.prototype.visitTimestamp=zn,C.prototype.visitTimestampSecond=zn,C.prototype.visitTimestampMillisecond=zn,C.prototype.visitTimestampMicrosecond=zn,C.prototype.visitTimestampNanosecond=zn,C.prototype.visitTime=jn,C.prototype.visitTimeSecond=jn,C.prototype.visitTimeMillisecond=jn,C.prototype.visitTimeMicrosecond=jn,C.prototype.visitTimeNanosecond=jn,C.prototype.visitDecimal=He,C.prototype.visitList=Gy,C.prototype.visitStruct=Hy,C.prototype.visitUnion=fs,C.prototype.visitDenseUnion=fs,C.prototype.visitSparseUnion=fs,C.prototype.visitDictionary=Ky,C.prototype.visitInterval=ps,C.prototype.visitIntervalDayTime=ps,C.prototype.visitIntervalYearMonth=ps,C.prototype.visitDuration=Yn,C.prototype.visitDurationSecond=Yn,C.prototype.visitDurationMillisecond=Yn,C.prototype.visitDurationMicrosecond=Yn,C.prototype.visitDurationNanosecond=Yn,C.prototype.visitFixedSizeList=Qy,C.prototype.visitMap=Xy;const Me=new C;function ys(e,t){return Me.compareSchemas(e,t)}function ms(e,t){return Jy(e,t.map(n=>n.data.concat()))}function Jy(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((y,_)=>Math.max(y,_.length),0)};let s=0,a=0,o=-1;const l=t.length;let c,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=c=t[o].shift(),a=Math.min(a,c?c.length:a);Number.isFinite(a)&&(d=Zy(n,a,d,t,i),a>0&&(r[s++]=G({type:new At(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(y=>new Lt(e,y))]}function Zy(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const c=n[o],d=c==null?void 0:c.length;if(d>=t)d===t?n[o]=c:(n[o]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(c.slice(t,d-t))));else{const y=e[o];e[o]=y.clone({nullable:!0}),n[o]=(s=c==null?void 0:c._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:G({type:y.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var Vl;class Bt{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new et([]),this._offsets=[0],this;let i,s;t[0]instanceof et&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof Lt)return[l];if(l instanceof Bt)return l.batches;if(l instanceof nt){if(l.type instanceof At)return[new Lt(new et(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>a(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>a(c));if(typeof l=="object"){const c=Object.keys(l),d=c.map(v=>new tt([l[v]])),y=i??new et(c.map((v,E)=>new ut(String(v),d[E].type,d[E].nullable))),[,_]=ms(y,d);return _.length===0?[new Lt(l)]:_}}}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 et([]),!(i instanceof et))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof Lt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!ys(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Rl(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=Bl(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(es(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?os.visit(new tt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
47
40
  ${this.toArray().join(`,
48
41
  `)}
49
- ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Lt(n,r.map(i=>new $t(n,i)))}slice(t,n){const r=this.schema;[t,n]=ic({length:this.numRows},t,n);const i=hc(this.data,this._offsets,t,n);return new Lt(r,i.map(s=>new $t(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=Q({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new it(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 it([Q({type:new Ue,length:this.numRows})]));const s=r.fields.slice(),o=s[t].clone({type:n.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,n],[r,i]=Ds(r,a)}return new Lt(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 Lt(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((a,c,l)=>{const[u,d]=a,y=n.findIndex(m=>m.name===c.name);return~y?d[y]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...n.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...r.map(a=>t.getChildAt(a))].filter(Boolean);return new Lt(...Ds(s,o))}}Ic=Symbol.toStringTag,Lt[Ic]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=di(ws),e.get=di(Ct.getVisitFn(p.Struct)),e.set=dc(Ht.getVisitFn(p.Struct)),e.indexOf=fc(fi.getVisitFn(p.Struct)),"Table"))(Lt.prototype);var Sc;let $t=class ur{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof st))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Q({nullCount:0,type:new Ot(this.schema.fields),children:this.schema.fields.map(n=>Q({type:n.type,nullCount:0}))})]=t,!(this.data instanceof ot))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ec(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((c,l,u)=>(c.children[u]=n[l],c.length=Math.max(c.length,n[l].length),c.fields[u]=yt.new({name:l,type:n[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new st(r),a=Q({type:new Ot(r),length:s,children:i,nullCount:0});[this.schema,this.data]=Ec(o,a.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=Tc(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 Ct.visit(this.data,t)}at(t){return this.get(ms(t,this.numRows))}set(t,n){return Ht.visit(this.data,t,n)}indexOf(t,n){return fi.visit(this.data,t,n)}[Symbol.iterator](){return Is.visit(new it([this.data]))}toArray(){return[...this]}concat(...t){return new Lt(this.schema,[this,...t])}slice(t,n){const[r]=new it([this.data]).slice(t,n).data;return new ur(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 it([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 it([Q({type:new Ue,length:this.numRows})]));const s=r.fields.slice(),o=i.children.slice(),a=s[t].clone({type:n.type});[s[t],o[t]]=[a,n.data[0]],r=new st(s,new Map(this.schema.metadata)),i=Q({type:new Ot(s),children:o})}return new ur(r,i)}select(t){const n=this.schema.select(t),r=new Ot(n.fields),i=[];for(const s of t){const o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new ur(n,Q({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=Q({type:new Ot(n.fields),length:this.numRows,children:r});return new ur(n,i)}};Sc=Symbol.toStringTag,$t[Sc]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))($t.prototype);function Ec(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],o=(n+63&-64)>>3;for(const[a,c]of e.fields.entries()){const l=t[a];(!l||l.length!==n)&&(i[a]=c.clone({nullable:!0}),s[a]=(r=l?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Q({type:c.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),Q({type:new Ot(i),length:n,children:s})]}function Tc(e,t,n=new Map){var r,i;if(((r=e?.length)!==null&&r!==void 0?r:0)>0&&e?.length===t?.length)for(let s=-1,o=e.length;++s<o;){const{type:a}=e[s],c=t[s];for(const l of[c,...((i=c?.dictionary)===null||i===void 0?void 0:i.data)||[]])Tc(a.children,l?.children,n);if(O.isDictionary(a)){const{id:l}=a;if(!n.has(l))c?.dictionary&&n.set(l,c.dictionary);else if(n.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class Ls extends $t{constructor(t){const n=t.fields.map(i=>Q({type:i.type})),r=Q({type:new Ot(t.fields),nullCount:0,children:n});super(t,r)}}let ke=class ye{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 ye).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+rt),(n||new ye).__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):vt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):et.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 Et).__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,vt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,et.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,o){return ye.startMessage(t),ye.addVersion(t,n),ye.addHeaderType(t,r),ye.addHeader(t,i),ye.addBodyLength(t,s),ye.addCustomMetadata(t,o),ye.endMessage(t)}};class Tg extends H{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return $a.startNull(n),$a.endNull(n)}visitInt(t,n){return Pt.startInt(n),Pt.addBitWidth(n,t.bitWidth),Pt.addIsSigned(n,t.isSigned),Pt.endInt(n)}visitFloat(t,n){return ce.startFloatingPoint(n),ce.addPrecision(n,t.precision),ce.endFloatingPoint(n)}visitBinary(t,n){return Fa.startBinary(n),Fa.endBinary(n)}visitLargeBinary(t,n){return Ua.startLargeBinary(n),Ua.endLargeBinary(n)}visitBool(t,n){return Ma.startBool(n),Ma.endBool(n)}visitUtf8(t,n){return ka.startUtf8(n),ka.endUtf8(n)}visitLargeUtf8(t,n){return xa.startLargeUtf8(n),xa.endLargeUtf8(n)}visitDecimal(t,n){return un.startDecimal(n),un.addScale(n,t.scale),un.addPrecision(n,t.precision),un.addBitWidth(n,t.bitWidth),un.endDecimal(n)}visitDate(t,n){return Vr.startDate(n),Vr.addUnit(n,t.unit),Vr.endDate(n)}visitTime(t,n){return qt.startTime(n),qt.addUnit(n,t.unit),qt.addBitWidth(n,t.bitWidth),qt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return Gt.startTimestamp(n),Gt.addUnit(n,t.unit),r!==void 0&&Gt.addTimezone(n,r),Gt.endTimestamp(n)}visitInterval(t,n){return ue.startInterval(n),ue.addUnit(n,t.unit),ue.endInterval(n)}visitDuration(t,n){return zr.startDuration(n),zr.addUnit(n,t.unit),zr.endDuration(n)}visitList(t,n){return Ca.startList(n),Ca.endList(n)}visitStruct(t,n){return Xe.startStruct_(n),Xe.endStruct_(n)}visitUnion(t,n){xt.startTypeIdsVector(n,t.typeIds.length);const r=xt.createTypeIdsVector(n,t.typeIds);return xt.startUnion(n),xt.addMode(n,t.mode),xt.addTypeIds(n,r),xt.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return Ie.startDictionaryEncoding(n),Ie.addId(n,BigInt(t.id)),Ie.addIsOrdered(n,t.isOrdered),r!==void 0&&Ie.addIndexType(n,r),Ie.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return Yr.startFixedSizeBinary(n),Yr.addByteWidth(n,t.byteWidth),Yr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return jr.startFixedSizeList(n),jr.addListSize(n,t.listSize),jr.endFixedSizeList(n)}visitMap(t,n){return qr.startMap(n),qr.addKeysSorted(n,t.keysSorted),qr.endMap(n)}}const Fs=new Tg;function Ag(e,t=new Map){return new st(Rg(e,t),vi(e.metadata),t)}function Ac(e){return new zt(e.count,Rc(e.columns),Bc(e.columns))}function Ng(e){return new fe(Ac(e.data),e.id,e.isDelta)}function Rg(e,t){return(e.fields||[]).filter(Boolean).map(n=>yt.fromJSON(n,t))}function Nc(e,t){return(e.children||[]).filter(Boolean).map(n=>yt.fromJSON(n,t))}function Rc(e){return(e||[]).reduce((t,n)=>[...t,new Pe(n.count,Bg(n.VALIDITY)),...Rc(n.children)],[])}function Bc(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new pe(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new pe(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new pe(t.length,i.OFFSET.length)),i.DATA&&t.push(new pe(t.length,i.DATA.length)),t=Bc(i.children,t)}return t}function Bg(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function Og(e,t){let n,r,i,s,o,a;return!t||!(s=e.dictionary)?(o=Dc(e,Nc(e,t)),i=new yt(e.name,o,e.nullable,vi(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Oc(r):new Kn,a=new fn(t.get(n),r,n,s.isOrdered),i=new yt(e.name,a,e.nullable,vi(e.metadata))):(r=(r=s.indexType)?Oc(r):new Kn,t.set(n,o=Dc(e,Nc(e,t))),a=new fn(o,r,n,s.isOrdered),i=new yt(e.name,a,e.nullable,vi(e.metadata))),i||null}function vi(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Oc(e){return new Je(e.isSigned,e.bitWidth)}function Dc(e,t){const n=e.type.name;switch(n){case"NONE":return new Ue;case"null":return new Ue;case"binary":return new Wr;case"largebinary":return new Hr;case"utf8":return new Kr;case"largeutf8":return new Qr;case"bool":return new Xr;case"list":return new ii((t||[])[0]);case"struct":return new Ot(t||[]);case"struct_":return new Ot(t||[])}switch(n){case"int":{const r=e.type;return new Je(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new Gr(Rt[r.precision])}case"decimal":{const r=e.type;return new Jr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new Zr(jt[r.unit])}case"time":{const r=e.type;return new ti(x[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new ei(x[r.unit],r.timezone)}case"interval":{const r=e.type;return new ni(ae[r.unit])}case"duration":{const r=e.type;return new ri(x[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new si(Nt[o],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new oi(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new ai(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new li((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var Dg=Oa,Lg=an;class Ft{static fromJSON(t,n){const r=new Ft(0,vt.V5,n);return r._createHeader=Fg(t,n),r}static decode(t){t=new Lg(X(t));const n=ke.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new Ft(r,i,s);return o._createHeader=Mg(n,s),o}static encode(t){const n=new Dg;let r=-1;return t.isSchema()?r=st.encode(n,t.header()):t.isRecordBatch()?r=zt.encode(n,t.header()):t.isDictionaryBatch()&&(r=fe.encode(n,t.header())),ke.startMessage(n),ke.addVersion(n,vt.V5),ke.addHeader(n,r),ke.addHeaderType(n,t.headerType),ke.addBodyLength(n,BigInt(t.bodyLength)),ke.finishMessageBuffer(n,ke.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof st)return new Ft(0,vt.V5,et.Schema,t);if(t instanceof zt)return new Ft(n,vt.V5,et.RecordBatch,t);if(t instanceof fe)return new Ft(n,vt.V5,et.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===et.Schema}isRecordBatch(){return this.headerType===et.RecordBatch}isDictionaryBatch(){return this.headerType===et.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=dt(t)}}class zt{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=dt(t)}}class fe{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=dt(n)}}class pe{constructor(t,n){this.offset=dt(t),this.length=dt(n)}}class Pe{constructor(t,n){this.length=dt(t),this.nullCount=dt(n)}}function Fg(e,t){return(()=>{switch(t){case et.Schema:return st.fromJSON(e);case et.RecordBatch:return zt.fromJSON(e);case et.DictionaryBatch:return fe.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${et[t]}, type: ${t} }`)})}function Mg(e,t){return(()=>{switch(t){case et.Schema:return st.decode(e.header(new he),new Map,e.version());case et.RecordBatch:return zt.decode(e.header(new we),e.version());case et.DictionaryBatch:return fe.decode(e.header(new ln),e.version())}throw new Error(`Unrecognized Message type: { name: ${et[t]}, type: ${t} }`)})}yt.encode=qg,yt.decode=Yg,yt.fromJSON=Og,st.encode=jg,st.decode=Ug,st.fromJSON=Ag,zt.encode=Gg,zt.decode=xg,zt.fromJSON=Ac,fe.encode=Wg,fe.decode=Cg,fe.fromJSON=Ng,Pe.encode=Hg,Pe.decode=kg,pe.encode=Kg,pe.decode=$g;function Ug(e,t=new Map,n=vt.V5){const r=zg(e,t);return new st(r,wi(e),t,n)}function xg(e,t=vt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new zt(e.length(),Pg(e),Vg(e,t))}function Cg(e,t=vt.V5){return new fe(zt.decode(e.data(),t),e.id(),e.isDelta())}function $g(e){return new pe(e.offset(),e.length())}function kg(e){return new Pe(e.length(),e.nullCount())}function Pg(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Pe.decode(n));return t}function Vg(e,t){const n=[];for(let r,i=-1,s=-1,o=e.buffersLength();++i<o;)(r=e.buffers(i))&&(t<vt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=pe.decode(r));return n}function zg(e,t){const n=[];for(let r,i=-1,s=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++s]=yt.decode(r,t));return n}function Lc(e,t){const n=[];for(let r,i=-1,s=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++s]=yt.decode(r,t));return n}function Yg(e,t){let n,r,i,s,o,a;return!t||!(a=e.dictionary())?(i=Mc(e,Lc(e,t)),r=new yt(e.name(),i,e.nullable(),wi(e))):t.has(n=dt(a.id()))?(s=(s=a.indexType())?Fc(s):new Kn,o=new fn(t.get(n),s,n,a.isOrdered()),r=new yt(e.name(),o,e.nullable(),wi(e))):(s=(s=a.indexType())?Fc(s):new Kn,t.set(n,i=Mc(e,Lc(e,t))),o=new fn(i,s,n,a.isOrdered()),r=new yt(e.name(),o,e.nullable(),wi(e))),r||null}function wi(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 Fc(e){return new Je(e.isSigned(),e.bitWidth())}function Mc(e,t){const n=e.typeType();switch(n){case pt.NONE:return new Ue;case pt.Null:return new Ue;case pt.Binary:return new Wr;case pt.LargeBinary:return new Hr;case pt.Utf8:return new Kr;case pt.LargeUtf8:return new Qr;case pt.Bool:return new Xr;case pt.List:return new ii((t||[])[0]);case pt.Struct_:return new Ot(t||[])}switch(n){case pt.Int:{const r=e.type(new Pt);return new Je(r.isSigned(),r.bitWidth())}case pt.FloatingPoint:{const r=e.type(new ce);return new Gr(r.precision())}case pt.Decimal:{const r=e.type(new un);return new Jr(r.scale(),r.precision(),r.bitWidth())}case pt.Date:{const r=e.type(new Vr);return new Zr(r.unit())}case pt.Time:{const r=e.type(new qt);return new ti(r.unit(),r.bitWidth())}case pt.Timestamp:{const r=e.type(new Gt);return new ei(r.unit(),r.timezone())}case pt.Interval:{const r=e.type(new ue);return new ni(r.unit())}case pt.Duration:{const r=e.type(new zr);return new ri(r.unit())}case pt.Union:{const r=e.type(new xt);return new si(r.mode(),r.typeIdsArray()||[],t||[])}case pt.FixedSizeBinary:{const r=e.type(new Yr);return new oi(r.byteWidth())}case pt.FixedSizeList:{const r=e.type(new jr);return new ai(r.listSize(),(t||[])[0])}case pt.Map:{const r=e.type(new qr);return new li((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${pt[n]}" (${n})`)}function jg(e,t){const n=t.fields.map(s=>yt.encode(e,s));he.startFieldsVector(e,n.length);const r=he.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?he.createCustomMetadataVector(e,[...t.metadata].map(([s,o])=>{const a=e.createString(`${s}`),c=e.createString(`${o}`);return Et.startKeyValue(e),Et.addKey(e,a),Et.addValue(e,c),Et.endKeyValue(e)})):-1;return he.startSchema(e),he.addFields(e,r),he.addEndianness(e,Qg?cn.Little:cn.Big),i!==-1&&he.addCustomMetadata(e,i),he.endSchema(e)}function qg(e,t){let n=-1,r=-1,i=-1;const s=t.type;let o=t.typeId;O.isDictionary(s)?(o=s.dictionary.typeId,i=Fs.visit(s,e),r=Fs.visit(s.dictionary,e)):r=Fs.visit(s,e);const a=(s.children||[]).map(u=>yt.encode(e,u)),c=Wt.createChildrenVector(e,a),l=t.metadata&&t.metadata.size>0?Wt.createCustomMetadataVector(e,[...t.metadata].map(([u,d])=>{const y=e.createString(`${u}`),m=e.createString(`${d}`);return Et.startKeyValue(e),Et.addKey(e,y),Et.addValue(e,m),Et.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Wt.startField(e),Wt.addType(e,r),Wt.addTypeType(e,o),Wt.addChildren(e,c),Wt.addNullable(e,!!t.nullable),n!==-1&&Wt.addName(e,n),i!==-1&&Wt.addDictionary(e,i),l!==-1&&Wt.addCustomMetadata(e,l),Wt.endField(e)}function Gg(e,t){const n=t.nodes||[],r=t.buffers||[];we.startNodesVector(e,n.length);for(const o of n.slice().reverse())Pe.encode(e,o);const i=e.endVector();we.startBuffersVector(e,r.length);for(const o of r.slice().reverse())pe.encode(e,o);const s=e.endVector();return we.startRecordBatch(e),we.addLength(e,BigInt(t.length)),we.addNodes(e,i),we.addBuffers(e,s),we.endRecordBatch(e)}function Wg(e,t){const n=zt.encode(e,t.data);return ln.startDictionaryBatch(e),ln.addId(e,BigInt(t.id)),ln.addIsDelta(e,t.isDelta),ln.addData(e,n),ln.endDictionaryBatch(e)}function Hg(e,t){return La.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Kg(e,t){return Da.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Qg=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),Ms=e=>`Expected ${et[e]} Message in stream, but was null or length 0.`,Us=e=>`Header pointer of flatbuffer-encoded ${et[e]} Message is null or length 0.`,Uc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,xc=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class Cc{constructor(t){this.source=t instanceof gi?t:new gi(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?Tt: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(Ms(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=X(this.source.read(t));if(n.byteLength<t)throw new Error(xc(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=et.Schema,r=this.readMessage(n),i=r?.header();if(t&&!i)throw new Error(Us(n));return i}readMetadataLength(){const t=this.source.read(Ii),n=t&&new an(t),r=n?.readInt32(0)||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return Tt;if(n.byteLength<t)throw new Error(Uc(t,n.byteLength));return{done:!1,value:Ft.decode(n)}}}class Xg{constructor(t,n){this.source=t instanceof wn?t:wa(t)?new _i(t,n):new wn(t)}[Symbol.asyncIterator](){return this}next(){return Y(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?Tt:t})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Y(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(Ms(t));return n.value})}readMessageBody(t){return Y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=X(yield this.source.read(t));if(n.byteLength<t)throw new Error(xc(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Y(this,arguments,void 0,function*(t=!1){const n=et.Schema,r=yield this.readMessage(n),i=r?.header();if(t&&!i)throw new Error(Us(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(Ii),n=t&&new an(t),r=n?.readInt32(0)||0;return{done:r===0,value:r}})}readMetadata(t){return Y(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return Tt;if(n.byteLength<t)throw new Error(Uc(t,n.byteLength));return{done:!1,value:Ft.decode(n)}})}}class Jg extends Cc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof _c?t:new _c(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Ft.fromJSON(t.schema,et.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Ft.fromJSON(n,et.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Ft.fromJSON(n,et.RecordBatch)}}return this._body=[],Tt}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(Ms(t));return n.value}readSchema(){const t=et.Schema,n=this.readMessage(t),r=n?.header();if(!n||!r)throw new Error(Us(t));return r}}const Ii=4,xs="ARROW1",er=new Uint8Array(xs.length);for(let e=0;e<xs.length;e+=1)er[e]=xs.codePointAt(e);function Cs(e,t=0){for(let n=-1,r=er.length;++n<r;)if(er[n]!==e[t+n])return!1;return!0}const nr=er.length,$c=nr+Ii,Zg=nr*2+Ii;class Qt extends Ts{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 Qe(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 Yt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Yt.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 Qt?t:rs(t)?r_(t):wa(t)?o_(t):Qe(t)?Y(this,void 0,void 0,function*(){return yield Qt.from(yield t)}):Ia(t)||is(t)||Sa(t)||on(t)?s_(new wn(t)):i_(new gi(t))}static readAll(t){return t instanceof Qt?t.isSync()?Yc(t):jc(t):rs(t)||ArrayBuffer.isView(t)||jn(t)||va(t)?Yc(t):jc(t)}}class Si extends Qt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return se(this,arguments,function*(){yield q(yield*Mr(Ke(this[Symbol.iterator]())))})}}class Ei extends Qt{constructor(t){super(t),this._impl=t}readAll(){return Y(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var o=!0,a=Ke(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;const l=i;s.push(l)}}catch(l){n={error:l}}finally{try{!o&&!t&&(r=a.return)&&(yield r.call(a))}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 kc extends Si{constructor(t){super(t),this._impl=t}}class t_ extends Ei{constructor(t){super(t),this._impl=t}}class Pc{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=Q({type:new Ot(this.schema.fields),length:t.length,children:r});return new $t(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(r),c=o.dictionaries.get(r),l=this._loadVectors(t.data,n,[c]);return(a&&i?a.concat(new it(l)):new it(l)).memoize()}_loadVectors(t,n,r){return new wc(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class Ti extends Pc{constructor(t,n){super(n),this._reader=rs(t)?new Jg(this._handle=t):new Cc(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=zc(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):Tt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Tt}next(){if(this.closed)return Tt;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 Ls(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ai extends Pc{constructor(t,n){super(n),this._reader=new Xg(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Y(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 Y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=zc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Tt})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Tt})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return Tt;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 Ls(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class Vc extends Ti{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 bc?t:new bc(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(et.RecordBatch);if(i?.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}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(et.DictionaryBatch);if(i?.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,n=t.size-$c,r=t.readInt32(n),i=t.readAt(n-r,r);return Xn.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 e_ extends Ai{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 _i?t:new _i(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Y(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 Y(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(et.RecordBatch);if(i?.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return Y(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(et.DictionaryBatch);if(i?.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return Y(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-$c,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Xn.decode(i)})}_readNextMessageAndValidate(t){return Y(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 n_ extends Ti{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new yg(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function zc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*Yc(e){const t=Qt.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function jc(e){return se(this,arguments,function*(){const t=yield q(Qt.from(e));try{if(!(yield q(t.open({autoDestroy:!1}))).closed)do yield yield q(t);while(!(yield q(t.reset().open())).closed)}finally{yield q(t.cancel())}})}function r_(e){return new Si(new n_(e))}function i_(e){const t=e.peek(nr+7&-8);return t&&t.byteLength>=4?Cs(t)?new kc(new Vc(e.read())):new Si(new Ti(e)):new Si(new Ti((function*(){})()))}function s_(e){return Y(this,void 0,void 0,function*(){const t=yield e.peek(nr+7&-8);return t&&t.byteLength>=4?Cs(t)?new kc(new Vc(yield e.read())):new Ei(new Ai(e)):new Ei(new Ai((function(){return se(this,arguments,function*(){})})()))})}function o_(e){return Y(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new _i(e,t);return t>=Zg&&Cs(yield n.readAt(0,nr+7&-8))?new t_(new e_(n)):new Ei(new Ai(n))})}class _t extends H{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof $t?s.data.children:s.data),r=new _t;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof it)return this.visitMany(t.data),this;const{type:n}=t;if(!O.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(O.isUnion(n))this.nodes.push(new Pe(r,0));else{const{nullCount:i}=t;O.isNull(n)||ne.call(this,i<=0?new Uint8Array(0):ui(t.offset,r,t.nullBitmap)),this.nodes.push(new Pe(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 ne(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new pe(this._byteLength,t)),this._byteLength+=t,this}function a_(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(ne.call(this,i),n.mode===Nt.Sparse)return ks.call(this,e);if(n.mode===Nt.Dense){if(e.offset<=0)return ne.call(this,s),ks.call(this,e);{const o=new Int32Array(r),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<r;)(l=i[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);ne.call(this,o),this.visitMany(e.children.map((l,u)=>{const d=n.typeIds[u],y=a[d],m=c[d];return l.slice(y,Math.min(r,m))}))}}return this}function l_(e){let t;return e.nullCount>=e.length?ne.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?ne.call(this,ui(e.offset,e.length,t)):ne.call(this,hi(e.values))}function Ne(e){return ne.call(this,e.values.subarray(0,e.length*e.stride))}function Ni(e){const{length:t,values:n,valueOffsets:r}=e,i=dt(r[0]),s=dt(r[t]),o=Math.min(s-i,n.byteLength-i);return ne.call(this,Na(-i,t+1,r)),ne.call(this,n.subarray(i,i+o)),this}function $s(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return ne.call(this,Na(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function ks(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}_t.prototype.visitBool=l_,_t.prototype.visitInt=Ne,_t.prototype.visitFloat=Ne,_t.prototype.visitUtf8=Ni,_t.prototype.visitLargeUtf8=Ni,_t.prototype.visitBinary=Ni,_t.prototype.visitLargeBinary=Ni,_t.prototype.visitFixedSizeBinary=Ne,_t.prototype.visitDate=Ne,_t.prototype.visitTimestamp=Ne,_t.prototype.visitTime=Ne,_t.prototype.visitDecimal=Ne,_t.prototype.visitList=$s,_t.prototype.visitStruct=ks,_t.prototype.visitUnion=a_,_t.prototype.visitInterval=Ne,_t.prototype.visitDuration=Ne,_t.prototype.visitFixedSizeList=$s,_t.prototype.visitMap=$s;class qc extends Ts{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 mi,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Ut(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 Qe(t)?t.then(n=>this.writeAll(n)):on(t)?Ys(this,t):zs(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 mi?this._sink=t:(this._sink=new mi,t&&ky(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Py(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||!Os(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 Lt&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof $t&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!Os(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof $t?t instanceof Ls||this._writeRecordBatch(t):t instanceof Lt?this.writeAll(t.batches):jn(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Ft.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,c=a-s-o;return t.headerType===et.RecordBatch?this._recordBatchBlocks.push(new Ce(a,t.bodyLength,this._position)):t.headerType===et.DictionaryBatch&&this._dictionaryBlocks.push(new Ce(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){const n=X(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Ft.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(er)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=_t.assemble(t),o=new zt(t.numRows,r,i),a=Ft.from(o,n);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=_t.assemble(new it([t])),c=new zt(t.length,s,o),l=new fe(c,n,r),u=Ft.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,o=t.length;++s<o;)(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 o=(n=s?.data)!==null&&n!==void 0?n:[],a=this._seenDictionaries.get(i),c=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(const[l,u]of o.entries())this._writeDictionaryBatch(u,i,l>0);else if(c<o.length)for(const l of o.slice(c))this._writeDictionaryBatch(l,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}}class Ps extends qc{static writeAll(t,n){const r=new Ps(n);return Qe(t)?t.then(i=>r.writeAll(i)):on(t)?Ys(r,t):zs(r,t)}}class Vs extends qc{static writeAll(t){const n=new Vs;return Qe(t)?t.then(r=>n.writeAll(r)):on(t)?Ys(n,t):zs(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=Xn.encode(new Xn(t,vt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function zs(e,t){let n=t;t instanceof Lt&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Ys(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,o,a,c;try{for(n=!0,r=Ke(t);i=yield r.next(),s=i.done,!s;n=!0){c=i.value,n=!1;const l=c;e.write(l)}}catch(l){o={error:l}}finally{try{!n&&!s&&(a=r.return)&&(yield a.call(r))}finally{if(o)throw o.error}}return e.finish()})}function c_(e,t="stream"){return(t==="stream"?Ps:Vs).writeAll(e).toUint8Array(!0)}var u_=Object.create,Gc=Object.defineProperty,h_=Object.getOwnPropertyDescriptor,d_=Object.getOwnPropertyNames,f_=Object.getPrototypeOf,p_=Object.prototype.hasOwnProperty,y_=(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 d_(t))!p_.call(e,i)&&i!==n&&Gc(e,i,{get:()=>t[i],enumerable:!(r=h_(t,i))||r.enumerable});return e},g_=(e,t,n)=>(n=e!=null?u_(f_(e)):{},m_(!e||!e.__esModule?Gc(n,"default",{value:e,enumerable:!0}):n,e)),__=y_((e,t)=>{t.exports=Worker}),Wc=(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))(Wc||{}),Hc=(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))(Hc||{}),Kc=(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))(Kc||{}),Qc=(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))(Qc||{}),Xc=(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))(Xc||{}),Jc=(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))(Jc||{}),b_=class{log(e){}},v_=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function w_(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 I_(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 S_(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 E_(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 Zc=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(Zc||{}),tu=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=Qt.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Lt(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 js(this._bindings,this._conn,n),i=await Qt.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 eu(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=c_(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)}},js=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}},eu=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=Qt.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Lt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new js(this.bindings,this.connectionId,t),r=await Qt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},nu=(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))(nu||{}),ru=(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))(ru||{}),J=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 Ri(e){switch(e.typeId){case p.Binary:return{sqlType:"binary"};case p.Bool:return{sqlType:"bool"};case p.Date:return{sqlType:"date"};case p.DateDay:return{sqlType:"date32[d]"};case p.DateMillisecond:return{sqlType:"date64[ms]"};case p.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case p.Float:return{sqlType:"float"};case p.Float16:return{sqlType:"float16"};case p.Float32:return{sqlType:"float32"};case p.Float64:return{sqlType:"float64"};case p.Int:return{sqlType:"int32"};case p.Int16:return{sqlType:"int16"};case p.Int32:return{sqlType:"int32"};case p.Int64:return{sqlType:"int64"};case p.Uint16:return{sqlType:"uint16"};case p.Uint32:return{sqlType:"uint32"};case p.Uint64:return{sqlType:"uint64"};case p.Uint8:return{sqlType:"uint8"};case p.IntervalDayTime:return{sqlType:"interval[dt]"};case p.IntervalYearMonth:return{sqlType:"interval[m]"};case p.List:return{sqlType:"list",valueType:Ri(e.valueType)};case p.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case p.Null:return{sqlType:"null"};case p.Utf8:return{sqlType:"utf8"};case p.Struct:return{sqlType:"struct",fields:e.children.map(t=>qs(t.name,t.type))};case p.Map:{let t=e;return{sqlType:"map",keyType:Ri(t.keyType),valueType:Ri(t.valueType)}}case p.Time:return{sqlType:"time[s]"};case p.TimeMicrosecond:return{sqlType:"time[us]"};case p.TimeMillisecond:return{sqlType:"time[ms]"};case p.TimeNanosecond:return{sqlType:"time[ns]"};case p.TimeSecond:return{sqlType:"time[s]"};case p.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case p.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case p.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case p.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case p.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function qs(e,t){let n=Ri(t);return n.name=e,n}var T_=new TextEncoder,A_=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 J("RESET",null);return await this.postTask(e)}async ping(){let e=new J("PING",null);await this.postTask(e)}async dropFile(e){let t=new J("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new J("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new J("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new J("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new J("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new J("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new J("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new J("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new J("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new tu(this,e)}async disconnect(e){let t=new J("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new J("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new J("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new J("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new J("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new J("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new J("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new J("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new J("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new J("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new J("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new J("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=T_.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new J("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new J("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new J("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new J("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new J("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new J("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new J("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new J("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new J("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 o=n.columns[s];i.push(qs(s,o))}n.columnsFlat=i,delete n.columns}let r=new J("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 o=n.columns[s];i.push(qs(s,o))}n.columnsFlat=i,delete n.columns}let r=new J("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function N_(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}N_();var iu=(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))(iu||{}),R_=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)}}},B_=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])),O_=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])),D_=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])),L_=()=>(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])),Gs={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},su=Gs.name,ou=Gs.version,Ws=Gs.version.split("."),F_=Ws[0],M_=Ws[1],U_=Ws[2],Hs=()=>typeof navigator>"u",au=()=>Hs()?"node":navigator.userAgent,x_=()=>au().includes("Firefox"),C_=()=>/^((?!chrome|android).)*safari/i.test(au());function $_(){let e="https://cdn.jsdelivr.net/npm/".concat(su,"@").concat(ou,"/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 Ks=null,Qs=null,Xs=null,Js=null,Zs=null;async function lu(){return Ks==null&&(Ks=typeof BigInt64Array<"u"),Qs==null&&(Qs=await O_()),Xs==null&&(Xs=await L_()),Js==null&&(Js=await D_()),Zs==null&&(Zs=await B_()),{bigInt64Array:Ks,crossOriginIsolated:Hs()||globalThis.crossOriginIsolated||!1,wasmExceptions:Qs,wasmSIMD:Js,wasmThreads:Xs,wasmBulkMemory:Zs}}async function k_(e){let t=await lu();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 P_=g_(__());async function V_(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new P_.default(r)}const z_=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:A_,AsyncDuckDBConnection:tu,AsyncDuckDBDispatcher:R_,AsyncPreparedStatement:eu,AsyncResultStreamIterator:js,ConsoleLogger:v_,DuckDBAccessMode:Wc,DuckDBDataProtocol:iu,LogEvent:Xc,LogLevel:Kc,LogOrigin:Jc,LogTopic:Qc,PACKAGE_NAME:su,PACKAGE_VERSION:ou,PACKAGE_VERSION_MAJOR:F_,PACKAGE_VERSION_MINOR:M_,PACKAGE_VERSION_PATCH:U_,StatusCode:Zc,TokenType:Hc,VoidLogger:b_,WorkerRequestType:nu,WorkerResponseType:ru,WorkerTask:J,createWorker:V_,getJsDelivrBundles:$_,getLogEventLabel:I_,getLogLevelLabel:w_,getLogOriginLabel:E_,getLogTopicLabel:S_,getPlatformFeatures:lu,isFirefox:x_,isNode:Hs,isSafari:C_,selectBundle:k_},Symbol.toStringTag,{value:"Module"}));async function Y_(){try{return vu.fetchAuthSession().then(e=>e?.tokens?.accessToken.toString())}catch(e){console.error(e)}}const cu=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:Y_},Symbol.toStringTag,{value:"Module"}));Xt.DataExplorer=Fy,Xt.UMAP=Uy,Object.defineProperty(Xt,Symbol.toStringTag,{value:"Module"})}));
42
+ ]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Bt(n,r.map(i=>new Lt(n,i)))}slice(t,n){const r=this.schema;[t,n]=Sl({length:this.numRows},t,n);const i=Ol(this.data,this._offsets,t,n);return new Bt(r,i.map(s=>new Lt(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=G({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new tt(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 tt([G({type:new Oe,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,c)=>this.getChildAt(c));[s[t],o[t]]=[a,n],[r,i]=ms(r,o)}return new Bt(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 Bt(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,c)=>{const[d,y]=o,_=n.findIndex(v=>v.name===l.name);return~_?y[_]=c:d.push(c),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 Bt(...ms(s,a))}}Vl=Symbol.toStringTag,Bt[Vl]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=ei(as),e.get=ei(Mt.getVisitFn(f.Struct)),e.set=Dl(Wt.getVisitFn(f.Struct)),e.indexOf=Fl(ni.getVisitFn(f.Struct)),"Table"))(Bt.prototype);var zl;let Lt=class ir{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof et))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=G({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(n=>G({type:n.type,nullCount:0}))})]=t,!(this.data instanceof nt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=jl(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,c,d)=>(l.children[d]=n[c],l.length=Math.max(l.length,n[c].length),l.fields[d]=ut.new({name:c,type:n[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new et(r),o=G({type:new At(r),length:s,children:i,nullCount:0});[this.schema,this.data]=jl(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=Yl(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 Mt.visit(this.data,t)}at(t){return this.get(es(t,this.numRows))}set(t,n){return Wt.visit(this.data,t,n)}indexOf(t,n){return ni.visit(this.data,t,n)}[Symbol.iterator](){return os.visit(new tt([this.data]))}toArray(){return[...this]}concat(...t){return new Bt(this.schema,[this,...t])}slice(t,n){const[r]=new tt([this.data]).slice(t,n).data;return new ir(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 tt([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 tt([G({type:new Oe,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 et(s,new Map(this.schema.metadata)),i=G({type:new At(s),children:a})}return new ir(r,i)}select(t){const n=this.schema.select(t),r=new At(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 ir(n,G({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=G({type:new At(n.fields),length:this.numRows,children:r});return new ir(n,i)}};zl=Symbol.toStringTag,Lt[zl]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Lt.prototype);function jl(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 c=t[o];(!c||c.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=c==null?void 0:c._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:G({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),G({type:new At(i),length:n,children:s})]}function Yl(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 c of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Yl(o.children,c==null?void 0:c.children,n);if(D.isDictionary(o)){const{id:c}=o;if(!n.has(c))l!=null&&l.dictionary&&n.set(c,l.dictionary);else if(n.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class bs extends Lt{constructor(t){const n=t.fields.map(i=>G({type:i.type})),r=G({type:new At(t.fields),nullCount:0,children:n});super(t,r)}}let Le=class fe{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 fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Z),(n||new fe).__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):yt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):X.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 vt).__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,yt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,X.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 fe.startMessage(t),fe.addVersion(t,n),fe.addHeaderType(t,r),fe.addHeader(t,i),fe.addBodyLength(t,s),fe.addCustomMetadata(t,a),fe.endMessage(t)}};class tm extends q{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return no.startNull(n),no.endNull(n)}visitInt(t,n){return Ut.startInt(n),Ut.addBitWidth(n,t.bitWidth),Ut.addIsSigned(n,t.isSigned),Ut.endInt(n)}visitFloat(t,n){return oe.startFloatingPoint(n),oe.addPrecision(n,t.precision),oe.endFloatingPoint(n)}visitBinary(t,n){return Xa.startBinary(n),Xa.endBinary(n)}visitLargeBinary(t,n){return Za.startLargeBinary(n),Za.endLargeBinary(n)}visitBool(t,n){return Ja.startBool(n),Ja.endBool(n)}visitUtf8(t,n){return ro.startUtf8(n),ro.endUtf8(n)}visitLargeUtf8(t,n){return to.startLargeUtf8(n),to.endLargeUtf8(n)}visitDecimal(t,n){return rn.startDecimal(n),rn.addScale(n,t.scale),rn.addPrecision(n,t.precision),rn.addBitWidth(n,t.bitWidth),rn.endDecimal(n)}visitDate(t,n){return Or.startDate(n),Or.addUnit(n,t.unit),Or.endDate(n)}visitTime(t,n){return zt.startTime(n),zt.addUnit(n,t.unit),zt.addBitWidth(n,t.bitWidth),zt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return jt.startTimestamp(n),jt.addUnit(n,t.unit),r!==void 0&&jt.addTimezone(n,r),jt.endTimestamp(n)}visitInterval(t,n){return le.startInterval(n),le.addUnit(n,t.unit),le.endInterval(n)}visitDuration(t,n){return Dr.startDuration(n),Dr.addUnit(n,t.unit),Dr.endDuration(n)}visitList(t,n){return eo.startList(n),eo.endList(n)}visitStruct(t,n){return We.startStruct_(n),We.endStruct_(n)}visitUnion(t,n){Ft.startTypeIdsVector(n,t.typeIds.length);const r=Ft.createTypeIdsVector(n,t.typeIds);return Ft.startUnion(n),Ft.addMode(n,t.mode),Ft.addTypeIds(n,r),Ft.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return ve.startDictionaryEncoding(n),ve.addId(n,BigInt(t.id)),ve.addIsOrdered(n,t.isOrdered),r!==void 0&&ve.addIndexType(n,r),ve.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return Fr.startFixedSizeBinary(n),Fr.addByteWidth(n,t.byteWidth),Fr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Mr.startFixedSizeList(n),Mr.addListSize(n,t.listSize),Mr.endFixedSizeList(n)}visitMap(t,n){return Lr.startMap(n),Lr.addKeysSorted(n,t.keysSorted),Lr.endMap(n)}}const gs=new tm;function em(e,t=new Map){return new et(rm(e,t),ci(e.metadata),t)}function Wl(e){return new kt(e.count,Gl(e.columns),Hl(e.columns))}function nm(e){return new he(Wl(e.data),e.id,e.isDelta)}function rm(e,t){return(e.fields||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function ql(e,t){return(e.children||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function Gl(e){return(e||[]).reduce((t,n)=>[...t,new xe(n.count,im(n.VALIDITY)),...Gl(n.children)],[])}function Hl(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new de(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new de(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new de(t.length,i.OFFSET.length)),i.DATA&&t.push(new de(t.length,i.DATA.length)),t=Hl(i.children,t)}return t}function im(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function sm(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=Ql(e,ql(e,t)),i=new ut(e.name,a,e.nullable,ci(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Kl(r):new $n,o=new on(t.get(n),r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))):(r=(r=s.indexType)?Kl(r):new $n,t.set(n,a=Ql(e,ql(e,t))),o=new on(a,r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))),i||null}function ci(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Kl(e){return new qe(e.isSigned,e.bitWidth)}function Ql(e,t){const n=e.type.name;switch(n){case"NONE":return new Oe;case"null":return new Oe;case"binary":return new Ur;case"largebinary":return new Cr;case"utf8":return new kr;case"largeutf8":return new $r;case"bool":return new Pr;case"list":return new Gr((t||[])[0]);case"struct":return new At(t||[]);case"struct_":return new At(t||[])}switch(n){case"int":{const r=e.type;return new qe(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new xr(Tt[r.precision])}case"decimal":{const r=e.type;return new Vr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new zr(Vt[r.unit])}case"time":{const r=e.type;return new jr(k[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Yr(k[r.unit],r.timezone)}case"interval":{const r=e.type;return new Wr(se[r.unit])}case"duration":{const r=e.type;return new qr(k[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Hr(Et[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Kr(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Qr(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Xr((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var am=Ha,om=tn;class Rt{static fromJSON(t,n){const r=new Rt(0,yt.V5,n);return r._createHeader=lm(t,n),r}static decode(t){t=new om(H(t));const n=Le.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new Rt(r,i,s);return a._createHeader=cm(n,s),a}static encode(t){const n=new am;let r=-1;return t.isSchema()?r=et.encode(n,t.header()):t.isRecordBatch()?r=kt.encode(n,t.header()):t.isDictionaryBatch()&&(r=he.encode(n,t.header())),Le.startMessage(n),Le.addVersion(n,yt.V5),Le.addHeader(n,r),Le.addHeaderType(n,t.headerType),Le.addBodyLength(n,BigInt(t.bodyLength)),Le.finishMessageBuffer(n,Le.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof et)return new Rt(0,yt.V5,X.Schema,t);if(t instanceof kt)return new Rt(n,yt.V5,X.RecordBatch,t);if(t instanceof he)return new Rt(n,yt.V5,X.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===X.Schema}isRecordBatch(){return this.headerType===X.RecordBatch}isDictionaryBatch(){return this.headerType===X.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ot(t)}}class kt{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=ot(t)}}class he{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=ot(n)}}class de{constructor(t,n){this.offset=ot(t),this.length=ot(n)}}class xe{constructor(t,n){this.length=ot(t),this.nullCount=ot(n)}}function lm(e,t){return()=>{switch(t){case X.Schema:return et.fromJSON(e);case X.RecordBatch:return kt.fromJSON(e);case X.DictionaryBatch:return he.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}function cm(e,t){return()=>{switch(t){case X.Schema:return et.decode(e.header(new ce),new Map,e.version());case X.RecordBatch:return kt.decode(e.header(new _e),e.version());case X.DictionaryBatch:return he.decode(e.header(new en),e.version())}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}ut.encode=vm,ut.decode=gm,ut.fromJSON=sm,et.encode=_m,et.decode=um,et.fromJSON=em,kt.encode=wm,kt.decode=hm,kt.fromJSON=Wl,he.encode=Im,he.decode=dm,he.fromJSON=nm,xe.encode=Sm,xe.decode=pm,de.encode=Em,de.decode=fm;function um(e,t=new Map,n=yt.V5){const r=bm(e,t);return new et(r,ui(e),t,n)}function hm(e,t=yt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new kt(e.length(),ym(e),mm(e,t))}function dm(e,t=yt.V5){return new he(kt.decode(e.data(),t),e.id(),e.isDelta())}function fm(e){return new de(e.offset(),e.length())}function pm(e){return new xe(e.length(),e.nullCount())}function ym(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=xe.decode(n));return t}function mm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<yt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=de.decode(r));return n}function bm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=ut.decode(r,t));return n}function Xl(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=ut.decode(r,t));return n}function gm(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=Zl(e,Xl(e,t)),r=new ut(e.name(),i,e.nullable(),ui(e))):t.has(n=ot(o.id()))?(s=(s=o.indexType())?Jl(s):new $n,a=new on(t.get(n),s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))):(s=(s=o.indexType())?Jl(s):new $n,t.set(n,i=Zl(e,Xl(e,t))),a=new on(i,s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))),r||null}function ui(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 Jl(e){return new qe(e.isSigned(),e.bitWidth())}function Zl(e,t){const n=e.typeType();switch(n){case lt.NONE:return new Oe;case lt.Null:return new Oe;case lt.Binary:return new Ur;case lt.LargeBinary:return new Cr;case lt.Utf8:return new kr;case lt.LargeUtf8:return new $r;case lt.Bool:return new Pr;case lt.List:return new Gr((t||[])[0]);case lt.Struct_:return new At(t||[])}switch(n){case lt.Int:{const r=e.type(new Ut);return new qe(r.isSigned(),r.bitWidth())}case lt.FloatingPoint:{const r=e.type(new oe);return new xr(r.precision())}case lt.Decimal:{const r=e.type(new rn);return new Vr(r.scale(),r.precision(),r.bitWidth())}case lt.Date:{const r=e.type(new Or);return new zr(r.unit())}case lt.Time:{const r=e.type(new zt);return new jr(r.unit(),r.bitWidth())}case lt.Timestamp:{const r=e.type(new jt);return new Yr(r.unit(),r.timezone())}case lt.Interval:{const r=e.type(new le);return new Wr(r.unit())}case lt.Duration:{const r=e.type(new Dr);return new qr(r.unit())}case lt.Union:{const r=e.type(new Ft);return new Hr(r.mode(),r.typeIdsArray()||[],t||[])}case lt.FixedSizeBinary:{const r=e.type(new Fr);return new Kr(r.byteWidth())}case lt.FixedSizeList:{const r=e.type(new Mr);return new Qr(r.listSize(),(t||[])[0])}case lt.Map:{const r=e.type(new Lr);return new Xr((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${lt[n]}" (${n})`)}function _m(e,t){const n=t.fields.map(s=>ut.encode(e,s));ce.startFieldsVector(e,n.length);const r=ce.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?ce.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return vt.startKeyValue(e),vt.addKey(e,o),vt.addValue(e,l),vt.endKeyValue(e)})):-1;return ce.startSchema(e),ce.addFields(e,r),ce.addEndianness(e,Tm?nn.Little:nn.Big),i!==-1&&ce.addCustomMetadata(e,i),ce.endSchema(e)}function vm(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;D.isDictionary(s)?(a=s.dictionary.typeId,i=gs.visit(s,e),r=gs.visit(s.dictionary,e)):r=gs.visit(s,e);const o=(s.children||[]).map(d=>ut.encode(e,d)),l=Yt.createChildrenVector(e,o),c=t.metadata&&t.metadata.size>0?Yt.createCustomMetadataVector(e,[...t.metadata].map(([d,y])=>{const _=e.createString(`${d}`),v=e.createString(`${y}`);return vt.startKeyValue(e),vt.addKey(e,_),vt.addValue(e,v),vt.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Yt.startField(e),Yt.addType(e,r),Yt.addTypeType(e,a),Yt.addChildren(e,l),Yt.addNullable(e,!!t.nullable),n!==-1&&Yt.addName(e,n),i!==-1&&Yt.addDictionary(e,i),c!==-1&&Yt.addCustomMetadata(e,c),Yt.endField(e)}function wm(e,t){const n=t.nodes||[],r=t.buffers||[];_e.startNodesVector(e,n.length);for(const a of n.slice().reverse())xe.encode(e,a);const i=e.endVector();_e.startBuffersVector(e,r.length);for(const a of r.slice().reverse())de.encode(e,a);const s=e.endVector();return _e.startRecordBatch(e),_e.addLength(e,BigInt(t.length)),_e.addNodes(e,i),_e.addBuffers(e,s),_e.endRecordBatch(e)}function Im(e,t){const n=kt.encode(e,t.data);return en.startDictionaryBatch(e),en.addId(e,BigInt(t.id)),en.addIsDelta(e,t.isDelta),en.addData(e,n),en.endDictionaryBatch(e)}function Sm(e,t){return Qa.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Em(e,t){return Ka.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Tm=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),_s=e=>`Expected ${X[e]} Message in stream, but was null or length 0.`,vs=e=>`Header pointer of flatbuffer-encoded ${X[e]} Message is null or length 0.`,tc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,ec=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class nc{constructor(t){this.source=t instanceof ai?t:new ai(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?wt: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(_s(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=H(this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=X.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i}readMetadataLength(){const t=this.source.read(hi),n=t&&new tn(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 wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}}}class Am{constructor(t,n){this.source=t instanceof yn?t:$a(t)?new oi(t,n):new yn(t)}[Symbol.asyncIterator](){return this}next(){return Y(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?wt:t})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Y(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(_s(t));return n.value})}readMessageBody(t){return Y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=H(yield this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Y(this,arguments,void 0,function*(t=!1){const n=X.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(hi),n=t&&new tn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Y(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}})}}class Nm extends nc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Cl?t:new Cl(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Rt.fromJSON(t.schema,X.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Rt.fromJSON(n,X.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Rt.fromJSON(n,X.RecordBatch)}}return this._body=[],wt}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(_s(t));return n.value}readSchema(){const t=X.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(vs(t));return r}}const hi=4,ws="ARROW1",Wn=new Uint8Array(ws.length);for(let e=0;e<ws.length;e+=1)Wn[e]=ws.codePointAt(e);function Is(e,t=0){for(let n=-1,r=Wn.length;++n<r;)if(Wn[n]!==e[t+n])return!1;return!0}const qn=Wn.length,rc=qn+hi,Bm=qn*2+hi;class Gt extends us{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 Ye(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 Pt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Pt.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 Gt?t:zi(t)?Fm(t):$a(t)?xm(t):Ye(t)?Y(this,void 0,void 0,function*(){return yield Gt.from(yield t)}):Pa(t)||ji(t)||Va(t)||Ze(t)?Lm(new yn(t)):Mm(new ai(t))}static readAll(t){return t instanceof Gt?t.isSync()?lc(t):cc(t):zi(t)||ArrayBuffer.isView(t)||Ln(t)||ka(t)?lc(t):cc(t)}}class di extends Gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return re(this,arguments,function*(){yield W(yield*Sr(je(this[Symbol.iterator]())))})}}class fi extends Gt{constructor(t){super(t),this._impl=t}readAll(){return Y(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=je(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const c=i;s.push(c)}}catch(c){n={error:c}}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 ic extends di{constructor(t){super(t),this._impl=t}}class Rm extends fi{constructor(t){super(t),this._impl=t}}class sc{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=G({type:new At(this.schema.fields),length:t.length,children:r});return new Lt(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),c=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new tt(c)):new tt(c)).memoize()}_loadVectors(t,n,r){return new Pl(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class pi extends sc{constructor(t,n){super(n),this._reader=zi(t)?new Nm(this._handle=t):new nc(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=oc(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):wt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):wt}next(){if(this.closed)return wt;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 bs(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class yi extends sc{constructor(t,n){super(n),this._reader=new Am(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Y(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 Y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):wt})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):wt})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return wt;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 bs(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class ac extends pi{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 kl?t:new kl(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(X.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(X.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-rc,r=t.readInt32(n),i=t.readAt(n-r,r);return Vn.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 yi{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 oi?t:new oi(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Y(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 Y(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(X.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 Y(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(X.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 Y(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-rc,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Vn.decode(i)})}_readNextMessageAndValidate(t){return Y(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 Dm extends pi{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new Yy(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function oc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*lc(e){const t=Gt.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function cc(e){return re(this,arguments,function*(){const t=yield W(Gt.from(e));try{if(!(yield W(t.open({autoDestroy:!1}))).closed)do yield yield W(t);while(!(yield W(t.reset().open())).closed)}finally{yield W(t.cancel())}})}function Fm(e){return new di(new Dm(e))}function Mm(e){const t=e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(e.read())):new di(new pi(e)):new di(new pi(function*(){}()))}function Lm(e){return Y(this,void 0,void 0,function*(){const t=yield e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(yield e.read())):new fi(new yi(e)):new fi(new yi(function(){return re(this,arguments,function*(){})}()))})}function xm(e){return Y(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new oi(e,t);return t>=Bm&&Is(yield n.readAt(0,qn+7&-8))?new Rm(new Om(n)):new fi(new yi(n))})}class pt extends q{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Lt?s.data.children:s.data),r=new pt;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof tt)return this.visitMany(t.data),this;const{type:n}=t;if(!D.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(D.isUnion(n))this.nodes.push(new xe(r,0));else{const{nullCount:i}=t;D.isNull(n)||Jt.call(this,i<=0?new Uint8Array(0):Zr(t.offset,r,t.nullBitmap)),this.nodes.push(new xe(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 Jt(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new de(this._byteLength,t)),this._byteLength+=t,this}function Um(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(Jt.call(this,i),n.mode===Et.Sparse)return Es.call(this,e);if(n.mode===Et.Dense){if(e.offset<=0)return Jt.call(this,s),Es.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let c,d,y=-1;++y<r;)(c=i[y])!==void 0&&((d=o[c])===void 0&&(d=o[c]=s[y]),a[y]=s[y]-d,l[c]=((t=l[c])!==null&&t!==void 0?t:0)+1);Jt.call(this,a),this.visitMany(e.children.map((c,d)=>{const y=n.typeIds[d],_=o[y],v=l[y];return c.slice(_,Math.min(r,v))}))}}return this}function Cm(e){let t;return e.nullCount>=e.length?Jt.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?Jt.call(this,Zr(e.offset,e.length,t)):Jt.call(this,ti(e.values))}function Te(e){return Jt.call(this,e.values.subarray(0,e.length*e.stride))}function mi(e){const{length:t,values:n,valueOffsets:r}=e,i=ot(r[0]),s=ot(r[t]),a=Math.min(s-i,n.byteLength-i);return Jt.call(this,Wa(-i,t+1,r)),Jt.call(this,n.subarray(i,i+a)),this}function Ss(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return Jt.call(this,Wa(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Es(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}pt.prototype.visitBool=Cm,pt.prototype.visitInt=Te,pt.prototype.visitFloat=Te,pt.prototype.visitUtf8=mi,pt.prototype.visitLargeUtf8=mi,pt.prototype.visitBinary=mi,pt.prototype.visitLargeBinary=mi,pt.prototype.visitFixedSizeBinary=Te,pt.prototype.visitDate=Te,pt.prototype.visitTimestamp=Te,pt.prototype.visitTime=Te,pt.prototype.visitDecimal=Te,pt.prototype.visitList=Ss,pt.prototype.visitStruct=Es,pt.prototype.visitUnion=Um,pt.prototype.visitInterval=Te,pt.prototype.visitDuration=Te,pt.prototype.visitFixedSizeList=Ss,pt.prototype.visitMap=Ss;class uc extends us{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 si,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Dt(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 Ye(t)?t.then(n=>this.writeAll(n)):Ze(t)?Bs(this,t):Ns(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 si?this._sink=t:(this._sink=new si,t&&pp(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&yp(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||!ys(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 Bt&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof Lt&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!ys(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof Lt?t instanceof bs||this._writeRecordBatch(t):t instanceof Bt?this.writeAll(t.batches):Ln(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Rt.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===X.RecordBatch?this._recordBatchBlocks.push(new Fe(o,t.bodyLength,this._position)):t.headerType===X.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(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=H(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Rt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Wn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=pt.assemble(t),a=new kt(t.numRows,r,i),o=Rt.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}=pt.assemble(new tt([t])),l=new kt(t.length,s,a),c=new he(l,n,r),d=Rt.from(c,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[c,d]of a.entries())this._writeDictionaryBatch(d,i,c>0);else if(l<a.length)for(const c of a.slice(l))this._writeDictionaryBatch(c,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class Ts extends uc{static writeAll(t,n){const r=new Ts(n);return Ye(t)?t.then(i=>r.writeAll(i)):Ze(t)?Bs(r,t):Ns(r,t)}}class As extends uc{static writeAll(t){const n=new As;return Ye(t)?t.then(r=>n.writeAll(r)):Ze(t)?Bs(n,t):Ns(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=Vn.encode(new Vn(t,yt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Ns(e,t){let n=t;t instanceof Bt&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Bs(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=je(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const c=l;e.write(c)}}catch(c){a={error:c}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function km(e,t="stream"){return(t==="stream"?Ts:As).writeAll(e).toUint8Array(!0)}var $m=Object.create,hc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Vm=Object.getOwnPropertyNames,zm=Object.getPrototypeOf,jm=Object.prototype.hasOwnProperty,Ym=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vm(t))!jm.call(e,i)&&i!==n&&hc(e,i,{get:()=>t[i],enumerable:!(r=Pm(t,i))||r.enumerable});return e},qm=(e,t,n)=>(n=e!=null?$m(zm(e)):{},Wm(!e||!e.__esModule?hc(n,"default",{value:e,enumerable:!0}):n,e)),Gm=Ym((e,t)=>{t.exports=Worker}),dc=(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))(dc||{}),fc=(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))(fc||{}),pc=(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))(pc||{}),yc=(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))(yc||{}),mc=(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))(mc||{}),bc=(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))(bc||{}),Hm=class{log(e){}},Km=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function Qm(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 Xm(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 Jm(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 Zm(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 gc=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(gc||{}),_c=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=Gt.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Bt(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 Rs(this._bindings,this._conn,n),i=await Gt.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 vc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=km(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)}},Rs=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}},vc=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=Gt.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Rs(this.bindings,this.connectionId,t),r=await Gt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},wc=(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))(wc||{}),Ic=(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))(Ic||{}),K=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 bi(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:bi(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=>Os(t.name,t.type))};case f.Map:{let t=e;return{sqlType:"map",keyType:bi(t.keyType),valueType:bi(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 Os(e,t){let n=bi(t);return n.name=e,n}var tb=new TextEncoder,eb=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 K("RESET",null);return await this.postTask(e)}async ping(){let e=new K("PING",null);await this.postTask(e)}async dropFile(e){let t=new K("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new K("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new K("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new K("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new K("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new K("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new K("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new K("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new K("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new _c(this,e)}async disconnect(e){let t=new K("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new K("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new K("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new K("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new K("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new K("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new K("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new K("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new K("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new K("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new K("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new K("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=tb.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new K("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new K("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new K("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new K("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new K("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new K("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new K("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new K("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new K("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(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("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(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function nb(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}nb();var Sc=(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))(Sc||{}),rb=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)}}},ib=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])),sb=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])),ab=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])),ob=()=>(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])),Ds={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},Ec=Ds.name,Tc=Ds.version,Fs=Ds.version.split("."),lb=Fs[0],cb=Fs[1],ub=Fs[2],Ms=()=>typeof navigator>"u",Ac=()=>Ms()?"node":navigator.userAgent,hb=()=>Ac().includes("Firefox"),db=()=>/^((?!chrome|android).)*safari/i.test(Ac());function fb(){let e="https://cdn.jsdelivr.net/npm/".concat(Ec,"@").concat(Tc,"/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 Ls=null,xs=null,Us=null,Cs=null,ks=null;async function Nc(){return Ls==null&&(Ls=typeof BigInt64Array<"u"),xs==null&&(xs=await sb()),Us==null&&(Us=await ob()),Cs==null&&(Cs=await ab()),ks==null&&(ks=await ib()),{bigInt64Array:Ls,crossOriginIsolated:Ms()||globalThis.crossOriginIsolated||!1,wasmExceptions:xs,wasmSIMD:Cs,wasmThreads:Us,wasmBulkMemory:ks}}async function pb(e){let t=await Nc();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 yb=qm(Gm());async function mb(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new yb.default(r)}const bb=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:eb,AsyncDuckDBConnection:_c,AsyncDuckDBDispatcher:rb,AsyncPreparedStatement:vc,AsyncResultStreamIterator:Rs,ConsoleLogger:Km,DuckDBAccessMode:dc,DuckDBDataProtocol:Sc,LogEvent:mc,LogLevel:pc,LogOrigin:bc,LogTopic:yc,PACKAGE_NAME:Ec,PACKAGE_VERSION:Tc,PACKAGE_VERSION_MAJOR:lb,PACKAGE_VERSION_MINOR:cb,PACKAGE_VERSION_PATCH:ub,StatusCode:gc,TokenType:fc,VoidLogger:Hm,WorkerRequestType:wc,WorkerResponseType:Ic,WorkerTask:K,createWorker:mb,getJsDelivrBundles:fb,getLogEventLabel:Xm,getLogLevelLabel:Qm,getLogOriginLabel:Zm,getLogTopicLabel:Jm,getPlatformFeatures:Nc,isFirefox:hb,isNode:Ms,isSafari:db,selectBundle:pb},Symbol.toStringTag,{value:"Module"}));async function gb(){var r,i,s,a;const e="@aws-amplify/auth";let t;try{t=await import(e)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:n}=t;return{token:((a=(s=(i=(r=await n())==null?void 0:r.tokens)==null?void 0:i.idToken)==null?void 0:s.toString)==null?void 0:a.call(s))??null,provider:"amplify"}}const Bc=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:gb},Symbol.toStringTag,{value:"Module"}));te.DataExplorer=lp,te.UMAP=up,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});