precision-dashwidgets 0.1.0 → 0.1.2

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,21 @@
1
- (function(Xt,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("vue"),require("element-plus"),require("@aws-amplify/auth"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","@aws-amplify/auth","pinia"],f):(Xt=typeof globalThis<"u"?globalThis:Xt||self,f(Xt["precision-dashwidgets"]={},Xt.Vue,Xt.ElementPlus,Xt.aws_amplify_auth,Xt.Pinia))})(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 mt(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function ze(e){return function t(n){return arguments.length===0||mt(n)?t:e.apply(this,arguments)}}function Ye(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return mt(n)?t:ze(function(i){return e(n,i)});default:return mt(n)&&mt(r)?t:mt(n)?ze(function(i){return e(i,r)}):mt(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 mt(n)?t:Ye(function(s,o){return e(n,s,o)});case 2:return mt(n)&&mt(r)?t:mt(n)?Ye(function(s,o){return e(s,r,o)}):mt(r)?Ye(function(s,o){return e(n,s,o)}):ze(function(s){return e(n,r,s)});default:return mt(n)&&mt(r)&&mt(i)?t:mt(n)&&mt(r)?Ye(function(s,o){return e(s,o,i)}):mt(n)&&mt(i)?Ye(function(s,o){return e(s,r,o)}):mt(r)&&mt(i)?Ye(function(s,o){return e(n,s,o)}):mt(n)?ze(function(s){return e(s,r,i)}):mt(r)?ze(function(s){return e(n,s,i)}):mt(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))});async function hr(){try{return bu.fetchAuthSession().then(e=>e?.tokens?.accessToken.toString())}catch(e){console.error(e)}}const Bu=vu.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),l=f.computed(()=>B=>i.value.get(B)),c=f.computed(()=>B=>{const T=i.value.get(B);return T&&!T.isLoading&&!T.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 B=await Promise.resolve().then(()=>z_),T={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"}},R=await B.selectBundle(T),z=new Worker(R.mainWorker),q=new B.ConsoleLogger(B.LogLevel.WARNING);return e.value=new B.AsyncDuckDB(q,z),await e.value.instantiate(R.mainModule),t.value=!0,e.value}catch(B){throw console.error("Failed to initialize DuckDB:",B),r.value=`Failed to initialize DuckDB: ${B.message}`,B}finally{n.value=!1}},m=async(B=null)=>{a.value||await y();const T=await e.value.connect(),R=B||`conn_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return s.value.set(R,{connection:T,viewerId:R,createdAt:new Date}),{connection:T,connectionId:R}},b=async B=>{const T=s.value.get(B);T&&(await T.connection.close(),s.value.delete(B),A(B),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},A=B=>{for(const[T,R]of o.value)R.delete(B),R.size===0&&console.log(`File ${T} is no longer used by any viewers`)},S=(B,T)=>{o.value.has(B)||o.value.set(B,new Set),o.value.get(B).add(T)},_=async B=>{const T=i.value.get(B);if(T&&T.tableName)try{const R=await e.value.connect();await R.query(`DROP TABLE IF EXISTS ${T.tableName};`),await R.close()}catch(R){console.warn(`Failed to drop table ${T.tableName}:`,R)}i.value.delete(B),o.value.delete(B)},W=async(B,T,R="my_data",z={},q=null,J=null)=>{const lt=J||B,_t=i.value.get(lt);if(_t&&!_t.isLoading&&!_t.error)return q&&S(lt,q),_t.tableName;a.value||await y(),i.value.set(lt,{tableName:R,fileType:T,fileUrl:B,isLoading:!0,error:null});try{const Tt=await fetch(B);if(!Tt.ok)throw new Error(`Failed to fetch file: ${Tt.status} ${Tt.statusText}`);let g;if(T==="csv"){const v=await Tt.text(),w=await new Blob([v],{type:"text/csv"}).arrayBuffer();g=new Uint8Array(w)}else{const v=await Tt.arrayBuffer();g=new Uint8Array(v)}const I=`${J||R}.${T}`;await e.value.registerFileBuffer(I,g);const h=await e.value.connect();try{let v;if(T==="csv"){const E={header:!0,delimiter:",",...z};v=`
2
- CREATE OR REPLACE TABLE ${R} AS
3
- SELECT * FROM read_csv('${I}', header=${E.header}, delim='${E.delimiter}');
4
- `}else if(T==="parquet")v=`
5
- CREATE OR REPLACE TABLE ${R} AS
6
- SELECT * FROM read_parquet('${I}');
7
- `;else throw new Error(`Unsupported file type: ${T}`);await h.query(v);const w=(await h.query(`SELECT COUNT(*) as count FROM ${R};`)).toArray()[0].count;return i.value.set(lt,{tableName:R,fileType:T,fileUrl:B,isLoading:!1,error:null,rowCount:w,loadedAt:new Date}),q&&S(lt,q),R}finally{await h.close()}}catch(Tt){throw i.value.set(lt,{tableName:R,fileType:T,fileUrl:B,isLoading:!1,error:Tt.message}),Tt}},Z=async(B,T)=>{const R=s.value.get(T);if(!R)throw new Error(`Connection not found: ${T}`);return(await R.connection.query(B)).toArray().map(z=>{const q={};for(const[J,lt]of Object.entries(z))q[J]=lt;return q})},wt=async()=>{for(const[B,T]of s.value)try{await T.connection.close(),console.log(`Closed connection: ${B}`)}catch(R){console.warn(`Error closing connection ${B}:`,R)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(B){console.warn("Error terminating DuckDB:",B)}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:l,isFileLoaded:c,activeConnectionCount:u,hasActiveConnections:d,initDuckDB:y,createConnection:m,closeConnection:b,cleanupViewerFileUsage:A,trackFileUsage:S,unloadFile:_,loadFile:W,executeQuery:Z,cleanup:async(B=!1)=>{B||s.value.size===0?await wt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},performGlobalCleanup:wt,getConnectionInfo:()=>{const B=[];for(const[T,R]of s.value)B.push({connectionId:T,viewerId:R.viewerId,createdAt:R.createdAt});return B},getFileUsageInfo:()=>{const B=[];for(const[T,R]of o.value){const z=i.value.get(T);B.push({fileId:T,tableName:z?.tableName,fileType:z?.fileType,fileUrl:z?.fileUrl,rowCount:z?.rowCount,loadedAt:z?.loadedAt,usedByViewers:Array.from(R)})}return B}}}),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"),l=f.ref(""),c=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 I=>{if(o.value=I,I)try{await T(),await z()}catch{console.error("file can not be loaded")}},{immediate:!0});const A=f.computed(()=>n.isReady&&b.value&&!i.value),S=f.computed(()=>i.value?"Loading...":n.isInitializing?"Initializing...":n.isReady?A.value?"Connected":"Not Connected":"Not Ready"),_=f.computed(()=>!c.value||!Array.isArray(c.value)||c.value.length===0?[]:Object.keys(c.value[0]||{})),W=f.computed(()=>!c.value||!Array.isArray(c.value)?0:Math.ceil(c.value.length/m.value)),Z=f.computed(()=>{if(!c.value||!Array.isArray(c.value))return[];const I=(y.value-1)*m.value,h=I+m.value;return c.value.slice(I,h)}),wt=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(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
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:A.value,activeConnections:n.activeConnectionCount,hasActiveConnections:n.hasActiveConnections}));const B=async()=>{try{const{connection:I,connectionId:h}=await n.createConnection(t.viewerId);b.value=h,o.value&&(await T(),z())}catch(I){console.error("Failed to initialize viewer:",I),u.value=`Failed to initialize: ${I.message}`}},T=async()=>{if(!o.value){u.value="Please provide a valid S3 URL";return}const I=t.fileId||o.value,h=n.getLoadedFile(I);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()}`,w=await n.loadFile(o.value,t.fileType,v,r.value,t.viewerId,t.fileId);a.value=w,lt("SELECT * FROM data LIMIT 10;")}catch{}finally{i.value=!1}},R=I=>!a.value||!I?I:I.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})`),z=async()=>{if(!l.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 I=R(l.value.trim());c.value=await n.executeQuery(I,b.value)}catch(I){console.error("Query execution failed:",I),u.value=`Query execution failed: ${I.message}`,c.value=null}finally{s.value=!1}},q=I=>{y.value=I},J=I=>{m.value=I,y.value=1},lt=I=>{l.value=I},_t=I=>I==null?"NULL":typeof I=="number"?Number.isInteger(I)?I.toString():I.toFixed(4):typeof I=="string"&&I.length>100?I.substring(0,100)+"...":I.toString(),Tt=()=>{if(!c.value||c.value.length===0)return;const I=Object.keys(c.value[0]),h=[I.join(","),...c.value.map(N=>I.map(D=>{const H=N[D],dt=H==null?"":H.toString();return dt.includes(",")?`"${dt}"`:dt}).join(","))].join(`
14
- `),v=new Blob([h],{type:"text/csv"}),w=URL.createObjectURL(v),E=document.createElement("a");E.href=w,E.download="query-results.csv",E.click(),URL.revokeObjectURL(w)},g=()=>{u.value=""};return f.onMounted(async()=>{await B()}),f.onUnmounted(async()=>{b.value&&(n.activeConnectionCount,n.loadedFiles.size,await n.closeConnection(b.value),n.activeConnectionCount,n.loadedFiles.size)}),(I,h)=>{const v=f.resolveComponent("bf-button"),w=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:A.value,loading:i.value}])},f.toDisplayString(S.value),3)]),f.createElementVNode("div",Lu,[A.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(wt.value,E=>(f.openBlock(),f.createElementBlock("button",{key:E.name,onClick:N=>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=>l.value=E),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[f.vModelText,l.value]]),f.createVNode(v,{onClick:z,disabled:s.value||!l.value},{default:f.withCtx(()=>[f.createTextVNode(f.toDisplayString(s.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):f.createCommentVNode("",!0),c.value?(f.openBlock(),f.createElementBlock("div",xu,[f.createElementVNode("h3",null,"Results ("+f.toDisplayString(c.value.length)+" rows)",1),f.createElementVNode("div",Cu,[f.createElementVNode("div",$u,[f.createVNode(v,{class:"secondary",onClick:Tt},{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(w,{key:0,"current-page":y.value,"onUpdate:currentPage":h[1]||(h[1]=E=>y.value=E),"page-size":m.value,total:c.value.length,layout:"prev, pager, next",onCurrentChange:q,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,N)=>(f.openBlock(),f.createElementBlock("tr",{key:N},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(_.value,D=>(f.openBlock(),f.createElementBlock("td",{key:D},f.toDisplayString(_t(E[D])),1))),128))]))),128))])]),W.value>1?(f.openBlock(),f.createElementBlock("div",zu,[f.createVNode(w,{"current-page":y.value,"onUpdate:currentPage":h[2]||(h[2]=E=>y.value=E),"page-size":m.value,total:c.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:q,onSizeChange:J},null,8,["current-page","page-size","total"])])):f.createCommentVNode("",!0)])):(f.openBlock(),f.createElementBlock("div",Yu,[f.createElementVNode("pre",null,f.toDisplayString(JSON.stringify(c.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 o(l);const c=n.value?.[0]?.content?.id;if(!c){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}s.value=c,r.value=await a(l,c);const u=t.pkg?.content?.packageType;i.value=u==="CSV"?"csv":"parquet"}catch(c){console.error(c)}});async function o(l){const c=await hr(),u=`${t.apiUrl}/packages/${l}/view?api_key=${c}`,d=await fetch(u);if(!d.ok)throw new Error(`view failed: ${d.status}`);n.value=await d.json()}async function a(l,c){const u=await hr(),d=`${t.apiUrl}/packages/${l}/files/${c}?api_key=${u}`,y=await fetch(d);if(!y.ok)throw new Error(`file url failed: ${y.status}`);return(await y.json()).url}return(l,c)=>(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-92b3e9f2"]]);var Qu={value:()=>{}};function Li(){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 dr(n)}function dr(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}})}dr.prototype=Li.prototype={constructor:dr,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]=ro(n[i],e.name,t);else if(t==null)for(i in n)n[i]=ro(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 dr(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 ro(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 Fi="http://www.w3.org/1999/xhtml";const io={svg:"http://www.w3.org/2000/svg",xhtml:Fi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function fr(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),io.hasOwnProperty(t)?{space:io[t],local:e}:e}function Zu(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Fi&&t.documentElement.namespaceURI===Fi?t.createElement(e):t.createElementNS(n,e)}}function th(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function so(e){var t=fr(e);return(t.local?th:Zu)(t)}function eh(){}function Mi(e){return e==null?eh:function(){return this.querySelector(e)}}function nh(e){typeof e!="function"&&(e=Mi(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),l,c,u=0;u<o;++u)(l=s[u])&&(c=e.call(l,l.__data__,u,s))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new kt(r,this._parents)}function rh(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ih(){return[]}function oo(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=oo(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var o=t[s],a=o.length,l,c=0;c<a;++c)(l=o[c])&&(r.push(e.call(l,l.__data__,c,o)),i.push(l));return new kt(r,i)}function ao(e){return function(){return this.matches(e)}}function lo(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:lo(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:lo(e)))}function yh(e){typeof e!="function"&&(e=ao(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]=[],l,c=0;c<o;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&a.push(l);return new kt(r,this._parents)}function co(e){return new Array(e.length)}function mh(){return new kt(this._enter||this._groups.map(co),this._parents)}function pr(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}pr.prototype={constructor:pr,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,l=t.length,c=s.length;o<c;++o)(a=t[o])?(a.__data__=s[o],r[o]=a):n[o]=new pr(e,s[o]);for(;o<l;++o)(a=t[o])&&(i[o]=a)}function bh(e,t,n,r,i,s,o){var a,l,c=new Map,u=t.length,d=s.length,y=new Array(u),m;for(a=0;a<u;++a)(l=t[a])&&(y[a]=m=o.call(l,l.__data__,a,t)+"",c.has(m)?i[a]=l:c.set(m,l));for(a=0;a<d;++a)m=o.call(e,s[a],a,s)+"",(l=c.get(m))?(r[a]=l,l.__data__=s[a],c.delete(m)):n[a]=new pr(e,s[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(y[a])===l&&(i[a]=l)}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),l=new Array(s),c=0;c<s;++c){var u=r[c],d=i[c],y=d.length,m=Ih(e.call(u,u&&u.__data__,c,r)),b=m.length,A=a[c]=new Array(b),S=o[c]=new Array(b),_=l[c]=new Array(y);n(u,d,A,S,_,m,t);for(var W=0,Z=0,wt,B;W<b;++W)if(wt=A[W]){for(W>=Z&&(Z=W+1);!(B=S[Z])&&++Z<b;);wt._next=B||null}}return o=new kt(o,r),o._enter=a,o._exit=l,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(co),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),l=0;l<o;++l)for(var c=n[l],u=r[l],d=c.length,y=a[l]=new Array(d),m,b=0;b<d;++b)(m=c[b]||u[b])&&(y[b]=m);for(;l<i;++l)a[l]=n[l];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,l=i[s]=new Array(a),c,u=0;u<a;++u)(c=o[u])&&(l[u]=c);l.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=fr(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 uo(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)||uo(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 ho(e){return e.trim().split(/^|\s+/)}function Ui(e){return e.classList||new fo(e)}function fo(e){this._node=e,this._names=ho(e.getAttribute("class")||"")}fo.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 po(e,t){for(var n=Ui(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function yo(e,t){for(var n=Ui(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Qh(e){return function(){po(this,e)}}function Xh(e){return function(){yo(this,e)}}function Jh(e,t){return function(){(t.apply(this,arguments)?po:yo)(this,e)}}function Zh(e,t){var n=ho(e+"");if(arguments.length<2){for(var r=Ui(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:so(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:so(e),r=t==null?fd:typeof t=="function"?t:Mi(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 l=0,c=a.length,u;l<c;++l)for(i=0,u=a[l];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 mo(e,t,n){var r=uo(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 mo(this,e,t)}}function Nd(e,t){return function(){return mo(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 go=[null];function kt(e,t){this._groups=e,this._parents=t}function Ln(){return new kt([[document.documentElement]],go)}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]],go)}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 xi={capture:!0,passive:!1};function Ci(e){e.preventDefault(),e.stopImmediatePropagation()}function Ld(e){var t=e.document.documentElement,n=me(e).on("dragstart.drag",Ci,xi);"onselectstart"in t?n.on("selectstart.drag",Ci,xi):(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",Ci,xi),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 $i(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function _o(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Fn(){}var Mn=.7,yr=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}\\)$`),bo={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};$i(Fn,xn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:vo,formatHex:vo,formatHex8:Vd,formatHsl:zd,formatRgb:wo,toString:wo});function vo(){return this.rgb().formatHex()}function Vd(){return this.rgb().formatHex8()}function zd(){return Ao(this).formatHsl()}function wo(){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?Io(t):n===3?new Mt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?mr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?mr(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))?mr(t[1],t[2],t[3],t[4]):(t=$d.exec(e))?mr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kd.exec(e))?To(t[1],t[2]/100,t[3]/100,1):(t=Pd.exec(e))?To(t[1],t[2]/100,t[3]/100,t[4]):bo.hasOwnProperty(e)?Io(bo[e]):e==="transparent"?new Mt(NaN,NaN,NaN,0):null}function Io(e){return new Mt(e>>16&255,e>>8&255,e&255,1)}function mr(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 ki(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}$i(Mt,ki,_o(Fn,{brighter(e){return e=e==null?yr:Math.pow(yr,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),gr(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:So,formatHex:So,formatHex8:jd,formatRgb:Eo,toString:Eo}));function So(){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 Eo(){const e=gr(this.opacity);return`${e===1?"rgb(":"rgba("}${je(this.r)}, ${je(this.g)}, ${je(this.b)}${e===1?")":`, ${e})`}`}function gr(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 To(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 Ao(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,l=(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/=l<.5?s+i:2-s-i,o*=60):a=l>0&&l<1?0:o,new Jt(o,a,l,e.opacity)}function qd(e,t,n,r){return arguments.length===1?Ao(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}$i(Jt,qd,_o(Fn,{brighter(e){return e=e==null?yr:Math.pow(yr,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(Pi(e>=240?e-240:e+120,i,r),Pi(e,i,r),Pi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Jt(No(this.h),_r(this.s),_r(this.l),gr(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=gr(this.opacity);return`${e===1?"hsl(":"hsla("}${No(this.h)}, ${_r(this.s)*100}%, ${_r(this.l)*100}%${e===1?")":`, ${e})`}`}}));function No(e){return e=(e||0)%360,e<0?e+360:e}function _r(e){return Math.max(0,Math.min(1,e||0))}function Pi(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 Ro=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?Bo:function(t,n){return n-t?Wd(t,n,e):Ro(isNaN(t)?n:t)}}function Bo(e,t){var n=t-e;return n?Gd(e,n):Ro(isNaN(e)?t:e)}const Oo=(function e(t){var n=Hd(t);function r(i,s){var o=n((i=ki(i)).r,(s=ki(s)).r),a=n(i.g,s.g),l=n(i.b,s.b),c=Bo(i.opacity,s.opacity);return function(u){return i.r=o(u),i.g=a(u),i.b=l(u),i.opacity=c(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 Vi=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,zi=new RegExp(Vi.source,"g");function Kd(e){return function(){return e}}function Qd(e){return function(t){return e(t)+""}}function Xd(e,t){var n=Vi.lastIndex=zi.lastIndex=0,r,i,s,o=-1,a=[],l=[];for(e=e+"",t=t+"";(r=Vi.exec(e))&&(i=zi.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,l.push({i:o,x:De(r,i)})),n=zi.lastIndex;return n<t.length&&(s=t.slice(n),a[o]?a[o]+=s:a[++o]=s),a.length<2?l[0]?Qd(l[0].x):Kd(t):(t=l.length,function(c){for(var u=0,d;u<t;++u)a[(d=l[u]).i]=d.x(c);return a.join("")})}var Do=180/Math.PI,Lo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fo(e,t,n,r,i,s){var o,a,l;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),e*r<t*n&&(e=-e,t=-t,l=-l,o=-o),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*Do,skewX:Math.atan(l)*Do,scaleX:o,scaleY:a}}var br;function Jd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Lo:Fo(t.a,t.b,t.c,t.d,t.e,t.f)}function Zd(e){return e==null||(br||(br=document.createElementNS("http://www.w3.org/2000/svg","g")),br.setAttribute("transform",e),!(e=br.transform.baseVal.consolidate()))?Lo:(e=e.matrix,Fo(e.a,e.b,e.c,e.d,e.e,e.f))}function Mo(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function s(c,u,d,y,m,b){if(c!==d||u!==y){var A=m.push("translate(",null,t,null,n);b.push({i:A-4,x:De(c,d)},{i:A-2,x:De(u,y)})}else(d||y)&&m.push("translate("+d+t+y+n)}function o(c,u,d,y){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),y.push({i:d.push(i(d)+"rotate(",null,r)-2,x:De(c,u)})):u&&d.push(i(d)+"rotate("+u+r)}function a(c,u,d,y){c!==u?y.push({i:d.push(i(d)+"skewX(",null,r)-2,x:De(c,u)}):u&&d.push(i(d)+"skewX("+u+r)}function l(c,u,d,y,m,b){if(c!==d||u!==y){var A=m.push(i(m)+"scale(",null,",",null,")");b.push({i:A-4,x:De(c,d)},{i:A-2,x:De(u,y)})}else(d!==1||y!==1)&&m.push(i(m)+"scale("+d+","+y+")")}return function(c,u){var d=[],y=[];return c=e(c),u=e(u),s(c.translateX,c.translateY,u.translateX,u.translateY,d,y),o(c.rotate,u.rotate,d,y),a(c.skewX,u.skewX,d,y),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,d,y),c=u=null,function(m){for(var b=-1,A=y.length,S;++b<A;)d[(S=y[b]).i]=S.x(m);return d.join("")}}}var tf=Mo(Jd,"px, ","px)","deg)"),ef=Mo(Zd,", ",")",")"),nf=1e-12;function Uo(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],l=s[1],c=s[2],u=o[0],d=o[1],y=o[2],m=u-a,b=d-l,A=m*m+b*b,S,_;if(A<nf)_=Math.log(y/c)/t,S=function(R){return[a+R*m,l+R*b,c*Math.exp(t*R*_)]};else{var W=Math.sqrt(A),Z=(y*y-c*c+r*A)/(2*c*n*W),wt=(y*y-c*c-r*A)/(2*y*n*W),B=Math.log(Math.sqrt(Z*Z+1)-Z),T=Math.log(Math.sqrt(wt*wt+1)-wt);_=(T-B)/t,S=function(R){var z=R*_,q=Uo(B),J=c/(n*W)*(q*sf(t*z+B)-rf(B));return[a+J*m,l+J*b,c*q/Uo(t*z+B)]}}return S.duration=_*1e3*t/Math.SQRT2,S}return i.rho=function(s){var o=Math.max(.001,+s),a=o*o,l=a*a;return e(o,a,l)},i})(Math.SQRT2,2,4);var sn=0,Cn=0,$n=0,xo=1e3,vr,kn,wr=0,Ge=0,Ir=0,Pn=typeof performance=="object"&&performance.now?performance:Date,Co=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Yi(){return Ge||(Co(af),Ge=Pn.now()+Ir)}function af(){Ge=0}function Sr(){this._call=this._time=this._next=null}Sr.prototype=$o.prototype={constructor:Sr,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Yi():+n)+(t==null?0:+t),!this._next&&kn!==this&&(kn?kn._next=this:vr=this,kn=this),this._call=e,this._time=n,ji()},stop:function(){this._call&&(this._call=null,this._time=1/0,ji())}};function $o(e,t,n){var r=new Sr;return r.restart(e,t,n),r}function lf(){Yi(),++sn;for(var e=vr,t;e;)(t=Ge-e._time)>=0&&e._call.call(void 0,t),e=e._next;--sn}function ko(){Ge=(wr=Pn.now())+Ir,sn=Cn=0;try{lf()}finally{sn=0,uf(),Ge=0}}function cf(){var e=Pn.now(),t=e-wr;t>xo&&(Ir-=t,wr=e)}function uf(){for(var e,t=vr,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:vr=n);kn=e,ji(r)}function ji(e){if(!sn){Cn&&(Cn=clearTimeout(Cn));var t=e-Ge;t>24?(e<1/0&&(Cn=setTimeout(ko,e-Pn.now()-Ir)),$n&&($n=clearInterval($n))):($n||(wr=Pn.now(),$n=setInterval(cf,xo)),sn=1,Co(ko))}}function Po(e,t,n){var r=new Sr;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var hf=Li("start","end","cancel","interrupt"),df=[],Vo=0,zo=1,qi=2,Er=3,Yo=4,Gi=5,Tr=6;function Ar(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:Vo})}function Wi(e,t){var n=Zt(e,t);if(n.state>Vo)throw new Error("too late; already scheduled");return n}function ie(e,t){var n=Zt(e,t);if(n.state>Er)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=$o(s,0,n.time);function s(c){n.state=zo,n.timer.restart(o,n.delay,n.time),n.delay<=c&&o(c-n.delay)}function o(c){var u,d,y,m;if(n.state!==zo)return l();for(u in r)if(m=r[u],m.name===n.name){if(m.state===Er)return Po(o);m.state===Yo?(m.state=Tr,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<t&&(m.state=Tr,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(Po(function(){n.state===Er&&(n.state=Yo,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=qi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===qi){for(n.state=Er,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(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Gi,1),d=-1,y=i.length;++d<y;)i[d].call(e,u);n.state===Gi&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Tr,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function Nr(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>qi&&r.state<Gi,r.state=Tr,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(){Nr(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},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=a;break}l===c&&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 Hi(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 jo(e,t){var n;return(typeof t=="number"?De:t instanceof xn?Oo:(n=xn(t))?(t=n,Oo):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),l;return a==null?void this.removeAttribute(e):(o=this.getAttribute(e),l=a+"",o===l?null:o===r&&l===i?s:(i=l,s=t(r=o,a)))}}function Sf(e,t,n){var r,i,s;return function(){var o,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),l=a+"",o===l?null:o===r&&l===i?s:(i=l,s=t(r=o,a)))}}function Ef(e,t){var n=fr(e),r=n==="transform"?ef:jo;return this.attrTween(e,typeof t=="function"?(n.local?Sf:If)(n,r,Hi(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=fr(e);return this.tween(n,(r.local?Nf:Rf)(r,t))}function Of(e,t){return function(){Wi(this,e).delay=+t.apply(this,arguments)}}function Df(e,t){return t=+t,function(){Wi(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=ao(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]=[],l,c=0;c<o;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&a.push(l);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 l=t[a],c=n[a],u=l.length,d=o[a]=new Array(u),y,m=0;m<u;++m)(y=l[m]||c[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)?Wi: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=Mi(e));for(var r=this._groups,i=r.length,s=new Array(i),o=0;o<i;++o)for(var a=r[o],l=a.length,c=s[o]=new Array(l),u,d,y=0;y<l;++y)(u=a[y])&&(d=e.call(u,u.__data__,y,a))&&("__data__"in u&&(d.__data__=u.__data__),c[y]=d,Ar(c[y],t,n,y,c,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=oo(e));for(var r=this._groups,i=r.length,s=[],o=[],a=0;a<i;++a)for(var l=r[a],c=l.length,u,d=0;d<c;++d)if(u=l[d]){for(var y=e.call(u,u.__data__,d,l),m,b=Zt(u,n),A=0,S=y.length;A<S;++A)(m=y[A])&&Ar(m,t,n,A,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 qo(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),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),nn(this,e))),o===l?null:o===r&&l===i?s:(i=l,s=t(r=o,a))}}function tp(e,t){var n,r,i,s="style."+t,o="end."+s,a;return function(){var l=ie(this,e),c=l.on,u=l.value[s]==null?a||(a=qo(t)):void 0;(c!==n||i!==u)&&(r=(n=c).copy()).on(o,i=u),l.on=r}}function ep(e,t,n){var r=(e+="")=="transform"?tf:jo;return t==null?this.styleTween(e,Xf(e,r)).on("end.style."+e,qo(e)):typeof t=="function"?this.styleTween(e,Zf(e,r,Hi(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(Hi(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=Go(),r=this._groups,i=r.length,s=0;s<i;++s)for(var o=r[s],a=o.length,l,c=0;c<a;++c)if(l=o[c]){var u=Zt(l,t);Ar(l,e,n,c,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},l={value:function(){--i===0&&s()}};n.each(function(){var c=ie(this,r),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.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 Go(){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=Go(),(n=yp).time=Yi(),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,l,c=0;c<a;++c)(l=o[c])&&Ar(l,e,t,c,o,n||mp(l,t));return new ge(r,this._parents,e,t)}Ln.prototype.interrupt=pf,Ln.prototype.transition=gp;const Rr=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 Br=new be(1,0,0);be.prototype;function Ki(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 Wo(){return this.__zoom||Br}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,l=of,c=Li("start","zoom","end"),u,d,y,m=500,b=150,A=0,S=10;function _(g){g.property("__zoom",Wo).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",J).filter(i).on("touchstart.zoom",lt).on("touchmove.zoom",_t).on("touchend.zoom touchcancel.zoom",Tt).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(g,I,h,v){var w=g.selection?g.selection():g;w.property("__zoom",Wo),g!==w?B(g,I,h,v):w.interrupt().each(function(){T(this,arguments).event(v).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},_.scaleBy=function(g,I,h,v){_.scaleTo(g,function(){var w=this.__zoom.k,E=typeof I=="function"?I.apply(this,arguments):I;return w*E},h,v)},_.scaleTo=function(g,I,h,v){_.transform(g,function(){var w=t.apply(this,arguments),E=this.__zoom,N=h==null?wt(w):typeof h=="function"?h.apply(this,arguments):h,D=E.invert(N),H=typeof I=="function"?I.apply(this,arguments):I;return n(Z(W(E,H),N,D),w,o)},h,v)},_.translateBy=function(g,I,h,v){_.transform(g,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof h=="function"?h.apply(this,arguments):h),t.apply(this,arguments),o)},null,v)},_.translateTo=function(g,I,h,v,w){_.transform(g,function(){var E=t.apply(this,arguments),N=this.__zoom,D=v==null?wt(E):typeof v=="function"?v.apply(this,arguments):v;return n(Br.translate(D[0],D[1]).scale(N.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof h=="function"?-h.apply(this,arguments):-h),E,o)},v,w)};function W(g,I){return I=Math.max(s[0],Math.min(s[1],I)),I===g.k?g:new be(I,g.x,g.y)}function Z(g,I,h){var v=I[0]-h[0]*g.k,w=I[1]-h[1]*g.k;return v===g.x&&w===g.y?g:new be(g.k,v,w)}function wt(g){return[(+g[0][0]+ +g[1][0])/2,(+g[0][1]+ +g[1][1])/2]}function B(g,I,h,v){g.on("start.zoom",function(){T(this,arguments).event(v).start()}).on("interrupt.zoom end.zoom",function(){T(this,arguments).event(v).end()}).tween("zoom",function(){var w=this,E=arguments,N=T(w,E).event(v),D=t.apply(w,E),H=h==null?wt(D):typeof h=="function"?h.apply(w,E):h,dt=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),tt=w.__zoom,ct=typeof I=="function"?I.apply(w,E):I,vt=l(tt.invert(H).concat(dt/tt.k),ct.invert(H).concat(dt/ct.k));return function(nt){if(nt===1)nt=ct;else{var yt=vt(nt),Bt=dt/yt[2];nt=new be(Bt,H[0]-yt[0]*Bt,H[1]-yt[1]*Bt)}N.zoom(null,nt)}})}function T(g,I,h){return!h&&g.__zooming||new R(g,I)}function R(g,I){this.that=g,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(g,I),this.taps=0}R.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,I){return this.mouse&&g!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&g!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&g!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(g){var I=me(this.that).datum();c.call(g,this.that,new _p(g,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:c}),I)}};function z(g,...I){if(!e.apply(this,arguments))return;var h=T(this,I).event(g),v=this.__zoom,w=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===w)return;h.mouse=[E,v.invert(E)],Nr(this),h.start()}Vn(g),h.wheel=setTimeout(N,b),h.zoom("mouse",n(Z(W(v,w),h.mouse[0],h.mouse[1]),h.extent,o));function N(){h.wheel=null,h.end()}}function q(g,...I){if(y||!e.apply(this,arguments))return;var h=g.currentTarget,v=T(this,I,!0).event(g),w=me(g.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",dt,!0),E=Oe(g,h),N=g.clientX,D=g.clientY;Ld(g.view),Ki(g),v.mouse=[E,this.__zoom.invert(E)],Nr(this),v.start();function H(tt){if(Vn(tt),!v.moved){var ct=tt.clientX-N,vt=tt.clientY-D;v.moved=ct*ct+vt*vt>A}v.event(tt).zoom("mouse",n(Z(v.that.__zoom,v.mouse[0]=Oe(tt,h),v.mouse[1]),v.extent,o))}function dt(tt){w.on("mousemove.zoom mouseup.zoom",null),Fd(tt.view,v.moved),Vn(tt),v.event(tt).end()}}function J(g,...I){if(e.apply(this,arguments)){var h=this.__zoom,v=Oe(g.changedTouches?g.changedTouches[0]:g,this),w=h.invert(v),E=h.k*(g.shiftKey?.5:2),N=n(Z(W(h,E),v,w),t.apply(this,I),o);Vn(g),a>0?me(this).transition().duration(a).call(B,N,v,g):me(this).call(_.transform,N,v,g)}}function lt(g,...I){if(e.apply(this,arguments)){var h=g.touches,v=h.length,w=T(this,I,g.changedTouches.length===v).event(g),E,N,D,H;for(Ki(g),N=0;N<v;++N)D=h[N],H=Oe(D,this),H=[H,this.__zoom.invert(H),D.identifier],w.touch0?!w.touch1&&w.touch0[2]!==H[2]&&(w.touch1=H,w.taps=0):(w.touch0=H,E=!0,w.taps=1+!!u);u&&(u=clearTimeout(u)),E&&(w.taps<2&&(d=H[0],u=setTimeout(function(){u=null},m)),Nr(this),w.start())}}function _t(g,...I){if(this.__zooming){var h=T(this,I).event(g),v=g.changedTouches,w=v.length,E,N,D,H;for(Vn(g),E=0;E<w;++E)N=v[E],D=Oe(N,this),h.touch0&&h.touch0[2]===N.identifier?h.touch0[0]=D:h.touch1&&h.touch1[2]===N.identifier&&(h.touch1[0]=D);if(N=h.that.__zoom,h.touch1){var dt=h.touch0[0],tt=h.touch0[1],ct=h.touch1[0],vt=h.touch1[1],nt=(nt=ct[0]-dt[0])*nt+(nt=ct[1]-dt[1])*nt,yt=(yt=vt[0]-tt[0])*yt+(yt=vt[1]-tt[1])*yt;N=W(N,Math.sqrt(nt/yt)),D=[(dt[0]+ct[0])/2,(dt[1]+ct[1])/2],H=[(tt[0]+vt[0])/2,(tt[1]+vt[1])/2]}else if(h.touch0)D=h.touch0[0],H=h.touch0[1];else return;h.zoom("touch",n(Z(N,D,H),h.extent,o))}}function Tt(g,...I){if(this.__zooming){var h=T(this,I).event(g),v=g.changedTouches,w=v.length,E,N;for(Ki(g),y&&clearTimeout(y),y=setTimeout(function(){y=null},m),E=0;E<w;++E)N=v[E],h.touch0&&h.touch0[2]===N.identifier?delete h.touch0:h.touch1&&h.touch1[2]===N.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&&(N=Oe(N,this),Math.hypot(d[0]-N[0],d[1]-N[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:Rr(+g),_):r},_.filter=function(g){return arguments.length?(e=typeof g=="function"?g:Rr(!!g),_):e},_.touchable=function(g){return arguments.length?(i=typeof g=="function"?g:Rr(!!g),_):i},_.extent=function(g){return arguments.length?(t=typeof g=="function"?g:Rr([[+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?(l=g,_):l},_.on=function(){var g=c.on.apply(c,arguments);return g===c?_:g},_.clickDistance=function(g){return arguments.length?(A=(g=+g)*g,_):Math.sqrt(A)},_.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,l=null,c=null,u=[],d=null,y=null,m=null,b=0,A=0,S=1;function _(h){if(!h||h.length<7)return[1,0,0];const v=parseInt(h.slice(1,3),16)/255,w=parseInt(h.slice(3,5),16)/255,E=parseInt(h.slice(5,7),16)/255;return[v,w,E].some(Number.isNaN)?[1,0,0]:[v,w,E]}const W=(h,v,w)=>h+(v-h)*w;function Z(h,v){const w=h.parentElement;w&&(S=window.devicePixelRatio||1,b=w.clientWidth||800,A=w.clientHeight||400,h.style.width=`${b}px`,h.style.height=`${A}px`,h.width=Math.round(b*S),h.height=Math.round(A*S),v.viewport(0,0,h.width,h.height))}function wt(h,v,w,E,N){if(!w)return{x:0,y:0};const D=h/E*2,H=-(v/N*2),dt=n.metaData?.row_groups?.[0]?.columns?.[0]?.meta_data?.statistics,tt=2/Math.max(1e-9,(dt?.max_value??1)-(dt?.min_value??-1)),ct=w.x/E*2-1,vt=-w.y/N*2+1,nt=w.k*tt,yt=(D-ct-1)/nt,Bt=(H-vt+1)/nt;return{x:yt,y:Bt}}function B(h,v,w,E,N,D){if(!h.length||!E)return null;const H=wt(v,w,E,N,D);let dt=1/0,tt=null;for(const ct of h){const vt=ct.x-H.x,nt=ct.y-H.y,yt=Math.hypot(vt,nt),Bt=3/(E.k/2);yt<dt&&yt<Bt&&(dt=yt,tt=ct)}return tt&&o.value&&(o.value.innerHTML=`
15
- Mouse: (${v.toFixed(2)}, ${w.toFixed(2)})<br/>
16
- Data: (${H.x.toFixed(2)}, ${H.y.toFixed(2)})<br/>
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
17
  Scale: ${E.k.toFixed(2)}
18
- `),tt}function T(h,v,w,E,N){const D=_(w),H=_(E),dt=_(N),tt=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(_),ct=new Map,vt=[];for(let nt=0;nt<n.data.length;nt++){const yt=n.data[nt],Bt=yt[0],en=yt[1],En=Math.round(Math.sqrt(Bt*Bt+en*en)*10)/10;ct.has(yt[5])||ct.set(yt[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],H[0],Tn),W(D[1],H[1],Tn),W(D[2],H[2],Tn)];break}case"single":Re=[...dt];break;case"Type":Re=[...ct.get(yt[5])||[1,1,1]];break;default:Re=[Math.random(),Math.random(),Math.random()]}vt.push({x:Bt,y:en,rawX:Bt,rawY:en,color:Re,id:nt,species:yt[4],value:En,label:`Point ${nt+1}: (${parseFloat(Bt).toFixed(2)}, ${parseFloat(en).toFixed(2)})`,category:En<25?"Near":En<50?"Medium":"Far"})}return vt}function R(h){const v={preserveDrawingBuffer:!0,antialias:!0,alpha:!0},w=h.getContext("webgl",v)||h.getContext("experimental-webgl",v);return w?(w.clearColor(0,0,0,1),w.enable(w.BLEND),w.blendFunc(w.SRC_ALPHA,w.ONE_MINUS_SRC_ALPHA),w.disable(w.DEPTH_TEST),w):(console.error("WebGL not supported"),null)}function z(h,v,w){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 N=h.createShader(h.FRAGMENT_SHADER);if(h.shaderSource(N,w),h.compileShader(N),!h.getShaderParameter(N,h.COMPILE_STATUS))return console.error("Fragment shader error:",h.getShaderInfoLog(N)),null;const D=h.createProgram();return h.attachShader(D,E),h.attachShader(D,N),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 q(h,v,w){if(!w.length)return null;const E=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,E);const N=new Float32Array(w.flatMap(nt=>[nt.x,nt.y]));h.bufferData(h.ARRAY_BUFFER,N,h.STATIC_DRAW);const D=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,D);const H=new Float32Array(w.flatMap(nt=>nt.color));h.bufferData(h.ARRAY_BUFFER,H,h.STATIC_DRAW);const dt=h.getAttribLocation(v,"a_position"),tt=h.getAttribLocation(v,"a_color"),ct=h.getUniformLocation(v,"u_viewMatrix"),vt=h.getUniformLocation(v,"u_pointSize");return dt===-1||tt===-1||!ct||!vt?(console.error("Failed to lookup attrib/uniform locations"),null):{program:v,positionBuffer:E,colorBuffer:D,positionAttributeLocation:dt,colorAttributeLocation:tt,viewMatrixLocation:ct,pointSizeLocation:vt,count:w.length}}function J(h,v,w,E,N=null){if(!h||!v||!w)return;const{program:D,positionBuffer:H,colorBuffer:dt,positionAttributeLocation:tt,colorAttributeLocation:ct,viewMatrixLocation:vt,pointSizeLocation:nt,count:yt}=v;h.clearColor(0,0,0,1),h.clear(h.COLOR_BUFFER_BIT),h.useProgram(D),h.enableVertexAttribArray(tt),h.bindBuffer(h.ARRAY_BUFFER,H),h.vertexAttribPointer(tt,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(ct),h.bindBuffer(h.ARRAY_BUFFER,dt),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),Y_=(Tn+uu)/2,j_=(hu+du)/2,q_=Math.max(1e-9,uu-Tn),G_=Math.max(1e-9,du-hu),W_=2/Math.max(q_,G_),H_=w.x/Bt*2-1,K_=-w.y/en*2+1,Oi=w.k*W_,Q_=H_-Oi*Y_,X_=K_-Oi*j_,J_=new Float32Array([Oi,0,0,0,0,Oi,0,0,0,0,1,0,Q_,X_,0,1]);if(h.uniformMatrix4fv(vt,!1,J_),h.uniform1f(nt,E*Math.sqrt(w.k)*S),h.enable(h.BLEND),h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA),h.drawArrays(h.POINTS,0,yt),N){const fu=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,fu),h.bufferData(h.ARRAY_BUFFER,new Float32Array([N.x,N.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(w.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(w.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=R(i.value),!a)||(Z(i.value,a),l=z(a,`
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,`
19
19
  attribute vec2 a_position;
20
20
  attribute vec3 a_color;
21
21
  uniform mat4 u_viewMatrix;
@@ -38,12 +38,12 @@
38
38
  }
39
39
  gl_FragColor = vec4(v_color, alpha);
40
40
  }
41
- `),!l)||(a.useProgram(l),u=T(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),c=q(a,l,u),c&&(d=Br.translate(b/2,A/2).scale(1),y=Ep().scaleExtent([.1,100]).on("zoom",h=>{if(d=h.transform,J(a,c,d,2,m),o.value){const[v,w]=Oe(h,i.value),E=wt(v,w,d,b,A);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(()=>J(a,c,d,2,null)),_t()))}function _t(){!i.value||!s.value||(i.value.addEventListener("mousemove",Tt),i.value.addEventListener("mouseleave",g))}function Tt(h){if(!i.value)return;const v=i.value.getBoundingClientRect(),w=h.clientX-v.left,E=h.clientY-v.top,N=B(u,w,E,d,b,A);if(N){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>${N.label}</strong><br/>
43
- Species: ${N.species}<br/>
44
- Distance: ${N.value.toFixed(2)}<br/>
45
- Category: ${N.category}
46
- `,m=N,J(a,c,d,2,m)}else s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,J(a,c,d,2,null))}function g(){s.value&&(s.value.style.opacity="0"),m!==null&&(m=null,J(a,c,d,2,null))}function I(){!i.value||!a||(Z(i.value,a),J(a,c,d,2,m))}return f.watch(()=>n.forceRegenerate,()=>{!a||!l||(u=T(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),c&&(a.deleteBuffer(c.positionBuffer),a.deleteBuffer(c.colorBuffer)),c=q(a,l,u),d=Br,i.value&&y&&me(i.value).call(y.transform,d),J(a,c,d,2,null))}),f.watch(()=>n.data,()=>{lt()}),f.watch(()=>n.colorMode,()=>{if(!a||!c||!u.length)return;let h=0;const v=n.metaData?.schema||[];for(let N=0;N<v.length;N++)if(v[N].name===n.colorMode){h=N-1;break}const w=new Float32Array(n.data.flatMap(N=>n.colorMap.get(N[h])));a.deleteBuffer(c.colorBuffer);const E=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,E),a.bufferData(a.ARRAY_BUFFER,w,a.STATIC_DRAW),c.colorBuffer=E,J(a,c,d,2,m)}),f.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],()=>{if(["species","sex"].includes(n.colorMode)||!a||!c)return;u=T(n.pointCount,n.colorMode,n.startColor,n.endColor,n.singleColor),a.deleteBuffer(c.colorBuffer);const h=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,h);const v=new Float32Array(u.flatMap(w=>w.color));a.bufferData(a.ARRAY_BUFFER,v,a.STATIC_DRAW),c.colorBuffer=h,J(a,c,d,2,m)}),f.watch(()=>n.pointCount,h=>{!a||!l||Math.abs(h-u.length)<=10||(u=T(h,n.colorMode,n.startColor,n.endColor,n.singleColor),c&&(a.deleteBuffer(c.positionBuffer),a.deleteBuffer(c.colorBuffer)),c=q(a,l,u),J(a,c,d,2,null))}),f.onMounted(()=>{window.addEventListener("resize",I)}),f.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",Tt),i.value.removeEventListener("mouseleave",g)),window.removeEventListener("resize",I),a&&c&&(a.deleteBuffer(c.positionBuffer),a.deleteBuffer(c.colorBuffer),l&&a.deleteProgram(l))}),(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),l=f.ref(n.singleColor);function c(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",l.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=>{l.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],A)=>(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:c(m[1])})},null,4),f.createElementVNode("div",Lp,f.toDisplayString(m[0]),1)]))),128))])])]))}}),Mp=Dn(Fp,[["__scopeId","data-v-0a5cce16"]]),Ho=["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"],Ko=["DATA_PAGE","INDEX_PAGE","DICTIONARY_PAGE","DATA_PAGE_V2"],Qo={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 Xo(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 Jo(e,r)}function Jo(e,t){const{element:n,parsers:r,utf8:i=!0}=t,{type:s,converted_type:o,logical_type:a}=n;if(o==="DECIMAL"){const l=10**-(n.scale||0),c=new Array(e.length);for(let u=0;u<c.length;u++)e[0]instanceof Uint8Array?c[u]=Zo(e[u])*l:c[u]=Number(e[u])*l;return c}if(!o&&s==="INT96"){const l=new Array(e.length);for(let c=0;c<l.length;c++)l[c]=r.timestampFromNanoseconds($p(e[c]));return l}if(o==="DATE"){const l=new Array(e.length);for(let c=0;c<l.length;c++)l[c]=r.dateFromDays(e[c]);return l}if(o==="TIMESTAMP_MILLIS"){const l=new Array(e.length);for(let c=0;c<l.length;c++)l[c]=r.timestampFromMilliseconds(e[c]);return l}if(o==="TIMESTAMP_MICROS"){const l=new Array(e.length);for(let c=0;c<l.length;c++)l[c]=r.timestampFromMicroseconds(e[c]);return l}if(o==="JSON"){const l=new TextDecoder;return e.map(c=>JSON.parse(l.decode(c)))}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 l=new TextDecoder,c=new Array(e.length);for(let u=0;u<c.length;u++)c[u]=e[u]&&l.decode(e[u]);return c}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 l=new BigUint64Array(e.length);for(let c=0;c<l.length;c++)l[c]=BigInt(e[c]);return l}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 l=new Uint32Array(e.length);for(let c=0;c<l.length;c++)l[c]=e[c];return l}if(a?.type==="FLOAT16")return Array.from(e).map(ta);if(a?.type==="TIMESTAMP"){const{unit:l}=a;let c=r.timestampFromMilliseconds;l==="MICROS"&&(c=r.timestampFromMicroseconds),l==="NANOS"&&(c=r.timestampFromNanoseconds);const u=new Array(e.length);for(let d=0;d<u.length;d++)u[d]=c(e[d]);return u}return e}function Zo(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 ta(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 ea(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=ea(e,t+s,[...n,o.name]);s+=a.count,i.push(a)}return{count:s,element:r,children:i,path:n}}function na(e,t){let n=ea(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 ra(e){let t=0;for(const{element:n}of e)n.repetition_type==="REPEATED"&&t++;return t}function Qi(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 ia(e){let t=0;const n={};for(;e.offset<e.view.byteLength;){const[r,i,s]=oa(e,t);if(t=s,r===At.STOP)break;n[`field_${i}`]=Or(e,r)}return n}function Or(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 Xi(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?Or(e,At.BYTE)===1:Or(e,n);return s}case At.STRUCT:{const n={};let r=0;for(;;){let i,s;if([i,s,r]=oa(e,r),i===At.STOP)break;n[`field_${s}`]=Or(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 Xi(e){const t=zp(e);return t>>1n^-(t&1n)}function sa(e){return e&15}function oa(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[sa(n),i,i]}function jp(e){const t=e.view.getUint8(e.offset++),n=t>>4,r=sa(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,l=await e.slice(a,r),c=new ArrayBuffer(o+8),u=new Uint8Array(c);return u.set(new Uint8Array(l)),u.set(new Uint8Array(i),r-a),Ji(c,{parsers:t})}else return Ji(i,{parsers:t})}function Ji(e,{parsers:t}={}){if(!(e instanceof ArrayBuffer))throw new Error("parquet expected ArrayBuffer");const n=new DataView(e);if(t={...Qo,...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=ia({view:n,offset:s}),a=new TextDecoder;function l(S){return S&&a.decode(S)}const c=o.field_1,u=o.field_2.map(S=>({type:Ho[S.field_1],type_length:S.field_2,repetition_type:Up[S.field_3],name:l(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:l(_.field_1),file_offset:_.field_2,meta_data:_.field_3&&{type:Ho[_.field_3.field_1],encodings:_.field_3.field_2?.map(Z=>We[Z]),path_in_schema:_.field_3.field_3.map(l),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:Ko[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:l(S.field_1),value:l(S.field_2)})),A=l(o.field_6);return{version:c,schema:u,num_rows:y,row_groups:m,key_value_metadata:b,created_by:A,metadata_length:i}}function Wp({schema:e}){return na(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:aa(e.field_7.field_2)}:e?.field_8?{type:"TIMESTAMP",isAdjustedToUTC:e.field_8.field_1,unit:aa(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 aa(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:Dr(e.field_1,t,n),min:Dr(e.field_2,t,n),null_count:e.field_3,distinct_count:e.field_4,max_value:Dr(e.field_5,t,n),min_value:Dr(e.field_6,t,n),is_max_value_exact:e.field_7,is_min_value_exact:e.field_8}}function Dr(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"?Zo(e)*10**-(t.scale||0):s?.type==="FLOAT16"?ta(e):e}function Zi(e,t){for(let n=0;n<t.length;n+=1e4)e.push(...t.slice(n,n+1e4))}function la(e){if(!e)return[];if(e.length===1)return e[0];const t=[];for(const n of e)Zi(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 l=Number(a.num_rows),c=o+l;if(l>0&&c>=t&&o<n){const u=[];for(const{file_path:b,meta_data:A}of a.columns){if(b)throw new Error("parquet file_path not supported");if(!A)throw new Error("parquet column metadata is undefined");(!r||r.includes(A.path_in_schema[0]))&&u.push(ca(A))}const d=Math.max(t-o,0),y=Math.min(n-o,l);i.push({ranges:u,rowGroup:a,groupStart:o,groupRows:l,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)Zi(s,u);else if(r?.length)throw new Error(`parquet columns not found: ${r.join(", ")}`)}o=c}return isFinite(n)||(n=o),{metadata:e,rowStart:t,rowEnd:n,columns:r,fetches:s,groups:i}}function ca({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(l=>l.slice(o,a)):n[s].slice(o,a)}else return n[s]}}}function ua(e,t,n,r,i){const s=t?.length||n.length;if(!s)return r;const o=Qi(i),a=i.map(({element:b})=>b.repetition_type);let l=0;const c=[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),c.push(u),y++),a[d]==="REPEATED"&&m++;for(let b=0;b<s;b++){const A=t?.length?t[b]:o,S=n[b];for(;d&&(S<m||a[d]!=="REPEATED");)a[d]!=="REQUIRED"&&(c.pop(),y--),a[d]==="REPEATED"&&m--,d--;for(u=c.at(-1);(d<a.length-2||a[d+1]==="REPEATED")&&(y<A||a[d+1]==="REQUIRED");){if(d++,a[d]!=="REQUIRED"){const _=[];u.push(_),u=_,c.push(_),y++}a[d]==="REPEATED"&&m++}A===o?u.push(r[l++]):d===a.length-2?u.push(null):u.push([])}if(!e.length)for(let b=0;b<o;b++){const A=[];u.push(A),u=A}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 l=o.path.join("."),c=e.get(l);if(!c)throw new Error("parquet list column missing values");i&&Lr(c,n),e.set(r,c),e.delete(l);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`),l=e.get(`${r}.${o}.value`);if(!a)throw new Error("parquet map column missing keys");if(!l)throw new Error("parquet map column missing values");if(a.length!==l.length)throw new Error("parquet map column key/value length mismatch");const c=ha(a,l,s);i&&Lr(c,n),e.delete(`${r}.${o}.key`),e.delete(`${r}.${o}.value`),e.set(r,c);return}if(t.children.length){const o=t.element.repetition_type==="REQUIRED"?n:n+1,a={};for(const c of t.children){zn(e,c,o);const u=e.get(c.path.join("."));if(!u)throw new Error("parquet struct missing child data");a[c.element.name]=u}for(const c of t.children)e.delete(c.path.join("."));const l=da(a,o);i&&Lr(l,n),e.set(r,l)}}function Lr(e,t){for(let n=0;n<e.length;n++)t?Lr(e[n],t-1):e[n]=e[n][0]}function ha(e,t,n){const r=[];for(let i=0;i<e.length;i++)if(n)r.push(ha(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 da(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(da(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=Xi(e),a=0;n[a++]=r?Number(o):o;const l=i/s;for(;a<t;){const c=Xi(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=l;const A=(1n<<y)-1n;for(;b&&a<t;){let S=BigInt(e.view.getUint8(e.offset))>>m&A;for(m+=y;m>=8;)m-=8n,e.offset++,m&&(S|=BigInt(e.view.getUint8(e.offset))<<y-m&A);const _=c+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<l&&a<t;m++)o+=c,n[a++]=r?Number(o):o}}}function fa(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 Fr(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 l=8,c=0;for(;s;)c>8?(c-=8,l-=8,a>>>=8):l-c<n?(a|=e.view.getUint8(e.offset)<<l,e.offset++,l+=8):(i<r.length&&(r[i++]=a>>c&o),s--,c+=n);return i}function pa(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 ts(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(Mr(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(Mr(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(Mr(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(Mr(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 Mr(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 ya(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 l=(o>>>2)+1;if(l>60){if(i+3>=n)throw new Error("snappy error literal pos + 3 >= inputLength");const c=l-60;l=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),l=(l&hy[c])+1,i+=c}if(i+l>n)throw new Error("snappy error literal exceeds input length");ya(e,i,t,s,l),i+=l,s+=l}else{let l=0;switch(o&3){case 1:a=(o>>>2&7)+4,l=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,l=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,l=e[i]+(e[i+1]<<8)+(e[i+2]<<16)+(e[i+3]<<24),i+=4;break}if(l===0||isNaN(l))throw new Error(`invalid offset ${l} pos ${i} inputLength ${n}`);if(l>s)throw new Error("cannot copy from before start of buffer");ya(t,s-l,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 l=py(o,t,i),{definitionLevels:c,numNulls:u}=yy(o,t,i),d=t.num_values-u;if(t.encoding==="PLAIN")a=ts(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=pa(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),fa(o,d,a);else throw new Error(`parquet unsupported encoding: ${t.encoding}`);return{definitionLevels:c,repetitionLevels:l,dataPage:a}}function py(e,t,n){if(n.length>1){const r=ra(n);if(r){const i=new Array(t.num_values);return Le(e,Fr(r),i),i}}return[]}function yy(e,t,n){const r=Qi(n);if(!r)return{definitionLevels:[],numNulls:0};const i=new Array(t.num_values);Le(e,Fr(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 es(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:l}=n,c=t.data_page_header_v2;if(!c)throw new Error("parquet data page header v2 is undefined");const u=gy(r,c,o);r.offset=c.repetition_levels_byte_length;const d=_y(r,c,o),y=t.uncompressed_page_size-c.definition_levels_byte_length-c.repetition_levels_byte_length;let m=e.subarray(r.offset);c.is_compressed!==!1&&(m=es(m,y,a,l));const b=new DataView(m.buffer,m.byteOffset,m.byteLength),A={view:b,offset:0};let S;const _=c.num_values-c.num_nulls;if(c.encoding==="PLAIN")S=ts(A,i,_,s.type_length);else if(c.encoding==="RLE")S=new Array(_),Le(A,1,S),S=S.map(W=>!!W);else if(c.encoding==="PLAIN_DICTIONARY"||c.encoding==="RLE_DICTIONARY"){const W=b.getUint8(A.offset++);S=new Array(_),Le(A,W,S,y-1)}else if(c.encoding==="DELTA_BINARY_PACKED")S=i==="INT32"?new Int32Array(_):new BigInt64Array(_),Yn(A,_,S);else if(c.encoding==="DELTA_LENGTH_BYTE_ARRAY")S=new Array(_),fa(A,_,S);else if(c.encoding==="DELTA_BYTE_ARRAY")S=new Array(_),Zp(A,_,S);else if(c.encoding==="BYTE_STREAM_SPLIT")S=pa(r,_,i,s.type_length);else throw new Error(`parquet unsupported encoding: ${c.encoding}`);return{definitionLevels:d,repetitionLevels:u,dataPage:S}}function gy(e,t,n){const r=ra(n);if(!r)return[];const i=new Array(t.num_values);return Le(e,Fr(r),i,t.repetition_levels_byte_length),i}function _y(e,t,n){const r=Qi(n);if(r){const i=new Array(t.num_values);return Le(e,Fr(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 l,c,u=0;const d=s&&(()=>{c&&s({columnName:o,columnData:c,rowStart:t+u-c.length,rowEnd:t+u})});for(;u<r&&!(e.offset>=e.view.byteLength-1);){const y=vy(e);if(y.type==="DICTIONARY_PAGE")l=ma(e,y,i,l,void 0,0),l=Jo(l,i);else{const m=c?.length||0,b=ma(e,y,i,l,c,n-u);c===b?u+=b.length-m:(d?.(),a.push(b),u+=b.length,c=b)}}return d?.(),u>r&&c&&(a[a.length-1]=c.slice(0,r-(u-c.length))),a}function ma(e,t,n,r,i,s){const{type:o,element:a,schemaPath:l,codec:c,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(l))return new Array(y.num_values);const m=es(d,Number(t.uncompressed_page_size),c,u),{definitionLevels:b,repetitionLevels:A,dataPage:S}=fy(m,y,n);let _=Xo(S,r,y.encoding,n);if(A.length||b?.length){const W=Array.isArray(i)?i:[];return ua(W,b,A,_,l)}else{for(let W=2;W<l.length;W++)l[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:A}=my(d,t,n),S=Xo(A,r,y.encoding,n),_=Array.isArray(i)?i:[];return ua(_,m,b,S,l)}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=es(d,Number(t.uncompressed_page_size),c,u),b={view:new DataView(m.buffer,m.byteOffset,m.byteLength),offset:0};return ts(b,o,y.num_values,a.type_length)}else throw new Error(`parquet unsupported page type: ${t.type}`)}function vy(e){const t=ia(e),n=Ko[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,l=t.field_7&&{num_values:t.field_7.field_1,encoding:We[t.field_7.field_2],is_sorted:t.field_7.field_3},c=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:l,data_page_header_v2:c}}function wy(e,{metadata:t,columns:n},r){const{file:i,compressors:s,utf8:o}=e,a=[],l={...Qo,...e.parsers};for(const{file_path:c,meta_data:u}of r.rowGroup.columns){if(c)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}=ca(u),b=m-y;if(b>1<<30){console.warn(`parquet skipping huge column "${u.path_in_schema}" ${b} bytes`);continue}const A=Promise.resolve(i.slice(y,m));a.push({pathInSchema:u.path_in_schema,data:A.then(S=>{const _=na(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:l,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(la))),a=e.map(u=>u.pathInSchema[0]).filter(u=>!r||r.includes(u)),l=r??a,c=l.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<l.length;y++)c[y]>=0&&(d[y]=o[c[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(l=>l.pathInSchema[0]===i.element.name);if(!s.length)continue;const o=new Map,a=Promise.all(s.map(l=>l.data.then(c=>{o.set(l.pathInSchema.join("."),la(c))}))).then(()=>{zn(o,i);const l=o.get(i.path.join("."));if(!l)throw new Error("parquet column data not assembled");return[l]});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 l=Wp(e.metadata),c=t.map(u=>Sy(u,l));if(s)for(const u of c)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 c){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);Zi(u,b.slice(y,m))}o(u)}else for(const{asyncColumns:u}of c)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),l=f.ref(0),c=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:T,srcFileType:R,srcFileId:z,pkgId:q,pkgType:J,apiUrl:lt})=>{try{if(u.value=void 0,d.value=void 0,T){const g=R??(T.toLowerCase().endsWith(".csv")?"csv":"parquet");await _(T,g,z);return}if(!q||!lt)return;await A(q,lt);const _t=b.value?.[0]?.content?.id;if(!_t){console.error("[UMAP Wrapper] No files returned from /view");return}const Tt=await S(q,_t,lt);await _(Tt,J==="CSV"?"csv":"parquet",_t)}catch(_t){console.error("[UMAP Wrapper] Load failed:",_t?.message||_t)}},{immediate:!0});async function A(T,R){const z=await hr(),q=`${R}/packages/${T}/view?api_key=${z}`,J=await fetch(q);if(!J.ok)throw new Error(`view failed: ${J.status}`);b.value=await J.json()}async function S(T,R,z){const q=await hr(),J=`${z}/packages/${T}/files/${R}?api_key=${q}`,lt=await fetch(J);if(!lt.ok)throw new Error(`file url failed: ${lt.status}`);return(await lt.json()).url}async function _(T,R,z){if(R==="csv")throw new Error("CSV not yet supported by UMAP wrapper. Provide a Parquet file.");const q=await fetch(T);if(!q.ok)throw new Error(`fetch failed: ${q.status}`);const J=await q.arrayBuffer();await Ey({file:J,onComplete:lt=>{d.value=Ji(J);try{const _t=d.value?.key_value_metadata?.[0];_t?.key&&(r.value=_t.key)}catch{}u.value=lt}}),wt()}function W(){a.value=!a.value,l.value++}function Z(T){try{if(!T||T.length<7)return[1,0,0];const R=parseInt(T.slice(1,3),16)/255,z=parseInt(T.slice(3,5),16)/255,q=parseInt(T.slice(5,7),16)/255;return Number.isNaN(R)||Number.isNaN(z)||Number.isNaN(q)?[1,0,0]:[R,z,q]}catch{return[1,0,0]}}function wt(){if(!d.value)return;const T=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"].map(Z),R=d.value.key_value_metadata||[];for(let z=0;z<R.length-1;z++){const q=R[z].key,J=JSON.parse(R[z].value);let lt=new Map,_t=0;for(const Tt of J)lt.set(Tt,T[_t%T.length]),_t++;m.value.set(q,lt),m.value.get(q)||m.value.set(q,new Map)}}function B(T){c.value=T[0],y.value=T[1]}return(T,R)=>(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:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),f.createVNode(Mp,{pointCount:n.value,"onUpdate:pointCount":R[0]||(R[0]=z=>n.value=z),colorMode:r.value,"onUpdate:colorMode":R[1]||(R[1]=z=>r.value=z),startColor:i.value,"onUpdate:startColor":R[2]||(R[2]=z=>i.value=z),endColor:s.value,"onUpdate:endColor":R[3]||(R[3]=z=>s.value=z),singleColor:o.value,"onUpdate:singleColor":R[4]||(R[4]=z=>o.value=z),"color-scheme":y.value,"color-map-map":m.value,onRegenerate:W,onUpdateColorMap:B},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),Ry=Dn(Ny,[["__scopeId","data-v-00da5d75"]]),By="dashboard:globalVars";function ga(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=ga(),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)}}}),_a=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Fy=_a(Ly,[["__scopeId","data-v-08f7f19e"]]),My={class:"umap-wrap"},Uy=_a(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){ga();const t=f.ref("Data Explorer");return(n,r)=>(f.openBlock(),f.createElementBlock(f.Fragment,null,[f.renderSlot(n.$slots,"default",{widgetName:t.value},void 0,!0),f.createElementVNode("div",My,[f.createVNode(f.unref(Ry),{srcUrl:n.urlSrc},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-2ddbfd71"]]);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{c(r.next(u))}catch(d){o(d)}}function l(u){try{c(r.throw(u))}catch(d){o(d)}}function c(u){u.done?s(u.value):i(u.value).then(a,l)}c((r=r.apply(e,t||[])).next())})}function ba(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 j(e){return this instanceof j?(this.v=e,this):new j(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(A){return new Promise(function(S,_){s.push([m,A,S,_])>1||l(m,A)})},b&&(i[m]=b(i[m])))}function l(m,b){try{c(r[m](b))}catch(A){y(s[0][3],A)}}function c(m){m.value instanceof j?Promise.resolve(m.value.v).then(u,d):y(s[0][2],m)}function u(m){l("next",m)}function d(m){l("throw",m)}function y(m,b){m(b),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Ur(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:j(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 ba=="function"?ba(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,l){o=e[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(c){s({value:c,done:a})},o)}}const xy=new TextDecoder("utf-8"),ns=e=>xy.decode(e),Cy=new TextEncoder,rs=e=>Cy.encode(e),$y=e=>typeof e=="number",va=e=>typeof e=="boolean",It=e=>typeof e=="function",Ut=e=>e!=null&&Object(e)===e,Qe=e=>Ut(e)&&It(e.then),jn=e=>Ut(e)&&It(e[Symbol.iterator]),on=e=>Ut(e)&&It(e[Symbol.asyncIterator]),is=e=>Ut(e)&&Ut(e.schema),wa=e=>Ut(e)&&"done"in e&&"value"in e,Ia=e=>Ut(e)&&It(e.stat)&&$y(e.fd),Sa=e=>Ut(e)&&ss(e.body),xr=e=>"_getDOMStream"in e&&"_getNodeStream"in e,ky=e=>Ut(e)&&It(e.abort)&&It(e.getWriter)&&!xr(e),ss=e=>Ut(e)&&It(e.cancel)&&It(e.getReader)&&!xr(e),Py=e=>Ut(e)&&It(e.end)&&It(e.write)&&va(e.writable)&&!xr(e),Ea=e=>Ut(e)&&It(e.read)&&It(e.pipe)&&va(e.readable)&&!xr(e),Vy=e=>Ut(e)&&It(e.clear)&&It(e.bytes)&&It(e.position)&&It(e.setPosition)&&It(e.capacity)&&It(e.getBufferIdentifier)&&It(e.createLong),os=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function zy(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let o,a,l=0,c=0,u=e.length;++l<u;){if(o=t[c],a=e[l],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++c]=a);continue}if({byteOffset:n,byteLength:i}=o,{byteOffset:r,byteLength:s}=a,n+i<r||r+s<n){a&&(t[++c]=a);continue}t[c]=new Uint8Array(o.buffer,n,r-n+s)}return t}function Ta(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,l=-1;const c=Math.min(t||Number.POSITIVE_INFINITY,r);for(const u=n.length;++l<u;){if(i=n[l],s=i.subarray(0,Math.min(i.length,c-a)),c<=a+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,o?Ta(o,s,a):o=s;break}Ta(o||(o=new Uint8Array(c)),s,a),a+=s.length}return[o||new Uint8Array(0),n.slice(l),r-(o?o.byteLength:0)]}function ut(e,t){let n=wa(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=rs(n)),n instanceof ArrayBuffer?new e(n):n instanceof os?new e(n):Vy(n)?ut(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=>ut(Int32Array,e),Aa=e=>ut(BigInt64Array,e),Q=e=>ut(Uint8Array,e),as=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 os?n(t):jn(t)?t:n(t);return yield*as((function*(i){let s=null;do s=i.next(yield ut(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const jy=e=>Yy(Uint8Array,e);function Na(e,t){return se(this,arguments,function*(){if(Qe(t))return yield j(yield j(yield*Ur(Ke(Na(e,yield j(t))))));const n=function(s){return se(this,arguments,function*(){yield yield j(yield j(s))})},r=function(s){return se(this,arguments,function*(){yield j(yield*Ur(Ke(as((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 os?n(t):jn(t)?r(t):on(t)?t:n(t);return yield j(yield*Ur(Ke(as((function(s){return se(this,arguments,function*(){let o=null;do o=yield j(s.next(yield yield j(ut(e,o))));while(!o.done)})})(i[Symbol.asyncIterator]()))))),yield j(new e)})}const qy=e=>Na(Uint8Array,e);function Ra(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 Cr(Wy(e))},fromAsyncIterable(e){return Cr(Hy(e))},fromDOMStream(e){return Cr(Ky(e))},fromNodeStream(e){return Cr(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')}},Cr=e=>(e.next(),e);function*Wy(e){let t,n=!1,r=[],i,s,o,a=0;function l(){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 c=jy(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?c.next():c.next(o-a),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield l());while(o<a);while(!t)}catch(u){(n=!0)&&typeof c.throw=="function"&&c.throw(u)}finally{n===!1&&typeof c.return=="function"&&c.return(null)}return null}function Hy(e){return se(this,arguments,function*(){let t,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?oe(r,o)[0]:([i,r,a]=oe(r,o),i)}({cmd:s,size:o}=(yield yield j(null))||{cmd:"read",size:0});const c=qy(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?yield j(c.next()):yield j(c.next(o-a)),!t&&i.byteLength>0&&(r.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield j(l()));while(o<a);while(!t)}catch(u){(n=!0)&&typeof c.throw=="function"&&(yield j(c.throw(u)))}finally{n===!1&&typeof c.return=="function"&&(yield j(c.return(new Uint8Array(0))))}return yield j(null)})}function Ky(e){return se(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?oe(r,o)[0]:([i,r,a]=oe(r,o),i)}({cmd:s,size:o}=(yield yield j(null))||{cmd:"read",size:0});const c=new Qy(e);try{do if({done:t,value:i}=Number.isNaN(o-a)?yield j(c.read()):yield j(c.read(o-a)),!t&&i.byteLength>0&&(r.push(Q(i)),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield yield j(l()));while(o<a);while(!t)}catch(u){(n=!0)&&(yield j(c.cancel(u)))}finally{n===!1?yield j(c.cancel()):e.locked&&c.releaseLock()}return yield j(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=Q(n)),n})}}const ls=(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,l=[],c;function u(){return s==="peek"?oe(l,o)[0]:([c,l,a]=oe(l,o),c)}if({cmd:s,size:o}=(yield yield j(null))||{cmd:"read",size:0},e.isTTY)return yield yield j(new Uint8Array(0)),yield j(null);try{t[0]=ls(e,"end"),t[1]=ls(e,"error");do{if(t[2]=ls(e,"readable"),[n,i]=yield j(Promise.race(t.map(y=>y[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(o-a)?(c=Q(e.read(o-a)),c.byteLength<o-a&&(c=Q(e.read()))):c=Q(e.read()),c.byteLength>0&&(l.push(c),a+=c.byteLength)),r||o<=a)do({cmd:s,size:o}=yield yield j(u()));while(o<a)}while(!r)}finally{yield j(d(t,n==="error"?i:null))}return yield j(null);function d(y,m){return c=l=null,new Promise((b,A)=>{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?A(m):b()}})}})}var bt;(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"})(bt||(bt={}));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 cs=2,le=4,ve=4,rt=4,Fe=new Int32Array(2),Ba=new Float32Array(Fe.buffer),Oa=new Float64Array(Fe.buffer),$r=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var us;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(us||(us={}));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),Ba[0]}readFloat64(t){return Fe[$r?0:1]=this.readInt32(t),Fe[$r?1:0]=this.readInt32(t+4),Oa[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){Ba[0]=n,this.writeInt32(t,Fe[0])}writeFloat64(t,n){Oa[0]=n,this.writeInt32(t,Fe[$r?0:1]),this.writeInt32(t+4,Fe[$r?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===us.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}},Da=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)*cs;this.addInt16(s);let o=0;const a=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=cs;c<s;c+=cs)if(this.bb.readInt16(a+c)!=this.bb.readInt16(l+c))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 kr;(function(e){e[e.BUFFER=0]="BUFFER"})(kr||(kr={}));var Pr;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Pr||(Pr={}));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):Pr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):kr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Pr.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,kr.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 La{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 Fa=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 eo{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 eo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+rt),(n||new eo).__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 Fa).__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 La).__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 no{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 no).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+rt),(n||new no).__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 Vr;(function(e){e[e.DenseArray=0]="DenseArray"})(Vr||(Vr={}));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):Vr.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,Vr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class St{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 St).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+rt),(n||new St).__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 St.startKeyValue(t),St.addKey(t,n),St.addValue(t,r),St.endKeyValue(t)}}let Ma=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)}},Ua=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)}},zr=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)}},Yr=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)}},jr=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)}},qr=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 xa=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)}},Ca=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)}},$a=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)}},Gr=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)}},ka=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 Pa=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 ft;(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"})(ft||(ft={}));let Wt=class Di{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 Di).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+rt),(n||new Di).__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):ft.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 Di).__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 St).__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,ft.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 St).__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 ht(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 Va(e,t){return ht(e/t)+ht(e%t)/ht(t)}const Zy=Symbol.for("isArrowBigNum");function te(e,...t){return t.length===0?Object.setPrototypeOf(ut(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 za(this,e)},te.prototype.toString=function(){return Hn(this)},te.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return za(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 za(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 l=BigInt(0),c=0;if(a){for(const u of o)l|=(u^em)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const u of o)l|=u*(BigInt(1)<<BigInt(64*c++));if(typeof t=="number"){const u=BigInt(Math.pow(10,t)),d=l/u,y=l%u;return ht(d)+ht(y)/ht(u)}return ht(l)}function Hn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return hs(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return hs(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`-${hs(t)}`}function nm(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Hn(e)}function hs(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 ds{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 ds.new(t,n)}}var Ya,ja,qa,Ga,Wa,Ha,Ka,Qa,Xa,Ja,Za,tl,el,nl,rl,il,sl,ol,al,ll,cl,ul;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}}Ya=Symbol.toStringTag,O[Ya]=(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"}}ja=Symbol.toStringTag,Ue[ja]=(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}`}}qa=Symbol.toStringTag,Je[qa]=(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 Wr 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}`}}Ga=Symbol.toStringTag,Wr[Ga]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(Wr.prototype);class Hr extends O{constructor(){super(p.Binary)}toString(){return"Binary"}}Wa=Symbol.toStringTag,Hr[Wa]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Hr.prototype);class Kr extends O{constructor(){super(p.LargeBinary)}toString(){return"LargeBinary"}}Ha=Symbol.toStringTag,Kr[Ha]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Kr.prototype);class Qr extends O{constructor(){super(p.Utf8)}toString(){return"Utf8"}}Ka=Symbol.toStringTag,Qr[Ka]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Qr.prototype);class Xr extends O{constructor(){super(p.LargeUtf8)}toString(){return"LargeUtf8"}}Qa=Symbol.toStringTag,Xr[Qa]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(Xr.prototype);class Jr extends O{constructor(){super(p.Bool)}toString(){return"Bool"}}Xa=Symbol.toStringTag,Jr[Xa]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Jr.prototype);class Zr 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}]`}}Ja=Symbol.toStringTag,Zr[Ja]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Zr.prototype);class ti 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}}Za=Symbol.toStringTag,ti[Za]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(ti.prototype);class ei 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`)}}tl=Symbol.toStringTag,ei[tl]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(ei.prototype);class ni extends O{constructor(t,n){super(p.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${x[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}el=Symbol.toStringTag,ni[el]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(ni.prototype);class ri extends O{constructor(t){super(p.Interval),this.unit=t}toString(){return`Interval<${ae[this.unit]}>`}}nl=Symbol.toStringTag,ri[nl]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(ri.prototype);class ii extends O{constructor(t){super(p.Duration),this.unit=t}toString(){return`Duration<${x[this.unit]}>`}}rl=Symbol.toStringTag,ii[rl]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(ii.prototype);class si 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}}il=Symbol.toStringTag,si[il]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(si.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(", ")}}>`}}sl=Symbol.toStringTag,Ot[sl]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(Ot.prototype);class oi 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(" | ")}>`}}ol=Symbol.toStringTag,oi[ol]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(oi.prototype);class ai extends O{constructor(t){super(p.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}al=Symbol.toStringTag,ai[al]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(ai.prototype);class li 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}>`}}ll=Symbol.toStringTag,li[ll]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(li.prototype);class ci 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(", ")}}>`}}cl=Symbol.toStringTag,ci[cl]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(ci.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():ht(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}>`}}ul=Symbol.toStringTag,fn[ul]=(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 G{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,hl(t),n):t?.type&&t.type instanceof O?pn(e,hl(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 hl(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]}'`)}G.prototype.visitInt8=null,G.prototype.visitInt16=null,G.prototype.visitInt32=null,G.prototype.visitInt64=null,G.prototype.visitUint8=null,G.prototype.visitUint16=null,G.prototype.visitUint32=null,G.prototype.visitUint64=null,G.prototype.visitFloat16=null,G.prototype.visitFloat32=null,G.prototype.visitFloat64=null,G.prototype.visitDateDay=null,G.prototype.visitDateMillisecond=null,G.prototype.visitTimestampSecond=null,G.prototype.visitTimestampMillisecond=null,G.prototype.visitTimestampMicrosecond=null,G.prototype.visitTimestampNanosecond=null,G.prototype.visitTimeSecond=null,G.prototype.visitTimeMillisecond=null,G.prototype.visitTimeMicrosecond=null,G.prototype.visitTimeNanosecond=null,G.prototype.visitDenseUnion=null,G.prototype.visitSparseUnion=null,G.prototype.visitIntervalDayTime=null,G.prototype.visitIntervalYearMonth=null,G.prototype.visitDuration=null,G.prototype.visitDurationSecond=null,G.prototype.visitDurationMillisecond=null,G.prototype.visitDurationMicrosecond=null,G.prototype.visitDurationNanosecond=null;const dl=new Float64Array(1),yn=new Uint32Array(dl.buffer);function fl(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;dl[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 G{}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)},pl=(e,t,n,r)=>{if(n+1<t.length){const i=ht(t[n]),s=ht(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},fs=({values:e},t,n)=>{e[t]=n},yl=({values:e},t,n)=>{e[t]=sm(n)},lm=(e,t,n)=>{switch(e.type.precision){case Rt.HALF:return yl(e,t,n);case Rt.SINGLE:case Rt.DOUBLE:return fs(e,t,n)}},ml=({values:e},t,n)=>{om(e,t,n.valueOf())},gl=({values:e},t,n)=>{e[t]=BigInt(n)},cm=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},_l=({values:e,valueOffsets:t},n,r)=>pl(e,t,n,r),bl=({values:e,valueOffsets:t},n,r)=>pl(e,t,n,rs(r)),um=(e,t,n)=>{e.type.unit===jt.DAY?ml(e,t,n):gl(e,t,n)},vl=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},wl=({values:e},t,n)=>{e[t]=BigInt(n)},Il=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Sl=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},hm=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return vl(e,t,n);case x.MILLISECOND:return wl(e,t,n);case x.MICROSECOND:return Il(e,t,n);case x.NANOSECOND:return Sl(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},Nl=({values:e},t,n)=>{e[t]=n},dm=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return El(e,t,n);case x.MILLISECOND:return Tl(e,t,n);case x.MICROSECOND:return Al(e,t,n);case x.NANOSECOND:return Nl(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],l=i[t+1];a<l;)s(r,a++,n[++o]);else for(let o=-1,a=i[t],l=i[t+1];a<l;)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 l=n instanceof Map?n.entries():Object.entries(n);for(const c of l)if(s(r,o,c),++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?Rl(e,t,n):Bl(e,t,n)},Rl=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Ht.visit(i,e.valueOffsets[t],n)},Bl=(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?Ol(e,t,n):Dl(e,t,n)},Ol=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Dl=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Ll=({values:e},t,n)=>{e[t]=n},Fl=({values:e},t,n)=>{e[t]=n},Ml=({values:e},t,n)=>{e[t]=n},Ul=({values:e},t,n)=>{e[t]=n},Em=(e,t,n)=>{switch(e.type.unit){case x.SECOND:return Ll(e,t,n);case x.MILLISECOND:return Fl(e,t,n);case x.MICROSECOND:return Ml(e,t,n);case x.NANOSECOND:return Ul(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(yl),C.prototype.visitFloat32=P(fs),C.prototype.visitFloat64=P(fs),C.prototype.visitUtf8=P(bl),C.prototype.visitLargeUtf8=P(bl),C.prototype.visitBinary=P(_l),C.prototype.visitLargeBinary=P(_l),C.prototype.visitFixedSizeBinary=P(cm),C.prototype.visitDate=P(um),C.prototype.visitDateDay=P(ml),C.prototype.visitDateMillisecond=P(gl),C.prototype.visitTimestamp=P(hm),C.prototype.visitTimestampSecond=P(vl),C.prototype.visitTimestampMillisecond=P(wl),C.prototype.visitTimestampMicrosecond=P(Il),C.prototype.visitTimestampNanosecond=P(Sl),C.prototype.visitTime=P(dm),C.prototype.visitTimeSecond=P(El),C.prototype.visitTimeMillisecond=P(Tl),C.prototype.visitTimeMicrosecond=P(Al),C.prototype.visitTimeNanosecond=P(Nl),C.prototype.visitDecimal=P(fm),C.prototype.visitList=P(pm),C.prototype.visitStruct=P(vm),C.prototype.visitUnion=P(wm),C.prototype.visitDenseUnion=P(Rl),C.prototype.visitSparseUnion=P(Bl),C.prototype.visitDictionary=P(Im),C.prototype.visitInterval=P(Sm),C.prototype.visitIntervalDayTime=P(Ol),C.prototype.visitIntervalYearMonth=P(Dl),C.prototype.visitDuration=P(Em),C.prototype.visitDurationSecond=P(Ll),C.prototype.visitDurationMillisecond=P(Fl),C.prototype.visitDurationMicrosecond=P(Ml),C.prototype.visitDurationNanosecond=P(Ul),C.prototype.visitFixedSizeList=P(Tm),C.prototype.visitMap=P(ym);const Ht=new C,ee=Symbol.for("parent"),mn=Symbol.for("rowIndex");class ps{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(ps.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 G{}function $(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Rm=(e,t)=>864e5*e[t],Bm=(e,t)=>null,xl=(e,t,n)=>{if(n+1>=t.length)return null;const r=ht(t[n]),i=ht(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},Cl=({values:e},t)=>Rm(e,t),$l=({values:e},t)=>ht(e[t]),xe=({stride:e,values:t},n)=>t[e*n],Dm=({stride:e,values:t},n)=>fl(t[e*n]),kl=({values:e},t)=>e[t],Lm=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Pl=({values:e,valueOffsets:t},n)=>xl(e,t,n),Vl=({values:e,valueOffsets:t},n)=>{const r=xl(e,t,n);return r!==null?ns(r):null},Fm=({values:e},t)=>e[t],Mm=({type:e,values:t},n)=>e.precision!==Rt.HALF?t[n]:fl(t[n]),Um=(e,t)=>e.type.unit===jt.DAY?Cl(e,t):$l(e,t),zl=({values:e},t)=>1e3*ht(e[t]),Yl=({values:e},t)=>ht(e[t]),jl=({values:e},t)=>Va(e[t],BigInt(1e3)),ql=({values:e},t)=>Va(e[t],BigInt(1e6)),xm=(e,t)=>{switch(e.type.unit){case x.SECOND:return zl(e,t);case x.MILLISECOND:return Yl(e,t);case x.MICROSECOND:return jl(e,t);case x.NANOSECOND:return ql(e,t)}},Gl=({values:e},t)=>e[t],Wl=({values:e},t)=>e[t],Hl=({values:e},t)=>e[t],Kl=({values:e},t)=>e[t],Cm=(e,t)=>{switch(e.type.unit){case x.SECOND:return Gl(e,t);case x.MILLISECOND:return Wl(e,t);case x.MICROSECOND:return Hl(e,t);case x.NANOSECOND:return Kl(e,t)}},$m=({values:e,stride:t},n)=>ds.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 ms(o.slice(i,s-i))},Vm=(e,t)=>new ps(e,t),zm=(e,t)=>e.type.mode===Nt.Dense?Ql(e,t):Xl(e,t),Ql=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Ct.visit(r,e.valueOffsets[t])},Xl=(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?Jl(e,t):Zl(e,t),Jl=({values:e},t)=>e.subarray(2*t,2*(t+1)),Zl=({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},tc=({values:e},t)=>e[t],ec=({values:e},t)=>e[t],nc=({values:e},t)=>e[t],rc=({values:e},t)=>e[t],qm=(e,t)=>{switch(e.type.unit){case x.SECOND:return tc(e,t);case x.MILLISECOND:return ec(e,t);case x.MICROSECOND:return nc(e,t);case x.NANOSECOND:return rc(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=$(kl),L.prototype.visitUint8=$(xe),L.prototype.visitUint16=$(xe),L.prototype.visitUint32=$(xe),L.prototype.visitUint64=$(kl),L.prototype.visitFloat=$(Mm),L.prototype.visitFloat16=$(Dm),L.prototype.visitFloat32=$(xe),L.prototype.visitFloat64=$(xe),L.prototype.visitUtf8=$(Vl),L.prototype.visitLargeUtf8=$(Vl),L.prototype.visitBinary=$(Pl),L.prototype.visitLargeBinary=$(Pl),L.prototype.visitFixedSizeBinary=$(Lm),L.prototype.visitDate=$(Um),L.prototype.visitDateDay=$(Cl),L.prototype.visitDateMillisecond=$($l),L.prototype.visitTimestamp=$(xm),L.prototype.visitTimestampSecond=$(zl),L.prototype.visitTimestampMillisecond=$(Yl),L.prototype.visitTimestampMicrosecond=$(jl),L.prototype.visitTimestampNanosecond=$(ql),L.prototype.visitTime=$(Cm),L.prototype.visitTimeSecond=$(Gl),L.prototype.visitTimeMillisecond=$(Wl),L.prototype.visitTimeMicrosecond=$(Hl),L.prototype.visitTimeNanosecond=$(Kl),L.prototype.visitDecimal=$($m),L.prototype.visitList=$(km),L.prototype.visitStruct=$(Vm),L.prototype.visitUnion=$(zm),L.prototype.visitDenseUnion=$(Ql),L.prototype.visitSparseUnion=$(Xl),L.prototype.visitDictionary=$(Ym),L.prototype.visitInterval=$(jm),L.prototype.visitIntervalDayTime=$(Jl),L.prototype.visitIntervalYearMonth=$(Zl),L.prototype.visitDuration=$(qm),L.prototype.visitDurationSecond=$(tc),L.prototype.visitDurationMillisecond=$(ec),L.prototype.visitDurationMicrosecond=$(nc),L.prototype.visitDurationNanosecond=$(rc),L.prototype.visitFixedSizeList=$(Gm),L.prototype.visitMap=$(Pm);const Ct=new L,gn=Symbol.for("keys"),_n=Symbol.for("vals"),bn=Symbol.for("kKeysAsStrings"),ys=Symbol.for("_kKeysAsStrings");class ms{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[ys]||(this[ys]=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(ms.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},[ys]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let ic;function sc(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&&(ic=s,s=o,o=ic),o>i&&(o=i),r?r(e,s,o):[s,o]}const gs=(e,t)=>e<0?t+e:e,oc=e=>e!==e;function vn(e){if(typeof e!="object"||e===null)return oc(e)?oc: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 ui(t)}function Qm(e){let t=-1;const n=[];for(const r of e.values())n[++t]=vn(r);return ui(n)}function Xm(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=vn(e.get(n));return ui(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 ui(r,n)}function ui(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return Zm(e,n);case Map:return ac(e,n,n.keys());case ms:case ps:case Object:case void 0:return ac(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 ac(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 l=s.next(),c=r.next(),u=i.next();for(;o<a&&!c.done&&!u.done&&!l.done&&!(c.value!==u.value||!e[o](l.value));++o,c=r.next(),u=i.next(),l=s.next());return o===a&&c.done&&u.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function lc(e,t,n,r){return(n&1<<r)!==0}function eg(e,t,n,r){return(n&1<<r)>>r}function hi(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):di(new _s(n,e,t,null,lc)).subarray(0,r)),i}return n}function di(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 _s{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 bs(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const o of new _s(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 bs(e,t,i)+bs(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+=vs(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=vs(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=vs(s.getUint8(i)),i+=1;return r}function vs(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-bs(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 l;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&&((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(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,l=o+t,c=1<<l%8,u=l>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(hi(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const d=s[u];r=(d&c)!==0,s[u]=n?d|c:d&~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,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,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,o,l,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(hi(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 G{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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.data),s=Q(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),o=Aa(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),o=Aa(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=Q(t.nullBitmap),{length:o=i.reduce((l,{length:c})=>Math.max(l,c),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=ut(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 l=qn(t.valueOffsets);return new ot(n,r,o,a,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ut(n.indices.ArrayType,t.data),{["dictionary"]:o=new it([new Qn().visit({type:n.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[void 0,s,i],[],o)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ut(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=Q(t.nullBitmap),s=ut(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=Q(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=Q(t.nullBitmap),o=qn(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new ot(n,r,a,l,[o,void 0,s],[i])}}const ig=new Qn;function K(e){return ig.visit(e)}class cc{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 uc(e){return e.reduce((t,n)=>t+n.nullCount,0)}function hc(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function dc(e,t,n,r){const i=[];for(let s=-1,o=e.length;++s<o;){const a=e[s],l=t[s],{length:c}=a;if(l>=r)break;if(n>=l+c)continue;if(l>=n&&l+c<=r){i.push(a);continue}const u=Math.max(0,n-l),d=Math.min(r-l,c);i.push(a.slice(u,d-u))}return i.length===0&&i.push(e[0].slice(0,0)),i}function ws(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 Is(e,t){return e.getValid(t)}function fi(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return ws(r,this._offsets,n,t)}}function fc(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=ws(s,this._offsets,r,n);return t=void 0,o}}function pc(e){let t;function n(r,i,s){let o=s,a=0,l=0;for(let c=i-1,u=r.length;++c<u;){const d=r[c];if(~(a=e(d,t,o)))return l+a;o=0,l+=d.length}return-1}return function(r,i){t=r;const s=this.data,o=typeof i!="number"?n(s,0,0):ws(s,this._offsets,i,n);return t=void 0,o}}class F extends G{}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 _s(n,e.offset+(t||0),e.length,n,lc)){if(!i)return r;++r}return-1}function V(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 yc(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=V,F.prototype.visitInt=V,F.prototype.visitInt8=V,F.prototype.visitInt16=V,F.prototype.visitInt32=V,F.prototype.visitInt64=V,F.prototype.visitUint8=V,F.prototype.visitUint16=V,F.prototype.visitUint32=V,F.prototype.visitUint64=V,F.prototype.visitFloat=V,F.prototype.visitFloat16=V,F.prototype.visitFloat32=V,F.prototype.visitFloat64=V,F.prototype.visitUtf8=V,F.prototype.visitLargeUtf8=V,F.prototype.visitBinary=V,F.prototype.visitLargeBinary=V,F.prototype.visitFixedSizeBinary=V,F.prototype.visitDate=V,F.prototype.visitDateDay=V,F.prototype.visitDateMillisecond=V,F.prototype.visitTimestamp=V,F.prototype.visitTimestampSecond=V,F.prototype.visitTimestampMillisecond=V,F.prototype.visitTimestampMicrosecond=V,F.prototype.visitTimestampNanosecond=V,F.prototype.visitTime=V,F.prototype.visitTimeSecond=V,F.prototype.visitTimeMillisecond=V,F.prototype.visitTimeMicrosecond=V,F.prototype.visitTimeNanosecond=V,F.prototype.visitDecimal=V,F.prototype.visitList=V,F.prototype.visitStruct=V,F.prototype.visitUnion=V,F.prototype.visitDenseUnion=yc,F.prototype.visitSparseUnion=yc,F.prototype.visitDictionary=V,F.prototype.visitInterval=V,F.prototype.visitIntervalDayTime=V,F.prototype.visitIntervalYearMonth=V,F.prototype.visitDuration=V,F.prototype.visitDurationSecond=V,F.prototype.visitDurationMillisecond=V,F.prototype.visitDurationMicrosecond=V,F.prototype.visitDurationNanosecond=V,F.prototype.visitFixedSizeList=V,F.prototype.visitMap=V;const pi=new F;class M extends G{}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 cc(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new cc(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 Ss=new M;var mc;const gc={},_c={};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:l,indexOf:c}=gc[o.typeId],u=s[0];this.isValid=d=>Is(u,d),this.get=d=>a(u,d),this.set=(d,y)=>l(u,d,y),this.indexOf=d=>c(u,d),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,_c[o.typeId]),this._offsets=hc(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 uc(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(gs(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return Ss.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(sc(this,t,n,({data:r,_offsets:i},s,o)=>dc(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:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*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 yi(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new it(n)}return new yi(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}}mc=Symbol.toStringTag,it[mc]=(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=pi.getVisitFnByTypeId(n);gc[n]={get:r,set:i,indexOf:s},_c[n]=Object.create(e,{isValid:{value:fi(Is)},get:{value:fi(Ct.getVisitFnByTypeId(n))},set:{value:fc(Ht.getVisitFnByTypeId(n))},indexOf:{value:pc(pi.getVisitFnByTypeId(n))}})}return"Vector"})(it.prototype);class yi 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 l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new yi(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 Es{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):bt.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 Es).__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 Es).__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 St).__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,bt.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=bt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=Ts(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=mi(mi(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{const l=r.findIndex(c=>c.name===a.name);return~l?(r[l]=a.clone({metadata:mi(mi(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=Ts(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 pt{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 pt(`${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],pt.new(n,r,i,s)}}pt.prototype.type=null,pt.prototype.name=null,pt.prototype.nullable=null,pt.prototype.metadata=null;function mi(e,t){return new Map([...e||new Map,...t||new Map])}function Ts(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&&Ts(i.children,t)}return t}var cg=Da,ug=an;class Xn{static decode(t){t=new ug(Q(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,bt.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=bt.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 Es.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=ht(r),this.bodyLength=ht(n)}}const Et=Object.freeze({done:!0,value:void 0});class bc{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class As{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 As{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(Et);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),Et})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),Et})}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(Et)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class gi extends dg{write(t){if((t=Q(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?ns(this.toUint8Array(!0)):this.toUint8Array(!1).then(ns)}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 l=!0,c=Ke(this),u;u=yield c.next(),n=u.done,!n;l=!0){s=u.value,l=!1;const d=s;o.push(d),a+=d.byteLength}}catch(d){r={error:d}}finally{try{!l&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}return oe(o,a)[0]})}}class _i{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 gi?this.source=new Ze(Yt.fromAsyncIterable(t)):Ea(t)?this.source=new Ze(Yt.fromNodeStream(t)):ss(t)?this.source=new Ze(Yt.fromDOMStream(t)):Sa(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)||Et)}return(t){return Object.create(this.source.return&&this.source.return(t)||Et)}}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))||Et;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))||Et;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class vc extends _i{constructor(t,n){super(),this.position=0,this.buffer=Q(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 bi 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 l=Math.min(r,s+Math.min(r-s,t)),c=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=a)<l&&(o+=a)<c.byteLength;)({bytesRead:a}=yield n.read(c,o,c.byteLength-o,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),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,Ns=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class wc{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 wc{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])),l=new at(new Uint32Array([Ns[o],0]));i.times(l),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 wc{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,l=new Kt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),c=new Kt(new Uint32Array([Ns[a],0]));s.times(c),s.plus(l),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])),l=new at(new Uint32Array([t.buffer[1],0])),c=new at(new Uint32Array([t.buffer[0],0]));let u=at.multiply(s,c);this.buffer[0]=u.low();const d=new at(new Uint32Array([u.high(),0]));return u=at.multiply(i,c),d.plus(u),u=at.multiply(s,l),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,c)).plus(at.multiply(i,l)).plus(at.multiply(s,a)),this.buffer[3]+=at.multiply(n,c).plus(at.multiply(r,l)).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,l=new de(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),c=new de(new Uint32Array([Ns[a],0,0,0]));s.times(c),s.plus(l),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 Ic extends G{constructor(t,n,r,i,s=bt.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 pt?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return K({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({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 K({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 K({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 K({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 K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({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 K({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<bt.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 K({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 K({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({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 K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return K({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 K({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 Ic{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):di(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return ut(Uint8Array,ut(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return ut(Uint8Array,ut(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?ut(Uint8Array,Kt.convertArray(r[n])):O.isDecimal(t)?ut(Uint8Array,de.convertArray(r[n])):O.isBinary(t)||O.isLargeBinary(t)||O.isFixedSizeBinary(t)?mg(r[n]):O.isBool(t)?di(r[n]):O.isUtf8(t)||O.isLargeUtf8(t)?rs(r[n].join("")):ut(Uint8Array,ut(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 G{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 vi(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 Rs(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 Bs(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 Os(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=vi,U.prototype.visitFloat16=vi,U.prototype.visitFloat32=vi,U.prototype.visitFloat64=vi,U.prototype.visitUtf8=tn,U.prototype.visitLargeUtf8=tn,U.prototype.visitBinary=tn,U.prototype.visitLargeBinary=tn,U.prototype.visitFixedSizeBinary=gg,U.prototype.visitDate=Rs,U.prototype.visitDateDay=Rs,U.prototype.visitDateMillisecond=Rs,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=Bs,U.prototype.visitDenseUnion=Bs,U.prototype.visitSparseUnion=Bs,U.prototype.visitDictionary=vg,U.prototype.visitInterval=Os,U.prototype.visitIntervalDayTime=Os,U.prototype.visitIntervalYearMonth=Os,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 Ds(e,t){return $e.compareSchemas(e,t)}function Ls(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 l=t.length;let c,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<l;)u[a]=c=t[a].shift(),o=Math.min(o,c?c.length:o);Number.isFinite(o)&&(u=Eg(n,o,u,t,i),o>0&&(r[s++]=K({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,l=r.length;++a<l;){const c=n[a],u=c?.length;if(u>=t)u===t?n[a]=c:(n[a]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[a].unshift(c.slice(t,u-t))));else{const d=e[a];e[a]=d.clone({nullable:!0}),n[a]=(s=c?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:K({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return n}var Sc;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=l=>{if(l){if(l instanceof $t)return[l];if(l instanceof Lt)return l.batches;if(l instanceof ot){if(l.type instanceof Ot)return[new $t(new st(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>o(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>o(c));if(typeof l=="object"){const c=Object.keys(l),u=c.map(m=>new it([l[m]])),d=i??new st(c.map((m,b)=>new pt(String(m),u[b].type,u[b].nullable))),[,y]=Ls(d,u);return y.length===0?[new $t(l)]:y}}}return[]},a=t.flatMap(l=>o(l));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 l of a){if(!(l instanceof $t))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Ds(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??hc(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=uc(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(gs(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?Ss.visit(new it(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
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`[
47
47
  ${this.toArray().join(`,
48
48
  `)}
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]=sc({length:this.numRows},t,n);const i=dc(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=K({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([K({type:new Ue,length:this.numRows})]));const s=r.fields.slice(),o=s[t].clone({type:n.type}),a=this.schema.fields.map((l,c)=>this.getChildAt(c));[s[t],a[t]]=[o,n],[r,i]=Ls(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,l,c)=>{const[u,d]=a,y=n.findIndex(m=>m.name===l.name);return~y?d[y]=c:u.push(c),a},[[],[]]),s=this.schema.assign(t.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):t.getChildAt(l)),...r.map(a=>t.getChildAt(a))].filter(Boolean);return new Lt(...Ls(s,o))}}Sc=Symbol.toStringTag,Lt[Sc]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=fi(Is),e.get=fi(Ct.getVisitFn(p.Struct)),e.set=fc(Ht.getVisitFn(p.Struct)),e.indexOf=pc(pi.getVisitFn(p.Struct)),"Table"))(Lt.prototype);var Ec;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=K({nullCount:0,type:new Ot(this.schema.fields),children:this.schema.fields.map(n=>K({type:n.type,nullCount:0}))})]=t,!(this.data instanceof ot))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Tc(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,c,u)=>(l.children[u]=n[c],l.length=Math.max(l.length,n[c].length),l.fields[u]=pt.new({name:c,type:n[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new st(r),a=K({type:new Ot(r),length:s,children:i,nullCount:0});[this.schema,this.data]=Tc(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=Ac(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(gs(t,this.numRows))}set(t,n){return Ht.visit(this.data,t,n)}indexOf(t,n){return pi.visit(this.data,t,n)}[Symbol.iterator](){return Ss.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([K({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=K({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,K({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=K({type:new Ot(n.fields),length:this.numRows,children:r});return new ur(n,i)}};Ec=Symbol.toStringTag,$t[Ec]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))($t.prototype);function Tc(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,l]of e.fields.entries()){const c=t[a];(!c||c.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=c?._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:K({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[e.assign(i),K({type:new Ot(i),length:n,children:s})]}function Ac(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],l=t[s];for(const c of[l,...((i=l?.dictionary)===null||i===void 0?void 0:i.data)||[]])Ac(a.children,c?.children,n);if(O.isDictionary(a)){const{id:c}=a;if(!n.has(c))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 Fs extends $t{constructor(t){const n=t.fields.map(i=>K({type:i.type})),r=K({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):bt.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 St).__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,bt.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 G{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return ka.startNull(n),ka.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 Ma.startBinary(n),Ma.endBinary(n)}visitLargeBinary(t,n){return xa.startLargeBinary(n),xa.endLargeBinary(n)}visitBool(t,n){return Ua.startBool(n),Ua.endBool(n)}visitUtf8(t,n){return Pa.startUtf8(n),Pa.endUtf8(n)}visitLargeUtf8(t,n){return Ca.startLargeUtf8(n),Ca.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 zr.startDate(n),zr.addUnit(n,t.unit),zr.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 Yr.startDuration(n),Yr.addUnit(n,t.unit),Yr.endDuration(n)}visitList(t,n){return $a.startList(n),$a.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 jr.startFixedSizeBinary(n),jr.addByteWidth(n,t.byteWidth),jr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return qr.startFixedSizeList(n),qr.addListSize(n,t.listSize),qr.endFixedSizeList(n)}visitMap(t,n){return Gr.startMap(n),Gr.addKeysSorted(n,t.keysSorted),Gr.endMap(n)}}const Ms=new Tg;function Ag(e,t=new Map){return new st(Rg(e,t),wi(e.metadata),t)}function Nc(e){return new zt(e.count,Bc(e.columns),Oc(e.columns))}function Ng(e){return new fe(Nc(e.data),e.id,e.isDelta)}function Rg(e,t){return(e.fields||[]).filter(Boolean).map(n=>pt.fromJSON(n,t))}function Rc(e,t){return(e.children||[]).filter(Boolean).map(n=>pt.fromJSON(n,t))}function Bc(e){return(e||[]).reduce((t,n)=>[...t,new Pe(n.count,Bg(n.VALIDITY)),...Bc(n.children)],[])}function Oc(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=Oc(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=Lc(e,Rc(e,t)),i=new pt(e.name,o,e.nullable,wi(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Dc(r):new Kn,a=new fn(t.get(n),r,n,s.isOrdered),i=new pt(e.name,a,e.nullable,wi(e.metadata))):(r=(r=s.indexType)?Dc(r):new Kn,t.set(n,o=Lc(e,Rc(e,t))),a=new fn(o,r,n,s.isOrdered),i=new pt(e.name,a,e.nullable,wi(e.metadata))),i||null}function wi(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Dc(e){return new Je(e.isSigned,e.bitWidth)}function Lc(e,t){const n=e.type.name;switch(n){case"NONE":return new Ue;case"null":return new Ue;case"binary":return new Hr;case"largebinary":return new Kr;case"utf8":return new Qr;case"largeutf8":return new Xr;case"bool":return new Jr;case"list":return new si((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 Wr(Rt[r.precision])}case"decimal":{const r=e.type;return new Zr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new ti(jt[r.unit])}case"time":{const r=e.type;return new ei(x[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new ni(x[r.unit],r.timezone)}case"interval":{const r=e.type;return new ri(ae[r.unit])}case"duration":{const r=e.type;return new ii(x[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new oi(Nt[o],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new ai(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new li(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new ci((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var Dg=Da,Lg=an;class Ft{static fromJSON(t,n){const r=new Ft(0,bt.V5,n);return r._createHeader=Fg(t,n),r}static decode(t){t=new Lg(Q(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,bt.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,bt.V5,et.Schema,t);if(t instanceof zt)return new Ft(n,bt.V5,et.RecordBatch,t);if(t instanceof fe)return new Ft(n,bt.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=ht(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=ht(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=ht(n)}}class pe{constructor(t,n){this.offset=ht(t),this.length=ht(n)}}class Pe{constructor(t,n){this.length=ht(t),this.nullCount=ht(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} }`)})}pt.encode=qg,pt.decode=Yg,pt.fromJSON=Og,st.encode=jg,st.decode=Ug,st.fromJSON=Ag,zt.encode=Gg,zt.decode=xg,zt.fromJSON=Nc,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=bt.V5){const r=zg(e,t);return new st(r,Ii(e),t,n)}function xg(e,t=bt.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=bt.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<bt.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]=pt.decode(r,t));return n}function Fc(e,t){const n=[];for(let r,i=-1,s=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++s]=pt.decode(r,t));return n}function Yg(e,t){let n,r,i,s,o,a;return!t||!(a=e.dictionary())?(i=Uc(e,Fc(e,t)),r=new pt(e.name(),i,e.nullable(),Ii(e))):t.has(n=ht(a.id()))?(s=(s=a.indexType())?Mc(s):new Kn,o=new fn(t.get(n),s,n,a.isOrdered()),r=new pt(e.name(),o,e.nullable(),Ii(e))):(s=(s=a.indexType())?Mc(s):new Kn,t.set(n,i=Uc(e,Fc(e,t))),o=new fn(i,s,n,a.isOrdered()),r=new pt(e.name(),o,e.nullable(),Ii(e))),r||null}function Ii(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 Mc(e){return new Je(e.isSigned(),e.bitWidth())}function Uc(e,t){const n=e.typeType();switch(n){case ft.NONE:return new Ue;case ft.Null:return new Ue;case ft.Binary:return new Hr;case ft.LargeBinary:return new Kr;case ft.Utf8:return new Qr;case ft.LargeUtf8:return new Xr;case ft.Bool:return new Jr;case ft.List:return new si((t||[])[0]);case ft.Struct_:return new Ot(t||[])}switch(n){case ft.Int:{const r=e.type(new Pt);return new Je(r.isSigned(),r.bitWidth())}case ft.FloatingPoint:{const r=e.type(new ce);return new Wr(r.precision())}case ft.Decimal:{const r=e.type(new un);return new Zr(r.scale(),r.precision(),r.bitWidth())}case ft.Date:{const r=e.type(new zr);return new ti(r.unit())}case ft.Time:{const r=e.type(new qt);return new ei(r.unit(),r.bitWidth())}case ft.Timestamp:{const r=e.type(new Gt);return new ni(r.unit(),r.timezone())}case ft.Interval:{const r=e.type(new ue);return new ri(r.unit())}case ft.Duration:{const r=e.type(new Yr);return new ii(r.unit())}case ft.Union:{const r=e.type(new xt);return new oi(r.mode(),r.typeIdsArray()||[],t||[])}case ft.FixedSizeBinary:{const r=e.type(new jr);return new ai(r.byteWidth())}case ft.FixedSizeList:{const r=e.type(new qr);return new li(r.listSize(),(t||[])[0])}case ft.Map:{const r=e.type(new Gr);return new ci((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${ft[n]}" (${n})`)}function jg(e,t){const n=t.fields.map(s=>pt.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}`),l=e.createString(`${o}`);return St.startKeyValue(e),St.addKey(e,a),St.addValue(e,l),St.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=Ms.visit(s,e),r=Ms.visit(s.dictionary,e)):r=Ms.visit(s,e);const a=(s.children||[]).map(u=>pt.encode(e,u)),l=Wt.createChildrenVector(e,a),c=t.metadata&&t.metadata.size>0?Wt.createCustomMetadataVector(e,[...t.metadata].map(([u,d])=>{const y=e.createString(`${u}`),m=e.createString(`${d}`);return St.startKeyValue(e),St.addKey(e,y),St.addValue(e,m),St.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,l),Wt.addNullable(e,!!t.nullable),n!==-1&&Wt.addName(e,n),i!==-1&&Wt.addDictionary(e,i),c!==-1&&Wt.addCustomMetadata(e,c),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 Fa.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Kg(e,t){return La.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})(),Us=e=>`Expected ${et[e]} Message in stream, but was null or length 0.`,xs=e=>`Header pointer of flatbuffer-encoded ${et[e]} Message is null or length 0.`,xc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,Cc=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class $c{constructor(t){this.source=t instanceof _i?t:new _i(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?Et: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(Us(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=Q(this.source.read(t));if(n.byteLength<t)throw new Error(Cc(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(xs(n));return i}readMetadataLength(){const t=this.source.read(Si),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 Et;if(n.byteLength<t)throw new Error(xc(t,n.byteLength));return{done:!1,value:Ft.decode(n)}}}class Xg{constructor(t,n){this.source=t instanceof wn?t:Ia(t)?new bi(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?Et: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(Us(t));return n.value})}readMessageBody(t){return Y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=Q(yield this.source.read(t));if(n.byteLength<t)throw new Error(Cc(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(xs(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(Si),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 Et;if(n.byteLength<t)throw new Error(xc(t,n.byteLength));return{done:!1,value:Ft.decode(n)}})}}class Jg extends $c{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof bc?t:new bc(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=[],Et}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(Us(t));return n.value}readSchema(){const t=et.Schema,n=this.readMessage(t),r=n?.header();if(!n||!r)throw new Error(xs(t));return r}}const Si=4,Cs="ARROW1",er=new Uint8Array(Cs.length);for(let e=0;e<Cs.length;e+=1)er[e]=Cs.codePointAt(e);function $s(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,kc=nr+Si,Zg=nr*2+Si;class Qt extends As{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:is(t)?r_(t):Ia(t)?o_(t):Qe(t)?Y(this,void 0,void 0,function*(){return yield Qt.from(yield t)}):Sa(t)||ss(t)||Ea(t)||on(t)?s_(new wn(t)):i_(new _i(t))}static readAll(t){return t instanceof Qt?t.isSync()?jc(t):qc(t):is(t)||ArrayBuffer.isView(t)||jn(t)||wa(t)?jc(t):qc(t)}}class Ei 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 j(yield*Ur(Ke(this[Symbol.iterator]())))})}}class Ti 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),l;l=yield a.next(),t=l.done,!t;o=!0){i=l.value,o=!1;const c=i;s.push(c)}}catch(c){n={error:c}}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 Pc extends Ei{constructor(t){super(t),this._impl=t}}class t_ extends Ti{constructor(t){super(t),this._impl=t}}class Vc{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=K({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),l=o.dictionaries.get(r),c=this._loadVectors(t.data,n,[l]);return(a&&i?a.concat(new it(c)):new it(c)).memoize()}_loadVectors(t,n,r){return new Ic(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class Ai extends Vc{constructor(t,n){super(n),this._reader=is(t)?new Jg(this._handle=t):new $c(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=Yc(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):Et}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Et}next(){if(this.closed)return Et;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 Fs(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ni extends Vc{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=Yc(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):Et})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Et})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return Et;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 Fs(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class zc 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){super(t instanceof vc?t:new vc(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-kc,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 Ni{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 bi?t:new bi(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-kc,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 Ai{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 Yc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*jc(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 qc(e){return se(this,arguments,function*(){const t=yield j(Qt.from(e));try{if(!(yield j(t.open({autoDestroy:!1}))).closed)do yield yield j(t);while(!(yield j(t.reset().open())).closed)}finally{yield j(t.cancel())}})}function r_(e){return new Ei(new n_(e))}function i_(e){const t=e.peek(nr+7&-8);return t&&t.byteLength>=4?$s(t)?new Pc(new zc(e.read())):new Ei(new Ai(e)):new Ei(new Ai((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?$s(t)?new Pc(new zc(yield e.read())):new Ti(new Ni(e)):new Ti(new Ni((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 bi(e,t);return t>=Zg&&$s(yield n.readAt(0,nr+7&-8))?new t_(new e_(n)):new Ti(new Ni(n))})}class gt extends G{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof $t?s.data.children:s.data),r=new gt;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):hi(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 Ps.call(this,e);if(n.mode===Nt.Dense){if(e.offset<=0)return ne.call(this,s),Ps.call(this,e);{const o=new Int32Array(r),a=Object.create(null),l=Object.create(null);for(let c,u,d=-1;++d<r;)(c=i[d])!==void 0&&((u=a[c])===void 0&&(u=a[c]=s[d]),o[d]=s[d]-u,l[c]=((t=l[c])!==null&&t!==void 0?t:0)+1);ne.call(this,o),this.visitMany(e.children.map((c,u)=>{const d=n.typeIds[u],y=a[d],m=l[d];return c.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,hi(e.offset,e.length,t)):ne.call(this,di(e.values))}function Ne(e){return ne.call(this,e.values.subarray(0,e.length*e.stride))}function Ri(e){const{length:t,values:n,valueOffsets:r}=e,i=ht(r[0]),s=ht(r[t]),o=Math.min(s-i,n.byteLength-i);return ne.call(this,Ra(-i,t+1,r)),ne.call(this,n.subarray(i,i+o)),this}function ks(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return ne.call(this,Ra(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Ps(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}gt.prototype.visitBool=l_,gt.prototype.visitInt=Ne,gt.prototype.visitFloat=Ne,gt.prototype.visitUtf8=Ri,gt.prototype.visitLargeUtf8=Ri,gt.prototype.visitBinary=Ri,gt.prototype.visitLargeBinary=Ri,gt.prototype.visitFixedSizeBinary=Ne,gt.prototype.visitDate=Ne,gt.prototype.visitTimestamp=Ne,gt.prototype.visitTime=Ne,gt.prototype.visitDecimal=Ne,gt.prototype.visitList=ks,gt.prototype.visitStruct=Ps,gt.prototype.visitUnion=a_,gt.prototype.visitInterval=Ne,gt.prototype.visitDuration=Ne,gt.prototype.visitFixedSizeList=ks,gt.prototype.visitMap=ks;class Gc extends As{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 gi,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)?js(this,t):Ys(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 gi?this._sink=t:(this._sink=new gi,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||!Ds(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&&!Ds(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof $t?t instanceof Fs||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,l=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(l)}_write(t){if(this._started){const n=Q(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}=gt.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}=gt.assemble(new it([t])),l=new zt(t.length,s,o),c=new fe(l,n,r),u=Ft.from(c,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),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!a||a.data[0]!==o[0])for(const[c,u]of o.entries())this._writeDictionaryBatch(u,i,c>0);else if(l<o.length)for(const c of o.slice(l))this._writeDictionaryBatch(c,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}}class Vs extends Gc{static writeAll(t,n){const r=new Vs(n);return Qe(t)?t.then(i=>r.writeAll(i)):on(t)?js(r,t):Ys(r,t)}}class zs extends Gc{static writeAll(t){const n=new zs;return Qe(t)?t.then(r=>n.writeAll(r)):on(t)?js(n,t):Ys(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,bt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Ys(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 js(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,o,a,l;try{for(n=!0,r=Ke(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const c=l;e.write(c)}}catch(c){o={error:c}}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"?Vs:zs).writeAll(e).toUint8Array(!0)}var u_=Object.create,Wc=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&&Wc(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?Wc(n,"default",{value:e,enumerable:!0}):n,e)),__=y_((e,t)=>{t.exports=Worker}),Hc=(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))(Hc||{}),Kc=(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))(Kc||{}),Qc=(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))(Qc||{}),Xc=(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))(Xc||{}),Jc=(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))(Jc||{}),Zc=(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))(Zc||{}),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 tu=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(tu||{}),eu=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 qs(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 nu(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)}},qs=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}},nu=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 qs(this.bindings,this.connectionId,t),r=await Qt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},ru=(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))(ru||{}),iu=(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))(iu||{}),X=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 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:Bi(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=>Gs(t.name,t.type))};case p.Map:{let t=e;return{sqlType:"map",keyType:Bi(t.keyType),valueType:Bi(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 Gs(e,t){let n=Bi(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 X("RESET",null);return await this.postTask(e)}async ping(){let e=new X("PING",null);await this.postTask(e)}async dropFile(e){let t=new X("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new X("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new X("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new X("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new X("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new X("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new X("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new X("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new X("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new eu(this,e)}async disconnect(e){let t=new X("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new X("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new X("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new X("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new X("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new X("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new X("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new X("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new X("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new X("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new X("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new X("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 X("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new X("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new X("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new X("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new X("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new X("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new X("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new X("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new X("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(Gs(s,o))}n.columnsFlat=i,delete n.columns}let r=new X("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(Gs(s,o))}n.columnsFlat=i,delete n.columns}let r=new X("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 su=(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))(su||{}),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])),Ws={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},ou=Ws.name,au=Ws.version,Hs=Ws.version.split("."),F_=Hs[0],M_=Hs[1],U_=Hs[2],Ks=()=>typeof navigator>"u",lu=()=>Ks()?"node":navigator.userAgent,x_=()=>lu().includes("Firefox"),C_=()=>/^((?!chrome|android).)*safari/i.test(lu());function $_(){let e="https://cdn.jsdelivr.net/npm/".concat(ou,"@").concat(au,"/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 Qs=null,Xs=null,Js=null,Zs=null,to=null;async function cu(){return Qs==null&&(Qs=typeof BigInt64Array<"u"),Xs==null&&(Xs=await O_()),Js==null&&(Js=await L_()),Zs==null&&(Zs=await D_()),to==null&&(to=await B_()),{bigInt64Array:Qs,crossOriginIsolated:Ks()||globalThis.crossOriginIsolated||!1,wasmExceptions:Xs,wasmSIMD:Zs,wasmThreads:Js,wasmBulkMemory:to}}async function k_(e){let t=await cu();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:eu,AsyncDuckDBDispatcher:R_,AsyncPreparedStatement:nu,AsyncResultStreamIterator:qs,ConsoleLogger:v_,DuckDBAccessMode:Hc,DuckDBDataProtocol:su,LogEvent:Jc,LogLevel:Qc,LogOrigin:Zc,LogTopic:Xc,PACKAGE_NAME:ou,PACKAGE_VERSION:au,PACKAGE_VERSION_MAJOR:F_,PACKAGE_VERSION_MINOR:M_,PACKAGE_VERSION_PATCH:U_,StatusCode:tu,TokenType:Kc,VoidLogger:b_,WorkerRequestType:ru,WorkerResponseType:iu,WorkerTask:X,createWorker:V_,getJsDelivrBundles:$_,getLogEventLabel:I_,getLogLevelLabel:w_,getLogOriginLabel:E_,getLogTopicLabel:S_,getPlatformFeatures:cu,isFirefox:x_,isNode:Ks,isSafari:C_,selectBundle:k_},Symbol.toStringTag,{value:"Module"}));Xt.DataExplorer=Fy,Xt.UMAP=Uy,Object.defineProperty(Xt,Symbol.toStringTag,{value:"Module"})}));
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"})}));