precision-dashwidgets 0.2.0 → 0.2.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,17 +1,17 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(ne,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("vue"),require("element-plus"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","pinia"],h):(ne=typeof globalThis<"u"?globalThis:ne||self,h(ne["precision-dashwidgets"]={},ne.Vue,ne.ElementPlus,ne.Pinia))})(this,(function(ne,h,Pc,Vc){"use strict";/*! Element Plus Icons Vue v2.3.2 */var zc=h.defineComponent({name:"InfoFilled",__name:"info-filled",setup(e){return(t,n)=>(h.openBlock(),h.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[h.createElementVNode("path",{fill:"currentColor",d:"M512 64a448 448 0 1 1 0 896.064A448 448 0 0 1 512 64m67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344M590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.99 12.99 0 0 1-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 0 1 7.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"})]))}}),jc=zc;function ft(e){return e!=null&&typeof e=="object"&&e["@@functional/placeholder"]===!0}function Ye(e){return function t(n){return arguments.length===0||ft(n)?t:e.apply(this,arguments)}}function We(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:Ye(function(i){return e(n,i)});default:return ft(n)&&ft(r)?t:ft(n)?Ye(function(i){return e(i,r)}):ft(r)?Ye(function(i){return e(n,i)}):e(n,r)}}}function Yc(e){return function t(n,r,i){switch(arguments.length){case 0:return t;case 1:return ft(n)?t:We(function(s,a){return e(n,s,a)});case 2:return ft(n)&&ft(r)?t:ft(n)?We(function(s,a){return e(s,r,a)}):ft(r)?We(function(s,a){return e(n,s,a)}):Ye(function(s){return e(n,r,s)});default:return ft(n)&&ft(r)&&ft(i)?t:ft(n)&&ft(r)?We(function(s,a){return e(s,a,i)}):ft(n)&&ft(i)?We(function(s,a){return e(s,r,a)}):ft(r)&&ft(i)?We(function(s,a){return e(n,s,a)}):ft(n)?Ye(function(s){return e(s,r,i)}):ft(r)?Ye(function(s){return e(n,s,i)}):ft(i)?Ye(function(s){return e(n,r,s)}):e(n,r,i)}}}const Wc=Number.isInteger||function(e){return e<<0===e};function qc(e,t){var n=e<0?t.length+e:e;return t[n]}var Gc=We(function(e,t){return t==null||t!==t?e:t});function Hc(e,t){for(var n=t,r=0;r<e.length;r+=1){if(n==null)return;var i=e[r];Wc(i)?n=qc(i,n):n=n[i]}return n}var Kc=Yc(function(e,t,n){return Gc(e,Hc(t,n))});const js=Vc.defineStore("duckdb",()=>{const e=h.ref(null),t=h.ref(!1),n=h.ref(!1),r=h.ref(""),i=h.ref(new Map),s=h.ref(new Map),a=h.ref(new Map);let o=null;const l=h.computed(()=>t.value&&!r.value),c=h.computed(()=>N=>i.value.get(N)),d=h.computed(()=>N=>{const F=i.value.get(N);return F&&!F.isLoading&&!F.error}),y=h.computed(()=>s.value.size),_=h.computed(()=>s.value.size>0),v=async()=>{if(typeof window>"u"||typeof Worker>"u"){const N="DuckDB can only be initialized in the browser.";throw r.value=N,new Error(N)}return e.value?e.value:o?(await o,e.value):(n.value=!0,r.value="",o=(async()=>{try{const N=await Promise.resolve().then(()=>bb),F={mvp:{mainModule:"/static/duckdb/duckdb-mvp.wasm",mainWorker:"/static/duckdb/duckdb-browser-mvp.worker.js"},eh:{mainModule:"/static/duckdb/duckdb-eh.wasm",mainWorker:"/static/duckdb/duckdb-browser-eh.worker.js"}},p=await N.selectBundle(F),g=new Worker(p.mainWorker),u=new N.ConsoleLogger(N.LogLevel.WARNING);return e.value=new N.AsyncDuckDB(u,g),await e.value.instantiate(p.mainModule),t.value=!0,e.value}catch(N){throw r.value=`Failed to initialize DuckDB: ${(N==null?void 0:N.message)||N}`,e.value=null,N}finally{n.value=!1,o=null}})(),await o,e.value)},E=async N=>{e.value||await v();const F=await e.value.connect(),p=N||`conn_${Date.now()}_${Math.random().toString(36).slice(2,11)}`;return s.value.set(p,{connection:F,viewerId:p,createdAt:new Date}),{connection:F,connectionId:p}},T=async N=>{const F=s.value.get(N);F&&(await F.connection.close(),s.value.delete(N),R(N),s.value.size===0&&console.log("No active connections remaining. Keeping DuckDB instance for potential reuse."))},R=N=>{for(const[F,p]of a.value)p.delete(N),p.size===0&&console.log(`File ${F} is no longer used by any viewers`)},B=(N,F)=>{a.value.has(N)||a.value.set(N,new Set),a.value.get(N).add(F)},J=async N=>{const F=i.value.get(N);if(F&&F.tableName)try{const p=await e.value.connect();await p.query(`DROP TABLE IF EXISTS ${F.tableName};`),await p.close()}catch(p){console.warn(`Failed to drop table ${F.tableName}:`,p)}i.value.delete(N),a.value.delete(N)},at=async(N,F,p="my_data",g={},u=null,m=null)=>{const b=m||N,w=i.value.get(b);if(w&&!w.isLoading&&!w.error)return u&&B(b,u),w.tableName;l.value||await v(),i.value.set(b,{tableName:p,fileType:F,fileUrl:N,isLoading:!0,error:null});try{const I=await fetch(N);if(!I.ok)throw new Error(`Failed to fetch file: ${I.status} ${I.statusText}`);let S;if(F==="csv"){const M=await I.text(),K=await new Blob([M],{type:"text/csv"}).arrayBuffer();S=new Uint8Array(K)}else{const M=await I.arrayBuffer();S=new Uint8Array(M)}const O=`${m||p}.${F}`;await e.value.registerFileBuffer(O,S);const A=await e.value.connect();try{let M;if(F==="csv"){const G={header:!0,delimiter:",",...g};M=`
|
|
2
2
|
CREATE OR REPLACE TABLE ${p} AS
|
|
3
|
-
SELECT * FROM read_csv('${O}', header=${
|
|
3
|
+
SELECT * FROM read_csv('${O}', header=${G.header}, delim='${G.delimiter}');
|
|
4
4
|
`}else if(F==="parquet")M=`
|
|
5
5
|
CREATE OR REPLACE TABLE ${p} AS
|
|
6
6
|
SELECT * FROM read_parquet('${O}');
|
|
7
|
-
`;else throw new Error(`Unsupported file type: ${F}`);await A.query(M);const
|
|
7
|
+
`;else throw new Error(`Unsupported file type: ${F}`);await A.query(M);const K=(await A.query(`SELECT COUNT(*) as count FROM ${p};`)).toArray()[0].count;return i.value.set(b,{tableName:p,fileType:F,fileUrl:N,isLoading:!1,error:null,rowCount:K,loadedAt:new Date}),u&&B(b,u),p}finally{await A.close()}}catch(I){throw i.value.set(b,{tableName:p,fileType:F,fileUrl:N,isLoading:!1,error:I.message}),I}},bt=async(N,F)=>{const p=s.value.get(F);if(!p)throw new Error(`Connection not found: ${F}`);return(await p.connection.query(N)).toArray().map(g=>{const u={};for(const[m,b]of Object.entries(g))u[m]=b;return u})},gt=async()=>{for(const[N,F]of s.value)try{await F.connection.close(),console.log(`Closed connection: ${N}`)}catch(p){console.warn(`Error closing connection ${N}:`,p)}if(s.value.clear(),e.value){try{await e.value.terminate()}catch(N){console.warn("Error terminating DuckDB:",N)}e.value=null}t.value=!1,i.value.clear(),a.value.clear(),r.value=""},_t=async(N=!1)=>{N||s.value.size===0?await gt():console.log(`Skipping global cleanup. ${s.value.size} active connections remaining.`)},St=()=>{const N=[];for(const[F,p]of s.value)N.push({connectionId:F,viewerId:p.viewerId,createdAt:p.createdAt});return N},Pt=()=>{const N=[];for(const[F,p]of a.value){const g=i.value.get(F);N.push({fileId:F,tableName:g==null?void 0:g.tableName,fileType:g==null?void 0:g.fileType,fileUrl:g==null?void 0:g.fileUrl,rowCount:g==null?void 0:g.rowCount,loadedAt:g==null?void 0:g.loadedAt,usedByViewers:Array.from(p)})}return N},dt=h.ref(null),ht=h.ref(0);function te(N){return`"${String(N).replace(/"/g,'""')}"`}return{db:e,isInitialized:t,isInitializing:n,initError:r,loadedFiles:i,connections:s,fileUsage:a,sharedResultName:dt,sharedVersion:ht,isReady:l,getLoadedFile:c,isFileLoaded:d,activeConnectionCount:y,hasActiveConnections:_,initDuckDB:v,createConnection:E,closeConnection:T,cleanupViewerFileUsage:R,trackFileUsage:B,unloadFile:J,loadFile:at,executeQuery:bt,cleanup:_t,performGlobalCleanup:gt,getConnectionInfo:St,getFileUsageInfo:Pt,publishViewFromQuery:async(N,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE VIEW ${te(N)} AS ${F}`),dt.value=N,ht.value++},publishTableFromQuery:async(N,F,p)=>{var u;const g=(u=s.value.get(p))==null?void 0:u.connection;if(!g)throw new Error(`Connection not found: ${p}`);await g.query(`CREATE OR REPLACE TABLE ${te(N)} AS ${F}`),dt.value=N,ht.value++}}}),On=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Qc={class:"dashboard-container"},Xc={class:"dashboard-header"},Jc={class:"dashboard-content"},Zc={key:0,class:"query-panel"},tu={class:"query-examples"},eu=["onClick"],nu={key:1,class:"results-panel"},ru={class:"results-controls"},iu={class:"left-controls"},su={class:"right-controls"},au={key:0,class:"table-container"},ou={class:"results-table"},lu={key:0,class:"bottom-pagination"},cu={key:1,class:"json-container"},uu={key:2,class:"error-panel"},hu={__name:"DataExplorer",props:{url:{type:String,default:""},fileType:{type:String,default:"parquet",validator:e=>["parquet","csv"].includes(e)},viewerId:{type:String,default:()=>`viewer_${Date.now()}_${Math.random().toString(36).substr(2,9)}`},fileId:{type:String,default:null}},emits:["query-results"],setup(e,{emit:t}){const n=e,r=t,i=js(),s=h.ref({header:!0,dynamicTyping:!0,delimiter:","}),a=h.ref(!1),o=h.ref(!1),l=h.ref(n.url),c=h.ref("my_data"),d=h.ref(""),y=h.ref(null),_=h.ref(""),v=h.ref("table"),E=h.ref(1),T=h.ref(50),R=h.ref(null);h.watch(()=>n.url,async m=>{if(l.value=m,m)try{await Pt(),await ht()}catch{console.error("file can not be loaded")}},{immediate:!0});const B=h.computed(()=>i.isReady&&R.value&&!a.value),J=h.computed(()=>a.value?"Loading...":i.isInitializing?"Initializing...":i.isReady?B.value?"Connected":"Not Connected":"Not Ready"),at=h.computed(()=>!y.value||!Array.isArray(y.value)||y.value.length===0?[]:Object.keys(y.value[0]||{})),bt=h.computed(()=>!y.value||!Array.isArray(y.value)?0:Math.ceil(y.value.length/T.value)),gt=h.computed(()=>{if(!y.value||!Array.isArray(y.value))return[];const m=(E.value-1)*T.value,b=m+T.value;return y.value.slice(m,b)}),_t=h.computed(()=>[{name:"Show All",query:"SELECT * FROM data LIMIT 100;"},{name:"Count Rows",query:"SELECT COUNT(*) as row_count FROM data;"},{name:"Group By",query:`SELECT
|
|
8
8
|
column1, column2,
|
|
9
9
|
COUNT(*) as count
|
|
10
10
|
FROM data
|
|
11
11
|
GROUP BY column1, column2
|
|
12
12
|
ORDER BY column1, column2
|
|
13
|
-
LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);h.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:
|
|
14
|
-
`),w=new Blob([b],{type:"text/csv"}),I=URL.createObjectURL(w),S=document.createElement("a");S.href=I,S.download="query-results.csv",S.click(),URL.revokeObjectURL(I)},u=()=>{_.value=""};return h.onMounted(async()=>{await It()}),h.onUnmounted(async()=>{N.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(N.value),i.activeConnectionCount,i.loadedFiles.size)}),(m,b)=>{const w=h.resolveComponent("bf-button"),I=h.resolveComponent("el-pagination");return h.openBlock(),h.createElementBlock("div",Qc,[h.createElementVNode("header",Xc,[b[3]||(b[3]=h.createElementVNode("h1",null,"Data Explorer",-1)),h.createElementVNode("div",{class:h.normalizeClass(["status-indicator",{connected:B.value,loading:a.value}])},h.toDisplayString(Q.value),3)]),h.createElementVNode("div",Jc,[B.value?(h.openBlock(),h.createElementBlock("div",Zc,[b[5]||(b[5]=h.createElementVNode("h3",null,"SQL Query",-1)),h.createElementVNode("div",tu,[b[4]||(b[4]=h.createElementVNode("span",null,"Quick queries:",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(gt.value,S=>(h.openBlock(),h.createElementBlock("button",{key:S.name,onClick:O=>F(S.query),class:"example-btn"},h.toDisplayString(S.name),9,eu))),128))]),h.withDirectives(h.createElementVNode("textarea",{"onUpdate:modelValue":b[0]||(b[0]=S=>d.value=S),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[h.vModelText,d.value]]),h.createVNode(w,{onClick:ht,disabled:o.value||!d.value},{default:h.withCtx(()=>[h.createTextVNode(h.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):h.createCommentVNode("",!0),y.value?(h.openBlock(),h.createElementBlock("div",nu,[h.createElementVNode("h3",null,"Results ("+h.toDisplayString(y.value.length)+" rows)",1),h.createElementVNode("div",ru,[h.createElementVNode("div",iu,[h.createVNode(w,{class:"secondary",onClick:g},{default:h.withCtx(()=>[...b[6]||(b[6]=[h.createTextVNode("Export to CSV",-1)])]),_:1})]),h.createElementVNode("div",su,[v.value==="table"&&mt.value>1?(h.openBlock(),h.createBlock(I,{key:0,"current-page":E.value,"onUpdate:currentPage":b[1]||(b[1]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:"prev, pager, next",onCurrentChange:Zt,class:"results-pagination"},null,8,["current-page","page-size","total"])):h.createCommentVNode("",!0)])]),b[7]||(b[7]=h.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),v.value==="table"?(h.openBlock(),h.createElementBlock("div",au,[h.createElementVNode("table",ou,[h.createElementVNode("thead",null,[h.createElementVNode("tr",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,S=>(h.openBlock(),h.createElementBlock("th",{key:S},h.toDisplayString(S),1))),128))])]),h.createElementVNode("tbody",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(bt.value,(S,O)=>(h.openBlock(),h.createElementBlock("tr",{key:O},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(it.value,A=>(h.openBlock(),h.createElementBlock("td",{key:A},h.toDisplayString(p(S[A])),1))),128))]))),128))])]),mt.value>1?(h.openBlock(),h.createElementBlock("div",lu,[h.createVNode(I,{"current-page":E.value,"onUpdate:currentPage":b[2]||(b[2]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:Zt,onSizeChange:R},null,8,["current-page","page-size","total"])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.createElementBlock("div",cu,[h.createElementVNode("pre",null,h.toDisplayString(JSON.stringify(y.value.slice(0,100),null,2)),1)]))])):h.createCommentVNode("",!0),_.value?(h.openBlock(),h.createElementBlock("div",uu,[b[8]||(b[8]=h.createElementVNode("h3",null,"Error",-1)),h.createElementVNode("p",null,h.toDisplayString(_.value),1),h.createElementVNode("button",{onClick:u,class:"clear-error-btn"},"Clear")])):h.createCommentVNode("",!0)])])}}},du=Sn(hu,[["__scopeId","data-v-6d7b972b"]]),fu={class:"app-container"},pu=h.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=h.ref([]),s=h.ref(""),a=h.ref("parquet"),o=h.ref("");h.onMounted(async()=>{var v,E,T,N,B;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),o.value=n.srcFileId??"url_"+btoa(n.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const _=Kc("",["content","id"],n.pkg);if(!_||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await d(_);const Q=(T=(E=(v=i.value)==null?void 0:v[0])==null?void 0:E.content)==null?void 0:T.id;if(!Q){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=Q,s.value=await y(_,Q);const it=(B=(N=n.pkg)==null?void 0:N.content)==null?void 0:B.packageType;a.value=it==="CSV"?"csv":"parquet"}catch(Q){console.error(Q)}});function l(_){r("queryResults",_)}async function c(){const{useGetToken:_}=await Promise.resolve().then(()=>Bc);return _()}async function d(_){const v=await c(),E=`${n.apiUrl}/packages/${_}/view?api_key=${v}`,T=await fetch(E);if(!T.ok)throw new Error(`view failed: ${T.status}`);i.value=await T.json()}async function y(_,v){const E=await c(),T=`${n.apiUrl}/packages/${_}/files/${v}?api_key=${E}`,N=await fetch(T);if(!N.ok)throw new Error(`file url failed: ${N.status}`);return(await N.json()).url}return(_,v)=>(h.openBlock(),h.createElementBlock("div",fu,[h.createVNode(du,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:v[0]||(v[0]=E=>l(E))},null,8,["url","file-type","file-id"])]))}}),yu=Sn(pu,[["__scopeId","data-v-d6dbc8b5"]]);var mu={value:()=>{}};function vi(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new sr(n)}function sr(e){this._=e}function bu(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}sr.prototype=vi.prototype={constructor:sr,on:function(e,t){var n=this._,r=bu(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=gu(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=Ys(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ys(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new sr(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function gu(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ys(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=mu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var wi="http://www.w3.org/1999/xhtml";const Ws={svg:"http://www.w3.org/2000/svg",xhtml:wi,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ar(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ws.hasOwnProperty(t)?{space:Ws[t],local:e}:e}function _u(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===wi&&t.documentElement.namespaceURI===wi?t.createElement(e):t.createElementNS(n,e)}}function vu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qs(e){var t=ar(e);return(t.local?vu:_u)(t)}function wu(){}function Ii(e){return e==null?wu:function(){return this.querySelector(e)}}function Iu(e){typeof e!="function"&&(e=Ii(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,c,d=0;d<a;++d)(l=s[d])&&(c=e.call(l,l.__data__,d,s))&&("__data__"in l&&(c.__data__=l.__data__),o[d]=c);return new xt(r,this._parents)}function Su(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Eu(){return[]}function Gs(e){return e==null?Eu:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return Su(e.apply(this,arguments))}}function Au(e){typeof e=="function"?e=Tu(e):e=Gs(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&(r.push(e.call(l,l.__data__,c,a)),i.push(l));return new xt(r,i)}function Hs(e){return function(){return this.matches(e)}}function Ks(e){return function(t){return t.matches(e)}}var Nu=Array.prototype.find;function Bu(e){return function(){return Nu.call(this.children,e)}}function Ru(){return this.firstElementChild}function Ou(e){return this.select(e==null?Ru:Bu(typeof e=="function"?e:Ks(e)))}var Du=Array.prototype.filter;function Fu(){return Array.from(this.children)}function Mu(e){return function(){return Du.call(this.children,e)}}function Lu(e){return this.selectAll(e==null?Fu:Mu(typeof e=="function"?e:Ks(e)))}function xu(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new xt(r,this._parents)}function Qs(e){return new Array(e.length)}function Uu(){return new xt(this._enter||this._groups.map(Qs),this._parents)}function or(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}or.prototype={constructor:or,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Cu(e){return function(){return e}}function ku(e,t,n,r,i,s){for(var a=0,o,l=t.length,c=s.length;a<c;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new or(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function $u(e,t,n,r,i,s,a){var o,l,c=new Map,d=t.length,y=s.length,_=new Array(d),v;for(o=0;o<d;++o)(l=t[o])&&(_[o]=v=a.call(l,l.__data__,o,t)+"",c.has(v)?i[o]=l:c.set(v,l));for(o=0;o<y;++o)v=a.call(e,s[o],o,s)+"",(l=c.get(v))?(r[o]=l,l.__data__=s[o],c.delete(v)):n[o]=new or(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&c.get(_[o])===l&&(i[o]=l)}function Pu(e){return e.__data__}function Vu(e,t){if(!arguments.length)return Array.from(this,Pu);var n=t?$u:ku,r=this._parents,i=this._groups;typeof e!="function"&&(e=Cu(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),c=0;c<s;++c){var d=r[c],y=i[c],_=y.length,v=zu(e.call(d,d&&d.__data__,c,r)),E=v.length,T=o[c]=new Array(E),N=a[c]=new Array(E),B=l[c]=new Array(_);n(d,y,T,N,B,v,t);for(var Q=0,it=0,mt,bt;Q<E;++Q)if(mt=T[Q]){for(Q>=it&&(it=Q+1);!(bt=N[it])&&++it<E;);mt._next=bt||null}}return a=new xt(a,r),a._enter=o,a._exit=l,a}function zu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ju(){return new xt(this._exit||this._groups.map(Qs),this._parents)}function Yu(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function Wu(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var c=n[l],d=r[l],y=c.length,_=o[l]=new Array(y),v,E=0;E<y;++E)(v=c[E]||d[E])&&(_[E]=v);for(;l<i;++l)o[l]=n[l];return new xt(o,this._parents)}function qu(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function Gu(e){e||(e=Hu);function t(y,_){return y&&_?e(y.__data__,_.__data__):!y-!_}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),c,d=0;d<o;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new xt(i,this._parents).order()}function Hu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ku(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qu(){return Array.from(this)}function Xu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function Ju(){let e=0;for(const t of this)++e;return e}function Zu(){return!this.node()}function th(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function eh(e){return function(){this.removeAttribute(e)}}function nh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t){return function(){this.setAttribute(e,t)}}function ih(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ah(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function oh(e,t){var n=ar(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?nh:eh:typeof t=="function"?n.local?ah:sh:n.local?ih:rh)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lh(e){return function(){this.style.removeProperty(e)}}function ch(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uh(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hh(e,t,n){return arguments.length>1?this.each((t==null?lh:typeof t=="function"?uh:ch)(e,t,n??"")):Qe(this.node(),e)}function Qe(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function dh(e){return function(){delete this[e]}}function fh(e,t){return function(){this[e]=t}}function ph(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yh(e,t){return arguments.length>1?this.each((t==null?dh:typeof t=="function"?ph:fh)(e,t)):this.node()[e]}function Js(e){return e.trim().split(/^|\s+/)}function Si(e){return e.classList||new Zs(e)}function Zs(e){this._node=e,this._names=Js(e.getAttribute("class")||"")}Zs.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ta(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function ea(e,t){for(var n=Si(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mh(e){return function(){ta(this,e)}}function bh(e){return function(){ea(this,e)}}function gh(e,t){return function(){(t.apply(this,arguments)?ta:ea)(this,e)}}function _h(e,t){var n=Js(e+"");if(arguments.length<2){for(var r=Si(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?gh:t?mh:bh)(n,t))}function vh(){this.textContent=""}function wh(e){return function(){this.textContent=e}}function Ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sh(e){return arguments.length?this.each(e==null?vh:(typeof e=="function"?Ih:wh)(e)):this.node().textContent}function Eh(){this.innerHTML=""}function Th(e){return function(){this.innerHTML=e}}function Ah(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Nh(e){return arguments.length?this.each(e==null?Eh:(typeof e=="function"?Ah:Th)(e)):this.node().innerHTML}function Bh(){this.nextSibling&&this.parentNode.appendChild(this)}function Rh(){return this.each(Bh)}function Oh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dh(){return this.each(Oh)}function Fh(e){var t=typeof e=="function"?e:qs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Mh(){return null}function Lh(e,t){var n=typeof e=="function"?e:qs(e),r=t==null?Mh:typeof t=="function"?t:Ii(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function xh(){var e=this.parentNode;e&&e.removeChild(this)}function Uh(){return this.each(xh)}function Ch(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $h(e){return this.select(e?kh:Ch)}function Ph(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vh(e){return function(t){e.call(this,t,this.__data__)}}function zh(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function jh(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function Yh(e,t,n){return function(){var r=this.__on,i,s=Vh(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function Wh(e,t,n){var r=zh(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,d;l<c;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?Yh:jh,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function na(e,t,n){var r=Xs(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function qh(e,t){return function(){return na(this,e,t)}}function Gh(e,t){return function(){return na(this,e,t.apply(this,arguments))}}function Hh(e,t){return this.each((typeof t=="function"?Gh:qh)(e,t))}function*Kh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var ra=[null];function xt(e,t){this._groups=e,this._parents=t}function En(){return new xt([[document.documentElement]],ra)}function Qh(){return this}xt.prototype=En.prototype={constructor:xt,select:Iu,selectAll:Au,selectChild:Ou,selectChildren:Lu,filter:xu,data:Vu,enter:Uu,exit:ju,join:Yu,merge:Wu,selection:Qh,order:qu,sort:Gu,call:Ku,nodes:Qu,node:Xu,size:Ju,empty:Zu,each:th,attr:oh,style:hh,property:yh,classed:_h,text:Sh,html:Nh,raise:Rh,lower:Dh,append:Fh,insert:Lh,remove:Uh,clone:$h,datum:Ph,on:Wh,dispatch:Hh,[Symbol.iterator]:Kh};function pe(e){return typeof e=="string"?new xt([[document.querySelector(e)]],[document.documentElement]):new xt([[e]],ra)}function Xh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=Xh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ei={capture:!0,passive:!1};function Ti(e){e.preventDefault(),e.stopImmediatePropagation()}function Jh(e){var t=e.document.documentElement,n=pe(e).on("dragstart.drag",Ti,Ei);"onselectstart"in t?n.on("selectstart.drag",Ti,Ei):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zh(e,t){var n=e.document.documentElement,r=pe(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ti,Ei),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}function Ai(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ia(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Tn(){}var An=.7,lr=1/An,Xe="\\s*([+-]?\\d+)\\s*",Nn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ee="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",td=/^#([0-9a-f]{3,8})$/,ed=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),nd=new RegExp(`^rgb\\(${ee},${ee},${ee}\\)$`),rd=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${Nn}\\)$`),id=new RegExp(`^rgba\\(${ee},${ee},${ee},${Nn}\\)$`),sd=new RegExp(`^hsl\\(${Nn},${ee},${ee}\\)$`),ad=new RegExp(`^hsla\\(${Nn},${ee},${ee},${Nn}\\)$`),sa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ai(Tn,Bn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:od,formatHsl:ld,formatRgb:oa,toString:oa});function aa(){return this.rgb().formatHex()}function od(){return this.rgb().formatHex8()}function ld(){return da(this).formatHsl()}function oa(){return this.rgb().formatRgb()}function Bn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=td.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?la(t):n===3?new Ot(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?cr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?cr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ed.exec(e))?new Ot(t[1],t[2],t[3],1):(t=nd.exec(e))?new Ot(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rd.exec(e))?cr(t[1],t[2],t[3],t[4]):(t=id.exec(e))?cr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sd.exec(e))?ha(t[1],t[2]/100,t[3]/100,1):(t=ad.exec(e))?ha(t[1],t[2]/100,t[3]/100,t[4]):sa.hasOwnProperty(e)?la(sa[e]):e==="transparent"?new Ot(NaN,NaN,NaN,0):null}function la(e){return new Ot(e>>16&255,e>>8&255,e&255,1)}function cr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Ot(e,t,n,r)}function cd(e){return e instanceof Tn||(e=Bn(e)),e?(e=e.rgb(),new Ot(e.r,e.g,e.b,e.opacity)):new Ot}function Ni(e,t,n,r){return arguments.length===1?cd(e):new Ot(e,t,n,r??1)}function Ot(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ai(Ot,Ni,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ot(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Ot(Pe(this.r),Pe(this.g),Pe(this.b),ur(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ca,formatHex:ca,formatHex8:ud,formatRgb:ua,toString:ua}));function ca(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function ud(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function ua(){const e=ur(this.opacity);return`${e===1?"rgb(":"rgba("}${Pe(this.r)}, ${Pe(this.g)}, ${Pe(this.b)}${e===1?")":`, ${e})`}`}function ur(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Pe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Pe(e),(e<16?"0":"")+e.toString(16)}function ha(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ht(e,t,n,r)}function da(e){if(e instanceof Ht)return new Ht(e.h,e.s,e.l,e.opacity);if(e instanceof Tn||(e=Bn(e)),!e)return new Ht;if(e instanceof Ht)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new Ht(a,o,l,e.opacity)}function hd(e,t,n,r){return arguments.length===1?da(e):new Ht(e,t,n,r??1)}function Ht(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ai(Ht,hd,ia(Tn,{brighter(e){return e=e==null?lr:Math.pow(lr,e),new Ht(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?An:Math.pow(An,e),new Ht(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Ot(Bi(e>=240?e-240:e+120,i,r),Bi(e,i,r),Bi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Ht(fa(this.h),hr(this.s),hr(this.l),ur(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ur(this.opacity);return`${e===1?"hsl(":"hsla("}${fa(this.h)}, ${hr(this.s)*100}%, ${hr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fa(e){return e=(e||0)%360,e<0?e+360:e}function hr(e){return Math.max(0,Math.min(1,e||0))}function Bi(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const pa=e=>()=>e;function dd(e,t){return function(n){return e+n*t}}function fd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function pd(e){return(e=+e)==1?ya:function(t,n){return n-t?fd(t,n,e):pa(isNaN(t)?n:t)}}function ya(e,t){var n=t-e;return n?dd(e,n):pa(isNaN(e)?t:e)}const ma=function e(t){var n=pd(t);function r(i,s){var a=n((i=Ni(i)).r,(s=Ni(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=ya(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=e,r}(1);function Ne(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Ri=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oi=new RegExp(Ri.source,"g");function yd(e){return function(){return e}}function md(e){return function(t){return e(t)+""}}function bd(e,t){var n=Ri.lastIndex=Oi.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Ri.exec(e))&&(i=Oi.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Ne(r,i)})),n=Oi.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?md(l[0].x):yd(t):(t=l.length,function(c){for(var d=0,y;d<t;++d)o[(y=l[d]).i]=y.x(c);return o.join("")})}var ba=180/Math.PI,ga={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _a(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*ba,skewX:Math.atan(l)*ba,scaleX:a,scaleY:o}}var dr;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ga:_a(t.a,t.b,t.c,t.d,t.e,t.f)}function _d(e){return e==null||(dr||(dr=document.createElementNS("http://www.w3.org/2000/svg","g")),dr.setAttribute("transform",e),!(e=dr.transform.baseVal.consolidate()))?ga:(e=e.matrix,_a(e.a,e.b,e.c,e.d,e.e,e.f))}function va(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function s(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push("translate(",null,t,null,n);E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y||_)&&v.push("translate("+y+t+_+n)}function a(c,d,y,_){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),_.push({i:y.push(i(y)+"rotate(",null,r)-2,x:Ne(c,d)})):d&&y.push(i(y)+"rotate("+d+r)}function o(c,d,y,_){c!==d?_.push({i:y.push(i(y)+"skewX(",null,r)-2,x:Ne(c,d)}):d&&y.push(i(y)+"skewX("+d+r)}function l(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push(i(v)+"scale(",null,",",null,")");E.push({i:T-4,x:Ne(c,y)},{i:T-2,x:Ne(d,_)})}else(y!==1||_!==1)&&v.push(i(v)+"scale("+y+","+_+")")}return function(c,d){var y=[],_=[];return c=e(c),d=e(d),s(c.translateX,c.translateY,d.translateX,d.translateY,y,_),a(c.rotate,d.rotate,y,_),o(c.skewX,d.skewX,y,_),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,y,_),c=d=null,function(v){for(var E=-1,T=_.length,N;++E<T;)y[(N=_[E]).i]=N.x(v);return y.join("")}}}var vd=va(gd,"px, ","px)","deg)"),wd=va(_d,", ",")",")"),Id=1e-12;function wa(e){return((e=Math.exp(e))+1/e)/2}function Sd(e){return((e=Math.exp(e))-1/e)/2}function Ed(e){return((e=Math.exp(2*e))-1)/(e+1)}const Td=function e(t,n,r){function i(s,a){var o=s[0],l=s[1],c=s[2],d=a[0],y=a[1],_=a[2],v=d-o,E=y-l,T=v*v+E*E,N,B;if(T<Id)B=Math.log(_/c)/t,N=function(It){return[o+It*v,l+It*E,c*Math.exp(t*It*B)]};else{var Q=Math.sqrt(T),it=(_*_-c*c+r*T)/(2*c*n*Q),mt=(_*_-c*c-r*T)/(2*_*n*Q),bt=Math.log(Math.sqrt(it*it+1)-it),gt=Math.log(Math.sqrt(mt*mt+1)-mt);B=(gt-bt)/t,N=function(It){var $t=It*B,dt=wa(bt),ht=c/(n*Q)*(dt*Ed(t*$t+bt)-Sd(bt));return[o+ht*v,l+ht*E,c*dt/wa(t*$t+bt)]}}return N.duration=B*1e3*t/Math.SQRT2,N}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i}(Math.SQRT2,2,4);var Je=0,Rn=0,On=0,Ia=1e3,fr,Dn,pr=0,ze=0,yr=0,Fn=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Di(){return ze||(Sa(Ad),ze=Fn.now()+yr)}function Ad(){ze=0}function mr(){this._call=this._time=this._next=null}mr.prototype=Ea.prototype={constructor:mr,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Di():+n)+(t==null?0:+t),!this._next&&Dn!==this&&(Dn?Dn._next=this:fr=this,Dn=this),this._call=e,this._time=n,Fi()},stop:function(){this._call&&(this._call=null,this._time=1/0,Fi())}};function Ea(e,t,n){var r=new mr;return r.restart(e,t,n),r}function Nd(){Di(),++Je;for(var e=fr,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Je}function Ta(){ze=(pr=Fn.now())+yr,Je=Rn=0;try{Nd()}finally{Je=0,Rd(),ze=0}}function Bd(){var e=Fn.now(),t=e-pr;t>Ia&&(yr-=t,pr=e)}function Rd(){for(var e,t=fr,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:fr=n);Dn=e,Fi(r)}function Fi(e){if(!Je){Rn&&(Rn=clearTimeout(Rn));var t=e-ze;t>24?(e<1/0&&(Rn=setTimeout(Ta,e-Fn.now()-yr)),On&&(On=clearInterval(On))):(On||(pr=Fn.now(),On=setInterval(Bd,Ia)),Je=1,Sa(Ta))}}function Aa(e,t,n){var r=new mr;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Od=vi("start","end","cancel","interrupt"),Dd=[],Na=0,Ba=1,Mi=2,br=3,Ra=4,Li=5,gr=6;function _r(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Fd(e,n,{name:t,index:r,group:i,on:Od,tween:Dd,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Na})}function xi(e,t){var n=Kt(e,t);if(n.state>Na)throw new Error("too late; already scheduled");return n}function ne(e,t){var n=Kt(e,t);if(n.state>br)throw new Error("too late; already running");return n}function Kt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Fd(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ea(s,0,n.time);function s(c){n.state=Ba,n.timer.restart(a,n.delay,n.time),n.delay<=c&&a(c-n.delay)}function a(c){var d,y,_,v;if(n.state!==Ba)return l();for(d in r)if(v=r[d],v.name===n.name){if(v.state===br)return Aa(a);v.state===Ra?(v.state=gr,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[d]):+d<t&&(v.state=gr,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[d])}if(Aa(function(){n.state===br&&(n.state=Ra,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=Mi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Mi){for(n.state=br,i=new Array(_=n.tween.length),d=0,y=-1;d<_;++d)(v=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++y]=v);i.length=y+1}}function o(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Li,1),y=-1,_=i.length;++y<_;)i[y].call(e,d);n.state===Li&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=gr,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function vr(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>Mi&&r.state<Li,r.state=gr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Md(e){return this.each(function(){vr(this,e)})}function Ld(e,t){var n,r;return function(){var i=ne(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function xd(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ne(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=o;break}l===c&&i.push(o)}s.tween=i}}function Ud(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Kt(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?Ld:xd)(n,e,t))}function Ui(e,t,n){var r=e._id;return e.each(function(){var i=ne(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Kt(i,r).value[t]}}function Oa(e,t){var n;return(typeof t=="number"?Ne:t instanceof Bn?ma:(n=Bn(t))?(t=n,ma):bd)(e,t)}function Cd(e){return function(){this.removeAttribute(e)}}function kd(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $d(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function Pd(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function Vd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function zd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function jd(e,t){var n=ar(e),r=n==="transform"?wd:Oa;return this.attrTween(e,typeof t=="function"?(n.local?zd:Vd)(n,r,Ui(this,"attr."+e,t)):t==null?(n.local?kd:Cd)(n):(n.local?Pd:$d)(n,r,t))}function Yd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Wd(e,s)),n}return i._value=t,i}function Gd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Yd(e,s)),n}return i._value=t,i}function Hd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=ar(e);return this.tween(n,(r.local?qd:Gd)(r,t))}function Kd(e,t){return function(){xi(this,e).delay=+t.apply(this,arguments)}}function Qd(e,t){return t=+t,function(){xi(this,e).delay=t}}function Xd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kd:Qd)(t,e)):Kt(this.node(),t).delay}function Jd(e,t){return function(){ne(this,e).duration=+t.apply(this,arguments)}}function Zd(e,t){return t=+t,function(){ne(this,e).duration=t}}function tf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jd:Zd)(t,e)):Kt(this.node(),t).duration}function ef(e,t){if(typeof t!="function")throw new Error;return function(){ne(this,e).ease=t}}function nf(e){var t=this._id;return arguments.length?this.each(ef(t,e)):Kt(this.node(),t).ease}function rf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ne(this,e).ease=n}}function sf(e){if(typeof e!="function")throw new Error;return this.each(rf(this._id,e))}function af(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new ye(r,this._parents,this._name,this._id)}function of(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],c=n[o],d=l.length,y=a[o]=new Array(d),_,v=0;v<d;++v)(_=l[v]||c[v])&&(y[v]=_);for(;o<r;++o)a[o]=t[o];return new ye(a,this._parents,this._name,this._id)}function lf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function cf(e,t,n){var r,i,s=lf(t)?xi:ne;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function uf(e,t){var n=this._id;return arguments.length<2?Kt(this.node(),n).on.on(e):this.each(cf(n,e,t))}function hf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function df(){return this.on("end.remove",hf(this._id))}function ff(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ii(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,c=s[a]=new Array(l),d,y,_=0;_<l;++_)(d=o[_])&&(y=e.call(d,d.__data__,_,o))&&("__data__"in d&&(y.__data__=d.__data__),c[_]=y,_r(c[_],t,n,_,c,Kt(d,n)));return new ye(s,this._parents,t,n)}function pf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gs(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],c=l.length,d,y=0;y<c;++y)if(d=l[y]){for(var _=e.call(d,d.__data__,y,l),v,E=Kt(d,n),T=0,N=_.length;T<N;++T)(v=_[T])&&_r(v,t,n,T,_,E);s.push(_),a.push(d)}return new ye(s,a,t,n)}var yf=En.prototype.constructor;function mf(){return new yf(this._groups,this._parents)}function bf(e,t){var n,r,i;return function(){var s=Qe(this,e),a=(this.style.removeProperty(e),Qe(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function Da(e){return function(){this.style.removeProperty(e)}}function gf(e,t,n){var r,i=n+"",s;return function(){var a=Qe(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function _f(e,t,n){var r,i,s;return function(){var a=Qe(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),Qe(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function vf(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=ne(this,e),c=l.on,d=l.value[s]==null?o||(o=Da(t)):void 0;(c!==n||i!==d)&&(r=(n=c).copy()).on(a,i=d),l.on=r}}function wf(e,t,n){var r=(e+="")=="transform"?vd:Oa;return t==null?this.styleTween(e,bf(e,r)).on("end.style."+e,Da(e)):typeof t=="function"?this.styleTween(e,_f(e,r,Ui(this,"style."+e,t))).each(vf(this._id,e)):this.styleTween(e,gf(e,r,t),n).on("end.style."+e,null)}function If(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Sf(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&If(e,a,n)),r}return s._value=t,s}function Ef(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Sf(e,t,n??""))}function Tf(e){return function(){this.textContent=e}}function Af(e){return function(){var t=e(this);this.textContent=t??""}}function Nf(e){return this.tween("text",typeof e=="function"?Af(Ui(this,"text",e)):Tf(e==null?"":e+""))}function Bf(e){return function(t){this.textContent=e.call(this,t)}}function Rf(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Bf(i)),t}return r._value=e,r}function Of(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Rf(e))}function Df(){for(var e=this._name,t=this._id,n=Fa(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)if(l=a[c]){var d=Kt(l,t);_r(l,e,n,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new ye(r,this._parents,e,n)}function Ff(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var c=ne(this,r),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),c.on=t}),i===0&&s()})}var Mf=0;function ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Fa(){return++Mf}var me=En.prototype;ye.prototype={constructor:ye,select:ff,selectAll:pf,selectChild:me.selectChild,selectChildren:me.selectChildren,filter:af,merge:of,selection:mf,transition:Df,call:me.call,nodes:me.nodes,node:me.node,size:me.size,empty:me.empty,each:me.each,on:uf,attr:jd,attrTween:Hd,style:wf,styleTween:Ef,text:Nf,textTween:Of,remove:df,tween:Ud,delay:Xd,duration:tf,ease:nf,easeVarying:sf,end:Ff,[Symbol.iterator]:me[Symbol.iterator]};function Lf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xf={time:null,delay:0,duration:250,ease:Lf};function Uf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Cf(e){var t,n;e instanceof ye?(t=e._id,e=e._name):(t=Fa(),(n=xf).time=Di(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&_r(l,e,t,c,a,n||Uf(l,t));return new ye(r,this._parents,e,t)}En.prototype.interrupt=Md,En.prototype.transition=Cf;const wr=e=>()=>e;function kf(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Ir=new be(1,0,0);be.prototype;function Ci(e){e.stopImmediatePropagation()}function Mn(e){e.preventDefault(),e.stopImmediatePropagation()}function $f(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Pf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ma(){return this.__zoom||Ir}function Vf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zf(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Yf(){var e=$f,t=Pf,n=jf,r=Vf,i=zf,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Td,c=vi("start","zoom","end"),d,y,_,v=500,E=150,T=0,N=10;function B(p){p.property("__zoom",Ma).on("wheel.zoom",$t,{passive:!1}).on("mousedown.zoom",dt).on("dblclick.zoom",ht).filter(i).on("touchstart.zoom",Zt).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}B.transform=function(p,g,u,m){var b=p.selection?p.selection():p;b.property("__zoom",Ma),p!==b?bt(p,g,u,m):b.interrupt().each(function(){gt(this,arguments).event(m).start().zoom(null,typeof g=="function"?g.apply(this,arguments):g).end()})},B.scaleBy=function(p,g,u,m){B.scaleTo(p,function(){var b=this.__zoom.k,w=typeof g=="function"?g.apply(this,arguments):g;return b*w},u,m)},B.scaleTo=function(p,g,u,m){B.transform(p,function(){var b=t.apply(this,arguments),w=this.__zoom,I=u==null?mt(b):typeof u=="function"?u.apply(this,arguments):u,S=w.invert(I),O=typeof g=="function"?g.apply(this,arguments):g;return n(it(Q(w,O),I,S),b,a)},u,m)},B.translateBy=function(p,g,u,m){B.transform(p,function(){return n(this.__zoom.translate(typeof g=="function"?g.apply(this,arguments):g,typeof u=="function"?u.apply(this,arguments):u),t.apply(this,arguments),a)},null,m)},B.translateTo=function(p,g,u,m,b){B.transform(p,function(){var w=t.apply(this,arguments),I=this.__zoom,S=m==null?mt(w):typeof m=="function"?m.apply(this,arguments):m;return n(Ir.translate(S[0],S[1]).scale(I.k).translate(typeof g=="function"?-g.apply(this,arguments):-g,typeof u=="function"?-u.apply(this,arguments):-u),w,a)},m,b)};function Q(p,g){return g=Math.max(s[0],Math.min(s[1],g)),g===p.k?p:new be(g,p.x,p.y)}function it(p,g,u){var m=g[0]-u[0]*p.k,b=g[1]-u[1]*p.k;return m===p.x&&b===p.y?p:new be(p.k,m,b)}function mt(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function bt(p,g,u,m){p.on("start.zoom",function(){gt(this,arguments).event(m).start()}).on("interrupt.zoom end.zoom",function(){gt(this,arguments).event(m).end()}).tween("zoom",function(){var b=this,w=arguments,I=gt(b,w).event(m),S=t.apply(b,w),O=u==null?mt(S):typeof u=="function"?u.apply(b,w):u,A=Math.max(S[1][0]-S[0][0],S[1][1]-S[0][1]),M=b.__zoom,J=typeof g=="function"?g.apply(b,w):g,st=l(M.invert(O).concat(A/M.k),J.invert(O).concat(A/J.k));return function(ct){if(ct===1)ct=J;else{var St=st(ct),Ke=A/St[2];ct=new be(Ke,O[0]-St[0]*Ke,O[1]-St[1]*Ke)}I.zoom(null,ct)}})}function gt(p,g,u){return!u&&p.__zooming||new It(p,g)}function It(p,g){this.that=p,this.args=g,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,g),this.taps=0}It.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,g){return this.mouse&&p!=="mouse"&&(this.mouse[1]=g.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=g.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=g.invert(this.touch1[0])),this.that.__zoom=g,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var g=pe(this.that).datum();c.call(p,this.that,new kf(p,{sourceEvent:this.sourceEvent,target:B,transform:this.that.__zoom,dispatch:c}),g)}};function $t(p,...g){if(!e.apply(this,arguments))return;var u=gt(this,g).event(p),m=this.__zoom,b=Math.max(s[0],Math.min(s[1],m.k*Math.pow(2,r.apply(this,arguments)))),w=$e(p);if(u.wheel)(u.mouse[0][0]!==w[0]||u.mouse[0][1]!==w[1])&&(u.mouse[1]=m.invert(u.mouse[0]=w)),clearTimeout(u.wheel);else{if(m.k===b)return;u.mouse=[w,m.invert(w)],vr(this),u.start()}Mn(p),u.wheel=setTimeout(I,E),u.zoom("mouse",n(it(Q(m,b),u.mouse[0],u.mouse[1]),u.extent,a));function I(){u.wheel=null,u.end()}}function dt(p,...g){if(_||!e.apply(this,arguments))return;var u=p.currentTarget,m=gt(this,g,!0).event(p),b=pe(p.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",A,!0),w=$e(p,u),I=p.clientX,S=p.clientY;Jh(p.view),Ci(p),m.mouse=[w,this.__zoom.invert(w)],vr(this),m.start();function O(M){if(Mn(M),!m.moved){var J=M.clientX-I,st=M.clientY-S;m.moved=J*J+st*st>T}m.event(M).zoom("mouse",n(it(m.that.__zoom,m.mouse[0]=$e(M,u),m.mouse[1]),m.extent,a))}function A(M){b.on("mousemove.zoom mouseup.zoom",null),Zh(M.view,m.moved),Mn(M),m.event(M).end()}}function ht(p,...g){if(e.apply(this,arguments)){var u=this.__zoom,m=$e(p.changedTouches?p.changedTouches[0]:p,this),b=u.invert(m),w=u.k*(p.shiftKey?.5:2),I=n(it(Q(u,w),m,b),t.apply(this,g),a);Mn(p),o>0?pe(this).transition().duration(o).call(bt,I,m,p):pe(this).call(B.transform,I,m,p)}}function Zt(p,...g){if(e.apply(this,arguments)){var u=p.touches,m=u.length,b=gt(this,g,p.changedTouches.length===m).event(p),w,I,S,O;for(Ci(p),I=0;I<m;++I)S=u[I],O=$e(S,this),O=[O,this.__zoom.invert(O),S.identifier],b.touch0?!b.touch1&&b.touch0[2]!==O[2]&&(b.touch1=O,b.taps=0):(b.touch0=O,w=!0,b.taps=1+!!d);d&&(d=clearTimeout(d)),w&&(b.taps<2&&(y=O[0],d=setTimeout(function(){d=null},v)),vr(this),b.start())}}function R(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I,S,O;for(Mn(p),w=0;w<b;++w)I=m[w],S=$e(I,this),u.touch0&&u.touch0[2]===I.identifier?u.touch0[0]=S:u.touch1&&u.touch1[2]===I.identifier&&(u.touch1[0]=S);if(I=u.that.__zoom,u.touch1){var A=u.touch0[0],M=u.touch0[1],J=u.touch1[0],st=u.touch1[1],ct=(ct=J[0]-A[0])*ct+(ct=J[1]-A[1])*ct,St=(St=st[0]-M[0])*St+(St=st[1]-M[1])*St;I=Q(I,Math.sqrt(ct/St)),S=[(A[0]+J[0])/2,(A[1]+J[1])/2],O=[(M[0]+st[0])/2,(M[1]+st[1])/2]}else if(u.touch0)S=u.touch0[0],O=u.touch0[1];else return;u.zoom("touch",n(it(I,S,O),u.extent,a))}}function F(p,...g){if(this.__zooming){var u=gt(this,g).event(p),m=p.changedTouches,b=m.length,w,I;for(Ci(p),_&&clearTimeout(_),_=setTimeout(function(){_=null},v),w=0;w<b;++w)I=m[w],u.touch0&&u.touch0[2]===I.identifier?delete u.touch0:u.touch1&&u.touch1[2]===I.identifier&&delete u.touch1;if(u.touch1&&!u.touch0&&(u.touch0=u.touch1,delete u.touch1),u.touch0)u.touch0[1]=this.__zoom.invert(u.touch0[0]);else if(u.end(),u.taps===2&&(I=$e(I,this),Math.hypot(y[0]-I[0],y[1]-I[1])<N)){var S=pe(this).on("dblclick.zoom");S&&S.apply(this,arguments)}}}return B.wheelDelta=function(p){return arguments.length?(r=typeof p=="function"?p:wr(+p),B):r},B.filter=function(p){return arguments.length?(e=typeof p=="function"?p:wr(!!p),B):e},B.touchable=function(p){return arguments.length?(i=typeof p=="function"?p:wr(!!p),B):i},B.extent=function(p){return arguments.length?(t=typeof p=="function"?p:wr([[+p[0][0],+p[0][1]],[+p[1][0],+p[1][1]]]),B):t},B.scaleExtent=function(p){return arguments.length?(s[0]=+p[0],s[1]=+p[1],B):[s[0],s[1]]},B.translateExtent=function(p){return arguments.length?(a[0][0]=+p[0][0],a[1][0]=+p[1][0],a[0][1]=+p[0][1],a[1][1]=+p[1][1],B):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},B.constrain=function(p){return arguments.length?(n=p,B):n},B.duration=function(p){return arguments.length?(o=+p,B):o},B.interpolate=function(p){return arguments.length?(l=p,B):l},B.on=function(){var p=c.on.apply(c,arguments);return p===c?B:p},B.clickDistance=function(p){return arguments.length?(T=(p=+p)*p,B):Math.sqrt(T)},B.tapDistance=function(p){return arguments.length?(N=+p,B):N},B}const Wf=h.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=h.ref(null),i=h.ref(null),s=h.ref(null),a=h.ref(null);let o=null,l=null,c=null,d=[],y=null,_=null,v=null,E=0,T=0,N=1;h.watch(()=>n.colorMap,g,{deep:!0});function B(u){if(!u||u.length<7)return[1,0,0];const m=parseInt(u.slice(1,3),16)/255,b=parseInt(u.slice(3,5),16)/255,w=parseInt(u.slice(5,7),16)/255;return[m,b,w].some(Number.isNaN)?[1,0,0]:[m,b,w]}const Q=(u,m,b)=>u+(m-u)*b;function it(u,m){const b=u.parentElement;b&&(N=window.devicePixelRatio||1,E=b.clientWidth||800,T=b.clientHeight||400,u.style.width=`${E}px`,u.style.height=`${T}px`,u.width=Math.round(E*N),u.height=Math.round(T*N),m.viewport(0,0,u.width,u.height))}function mt(u,m){var Hn,Kn,Qn,Rc,Oc,Dc,Fc,Mc,Lc,xc,Uc,Cc;const b=(Dc=(Oc=(Rc=(Qn=(Kn=(Hn=n.metaData)==null?void 0:Hn.row_groups)==null?void 0:Kn[0])==null?void 0:Qn.columns)==null?void 0:Rc[0])==null?void 0:Oc.meta_data)==null?void 0:Dc.statistics,w=(Cc=(Uc=(xc=(Lc=(Mc=(Fc=n.metaData)==null?void 0:Fc.row_groups)==null?void 0:Mc[0])==null?void 0:Lc.columns)==null?void 0:xc[1])==null?void 0:Uc.meta_data)==null?void 0:Cc.statistics,I=Number((b==null?void 0:b.min_value)??-1),S=Number((b==null?void 0:b.max_value)??1),O=Number((w==null?void 0:w.min_value)??-1),A=Number((w==null?void 0:w.max_value)??1),M=(I+S)/2,J=(O+A)/2,st=Math.max(1e-9,S-I),ct=Math.max(1e-9,A-O),St=2/Math.max(st,ct),Ke=y.x/u*2-1,gi=-y.y/m*2+1,Gn=y.k*St,$s=Ke-Gn*M,Ps=gi-Gn*J;return{s:Gn,tx:$s,ty:Ps}}function bt(u,m,b,w){const{s:I,tx:S,ty:O}=mt(b,w),A=u/b*2-1,M=-(m/w*2-1),J=(A-S)/I,st=(M-O)/I;return{x:J,y:st}}function gt(u,m,b,w,I){if(!u.length||!y)return null;const S=bt(m,b,w,I);let O=1/0,A=null;for(const M of u){const J=M.x-S.x,st=M.y-S.y,ct=Math.hypot(J,st),St=3/(y.k/2);ct<O&&ct<St&&(O=ct,A=M)}return A}function It(){const u=[];for(let m=0;m<n.data.length;m++){const b=n.data[m],w=Number(b[0]),I=Number(b[1]);u.push({x:w,y:I,rawX:w,rawY:I,color:[.5,.5,.5],id:m})}return u}function $t(u,m,b){const w=u.createShader(u.VERTEX_SHADER);if(u.shaderSource(w,m),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))return console.error("Vertex shader error:",u.getShaderInfoLog(w)),null;const I=u.createShader(u.FRAGMENT_SHADER);if(u.shaderSource(I,b),u.compileShader(I),!u.getShaderParameter(I,u.COMPILE_STATUS))return console.error("Fragment shader error:",u.getShaderInfoLog(I)),null;const S=u.createProgram();return u.attachShader(S,w),u.attachShader(S,I),u.linkProgram(S),u.getProgramParameter(S,u.LINK_STATUS)?(u.validateProgram(S),u.getProgramParameter(S,u.VALIDATE_STATUS)?S:(console.error("Program validate error:",u.getProgramInfoLog(S)),null)):(console.error("Program link error:",u.getProgramInfoLog(S)),null)}function dt(u,m,b){if(!b.length)return null;const w=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,w);const I=new Float32Array(b.flatMap(ct=>[ct.x,ct.y]));u.bufferData(u.ARRAY_BUFFER,I,u.STATIC_DRAW);const S=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,S);const O=new Float32Array(b.flatMap(ct=>ct.color));u.bufferData(u.ARRAY_BUFFER,O,u.STATIC_DRAW);const A=u.getAttribLocation(m,"a_position"),M=u.getAttribLocation(m,"a_color"),J=u.getUniformLocation(m,"u_viewMatrix"),st=u.getUniformLocation(m,"u_pointSize");return{program:m,positionBuffer:w,colorBuffer:S,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:b.length}}function ht(u,m,b,w=null){if(!u||!m||!y)return;const{program:I,positionBuffer:S,colorBuffer:O,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:J,pointSizeLocation:st,count:ct}=m;u.clearColor(0,0,0,1),u.clear(u.COLOR_BUFFER_BIT),u.useProgram(I),u.enableVertexAttribArray(A),u.bindBuffer(u.ARRAY_BUFFER,S),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0),u.enableVertexAttribArray(M),u.bindBuffer(u.ARRAY_BUFFER,O),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0);const St=u.canvas.clientWidth,Ke=u.canvas.clientHeight,{s:gi,tx:Gn,ty:$s}=mt(St,Ke),Ps=new Float32Array([gi,0,0,0,0,gi,0,0,0,0,1,0,Gn,$s,0,1]);if(u.uniformMatrix4fv(J,!1,Ps),u.uniform1f(st,Math.max(1.5,b*Math.sqrt(y.k)*N)),u.enable(u.BLEND),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawArrays(u.POINTS,0,ct),w){const Hn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Hn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([w.x,w.y]),u.STATIC_DRAW),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0);const Kn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Kn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,1,.5]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(2.5,b*Math.sqrt(y.k)*2.5*N)),u.drawArrays(u.POINTS,0,1);const Qn=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Qn),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,.8,.2]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(st,Math.max(3,b*Math.sqrt(y.k)*3*N)),u.drawArrays(u.POINTS,0,1),u.deleteBuffer(Hn),u.deleteBuffer(Kn),u.deleteBuffer(Qn)}}function Zt(){if(!(!i.value||!r.value)){if(o=i.value.getContext("webgl",{preserveDrawingBuffer:!0,antialias:!0,alpha:!0})||i.value.getContext("experimental-webgl"),!o){console.error("WebGL not supported");return}it(i.value,o),l=$t(o,`
|
|
13
|
+
LIMIT 20;`},{name:"Describe",query:"DESCRIBE data;"},{name:"Sample",query:"SELECT * FROM data USING SAMPLE 10;"},{name:"Columns",query:"PRAGMA table_info(data);"}]);h.computed(()=>({viewerId:n.viewerId,fileId:n.fileId,connectionId:R.value,tableName:c.value,isConnected:B.value,activeConnections:i.activeConnectionCount,hasActiveConnections:i.hasActiveConnections}));const St=async()=>{try{const{connection:m,connectionId:b}=await i.createConnection(n.viewerId);R.value=b,l.value&&(await Pt(),ht())}catch(m){console.error("Failed to initialize viewer:",m),_.value=`Failed to initialize: ${m.message}`}},Pt=async()=>{if(!l.value){_.value="Please provide a valid S3 URL";return}const m=n.fileId||l.value,b=i.getLoadedFile(m);if(b&&!b.isLoading&&!b.error){c.value=b.tableName,F("SELECT * FROM data LIMIT 10;");return}a.value=!0,_.value="";try{const w=n.fileId?`file_${n.fileId}`:`data_${Date.now()}`,I=await i.loadFile(l.value,n.fileType,w,s.value,n.viewerId,n.fileId);c.value=I,F("SELECT * FROM data LIMIT 10;")}catch{}finally{a.value=!1}},dt=m=>!c.value||!m?m:m.replace(/\bFROM\s+data\b/gi,`FROM ${c.value}`).replace(/\bJOIN\s+data\b/gi,`JOIN ${c.value}`).replace(/\bUPDATE\s+data\b/gi,`UPDATE ${c.value}`).replace(/\bINSERT\s+INTO\s+data\b/gi,`INSERT INTO ${c.value}`).replace(/\bINTO\s+data\b/gi,`INTO ${c.value}`).replace(/\btable_info\(\s*data\s*\)/gi,`table_info(${c.value})`).replace(/\bDESCRIBE\s+data\b/gi,`DESCRIBE ${c.value}`).replace(/\bPRAGMA\s+table_info\(\s*data\s*\)/gi,`PRAGMA table_info(${c.value})`),ht=async()=>{if(!d.value||!R.value){_.value="Please provide a valid SQL query";return}if(!c.value){_.value="No data table loaded";return}o.value=!0,_.value="",E.value=1;try{const m=dt(d.value.trim());y.value=await i.executeQuery(m,R.value),await i.publishViewFromQuery("umap_result",m,R.value),r("query-results",{results:y.value,query:m})}catch(m){console.error("Query execution failed:",m),_.value=`Query execution failed: ${m.message}`,y.value=null}finally{o.value=!1}},te=m=>{E.value=m},N=m=>{T.value=m,E.value=1},F=m=>{d.value=m},p=m=>m==null?"NULL":typeof m=="number"?Number.isInteger(m)?m.toString():m.toFixed(4):typeof m=="string"&&m.length>100?m.substring(0,100)+"...":m.toString(),g=()=>{if(!y.value||y.value.length===0)return;const m=Object.keys(y.value[0]),b=[m.join(","),...y.value.map(O=>m.map(A=>{const M=O[A],K=M==null?"":M.toString();return K.includes(",")?`"${K}"`:K}).join(","))].join(`
|
|
14
|
+
`),w=new Blob([b],{type:"text/csv"}),I=URL.createObjectURL(w),S=document.createElement("a");S.href=I,S.download="query-results.csv",S.click(),URL.revokeObjectURL(I)},u=()=>{_.value=""};return h.onMounted(async()=>{await St()}),h.onUnmounted(async()=>{R.value&&(i.activeConnectionCount,i.loadedFiles.size,await i.closeConnection(R.value),i.activeConnectionCount,i.loadedFiles.size)}),(m,b)=>{const w=h.resolveComponent("bf-button"),I=h.resolveComponent("el-pagination");return h.openBlock(),h.createElementBlock("div",Qc,[h.createElementVNode("header",Xc,[b[3]||(b[3]=h.createElementVNode("h1",null,"Data Explorer",-1)),h.createElementVNode("div",{class:h.normalizeClass(["status-indicator",{connected:B.value,loading:a.value}])},h.toDisplayString(J.value),3)]),h.createElementVNode("div",Jc,[B.value?(h.openBlock(),h.createElementBlock("div",Zc,[b[5]||(b[5]=h.createElementVNode("h3",null,"SQL Query",-1)),h.createElementVNode("div",tu,[b[4]||(b[4]=h.createElementVNode("span",null,"Quick queries:",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(_t.value,S=>(h.openBlock(),h.createElementBlock("button",{key:S.name,onClick:O=>F(S.query),class:"example-btn"},h.toDisplayString(S.name),9,eu))),128))]),h.withDirectives(h.createElementVNode("textarea",{"onUpdate:modelValue":b[0]||(b[0]=S=>d.value=S),placeholder:"SELECT * FROM data LIMIT 10;",class:"query-textarea",rows:"4"},null,512),[[h.vModelText,d.value]]),h.createVNode(w,{class:"execute-query-button",onClick:ht,disabled:o.value||!d.value},{default:h.withCtx(()=>[h.createTextVNode(h.toDisplayString(o.value?"Running...":"Execute Query"),1)]),_:1},8,["disabled"])])):h.createCommentVNode("",!0),y.value?(h.openBlock(),h.createElementBlock("div",nu,[h.createElementVNode("h3",null,"Results ("+h.toDisplayString(y.value.length)+" rows)",1),h.createElementVNode("div",ru,[h.createElementVNode("div",iu,[h.createVNode(w,{class:"secondary",onClick:g},{default:h.withCtx(()=>[...b[6]||(b[6]=[h.createTextVNode("Export to CSV",-1)])]),_:1})]),h.createElementVNode("div",su,[v.value==="table"&&bt.value>1?(h.openBlock(),h.createBlock(I,{key:0,"current-page":E.value,"onUpdate:currentPage":b[1]||(b[1]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:"prev, pager, next",onCurrentChange:te,class:"results-pagination"},null,8,["current-page","page-size","total"])):h.createCommentVNode("",!0)])]),b[7]||(b[7]=h.createElementVNode("div",{class:"pagination-wrapper"},null,-1)),v.value==="table"?(h.openBlock(),h.createElementBlock("div",au,[h.createElementVNode("table",ou,[h.createElementVNode("thead",null,[h.createElementVNode("tr",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(at.value,S=>(h.openBlock(),h.createElementBlock("th",{key:S},h.toDisplayString(S),1))),128))])]),h.createElementVNode("tbody",null,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(gt.value,(S,O)=>(h.openBlock(),h.createElementBlock("tr",{key:O},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(at.value,A=>(h.openBlock(),h.createElementBlock("td",{key:A},h.toDisplayString(p(S[A])),1))),128))]))),128))])]),bt.value>1?(h.openBlock(),h.createElementBlock("div",lu,[h.createVNode(I,{"current-page":E.value,"onUpdate:currentPage":b[2]||(b[2]=S=>E.value=S),"page-size":T.value,total:y.value.length,layout:" prev, pager, next","page-sizes":[25,50,100,200,500],onCurrentChange:te,onSizeChange:N},null,8,["current-page","page-size","total"])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.createElementBlock("div",cu,[h.createElementVNode("pre",null,h.toDisplayString(JSON.stringify(y.value.slice(0,100),null,2)),1)]))])):h.createCommentVNode("",!0),_.value?(h.openBlock(),h.createElementBlock("div",uu,[b[8]||(b[8]=h.createElementVNode("h3",null,"Error",-1)),h.createElementVNode("p",null,h.toDisplayString(_.value),1),h.createElementVNode("button",{onClick:u,class:"clear-error-btn"},"Clear")])):h.createCommentVNode("",!0)])])}}},du=On(hu,[["__scopeId","data-v-eccd9d40"]]),fu={class:"app-container"},pu=h.defineComponent({__name:"DataExplorerWrap",props:{pkg:{},apiUrl:{},srcUrl:{},srcFileType:{},srcFileId:{}},emits:["queryResults"],setup(e,{emit:t}){const n=e,r=t,i=h.ref([]),s=h.ref(""),a=h.ref("parquet"),o=h.ref("");h.onMounted(async()=>{var v,E,T,R,B;if(n.srcUrl){s.value=n.srcUrl,a.value=n.srcFileType??(n.srcUrl.toLowerCase().endsWith(".csv")?"csv":"parquet"),o.value=n.srcFileId??"url_"+btoa(n.srcUrl).replace(/=+$/,"").replace(/[+/]/g,"_");return}const _=Kc("",["content","id"],n.pkg);if(!_||!n.apiUrl){console.error("[DuckDBViewerWrapper] Missing pkg.id or apiUrl, and no srcUrl provided.");return}try{await d(_);const J=(T=(E=(v=i.value)==null?void 0:v[0])==null?void 0:E.content)==null?void 0:T.id;if(!J){console.error("[DuckDBViewerWrapper] No files found in /view response.");return}o.value=J,s.value=await y(_,J);const at=(B=(R=n.pkg)==null?void 0:R.content)==null?void 0:B.packageType;a.value=at==="CSV"?"csv":"parquet"}catch(J){console.error(J)}});function l(_){r("queryResults",_)}async function c(){const{useGetToken:_}=await Promise.resolve().then(()=>Bc);return _()}async function d(_){const v=await c(),E=`${n.apiUrl}/packages/${_}/view?api_key=${v}`,T=await fetch(E);if(!T.ok)throw new Error(`view failed: ${T.status}`);i.value=await T.json()}async function y(_,v){const E=await c(),T=`${n.apiUrl}/packages/${_}/files/${v}?api_key=${E}`,R=await fetch(T);if(!R.ok)throw new Error(`file url failed: ${R.status}`);return(await R.json()).url}return(_,v)=>(h.openBlock(),h.createElementBlock("div",fu,[h.createVNode(du,{url:s.value,"file-type":a.value,"file-id":o.value,onQueryResults:v[0]||(v[0]=E=>l(E))},null,8,["url","file-type","file-id"])]))}}),yu=On(pu,[["__scopeId","data-v-d6dbc8b5"]]);var mu={value:()=>{}};function Ii(){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 lr(n)}function lr(e){this._=e}function bu(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}lr.prototype=Ii.prototype={constructor:lr,on:function(e,t){var n=this._,r=bu(e+"",n),i,s=-1,a=r.length;if(arguments.length<2){for(;++s<a;)if((i=(e=r[s]).type)&&(i=gu(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<a;)if(i=(e=r[s]).type)n[i]=Ys(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Ys(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new lr(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,s;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,i=s.length;r<i;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,s=r.length;i<s;++i)r[i].value.apply(t,n)}};function gu(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Ys(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=mu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Si="http://www.w3.org/1999/xhtml";const Ws={svg:"http://www.w3.org/2000/svg",xhtml:Si,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cr(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Ws.hasOwnProperty(t)?{space:Ws[t],local:e}:e}function _u(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Si&&t.documentElement.namespaceURI===Si?t.createElement(e):t.createElementNS(n,e)}}function vu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qs(e){var t=cr(e);return(t.local?vu:_u)(t)}function wu(){}function Ei(e){return e==null?wu:function(){return this.querySelector(e)}}function Iu(e){typeof e!="function"&&(e=Ei(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=new Array(a),l,c,d=0;d<a;++d)(l=s[d])&&(c=e.call(l,l.__data__,d,s))&&("__data__"in l&&(c.__data__=l.__data__),o[d]=c);return new Ut(r,this._parents)}function Su(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Eu(){return[]}function Gs(e){return e==null?Eu:function(){return this.querySelectorAll(e)}}function Tu(e){return function(){return Su(e.apply(this,arguments))}}function Au(e){typeof e=="function"?e=Tu(e):e=Gs(e);for(var t=this._groups,n=t.length,r=[],i=[],s=0;s<n;++s)for(var a=t[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&(r.push(e.call(l,l.__data__,c,a)),i.push(l));return new Ut(r,i)}function Hs(e){return function(){return this.matches(e)}}function Ks(e){return function(t){return t.matches(e)}}var Ru=Array.prototype.find;function Bu(e){return function(){return Ru.call(this.children,e)}}function Nu(){return this.firstElementChild}function Ou(e){return this.select(e==null?Nu:Bu(typeof e=="function"?e:Ks(e)))}var Du=Array.prototype.filter;function Mu(){return Array.from(this.children)}function Fu(e){return function(){return Du.call(this.children,e)}}function Lu(e){return this.selectAll(e==null?Mu:Fu(typeof e=="function"?e:Ks(e)))}function xu(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new Ut(r,this._parents)}function Qs(e){return new Array(e.length)}function Uu(){return new Ut(this._enter||this._groups.map(Qs),this._parents)}function ur(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ur.prototype={constructor:ur,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Cu(e){return function(){return e}}function $u(e,t,n,r,i,s){for(var a=0,o,l=t.length,c=s.length;a<c;++a)(o=t[a])?(o.__data__=s[a],r[a]=o):n[a]=new ur(e,s[a]);for(;a<l;++a)(o=t[a])&&(i[a]=o)}function ku(e,t,n,r,i,s,a){var o,l,c=new Map,d=t.length,y=s.length,_=new Array(d),v;for(o=0;o<d;++o)(l=t[o])&&(_[o]=v=a.call(l,l.__data__,o,t)+"",c.has(v)?i[o]=l:c.set(v,l));for(o=0;o<y;++o)v=a.call(e,s[o],o,s)+"",(l=c.get(v))?(r[o]=l,l.__data__=s[o],c.delete(v)):n[o]=new ur(e,s[o]);for(o=0;o<d;++o)(l=t[o])&&c.get(_[o])===l&&(i[o]=l)}function Pu(e){return e.__data__}function Vu(e,t){if(!arguments.length)return Array.from(this,Pu);var n=t?ku:$u,r=this._parents,i=this._groups;typeof e!="function"&&(e=Cu(e));for(var s=i.length,a=new Array(s),o=new Array(s),l=new Array(s),c=0;c<s;++c){var d=r[c],y=i[c],_=y.length,v=zu(e.call(d,d&&d.__data__,c,r)),E=v.length,T=o[c]=new Array(E),R=a[c]=new Array(E),B=l[c]=new Array(_);n(d,y,T,R,B,v,t);for(var J=0,at=0,bt,gt;J<E;++J)if(bt=T[J]){for(J>=at&&(at=J+1);!(gt=R[at])&&++at<E;);bt._next=gt||null}}return a=new Ut(a,r),a._enter=o,a._exit=l,a}function zu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ju(){return new Ut(this._exit||this._groups.map(Qs),this._parents)}function Yu(e,t,n){var r=this.enter(),i=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?s.remove():n(s),r&&i?r.merge(i).order():i}function Wu(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,s=r.length,a=Math.min(i,s),o=new Array(i),l=0;l<a;++l)for(var c=n[l],d=r[l],y=c.length,_=o[l]=new Array(y),v,E=0;E<y;++E)(v=c[E]||d[E])&&(_[E]=v);for(;l<i;++l)o[l]=n[l];return new Ut(o,this._parents)}function qu(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,s=r[i],a;--i>=0;)(a=r[i])&&(s&&a.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(a,s),s=a);return this}function Gu(e){e||(e=Hu);function t(y,_){return y&&_?e(y.__data__,_.__data__):!y-!_}for(var n=this._groups,r=n.length,i=new Array(r),s=0;s<r;++s){for(var a=n[s],o=a.length,l=i[s]=new Array(o),c,d=0;d<o;++d)(c=a[d])&&(l[d]=c);l.sort(t)}return new Ut(i,this._parents).order()}function Hu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ku(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qu(){return Array.from(this)}function Xu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length;i<s;++i){var a=r[i];if(a)return a}return null}function Ju(){let e=0;for(const t of this)++e;return e}function Zu(){return!this.node()}function th(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],s=0,a=i.length,o;s<a;++s)(o=i[s])&&e.call(o,o.__data__,s,i);return this}function eh(e){return function(){this.removeAttribute(e)}}function nh(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rh(e,t){return function(){this.setAttribute(e,t)}}function ih(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function sh(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ah(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function oh(e,t){var n=cr(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?nh:eh:typeof t=="function"?n.local?ah:sh:n.local?ih:rh)(n,t))}function Xs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function lh(e){return function(){this.style.removeProperty(e)}}function ch(e,t,n){return function(){this.style.setProperty(e,t,n)}}function uh(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function hh(e,t,n){return arguments.length>1?this.each((t==null?lh:typeof t=="function"?uh:ch)(e,t,n??"")):nn(this.node(),e)}function nn(e,t){return e.style.getPropertyValue(t)||Xs(e).getComputedStyle(e,null).getPropertyValue(t)}function dh(e){return function(){delete this[e]}}function fh(e,t){return function(){this[e]=t}}function ph(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yh(e,t){return arguments.length>1?this.each((t==null?dh:typeof t=="function"?ph:fh)(e,t)):this.node()[e]}function Js(e){return e.trim().split(/^|\s+/)}function Ti(e){return e.classList||new Zs(e)}function Zs(e){this._node=e,this._names=Js(e.getAttribute("class")||"")}Zs.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ta(e,t){for(var n=Ti(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function ea(e,t){for(var n=Ti(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function mh(e){return function(){ta(this,e)}}function bh(e){return function(){ea(this,e)}}function gh(e,t){return function(){(t.apply(this,arguments)?ta:ea)(this,e)}}function _h(e,t){var n=Js(e+"");if(arguments.length<2){for(var r=Ti(this.node()),i=-1,s=n.length;++i<s;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?gh:t?mh:bh)(n,t))}function vh(){this.textContent=""}function wh(e){return function(){this.textContent=e}}function Ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Sh(e){return arguments.length?this.each(e==null?vh:(typeof e=="function"?Ih:wh)(e)):this.node().textContent}function Eh(){this.innerHTML=""}function Th(e){return function(){this.innerHTML=e}}function Ah(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Rh(e){return arguments.length?this.each(e==null?Eh:(typeof e=="function"?Ah:Th)(e)):this.node().innerHTML}function Bh(){this.nextSibling&&this.parentNode.appendChild(this)}function Nh(){return this.each(Bh)}function Oh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dh(){return this.each(Oh)}function Mh(e){var t=typeof e=="function"?e:qs(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Fh(){return null}function Lh(e,t){var n=typeof e=="function"?e:qs(e),r=t==null?Fh:typeof t=="function"?t:Ei(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function xh(){var e=this.parentNode;e&&e.removeChild(this)}function Uh(){return this.each(xh)}function Ch(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function $h(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function kh(e){return this.select(e?$h:Ch)}function Ph(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Vh(e){return function(t){e.call(this,t,this.__data__)}}function zh(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function jh(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,s;n<i;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function Yh(e,t,n){return function(){var r=this.__on,i,s=Vh(t);if(r){for(var a=0,o=r.length;a<o;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=s,i.options=n),i.value=t;return}}this.addEventListener(e.type,s,n),i={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(i):this.__on=[i]}}function Wh(e,t,n){var r=zh(e+""),i,s=r.length,a;if(arguments.length<2){var o=this.node().__on;if(o){for(var l=0,c=o.length,d;l<c;++l)for(i=0,d=o[l];i<s;++i)if((a=r[i]).type===d.type&&a.name===d.name)return d.value}return}for(o=t?Yh:jh,i=0;i<s;++i)this.each(o(r[i],t,n));return this}function na(e,t,n){var r=Xs(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function qh(e,t){return function(){return na(this,e,t)}}function Gh(e,t){return function(){return na(this,e,t.apply(this,arguments))}}function Hh(e,t){return this.each((typeof t=="function"?Gh:qh)(e,t))}function*Kh(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,s=r.length,a;i<s;++i)(a=r[i])&&(yield a)}var ra=[null];function Ut(e,t){this._groups=e,this._parents=t}function Dn(){return new Ut([[document.documentElement]],ra)}function Qh(){return this}Ut.prototype=Dn.prototype={constructor:Ut,select:Iu,selectAll:Au,selectChild:Ou,selectChildren:Lu,filter:xu,data:Vu,enter:Uu,exit:ju,join:Yu,merge:Wu,selection:Qh,order:qu,sort:Gu,call:Ku,nodes:Qu,node:Xu,size:Ju,empty:Zu,each:th,attr:oh,style:hh,property:yh,classed:_h,text:Sh,html:Rh,raise:Nh,lower:Dh,append:Mh,insert:Lh,remove:Uh,clone:kh,datum:Ph,on:Wh,dispatch:Hh,[Symbol.iterator]:Kh};function me(e){return typeof e=="string"?new Ut([[document.querySelector(e)]],[document.documentElement]):new Ut([[e]],ra)}function Xh(e){let t;for(;t=e.sourceEvent;)e=t;return e}function qe(e,t){if(e=Xh(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ai={capture:!0,passive:!1};function Ri(e){e.preventDefault(),e.stopImmediatePropagation()}function Jh(e){var t=e.document.documentElement,n=me(e).on("dragstart.drag",Ri,Ai);"onselectstart"in t?n.on("selectstart.drag",Ri,Ai):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zh(e,t){var n=e.document.documentElement,r=me(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ri,Ai),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 Bi(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ia(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Mn(){}var Fn=.7,hr=1/Fn,rn="\\s*([+-]?\\d+)\\s*",Ln="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",re="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",td=/^#([0-9a-f]{3,8})$/,ed=new RegExp(`^rgb\\(${rn},${rn},${rn}\\)$`),nd=new RegExp(`^rgb\\(${re},${re},${re}\\)$`),rd=new RegExp(`^rgba\\(${rn},${rn},${rn},${Ln}\\)$`),id=new RegExp(`^rgba\\(${re},${re},${re},${Ln}\\)$`),sd=new RegExp(`^hsl\\(${Ln},${re},${re}\\)$`),ad=new RegExp(`^hsla\\(${Ln},${re},${re},${Ln}\\)$`),sa={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Bi(Mn,xn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:aa,formatHex:aa,formatHex8:od,formatHsl:ld,formatRgb:oa,toString:oa});function aa(){return this.rgb().formatHex()}function od(){return this.rgb().formatHex8()}function ld(){return da(this).formatHsl()}function oa(){return this.rgb().formatRgb()}function xn(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=td.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?la(t):n===3?new Dt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?dr(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?dr(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ed.exec(e))?new Dt(t[1],t[2],t[3],1):(t=nd.exec(e))?new Dt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rd.exec(e))?dr(t[1],t[2],t[3],t[4]):(t=id.exec(e))?dr(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sd.exec(e))?ha(t[1],t[2]/100,t[3]/100,1):(t=ad.exec(e))?ha(t[1],t[2]/100,t[3]/100,t[4]):sa.hasOwnProperty(e)?la(sa[e]):e==="transparent"?new Dt(NaN,NaN,NaN,0):null}function la(e){return new Dt(e>>16&255,e>>8&255,e&255,1)}function dr(e,t,n,r){return r<=0&&(e=t=n=NaN),new Dt(e,t,n,r)}function cd(e){return e instanceof Mn||(e=xn(e)),e?(e=e.rgb(),new Dt(e.r,e.g,e.b,e.opacity)):new Dt}function Ni(e,t,n,r){return arguments.length===1?cd(e):new Dt(e,t,n,r??1)}function Dt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Bi(Dt,Ni,ia(Mn,{brighter(e){return e=e==null?hr:Math.pow(hr,e),new Dt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fn:Math.pow(Fn,e),new Dt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Dt(Ge(this.r),Ge(this.g),Ge(this.b),fr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:ca,formatHex:ca,formatHex8:ud,formatRgb:ua,toString:ua}));function ca(){return`#${He(this.r)}${He(this.g)}${He(this.b)}`}function ud(){return`#${He(this.r)}${He(this.g)}${He(this.b)}${He((isNaN(this.opacity)?1:this.opacity)*255)}`}function ua(){const e=fr(this.opacity);return`${e===1?"rgb(":"rgba("}${Ge(this.r)}, ${Ge(this.g)}, ${Ge(this.b)}${e===1?")":`, ${e})`}`}function fr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ge(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function He(e){return e=Ge(e),(e<16?"0":"")+e.toString(16)}function ha(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Kt(e,t,n,r)}function da(e){if(e instanceof Kt)return new Kt(e.h,e.s,e.l,e.opacity);if(e instanceof Mn||(e=xn(e)),!e)return new Kt;if(e instanceof Kt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),s=Math.max(t,n,r),a=NaN,o=s-i,l=(s+i)/2;return o?(t===s?a=(n-r)/o+(n<r)*6:n===s?a=(r-t)/o+2:a=(t-n)/o+4,o/=l<.5?s+i:2-s-i,a*=60):o=l>0&&l<1?0:a,new Kt(a,o,l,e.opacity)}function hd(e,t,n,r){return arguments.length===1?da(e):new Kt(e,t,n,r??1)}function Kt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Bi(Kt,hd,ia(Mn,{brighter(e){return e=e==null?hr:Math.pow(hr,e),new Kt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fn:Math.pow(Fn,e),new Kt(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 Dt(Oi(e>=240?e-240:e+120,i,r),Oi(e,i,r),Oi(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Kt(fa(this.h),pr(this.s),pr(this.l),fr(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=fr(this.opacity);return`${e===1?"hsl(":"hsla("}${fa(this.h)}, ${pr(this.s)*100}%, ${pr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fa(e){return e=(e||0)%360,e<0?e+360:e}function pr(e){return Math.max(0,Math.min(1,e||0))}function Oi(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const pa=e=>()=>e;function dd(e,t){return function(n){return e+n*t}}function fd(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function pd(e){return(e=+e)==1?ya:function(t,n){return n-t?fd(t,n,e):pa(isNaN(t)?n:t)}}function ya(e,t){var n=t-e;return n?dd(e,n):pa(isNaN(e)?t:e)}const ma=(function e(t){var n=pd(t);function r(i,s){var a=n((i=Ni(i)).r,(s=Ni(s)).r),o=n(i.g,s.g),l=n(i.b,s.b),c=ya(i.opacity,s.opacity);return function(d){return i.r=a(d),i.g=o(d),i.b=l(d),i.opacity=c(d),i+""}}return r.gamma=e,r})(1);function Me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Di=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mi=new RegExp(Di.source,"g");function yd(e){return function(){return e}}function md(e){return function(t){return e(t)+""}}function bd(e,t){var n=Di.lastIndex=Mi.lastIndex=0,r,i,s,a=-1,o=[],l=[];for(e=e+"",t=t+"";(r=Di.exec(e))&&(i=Mi.exec(t));)(s=i.index)>n&&(s=t.slice(n,s),o[a]?o[a]+=s:o[++a]=s),(r=r[0])===(i=i[0])?o[a]?o[a]+=i:o[++a]=i:(o[++a]=null,l.push({i:a,x:Me(r,i)})),n=Mi.lastIndex;return n<t.length&&(s=t.slice(n),o[a]?o[a]+=s:o[++a]=s),o.length<2?l[0]?md(l[0].x):yd(t):(t=l.length,function(c){for(var d=0,y;d<t;++d)o[(y=l[d]).i]=y.x(c);return o.join("")})}var ba=180/Math.PI,ga={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _a(e,t,n,r,i,s){var a,o,l;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(o=Math.sqrt(n*n+r*r))&&(n/=o,r/=o,l/=o),e*r<t*n&&(e=-e,t=-t,l=-l,a=-a),{translateX:i,translateY:s,rotate:Math.atan2(t,e)*ba,skewX:Math.atan(l)*ba,scaleX:a,scaleY:o}}var yr;function gd(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?ga:_a(t.a,t.b,t.c,t.d,t.e,t.f)}function _d(e){return e==null||(yr||(yr=document.createElementNS("http://www.w3.org/2000/svg","g")),yr.setAttribute("transform",e),!(e=yr.transform.baseVal.consolidate()))?ga:(e=e.matrix,_a(e.a,e.b,e.c,e.d,e.e,e.f))}function va(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function s(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push("translate(",null,t,null,n);E.push({i:T-4,x:Me(c,y)},{i:T-2,x:Me(d,_)})}else(y||_)&&v.push("translate("+y+t+_+n)}function a(c,d,y,_){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),_.push({i:y.push(i(y)+"rotate(",null,r)-2,x:Me(c,d)})):d&&y.push(i(y)+"rotate("+d+r)}function o(c,d,y,_){c!==d?_.push({i:y.push(i(y)+"skewX(",null,r)-2,x:Me(c,d)}):d&&y.push(i(y)+"skewX("+d+r)}function l(c,d,y,_,v,E){if(c!==y||d!==_){var T=v.push(i(v)+"scale(",null,",",null,")");E.push({i:T-4,x:Me(c,y)},{i:T-2,x:Me(d,_)})}else(y!==1||_!==1)&&v.push(i(v)+"scale("+y+","+_+")")}return function(c,d){var y=[],_=[];return c=e(c),d=e(d),s(c.translateX,c.translateY,d.translateX,d.translateY,y,_),a(c.rotate,d.rotate,y,_),o(c.skewX,d.skewX,y,_),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,y,_),c=d=null,function(v){for(var E=-1,T=_.length,R;++E<T;)y[(R=_[E]).i]=R.x(v);return y.join("")}}}var vd=va(gd,"px, ","px)","deg)"),wd=va(_d,", ",")",")"),Id=1e-12;function wa(e){return((e=Math.exp(e))+1/e)/2}function Sd(e){return((e=Math.exp(e))-1/e)/2}function Ed(e){return((e=Math.exp(2*e))-1)/(e+1)}const Td=(function e(t,n,r){function i(s,a){var o=s[0],l=s[1],c=s[2],d=a[0],y=a[1],_=a[2],v=d-o,E=y-l,T=v*v+E*E,R,B;if(T<Id)B=Math.log(_/c)/t,R=function(St){return[o+St*v,l+St*E,c*Math.exp(t*St*B)]};else{var J=Math.sqrt(T),at=(_*_-c*c+r*T)/(2*c*n*J),bt=(_*_-c*c-r*T)/(2*_*n*J),gt=Math.log(Math.sqrt(at*at+1)-at),_t=Math.log(Math.sqrt(bt*bt+1)-bt);B=(_t-gt)/t,R=function(St){var Pt=St*B,dt=wa(gt),ht=c/(n*J)*(dt*Ed(t*Pt+gt)-Sd(gt));return[o+ht*v,l+ht*E,c*dt/wa(t*Pt+gt)]}}return R.duration=B*1e3*t/Math.SQRT2,R}return i.rho=function(s){var a=Math.max(.001,+s),o=a*a,l=o*o;return e(a,o,l)},i})(Math.SQRT2,2,4);var sn=0,Un=0,Cn=0,Ia=1e3,mr,$n,br=0,Ke=0,gr=0,kn=typeof performance=="object"&&performance.now?performance:Date,Sa=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fi(){return Ke||(Sa(Ad),Ke=kn.now()+gr)}function Ad(){Ke=0}function _r(){this._call=this._time=this._next=null}_r.prototype=Ea.prototype={constructor:_r,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Fi():+n)+(t==null?0:+t),!this._next&&$n!==this&&($n?$n._next=this:mr=this,$n=this),this._call=e,this._time=n,Li()},stop:function(){this._call&&(this._call=null,this._time=1/0,Li())}};function Ea(e,t,n){var r=new _r;return r.restart(e,t,n),r}function Rd(){Fi(),++sn;for(var e=mr,t;e;)(t=Ke-e._time)>=0&&e._call.call(void 0,t),e=e._next;--sn}function Ta(){Ke=(br=kn.now())+gr,sn=Un=0;try{Rd()}finally{sn=0,Nd(),Ke=0}}function Bd(){var e=kn.now(),t=e-br;t>Ia&&(gr-=t,br=e)}function Nd(){for(var e,t=mr,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:mr=n);$n=e,Li(r)}function Li(e){if(!sn){Un&&(Un=clearTimeout(Un));var t=e-Ke;t>24?(e<1/0&&(Un=setTimeout(Ta,e-kn.now()-gr)),Cn&&(Cn=clearInterval(Cn))):(Cn||(br=kn.now(),Cn=setInterval(Bd,Ia)),sn=1,Sa(Ta))}}function Aa(e,t,n){var r=new _r;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var Od=Ii("start","end","cancel","interrupt"),Dd=[],Ra=0,Ba=1,xi=2,vr=3,Na=4,Ui=5,wr=6;function Ir(e,t,n,r,i,s){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;Md(e,n,{name:t,index:r,group:i,on:Od,tween:Dd,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:Ra})}function Ci(e,t){var n=Qt(e,t);if(n.state>Ra)throw new Error("too late; already scheduled");return n}function ie(e,t){var n=Qt(e,t);if(n.state>vr)throw new Error("too late; already running");return n}function Qt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Md(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Ea(s,0,n.time);function s(c){n.state=Ba,n.timer.restart(a,n.delay,n.time),n.delay<=c&&a(c-n.delay)}function a(c){var d,y,_,v;if(n.state!==Ba)return l();for(d in r)if(v=r[d],v.name===n.name){if(v.state===vr)return Aa(a);v.state===Na?(v.state=wr,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[d]):+d<t&&(v.state=wr,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[d])}if(Aa(function(){n.state===vr&&(n.state=Na,n.timer.restart(o,n.delay,n.time),o(c))}),n.state=xi,n.on.call("start",e,e.__data__,n.index,n.group),n.state===xi){for(n.state=vr,i=new Array(_=n.tween.length),d=0,y=-1;d<_;++d)(v=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(i[++y]=v);i.length=y+1}}function o(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Ui,1),y=-1,_=i.length;++y<_;)i[y].call(e,d);n.state===Ui&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=wr,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function Sr(e,t){var n=e.__transition,r,i,s=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){s=!1;continue}i=r.state>xi&&r.state<Ui,r.state=wr,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}s&&delete e.__transition}}function Fd(e){return this.each(function(){Sr(this,e)})}function Ld(e,t){var n,r;return function(){var i=ie(this,e),s=i.tween;if(s!==n){r=n=s;for(var a=0,o=r.length;a<o;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function xd(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var s=ie(this,e),a=s.tween;if(a!==r){i=(r=a).slice();for(var o={name:t,value:n},l=0,c=i.length;l<c;++l)if(i[l].name===t){i[l]=o;break}l===c&&i.push(o)}s.tween=i}}function Ud(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Qt(this.node(),n).tween,i=0,s=r.length,a;i<s;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?Ld:xd)(n,e,t))}function $i(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 Qt(i,r).value[t]}}function Oa(e,t){var n;return(typeof t=="number"?Me:t instanceof xn?ma:(n=xn(t))?(t=n,ma):bd)(e,t)}function Cd(e){return function(){this.removeAttribute(e)}}function $d(e){return function(){this.removeAttributeNS(e.space,e.local)}}function kd(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttribute(e);return a===i?null:a===r?s:s=t(r=a,n)}}function Pd(e,t,n){var r,i=n+"",s;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?s:s=t(r=a,n)}}function Vd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttribute(e):(a=this.getAttribute(e),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function zd(e,t,n){var r,i,s;return function(){var a,o=n(this),l;return o==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),l=o+"",a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o)))}}function jd(e,t){var n=cr(e),r=n==="transform"?wd:Oa;return this.attrTween(e,typeof t=="function"?(n.local?zd:Vd)(n,r,$i(this,"attr."+e,t)):t==null?(n.local?$d:Cd)(n):(n.local?Pd:kd)(n,r,t))}function Yd(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Wd(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function qd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Wd(e,s)),n}return i._value=t,i}function Gd(e,t){var n,r;function i(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&Yd(e,s)),n}return i._value=t,i}function Hd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=cr(e);return this.tween(n,(r.local?qd:Gd)(r,t))}function Kd(e,t){return function(){Ci(this,e).delay=+t.apply(this,arguments)}}function Qd(e,t){return t=+t,function(){Ci(this,e).delay=t}}function Xd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Kd:Qd)(t,e)):Qt(this.node(),t).delay}function Jd(e,t){return function(){ie(this,e).duration=+t.apply(this,arguments)}}function Zd(e,t){return t=+t,function(){ie(this,e).duration=t}}function tf(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Jd:Zd)(t,e)):Qt(this.node(),t).duration}function ef(e,t){if(typeof t!="function")throw new Error;return function(){ie(this,e).ease=t}}function nf(e){var t=this._id;return arguments.length?this.each(ef(t,e)):Qt(this.node(),t).ease}function rf(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ie(this,e).ease=n}}function sf(e){if(typeof e!="function")throw new Error;return this.each(rf(this._id,e))}function af(e){typeof e!="function"&&(e=Hs(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var s=t[i],a=s.length,o=r[i]=[],l,c=0;c<a;++c)(l=s[c])&&e.call(l,l.__data__,c,s)&&o.push(l);return new be(r,this._parents,this._name,this._id)}function of(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,s=Math.min(r,i),a=new Array(r),o=0;o<s;++o)for(var l=t[o],c=n[o],d=l.length,y=a[o]=new Array(d),_,v=0;v<d;++v)(_=l[v]||c[v])&&(y[v]=_);for(;o<r;++o)a[o]=t[o];return new be(a,this._parents,this._name,this._id)}function lf(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function cf(e,t,n){var r,i,s=lf(t)?Ci:ie;return function(){var a=s(this,e),o=a.on;o!==r&&(i=(r=o).copy()).on(t,n),a.on=i}}function uf(e,t){var n=this._id;return arguments.length<2?Qt(this.node(),n).on.on(e):this.each(cf(n,e,t))}function hf(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function df(){return this.on("end.remove",hf(this._id))}function ff(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ei(e));for(var r=this._groups,i=r.length,s=new Array(i),a=0;a<i;++a)for(var o=r[a],l=o.length,c=s[a]=new Array(l),d,y,_=0;_<l;++_)(d=o[_])&&(y=e.call(d,d.__data__,_,o))&&("__data__"in d&&(y.__data__=d.__data__),c[_]=y,Ir(c[_],t,n,_,c,Qt(d,n)));return new be(s,this._parents,t,n)}function pf(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gs(e));for(var r=this._groups,i=r.length,s=[],a=[],o=0;o<i;++o)for(var l=r[o],c=l.length,d,y=0;y<c;++y)if(d=l[y]){for(var _=e.call(d,d.__data__,y,l),v,E=Qt(d,n),T=0,R=_.length;T<R;++T)(v=_[T])&&Ir(v,t,n,T,_,E);s.push(_),a.push(d)}return new be(s,a,t,n)}var yf=Dn.prototype.constructor;function mf(){return new yf(this._groups,this._parents)}function bf(e,t){var n,r,i;return function(){var s=nn(this,e),a=(this.style.removeProperty(e),nn(this,e));return s===a?null:s===n&&a===r?i:i=t(n=s,r=a)}}function Da(e){return function(){this.style.removeProperty(e)}}function gf(e,t,n){var r,i=n+"",s;return function(){var a=nn(this,e);return a===i?null:a===r?s:s=t(r=a,n)}}function _f(e,t,n){var r,i,s;return function(){var a=nn(this,e),o=n(this),l=o+"";return o==null&&(l=o=(this.style.removeProperty(e),nn(this,e))),a===l?null:a===r&&l===i?s:(i=l,s=t(r=a,o))}}function vf(e,t){var n,r,i,s="style."+t,a="end."+s,o;return function(){var l=ie(this,e),c=l.on,d=l.value[s]==null?o||(o=Da(t)):void 0;(c!==n||i!==d)&&(r=(n=c).copy()).on(a,i=d),l.on=r}}function wf(e,t,n){var r=(e+="")=="transform"?vd:Oa;return t==null?this.styleTween(e,bf(e,r)).on("end.style."+e,Da(e)):typeof t=="function"?this.styleTween(e,_f(e,r,$i(this,"style."+e,t))).each(vf(this._id,e)):this.styleTween(e,gf(e,r,t),n).on("end.style."+e,null)}function If(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Sf(e,t,n){var r,i;function s(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&If(e,a,n)),r}return s._value=t,s}function Ef(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Sf(e,t,n??""))}function Tf(e){return function(){this.textContent=e}}function Af(e){return function(){var t=e(this);this.textContent=t??""}}function Rf(e){return this.tween("text",typeof e=="function"?Af($i(this,"text",e)):Tf(e==null?"":e+""))}function Bf(e){return function(t){this.textContent=e.call(this,t)}}function Nf(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Bf(i)),t}return r._value=e,r}function Of(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Nf(e))}function Df(){for(var e=this._name,t=this._id,n=Ma(),r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)if(l=a[c]){var d=Qt(l,t);Ir(l,e,n,c,a,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new be(r,this._parents,e,n)}function Mf(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(s,a){var o={value:a},l={value:function(){--i===0&&s()}};n.each(function(){var c=ie(this,r),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(o),t._.interrupt.push(o),t._.end.push(l)),c.on=t}),i===0&&s()})}var Ff=0;function be(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ma(){return++Ff}var ge=Dn.prototype;be.prototype={constructor:be,select:ff,selectAll:pf,selectChild:ge.selectChild,selectChildren:ge.selectChildren,filter:af,merge:of,selection:mf,transition:Df,call:ge.call,nodes:ge.nodes,node:ge.node,size:ge.size,empty:ge.empty,each:ge.each,on:uf,attr:jd,attrTween:Hd,style:wf,styleTween:Ef,text:Rf,textTween:Of,remove:df,tween:Ud,delay:Xd,duration:tf,ease:nf,easeVarying:sf,end:Mf,[Symbol.iterator]:ge[Symbol.iterator]};function Lf(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var xf={time:null,delay:0,duration:250,ease:Lf};function Uf(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Cf(e){var t,n;e instanceof be?(t=e._id,e=e._name):(t=Ma(),(n=xf).time=Fi(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,s=0;s<i;++s)for(var a=r[s],o=a.length,l,c=0;c<o;++c)(l=a[c])&&Ir(l,e,t,c,a,n||Uf(l,t));return new be(r,this._parents,e,t)}Dn.prototype.interrupt=Fd,Dn.prototype.transition=Cf;const Er=e=>()=>e;function $f(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 _e(e,t,n){this.k=e,this.x=t,this.y=n}_e.prototype={constructor:_e,scale:function(e){return e===1?this:new _e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _e(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 Tr=new _e(1,0,0);_e.prototype;function ki(e){e.stopImmediatePropagation()}function Pn(e){e.preventDefault(),e.stopImmediatePropagation()}function kf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Pf(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Fa(){return this.__zoom||Tr}function Vf(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function zf(){return navigator.maxTouchPoints||"ontouchstart"in this}function jf(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}function Yf(){var e=kf,t=Pf,n=jf,r=Vf,i=zf,s=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],o=250,l=Td,c=Ii("start","zoom","end"),d,y,_,v=500,E=150,T=0,R=10;function B(p){p.property("__zoom",Fa).on("wheel.zoom",Pt,{passive:!1}).on("mousedown.zoom",dt).on("dblclick.zoom",ht).filter(i).on("touchstart.zoom",te).on("touchmove.zoom",N).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}B.transform=function(p,g,u,m){var b=p.selection?p.selection():p;b.property("__zoom",Fa),p!==b?gt(p,g,u,m):b.interrupt().each(function(){_t(this,arguments).event(m).start().zoom(null,typeof g=="function"?g.apply(this,arguments):g).end()})},B.scaleBy=function(p,g,u,m){B.scaleTo(p,function(){var b=this.__zoom.k,w=typeof g=="function"?g.apply(this,arguments):g;return b*w},u,m)},B.scaleTo=function(p,g,u,m){B.transform(p,function(){var b=t.apply(this,arguments),w=this.__zoom,I=u==null?bt(b):typeof u=="function"?u.apply(this,arguments):u,S=w.invert(I),O=typeof g=="function"?g.apply(this,arguments):g;return n(at(J(w,O),I,S),b,a)},u,m)},B.translateBy=function(p,g,u,m){B.transform(p,function(){return n(this.__zoom.translate(typeof g=="function"?g.apply(this,arguments):g,typeof u=="function"?u.apply(this,arguments):u),t.apply(this,arguments),a)},null,m)},B.translateTo=function(p,g,u,m,b){B.transform(p,function(){var w=t.apply(this,arguments),I=this.__zoom,S=m==null?bt(w):typeof m=="function"?m.apply(this,arguments):m;return n(Tr.translate(S[0],S[1]).scale(I.k).translate(typeof g=="function"?-g.apply(this,arguments):-g,typeof u=="function"?-u.apply(this,arguments):-u),w,a)},m,b)};function J(p,g){return g=Math.max(s[0],Math.min(s[1],g)),g===p.k?p:new _e(g,p.x,p.y)}function at(p,g,u){var m=g[0]-u[0]*p.k,b=g[1]-u[1]*p.k;return m===p.x&&b===p.y?p:new _e(p.k,m,b)}function bt(p){return[(+p[0][0]+ +p[1][0])/2,(+p[0][1]+ +p[1][1])/2]}function gt(p,g,u,m){p.on("start.zoom",function(){_t(this,arguments).event(m).start()}).on("interrupt.zoom end.zoom",function(){_t(this,arguments).event(m).end()}).tween("zoom",function(){var b=this,w=arguments,I=_t(b,w).event(m),S=t.apply(b,w),O=u==null?bt(S):typeof u=="function"?u.apply(b,w):u,A=Math.max(S[1][0]-S[0][0],S[1][1]-S[0][1]),M=b.__zoom,K=typeof g=="function"?g.apply(b,w):g,G=l(M.invert(O).concat(A/M.k),K.invert(O).concat(A/K.k));return function(Z){if(Z===1)Z=K;else{var yt=G(Z),Be=A/yt[2];Z=new _e(Be,O[0]-yt[0]*Be,O[1]-yt[1]*Be)}I.zoom(null,Z)}})}function _t(p,g,u){return!u&&p.__zooming||new St(p,g)}function St(p,g){this.that=p,this.args=g,this.active=0,this.sourceEvent=null,this.extent=t.apply(p,g),this.taps=0}St.prototype={event:function(p){return p&&(this.sourceEvent=p),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(p,g){return this.mouse&&p!=="mouse"&&(this.mouse[1]=g.invert(this.mouse[0])),this.touch0&&p!=="touch"&&(this.touch0[1]=g.invert(this.touch0[0])),this.touch1&&p!=="touch"&&(this.touch1[1]=g.invert(this.touch1[0])),this.that.__zoom=g,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(p){var g=me(this.that).datum();c.call(p,this.that,new $f(p,{sourceEvent:this.sourceEvent,target:B,transform:this.that.__zoom,dispatch:c}),g)}};function Pt(p,...g){if(!e.apply(this,arguments))return;var u=_t(this,g).event(p),m=this.__zoom,b=Math.max(s[0],Math.min(s[1],m.k*Math.pow(2,r.apply(this,arguments)))),w=qe(p);if(u.wheel)(u.mouse[0][0]!==w[0]||u.mouse[0][1]!==w[1])&&(u.mouse[1]=m.invert(u.mouse[0]=w)),clearTimeout(u.wheel);else{if(m.k===b)return;u.mouse=[w,m.invert(w)],Sr(this),u.start()}Pn(p),u.wheel=setTimeout(I,E),u.zoom("mouse",n(at(J(m,b),u.mouse[0],u.mouse[1]),u.extent,a));function I(){u.wheel=null,u.end()}}function dt(p,...g){if(_||!e.apply(this,arguments))return;var u=p.currentTarget,m=_t(this,g,!0).event(p),b=me(p.view).on("mousemove.zoom",O,!0).on("mouseup.zoom",A,!0),w=qe(p,u),I=p.clientX,S=p.clientY;Jh(p.view),ki(p),m.mouse=[w,this.__zoom.invert(w)],Sr(this),m.start();function O(M){if(Pn(M),!m.moved){var K=M.clientX-I,G=M.clientY-S;m.moved=K*K+G*G>T}m.event(M).zoom("mouse",n(at(m.that.__zoom,m.mouse[0]=qe(M,u),m.mouse[1]),m.extent,a))}function A(M){b.on("mousemove.zoom mouseup.zoom",null),Zh(M.view,m.moved),Pn(M),m.event(M).end()}}function ht(p,...g){if(e.apply(this,arguments)){var u=this.__zoom,m=qe(p.changedTouches?p.changedTouches[0]:p,this),b=u.invert(m),w=u.k*(p.shiftKey?.5:2),I=n(at(J(u,w),m,b),t.apply(this,g),a);Pn(p),o>0?me(this).transition().duration(o).call(gt,I,m,p):me(this).call(B.transform,I,m,p)}}function te(p,...g){if(e.apply(this,arguments)){var u=p.touches,m=u.length,b=_t(this,g,p.changedTouches.length===m).event(p),w,I,S,O;for(ki(p),I=0;I<m;++I)S=u[I],O=qe(S,this),O=[O,this.__zoom.invert(O),S.identifier],b.touch0?!b.touch1&&b.touch0[2]!==O[2]&&(b.touch1=O,b.taps=0):(b.touch0=O,w=!0,b.taps=1+!!d);d&&(d=clearTimeout(d)),w&&(b.taps<2&&(y=O[0],d=setTimeout(function(){d=null},v)),Sr(this),b.start())}}function N(p,...g){if(this.__zooming){var u=_t(this,g).event(p),m=p.changedTouches,b=m.length,w,I,S,O;for(Pn(p),w=0;w<b;++w)I=m[w],S=qe(I,this),u.touch0&&u.touch0[2]===I.identifier?u.touch0[0]=S:u.touch1&&u.touch1[2]===I.identifier&&(u.touch1[0]=S);if(I=u.that.__zoom,u.touch1){var A=u.touch0[0],M=u.touch0[1],K=u.touch1[0],G=u.touch1[1],Z=(Z=K[0]-A[0])*Z+(Z=K[1]-A[1])*Z,yt=(yt=G[0]-M[0])*yt+(yt=G[1]-M[1])*yt;I=J(I,Math.sqrt(Z/yt)),S=[(A[0]+K[0])/2,(A[1]+K[1])/2],O=[(M[0]+G[0])/2,(M[1]+G[1])/2]}else if(u.touch0)S=u.touch0[0],O=u.touch0[1];else return;u.zoom("touch",n(at(I,S,O),u.extent,a))}}function F(p,...g){if(this.__zooming){var u=_t(this,g).event(p),m=p.changedTouches,b=m.length,w,I;for(ki(p),_&&clearTimeout(_),_=setTimeout(function(){_=null},v),w=0;w<b;++w)I=m[w],u.touch0&&u.touch0[2]===I.identifier?delete u.touch0:u.touch1&&u.touch1[2]===I.identifier&&delete u.touch1;if(u.touch1&&!u.touch0&&(u.touch0=u.touch1,delete u.touch1),u.touch0)u.touch0[1]=this.__zoom.invert(u.touch0[0]);else if(u.end(),u.taps===2&&(I=qe(I,this),Math.hypot(y[0]-I[0],y[1]-I[1])<R)){var S=me(this).on("dblclick.zoom");S&&S.apply(this,arguments)}}}return B.wheelDelta=function(p){return arguments.length?(r=typeof p=="function"?p:Er(+p),B):r},B.filter=function(p){return arguments.length?(e=typeof p=="function"?p:Er(!!p),B):e},B.touchable=function(p){return arguments.length?(i=typeof p=="function"?p:Er(!!p),B):i},B.extent=function(p){return arguments.length?(t=typeof p=="function"?p:Er([[+p[0][0],+p[0][1]],[+p[1][0],+p[1][1]]]),B):t},B.scaleExtent=function(p){return arguments.length?(s[0]=+p[0],s[1]=+p[1],B):[s[0],s[1]]},B.translateExtent=function(p){return arguments.length?(a[0][0]=+p[0][0],a[1][0]=+p[1][0],a[0][1]=+p[0][1],a[1][1]=+p[1][1],B):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},B.constrain=function(p){return arguments.length?(n=p,B):n},B.duration=function(p){return arguments.length?(o=+p,B):o},B.interpolate=function(p){return arguments.length?(l=p,B):l},B.on=function(){var p=c.on.apply(c,arguments);return p===c?B:p},B.clickDistance=function(p){return arguments.length?(T=(p=+p)*p,B):Math.sqrt(T)},B.tapDistance=function(p){return arguments.length?(R=+p,B):R},B}const Wf=h.defineComponent({__name:"scatterplot",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},forceRegenerate:{type:Boolean,default:!1},data:{type:Array,default:()=>[]},metaData:{type:Object,default:()=>({})},colorMap:{type:Map,default:()=>new Map},selectedMapEntries:{type:[Array,Map],default:()=>[]}},emits:["updateColorMap"],setup(e,{emit:t}){const n=e,r=h.ref(null),i=h.ref(null),s=h.ref(null),a=h.ref(null);let o=null,l=null,c=null,d=[],y=null,_=null,v=null,E=0,T=0,R=1;h.watch(()=>n.colorMap,g,{deep:!0});function B(u){if(!u||u.length<7)return[1,0,0];const m=parseInt(u.slice(1,3),16)/255,b=parseInt(u.slice(3,5),16)/255,w=parseInt(u.slice(5,7),16)/255;return[m,b,w].some(Number.isNaN)?[1,0,0]:[m,b,w]}const J=(u,m,b)=>u+(m-u)*b;function at(u,m){const b=u.parentElement;b&&(R=window.devicePixelRatio||1,E=b.clientWidth||800,T=b.clientHeight||400,u.style.width=`${E}px`,u.style.height=`${T}px`,u.width=Math.round(E*R),u.height=Math.round(T*R),m.viewport(0,0,u.width,u.height))}function bt(u,m){var Ot,Oe,ze,Nc,Oc,Dc,Mc,Fc,Lc,xc,Uc,Cc;const b=(Dc=(Oc=(Nc=(ze=(Oe=(Ot=n.metaData)==null?void 0:Ot.row_groups)==null?void 0:Oe[0])==null?void 0:ze.columns)==null?void 0:Nc[0])==null?void 0:Oc.meta_data)==null?void 0:Dc.statistics,w=(Cc=(Uc=(xc=(Lc=(Fc=(Mc=n.metaData)==null?void 0:Mc.row_groups)==null?void 0:Fc[0])==null?void 0:Lc.columns)==null?void 0:xc[1])==null?void 0:Uc.meta_data)==null?void 0:Cc.statistics,I=Number((b==null?void 0:b.min_value)??-1),S=Number((b==null?void 0:b.max_value)??1),O=Number((w==null?void 0:w.min_value)??-1),A=Number((w==null?void 0:w.max_value)??1),M=(I+S)/2,K=(O+A)/2,G=Math.max(1e-9,S-I),Z=Math.max(1e-9,A-O),yt=2/Math.max(G,Z),Be=y.x/u*2-1,ee=-y.y/m*2+1,Ne=y.k*yt,Ve=Be-Ne*M,En=ee-Ne*K;return{s:Ne,tx:Ve,ty:En}}function gt(u,m,b,w){const{s:I,tx:S,ty:O}=bt(b,w),A=u/b*2-1,M=-(m/w*2-1),K=(A-S)/I,G=(M-O)/I;return{x:K,y:G}}function _t(u,m,b,w,I){if(!u.length||!y)return null;const S=gt(m,b,w,I);let O=1/0,A=null;for(const M of u){const K=M.x-S.x,G=M.y-S.y,Z=Math.hypot(K,G),yt=3/(y.k/2);Z<O&&Z<yt&&(O=Z,A=M)}return A}function St(){var w,I;const u=[],m=((w=n.metaData)==null?void 0:w.schema)||[],b=n.data;for(let S=0;S<b.length;S++){const O=b[S],A=Number(O[0]),M=Number(O[1]),K={};for(let G=0;G<m.length;G++){const Z=((I=m[G])==null?void 0:I.name)??`col_${G}`;K[Z]=O[G]}u.push({x:A,y:M,rawX:A,rawY:M,color:[.5,.5,.5],id:S,attrs:K})}return u}function Pt(u,m,b){const w=u.createShader(u.VERTEX_SHADER);if(u.shaderSource(w,m),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))return console.error("Vertex shader error:",u.getShaderInfoLog(w)),null;const I=u.createShader(u.FRAGMENT_SHADER);if(u.shaderSource(I,b),u.compileShader(I),!u.getShaderParameter(I,u.COMPILE_STATUS))return console.error("Fragment shader error:",u.getShaderInfoLog(I)),null;const S=u.createProgram();return u.attachShader(S,w),u.attachShader(S,I),u.linkProgram(S),u.getProgramParameter(S,u.LINK_STATUS)?(u.validateProgram(S),u.getProgramParameter(S,u.VALIDATE_STATUS)?S:(console.error("Program validate error:",u.getProgramInfoLog(S)),null)):(console.error("Program link error:",u.getProgramInfoLog(S)),null)}function dt(u,m,b){if(!b.length)return null;const w=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,w);const I=new Float32Array(b.flatMap(Z=>[Z.x,Z.y]));u.bufferData(u.ARRAY_BUFFER,I,u.STATIC_DRAW);const S=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,S);const O=new Float32Array(b.flatMap(Z=>Z.color));u.bufferData(u.ARRAY_BUFFER,O,u.STATIC_DRAW);const A=u.getAttribLocation(m,"a_position"),M=u.getAttribLocation(m,"a_color"),K=u.getUniformLocation(m,"u_viewMatrix"),G=u.getUniformLocation(m,"u_pointSize");return{program:m,positionBuffer:w,colorBuffer:S,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:K,pointSizeLocation:G,count:b.length}}function ht(u,m,b,w=null){if(!u||!m||!y)return;const{program:I,positionBuffer:S,colorBuffer:O,positionAttributeLocation:A,colorAttributeLocation:M,viewMatrixLocation:K,pointSizeLocation:G,count:Z}=m;u.clearColor(0,0,0,1),u.clear(u.COLOR_BUFFER_BIT),u.useProgram(I),u.enableVertexAttribArray(A),u.bindBuffer(u.ARRAY_BUFFER,S),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0),u.enableVertexAttribArray(M),u.bindBuffer(u.ARRAY_BUFFER,O),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0);const yt=u.canvas.clientWidth,Be=u.canvas.clientHeight,{s:ee,tx:Ne,ty:Ve}=bt(yt,Be),En=new Float32Array([ee,0,0,0,0,ee,0,0,0,0,1,0,Ne,Ve,0,1]);if(u.uniformMatrix4fv(K,!1,En),u.uniform1f(G,Math.max(1.5,b*Math.sqrt(y.k)*R)),u.enable(u.BLEND),u.blendFunc(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawArrays(u.POINTS,0,Z),w){const Ot=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Ot),u.bufferData(u.ARRAY_BUFFER,new Float32Array([w.x,w.y]),u.STATIC_DRAW),u.vertexAttribPointer(A,2,u.FLOAT,!1,0,0);const Oe=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,Oe),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,1,.5]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(G,Math.max(2.5,b*Math.sqrt(y.k)*2.5*R)),u.drawArrays(u.POINTS,0,1);const ze=u.createBuffer();u.bindBuffer(u.ARRAY_BUFFER,ze),u.bufferData(u.ARRAY_BUFFER,new Float32Array([1,.8,.2]),u.STATIC_DRAW),u.vertexAttribPointer(M,3,u.FLOAT,!1,0,0),u.uniform1f(G,Math.max(3,b*Math.sqrt(y.k)*3*R)),u.drawArrays(u.POINTS,0,1),u.deleteBuffer(Ot),u.deleteBuffer(Oe),u.deleteBuffer(ze)}}function te(){if(!(!i.value||!r.value)){if(o=i.value.getContext("webgl",{preserveDrawingBuffer:!0,antialias:!0,alpha:!0})||i.value.getContext("experimental-webgl"),!o){console.error("WebGL not supported");return}at(i.value,o),l=Pt(o,`
|
|
15
15
|
attribute vec2 a_position;
|
|
16
16
|
attribute vec3 a_color;
|
|
17
17
|
uniform mat4 u_viewMatrix;
|
|
@@ -32,11 +32,15 @@
|
|
|
32
32
|
if (dist > 0.4) { alpha = 1.0 - (dist - 0.4) * 2.0; }
|
|
33
33
|
gl_FragColor = vec4(v_color, alpha);
|
|
34
34
|
}
|
|
35
|
-
`),l&&(o.useProgram(l),d=
|
|
35
|
+
`),l&&(o.useProgram(l),d=St(),c=dt(o,l,d),y=Tr.translate(E/2,T/2).scale(1),_=Yf().scaleExtent([.1,100]).on("zoom",u=>{y=u.transform,ht(o,c,2,v)}),me(i.value).call(_),requestAnimationFrame(()=>ht(o,c,2,null)),i.value.addEventListener("mousemove",N),i.value.addEventListener("mouseleave",F))}}function N(u){var S,O,A,M,K;if(!i.value)return;const m=i.value.getBoundingClientRect(),b=u.clientX-m.left,w=u.clientY-m.top,I=_t(d,b,w,E,T);if(I){const G=s.value;G.style.left=`${u.clientX+15}px`,G.style.top=`${u.clientY-15}px`,G.style.opacity="1";const Z=((S=n.metaData)==null?void 0:S.schema)||[],yt=Z.findIndex(Ot=>(Ot==null?void 0:Ot.name)===n.colorMode),Be=n.colorMode,ee=yt>=0?(A=I.attrs)==null?void 0:A[((O=Z[yt])==null?void 0:O.name)||""]:void 0;let Ne="";const Ve=n.selectedMapEntries;ee!==void 0&&(Ve instanceof Map?Ne=Ve.has(ee)?String(ee):"":Array.isArray(Ve)&&(Ne=Ve.some(([Ot])=>Ot===ee)?String(ee):""));const En=[];for(let Ot=2;Ot<Math.min(Z.length,7);Ot++){const Oe=(M=Z[Ot])==null?void 0:M.name;if(!Oe)continue;const ze=(K=I.attrs)==null?void 0:K[Oe];En.push(`<div><em>${Oe}</em>: ${ze===void 0?"—":String(ze)}</div>`)}G.innerHTML=`
|
|
36
|
+
<strong>(${I.rawX.toFixed(2)}, ${I.rawY.toFixed(2)})</strong>
|
|
37
|
+
${yt>=0?`<div><b>${Be}</b>: ${Ne||String(ee)}</div>`:""}
|
|
38
|
+
${En.join("")}
|
|
39
|
+
`,v=I,ht(o,c,2,v)}else s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function F(){s.value&&(s.value.style.opacity="0"),v!==null&&(v=null,ht(o,c,2,null))}function p(){!i.value||!o||(at(i.value,o),ht(o,c,2,v))}function g(){var O;if(!o||!c||!n.data.length)return;const u=(((O=n.metaData)==null?void 0:O.schema)||[]).findIndex(A=>(A==null?void 0:A.name)===n.colorMode),m=u>=0?u:-1,b=B(n.startColor),w=B(n.endColor);let I=[];if(n.colorMap&&n.colorMap.size>0&&m>=0)I=n.data.flatMap(A=>n.colorMap.get(A[m])||[.6,.6,.6]);else if(m>=0){const A=n.data.map(G=>Number(G[m])).filter(Number.isFinite),M=Math.min(...A),K=Math.max(...A)-M||1;I=n.data.flatMap(G=>{const Z=Number(G[m]),yt=Math.max(0,Math.min(1,(Z-M)/K));return[J(b[0],w[0],yt),J(b[1],w[1],yt),J(b[2],w[2],yt)]})}else{const A=B(n.singleColor);I=n.data.flatMap(()=>A)}o.deleteBuffer(c.colorBuffer);const S=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,S),o.bufferData(o.ARRAY_BUFFER,new Float32Array(I),o.STATIC_DRAW),c.colorBuffer=S,ht(o,c,2,v)}return h.watch(()=>n.forceRegenerate,()=>{!o||!l||(d=St(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),y=Tr,i.value&&_&&me(i.value).call(_.transform,y),g(),ht(o,c,2,null))}),h.watch(()=>n.data,()=>{if(!o||!l){te();return}d=St(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null)}),h.watch(()=>n.colorMode,g),h.watch([()=>n.startColor,()=>n.endColor,()=>n.singleColor],g),h.watch(()=>n.pointCount,u=>{!o||!l||(d=St(),c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer)),c=dt(o,l,d),g(),ht(o,c,2,null))}),h.onMounted(()=>{window.addEventListener("resize",p)}),h.onBeforeUnmount(()=>{i.value&&(i.value.removeEventListener("mousemove",N),i.value.removeEventListener("mouseleave",F)),window.removeEventListener("resize",p),o&&c&&(o.deleteBuffer(c.positionBuffer),o.deleteBuffer(c.colorBuffer),l&&o.deleteProgram(l))}),(u,m)=>(h.openBlock(),h.createElementBlock("div",{class:"scatterplot-container",ref_key:"containerRef",ref:r},[h.createElementVNode("canvas",{ref_key:"canvasRef",ref:i},null,512),h.createElementVNode("div",{id:"tooltip",ref_key:"tooltipRef",ref:s},null,512),h.withDirectives(h.createElementVNode("div",{id:"debug",ref_key:"debugRef",ref:a},null,512),[[h.vShow,!1]])],512))}}),qf=On(Wf,[["__scopeId","data-v-72d91e48"]]),Gf={class:"control-panel"},Hf={class:"color-option"},Kf=["value"],Qf={key:0,class:"color-option"},Xf={class:"legend"},Jf={class:"legend-label"},Zf=h.defineComponent({__name:"control",props:{pointCount:{type:Number,default:5e3},colorMode:{type:String,default:"random"},startColor:{type:String,default:"#ff0000"},endColor:{type:String,default:"#0000ff"},singleColor:{type:String,default:"#4285f4"},colorScheme:{type:Map,default:()=>new Map},colorMapMap:{type:Map,default:()=>new Map}},emits:["update:pointCount","update:colorMode","update:startColor","update:endColor","update:singleColor","regenerate","updateColorMap"],setup(e,{emit:t}){const n=e,r=t,i=h.ref(n.pointCount),s=h.ref(n.colorMode),a=h.ref(n.startColor),o=h.ref(n.endColor),l=h.ref(n.singleColor),c=h.computed(()=>n.colorMapMap instanceof Map?Array.from(n.colorMapMap.keys()):[]),d=h.computed(()=>n.colorMapMap instanceof Map?n.colorMapMap.get(s.value):void 0),y=h.computed(()=>d.value?Array.from(d.value.entries()):[]);function _(E){if(!E)return"rgb(150,150,150)";const[T,R,B]=E;return`rgb(${Math.round(T*255)}, ${Math.round(R*255)}, ${Math.round(B*255)})`}function v(){r("update:colorMode",s.value),r("updateColorMap",[s.value,d.value??new Map]),r("update:startColor",a.value),r("update:endColor",o.value),r("update:singleColor",l.value)}return h.watch(()=>n.pointCount,E=>i.value=E),h.watch(()=>n.colorMode,E=>s.value=E),h.watch(()=>n.startColor,E=>a.value=E),h.watch(()=>n.endColor,E=>o.value=E),h.watch(()=>n.singleColor,E=>l.value=E),h.watch(s,v),h.watch(()=>n.colorMapMap,()=>{n.colorMapMap instanceof Map&&(s.value!=="random"&&!n.colorMapMap.has(s.value)&&(s.value="random"),v())}),(E,T)=>(h.openBlock(),h.createElementBlock("div",Gf,[T[4]||(T[4]=h.createElementVNode("h3",null,"Color Controls",-1)),h.createElementVNode("div",Hf,[T[2]||(T[2]=h.createElementVNode("label",{for:"colorMode"},"Color Mode:",-1)),h.withDirectives(h.createElementVNode("select",{id:"colorMode","onUpdate:modelValue":T[0]||(T[0]=R=>s.value=R)},[T[1]||(T[1]=h.createElementVNode("option",{value:"random"},"all",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(c.value,R=>(h.openBlock(),h.createElementBlock("option",{key:R,value:R},h.toDisplayString(R),9,Kf))),128))],512),[[h.vModelSelect,s.value]])]),y.value.length?(h.openBlock(),h.createElementBlock("div",Qf,[h.createElementVNode("div",Xf,[T[3]||(T[3]=h.createElementVNode("h4",null,"Legend",-1)),(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(y.value,([R,B],J)=>(h.openBlock(),h.createElementBlock("div",{class:"legend-item",key:`${R}-${J}`},[h.createElementVNode("div",{class:"legend-color",style:h.normalizeStyle({backgroundColor:_(B)})},null,4),h.createElementVNode("div",Jf,h.toDisplayString(R),1)]))),128))])])):h.createCommentVNode("",!0)]))}}),tp=On(Zf,[["__scopeId","data-v-710a5c42"]]),ep={class:"app-container"},Pi="UMAP_1",Vi="UMAP_2",np=h.defineComponent({__name:"wrapper",props:{apiUrl:{},pkg:{},srcUrl:{},srcFileType:{},srcFileId:{}},setup(e){const t=e,n=h.ref(5e3),r=h.ref("random"),i=h.ref("#ff0000"),s=h.ref("#0000ff"),a=h.ref("#4285f4"),o=h.ref(!1),l=h.ref(0),c=h.ref([]),d=h.ref(null),y=h.ref(new Map),_=h.ref(new Map),v=h.ref([]),E=js(),T=h.ref(null),R=h.ref(null);h.watch(()=>{var p,g,u,m;return{srcUrl:t.srcUrl,srcFileType:t.srcFileType,srcFileId:t.srcFileId,pkgId:((g=(p=t.pkg)==null?void 0:p.content)==null?void 0:g.id)||"",pkgType:((m=(u=t.pkg)==null?void 0:u.content)==null?void 0:m.packageType)||"",apiUrl:t.apiUrl||""}},async({srcUrl:p,srcFileType:g,srcFileId:u,pkgId:m,pkgType:b,apiUrl:w})=>{var I,S,O;try{if(c.value=[],d.value=null,await B(),p){const A=g??(p.toLowerCase().endsWith(".csv")?"csv":"parquet");await J(p,A,u||"umap_file"),await at();return}if(m&&w){await St(m,w);const A=(O=(S=(I=v.value)==null?void 0:I[0])==null?void 0:S.content)==null?void 0:O.id;if(!A)return;const M=await Pt(m,A,w);await J(M,b==="CSV"?"csv":"parquet",A),await at()}}catch(A){console.error("[UMAP Wrapper] Load failed:",(A==null?void 0:A.message)||A)}},{immediate:!0}),h.watch(n,async()=>{R.value&&T.value&&await bt()}),h.watch([()=>E.sharedVersion,()=>E.sharedResultName],async()=>{E.sharedResultName&&(await B(),R.value=E.sharedResultName,await at())});async function B(){if(T.value)return;const{connectionId:p}=await E.createConnection(`umap_${Date.now()}`);T.value=p}async function J(p,g,u){const m=`umap_${u.replace(/[^a-zA-Z0-9_]/g,"_")}`;R.value=await E.loadFile(p,g,m,{},T.value,u)}async function at(){var b,w,I,S;if(!R.value||!T.value)return;const p=await F(R.value),g=p.filter(O=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(O.type)),u=p.some(O=>O.name===Pi)?Pi:((b=g[0])==null?void 0:b.name)||((w=p[0])==null?void 0:w.name),m=p.some(O=>O.name===Vi)?Vi:((I=g[1])==null?void 0:I.name)||((S=p[1])==null?void 0:S.name)||u;await bt(u,m,p.map(O=>O.name)),await gt(p,u,m)}async function bt(p=Pi,g=Vi,u){var O;if(!R.value||!T.value)return;const m=(u||(await F(R.value)).map(A=>A.name)).filter(A=>A!==p&&A!==g),b=`SELECT ${[`CAST(${dt(p)} AS DOUBLE) AS __x`,`CAST(${dt(g)} AS DOUBLE) AS __y`,...m.map(A=>dt(A))].join(", ")} FROM ${R.value} LIMIT ${n.value}`,w=await E.executeQuery(b,T.value);c.value=w.map(A=>[A.__x,A.__y,...m.map(M=>A[M])]);const I=`
|
|
36
40
|
SELECT min(${dt(p)}) AS xmin, max(${dt(p)}) AS xmax,
|
|
37
41
|
min(${dt(g)}) AS ymin, max(${dt(g)}) AS ymax
|
|
38
|
-
FROM ${
|
|
39
|
-
`,S=((O=await E.executeQuery(I,T.value))==null?void 0:O[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};d.value={schema:[{name:p},{name:g},...m.map(A=>({name:A}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:S.xmin,max_value:S.xmax}}},{meta_data:{statistics:{min_value:S.ymin,max_value:S.ymax}}}]}]}}async function bt(p,g,u){_.value=new Map;const m=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],b=w=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(w);for(const w of p){if(w.name===g||w.name===u){_.value.set(w.name,new Map);continue}if(b(w.type))_.value.set(w.name,new Map);else{const I=`SELECT DISTINCT ${dt(w.name)} AS v FROM ${N.value} LIMIT 10000`,S=(await E.executeQuery(I,T.value)).map(A=>A.v).filter(A=>A!=null),O=new Map;S.forEach((A,M)=>O.set(A,Zt(m[M%m.length]))),_.value.set(w.name,O)}}(d.value||(d.value={})).key_value_metadata=Array.from(_.value.keys()).map(w=>{var I;return{key:w,value:JSON.stringify(Array.from(((I=_.value.get(w))==null?void 0:I.keys())??[]))}}),r.value!=="random"&&!_.value.has(r.value)&&(r.value="random")}async function gt(){const{useGetToken:p}=await Promise.resolve().then(()=>Bc);return p()}async function It(p,g){const u=await gt(),m=`${g}/packages/${p}/view?api_key=${u}`,b=await fetch(m);if(!b.ok)throw new Error(`view failed: ${b.status}`);v.value=await b.json()}async function $t(p,g,u){const m=await gt(),b=`${u}/packages/${p}/files/${g}?api_key=${m}`,w=await fetch(b);if(!w.ok)throw new Error(`file url failed: ${w.status}`);return(await w.json()).url}function dt(p){return`"${p.replace(/"/g,'""')}"`}function ht(){o.value=!o.value,l.value++}function Zt(p){try{if(!p||p.length<7)return[1,0,0];const g=parseInt(p.slice(1,3),16)/255,u=parseInt(p.slice(3,5),16)/255,m=parseInt(p.slice(5,7),16)/255;return Number.isNaN(g)||Number.isNaN(u)||Number.isNaN(m)?[1,0,0]:[g,u,m]}catch{return[1,0,0]}}function R(p){y.value=p[1]}async function F(p){return(await E.executeQuery(`PRAGMA table_info(${p});`,T.value)).map(g=>({name:g.name,type:g.type}))}return h.onMounted(async()=>{await B()}),h.onBeforeUnmount(async()=>{T.value&&await E.closeConnection(T.value)}),(p,g)=>(h.openBlock(),h.createElementBlock("div",ep,[(h.openBlock(),h.createBlock(qf,{data:c.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","forceRegenerate"])),h.createVNode(tp,{pointCount:n.value,"onUpdate:pointCount":g[0]||(g[0]=u=>n.value=u),colorMode:r.value,"onUpdate:colorMode":g[1]||(g[1]=u=>r.value=u),startColor:i.value,"onUpdate:startColor":g[2]||(g[2]=u=>i.value=u),endColor:s.value,"onUpdate:endColor":g[3]||(g[3]=u=>s.value=u),singleColor:a.value,"onUpdate:singleColor":g[4]||(g[4]=u=>a.value=u),"color-scheme":y.value,"color-map-map":_.value,onRegenerate:ht,onUpdateColorMap:R},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),rp=Sn(np,[["__scopeId","data-v-244cd07d"]]),ip="dashboard:globalVars";function La(e=!1){const t=h.inject(ip,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const sp={class:"data-explorer-wrap"},ap={class:"data-explorer-info"},op=h.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t.s3Url));return h.watchEffect(()=>{}),(i,s)=>{const a=h.resolveComponent("el-icon");return h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",sp,[h.createElementVNode("div",ap,[h.createVNode(h.unref(Pc.ElTooltip),{placement:"top-start"},{content:h.withCtx(()=>[...s[0]||(s[0]=[h.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:h.withCtx(()=>[h.createVNode(a,{color:"#8300BF"},{default:h.withCtx(()=>[h.createVNode(h.unref(jc))]),_:1})]),_:1})]),h.createVNode(h.unref(yu),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),xa=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},lp=xa(op,[["__scopeId","data-v-08f7f19e"]]),cp={class:"umap-wrap"},up=xa(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t==null?void 0:t.s3Url));return(i,s)=>(h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",cp,[h.createVNode(h.unref(rp),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function Y(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(d){try{c(r.next(d))}catch(y){a(y)}}function l(d){try{c(r.throw(d))}catch(y){a(y)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((r=r.apply(e,t||[])).next())})}function Ua(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function re(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(e,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(E){return Promise.resolve(E).then(v,y)}}function o(v,E){r[v]&&(i[v]=function(T){return new Promise(function(N,B){s.push([v,T,N,B])>1||l(v,T)})},E&&(i[v]=E(i[v])))}function l(v,E){try{c(r[v](E))}catch(T){_(s[0][3],T)}}function c(v){v.value instanceof W?Promise.resolve(v.value.v).then(d,y):_(s[0][2],v)}function d(v){l("next",v)}function y(v){l("throw",v)}function _(v,E){v(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Sr(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:W(e[i](a)),done:!1}:s?s(a):a}:s}}function je(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ua=="function"?Ua(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(c){s({value:c,done:o})},a)}}const hp=new TextDecoder("utf-8"),Pi=e=>hp.decode(e),dp=new TextEncoder,Vi=e=>dp.encode(e),fp=e=>typeof e=="number",Ca=e=>typeof e=="boolean",_t=e=>typeof e=="function",Dt=e=>e!=null&&Object(e)===e,Ye=e=>Dt(e)&&_t(e.then),Ln=e=>Dt(e)&&_t(e[Symbol.iterator]),Ze=e=>Dt(e)&&_t(e[Symbol.asyncIterator]),zi=e=>Dt(e)&&Dt(e.schema),ka=e=>Dt(e)&&"done"in e&&"value"in e,$a=e=>Dt(e)&&_t(e.stat)&&fp(e.fd),Pa=e=>Dt(e)&&ji(e.body),Er=e=>"_getDOMStream"in e&&"_getNodeStream"in e,pp=e=>Dt(e)&&_t(e.abort)&&_t(e.getWriter)&&!Er(e),ji=e=>Dt(e)&&_t(e.cancel)&&_t(e.getReader)&&!Er(e),yp=e=>Dt(e)&&_t(e.end)&&_t(e.write)&&Ca(e.writable)&&!Er(e),Va=e=>Dt(e)&&_t(e.read)&&_t(e.pipe)&&Ca(e.readable)&&!Er(e),mp=e=>Dt(e)&&_t(e.clear)&&_t(e.bytes)&&_t(e.position)&&_t(e.setPosition)&&_t(e.capacity)&&_t(e.getBufferIdentifier)&&_t(e.createLong),Yi=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function bp(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,c=0,d=e.length;++l<d;){if(a=t[c],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++c]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++c]=o);continue}t[c]=new Uint8Array(a.buffer,n,r-n+s)}return t}function za(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function ie(e,t){const n=bp(e),r=n.reduce((d,y)=>d+y.byteLength,0);let i,s,a,o=0,l=-1;const c=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=n.length;++l<d;){if(i=n[l],s=i.subarray(0,Math.min(i.length,c-o)),c<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?za(a,s,o):a=s;break}za(a||(a=new Uint8Array(c)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function at(e,t){let n=ka(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=Vi(n)),n instanceof ArrayBuffer?new e(n):n instanceof Yi?new e(n):mp(n)?at(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const xn=e=>at(Int32Array,e),ja=e=>at(BigInt64Array,e),H=e=>at(Uint8Array,e),Wi=e=>(e.next(),e);function*gp(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Yi?n(t):Ln(t)?t:n(t);return yield*Wi(function*(i){let s=null;do s=i.next(yield at(e,s));while(!s.done)}(r[Symbol.iterator]())),new e}const _p=e=>gp(Uint8Array,e);function Ya(e,t){return re(this,arguments,function*(){if(Ye(t))return yield W(yield W(yield*Sr(je(Ya(e,yield W(t))))));const n=function(s){return re(this,arguments,function*(){yield yield W(yield W(s))})},r=function(s){return re(this,arguments,function*(){yield W(yield*Sr(je(Wi(function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)}(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Yi?n(t):Ln(t)?r(t):Ze(t)?t:n(t);return yield W(yield*Sr(je(Wi(function(s){return re(this,arguments,function*(){let a=null;do a=yield W(s.next(yield yield W(at(e,a))));while(!a.done)})}(i[Symbol.asyncIterator]()))))),yield W(new e)})}const vp=e=>Ya(Uint8Array,e);function Wa(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function wp(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const Pt={fromIterable(e){return Tr(Ip(e))},fromAsyncIterable(e){return Tr(Sp(e))},fromDOMStream(e){return Tr(Ep(e))},fromNodeStream(e){return Tr(Ap(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},Tr=e=>(e.next(),e);function*Ip(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const c=_p(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?c.next():c.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&c.throw(d)}finally{n===!1&&typeof c.return=="function"&&c.return(null)}return null}function Sp(e){return re(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=vp(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.next()):yield W(c.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&(yield W(c.throw(d)))}finally{n===!1&&typeof c.return=="function"&&(yield W(c.return(new Uint8Array(0))))}return yield W(null)})}function Ep(e){return re(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ie(r,a)[0]:([i,r,o]=ie(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=new Tp(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.read()):yield W(c.read(a-o)),!t&&i.byteLength>0&&(r.push(H(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&(yield W(c.cancel(d)))}finally{n===!1?yield W(c.cancel()):e.locked&&c.releaseLock()}return yield W(null)})}class Tp{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Y(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Y(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=H(n)),n})}}const qi=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Ap(e){return re(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],c;function d(){return s==="peek"?ie(l,a)[0]:([c,l,o]=ie(l,a),c)}if({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0},e.isTTY)return yield yield W(new Uint8Array(0)),yield W(null);try{t[0]=qi(e,"end"),t[1]=qi(e,"error");do{if(t[2]=qi(e,"readable"),[n,i]=yield W(Promise.race(t.map(_=>_[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(c=H(e.read(a-o)),c.byteLength<a-o&&(c=H(e.read()))):c=H(e.read()),c.byteLength>0&&(l.push(c),o+=c.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield W(d()));while(a<o)}while(!r)}finally{yield W(y(t,n==="error"?i:null))}return yield W(null);function y(_,v){return c=l=null,new Promise((E,T)=>{for(const[N,B]of _)e.off(N,B);try{const N=e.destroy;N&&N.call(e,v),v=void 0}catch(N){v=N||v}finally{v!=null?T(v):E()}})}})}var yt;(function(e){e[e.V1=0]="V1",e[e.V2=1]="V2",e[e.V3=2]="V3",e[e.V4=3]="V4",e[e.V5=4]="V5"})(yt||(yt={}));var Et;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Et||(Et={}));var Tt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Tt||(Tt={}));var Vt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(Vt||(Vt={}));var k;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var se;(function(e){e[e.YEAR_MONTH=0]="YEAR_MONTH",e[e.DAY_TIME=1]="DAY_TIME",e[e.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(se||(se={}));const Gi=2,ae=4,ge=4,Z=4,Be=new Int32Array(2),qa=new Float32Array(Be.buffer),Ga=new Float64Array(Be.buffer),Ar=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Hi;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Hi||(Hi={}));let tn=class kc{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new kc(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return Be[0]=this.readInt32(t),qa[0]}readFloat64(t){return Be[Ar?0:1]=this.readInt32(t),Be[Ar?1:0]=this.readInt32(t+4),Ga[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){qa[0]=n,this.writeInt32(t,Be[0])}writeFloat64(t,n){Ga[0]=n,this.writeInt32(t,Be[Ar?0:1]),this.writeInt32(t+4,Be[Ar?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+ae+ge)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let n=0;n<ge;n++)t+=String.fromCharCode(this.readInt8(this.position_+ae+n));return t}__offset(t,n){const r=t-this.readInt32(t);return n<this.readInt16(r)?this.readInt16(r+n):0}__union(t,n){return t.bb_pos=n+this.readInt32(n),t.bb=this,t}__string(t,n){t+=this.readInt32(t);const r=this.readInt32(t);t+=ae;const i=this.bytes_.subarray(t,t+r);return n===Hi.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,n){return typeof t=="string"?this.__string(n):this.__union(t,n)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+ae}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=ge)throw new Error("FlatBuffers: file identifier must be length "+ge);for(let n=0;n<ge;n++)if(t.charCodeAt(n)!=this.readInt8(this.position()+ae+n))return!1;return!0}createScalarList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s)}return r}createObjList(t,n){const r=[];for(let i=0;i<n;++i){const s=t(i);s!==null&&r.push(s.unpack())}return r}},Ha=class $c{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let n;t?n=t:n=1024,this.bb=tn.allocate(n),this.space=n}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);const r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){const i=this.bb.capacity();this.bb=$c.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(r)}pad(t){for(let n=0;n<t;n++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,n,r){(this.force_defaults||n!=r)&&(this.addInt8(n),this.slot(t))}addFieldInt16(t,n,r){(this.force_defaults||n!=r)&&(this.addInt16(n),this.slot(t))}addFieldInt32(t,n,r){(this.force_defaults||n!=r)&&(this.addInt32(n),this.slot(t))}addFieldInt64(t,n,r){(this.force_defaults||n!==r)&&(this.addInt64(n),this.slot(t))}addFieldFloat32(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat32(n),this.slot(t))}addFieldFloat64(t,n,r){(this.force_defaults||n!=r)&&(this.addFloat64(n),this.slot(t))}addFieldOffset(t,n,r){(this.force_defaults||n!=r)&&(this.addOffset(n),this.slot(t))}addFieldStruct(t,n,r){n!=r&&(this.nested(n),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const n=t.capacity();if(n&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=n<<1,i=tn.allocate(r);return i.setPosition(r-n),i.bytes().set(t.bytes(),r-n),i}addOffset(t){this.prep(ae,0),this.writeInt32(this.offset()-t+ae)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let n=0;n<t;n++)this.vtable[n]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let n=this.vtable_in_use-1;for(;n>=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?t-this.vtable[n]:0);const i=2;this.addInt16(t-this.object_start);const s=(r+i)*Gi;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let c=Gi;c<s;c+=Gi)if(this.bb.readInt16(o+c)!=this.bb.readInt16(l+c))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?Z:0;if(n){const s=n;if(this.prep(this.minalign,ae+ge+i),s.length!=ge)throw new TypeError("FlatBuffers: file identifier must be length "+ge);for(let a=ge-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,ae+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,n){this.finish(t,n,!0)}requiredField(t,n){const r=this.bb.capacity()-t,i=r-this.bb.readInt32(r);if(!(n<this.bb.readInt16(i)&&this.bb.readInt16(i+n)!=0))throw new TypeError("FlatBuffers: field "+n+" must be set")}startVector(t,n,r){this.notNested(),this.vector_num_elems=n,this.prep(ae,t*n),this.prep(r,t*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const n=this.createString(t);return this.string_maps.set(t,n),n}createString(t){if(t==null)return 0;let n;return t instanceof Uint8Array?n=t:n=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length),this.bb.bytes().set(n,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){const n=[];for(let r=0;r<t.length;++r){const i=t[r];if(i!==null)n.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return n}createStructOffsetList(t,n){return n(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Nr;(function(e){e[e.BUFFER=0]="BUFFER"})(Nr||(Nr={}));var Br;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Br||(Br={}));class Re{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBodyCompression(t,n){return(n||new Re).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+Z),(n||new Re).__init(t.readInt32(t.position())+t.position(),t)}codec(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Br.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Nr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Br.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,Nr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Re.startBodyCompression(t),Re.addCodec(t,n),Re.addMethod(t,r),Re.endBodyCompression(t)}}class Ka{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Qa=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},_e=class Vs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+Z),(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Qa).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ka).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Re).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addNodes(t,n){t.addFieldOffset(1,n,0)}static startNodesVector(t,n){t.startVector(16,n,8)}static addBuffers(t,n){t.addFieldOffset(2,n,0)}static startBuffersVector(t,n){t.startVector(16,n,8)}static addCompression(t,n){t.addFieldOffset(3,n,0)}static endRecordBatch(t){return t.endObject()}},en=class zs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+Z),(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new _e).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addData(t,n){t.addFieldOffset(1,n,0)}static addIsDelta(t,n){t.addFieldInt8(2,+n,0)}static endDictionaryBatch(t){return t.endObject()}};var nn;(function(e){e[e.Little=0]="Little",e[e.Big=1]="Big"})(nn||(nn={}));var Rr;(function(e){e[e.DenseArray=0]="DenseArray"})(Rr||(Rr={}));class Ut{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInt(t,n){return(n||new Ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+Z),(n||new Ut).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,n){t.addFieldInt32(0,n,0)}static addIsSigned(t,n){t.addFieldInt8(1,+n,0)}static endInt(t){return t.endObject()}static createInt(t,n,r){return Ut.startInt(t),Ut.addBitWidth(t,n),Ut.addIsSigned(t,r),Ut.endInt(t)}}class ve{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryEncoding(t,n){return(n||new ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+Z),(n||new ve).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ut).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isOrdered(){const t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):Rr.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,n){t.addFieldInt64(0,n,BigInt("0"))}static addIndexType(t,n){t.addFieldOffset(1,n,0)}static addIsOrdered(t,n){t.addFieldInt8(2,+n,0)}static addDictionaryKind(t,n){t.addFieldInt16(3,n,Rr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class vt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsKeyValue(t,n){return(n||new vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+Z),(n||new vt).__init(t.readInt32(t.position())+t.position(),t)}key(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}value(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,n){t.addFieldOffset(0,n,0)}static addValue(t,n){t.addFieldOffset(1,n,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,n,r){return vt.startKeyValue(t),vt.addKey(t,n),vt.addValue(t,r),vt.endKeyValue(t)}}let Xa=class Xn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBinary(t,n){return(n||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+Z),(n||new Xn).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Xn.startBinary(t),Xn.endBinary(t)}},Ja=class Jn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsBool(t,n){return(n||new Jn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+Z),(n||new Jn).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Jn.startBool(t),Jn.endBool(t)}},Or=class gn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDate(t,n){return(n||new gn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+Z),(n||new gn).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Vt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,Vt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return gn.startDate(t),gn.addUnit(t,n),gn.endDate(t)}},rn=class Ue{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDecimal(t,n){return(n||new Ue).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+Z),(n||new Ue).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,n){t.addFieldInt32(0,n,0)}static addScale(t,n){t.addFieldInt32(1,n,0)}static addBitWidth(t,n){t.addFieldInt32(2,n,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,n,r,i){return Ue.startDecimal(t),Ue.addPrecision(t,n),Ue.addScale(t,r),Ue.addBitWidth(t,i),Ue.endDecimal(t)}},Dr=class _n{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDuration(t,n){return(n||new _n).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+Z),(n||new _n).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,k.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return _n.startDuration(t),_n.addUnit(t,n),_n.endDuration(t)}},Fr=class vn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeBinary(t,n){return(n||new vn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+Z),(n||new vn).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,n){return vn.startFixedSizeBinary(t),vn.addByteWidth(t,n),vn.endFixedSizeBinary(t)}},Mr=class wn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFixedSizeList(t,n){return(n||new wn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+Z),(n||new wn).__init(t.readInt32(t.position())+t.position(),t)}listSize(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,n){t.addFieldInt32(0,n,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,n){return wn.startFixedSizeList(t),wn.addListSize(t,n),wn.endFixedSizeList(t)}};class oe{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFloatingPoint(t,n){return(n||new oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+Z),(n||new oe).__init(t.readInt32(t.position())+t.position(),t)}precision(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Tt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Tt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return oe.startFloatingPoint(t),oe.addPrecision(t,n),oe.endFloatingPoint(t)}}class le{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsInterval(t,n){return(n||new le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+Z),(n||new le).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):se.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,se.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return le.startInterval(t),le.addUnit(t,n),le.endInterval(t)}}let Za=class Zn{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeBinary(t,n){return(n||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+Z),(n||new Zn).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Zn.startLargeBinary(t),Zn.endLargeBinary(t)}},to=class tr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsLargeUtf8(t,n){return(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+Z),(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return tr.startLargeUtf8(t),tr.endLargeUtf8(t)}},eo=class er{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsList(t,n){return(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+Z),(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return er.startList(t),er.endList(t)}},Lr=class In{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMap(t,n){return(n||new In).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+Z),(n||new In).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){const t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,n){t.addFieldInt8(0,+n,0)}static endMap(t){return t.endObject()}static createMap(t,n){return In.startMap(t),In.addKeysSorted(t,n),In.endMap(t)}},no=class nr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsNull(t,n){return(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+Z),(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return nr.startNull(t),nr.endNull(t)}};class We{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsStruct_(t,n){return(n||new We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+Z),(n||new We).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return We.startStruct_(t),We.endStruct_(t)}}class zt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTime(t,n){return(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+Z),(n||new zt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.MILLISECOND}bitWidth(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,k.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return zt.startTime(t),zt.addUnit(t,n),zt.addBitWidth(t,r),zt.endTime(t)}}class jt{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsTimestamp(t,n){return(n||new jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+Z),(n||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):k.SECOND}timezone(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.__string(this.bb_pos+n,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,n){t.addFieldInt16(0,n,k.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return jt.startTimestamp(t),jt.addUnit(t,n),jt.addTimezone(t,r),jt.endTimestamp(t)}}class Ft{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+Z),(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Et.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Et.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return Ft.startUnion(t),Ft.addMode(t,n),Ft.addTypeIds(t,r),Ft.endUnion(t)}}let ro=class rr{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUtf8(t,n){return(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+Z),(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return rr.startUtf8(t),rr.endUtf8(t)}};var lt;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.FloatingPoint=3]="FloatingPoint",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct_=13]="Struct_",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.LargeList=21]="LargeList",e[e.RunEndEncoded=22]="RunEndEncoded"})(lt||(lt={}));let Yt=class _i{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsField(t,n){return(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+Z),(n||new _i).__init(t.readInt32(t.position())+t.position(),t)}name(t){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,t):null}nullable(){const t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):lt.NONE}type(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(t,this.bb_pos+n):null}dictionary(t){const n=this.bb.__offset(this.bb_pos,12);return n?(t||new ve).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(t,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new _i).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,n){t.addFieldOffset(0,n,0)}static addNullable(t,n){t.addFieldInt8(1,+n,0)}static addTypeType(t,n){t.addFieldInt8(2,n,lt.NONE)}static addType(t,n){t.addFieldOffset(3,n,0)}static addDictionary(t,n){t.addFieldOffset(4,n,0)}static addChildren(t,n){t.addFieldOffset(5,n,0)}static createChildrenVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startChildrenVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(6,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endField(t){return t.endObject()}},ce=class Ae{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsSchema(t,n){return(n||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+Z),(n||new Ae).__init(t.readInt32(t.position())+t.position(),t)}endianness(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):nn.Little}fields(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Yt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}fieldsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+t*8):BigInt(0)}featuresLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,n){t.addFieldInt16(0,n,nn.Little)}static addFields(t,n){t.addFieldOffset(1,n,0)}static createFieldsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startFieldsVector(t,n){t.startVector(4,n,4)}static addCustomMetadata(t,n){t.addFieldOffset(2,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static addFeatures(t,n){t.addFieldOffset(3,n,0)}static createFeaturesVector(t,n){t.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)t.addInt64(n[r]);return t.endVector()}static startFeaturesVector(t,n){t.startVector(8,n,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,n){t.finish(n)}static finishSizePrefixedSchemaBuffer(t,n){t.finish(n,void 0,!0)}static createSchema(t,n,r,i,s){return Ae.startSchema(t),Ae.addEndianness(t,n),Ae.addFields(t,r),Ae.addCustomMetadata(t,i),Ae.addFeatures(t,s),Ae.endSchema(t)}};var X;(function(e){e[e.NONE=0]="NONE",e[e.Schema=1]="Schema",e[e.DictionaryBatch=2]="DictionaryBatch",e[e.RecordBatch=3]="RecordBatch",e[e.Tensor=4]="Tensor",e[e.SparseTensor=5]="SparseTensor"})(X||(X={}));var f;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(f||(f={}));var we;(function(e){e[e.OFFSET=0]="OFFSET",e[e.DATA=1]="DATA",e[e.VALIDITY=2]="VALIDITY",e[e.TYPE=3]="TYPE"})(we||(we={}));const Np=void 0;function Un(e){if(e===null)return"null";if(e===Np)return"undefined";switch(typeof e){case"number":return`${e}`;case"bigint":return`${e}`;case"string":return`"${e}"`}return typeof e[Symbol.toPrimitive]=="function"?e[Symbol.toPrimitive]("string"):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(t=>Un(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function ot(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function io(e,t){return ot(e/t)+ot(e%t)/ot(t)}const Bp=Symbol.for("isArrowBigNum");function Qt(e,...t){return t.length===0?Object.setPrototypeOf(at(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Qt.prototype[Bp]=!0,Qt.prototype.toJSON=function(){return`"${kn(this)}"`},Qt.prototype.valueOf=function(e){return so(this,e)},Qt.prototype.toString=function(){return kn(this)},Qt.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return so(this);case"string":return kn(this);case"default":return Dp(this)}return kn(this)};function sn(...e){return Qt.apply(this,e)}function an(...e){return Qt.apply(this,e)}function Cn(...e){return Qt.apply(this,e)}Object.setPrototypeOf(sn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(an.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Cn.prototype,Object.create(Uint32Array.prototype)),Object.assign(sn.prototype,Qt.prototype,{constructor:sn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(an.prototype,Qt.prototype,{constructor:an,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Cn.prototype,Qt.prototype,{constructor:Cn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Rp=BigInt(4294967296)*BigInt(4294967296),Op=Rp-BigInt(1);function so(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),c=0;if(o){for(const d of a)l|=(d^Op)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*c++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),y=l/d,_=l%d;return ot(y)+ot(_)/ot(d)}return ot(l)}function kn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Ki(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ki(e);t=t.slice();let n=1;for(let r=0;r<t.length;r++){const i=t[r],s=~i+n;t[r]=s,n&=i===0?1:0}return`-${Ki(t)}`}function Dp(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:kn(e)}function Ki(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class Qi{static new(t,n){switch(n){case!0:return new sn(t);case!1:return new an(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new sn(t)}return t.byteLength===16?new Cn(t):new an(t)}static signed(t){return new sn(t)}static unsigned(t){return new an(t)}static decimal(t){return new Cn(t)}constructor(t,n){return Qi.new(t,n)}}var ao,oo,lo,co,uo,ho,fo,po,yo,mo,bo,go,_o,vo,wo,Io,So,Eo,To,Ao,No,Bo;class D{static isNull(t){return(t==null?void 0:t.typeId)===f.Null}static isInt(t){return(t==null?void 0:t.typeId)===f.Int}static isFloat(t){return(t==null?void 0:t.typeId)===f.Float}static isBinary(t){return(t==null?void 0:t.typeId)===f.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===f.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===f.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===f.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===f.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===f.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===f.Date}static isTime(t){return(t==null?void 0:t.typeId)===f.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===f.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===f.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===f.Duration}static isList(t){return(t==null?void 0:t.typeId)===f.List}static isStruct(t){return(t==null?void 0:t.typeId)===f.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===f.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===f.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===f.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===f.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===f.Dictionary}static isDenseUnion(t){return D.isUnion(t)&&t.mode===Et.Dense}static isSparseUnion(t){return D.isUnion(t)&&t.mode===Et.Sparse}constructor(t){this.typeId=t}}ao=Symbol.toStringTag,D[ao]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(D.prototype);class Oe extends D{constructor(){super(f.Null)}toString(){return"Null"}}oo=Symbol.toStringTag,Oe[oo]=(e=>e[Symbol.toStringTag]="Null")(Oe.prototype);class qe extends D{constructor(t,n){super(f.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}lo=Symbol.toStringTag,qe[lo]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(qe.prototype);class $n extends qe{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty($n.prototype,"ArrayType",{value:Int32Array});class xr extends D{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Tt.HALF:return Uint16Array;case Tt.SINGLE:return Float32Array;case Tt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}co=Symbol.toStringTag,xr[co]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))(xr.prototype);class Ur extends D{constructor(){super(f.Binary)}toString(){return"Binary"}}uo=Symbol.toStringTag,Ur[uo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(Ur.prototype);class Cr extends D{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}}ho=Symbol.toStringTag,Cr[ho]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Cr.prototype);class kr extends D{constructor(){super(f.Utf8)}toString(){return"Utf8"}}fo=Symbol.toStringTag,kr[fo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(kr.prototype);class $r extends D{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}}po=Symbol.toStringTag,$r[po]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))($r.prototype);class Pr extends D{constructor(){super(f.Bool)}toString(){return"Bool"}}yo=Symbol.toStringTag,Pr[yo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(Pr.prototype);class Vr extends D{constructor(t,n,r=128){super(f.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}mo=Symbol.toStringTag,Vr[mo]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Vr.prototype);class zr extends D{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Vt[this.unit]}>`}get ArrayType(){return this.unit===Vt.DAY?Int32Array:BigInt64Array}}bo=Symbol.toStringTag,zr[bo]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(zr.prototype);class jr extends D{constructor(t,n){super(f.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${k[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}go=Symbol.toStringTag,jr[go]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(jr.prototype);class Yr extends D{constructor(t,n){super(f.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${k[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}_o=Symbol.toStringTag,Yr[_o]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Yr.prototype);class Wr extends D{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${se[this.unit]}>`}}vo=Symbol.toStringTag,Wr[vo]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Wr.prototype);class qr extends D{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${k[this.unit]}>`}}wo=Symbol.toStringTag,qr[wo]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(qr.prototype);class Gr extends D{constructor(t){super(f.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}Io=Symbol.toStringTag,Gr[Io]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Gr.prototype);class At extends D{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}So=Symbol.toStringTag,At[So]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(At.prototype);class Hr extends D{constructor(t,n,r){super(f.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}Eo=Symbol.toStringTag,Hr[Eo]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Hr.prototype);class Kr extends D{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}To=Symbol.toStringTag,Kr[To]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Kr.prototype);class Qr extends D{constructor(t,n){super(f.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Ao=Symbol.toStringTag,Qr[Ao]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Qr.prototype);class Xr extends D{constructor(t,n=!1){var r,i,s;if(super(f.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}No=Symbol.toStringTag,Xr[No]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(Xr.prototype);const Fp=(e=>()=>++e)(-1);class on extends D{constructor(t,n,r,i){super(f.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?Fp():ot(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}Bo=Symbol.toStringTag,on[Bo]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]="Dictionary"))(on.prototype);function Ie(e){const t=e;switch(e.typeId){case f.Decimal:return e.bitWidth/32;case f.Interval:return 1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}class q{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return Mp(this,t,n)}getVisitFnByTypeId(t,n=!0){return ln(this,t,n)}visitNull(t,...n){return null}visitBool(t,...n){return null}visitInt(t,...n){return null}visitFloat(t,...n){return null}visitUtf8(t,...n){return null}visitLargeUtf8(t,...n){return null}visitBinary(t,...n){return null}visitLargeBinary(t,...n){return null}visitFixedSizeBinary(t,...n){return null}visitDate(t,...n){return null}visitTimestamp(t,...n){return null}visitTime(t,...n){return null}visitDecimal(t,...n){return null}visitList(t,...n){return null}visitStruct(t,...n){return null}visitUnion(t,...n){return null}visitDictionary(t,...n){return null}visitInterval(t,...n){return null}visitDuration(t,...n){return null}visitFixedSizeList(t,...n){return null}visitMap(t,...n){return null}}function Mp(e,t,n=!0){return typeof t=="number"?ln(e,t,n):typeof t=="string"&&t in f?ln(e,f[t],n):t&&t instanceof D?ln(e,Ro(t),n):t!=null&&t.type&&t.type instanceof D?ln(e,Ro(t.type),n):ln(e,f.NONE,n)}function ln(e,t,n=!0){let r=null;switch(t){case f.Null:r=e.visitNull;break;case f.Bool:r=e.visitBool;break;case f.Int:r=e.visitInt;break;case f.Int8:r=e.visitInt8||e.visitInt;break;case f.Int16:r=e.visitInt16||e.visitInt;break;case f.Int32:r=e.visitInt32||e.visitInt;break;case f.Int64:r=e.visitInt64||e.visitInt;break;case f.Uint8:r=e.visitUint8||e.visitInt;break;case f.Uint16:r=e.visitUint16||e.visitInt;break;case f.Uint32:r=e.visitUint32||e.visitInt;break;case f.Uint64:r=e.visitUint64||e.visitInt;break;case f.Float:r=e.visitFloat;break;case f.Float16:r=e.visitFloat16||e.visitFloat;break;case f.Float32:r=e.visitFloat32||e.visitFloat;break;case f.Float64:r=e.visitFloat64||e.visitFloat;break;case f.Utf8:r=e.visitUtf8;break;case f.LargeUtf8:r=e.visitLargeUtf8;break;case f.Binary:r=e.visitBinary;break;case f.LargeBinary:r=e.visitLargeBinary;break;case f.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case f.Date:r=e.visitDate;break;case f.DateDay:r=e.visitDateDay||e.visitDate;break;case f.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case f.Timestamp:r=e.visitTimestamp;break;case f.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case f.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case f.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case f.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case f.Time:r=e.visitTime;break;case f.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case f.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case f.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case f.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case f.Decimal:r=e.visitDecimal;break;case f.List:r=e.visitList;break;case f.Struct:r=e.visitStruct;break;case f.Union:r=e.visitUnion;break;case f.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case f.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case f.Dictionary:r=e.visitDictionary;break;case f.Interval:r=e.visitInterval;break;case f.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case f.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case f.Duration:r=e.visitDuration;break;case f.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case f.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case f.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case f.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case f.FixedSizeList:r=e.visitFixedSizeList;break;case f.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function Ro(e){switch(e.typeId){case f.Null:return f.Null;case f.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?f.Int8:f.Uint8;case 16:return n?f.Int16:f.Uint16;case 32:return n?f.Int32:f.Uint32;case 64:return n?f.Int64:f.Uint64}return f.Int}case f.Float:switch(e.precision){case Tt.HALF:return f.Float16;case Tt.SINGLE:return f.Float32;case Tt.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(e.unit){case k.SECOND:return f.TimeSecond;case k.MILLISECOND:return f.TimeMillisecond;case k.MICROSECOND:return f.TimeMicrosecond;case k.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(e.unit){case k.SECOND:return f.TimestampSecond;case k.MILLISECOND:return f.TimestampMillisecond;case k.MICROSECOND:return f.TimestampMicrosecond;case k.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(e.unit){case Vt.DAY:return f.DateDay;case Vt.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(e.unit){case se.DAY_TIME:return f.IntervalDayTime;case se.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(e.unit){case k.SECOND:return f.DurationSecond;case k.MILLISECOND:return f.DurationMillisecond;case k.MICROSECOND:return f.DurationMicrosecond;case k.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(e.mode){case Et.Dense:return f.DenseUnion;case Et.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[e.typeId]}'`)}q.prototype.visitInt8=null,q.prototype.visitInt16=null,q.prototype.visitInt32=null,q.prototype.visitInt64=null,q.prototype.visitUint8=null,q.prototype.visitUint16=null,q.prototype.visitUint32=null,q.prototype.visitUint64=null,q.prototype.visitFloat16=null,q.prototype.visitFloat32=null,q.prototype.visitFloat64=null,q.prototype.visitDateDay=null,q.prototype.visitDateMillisecond=null,q.prototype.visitTimestampSecond=null,q.prototype.visitTimestampMillisecond=null,q.prototype.visitTimestampMicrosecond=null,q.prototype.visitTimestampNanosecond=null,q.prototype.visitTimeSecond=null,q.prototype.visitTimeMillisecond=null,q.prototype.visitTimeMicrosecond=null,q.prototype.visitTimeNanosecond=null,q.prototype.visitDenseUnion=null,q.prototype.visitSparseUnion=null,q.prototype.visitIntervalDayTime=null,q.prototype.visitIntervalYearMonth=null,q.prototype.visitDuration=null,q.prototype.visitDurationSecond=null,q.prototype.visitDurationMillisecond=null,q.prototype.visitDurationMicrosecond=null,q.prototype.visitDurationNanosecond=null;const Oo=new Float64Array(1),cn=new Uint32Array(Oo.buffer);function Do(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function Lp(e){if(e!==e)return 32256;Oo[0]=e;const t=(cn[1]&2147483648)>>16&65535;let n=cn[1]&2146435072,r=0;return n>=1089470464?cn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(cn[1]&1048575)>>10):n<=1056964608?(r=1048576+(cn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(cn[1]&1048575)+512>>10),t|n|r&65535}class $ extends q{}function z(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const xp=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Fo=(e,t,n,r)=>{if(n+1<t.length){const i=ot(t[n]),s=ot(t[n+1]);e.set(r.subarray(0,s-i),i)}},Up=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Se=({values:e},t,n)=>{e[t]=n},Xi=({values:e},t,n)=>{e[t]=n},Mo=({values:e},t,n)=>{e[t]=Lp(n)},Cp=(e,t,n)=>{switch(e.type.precision){case Tt.HALF:return Mo(e,t,n);case Tt.SINGLE:case Tt.DOUBLE:return Xi(e,t,n)}},Lo=({values:e},t,n)=>{xp(e,t,n.valueOf())},xo=({values:e},t,n)=>{e[t]=BigInt(n)},kp=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Uo=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,r),Co=({values:e,valueOffsets:t},n,r)=>Fo(e,t,n,Vi(r)),$p=(e,t,n)=>{e.type.unit===Vt.DAY?Lo(e,t,n):xo(e,t,n)},ko=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},$o=({values:e},t,n)=>{e[t]=BigInt(n)},Po=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Vo=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Pp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return ko(e,t,n);case k.MILLISECOND:return $o(e,t,n);case k.MICROSECOND:return Po(e,t,n);case k.NANOSECOND:return Vo(e,t,n)}},zo=({values:e},t,n)=>{e[t]=n},jo=({values:e},t,n)=>{e[t]=n},Yo=({values:e},t,n)=>{e[t]=n},Wo=({values:e},t,n)=>{e[t]=n},Vp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return zo(e,t,n);case k.MILLISECOND:return jo(e,t,n);case k.MICROSECOND:return Yo(e,t,n);case k.NANOSECOND:return Wo(e,t,n)}},zp=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},jp=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=Wt.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},Yp=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=Wt.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const c of l)if(s(r,a,c),++a>=o)break},Wp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),qp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),Gp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),Hp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),Kp=(e,t,n)=>{const r=e.type.children.map(s=>Wt.getVisitFn(s.type)),i=n instanceof Map?Gp(t,n):n instanceof tt?qp(t,n):Array.isArray(n)?Wp(t,n):Hp(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},Qp=(e,t,n)=>{e.type.mode===Et.Dense?qo(e,t,n):Go(e,t,n)},qo=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,e.valueOffsets[t],n)},Go=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];Wt.visit(i,t,n)},Xp=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Jp=(e,t,n)=>{e.type.unit===se.DAY_TIME?Ho(e,t,n):Ko(e,t,n)},Ho=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ko=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Qo=({values:e},t,n)=>{e[t]=n},Xo=({values:e},t,n)=>{e[t]=n},Jo=({values:e},t,n)=>{e[t]=n},Zo=({values:e},t,n)=>{e[t]=n},Zp=(e,t,n)=>{switch(e.type.unit){case k.SECOND:return Qo(e,t,n);case k.MILLISECOND:return Xo(e,t,n);case k.MICROSECOND:return Jo(e,t,n);case k.NANOSECOND:return Zo(e,t,n)}},ty=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=Wt.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};$.prototype.visitBool=z(Up),$.prototype.visitInt=z(Se),$.prototype.visitInt8=z(Se),$.prototype.visitInt16=z(Se),$.prototype.visitInt32=z(Se),$.prototype.visitInt64=z(Se),$.prototype.visitUint8=z(Se),$.prototype.visitUint16=z(Se),$.prototype.visitUint32=z(Se),$.prototype.visitUint64=z(Se),$.prototype.visitFloat=z(Cp),$.prototype.visitFloat16=z(Mo),$.prototype.visitFloat32=z(Xi),$.prototype.visitFloat64=z(Xi),$.prototype.visitUtf8=z(Co),$.prototype.visitLargeUtf8=z(Co),$.prototype.visitBinary=z(Uo),$.prototype.visitLargeBinary=z(Uo),$.prototype.visitFixedSizeBinary=z(kp),$.prototype.visitDate=z($p),$.prototype.visitDateDay=z(Lo),$.prototype.visitDateMillisecond=z(xo),$.prototype.visitTimestamp=z(Pp),$.prototype.visitTimestampSecond=z(ko),$.prototype.visitTimestampMillisecond=z($o),$.prototype.visitTimestampMicrosecond=z(Po),$.prototype.visitTimestampNanosecond=z(Vo),$.prototype.visitTime=z(Vp),$.prototype.visitTimeSecond=z(zo),$.prototype.visitTimeMillisecond=z(jo),$.prototype.visitTimeMicrosecond=z(Yo),$.prototype.visitTimeNanosecond=z(Wo),$.prototype.visitDecimal=z(zp),$.prototype.visitList=z(jp),$.prototype.visitStruct=z(Kp),$.prototype.visitUnion=z(Qp),$.prototype.visitDenseUnion=z(qo),$.prototype.visitSparseUnion=z(Go),$.prototype.visitDictionary=z(Xp),$.prototype.visitInterval=z(Jp),$.prototype.visitIntervalDayTime=z(Ho),$.prototype.visitIntervalYearMonth=z(Ko),$.prototype.visitDuration=z(Zp),$.prototype.visitDurationSecond=z(Qo),$.prototype.visitDurationMillisecond=z(Xo),$.prototype.visitDurationMicrosecond=z(Jo),$.prototype.visitDurationNanosecond=z(Zo),$.prototype.visitFixedSizeList=z(ty),$.prototype.visitMap=z(Yp);const Wt=new $,Xt=Symbol.for("parent"),un=Symbol.for("rowIndex");class Ji{constructor(t,n){return this[Xt]=t,this[un]=n,new Proxy(this,new ny)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[un],n=this[Xt],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=Mt.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ey(this[Xt],this[un])}}class ey{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(Ji.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Xt]:{writable:!0,enumerable:!1,configurable:!1,value:null},[un]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class ny{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Xt].type.children.map(n=>n.name)}has(t,n){return t[Xt].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[Xt].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[Xt].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Mt.visit(t[Xt].children[r],t[un]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[Xt].type.children.findIndex(s=>s.name===n);return i!==-1?(Wt.visit(t[Xt].children[i],t[un],r),Reflect.set(t,n,r)):Reflect.has(t,n)||typeof n=="symbol"?Reflect.set(t,n,r):!1}}class L extends q{}function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const ry=(e,t)=>864e5*e[t],iy=(e,t)=>null,tl=(e,t,n)=>{if(n+1>=t.length)return null;const r=ot(t[n]),i=ot(t[n+1]);return e.subarray(r,i)},sy=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},el=({values:e},t)=>ry(e,t),nl=({values:e},t)=>ot(e[t]),De=({stride:e,values:t},n)=>t[e*n],ay=({stride:e,values:t},n)=>Do(t[e*n]),rl=({values:e},t)=>e[t],oy=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),il=({values:e,valueOffsets:t},n)=>tl(e,t,n),sl=({values:e,valueOffsets:t},n)=>{const r=tl(e,t,n);return r!==null?Pi(r):null},ly=({values:e},t)=>e[t],cy=({type:e,values:t},n)=>e.precision!==Tt.HALF?t[n]:Do(t[n]),uy=(e,t)=>e.type.unit===Vt.DAY?el(e,t):nl(e,t),al=({values:e},t)=>1e3*ot(e[t]),ol=({values:e},t)=>ot(e[t]),ll=({values:e},t)=>io(e[t],BigInt(1e3)),cl=({values:e},t)=>io(e[t],BigInt(1e6)),hy=(e,t)=>{switch(e.type.unit){case k.SECOND:return al(e,t);case k.MILLISECOND:return ol(e,t);case k.MICROSECOND:return ll(e,t);case k.NANOSECOND:return cl(e,t)}},ul=({values:e},t)=>e[t],hl=({values:e},t)=>e[t],dl=({values:e},t)=>e[t],fl=({values:e},t)=>e[t],dy=(e,t)=>{switch(e.type.unit){case k.SECOND:return ul(e,t);case k.MILLISECOND:return hl(e,t);case k.MICROSECOND:return dl(e,t);case k.NANOSECOND:return fl(e,t)}},fy=({values:e,stride:t},n)=>Qi.decimal(e.subarray(t*n,t*(n+1))),py=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,o=i[0].slice(s,a-s);return new tt([o])},yy=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new ts(a.slice(i,s-i))},my=(e,t)=>new Ji(e,t),by=(e,t)=>e.type.mode===Et.Dense?pl(e,t):yl(e,t),pl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,e.valueOffsets[t])},yl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Mt.visit(r,t)},gy=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},_y=(e,t)=>e.type.unit===se.DAY_TIME?ml(e,t):bl(e,t),ml=({values:e},t)=>e.subarray(2*t,2*(t+1)),bl=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},gl=({values:e},t)=>e[t],_l=({values:e},t)=>e[t],vl=({values:e},t)=>e[t],wl=({values:e},t)=>e[t],vy=(e,t)=>{switch(e.type.unit){case k.SECOND:return gl(e,t);case k.MILLISECOND:return _l(e,t);case k.MICROSECOND:return vl(e,t);case k.NANOSECOND:return wl(e,t)}},wy=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new tt([i])};L.prototype.visitNull=P(iy),L.prototype.visitBool=P(sy),L.prototype.visitInt=P(ly),L.prototype.visitInt8=P(De),L.prototype.visitInt16=P(De),L.prototype.visitInt32=P(De),L.prototype.visitInt64=P(rl),L.prototype.visitUint8=P(De),L.prototype.visitUint16=P(De),L.prototype.visitUint32=P(De),L.prototype.visitUint64=P(rl),L.prototype.visitFloat=P(cy),L.prototype.visitFloat16=P(ay),L.prototype.visitFloat32=P(De),L.prototype.visitFloat64=P(De),L.prototype.visitUtf8=P(sl),L.prototype.visitLargeUtf8=P(sl),L.prototype.visitBinary=P(il),L.prototype.visitLargeBinary=P(il),L.prototype.visitFixedSizeBinary=P(oy),L.prototype.visitDate=P(uy),L.prototype.visitDateDay=P(el),L.prototype.visitDateMillisecond=P(nl),L.prototype.visitTimestamp=P(hy),L.prototype.visitTimestampSecond=P(al),L.prototype.visitTimestampMillisecond=P(ol),L.prototype.visitTimestampMicrosecond=P(ll),L.prototype.visitTimestampNanosecond=P(cl),L.prototype.visitTime=P(dy),L.prototype.visitTimeSecond=P(ul),L.prototype.visitTimeMillisecond=P(hl),L.prototype.visitTimeMicrosecond=P(dl),L.prototype.visitTimeNanosecond=P(fl),L.prototype.visitDecimal=P(fy),L.prototype.visitList=P(py),L.prototype.visitStruct=P(my),L.prototype.visitUnion=P(by),L.prototype.visitDenseUnion=P(pl),L.prototype.visitSparseUnion=P(yl),L.prototype.visitDictionary=P(gy),L.prototype.visitInterval=P(_y),L.prototype.visitIntervalDayTime=P(ml),L.prototype.visitIntervalYearMonth=P(bl),L.prototype.visitDuration=P(vy),L.prototype.visitDurationSecond=P(gl),L.prototype.visitDurationMillisecond=P(_l),L.prototype.visitDurationMicrosecond=P(vl),L.prototype.visitDurationNanosecond=P(wl),L.prototype.visitFixedSizeList=P(wy),L.prototype.visitMap=P(yy);const Mt=new L,hn=Symbol.for("keys"),dn=Symbol.for("vals"),fn=Symbol.for("kKeysAsStrings"),Zi=Symbol.for("_kKeysAsStrings");class ts{constructor(t){return this[hn]=new tt([t.children[0]]).memoize(),this[dn]=t.children[1],new Proxy(this,new Sy)}get[fn](){return this[Zi]||(this[Zi]=Array.from(this[hn].toArray(),String))}[Symbol.iterator](){return new Iy(this[hn],this[dn])}get size(){return this[hn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[hn],n=this[dn],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Mt.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${Un(t)}: ${Un(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Iy{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Mt.visit(this.vals,t)]})}}class Sy{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[fn]}has(t,n){return t[fn].includes(n)}getOwnPropertyDescriptor(t,n){if(t[fn].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[fn].indexOf(n);if(r!==-1){const i=Mt.visit(Reflect.get(t,dn),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[fn].indexOf(n);return i!==-1?(Wt.visit(Reflect.get(t,dn),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(ts.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[hn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[dn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Zi]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Il;function Sl(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(Il=s,s=a,a=Il),a>i&&(a=i),r?r(e,s,a):[s,a]}const es=(e,t)=>e<0?t+e:e,El=e=>e!==e;function pn(e){if(typeof e!="object"||e===null)return El(e)?El:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?wp(e,t):!1:e instanceof Map?Ty(e):Array.isArray(e)?Ey(e):e instanceof tt?Ay(e):Ny(e,!0)}function Ey(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e[n]);return Jr(t)}function Ty(e){let t=-1;const n=[];for(const r of e.values())n[++t]=pn(r);return Jr(n)}function Ay(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=pn(e.get(n));return Jr(t)}function Ny(e,t=!1){const n=Object.keys(e);if(!t&&n.length===0)return()=>!1;const r=[];for(let i=-1,s=n.length;++i<s;)r[i]=pn(e[n[i]]);return Jr(r,n)}function Jr(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return By(e,n);case Map:return Tl(e,n,n.keys());case ts:case Ji:case Object:case void 0:return Tl(e,n,t||Object.keys(n))}return n instanceof tt?Ry(e,n):!1}}function By(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function Ry(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Tl(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),c=r.next(),d=i.next();for(;a<o&&!c.done&&!d.done&&!l.done&&!(c.value!==d.value||!e[a](l.value));++a,c=r.next(),d=i.next(),l=s.next());return a===o&&c.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function Al(e,t,n,r){return(n&1<<r)!==0}function Oy(e,t,n,r){return(n&1<<r)>>r}function Zr(e,t,n){const r=n.byteLength+7&-8;if(e>0||n.byteLength<r){const i=new Uint8Array(r);return i.set(e%8===0?n.subarray(e>>3):ti(new ns(n,e,t,null,Al)).subarray(0,r)),i}return n}function ti(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class ns{constructor(t,n,r,i,s){this.bytes=t,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}function rs(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new ns(e,t,n-t,e,Oy))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return rs(e,t,i)+rs(e,r,n)+Dy(e,i>>3,r-i>>3)}function Dy(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=is(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=is(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=is(s.getUint8(i)),i+=1;return r}function is(e){let t=Math.trunc(e);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const Fy=-1;class nt{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return D.isSparseUnion(t)?this.children.some(n=>n.nullable):D.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(D.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=Fy&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-rs(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof nt?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ie(t),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){const{type:n}=this;if(D.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Et.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(D.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Et.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,c=1<<l%8,d=l>>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Zr(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const y=s[d];r=(y&c)!==0,s[d]=n?y|c:y&~c}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new nt(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===f.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(Zr(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[we.VALIDITY]=i,this.clone(this.type,0,t,r+(t-n),s)}_sliceBuffers(t,n,r,i){let s;const{buffers:a}=this;return(s=a[we.TYPE])&&(a[we.TYPE]=s.subarray(t,t+n)),(s=a[we.OFFSET])&&(a[we.OFFSET]=s.subarray(t,t+n+1))||(s=a[we.DATA])&&(a[we.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}nt.prototype.children=Object.freeze([]);class Pn extends q{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new nt(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.data),s=H(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=H(t.nullBitmap),{length:a=i.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=at(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(D.isSparseUnion(n))return new nt(n,r,a,o,[void 0,void 0,void 0,s],i);const l=xn(t.valueOffsets);return new nt(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.indices.ArrayType,t.data),{["dictionary"]:a=new tt([new Pn().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=H(t.nullBitmap),s=at(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.valueType})}=t,s=H(t.nullBitmap),{["length"]:a=i.length/Ie(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new nt(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Pn().visit({type:n.childType})}=t,s=H(t.nullBitmap),a=xn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new nt(n,r,o,l,[a,void 0,s],[i])}}const My=new Pn;function G(e){return My.visit(e)}class Nl{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function Ly(e){return e.some(t=>t.nullable)}function Bl(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Rl(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function Ol(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:c}=o;if(l>=r)break;if(n>=l+c)continue;if(l>=n&&l+c<=r){i.push(o);continue}const d=Math.max(0,n-l),y=Math.min(r-l,c);i.push(o.slice(d,y-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function ss(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function as(e,t){return e.getValid(t)}function ei(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return ss(r,this._offsets,n,t)}}function Dl(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=ss(s,this._offsets,r,n);return t=void 0,a}}function Fl(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let c=i-1,d=r.length;++c<d;){const y=r[c];if(~(o=e(y,t,a)))return l+o;a=0,l+=y.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):ss(s,this._offsets,i,n);return t=void 0,a}}class x extends q{}function xy(e,t){return t===null&&e.length>0?0:-1}function Uy(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new ns(n,e.offset+(t||0),e.length,n,Al)){if(!i)return r;++r}return-1}function j(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case f.Union:break;case f.Dictionary:break;default:return Uy(e,n)}const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function Ml(e,t,n){const r=Mt.getVisitFn(e),i=pn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}x.prototype.visitNull=xy,x.prototype.visitBool=j,x.prototype.visitInt=j,x.prototype.visitInt8=j,x.prototype.visitInt16=j,x.prototype.visitInt32=j,x.prototype.visitInt64=j,x.prototype.visitUint8=j,x.prototype.visitUint16=j,x.prototype.visitUint32=j,x.prototype.visitUint64=j,x.prototype.visitFloat=j,x.prototype.visitFloat16=j,x.prototype.visitFloat32=j,x.prototype.visitFloat64=j,x.prototype.visitUtf8=j,x.prototype.visitLargeUtf8=j,x.prototype.visitBinary=j,x.prototype.visitLargeBinary=j,x.prototype.visitFixedSizeBinary=j,x.prototype.visitDate=j,x.prototype.visitDateDay=j,x.prototype.visitDateMillisecond=j,x.prototype.visitTimestamp=j,x.prototype.visitTimestampSecond=j,x.prototype.visitTimestampMillisecond=j,x.prototype.visitTimestampMicrosecond=j,x.prototype.visitTimestampNanosecond=j,x.prototype.visitTime=j,x.prototype.visitTimeSecond=j,x.prototype.visitTimeMillisecond=j,x.prototype.visitTimeMicrosecond=j,x.prototype.visitTimeNanosecond=j,x.prototype.visitDecimal=j,x.prototype.visitList=j,x.prototype.visitStruct=j,x.prototype.visitUnion=j,x.prototype.visitDenseUnion=Ml,x.prototype.visitSparseUnion=Ml,x.prototype.visitDictionary=j,x.prototype.visitInterval=j,x.prototype.visitIntervalDayTime=j,x.prototype.visitIntervalYearMonth=j,x.prototype.visitDuration=j,x.prototype.visitDurationSecond=j,x.prototype.visitDurationMillisecond=j,x.prototype.visitDurationMicrosecond=j,x.prototype.visitDurationNanosecond=j,x.prototype.visitFixedSizeList=j,x.prototype.visitMap=j;const ni=new x;class U extends q{}function V(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(D.isInt(t)&&t.bitWidth!==64||D.isTime(t)&&t.bitWidth!==64||D.isFloat(t)&&t.precision!==Tt.HALF))return new Nl(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Nl(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new Cy(s)})}class Cy{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}U.prototype.visitNull=V,U.prototype.visitBool=V,U.prototype.visitInt=V,U.prototype.visitInt8=V,U.prototype.visitInt16=V,U.prototype.visitInt32=V,U.prototype.visitInt64=V,U.prototype.visitUint8=V,U.prototype.visitUint16=V,U.prototype.visitUint32=V,U.prototype.visitUint64=V,U.prototype.visitFloat=V,U.prototype.visitFloat16=V,U.prototype.visitFloat32=V,U.prototype.visitFloat64=V,U.prototype.visitUtf8=V,U.prototype.visitLargeUtf8=V,U.prototype.visitBinary=V,U.prototype.visitLargeBinary=V,U.prototype.visitFixedSizeBinary=V,U.prototype.visitDate=V,U.prototype.visitDateDay=V,U.prototype.visitDateMillisecond=V,U.prototype.visitTimestamp=V,U.prototype.visitTimestampSecond=V,U.prototype.visitTimestampMillisecond=V,U.prototype.visitTimestampMicrosecond=V,U.prototype.visitTimestampNanosecond=V,U.prototype.visitTime=V,U.prototype.visitTimeSecond=V,U.prototype.visitTimeMillisecond=V,U.prototype.visitTimeMicrosecond=V,U.prototype.visitTimeNanosecond=V,U.prototype.visitDecimal=V,U.prototype.visitList=V,U.prototype.visitStruct=V,U.prototype.visitUnion=V,U.prototype.visitDenseUnion=V,U.prototype.visitSparseUnion=V,U.prototype.visitDictionary=V,U.prototype.visitInterval=V,U.prototype.visitIntervalDayTime=V,U.prototype.visitIntervalYearMonth=V,U.prototype.visitDuration=V,U.prototype.visitDurationSecond=V,U.prototype.visitDurationMillisecond=V,U.prototype.visitDurationMicrosecond=V,U.prototype.visitDurationNanosecond=V,U.prototype.visitFixedSizeList=V,U.prototype.visitMap=V;const os=new U;var Ll;const xl={},Ul={};class tt{constructor(t){var n,r,i;const s=t[0]instanceof tt?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof nt)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:c}=xl[a.typeId],d=s[0];this.isValid=y=>as(d,y),this.get=y=>o(d,y),this.set=(y,_)=>l(d,y,_),this.indexOf=y=>c(d,y),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,Ul[a.typeId]),this._offsets=Rl(s);break}this.data=s,this.type=a,this.stride=Ie(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return Ly(this.data)}get nullCount(){return Bl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(es(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return os.visit(this)}concat(...t){return new tt(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new tt(Sl(this,t,n,({data:r,_offsets:i},s,a)=>Ol(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new tt(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return D.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(D.isDictionary(this.type)){const t=new ri(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new tt(n)}return new ri(this)}unmemoize(){if(D.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new tt(n)}return this}}Ll=Symbol.toStringTag,tt[Ll]=(e=>{e.type=D.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(f).map(n=>f[n]).filter(n=>typeof n=="number"&&n!==f.NONE);for(const n of t){const r=Mt.getVisitFnByTypeId(n),i=Wt.getVisitFnByTypeId(n),s=ni.getVisitFnByTypeId(n);xl[n]={get:r,set:i,indexOf:s},Ul[n]=Object.create(e,{isValid:{value:ei(as)},get:{value:ei(Mt.getVisitFnByTypeId(n))},set:{value:Dl(Wt.getVisitFnByTypeId(n))},indexOf:{value:Fl(ni.getVisitFnByTypeId(n))}})}return"Vector"})(tt.prototype);class ri extends tt{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new ri(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new tt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class ls{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,n,r,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(r),t.writeInt64(BigInt(n??0)),t.offset()}}class Ct{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsFooter(t,n){return(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+Z),(n||new Ct).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yt.V1}schema(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new ce).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new ls).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}dictionariesLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new ls).__init(this.bb.__vector(this.bb_pos+r)+t*24,this.bb):null}recordBatchesLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yt.V1)}static addSchema(t,n){t.addFieldOffset(1,n,0)}static addDictionaries(t,n){t.addFieldOffset(2,n,0)}static startDictionariesVector(t,n){t.startVector(24,n,8)}static addRecordBatches(t,n){t.addFieldOffset(3,n,0)}static startRecordBatchesVector(t,n){t.startVector(24,n,8)}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,n){t.finish(n)}static finishSizePrefixedFooterBuffer(t,n){t.finish(n,void 0,!0)}}class et{constructor(t=[],n,r,i=yt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=cs(this.fields)),this.dictionaries=r,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,n)=>`${n}: ${t}`).join(", ")} }>`}select(t){const n=new Set(t),r=this.fields.filter(i=>n.has(i.name));return new et(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new et(n,this.metadata)}assign(...t){const n=t[0]instanceof et?t[0]:Array.isArray(t[0])?new et(t[0]):new et(t),r=[...this.fields],i=ii(ii(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(c=>c.name===o.name);return~l?(r[l]=o.clone({metadata:ii(ii(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=cs(s,new Map);return new et([...r,...s],i,new Map([...this.dictionaries,...a]))}}et.prototype.fields=null,et.prototype.metadata=null,et.prototype.dictionaries=null;class ut{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new ut(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],ut.new(n,r,i,s)}}ut.prototype.type=null,ut.prototype.name=null,ut.prototype.nullable=null,ut.prototype.metadata=null;function ii(e,t){return new Map([...e||new Map,...t||new Map])}function cs(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(D.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&cs(i.children,t)}return t}var ky=Ha,$y=tn;class Vn{static decode(t){t=new $y(H(t));const n=Ct.getRootAsFooter(t),r=et.decode(n.schema(),new Map,n.version());return new Py(r,n)}static encode(t){const n=new ky,r=et.encode(n,t.schema);Ct.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Fe.encode(n,a);const i=n.endVector();Ct.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Fe.encode(n,a);const s=n.endVector();return Ct.startFooter(n),Ct.addSchema(n,r),Ct.addVersion(n,yt.V5),Ct.addRecordBatches(n,i),Ct.addDictionaries(n,s),Ct.finishFooterBuffer(n,Ct.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=yt.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class Py extends Vn{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,n){super(t,n.version()),this._footer=n}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){const n=this._footer.recordBatches(t);if(n)return Fe.decode(n)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){const n=this._footer.dictionaries(t);if(n)return Fe.decode(n)}return null}}class Fe{static decode(t){return new Fe(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,n){const{metaDataLength:r}=n,i=BigInt(n.offset),s=BigInt(n.bodyLength);return ls.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=ot(r),this.bodyLength=ot(n)}}const wt=Object.freeze({done:!0,value:void 0});class Cl{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class us{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class Vy extends us{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){const{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(wt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Pt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Pt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Y(this,void 0,void 0,function*(){return yield this.abort(t),wt})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),wt})}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(wt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class si extends Vy{write(t){if((t=H(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Pi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Pi)}toUint8Array(t=!1){return t?ie(this._values)[0]:Y(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,c=je(this),d;d=yield c.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const y=s;a.push(y),o+=y.byteLength}}catch(y){r={error:y}}finally{try{!l&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}return ie(a,o)[0]})}}class ai{constructor(t){t&&(this.source=new zy(Pt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class yn{constructor(t){t instanceof yn?this.source=t.source:t instanceof si?this.source=new Ge(Pt.fromAsyncIterable(t)):Va(t)?this.source=new Ge(Pt.fromNodeStream(t)):ji(t)?this.source=new Ge(Pt.fromDOMStream(t)):Pa(t)?this.source=new Ge(Pt.fromDOMStream(t.body)):Ln(t)?this.source=new Ge(Pt.fromIterable(t)):Ye(t)?this.source=new Ge(Pt.fromAsyncIterable(t)):Ze(t)&&(this.source=new Ge(Pt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class zy{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||wt)}return(t){return Object.create(this.source.return&&this.source.return(t)||wt)}}class Ge{constructor(t){this.source=t,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(t){return Y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Y(this,arguments,void 0,function*(n,r="read"){return yield this.source.next({cmd:r,size:n})})}throw(t){return Y(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(t){return Y(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(t))||wt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class kl extends ai{constructor(t,n){super(),this.position=0,this.buffer=H(t),this.size=n===void 0?this.buffer.byteLength:n}readInt32(t){const{buffer:n,byteOffset:r}=this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){const{buffer:n,size:r,position:i}=this;return n&&i<r?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(r,i+Math.min(r-i,t)),n.subarray(i,this.position)):null}readAt(t,n){const r=this.buffer,i=Math.min(this.size,t+n);return r?r.subarray(t,i):new Uint8Array(n)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}}class oi extends yn{constructor(t,n){super(),this.position=0,this._handle=t,typeof n=="number"?this.size=n:this._pending=Y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return Y(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(t,4);return new DataView(n,r).getInt32(0,!0)})}seek(t){return Y(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return Y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:n,size:r,position:i}=this;if(n&&i<r){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),c=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<c.byteLength;)({bytesRead:o}=yield n.read(c,a,c.byteLength-a,s));return c}return null})}readAt(t,n){return Y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Y(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const jy=65536;function mn(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const bn=8,hs=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class $l{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?jy:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${mn(this.buffer[1])} ${mn(this.buffer[0])}`}}class rt extends $l{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return rt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return rt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new rt(n);for(let s=0;s<r;){const a=bn<r-s?bn:r-s,o=new rt(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new rt(new Uint32Array([hs[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)rt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new rt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new rt(new Uint32Array(t.buffer)).plus(n)}}class qt extends $l{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){const n=this.buffer[1]<<0,r=t.buffer[1]<<0;return n<r||n===r&&this.buffer[0]<t.buffer[0]}static from(t,n=new Uint32Array(2)){return qt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return qt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new qt(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new qt(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),c=new qt(new Uint32Array([hs[o],0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)qt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new qt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new qt(new Uint32Array(t.buffer)).plus(n)}}class ue{constructor(t){this.buffer=t}high(){return new qt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new qt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){const n=new rt(new Uint32Array([this.buffer[3],0])),r=new rt(new Uint32Array([this.buffer[2],0])),i=new rt(new Uint32Array([this.buffer[1],0])),s=new rt(new Uint32Array([this.buffer[0],0])),a=new rt(new Uint32Array([t.buffer[3],0])),o=new rt(new Uint32Array([t.buffer[2],0])),l=new rt(new Uint32Array([t.buffer[1],0])),c=new rt(new Uint32Array([t.buffer[0],0]));let d=rt.multiply(s,c);this.buffer[0]=d.low();const y=new rt(new Uint32Array([d.high(),0]));return d=rt.multiply(i,c),y.plus(d),d=rt.multiply(s,l),y.plus(d),this.buffer[1]=y.low(),this.buffer[3]=y.lessThan(d)?1:0,this.buffer[2]=y.high(),new rt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(rt.multiply(r,c)).plus(rt.multiply(i,l)).plus(rt.multiply(s,o)),this.buffer[3]+=rt.multiply(n,c).plus(rt.multiply(r,l)).plus(rt.multiply(i,o)).plus(rt.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${mn(this.buffer[3])} ${mn(this.buffer[2])} ${mn(this.buffer[1])} ${mn(this.buffer[0])}`}static multiply(t,n){return new ue(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new ue(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return ue.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return ue.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){const r=t.startsWith("-"),i=t.length,s=new ue(n);for(let a=r?1:0;a<i;){const o=bn<i-a?bn:i-a,l=new ue(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),c=new ue(new Uint32Array([hs[o],0,0,0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)ue.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class Pl extends q{constructor(t,n,r,i,s=yt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof ut?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return G({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),children:this.visitMany(t.children)})}visitUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return this.metadataVersion<yt.V5&&this.readNullBitmap(t,r),t.mode===Et.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),child:this.visit(t.children[0])})}visitMap(t,{length:n,nullCount:r}=this.nextFieldNode()){return G({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class Yy extends Pl{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):ti(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return at(Uint8Array,at(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return D.isTimestamp(t)||(D.isInt(t)||D.isTime(t))&&t.bitWidth===64||D.isDuration(t)||D.isDate(t)&&t.unit===Vt.MILLISECOND?at(Uint8Array,qt.convertArray(r[n])):D.isDecimal(t)?at(Uint8Array,ue.convertArray(r[n])):D.isBinary(t)||D.isLargeBinary(t)||D.isFixedSizeBinary(t)?Wy(r[n]):D.isBool(t)?ti(r[n]):D.isUtf8(t)||D.isLargeUtf8(t)?Vi(r[n].join("")):at(Uint8Array,at(t.ArrayType,r[n].map(i=>+i)))}}function Wy(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class C extends q{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function Nt(e,t){return t instanceof e.constructor}function He(e,t){return e===t||Nt(e,t)}function Ee(e,t){return e===t||Nt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function li(e,t){return e===t||Nt(e,t)&&e.precision===t.precision}function qy(e,t){return e===t||Nt(e,t)&&e.byteWidth===t.byteWidth}function ds(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function zn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function jn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Gy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Hy(e,t){return e===t||Nt(e,t)&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function fs(e,t){return e===t||Nt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&Me.compareManyFields(e.children,t.children)}function Ky(e,t){return e===t||Nt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&Me.visit(e.indices,t.indices)&&Me.visit(e.dictionary,t.dictionary)}function ps(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Yn(e,t){return e===t||Nt(e,t)&&e.unit===t.unit}function Qy(e,t){return e===t||Nt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}function Xy(e,t){return e===t||Nt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&Me.compareManyFields(e.children,t.children)}C.prototype.visitNull=He,C.prototype.visitBool=He,C.prototype.visitInt=Ee,C.prototype.visitInt8=Ee,C.prototype.visitInt16=Ee,C.prototype.visitInt32=Ee,C.prototype.visitInt64=Ee,C.prototype.visitUint8=Ee,C.prototype.visitUint16=Ee,C.prototype.visitUint32=Ee,C.prototype.visitUint64=Ee,C.prototype.visitFloat=li,C.prototype.visitFloat16=li,C.prototype.visitFloat32=li,C.prototype.visitFloat64=li,C.prototype.visitUtf8=He,C.prototype.visitLargeUtf8=He,C.prototype.visitBinary=He,C.prototype.visitLargeBinary=He,C.prototype.visitFixedSizeBinary=qy,C.prototype.visitDate=ds,C.prototype.visitDateDay=ds,C.prototype.visitDateMillisecond=ds,C.prototype.visitTimestamp=zn,C.prototype.visitTimestampSecond=zn,C.prototype.visitTimestampMillisecond=zn,C.prototype.visitTimestampMicrosecond=zn,C.prototype.visitTimestampNanosecond=zn,C.prototype.visitTime=jn,C.prototype.visitTimeSecond=jn,C.prototype.visitTimeMillisecond=jn,C.prototype.visitTimeMicrosecond=jn,C.prototype.visitTimeNanosecond=jn,C.prototype.visitDecimal=He,C.prototype.visitList=Gy,C.prototype.visitStruct=Hy,C.prototype.visitUnion=fs,C.prototype.visitDenseUnion=fs,C.prototype.visitSparseUnion=fs,C.prototype.visitDictionary=Ky,C.prototype.visitInterval=ps,C.prototype.visitIntervalDayTime=ps,C.prototype.visitIntervalYearMonth=ps,C.prototype.visitDuration=Yn,C.prototype.visitDurationSecond=Yn,C.prototype.visitDurationMillisecond=Yn,C.prototype.visitDurationMicrosecond=Yn,C.prototype.visitDurationNanosecond=Yn,C.prototype.visitFixedSizeList=Qy,C.prototype.visitMap=Xy;const Me=new C;function ys(e,t){return Me.compareSchemas(e,t)}function ms(e,t){return Jy(e,t.map(n=>n.data.concat()))}function Jy(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((y,_)=>Math.max(y,_.length),0)};let s=0,a=0,o=-1;const l=t.length;let c,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=c=t[o].shift(),a=Math.min(a,c?c.length:a);Number.isFinite(a)&&(d=Zy(n,a,d,t,i),a>0&&(r[s++]=G({type:new At(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(y=>new Lt(e,y))]}function Zy(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const c=n[o],d=c==null?void 0:c.length;if(d>=t)d===t?n[o]=c:(n[o]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(c.slice(t,d-t))));else{const y=e[o];e[o]=y.clone({nullable:!0}),n[o]=(s=c==null?void 0:c._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:G({type:y.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var Vl;class Bt{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new et([]),this._offsets=[0],this;let i,s;t[0]instanceof et&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof Lt)return[l];if(l instanceof Bt)return l.batches;if(l instanceof nt){if(l.type instanceof At)return[new Lt(new et(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>a(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>a(c));if(typeof l=="object"){const c=Object.keys(l),d=c.map(v=>new tt([l[v]])),y=i??new et(c.map((v,E)=>new ut(String(v),d[E].type,d[E].nullable))),[,_]=ms(y,d);return _.length===0?[new Lt(l)]:_}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new et([]),!(i instanceof et))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof Lt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!ys(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Rl(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Bl(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(es(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?os.visit(new tt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
42
|
+
FROM ${R.value}
|
|
43
|
+
`,S=((O=await E.executeQuery(I,T.value))==null?void 0:O[0])||{xmin:-1,xmax:1,ymin:-1,ymax:1};d.value={schema:[{name:p},{name:g},...m.map(A=>({name:A}))],row_groups:[{columns:[{meta_data:{statistics:{min_value:S.xmin,max_value:S.xmax}}},{meta_data:{statistics:{min_value:S.ymin,max_value:S.ymax}}}]}]}}async function gt(p,g,u){_.value=new Map;const m=["#4269d0","#efb118","#ff725c","#6cc5b0","#3ca951","#ff8ab7","#a463f2","#97bbf5","#9c6b4e","#9498a0"],b=w=>/DOUBLE|HUGEINT|BIGINT|INTEGER|DECIMAL|FLOAT|REAL/i.test(w);for(const w of p){if(w.name===g||w.name===u){_.value.set(w.name,new Map);continue}if(b(w.type))_.value.set(w.name,new Map);else{const I=`SELECT DISTINCT ${dt(w.name)} AS v FROM ${R.value} LIMIT 10000`,S=(await E.executeQuery(I,T.value)).map(A=>A.v).filter(A=>A!=null),O=new Map;S.forEach((A,M)=>O.set(A,te(m[M%m.length]))),_.value.set(w.name,O)}}(d.value||(d.value={})).key_value_metadata=Array.from(_.value.keys()).map(w=>{var I;return{key:w,value:JSON.stringify(Array.from(((I=_.value.get(w))==null?void 0:I.keys())??[]))}}),r.value!=="random"&&!_.value.has(r.value)&&(r.value="random")}async function _t(){const{useGetToken:p}=await Promise.resolve().then(()=>Bc);return p()}async function St(p,g){const u=await _t(),m=`${g}/packages/${p}/view?api_key=${u}`,b=await fetch(m);if(!b.ok)throw new Error(`view failed: ${b.status}`);v.value=await b.json()}async function Pt(p,g,u){const m=await _t(),b=`${u}/packages/${p}/files/${g}?api_key=${m}`,w=await fetch(b);if(!w.ok)throw new Error(`file url failed: ${w.status}`);return(await w.json()).url}function dt(p){return`"${p.replace(/"/g,'""')}"`}function ht(){o.value=!o.value,l.value++}function te(p){try{if(!p||p.length<7)return[1,0,0];const g=parseInt(p.slice(1,3),16)/255,u=parseInt(p.slice(3,5),16)/255,m=parseInt(p.slice(5,7),16)/255;return Number.isNaN(g)||Number.isNaN(u)||Number.isNaN(m)?[1,0,0]:[g,u,m]}catch{return[1,0,0]}}function N(p){y.value=p[1]}async function F(p){return(await E.executeQuery(`PRAGMA table_info(${p});`,T.value)).map(g=>({name:g.name,type:g.type}))}return h.onMounted(async()=>{await B()}),h.onBeforeUnmount(async()=>{T.value&&await E.closeConnection(T.value)}),(p,g)=>(h.openBlock(),h.createElementBlock("div",ep,[(h.openBlock(),h.createBlock(qf,{data:c.value,metaData:d.value,pointCount:n.value,"color-map":y.value,colorMode:r.value,startColor:i.value,endColor:s.value,singleColor:a.value,selectedMapEntries:Array.from(y.value),forceRegenerate:o.value,key:l.value},null,8,["data","metaData","pointCount","color-map","colorMode","startColor","endColor","singleColor","selectedMapEntries","forceRegenerate"])),h.createVNode(tp,{pointCount:n.value,"onUpdate:pointCount":g[0]||(g[0]=u=>n.value=u),colorMode:r.value,"onUpdate:colorMode":g[1]||(g[1]=u=>r.value=u),startColor:i.value,"onUpdate:startColor":g[2]||(g[2]=u=>i.value=u),endColor:s.value,"onUpdate:endColor":g[3]||(g[3]=u=>s.value=u),singleColor:a.value,"onUpdate:singleColor":g[4]||(g[4]=u=>a.value=u),"color-scheme":y.value,"color-map-map":_.value,onRegenerate:ht,onUpdateColorMap:N},null,8,["pointCount","colorMode","startColor","endColor","singleColor","color-scheme","color-map-map"])]))}}),rp=On(np,[["__scopeId","data-v-028490f3"]]),ip="dashboard:globalVars";function La(e=!1){const t=h.inject(ip,null);return!t&&e&&console.warn("[Widget] dashboard:globalVars not provided."),t}const sp={class:"data-explorer-wrap"},ap={class:"data-explorer-info"},op=h.defineComponent({inheritAttrs:!1,__name:"DataExplorer",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t.s3Url));return h.watchEffect(()=>{}),(i,s)=>{const a=h.resolveComponent("el-icon");return h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",sp,[h.createElementVNode("div",ap,[h.createVNode(h.unref(Pc.ElTooltip),{placement:"top-start"},{content:h.withCtx(()=>[...s[0]||(s[0]=[h.createTextVNode("Type in a query or use the suggested query buttons to run on your csv file",-1)])]),default:h.withCtx(()=>[h.createVNode(a,{color:"#8300BF"},{default:h.withCtx(()=>[h.createVNode(h.unref(jc))]),_:1})]),_:1})]),h.createVNode(h.unref(yu),{srcUrl:r.value},null,8,["srcUrl"])])],64)}}}),xa=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},lp=xa(op,[["__scopeId","data-v-2908b590"]]),cp={class:"umap-wrap"},up=xa(Object.assign({inheritAttrs:!1},{__name:"Umap",setup(e){const t=La(),n=h.ref("Data Explorer"),r=h.computed(()=>h.unref(t==null?void 0:t.s3Url));return(i,s)=>(h.openBlock(),h.createElementBlock(h.Fragment,null,[h.renderSlot(i.$slots,"default",{widgetName:n.value},void 0,!0),h.createElementVNode("div",cp,[h.createVNode(h.unref(rp),{srcUrl:r.value},null,8,["srcUrl"])])],64))}}),[["__scopeId","data-v-c778c86e"]]);function Y(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function o(d){try{c(r.next(d))}catch(y){a(y)}}function l(d){try{c(r.throw(d))}catch(y){a(y)}}function c(d){d.done?s(d.value):i(d.value).then(o,l)}c((r=r.apply(e,t||[])).next())})}function Ua(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function 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),o("next"),o("throw"),o("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(v){return function(E){return Promise.resolve(E).then(v,y)}}function o(v,E){r[v]&&(i[v]=function(T){return new Promise(function(R,B){s.push([v,T,R,B])>1||l(v,T)})},E&&(i[v]=E(i[v])))}function l(v,E){try{c(r[v](E))}catch(T){_(s[0][3],T)}}function c(v){v.value instanceof W?Promise.resolve(v.value.v).then(d,y):_(s[0][2],v)}function d(v){l("next",v)}function y(v){l("throw",v)}function _(v,E){v(E),s.shift(),s.length&&l(s[0][0],s[0][1])}}function Ar(e){var t,n;return t={},r("next"),r("throw",function(i){throw i}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(i,s){t[i]=e[i]?function(a){return(n=!n)?{value:W(e[i](a)),done:!1}:s?s(a):a}:s}}function Qe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ua=="function"?Ua(e):e[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=e[s]&&function(a){return new Promise(function(o,l){a=e[s](a),i(o,l,a.done,a.value)})}}function i(s,a,o,l){Promise.resolve(l).then(function(c){s({value:c,done:o})},a)}}const hp=new TextDecoder("utf-8"),zi=e=>hp.decode(e),dp=new TextEncoder,ji=e=>dp.encode(e),fp=e=>typeof e=="number",Ca=e=>typeof e=="boolean",vt=e=>typeof e=="function",Mt=e=>e!=null&&Object(e)===e,Xe=e=>Mt(e)&&vt(e.then),Vn=e=>Mt(e)&&vt(e[Symbol.iterator]),an=e=>Mt(e)&&vt(e[Symbol.asyncIterator]),Yi=e=>Mt(e)&&Mt(e.schema),$a=e=>Mt(e)&&"done"in e&&"value"in e,ka=e=>Mt(e)&&vt(e.stat)&&fp(e.fd),Pa=e=>Mt(e)&&Wi(e.body),Rr=e=>"_getDOMStream"in e&&"_getNodeStream"in e,pp=e=>Mt(e)&&vt(e.abort)&&vt(e.getWriter)&&!Rr(e),Wi=e=>Mt(e)&&vt(e.cancel)&&vt(e.getReader)&&!Rr(e),yp=e=>Mt(e)&&vt(e.end)&&vt(e.write)&&Ca(e.writable)&&!Rr(e),Va=e=>Mt(e)&&vt(e.read)&&vt(e.pipe)&&Ca(e.readable)&&!Rr(e),mp=e=>Mt(e)&&vt(e.clear)&&vt(e.bytes)&&vt(e.position)&&vt(e.setPosition)&&vt(e.capacity)&&vt(e.getBufferIdentifier)&&vt(e.createLong),qi=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function bp(e){const t=e[0]?[e[0]]:[];let n,r,i,s;for(let a,o,l=0,c=0,d=e.length;++l<d;){if(a=t[c],o=e[l],!a||!o||a.buffer!==o.buffer||o.byteOffset<a.byteOffset){o&&(t[++c]=o);continue}if({byteOffset:n,byteLength:i}=a,{byteOffset:r,byteLength:s}=o,n+i<r||r+s<n){o&&(t[++c]=o);continue}t[c]=new Uint8Array(a.buffer,n,r-n+s)}return t}function za(e,t,n=0,r=t.byteLength){const i=e.byteLength,s=new Uint8Array(e.buffer,e.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return s.set(a,n),e}function ae(e,t){const n=bp(e),r=n.reduce((d,y)=>d+y.byteLength,0);let i,s,a,o=0,l=-1;const c=Math.min(t||Number.POSITIVE_INFINITY,r);for(const d=n.length;++l<d;){if(i=n[l],s=i.subarray(0,Math.min(i.length,c-o)),c<=o+s.length){s.length<i.length?n[l]=i.subarray(s.length):s.length===i.length&&l++,a?za(a,s,o):a=s;break}za(a||(a=new Uint8Array(c)),s,o),o+=s.length}return[a||new Uint8Array(0),n.slice(l),r-(a?a.byteLength:0)]}function ot(e,t){let n=$a(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n=="string"&&(n=ji(n)),n instanceof ArrayBuffer?new e(n):n instanceof qi?new e(n):mp(n)?ot(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 zn=e=>ot(Int32Array,e),ja=e=>ot(BigInt64Array,e),Q=e=>ot(Uint8Array,e),Gi=e=>(e.next(),e);function*gp(e,t){const n=function*(i){yield i},r=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof qi?n(t):Vn(t)?t:n(t);return yield*Gi((function*(i){let s=null;do s=i.next(yield ot(e,s));while(!s.done)})(r[Symbol.iterator]())),new e}const _p=e=>gp(Uint8Array,e);function Ya(e,t){return se(this,arguments,function*(){if(Xe(t))return yield W(yield W(yield*Ar(Qe(Ya(e,yield W(t))))));const n=function(s){return se(this,arguments,function*(){yield yield W(yield W(s))})},r=function(s){return se(this,arguments,function*(){yield W(yield*Ar(Qe(Gi((function*(a){let o=null;do o=a.next(yield o==null?void 0:o.value);while(!o.done)})(s[Symbol.iterator]())))))})},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof qi?n(t):Vn(t)?r(t):an(t)?t:n(t);return yield W(yield*Ar(Qe(Gi((function(s){return se(this,arguments,function*(){let a=null;do a=yield W(s.next(yield yield W(ot(e,a))));while(!a.done)})})(i[Symbol.asyncIterator]()))))),yield W(new e)})}const vp=e=>Ya(Uint8Array,e);function Wa(e,t,n){if(e!==0){n=n.slice(0,t);for(let r=-1,i=n.length;++r<i;)n[r]+=e}return n.subarray(0,t)}function wp(e,t){let n=0;const r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}const Vt={fromIterable(e){return Br(Ip(e))},fromAsyncIterable(e){return Br(Sp(e))},fromDOMStream(e){return Br(Ep(e))},fromNodeStream(e){return Br(Ap(e))},toDOMStream(e,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(e,t){throw new Error('"toNodeStream" not available in this environment')}},Br=e=>(e.next(),e);function*Ip(e){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ae(r,a)[0]:([i,r,o]=ae(r,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});const c=_p(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?c.next():c.next(a-o),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield l());while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&c.throw(d)}finally{n===!1&&typeof c.return=="function"&&c.return(null)}return null}function Sp(e){return se(this,arguments,function*(){let t,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ae(r,a)[0]:([i,r,o]=ae(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=vp(e)[Symbol.asyncIterator]();try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.next()):yield W(c.next(a-o)),!t&&i.byteLength>0&&(r.push(i),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&typeof c.throw=="function"&&(yield W(c.throw(d)))}finally{n===!1&&typeof c.return=="function"&&(yield W(c.return(new Uint8Array(0))))}return yield W(null)})}function Ep(e){return se(this,arguments,function*(){let t=!1,n=!1,r=[],i,s,a,o=0;function l(){return s==="peek"?ae(r,a)[0]:([i,r,o]=ae(r,a),i)}({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0});const c=new Tp(e);try{do if({done:t,value:i}=Number.isNaN(a-o)?yield W(c.read()):yield W(c.read(a-o)),!t&&i.byteLength>0&&(r.push(Q(i)),o+=i.byteLength),t||a<=o)do({cmd:s,size:a}=yield yield W(l()));while(a<o);while(!t)}catch(d){(n=!0)&&(yield W(c.cancel(d)))}finally{n===!1?yield W(c.cancel()):e.locked&&c.releaseLock()}return yield W(null)})}class Tp{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Y(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(t).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(t){return Y(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=Q(n)),n})}}const Hi=(e,t)=>{const n=i=>r([t,i]);let r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Ap(e){return se(this,arguments,function*(){const t=[];let n="error",r=!1,i=null,s,a,o=0,l=[],c;function d(){return s==="peek"?ae(l,a)[0]:([c,l,o]=ae(l,a),c)}if({cmd:s,size:a}=(yield yield W(null))||{cmd:"read",size:0},e.isTTY)return yield yield W(new Uint8Array(0)),yield W(null);try{t[0]=Hi(e,"end"),t[1]=Hi(e,"error");do{if(t[2]=Hi(e,"readable"),[n,i]=yield W(Promise.race(t.map(_=>_[2]))),n==="error")break;if((r=n==="end")||(Number.isFinite(a-o)?(c=Q(e.read(a-o)),c.byteLength<a-o&&(c=Q(e.read()))):c=Q(e.read()),c.byteLength>0&&(l.push(c),o+=c.byteLength)),r||a<=o)do({cmd:s,size:a}=yield yield W(d()));while(a<o)}while(!r)}finally{yield W(y(t,n==="error"?i:null))}return yield W(null);function y(_,v){return c=l=null,new Promise((E,T)=>{for(const[R,B]of _)e.off(R,B);try{const R=e.destroy;R&&R.call(e,v),v=void 0}catch(R){v=R||v}finally{v!=null?T(v):E()}})}})}var mt;(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"})(mt||(mt={}));var Et;(function(e){e[e.Sparse=0]="Sparse",e[e.Dense=1]="Dense"})(Et||(Et={}));var Tt;(function(e){e[e.HALF=0]="HALF",e[e.SINGLE=1]="SINGLE",e[e.DOUBLE=2]="DOUBLE"})(Tt||(Tt={}));var zt;(function(e){e[e.DAY=0]="DAY",e[e.MILLISECOND=1]="MILLISECOND"})(zt||(zt={}));var $;(function(e){e[e.SECOND=0]="SECOND",e[e.MILLISECOND=1]="MILLISECOND",e[e.MICROSECOND=2]="MICROSECOND",e[e.NANOSECOND=3]="NANOSECOND"})($||($={}));var oe;(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"})(oe||(oe={}));const Ki=2,le=4,ve=4,et=4,Fe=new Int32Array(2),qa=new Float32Array(Fe.buffer),Ga=new Float64Array(Fe.buffer),Nr=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Qi;(function(e){e[e.UTF8_BYTES=1]="UTF8_BYTES",e[e.UTF16_STRING=2]="UTF16_STRING"})(Qi||(Qi={}));let on=class $c{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new $c(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),qa[0]}readFloat64(t){return Fe[Nr?0:1]=this.readInt32(t),Fe[Nr?1:0]=this.readInt32(t+4),Ga[0]}writeInt8(t,n){this.bytes_[t]=n}writeUint8(t,n){this.bytes_[t]=n}writeInt16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeUint16(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8}writeInt32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeUint32(t,n){this.bytes_[t]=n,this.bytes_[t+1]=n>>8,this.bytes_[t+2]=n>>16,this.bytes_[t+3]=n>>24}writeInt64(t,n){this.writeInt32(t,Number(BigInt.asIntN(32,n))),this.writeInt32(t+4,Number(BigInt.asIntN(32,n>>BigInt(32))))}writeUint64(t,n){this.writeUint32(t,Number(BigInt.asUintN(32,n))),this.writeUint32(t+4,Number(BigInt.asUintN(32,n>>BigInt(32))))}writeFloat32(t,n){qa[0]=n,this.writeInt32(t,Fe[0])}writeFloat64(t,n){Ga[0]=n,this.writeInt32(t,Fe[Nr?0:1]),this.writeInt32(t+4,Fe[Nr?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===Qi.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}},Ha=class kc{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=on.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=kc.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=on.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)*Ki;this.addInt16(s);let a=0;const o=this.space;t:for(n=0;n<this.vtables.length;n++){const l=this.bb.capacity()-this.vtables[n];if(s==this.bb.readInt16(l)){for(let c=Ki;c<s;c+=Ki)if(this.bb.readInt16(o+c)!=this.bb.readInt16(l+c))continue t;a=this.vtables[n];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,n,r){const i=r?et: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 a=ve-1;a>=0;a--)this.writeInt8(s.charCodeAt(a))}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 Or;(function(e){e[e.BUFFER=0]="BUFFER"})(Or||(Or={}));var Dr;(function(e){e[e.LZ4_FRAME=0]="LZ4_FRAME",e[e.ZSTD=1]="ZSTD"})(Dr||(Dr={}));class Le{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 Le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+et),(n||new Le).__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):Dr.LZ4_FRAME}method(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Or.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,n){t.addFieldInt8(0,n,Dr.LZ4_FRAME)}static addMethod(t,n){t.addFieldInt8(1,n,Or.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,n,r){return Le.startBodyCompression(t),Le.addCodec(t,n),Le.addMethod(t,r),Le.endBodyCompression(t)}}class Ka{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,n,r){return t.prep(8,16),t.writeInt64(BigInt(r??0)),t.writeInt64(BigInt(n??0)),t.offset()}}let Qa=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},we=class Vs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsRecordBatch(t,n){return(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+et),(n||new Vs).__init(t.readInt32(t.position())+t.position(),t)}length(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new Qa).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}nodesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new Ka).__init(this.bb.__vector(this.bb_pos+r)+t*16,this.bb):null}buffersLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){const n=this.bb.__offset(this.bb_pos,10);return n?(t||new Le).__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 zs{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsDictionaryBatch(t,n){return(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+et),(n||new zs).__init(t.readInt32(t.position())+t.position(),t)}id(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){const n=this.bb.__offset(this.bb_pos,6);return n?(t||new 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 Mr;(function(e){e[e.DenseArray=0]="DenseArray"})(Mr||(Mr={}));class Ct{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 Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+et),(n||new Ct).__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 Ct.startInt(t),Ct.addBitWidth(t,n),Ct.addIsSigned(t,r),Ct.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()+et),(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 Ct).__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):Mr.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,Mr.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}}class wt{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 wt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+et),(n||new wt).__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 wt.startKeyValue(t),wt.addKey(t,n),wt.addValue(t,r),wt.endKeyValue(t)}}let Xa=class tr{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 tr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+et),(n||new tr).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return tr.startBinary(t),tr.endBinary(t)}},Ja=class er{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 er).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+et),(n||new er).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return er.startBool(t),er.endBool(t)}},Fr=class Tn{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 Tn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+et),(n||new Tn).__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):zt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,zt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,n){return Tn.startDate(t),Tn.addUnit(t,n),Tn.endDate(t)}},un=class je{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 je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+et),(n||new je).__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 je.startDecimal(t),je.addPrecision(t,n),je.addScale(t,r),je.addBitWidth(t,i),je.endDecimal(t)}},Lr=class An{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 An).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+et),(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):$.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,$.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,n){return An.startDuration(t),An.addUnit(t,n),An.endDuration(t)}},xr=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()+et),(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)}},Ur=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()+et),(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()+et),(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):Tt.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,n){t.addFieldInt16(0,n,Tt.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,n){return 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()+et),(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):oe.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,n){t.addFieldInt16(0,n,oe.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,n){return ue.startInterval(t),ue.addUnit(t,n),ue.endInterval(t)}}let Za=class nr{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 nr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+et),(n||new nr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return nr.startLargeBinary(t),nr.endLargeBinary(t)}},to=class rr{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 rr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+et),(n||new rr).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return rr.startLargeUtf8(t),rr.endLargeUtf8(t)}},eo=class ir{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 ir).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+et),(n||new ir).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return ir.startList(t),ir.endList(t)}},Cr=class Nn{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 Nn).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+et),(n||new Nn).__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 Nn.startMap(t),Nn.addKeysSorted(t,n),Nn.endMap(t)}},no=class sr{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 sr).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+et),(n||new sr).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return sr.startNull(t),sr.endNull(t)}};class Je{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 Je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+et),(n||new Je).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Je.startStruct_(t),Je.endStruct_(t)}}class jt{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 jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+et),(n||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.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,$.MILLISECOND)}static addBitWidth(t,n){t.addFieldInt32(1,n,32)}static endTime(t){return t.endObject()}static createTime(t,n,r){return jt.startTime(t),jt.addUnit(t,n),jt.addBitWidth(t,r),jt.endTime(t)}}class Yt{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 Yt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+et),(n||new Yt).__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):$.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,$.SECOND)}static addTimezone(t,n){t.addFieldOffset(1,n,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,n,r){return Yt.startTimestamp(t),Yt.addUnit(t,n),Yt.addTimezone(t,r),Yt.endTimestamp(t)}}class Ft{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsUnion(t,n){return(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+et),(n||new Ft).__init(t.readInt32(t.position())+t.position(),t)}mode(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Et.Sparse}typeIds(t){const n=this.bb.__offset(this.bb_pos,6);return n?this.bb.readInt32(this.bb.__vector(this.bb_pos+n)+t*4):0}typeIdsLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,n){t.addFieldInt16(0,n,Et.Sparse)}static addTypeIds(t,n){t.addFieldOffset(1,n,0)}static createTypeIdsVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addInt32(n[r]);return t.endVector()}static startTypeIdsVector(t,n){t.startVector(4,n,4)}static endUnion(t){return t.endObject()}static createUnion(t,n,r){return Ft.startUnion(t),Ft.addMode(t,n),Ft.addTypeIds(t,r),Ft.endUnion(t)}}let ro=class ar{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 ar).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+et),(n||new ar).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return ar.startUtf8(t),ar.endUtf8(t)}};var ct;(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"})(ct||(ct={}));let Wt=class wi{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 wi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+et),(n||new wi).__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):ct.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 wi).__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 wt).__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,ct.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 De{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 De).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+et),(n||new De).__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 wt).__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 De.startSchema(t),De.addEndianness(t,n),De.addFields(t,r),De.addCustomMetadata(t,i),De.addFeatures(t,s),De.endSchema(t)}};var tt;(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"})(tt||(tt={}));var f;(function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Duration=18]="Duration",e[e.LargeBinary=19]="LargeBinary",e[e.LargeUtf8=20]="LargeUtf8",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth",e[e.DurationSecond=-27]="DurationSecond",e[e.DurationMillisecond=-28]="DurationMillisecond",e[e.DurationMicrosecond=-29]="DurationMicrosecond",e[e.DurationNanosecond=-30]="DurationNanosecond"})(f||(f={}));var 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 Rp=void 0;function jn(e){if(e===null)return"null";if(e===Rp)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=>jn(t))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}`:n)}function lt(e){if(typeof e=="bigint"&&(e<Number.MIN_SAFE_INTEGER||e>Number.MAX_SAFE_INTEGER))throw new TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function io(e,t){return lt(e/t)+lt(e%t)/lt(t)}const Bp=Symbol.for("isArrowBigNum");function Xt(e,...t){return t.length===0?Object.setPrototypeOf(ot(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Xt.prototype[Bp]=!0,Xt.prototype.toJSON=function(){return`"${Wn(this)}"`},Xt.prototype.valueOf=function(e){return so(this,e)},Xt.prototype.toString=function(){return Wn(this)},Xt.prototype[Symbol.toPrimitive]=function(e="default"){switch(e){case"number":return so(this);case"string":return Wn(this);case"default":return Dp(this)}return Wn(this)};function hn(...e){return Xt.apply(this,e)}function dn(...e){return Xt.apply(this,e)}function Yn(...e){return Xt.apply(this,e)}Object.setPrototypeOf(hn.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(dn.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Yn.prototype,Object.create(Uint32Array.prototype)),Object.assign(hn.prototype,Xt.prototype,{constructor:hn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(dn.prototype,Xt.prototype,{constructor:dn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Yn.prototype,Xt.prototype,{constructor:Yn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const Np=BigInt(4294967296)*BigInt(4294967296),Op=Np-BigInt(1);function so(e,t){const{buffer:n,byteOffset:r,byteLength:i,signed:s}=e,a=new BigUint64Array(n,r,i/8),o=s&&a.at(-1)&BigInt(1)<<BigInt(63);let l=BigInt(0),c=0;if(o){for(const d of a)l|=(d^Op)*(BigInt(1)<<BigInt(64*c++));l*=BigInt(-1),l-=BigInt(1)}else for(const d of a)l|=d*(BigInt(1)<<BigInt(64*c++));if(typeof t=="number"){const d=BigInt(Math.pow(10,t)),y=l/d,_=l%d;return lt(y)+lt(_)/lt(d)}return lt(l)}function Wn(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Xi(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Xi(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`-${Xi(t)}`}function Dp(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Wn(e)}function Xi(e){let t="";const n=new Uint32Array(2);let r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const a=r.length-1;do{for(n[0]=r[s=0];s<a;)r[s++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[s];r[s]=n[1]=n[0]/10,n[0]=n[0]-n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}class Ji{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 Yn(t):new dn(t)}static signed(t){return new hn(t)}static unsigned(t){return new dn(t)}static decimal(t){return new Yn(t)}constructor(t,n){return Ji.new(t,n)}}var ao,oo,lo,co,uo,ho,fo,po,yo,mo,bo,go,_o,vo,wo,Io,So,Eo,To,Ao,Ro,Bo;class D{static isNull(t){return(t==null?void 0:t.typeId)===f.Null}static isInt(t){return(t==null?void 0:t.typeId)===f.Int}static isFloat(t){return(t==null?void 0:t.typeId)===f.Float}static isBinary(t){return(t==null?void 0:t.typeId)===f.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===f.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===f.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===f.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===f.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===f.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===f.Date}static isTime(t){return(t==null?void 0:t.typeId)===f.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===f.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===f.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===f.Duration}static isList(t){return(t==null?void 0:t.typeId)===f.List}static isStruct(t){return(t==null?void 0:t.typeId)===f.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===f.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===f.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===f.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===f.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===f.Dictionary}static isDenseUnion(t){return D.isUnion(t)&&t.mode===Et.Dense}static isSparseUnion(t){return D.isUnion(t)&&t.mode===Et.Sparse}constructor(t){this.typeId=t}}ao=Symbol.toStringTag,D[ao]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]="DataType"))(D.prototype);class xe extends D{constructor(){super(f.Null)}toString(){return"Null"}}oo=Symbol.toStringTag,xe[oo]=(e=>e[Symbol.toStringTag]="Null")(xe.prototype);class Ze extends D{constructor(t,n){super(f.Int),this.isSigned=t,this.bitWidth=n}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}lo=Symbol.toStringTag,Ze[lo]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]="Int"))(Ze.prototype);class qn extends Ze{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(qn.prototype,"ArrayType",{value:Int32Array});class $r extends D{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case Tt.HALF:return Uint16Array;case Tt.SINGLE:return Float32Array;case Tt.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}co=Symbol.toStringTag,$r[co]=(e=>(e.precision=null,e[Symbol.toStringTag]="Float"))($r.prototype);class kr extends D{constructor(){super(f.Binary)}toString(){return"Binary"}}uo=Symbol.toStringTag,kr[uo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Binary"))(kr.prototype);class Pr extends D{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}}ho=Symbol.toStringTag,Pr[ho]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeBinary"))(Pr.prototype);class Vr extends D{constructor(){super(f.Utf8)}toString(){return"Utf8"}}fo=Symbol.toStringTag,Vr[fo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Utf8"))(Vr.prototype);class zr extends D{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}}po=Symbol.toStringTag,zr[po]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]="LargeUtf8"))(zr.prototype);class jr extends D{constructor(){super(f.Bool)}toString(){return"Bool"}}yo=Symbol.toStringTag,jr[yo]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]="Bool"))(jr.prototype);class Yr extends D{constructor(t,n,r=128){super(f.Decimal),this.scale=t,this.precision=n,this.bitWidth=r}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}mo=Symbol.toStringTag,Yr[mo]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]="Decimal"))(Yr.prototype);class Wr extends D{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${zt[this.unit]}>`}get ArrayType(){return this.unit===zt.DAY?Int32Array:BigInt64Array}}bo=Symbol.toStringTag,Wr[bo]=(e=>(e.unit=null,e[Symbol.toStringTag]="Date"))(Wr.prototype);class qr extends D{constructor(t,n){super(f.Time),this.unit=t,this.bitWidth=n}toString(){return`Time${this.bitWidth}<${$[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}go=Symbol.toStringTag,qr[go]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]="Time"))(qr.prototype);class Gr extends D{constructor(t,n){super(f.Timestamp),this.unit=t,this.timezone=n}toString(){return`Timestamp<${$[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}_o=Symbol.toStringTag,Gr[_o]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Timestamp"))(Gr.prototype);class Hr extends D{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${oe[this.unit]}>`}}vo=Symbol.toStringTag,Hr[vo]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]="Interval"))(Hr.prototype);class Kr extends D{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${$[this.unit]}>`}}wo=Symbol.toStringTag,Kr[wo]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]="Duration"))(Kr.prototype);class Qr extends D{constructor(t){super(f.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}Io=Symbol.toStringTag,Qr[Io]=(e=>(e.children=null,e[Symbol.toStringTag]="List"))(Qr.prototype);class At extends D{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}So=Symbol.toStringTag,At[So]=(e=>(e.children=null,e[Symbol.toStringTag]="Struct"))(At.prototype);class Xr extends D{constructor(t,n,r){super(f.Union),this.mode=t,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}Eo=Symbol.toStringTag,Xr[Eo]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]="Union"))(Xr.prototype);class Jr extends D{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}To=Symbol.toStringTag,Jr[To]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]="FixedSizeBinary"))(Jr.prototype);class Zr extends D{constructor(t,n){super(f.FixedSizeList),this.listSize=t,this.children=[n]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Ao=Symbol.toStringTag,Zr[Ao]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]="FixedSizeList"))(Zr.prototype);class ti extends D{constructor(t,n=!1){var r,i,s;if(super(f.Map),this.children=[t],this.keysSorted=n,t&&(t.name="entries",!((r=t==null?void 0:t.type)===null||r===void 0)&&r.children)){const a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");const o=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];o&&(o.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Ro=Symbol.toStringTag,ti[Ro]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]="Map_"))(ti.prototype);const Mp=(e=>()=>++e)(-1);class fn extends D{constructor(t,n,r,i){super(f.Dictionary),this.indices=n,this.dictionary=t,this.isOrdered=i||!1,this.id=r==null?Mp():lt(r)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}Bo=Symbol.toStringTag,fn[Bo]=(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 f.Decimal:return e.bitWidth/32;case f.Interval:return 1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}class q{visitMany(t,...n){return t.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,n=!0){return Fp(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 Fp(e,t,n=!0){return typeof t=="number"?pn(e,t,n):typeof t=="string"&&t in f?pn(e,f[t],n):t&&t instanceof D?pn(e,No(t),n):t!=null&&t.type&&t.type instanceof D?pn(e,No(t.type),n):pn(e,f.NONE,n)}function pn(e,t,n=!0){let r=null;switch(t){case f.Null:r=e.visitNull;break;case f.Bool:r=e.visitBool;break;case f.Int:r=e.visitInt;break;case f.Int8:r=e.visitInt8||e.visitInt;break;case f.Int16:r=e.visitInt16||e.visitInt;break;case f.Int32:r=e.visitInt32||e.visitInt;break;case f.Int64:r=e.visitInt64||e.visitInt;break;case f.Uint8:r=e.visitUint8||e.visitInt;break;case f.Uint16:r=e.visitUint16||e.visitInt;break;case f.Uint32:r=e.visitUint32||e.visitInt;break;case f.Uint64:r=e.visitUint64||e.visitInt;break;case f.Float:r=e.visitFloat;break;case f.Float16:r=e.visitFloat16||e.visitFloat;break;case f.Float32:r=e.visitFloat32||e.visitFloat;break;case f.Float64:r=e.visitFloat64||e.visitFloat;break;case f.Utf8:r=e.visitUtf8;break;case f.LargeUtf8:r=e.visitLargeUtf8;break;case f.Binary:r=e.visitBinary;break;case f.LargeBinary:r=e.visitLargeBinary;break;case f.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case f.Date:r=e.visitDate;break;case f.DateDay:r=e.visitDateDay||e.visitDate;break;case f.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case f.Timestamp:r=e.visitTimestamp;break;case f.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case f.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case f.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case f.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case f.Time:r=e.visitTime;break;case f.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case f.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case f.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case f.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case f.Decimal:r=e.visitDecimal;break;case f.List:r=e.visitList;break;case f.Struct:r=e.visitStruct;break;case f.Union:r=e.visitUnion;break;case f.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case f.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case f.Dictionary:r=e.visitDictionary;break;case f.Interval:r=e.visitInterval;break;case f.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case f.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case f.Duration:r=e.visitDuration;break;case f.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case f.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case f.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case f.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case f.FixedSizeList:r=e.visitFixedSizeList;break;case f.Map:r=e.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function No(e){switch(e.typeId){case f.Null:return f.Null;case f.Int:{const{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?f.Int8:f.Uint8;case 16:return n?f.Int16:f.Uint16;case 32:return n?f.Int32:f.Uint32;case 64:return n?f.Int64:f.Uint64}return f.Int}case f.Float:switch(e.precision){case Tt.HALF:return f.Float16;case Tt.SINGLE:return f.Float32;case Tt.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(e.unit){case $.SECOND:return f.TimeSecond;case $.MILLISECOND:return f.TimeMillisecond;case $.MICROSECOND:return f.TimeMicrosecond;case $.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(e.unit){case $.SECOND:return f.TimestampSecond;case $.MILLISECOND:return f.TimestampMillisecond;case $.MICROSECOND:return f.TimestampMicrosecond;case $.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(e.unit){case zt.DAY:return f.DateDay;case zt.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(e.unit){case oe.DAY_TIME:return f.IntervalDayTime;case oe.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(e.unit){case $.SECOND:return f.DurationSecond;case $.MILLISECOND:return f.DurationMillisecond;case $.MICROSECOND:return f.DurationMicrosecond;case $.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(e.mode){case Et.Dense:return f.DenseUnion;case Et.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[e.typeId]}'`)}q.prototype.visitInt8=null,q.prototype.visitInt16=null,q.prototype.visitInt32=null,q.prototype.visitInt64=null,q.prototype.visitUint8=null,q.prototype.visitUint16=null,q.prototype.visitUint32=null,q.prototype.visitUint64=null,q.prototype.visitFloat16=null,q.prototype.visitFloat32=null,q.prototype.visitFloat64=null,q.prototype.visitDateDay=null,q.prototype.visitDateMillisecond=null,q.prototype.visitTimestampSecond=null,q.prototype.visitTimestampMillisecond=null,q.prototype.visitTimestampMicrosecond=null,q.prototype.visitTimestampNanosecond=null,q.prototype.visitTimeSecond=null,q.prototype.visitTimeMillisecond=null,q.prototype.visitTimeMicrosecond=null,q.prototype.visitTimeNanosecond=null,q.prototype.visitDenseUnion=null,q.prototype.visitSparseUnion=null,q.prototype.visitIntervalDayTime=null,q.prototype.visitIntervalYearMonth=null,q.prototype.visitDuration=null,q.prototype.visitDurationSecond=null,q.prototype.visitDurationMillisecond=null,q.prototype.visitDurationMicrosecond=null,q.prototype.visitDurationNanosecond=null;const Oo=new Float64Array(1),yn=new Uint32Array(Oo.buffer);function Do(e){const t=(e&31744)>>10,n=(e&1023)/1024,r=Math.pow(-1,(e&32768)>>15);switch(t){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,t-15)*(1+n)}function Lp(e){if(e!==e)return 32256;Oo[0]=e;const t=(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 k extends q{}function z(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const xp=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Mo=(e,t,n,r)=>{if(n+1<t.length){const i=lt(t[n]),s=lt(t[n+1]);e.set(r.subarray(0,s-i),i)}},Up=({offset:e,values:t},n,r)=>{const i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Te=({values:e},t,n)=>{e[t]=n},Zi=({values:e},t,n)=>{e[t]=n},Fo=({values:e},t,n)=>{e[t]=Lp(n)},Cp=(e,t,n)=>{switch(e.type.precision){case Tt.HALF:return Fo(e,t,n);case Tt.SINGLE:case Tt.DOUBLE:return Zi(e,t,n)}},Lo=({values:e},t,n)=>{xp(e,t,n.valueOf())},xo=({values:e},t,n)=>{e[t]=BigInt(n)},$p=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},Uo=({values:e,valueOffsets:t},n,r)=>Mo(e,t,n,r),Co=({values:e,valueOffsets:t},n,r)=>Mo(e,t,n,ji(r)),kp=(e,t,n)=>{e.type.unit===zt.DAY?Lo(e,t,n):xo(e,t,n)},$o=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},ko=({values:e},t,n)=>{e[t]=BigInt(n)},Po=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},Vo=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},Pp=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return $o(e,t,n);case $.MILLISECOND:return ko(e,t,n);case $.MICROSECOND:return Po(e,t,n);case $.NANOSECOND:return Vo(e,t,n)}},zo=({values:e},t,n)=>{e[t]=n},jo=({values:e},t,n)=>{e[t]=n},Yo=({values:e},t,n)=>{e[t]=n},Wo=({values:e},t,n)=>{e[t]=n},Vp=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return zo(e,t,n);case $.MILLISECOND:return jo(e,t,n);case $.MICROSECOND:return Yo(e,t,n);case $.NANOSECOND:return Wo(e,t,n)}},zp=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},jp=(e,t,n)=>{const r=e.children[0],i=e.valueOffsets,s=qt.getVisitFn(r);if(Array.isArray(n))for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n[++a]);else for(let a=-1,o=i[t],l=i[t+1];o<l;)s(r,o++,n.get(++a))},Yp=(e,t,n)=>{const r=e.children[0],{valueOffsets:i}=e,s=qt.getVisitFn(r);let{[t]:a,[t+1]:o}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const c of l)if(s(r,a,c),++a>=o)break},Wp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[s]),qp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(s)),Gp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t.get(i.name)),Hp=(e,t)=>(n,r,i,s)=>r&&n(r,e,t[i.name]),Kp=(e,t,n)=>{const r=e.type.children.map(s=>qt.getVisitFn(s.type)),i=n instanceof Map?Gp(t,n):n instanceof nt?qp(t,n):Array.isArray(n)?Wp(t,n):Hp(t,n);e.type.children.forEach((s,a)=>i(r[a],e.children[a],s,a))},Qp=(e,t,n)=>{e.type.mode===Et.Dense?qo(e,t,n):Go(e,t,n)},qo=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];qt.visit(i,e.valueOffsets[t],n)},Go=(e,t,n)=>{const r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];qt.visit(i,t,n)},Xp=(e,t,n)=>{var r;(r=e.dictionary)===null||r===void 0||r.set(e.values[t],n)},Jp=(e,t,n)=>{e.type.unit===oe.DAY_TIME?Ho(e,t,n):Ko(e,t,n)},Ho=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Ko=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Qo=({values:e},t,n)=>{e[t]=n},Xo=({values:e},t,n)=>{e[t]=n},Jo=({values:e},t,n)=>{e[t]=n},Zo=({values:e},t,n)=>{e[t]=n},Zp=(e,t,n)=>{switch(e.type.unit){case $.SECOND:return Qo(e,t,n);case $.MILLISECOND:return Xo(e,t,n);case $.MICROSECOND:return Jo(e,t,n);case $.NANOSECOND:return Zo(e,t,n)}},ty=(e,t,n)=>{const{stride:r}=e,i=e.children[0],s=qt.getVisitFn(i);if(Array.isArray(n))for(let a=-1,o=t*r;++a<r;)s(i,o+a,n[a]);else for(let a=-1,o=t*r;++a<r;)s(i,o+a,n.get(a))};k.prototype.visitBool=z(Up),k.prototype.visitInt=z(Te),k.prototype.visitInt8=z(Te),k.prototype.visitInt16=z(Te),k.prototype.visitInt32=z(Te),k.prototype.visitInt64=z(Te),k.prototype.visitUint8=z(Te),k.prototype.visitUint16=z(Te),k.prototype.visitUint32=z(Te),k.prototype.visitUint64=z(Te),k.prototype.visitFloat=z(Cp),k.prototype.visitFloat16=z(Fo),k.prototype.visitFloat32=z(Zi),k.prototype.visitFloat64=z(Zi),k.prototype.visitUtf8=z(Co),k.prototype.visitLargeUtf8=z(Co),k.prototype.visitBinary=z(Uo),k.prototype.visitLargeBinary=z(Uo),k.prototype.visitFixedSizeBinary=z($p),k.prototype.visitDate=z(kp),k.prototype.visitDateDay=z(Lo),k.prototype.visitDateMillisecond=z(xo),k.prototype.visitTimestamp=z(Pp),k.prototype.visitTimestampSecond=z($o),k.prototype.visitTimestampMillisecond=z(ko),k.prototype.visitTimestampMicrosecond=z(Po),k.prototype.visitTimestampNanosecond=z(Vo),k.prototype.visitTime=z(Vp),k.prototype.visitTimeSecond=z(zo),k.prototype.visitTimeMillisecond=z(jo),k.prototype.visitTimeMicrosecond=z(Yo),k.prototype.visitTimeNanosecond=z(Wo),k.prototype.visitDecimal=z(zp),k.prototype.visitList=z(jp),k.prototype.visitStruct=z(Kp),k.prototype.visitUnion=z(Qp),k.prototype.visitDenseUnion=z(qo),k.prototype.visitSparseUnion=z(Go),k.prototype.visitDictionary=z(Xp),k.prototype.visitInterval=z(Jp),k.prototype.visitIntervalDayTime=z(Ho),k.prototype.visitIntervalYearMonth=z(Ko),k.prototype.visitDuration=z(Zp),k.prototype.visitDurationSecond=z(Qo),k.prototype.visitDurationMillisecond=z(Xo),k.prototype.visitDurationMicrosecond=z(Jo),k.prototype.visitDurationNanosecond=z(Zo),k.prototype.visitFixedSizeList=z(ty),k.prototype.visitMap=z(Yp);const qt=new k,Jt=Symbol.for("parent"),mn=Symbol.for("rowIndex");class ts{constructor(t,n){return this[Jt]=t,this[mn]=n,new Proxy(this,new ny)}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[mn],n=this[Jt],r=n.type.children,i={};for(let s=-1,a=r.length;++s<a;)i[r[s].name]=Lt.visit(n.children[s],t);return i}toString(){return`{${[...this].map(([t,n])=>`${jn(t)}: ${jn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ey(this[Jt],this[mn])}}class ey{constructor(t,n){this.childIndex=0,this.children=t.children,this.rowIndex=n,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Lt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}}Object.defineProperties(ts.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Jt]:{writable:!0,enumerable:!1,configurable:!1,value:null},[mn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});class ny{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Jt].type.children.map(n=>n.name)}has(t,n){return t[Jt].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(t,n){if(t[Jt].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[Jt].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Lt.visit(t[Jt].children[r],t[mn]);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[Jt].type.children.findIndex(s=>s.name===n);return i!==-1?(qt.visit(t[Jt].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 q{}function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const ry=(e,t)=>864e5*e[t],iy=(e,t)=>null,tl=(e,t,n)=>{if(n+1>=t.length)return null;const r=lt(t[n]),i=lt(t[n+1]);return e.subarray(r,i)},sy=({offset:e,values:t},n)=>{const r=e+n;return(t[r>>3]&1<<r%8)!==0},el=({values:e},t)=>ry(e,t),nl=({values:e},t)=>lt(e[t]),Ue=({stride:e,values:t},n)=>t[e*n],ay=({stride:e,values:t},n)=>Do(t[e*n]),rl=({values:e},t)=>e[t],oy=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),il=({values:e,valueOffsets:t},n)=>tl(e,t,n),sl=({values:e,valueOffsets:t},n)=>{const r=tl(e,t,n);return r!==null?zi(r):null},ly=({values:e},t)=>e[t],cy=({type:e,values:t},n)=>e.precision!==Tt.HALF?t[n]:Do(t[n]),uy=(e,t)=>e.type.unit===zt.DAY?el(e,t):nl(e,t),al=({values:e},t)=>1e3*lt(e[t]),ol=({values:e},t)=>lt(e[t]),ll=({values:e},t)=>io(e[t],BigInt(1e3)),cl=({values:e},t)=>io(e[t],BigInt(1e6)),hy=(e,t)=>{switch(e.type.unit){case $.SECOND:return al(e,t);case $.MILLISECOND:return ol(e,t);case $.MICROSECOND:return ll(e,t);case $.NANOSECOND:return cl(e,t)}},ul=({values:e},t)=>e[t],hl=({values:e},t)=>e[t],dl=({values:e},t)=>e[t],fl=({values:e},t)=>e[t],dy=(e,t)=>{switch(e.type.unit){case $.SECOND:return ul(e,t);case $.MILLISECOND:return hl(e,t);case $.MICROSECOND:return dl(e,t);case $.NANOSECOND:return fl(e,t)}},fy=({values:e,stride:t},n)=>Ji.decimal(e.subarray(t*n,t*(n+1))),py=(e,t)=>{const{valueOffsets:n,stride:r,children:i}=e,{[t*r]:s,[t*r+1]:a}=n,o=i[0].slice(s,a-s);return new nt([o])},yy=(e,t)=>{const{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:s}=n,a=r[0];return new ns(a.slice(i,s-i))},my=(e,t)=>new ts(e,t),by=(e,t)=>e.type.mode===Et.Dense?pl(e,t):yl(e,t),pl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Lt.visit(r,e.valueOffsets[t])},yl=(e,t)=>{const n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return Lt.visit(r,t)},gy=(e,t)=>{var n;return(n=e.dictionary)===null||n===void 0?void 0:n.get(e.values[t])},_y=(e,t)=>e.type.unit===oe.DAY_TIME?ml(e,t):bl(e,t),ml=({values:e},t)=>e.subarray(2*t,2*(t+1)),bl=({values:e},t)=>{const n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},gl=({values:e},t)=>e[t],_l=({values:e},t)=>e[t],vl=({values:e},t)=>e[t],wl=({values:e},t)=>e[t],vy=(e,t)=>{switch(e.type.unit){case $.SECOND:return gl(e,t);case $.MILLISECOND:return _l(e,t);case $.MICROSECOND:return vl(e,t);case $.NANOSECOND:return wl(e,t)}},wy=(e,t)=>{const{stride:n,children:r}=e,i=r[0].slice(t*n,n);return new nt([i])};L.prototype.visitNull=P(iy),L.prototype.visitBool=P(sy),L.prototype.visitInt=P(ly),L.prototype.visitInt8=P(Ue),L.prototype.visitInt16=P(Ue),L.prototype.visitInt32=P(Ue),L.prototype.visitInt64=P(rl),L.prototype.visitUint8=P(Ue),L.prototype.visitUint16=P(Ue),L.prototype.visitUint32=P(Ue),L.prototype.visitUint64=P(rl),L.prototype.visitFloat=P(cy),L.prototype.visitFloat16=P(ay),L.prototype.visitFloat32=P(Ue),L.prototype.visitFloat64=P(Ue),L.prototype.visitUtf8=P(sl),L.prototype.visitLargeUtf8=P(sl),L.prototype.visitBinary=P(il),L.prototype.visitLargeBinary=P(il),L.prototype.visitFixedSizeBinary=P(oy),L.prototype.visitDate=P(uy),L.prototype.visitDateDay=P(el),L.prototype.visitDateMillisecond=P(nl),L.prototype.visitTimestamp=P(hy),L.prototype.visitTimestampSecond=P(al),L.prototype.visitTimestampMillisecond=P(ol),L.prototype.visitTimestampMicrosecond=P(ll),L.prototype.visitTimestampNanosecond=P(cl),L.prototype.visitTime=P(dy),L.prototype.visitTimeSecond=P(ul),L.prototype.visitTimeMillisecond=P(hl),L.prototype.visitTimeMicrosecond=P(dl),L.prototype.visitTimeNanosecond=P(fl),L.prototype.visitDecimal=P(fy),L.prototype.visitList=P(py),L.prototype.visitStruct=P(my),L.prototype.visitUnion=P(by),L.prototype.visitDenseUnion=P(pl),L.prototype.visitSparseUnion=P(yl),L.prototype.visitDictionary=P(gy),L.prototype.visitInterval=P(_y),L.prototype.visitIntervalDayTime=P(ml),L.prototype.visitIntervalYearMonth=P(bl),L.prototype.visitDuration=P(vy),L.prototype.visitDurationSecond=P(gl),L.prototype.visitDurationMillisecond=P(_l),L.prototype.visitDurationMicrosecond=P(vl),L.prototype.visitDurationNanosecond=P(wl),L.prototype.visitFixedSizeList=P(wy),L.prototype.visitMap=P(yy);const Lt=new L,bn=Symbol.for("keys"),gn=Symbol.for("vals"),_n=Symbol.for("kKeysAsStrings"),es=Symbol.for("_kKeysAsStrings");class ns{constructor(t){return this[bn]=new nt([t.children[0]]).memoize(),this[gn]=t.children[1],new Proxy(this,new Sy)}get[_n](){return this[es]||(this[es]=Array.from(this[bn].toArray(),String))}[Symbol.iterator](){return new Iy(this[bn],this[gn])}get size(){return this[bn].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[bn],n=this[gn],r={};for(let i=-1,s=t.length;++i<s;)r[t.get(i)]=Lt.visit(n,i);return r}toString(){return`{${[...this].map(([t,n])=>`${jn(t)}: ${jn(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class Iy{constructor(t,n){this.keys=t,this.vals=n,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){const t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Lt.visit(this.vals,t)]})}}class Sy{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[_n]}has(t,n){return t[_n].includes(n)}getOwnPropertyDescriptor(t,n){if(t[_n].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,n){if(Reflect.has(t,n))return t[n];const r=t[_n].indexOf(n);if(r!==-1){const i=Lt.visit(Reflect.get(t,gn),r);return Reflect.set(t,n,i),i}}set(t,n,r){const i=t[_n].indexOf(n);return i!==-1?(qt.visit(Reflect.get(t,gn),i,r),Reflect.set(t,n,r)):Reflect.has(t,n)?Reflect.set(t,n,r):!1}}Object.defineProperties(ns.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[bn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[gn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[es]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Il;function Sl(e,t,n,r){const{length:i=0}=e;let s=typeof t!="number"?0:t,a=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(Il=s,s=a,a=Il),a>i&&(a=i),r?r(e,s,a):[s,a]}const rs=(e,t)=>e<0?t+e:e,El=e=>e!==e;function vn(e){if(typeof e!="object"||e===null)return El(e)?El:t=>t===e;if(e instanceof Date){const t=e.valueOf();return n=>n instanceof Date?n.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?wp(e,t):!1:e instanceof Map?Ty(e):Array.isArray(e)?Ey(e):e instanceof nt?Ay(e):Ry(e,!0)}function Ey(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=vn(e[n]);return ei(t)}function Ty(e){let t=-1;const n=[];for(const r of e.values())n[++t]=vn(r);return ei(n)}function Ay(e){const t=[];for(let n=-1,r=e.length;++n<r;)t[n]=vn(e.get(n));return ei(t)}function Ry(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 ei(r,n)}function ei(e,t){return n=>{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return By(e,n);case Map:return Tl(e,n,n.keys());case ns:case ts:case Object:case void 0:return Tl(e,n,t||Object.keys(n))}return n instanceof nt?Ny(e,n):!1}}function By(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function Ny(e,t){const n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Tl(e,t,n){const r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator]();let a=0;const o=e.length;let l=s.next(),c=r.next(),d=i.next();for(;a<o&&!c.done&&!d.done&&!l.done&&!(c.value!==d.value||!e[a](l.value));++a,c=r.next(),d=i.next(),l=s.next());return a===o&&c.done&&d.done&&l.done?!0:(r.return&&r.return(),i.return&&i.return(),s.return&&s.return(),!1)}function Al(e,t,n,r){return(n&1<<r)!==0}function Oy(e,t,n,r){return(n&1<<r)>>r}function ni(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):ri(new is(n,e,t,null,Al)).subarray(0,r)),i}return n}function ri(e){const t=[];let n=0,r=0,i=0;for(const a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class is{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 ss(e,t,n){if(n-t<=0)return 0;if(n-t<8){let s=0;for(const a of new is(e,t,n-t,e,Oy))s+=a;return s}const r=n>>3<<3,i=t+(t%8===0?0:8-t%8);return ss(e,t,i)+ss(e,r,n)+Dy(e,i>>3,r-i>>3)}function Dy(e,t,n){let r=0,i=Math.trunc(t);const s=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n===void 0?e.byteLength:i+n;for(;a-i>=4;)r+=as(s.getUint32(i)),i+=4;for(;a-i>=2;)r+=as(s.getUint16(i)),i+=2;for(;a-i>=1;)r+=as(s.getUint8(i)),i+=1;return r}function as(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 My=-1;class it{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){const{type:t}=this;return D.isSparseUnion(t)?this.children.some(n=>n.nullable):D.isDenseUnion(t)?this.children.some(n=>n.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(t+=n.byteLength),r&&(t+=r.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,o)=>a+o.byteLength,t)}get nullCount(){if(D.isUnion(this.type))return this.children.reduce((r,i)=>r+i.nullCount,0);let t=this._nullCount,n;return t<=My&&(n=this.nullBitmap)&&(this._nullCount=t=n.length===0?0:this.length-ss(n,this.offset,this.offset+this.length)),t}constructor(t,n,r,i,s,a=[],o){this.type=t,this.children=a,this.dictionary=o,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof it?(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(D.isUnion(n)){const r=n,i=this.children[r.typeIdToChildIndex[this.typeIds[t]]],s=r.mode===Et.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){const r=this.offset+t;return(this.nullBitmap[r>>3]&1<<r%8)!==0}return!0}setValid(t,n){let r;const{type:i}=this;if(D.isUnion(i)){const s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],o=s.mode===Et.Dense?this.valueOffsets[t]:t;r=a.getValid(o),a.setValid(o,n)}else{let{nullBitmap:s}=this;const{offset:a,length:o}=this,l=a+t,c=1<<l%8,d=l>>3;(!s||s.byteLength<=d)&&(s=new Uint8Array((a+o+63&-64)>>3).fill(255),this.nullCount>0?(s.set(ni(a,o,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const y=s[d];r=(y&c)!==0,s[d]=n?y|c:y&~c}return r!==!!n&&(this._nullCount=this.nullCount+(n?-1:1)),n}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,s=this,a=this.children){return new it(t,n,r,i,s,a,this.dictionary)}slice(t,n){const{stride:r,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,o=i===16?r:1,l=this._sliceBuffers(t,n,r,i);return this.clone(this.type,this.offset+t,n,a,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,o*t,o*n))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===f.Null)return this.clone(this.type,0,t,0);const{length:n,nullCount:r}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,n>>3);i[n>>3]=(1<<n-(n&-8))-1,r>0&&i.set(ni(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:a}=this;return(s=a[Se.TYPE])&&(a[Se.TYPE]=s.subarray(t,t+n)),(s=a[Se.OFFSET])&&(a[Se.OFFSET]=s.subarray(t,t+n+1))||(s=a[Se.DATA])&&(a[Se.DATA]=i===6?s:s.subarray(r*t,r*(t+n))),a}_sliceChildren(t,n,r){return t.map(i=>i.slice(n,r))}}it.prototype.children=Object.freeze([]);class Gn extends q{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=t;return new it(n,r,i,i)}visitBool(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitInt(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitFloat(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),a=zn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,i,s])}visitLargeUtf8(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,i,s])}visitBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),a=zn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,i,s])}visitLargeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.data),s=Q(t.nullBitmap),a=ja(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,i,s])}visitFixedSizeBinary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitDate(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitTimestamp(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitTime(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitDecimal(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitList(t){const{["type"]:n,["offset"]:r=0,["child"]:i}=t,s=Q(t.nullBitmap),a=zn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,void 0,s],[i])}visitStruct(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=Q(t.nullBitmap),{length:a=i.reduce((l,{length:c})=>Math.max(l,c),0),nullCount:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,void 0,s],i)}visitUnion(t){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=t,s=ot(n.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:o=-1}=t;if(D.isSparseUnion(n))return new it(n,r,a,o,[void 0,void 0,void 0,s],i);const l=zn(t.valueOffsets);return new it(n,r,a,o,[l,void 0,void 0,s],i)}visitDictionary(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.indices.ArrayType,t.data),{["dictionary"]:a=new nt([new Gn().visit({type:n.dictionary})])}=t,{["length"]:o=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[void 0,s,i],[],a)}visitInterval(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitDuration(t){const{["type"]:n,["offset"]:r=0}=t,i=Q(t.nullBitmap),s=ot(n.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,s,i])}visitFixedSizeList(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Gn().visit({type:n.valueType})}=t,s=Q(t.nullBitmap),{["length"]:a=i.length/Ee(n),["nullCount"]:o=t.nullBitmap?-1:0}=t;return new it(n,r,a,o,[void 0,void 0,s],[i])}visitMap(t){const{["type"]:n,["offset"]:r=0,["child"]:i=new Gn().visit({type:n.childType})}=t,s=Q(t.nullBitmap),a=zn(t.valueOffsets),{["length"]:o=a.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new it(n,r,o,l,[a,void 0,s],[i])}}const Fy=new Gn;function H(e){return Fy.visit(e)}class Rl{constructor(t=0,n){this.numChunks=t,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){const t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function Ly(e){return e.some(t=>t.nullable)}function Bl(e){return e.reduce((t,n)=>t+n.nullCount,0)}function Nl(e){return e.reduce((t,n,r)=>(t[r+1]=t[r]+n.length,t),new Uint32Array(e.length+1))}function Ol(e,t,n,r){const i=[];for(let s=-1,a=e.length;++s<a;){const o=e[s],l=t[s],{length:c}=o;if(l>=r)break;if(n>=l+c)continue;if(l>=n&&l+c<=r){i.push(o);continue}const d=Math.max(0,n-l),y=Math.min(r-l,c);i.push(o.slice(d,y-d))}return i.length===0&&i.push(e[0].slice(0,0)),i}function os(e,t,n,r){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return n<t[a]?r(e,i,n-t[i]):null;s=i+Math.trunc((a-i)*.5),n<t[s]?a=s:i=s}while(i<a)}function ls(e,t){return e.getValid(t)}function ii(e){function t(n,r,i){return e(n[r],i)}return function(n){const r=this.data;return os(r,this._offsets,n,t)}}function Dl(e){let t;function n(r,i,s){return e(r[i],s,t)}return function(r,i){const s=this.data;t=i;const a=os(s,this._offsets,r,n);return t=void 0,a}}function Ml(e){let t;function n(r,i,s){let a=s,o=0,l=0;for(let c=i-1,d=r.length;++c<d;){const y=r[c];if(~(o=e(y,t,a)))return l+o;a=0,l+=y.length}return-1}return function(r,i){t=r;const s=this.data,a=typeof i!="number"?n(s,0,0):os(s,this._offsets,i,n);return t=void 0,a}}class x extends q{}function xy(e,t){return t===null&&e.length>0?0:-1}function Uy(e,t){const{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(const i of new is(n,e.offset+(t||0),e.length,n,Al)){if(!i)return r;++r}return-1}function j(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case f.Union:break;case f.Dictionary:break;default:return Uy(e,n)}const r=Lt.getVisitFn(e),i=vn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}function Fl(e,t,n){const r=Lt.getVisitFn(e),i=vn(t);for(let s=(n||0)-1,a=e.length;++s<a;)if(i(r(e,s)))return s;return-1}x.prototype.visitNull=xy,x.prototype.visitBool=j,x.prototype.visitInt=j,x.prototype.visitInt8=j,x.prototype.visitInt16=j,x.prototype.visitInt32=j,x.prototype.visitInt64=j,x.prototype.visitUint8=j,x.prototype.visitUint16=j,x.prototype.visitUint32=j,x.prototype.visitUint64=j,x.prototype.visitFloat=j,x.prototype.visitFloat16=j,x.prototype.visitFloat32=j,x.prototype.visitFloat64=j,x.prototype.visitUtf8=j,x.prototype.visitLargeUtf8=j,x.prototype.visitBinary=j,x.prototype.visitLargeBinary=j,x.prototype.visitFixedSizeBinary=j,x.prototype.visitDate=j,x.prototype.visitDateDay=j,x.prototype.visitDateMillisecond=j,x.prototype.visitTimestamp=j,x.prototype.visitTimestampSecond=j,x.prototype.visitTimestampMillisecond=j,x.prototype.visitTimestampMicrosecond=j,x.prototype.visitTimestampNanosecond=j,x.prototype.visitTime=j,x.prototype.visitTimeSecond=j,x.prototype.visitTimeMillisecond=j,x.prototype.visitTimeMicrosecond=j,x.prototype.visitTimeNanosecond=j,x.prototype.visitDecimal=j,x.prototype.visitList=j,x.prototype.visitStruct=j,x.prototype.visitUnion=j,x.prototype.visitDenseUnion=Fl,x.prototype.visitSparseUnion=Fl,x.prototype.visitDictionary=j,x.prototype.visitInterval=j,x.prototype.visitIntervalDayTime=j,x.prototype.visitIntervalYearMonth=j,x.prototype.visitDuration=j,x.prototype.visitDurationSecond=j,x.prototype.visitDurationMillisecond=j,x.prototype.visitDurationMicrosecond=j,x.prototype.visitDurationNanosecond=j,x.prototype.visitFixedSizeList=j,x.prototype.visitMap=j;const si=new x;class U extends q{}function V(e){const{type:t}=e;if(e.nullCount===0&&e.stride===1&&(D.isInt(t)&&t.bitWidth!==64||D.isTime(t)&&t.bitWidth!==64||D.isFloat(t)&&t.precision!==Tt.HALF))return new Rl(e.data.length,r=>{const i=e.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new Rl(e.data.length,r=>{const i=e.data[r].length,s=e.slice(n,n+i);return n+=i,new Cy(s)})}class Cy{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}U.prototype.visitNull=V,U.prototype.visitBool=V,U.prototype.visitInt=V,U.prototype.visitInt8=V,U.prototype.visitInt16=V,U.prototype.visitInt32=V,U.prototype.visitInt64=V,U.prototype.visitUint8=V,U.prototype.visitUint16=V,U.prototype.visitUint32=V,U.prototype.visitUint64=V,U.prototype.visitFloat=V,U.prototype.visitFloat16=V,U.prototype.visitFloat32=V,U.prototype.visitFloat64=V,U.prototype.visitUtf8=V,U.prototype.visitLargeUtf8=V,U.prototype.visitBinary=V,U.prototype.visitLargeBinary=V,U.prototype.visitFixedSizeBinary=V,U.prototype.visitDate=V,U.prototype.visitDateDay=V,U.prototype.visitDateMillisecond=V,U.prototype.visitTimestamp=V,U.prototype.visitTimestampSecond=V,U.prototype.visitTimestampMillisecond=V,U.prototype.visitTimestampMicrosecond=V,U.prototype.visitTimestampNanosecond=V,U.prototype.visitTime=V,U.prototype.visitTimeSecond=V,U.prototype.visitTimeMillisecond=V,U.prototype.visitTimeMicrosecond=V,U.prototype.visitTimeNanosecond=V,U.prototype.visitDecimal=V,U.prototype.visitList=V,U.prototype.visitStruct=V,U.prototype.visitUnion=V,U.prototype.visitDenseUnion=V,U.prototype.visitSparseUnion=V,U.prototype.visitDictionary=V,U.prototype.visitInterval=V,U.prototype.visitIntervalDayTime=V,U.prototype.visitIntervalYearMonth=V,U.prototype.visitDuration=V,U.prototype.visitDurationSecond=V,U.prototype.visitDurationMillisecond=V,U.prototype.visitDurationMicrosecond=V,U.prototype.visitDurationNanosecond=V,U.prototype.visitFixedSizeList=V,U.prototype.visitMap=V;const cs=new U;var Ll;const xl={},Ul={};class nt{constructor(t){var n,r,i;const s=t[0]instanceof nt?t.flatMap(o=>o.data):t;if(s.length===0||s.some(o=>!(o instanceof it)))throw new TypeError("Vector constructor expects an Array of Data instances.");const a=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:o,set:l,indexOf:c}=xl[a.typeId],d=s[0];this.isValid=y=>ls(d,y),this.get=y=>o(d,y),this.set=(y,_)=>l(d,y,_),this.indexOf=y=>c(d,y),this._offsets=[0,d.length];break}default:Object.setPrototypeOf(this,Ul[a.typeId]),this._offsets=Nl(s);break}this.data=s,this.type=a,this.stride=Ee(a),this.numChildren=(i=(r=a.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,n)=>t+n.byteLength,0)}get nullable(){return Ly(this.data)}get nullCount(){return Bl(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(rs(t,this.length))}set(t,n){}indexOf(t,n){return-1}includes(t,n){return this.indexOf(t,n)>-1}[Symbol.iterator](){return cs.visit(this)}concat(...t){return new nt(this.data.concat(t.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(t,n){return new nt(Sl(this,t,n,({data:r,_offsets:i},s,a)=>Ol(r,i,s,a)))}toJSON(){return[...this]}toArray(){const{type:t,data:n,length:r,stride:i,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((a,{values:o,length:l})=>(a.array.set(o.subarray(0,l*i),a.offset),a.offset+=l*i,a),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new nt(this.data.map(({children:n})=>n[t])):null}get isMemoized(){return D.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(D.isDictionary(this.type)){const t=new ai(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new nt(n)}return new ai(this)}unmemoize(){if(D.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=t,i});return new nt(n)}return this}}Ll=Symbol.toStringTag,nt[Ll]=(e=>{e.type=D.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;const t=Object.keys(f).map(n=>f[n]).filter(n=>typeof n=="number"&&n!==f.NONE);for(const n of t){const r=Lt.getVisitFnByTypeId(n),i=qt.getVisitFnByTypeId(n),s=si.getVisitFnByTypeId(n);xl[n]={get:r,set:i,indexOf:s},Ul[n]=Object.create(e,{isValid:{value:ii(ls)},get:{value:ii(Lt.getVisitFnByTypeId(n))},set:{value:Dl(qt.getVisitFnByTypeId(n))},indexOf:{value:Ml(si.getVisitFnByTypeId(n))}})}return"Vector"})(nt.prototype);class ai extends nt{constructor(t){super(t.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){const o=s[a];if(o!==void 0)return o;const l=n.call(this,a);return s[a]=l,l}}),Object.defineProperty(this,"set",{value(a,o){r.call(this,a,o),s[a]=o}}),Object.defineProperty(this,"slice",{value:(a,o)=>new ai(i.call(this,a,o))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new nt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class us{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 $t{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 $t).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+et),(n||new $t).__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):mt.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 us).__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 us).__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 wt).__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,mt.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 rt{constructor(t=[],n,r,i=mt.V5){this.fields=t||[],this.metadata=n||new Map,r||(r=hs(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 rt(r,this.metadata)}selectAt(t){const n=t.map(r=>this.fields[r]).filter(Boolean);return new rt(n,this.metadata)}assign(...t){const n=t[0]instanceof rt?t[0]:Array.isArray(t[0])?new rt(t[0]):new rt(t),r=[...this.fields],i=oi(oi(new Map,this.metadata),n.metadata),s=n.fields.filter(o=>{const l=r.findIndex(c=>c.name===o.name);return~l?(r[l]=o.clone({metadata:oi(oi(new Map,r[l].metadata),o.metadata)}))&&!1:!0}),a=hs(s,new Map);return new rt([...r,...s],i,new Map([...this.dictionaries,...a]))}}rt.prototype.fields=null,rt.prototype.metadata=null,rt.prototype.dictionaries=null;class ut{static new(...t){let[n,r,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new ut(`${n}`,r,i,s)}constructor(t,n,r=!1,i){this.name=t,this.type=n,this.nullable=r,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,s]=t;return!t[0]||typeof t[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],ut.new(n,r,i,s)}}ut.prototype.type=null,ut.prototype.name=null,ut.prototype.nullable=null,ut.prototype.metadata=null;function oi(e,t){return new Map([...e||new Map,...t||new Map])}function hs(e,t=new Map){for(let n=-1,r=e.length;++n<r;){const i=e[n].type;if(D.isDictionary(i)){if(!t.has(i.id))t.set(i.id,i.dictionary);else if(t.get(i.id)!==i.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}i.children&&i.children.length>0&&hs(i.children,t)}return t}var $y=Ha,ky=on;class Hn{static decode(t){t=new ky(Q(t));const n=$t.getRootAsFooter(t),r=rt.decode(n.schema(),new Map,n.version());return new Py(r,n)}static encode(t){const n=new $y,r=rt.encode(n,t.schema);$t.startRecordBatchesVector(n,t.numRecordBatches);for(const a of[...t.recordBatches()].slice().reverse())Ce.encode(n,a);const i=n.endVector();$t.startDictionariesVector(n,t.numDictionaries);for(const a of[...t.dictionaryBatches()].slice().reverse())Ce.encode(n,a);const s=n.endVector();return $t.startFooter(n),$t.addSchema(n,r),$t.addVersion(n,mt.V5),$t.addRecordBatches(n,i),$t.addDictionaries(n,s),$t.finishFooterBuffer(n,$t.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,n=mt.V5,r,i){this.schema=t,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,n=-1,r=this.numRecordBatches;++n<r;)(t=this.getRecordBatch(n))&&(yield t)}*dictionaryBatches(){for(let t,n=-1,r=this.numDictionaries;++n<r;)(t=this.getDictionaryBatch(n))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}}class Py extends Hn{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 us.createBlock(t,i,r,s)}constructor(t,n,r){this.metaDataLength=t,this.offset=lt(r),this.bodyLength=lt(n)}}const It=Object.freeze({done:!0,value:void 0});class Cl{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}}class ds{tee(){return this._getDOMStream().tee()}pipe(t,n){return this._getNodeStream().pipe(t,n)}pipeTo(t,n){return this._getDOMStream().pipeTo(t,n)}pipeThrough(t,n){return this._getDOMStream().pipeThrough(t,n)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}}class Vy extends ds{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(It);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Vt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Vt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Y(this,void 0,void 0,function*(){return yield this.abort(t),It})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),It})}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(It)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class li extends Vy{write(t){if((t=Q(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?zi(this.toUint8Array(!0)):this.toUint8Array(!1).then(zi)}toUint8Array(t=!1){return t?ae(this._values)[0]:Y(this,void 0,void 0,function*(){var n,r,i,s;const a=[];let o=0;try{for(var l=!0,c=Qe(this),d;d=yield c.next(),n=d.done,!n;l=!0){s=d.value,l=!1;const y=s;a.push(y),o+=y.byteLength}}catch(y){r={error:y}}finally{try{!l&&!n&&(i=c.return)&&(yield i.call(c))}finally{if(r)throw r.error}}return ae(a,o)[0]})}}class ci{constructor(t){t&&(this.source=new zy(Vt.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 li?this.source=new tn(Vt.fromAsyncIterable(t)):Va(t)?this.source=new tn(Vt.fromNodeStream(t)):Wi(t)?this.source=new tn(Vt.fromDOMStream(t)):Pa(t)?this.source=new tn(Vt.fromDOMStream(t.body)):Vn(t)?this.source=new tn(Vt.fromIterable(t)):Xe(t)?this.source=new tn(Vt.fromAsyncIterable(t)):an(t)&&(this.source=new tn(Vt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}}class zy{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,n="read"){return this.source.next({cmd:n,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||It)}return(t){return Object.create(this.source.return&&this.source.return(t)||It)}}class tn{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))||It;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))||It;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class $l extends ci{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 ui 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,a=0,o=0;const l=Math.min(r,s+Math.min(r-s,t)),c=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=o)<l&&(a+=o)<c.byteLength;)({bytesRead:o}=yield n.read(c,a,c.byteLength-a,s));return c}return null})}readAt(t,n){return Y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);const{_handle:r,size:i}=this;if(r&&t+n<i){const s=Math.min(i,t+n),a=new Uint8Array(s-t);return(yield r.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return Y(this,void 0,void 0,function*(){const t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return Y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}}const jy=65536;function In(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Sn=8,fs=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class kl{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const n=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?jy:0,this.buffer[1]+=s>>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(t){const n=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],n<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${In(this.buffer[1])} ${In(this.buffer[0])}`}}class st extends kl{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,n=new Uint32Array(2)){return st.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return st.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.length,i=new st(n);for(let s=0;s<r;){const a=Sn<r-s?Sn:r-s,o=new st(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),l=new st(new Uint32Array([fs[a],0]));i.times(l),i.plus(o),s+=a}return i}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)st.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new st(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new st(new Uint32Array(t.buffer)).plus(n)}}class Gt extends kl{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 Gt.fromString(typeof t=="string"?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return Gt.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){const r=t.startsWith("-"),i=t.length,s=new Gt(n);for(let a=r?1:0;a<i;){const o=Sn<i-a?Sn:i-a,l=new Gt(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0])),c=new Gt(new Uint32Array([fs[o],0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)Gt.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new Gt(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new Gt(new Uint32Array(t.buffer)).plus(n)}}class de{constructor(t){this.buffer=t}high(){return new Gt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Gt(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 st(new Uint32Array([this.buffer[3],0])),r=new st(new Uint32Array([this.buffer[2],0])),i=new st(new Uint32Array([this.buffer[1],0])),s=new st(new Uint32Array([this.buffer[0],0])),a=new st(new Uint32Array([t.buffer[3],0])),o=new st(new Uint32Array([t.buffer[2],0])),l=new st(new Uint32Array([t.buffer[1],0])),c=new st(new Uint32Array([t.buffer[0],0]));let d=st.multiply(s,c);this.buffer[0]=d.low();const y=new st(new Uint32Array([d.high(),0]));return d=st.multiply(i,c),y.plus(d),d=st.multiply(s,l),y.plus(d),this.buffer[1]=y.low(),this.buffer[3]=y.lessThan(d)?1:0,this.buffer[2]=y.high(),new st(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(st.multiply(r,c)).plus(st.multiply(i,l)).plus(st.multiply(s,o)),this.buffer[3]+=st.multiply(n,c).plus(st.multiply(r,l)).plus(st.multiply(i,o)).plus(st.multiply(s,a)).low(),this}plus(t){const n=new Uint32Array(4);return n[3]=this.buffer[3]+t.buffer[3]>>>0,n[2]=this.buffer[2]+t.buffer[2]>>>0,n[1]=this.buffer[1]+t.buffer[1]>>>0,n[0]=this.buffer[0]+t.buffer[0]>>>0,n[0]<this.buffer[0]>>>0&&++n[1],n[1]<this.buffer[1]>>>0&&++n[2],n[2]<this.buffer[2]>>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${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 a=r?1:0;a<i;){const o=Sn<i-a?Sn:i-a,l=new de(new Uint32Array([Number.parseInt(t.slice(a,a+o),10),0,0,0])),c=new de(new Uint32Array([fs[o],0,0,0]));s.times(c),s.plus(l),a+=o}return r?s.negate():s}static convertArray(t){const n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)de.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}}class Pl extends q{constructor(t,n,r,i,s=mt.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=n,this.buffers=r,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof ut?t.type:t)}visitNull(t,{length:n}=this.nextFieldNode()){return H({type:t,length:n})}visitBool(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitInt(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFloat(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitUtf8(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({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 H({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 H({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 H({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 H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDate(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTimestamp(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitTime(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDecimal(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitList(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({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 H({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<mt.V5&&this.readNullBitmap(t,r),t.mode===Et.Sparse?this.visitSparseUnion(t,{length:n,nullCount:r}):this.visitDenseUnion(t,{length:n,nullCount:r})}visitDenseUnion(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({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 H({type:t,length:n,nullCount:r,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({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 H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitDuration(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),data:this.readData(t)})}visitFixedSizeList(t,{length:n,nullCount:r}=this.nextFieldNode()){return H({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 H({type:t,length:n,nullCount:r,nullBitmap:this.readNullBitmap(t,r),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,n,r=this.nextBufferRange()){return n>0&&this.readData(t,r)||new Uint8Array(0)}readOffsets(t,n){return this.readData(t,n)}readTypeIds(t,n){return this.readData(t,n)}readData(t,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(t){return this.dictionaries.get(t.id)}}class Yy extends Pl{constructor(t,n,r,i,s){super(new Uint8Array(0),n,r,i,s),this.sources=t}readNullBitmap(t,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):ri(this.sources[r])}readOffsets(t,{offset:n}=this.nextBufferRange()){return ot(Uint8Array,ot(t.OffsetArrayType,this.sources[n]))}readTypeIds(t,{offset:n}=this.nextBufferRange()){return ot(Uint8Array,ot(t.ArrayType,this.sources[n]))}readData(t,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return D.isTimestamp(t)||(D.isInt(t)||D.isTime(t))&&t.bitWidth===64||D.isDuration(t)||D.isDate(t)&&t.unit===zt.MILLISECOND?ot(Uint8Array,Gt.convertArray(r[n])):D.isDecimal(t)?ot(Uint8Array,de.convertArray(r[n])):D.isBinary(t)||D.isLargeBinary(t)||D.isFixedSizeBinary(t)?Wy(r[n]):D.isBool(t)?ri(r[n]):D.isUtf8(t)||D.isLargeUtf8(t)?ji(r[n].join("")):ot(Uint8Array,ot(t.ArrayType,r[n].map(i=>+i)))}}function Wy(e){const t=e.join(""),n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r>>1]=Number.parseInt(t.slice(r,r+2),16);return n}class C extends q{compareSchemas(t,n){return t===n||n instanceof t.constructor&&this.compareManyFields(t.fields,n.fields)}compareManyFields(t,n){return t===n||Array.isArray(t)&&Array.isArray(n)&&t.length===n.length&&t.every((r,i)=>this.compareFields(r,n[i]))}compareFields(t,n){return t===n||n instanceof t.constructor&&t.name===n.name&&t.nullable===n.nullable&&this.visit(t.type,n.type)}}function Rt(e,t){return t instanceof e.constructor}function en(e,t){return e===t||Rt(e,t)}function Ae(e,t){return e===t||Rt(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function hi(e,t){return e===t||Rt(e,t)&&e.precision===t.precision}function qy(e,t){return e===t||Rt(e,t)&&e.byteWidth===t.byteWidth}function ps(e,t){return e===t||Rt(e,t)&&e.unit===t.unit}function Kn(e,t){return e===t||Rt(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function Qn(e,t){return e===t||Rt(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function Gy(e,t){return e===t||Rt(e,t)&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function Hy(e,t){return e===t||Rt(e,t)&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function ys(e,t){return e===t||Rt(e,t)&&e.mode===t.mode&&e.typeIds.every((n,r)=>n===t.typeIds[r])&&$e.compareManyFields(e.children,t.children)}function Ky(e,t){return e===t||Rt(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&$e.visit(e.indices,t.indices)&&$e.visit(e.dictionary,t.dictionary)}function ms(e,t){return e===t||Rt(e,t)&&e.unit===t.unit}function Xn(e,t){return e===t||Rt(e,t)&&e.unit===t.unit}function Qy(e,t){return e===t||Rt(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}function Xy(e,t){return e===t||Rt(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&$e.compareManyFields(e.children,t.children)}C.prototype.visitNull=en,C.prototype.visitBool=en,C.prototype.visitInt=Ae,C.prototype.visitInt8=Ae,C.prototype.visitInt16=Ae,C.prototype.visitInt32=Ae,C.prototype.visitInt64=Ae,C.prototype.visitUint8=Ae,C.prototype.visitUint16=Ae,C.prototype.visitUint32=Ae,C.prototype.visitUint64=Ae,C.prototype.visitFloat=hi,C.prototype.visitFloat16=hi,C.prototype.visitFloat32=hi,C.prototype.visitFloat64=hi,C.prototype.visitUtf8=en,C.prototype.visitLargeUtf8=en,C.prototype.visitBinary=en,C.prototype.visitLargeBinary=en,C.prototype.visitFixedSizeBinary=qy,C.prototype.visitDate=ps,C.prototype.visitDateDay=ps,C.prototype.visitDateMillisecond=ps,C.prototype.visitTimestamp=Kn,C.prototype.visitTimestampSecond=Kn,C.prototype.visitTimestampMillisecond=Kn,C.prototype.visitTimestampMicrosecond=Kn,C.prototype.visitTimestampNanosecond=Kn,C.prototype.visitTime=Qn,C.prototype.visitTimeSecond=Qn,C.prototype.visitTimeMillisecond=Qn,C.prototype.visitTimeMicrosecond=Qn,C.prototype.visitTimeNanosecond=Qn,C.prototype.visitDecimal=en,C.prototype.visitList=Gy,C.prototype.visitStruct=Hy,C.prototype.visitUnion=ys,C.prototype.visitDenseUnion=ys,C.prototype.visitSparseUnion=ys,C.prototype.visitDictionary=Ky,C.prototype.visitInterval=ms,C.prototype.visitIntervalDayTime=ms,C.prototype.visitIntervalYearMonth=ms,C.prototype.visitDuration=Xn,C.prototype.visitDurationSecond=Xn,C.prototype.visitDurationMillisecond=Xn,C.prototype.visitDurationMicrosecond=Xn,C.prototype.visitDurationNanosecond=Xn,C.prototype.visitFixedSizeList=Qy,C.prototype.visitMap=Xy;const $e=new C;function bs(e,t){return $e.compareSchemas(e,t)}function gs(e,t){return Jy(e,t.map(n=>n.data.concat()))}function Jy(e,t){const n=[...e.fields],r=[],i={numBatches:t.reduce((y,_)=>Math.max(y,_.length),0)};let s=0,a=0,o=-1;const l=t.length;let c,d=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,o=-1;++o<l;)d[o]=c=t[o].shift(),a=Math.min(a,c?c.length:a);Number.isFinite(a)&&(d=Zy(n,a,d,t,i),a>0&&(r[s++]=H({type:new At(n),length:a,nullCount:0,children:d.slice()})))}return[e=e.assign(n),r.map(y=>new xt(e,y))]}function Zy(e,t,n,r,i){var s;const a=(t+63&-64)>>3;for(let o=-1,l=r.length;++o<l;){const c=n[o],d=c==null?void 0:c.length;if(d>=t)d===t?n[o]=c:(n[o]=c.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(c.slice(t,d-t))));else{const y=e[o];e[o]=y.clone({nullable:!0}),n[o]=(s=c==null?void 0:c._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:H({type:y.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var Vl;class Bt{constructor(...t){var n,r;if(t.length===0)return this.batches=[],this.schema=new rt([]),this._offsets=[0],this;let i,s;t[0]instanceof rt&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const a=l=>{if(l){if(l instanceof xt)return[l];if(l instanceof Bt)return l.batches;if(l instanceof it){if(l.type instanceof At)return[new xt(new rt(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(c=>a(c));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(c=>a(c));if(typeof l=="object"){const c=Object.keys(l),d=c.map(v=>new nt([l[v]])),y=i??new rt(c.map((v,E)=>new ut(String(v),d[E].type,d[E].nullable))),[,_]=gs(y,d);return _.length===0?[new xt(l)]:_}}}return[]},o=t.flatMap(l=>a(l));if(i=(r=i??((n=o[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new rt([]),!(i instanceof rt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of o){if(!(l instanceof xt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!bs(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=o,this._offsets=s??Nl(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,n)=>t+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Bl(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(rs(t,this.numRows))}set(t,n){}indexOf(t,n){return-1}[Symbol.iterator](){return this.batches.length>0?cs.visit(new nt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
40
44
|
${this.toArray().join(`,
|
|
41
45
|
`)}
|
|
42
|
-
]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Bt(n,r.map(i=>new Lt(n,i)))}slice(t,n){const r=this.schema;[t,n]=Sl({length:this.numRows},t,n);const i=Ol(this.data,this._offsets,t,n);return new Bt(r,i.map(s=>new Lt(r,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){const n=this.data.map(r=>r.children[t]);if(n.length===0){const{type:r}=this.schema.fields[t],i=G({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new tt(n)}return null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||(n=new tt([G({type:new Oe,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,c)=>this.getChildAt(c));[s[t],o[t]]=[a,n],[r,i]=ms(r,o)}return new Bt(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Bt(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,c)=>{const[d,y]=o,_=n.findIndex(v=>v.name===l.name);return~_?y[_]=c:d.push(c),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new Bt(...ms(s,a))}}Vl=Symbol.toStringTag,Bt[Vl]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=ei(as),e.get=ei(Mt.getVisitFn(f.Struct)),e.set=Dl(Wt.getVisitFn(f.Struct)),e.indexOf=Fl(ni.getVisitFn(f.Struct)),"Table"))(Bt.prototype);var zl;let Lt=class ir{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof et))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=G({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(n=>G({type:n.type,nullCount:0}))})]=t,!(this.data instanceof nt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=jl(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,c,d)=>(l.children[d]=n[c],l.length=Math.max(l.length,n[c].length),l.fields[d]=ut.new({name:c,type:n[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new et(r),o=G({type:new At(r),length:s,children:i,nullCount:0});[this.schema,this.data]=jl(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Yl(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Mt.visit(this.data,t)}at(t){return this.get(es(t,this.numRows))}set(t,n){return Wt.visit(this.data,t,n)}indexOf(t,n){return ni.visit(this.data,t,n)}[Symbol.iterator](){return os.visit(new tt([this.data]))}toArray(){return[...this]}concat(...t){return new Bt(this.schema,[this,...t])}slice(t,n){const[r]=new tt([this.data]).slice(t,n).data;return new ir(this.schema,r)}getChild(t){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new tt([this.data.children[t]]):null}setChild(t,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===t),n)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||(n=new tt([G({type:new Oe,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new et(s,new Map(this.schema.metadata)),i=G({type:new At(s),children:a})}return new ir(r,i)}select(t){const n=this.schema.select(t),r=new At(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new ir(n,G({type:r,length:this.numRows,children:i}))}selectAt(t){const n=this.schema.selectAt(t),r=t.map(s=>this.data.children[s]).filter(Boolean),i=G({type:new At(n.fields),length:this.numRows,children:r});return new ir(n,i)}};zl=Symbol.toStringTag,Lt[zl]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Lt.prototype);function jl(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const c=t[o];(!c||c.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=c==null?void 0:c._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:G({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),G({type:new At(i),length:n,children:s})]}function Yl(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const c of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Yl(o.children,c==null?void 0:c.children,n);if(D.isDictionary(o)){const{id:c}=o;if(!n.has(c))l!=null&&l.dictionary&&n.set(c,l.dictionary);else if(n.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class bs extends Lt{constructor(t){const n=t.fields.map(i=>G({type:i.type})),r=G({type:new At(t.fields),nullCount:0,children:n});super(t,r)}}let Le=class fe{constructor(){this.bb=null,this.bb_pos=0}__init(t,n){return this.bb_pos=t,this.bb=n,this}static getRootAsMessage(t,n){return(n||new fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+Z),(n||new fe).__init(t.readInt32(t.position())+t.position(),t)}version(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):yt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):X.NONE}header(t){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(t,this.bb_pos+n):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new vt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}customMetadataLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,n){t.addFieldInt16(0,n,yt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,X.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return fe.startMessage(t),fe.addVersion(t,n),fe.addHeaderType(t,r),fe.addHeader(t,i),fe.addBodyLength(t,s),fe.addCustomMetadata(t,a),fe.endMessage(t)}};class tm extends q{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return no.startNull(n),no.endNull(n)}visitInt(t,n){return Ut.startInt(n),Ut.addBitWidth(n,t.bitWidth),Ut.addIsSigned(n,t.isSigned),Ut.endInt(n)}visitFloat(t,n){return oe.startFloatingPoint(n),oe.addPrecision(n,t.precision),oe.endFloatingPoint(n)}visitBinary(t,n){return Xa.startBinary(n),Xa.endBinary(n)}visitLargeBinary(t,n){return Za.startLargeBinary(n),Za.endLargeBinary(n)}visitBool(t,n){return Ja.startBool(n),Ja.endBool(n)}visitUtf8(t,n){return ro.startUtf8(n),ro.endUtf8(n)}visitLargeUtf8(t,n){return to.startLargeUtf8(n),to.endLargeUtf8(n)}visitDecimal(t,n){return rn.startDecimal(n),rn.addScale(n,t.scale),rn.addPrecision(n,t.precision),rn.addBitWidth(n,t.bitWidth),rn.endDecimal(n)}visitDate(t,n){return Or.startDate(n),Or.addUnit(n,t.unit),Or.endDate(n)}visitTime(t,n){return zt.startTime(n),zt.addUnit(n,t.unit),zt.addBitWidth(n,t.bitWidth),zt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return jt.startTimestamp(n),jt.addUnit(n,t.unit),r!==void 0&&jt.addTimezone(n,r),jt.endTimestamp(n)}visitInterval(t,n){return le.startInterval(n),le.addUnit(n,t.unit),le.endInterval(n)}visitDuration(t,n){return Dr.startDuration(n),Dr.addUnit(n,t.unit),Dr.endDuration(n)}visitList(t,n){return eo.startList(n),eo.endList(n)}visitStruct(t,n){return We.startStruct_(n),We.endStruct_(n)}visitUnion(t,n){Ft.startTypeIdsVector(n,t.typeIds.length);const r=Ft.createTypeIdsVector(n,t.typeIds);return Ft.startUnion(n),Ft.addMode(n,t.mode),Ft.addTypeIds(n,r),Ft.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return ve.startDictionaryEncoding(n),ve.addId(n,BigInt(t.id)),ve.addIsOrdered(n,t.isOrdered),r!==void 0&&ve.addIndexType(n,r),ve.endDictionaryEncoding(n)}visitFixedSizeBinary(t,n){return Fr.startFixedSizeBinary(n),Fr.addByteWidth(n,t.byteWidth),Fr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Mr.startFixedSizeList(n),Mr.addListSize(n,t.listSize),Mr.endFixedSizeList(n)}visitMap(t,n){return Lr.startMap(n),Lr.addKeysSorted(n,t.keysSorted),Lr.endMap(n)}}const gs=new tm;function em(e,t=new Map){return new et(rm(e,t),ci(e.metadata),t)}function Wl(e){return new kt(e.count,Gl(e.columns),Hl(e.columns))}function nm(e){return new he(Wl(e.data),e.id,e.isDelta)}function rm(e,t){return(e.fields||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function ql(e,t){return(e.children||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function Gl(e){return(e||[]).reduce((t,n)=>[...t,new xe(n.count,im(n.VALIDITY)),...Gl(n.children)],[])}function Hl(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new de(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new de(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new de(t.length,i.OFFSET.length)),i.DATA&&t.push(new de(t.length,i.DATA.length)),t=Hl(i.children,t)}return t}function im(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function sm(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=Ql(e,ql(e,t)),i=new ut(e.name,a,e.nullable,ci(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Kl(r):new $n,o=new on(t.get(n),r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))):(r=(r=s.indexType)?Kl(r):new $n,t.set(n,a=Ql(e,ql(e,t))),o=new on(a,r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,ci(e.metadata))),i||null}function ci(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Kl(e){return new qe(e.isSigned,e.bitWidth)}function Ql(e,t){const n=e.type.name;switch(n){case"NONE":return new Oe;case"null":return new Oe;case"binary":return new Ur;case"largebinary":return new Cr;case"utf8":return new kr;case"largeutf8":return new $r;case"bool":return new Pr;case"list":return new Gr((t||[])[0]);case"struct":return new At(t||[]);case"struct_":return new At(t||[])}switch(n){case"int":{const r=e.type;return new qe(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new xr(Tt[r.precision])}case"decimal":{const r=e.type;return new Vr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new zr(Vt[r.unit])}case"time":{const r=e.type;return new jr(k[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Yr(k[r.unit],r.timezone)}case"interval":{const r=e.type;return new Wr(se[r.unit])}case"duration":{const r=e.type;return new qr(k[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Hr(Et[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Kr(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Qr(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new Xr((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var am=Ha,om=tn;class Rt{static fromJSON(t,n){const r=new Rt(0,yt.V5,n);return r._createHeader=lm(t,n),r}static decode(t){t=new om(H(t));const n=Le.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new Rt(r,i,s);return a._createHeader=cm(n,s),a}static encode(t){const n=new am;let r=-1;return t.isSchema()?r=et.encode(n,t.header()):t.isRecordBatch()?r=kt.encode(n,t.header()):t.isDictionaryBatch()&&(r=he.encode(n,t.header())),Le.startMessage(n),Le.addVersion(n,yt.V5),Le.addHeader(n,r),Le.addHeaderType(n,t.headerType),Le.addBodyLength(n,BigInt(t.bodyLength)),Le.finishMessageBuffer(n,Le.endMessage(n)),n.asUint8Array()}static from(t,n=0){if(t instanceof et)return new Rt(0,yt.V5,X.Schema,t);if(t instanceof kt)return new Rt(n,yt.V5,X.RecordBatch,t);if(t instanceof he)return new Rt(n,yt.V5,X.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===X.Schema}isRecordBatch(){return this.headerType===X.RecordBatch}isDictionaryBatch(){return this.headerType===X.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=ot(t)}}class kt{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=ot(t)}}class he{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,n,r=!1){this._data=t,this._isDelta=r,this._id=ot(n)}}class de{constructor(t,n){this.offset=ot(t),this.length=ot(n)}}class xe{constructor(t,n){this.length=ot(t),this.nullCount=ot(n)}}function lm(e,t){return()=>{switch(t){case X.Schema:return et.fromJSON(e);case X.RecordBatch:return kt.fromJSON(e);case X.DictionaryBatch:return he.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}function cm(e,t){return()=>{switch(t){case X.Schema:return et.decode(e.header(new ce),new Map,e.version());case X.RecordBatch:return kt.decode(e.header(new _e),e.version());case X.DictionaryBatch:return he.decode(e.header(new en),e.version())}throw new Error(`Unrecognized Message type: { name: ${X[t]}, type: ${t} }`)}}ut.encode=vm,ut.decode=gm,ut.fromJSON=sm,et.encode=_m,et.decode=um,et.fromJSON=em,kt.encode=wm,kt.decode=hm,kt.fromJSON=Wl,he.encode=Im,he.decode=dm,he.fromJSON=nm,xe.encode=Sm,xe.decode=pm,de.encode=Em,de.decode=fm;function um(e,t=new Map,n=yt.V5){const r=bm(e,t);return new et(r,ui(e),t,n)}function hm(e,t=yt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new kt(e.length(),ym(e),mm(e,t))}function dm(e,t=yt.V5){return new he(kt.decode(e.data(),t),e.id(),e.isDelta())}function fm(e){return new de(e.offset(),e.length())}function pm(e){return new xe(e.length(),e.nullCount())}function ym(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=xe.decode(n));return t}function mm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<yt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=de.decode(r));return n}function bm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=ut.decode(r,t));return n}function Xl(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=ut.decode(r,t));return n}function gm(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=Zl(e,Xl(e,t)),r=new ut(e.name(),i,e.nullable(),ui(e))):t.has(n=ot(o.id()))?(s=(s=o.indexType())?Jl(s):new $n,a=new on(t.get(n),s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))):(s=(s=o.indexType())?Jl(s):new $n,t.set(n,i=Zl(e,Xl(e,t))),a=new on(i,s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),ui(e))),r||null}function ui(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function Jl(e){return new qe(e.isSigned(),e.bitWidth())}function Zl(e,t){const n=e.typeType();switch(n){case lt.NONE:return new Oe;case lt.Null:return new Oe;case lt.Binary:return new Ur;case lt.LargeBinary:return new Cr;case lt.Utf8:return new kr;case lt.LargeUtf8:return new $r;case lt.Bool:return new Pr;case lt.List:return new Gr((t||[])[0]);case lt.Struct_:return new At(t||[])}switch(n){case lt.Int:{const r=e.type(new Ut);return new qe(r.isSigned(),r.bitWidth())}case lt.FloatingPoint:{const r=e.type(new oe);return new xr(r.precision())}case lt.Decimal:{const r=e.type(new rn);return new Vr(r.scale(),r.precision(),r.bitWidth())}case lt.Date:{const r=e.type(new Or);return new zr(r.unit())}case lt.Time:{const r=e.type(new zt);return new jr(r.unit(),r.bitWidth())}case lt.Timestamp:{const r=e.type(new jt);return new Yr(r.unit(),r.timezone())}case lt.Interval:{const r=e.type(new le);return new Wr(r.unit())}case lt.Duration:{const r=e.type(new Dr);return new qr(r.unit())}case lt.Union:{const r=e.type(new Ft);return new Hr(r.mode(),r.typeIdsArray()||[],t||[])}case lt.FixedSizeBinary:{const r=e.type(new Fr);return new Kr(r.byteWidth())}case lt.FixedSizeList:{const r=e.type(new Mr);return new Qr(r.listSize(),(t||[])[0])}case lt.Map:{const r=e.type(new Lr);return new Xr((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${lt[n]}" (${n})`)}function _m(e,t){const n=t.fields.map(s=>ut.encode(e,s));ce.startFieldsVector(e,n.length);const r=ce.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?ce.createCustomMetadataVector(e,[...t.metadata].map(([s,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return vt.startKeyValue(e),vt.addKey(e,o),vt.addValue(e,l),vt.endKeyValue(e)})):-1;return ce.startSchema(e),ce.addFields(e,r),ce.addEndianness(e,Tm?nn.Little:nn.Big),i!==-1&&ce.addCustomMetadata(e,i),ce.endSchema(e)}function vm(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;D.isDictionary(s)?(a=s.dictionary.typeId,i=gs.visit(s,e),r=gs.visit(s.dictionary,e)):r=gs.visit(s,e);const o=(s.children||[]).map(d=>ut.encode(e,d)),l=Yt.createChildrenVector(e,o),c=t.metadata&&t.metadata.size>0?Yt.createCustomMetadataVector(e,[...t.metadata].map(([d,y])=>{const _=e.createString(`${d}`),v=e.createString(`${y}`);return vt.startKeyValue(e),vt.addKey(e,_),vt.addValue(e,v),vt.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Yt.startField(e),Yt.addType(e,r),Yt.addTypeType(e,a),Yt.addChildren(e,l),Yt.addNullable(e,!!t.nullable),n!==-1&&Yt.addName(e,n),i!==-1&&Yt.addDictionary(e,i),c!==-1&&Yt.addCustomMetadata(e,c),Yt.endField(e)}function wm(e,t){const n=t.nodes||[],r=t.buffers||[];_e.startNodesVector(e,n.length);for(const a of n.slice().reverse())xe.encode(e,a);const i=e.endVector();_e.startBuffersVector(e,r.length);for(const a of r.slice().reverse())de.encode(e,a);const s=e.endVector();return _e.startRecordBatch(e),_e.addLength(e,BigInt(t.length)),_e.addNodes(e,i),_e.addBuffers(e,s),_e.endRecordBatch(e)}function Im(e,t){const n=kt.encode(e,t.data);return en.startDictionaryBatch(e),en.addId(e,BigInt(t.id)),en.addIsDelta(e,t.isDelta),en.addData(e,n),en.endDictionaryBatch(e)}function Sm(e,t){return Qa.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Em(e,t){return Ka.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Tm=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),_s=e=>`Expected ${X[e]} Message in stream, but was null or length 0.`,vs=e=>`Header pointer of flatbuffer-encoded ${X[e]} Message is null or length 0.`,tc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,ec=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class nc{constructor(t){this.source=t instanceof ai?t:new ai(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done||t.value===-1&&(t=this.readMetadataLength()).done||(t=this.readMetadata(t.value)).done?wt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const n=H(this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=X.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i}readMetadataLength(){const t=this.source.read(hi),n=t&&new tn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}}}class Am{constructor(t,n){this.source=t instanceof yn?t:$a(t)?new oi(t,n):new yn(t)}[Symbol.asyncIterator](){return this}next(){return Y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done||t.value===-1&&(t=yield this.readMetadataLength()).done||(t=yield this.readMetadata(t.value)).done?wt:t})}throw(t){return Y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return Y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return Y(this,void 0,void 0,function*(){let n;if((n=yield this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value})}readMessageBody(t){return Y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);const n=H(yield this.source.read(t));if(n.byteLength<t)throw new Error(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Y(this,arguments,void 0,function*(t=!1){const n=X.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(vs(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(hi),n=t&&new tn(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Y(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return wt;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Rt.decode(n)}})}}class Nm extends nc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Cl?t:new Cl(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Rt.fromJSON(t.schema,X.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Rt.fromJSON(n,X.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Rt.fromJSON(n,X.RecordBatch)}}return this._body=[],wt}readMessageBody(t){return n(this._body);function n(r){return(r||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(t){let n;if((n=this.next()).done)return null;if(t!=null&&n.value.headerType!==t)throw new Error(_s(t));return n.value}readSchema(){const t=X.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(vs(t));return r}}const hi=4,ws="ARROW1",Wn=new Uint8Array(ws.length);for(let e=0;e<ws.length;e+=1)Wn[e]=ws.codePointAt(e);function Is(e,t=0){for(let n=-1,r=Wn.length;++n<r;)if(Wn[n]!==e[t+n])return!1;return!0}const qn=Wn.length,rc=qn+hi,Bm=qn*2+hi;class Gt extends us{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){const n=this._impl.open(t);return Ye(n)?n.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Pt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Pt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Gt?t:zi(t)?Fm(t):$a(t)?xm(t):Ye(t)?Y(this,void 0,void 0,function*(){return yield Gt.from(yield t)}):Pa(t)||ji(t)||Va(t)||Ze(t)?Lm(new yn(t)):Mm(new ai(t))}static readAll(t){return t instanceof Gt?t.isSync()?lc(t):cc(t):zi(t)||ArrayBuffer.isView(t)||Ln(t)||ka(t)?lc(t):cc(t)}}class di extends Gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return re(this,arguments,function*(){yield W(yield*Sr(je(this[Symbol.iterator]())))})}}class fi extends Gt{constructor(t){super(t),this._impl=t}readAll(){return Y(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=je(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const c=i;s.push(c)}}catch(c){n={error:c}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class ic extends di{constructor(t){super(t),this._impl=t}}class Rm extends fi{constructor(t){super(t),this._impl=t}}class sc{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=G({type:new At(this.schema.fields),length:t.length,children:r});return new Lt(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),c=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new tt(c)):new tt(c)).memoize()}_loadVectors(t,n,r){return new Pl(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class pi extends sc{constructor(t,n){super(n),this._reader=zi(t)?new Nm(this._handle=t):new nc(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):wt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):wt}next(){if(this.closed)return wt;let t;const{_reader:n}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bs(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class yi extends sc{constructor(t,n){super(n),this._reader=new Am(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return Y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):wt})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):wt})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return wt;let t;const{_reader:n}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const r=t.header(),i=yield n.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bs(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class ac extends pi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,n){super(t instanceof kl?t:new kl(t),n)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(X.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(X.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-rc,r=t.readInt32(n),i=t.readAt(n-r,r);return Vn.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class Om extends yi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...n){const r=typeof n[0]!="number"?n.shift():void 0,i=n[0]instanceof Map?n.shift():void 0;super(t instanceof oi?t:new oi(t,r),i)}isFile(){return!0}isAsync(){return!0}open(t){const n=Object.create(null,{open:{get:()=>super.open}});return Y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,t)})}readRecordBatch(t){return Y(this,void 0,void 0,function*(){var n;if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(X.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return Y(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(X.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return Y(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-rc,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Vn.decode(i)})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class Dm extends pi{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new Yy(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function oc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*lc(e){const t=Gt.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function cc(e){return re(this,arguments,function*(){const t=yield W(Gt.from(e));try{if(!(yield W(t.open({autoDestroy:!1}))).closed)do yield yield W(t);while(!(yield W(t.reset().open())).closed)}finally{yield W(t.cancel())}})}function Fm(e){return new di(new Dm(e))}function Mm(e){const t=e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(e.read())):new di(new pi(e)):new di(new pi(function*(){}()))}function Lm(e){return Y(this,void 0,void 0,function*(){const t=yield e.peek(qn+7&-8);return t&&t.byteLength>=4?Is(t)?new ic(new ac(yield e.read())):new fi(new yi(e)):new fi(new yi(function(){return re(this,arguments,function*(){})}()))})}function xm(e){return Y(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new oi(e,t);return t>=Bm&&Is(yield n.readAt(0,qn+7&-8))?new Rm(new Om(n)):new fi(new yi(n))})}class pt extends q{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof Lt?s.data.children:s.data),r=new pt;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof tt)return this.visitMany(t.data),this;const{type:n}=t;if(!D.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(D.isUnion(n))this.nodes.push(new xe(r,0));else{const{nullCount:i}=t;D.isNull(n)||Jt.call(this,i<=0?new Uint8Array(0):Zr(t.offset,r,t.nullBitmap)),this.nodes.push(new xe(r,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Jt(e){const t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new de(this._byteLength,t)),this._byteLength+=t,this}function Um(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(Jt.call(this,i),n.mode===Et.Sparse)return Es.call(this,e);if(n.mode===Et.Dense){if(e.offset<=0)return Jt.call(this,s),Es.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let c,d,y=-1;++y<r;)(c=i[y])!==void 0&&((d=o[c])===void 0&&(d=o[c]=s[y]),a[y]=s[y]-d,l[c]=((t=l[c])!==null&&t!==void 0?t:0)+1);Jt.call(this,a),this.visitMany(e.children.map((c,d)=>{const y=n.typeIds[d],_=o[y],v=l[y];return c.slice(_,Math.min(r,v))}))}}return this}function Cm(e){let t;return e.nullCount>=e.length?Jt.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?Jt.call(this,Zr(e.offset,e.length,t)):Jt.call(this,ti(e.values))}function Te(e){return Jt.call(this,e.values.subarray(0,e.length*e.stride))}function mi(e){const{length:t,values:n,valueOffsets:r}=e,i=ot(r[0]),s=ot(r[t]),a=Math.min(s-i,n.byteLength-i);return Jt.call(this,Wa(-i,t+1,r)),Jt.call(this,n.subarray(i,i+a)),this}function Ss(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return Jt.call(this,Wa(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Es(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}pt.prototype.visitBool=Cm,pt.prototype.visitInt=Te,pt.prototype.visitFloat=Te,pt.prototype.visitUtf8=mi,pt.prototype.visitLargeUtf8=mi,pt.prototype.visitBinary=mi,pt.prototype.visitLargeBinary=mi,pt.prototype.visitFixedSizeBinary=Te,pt.prototype.visitDate=Te,pt.prototype.visitTimestamp=Te,pt.prototype.visitTime=Te,pt.prototype.visitDecimal=Te,pt.prototype.visitList=Ss,pt.prototype.visitStruct=Es,pt.prototype.visitUnion=Um,pt.prototype.visitInterval=Te,pt.prototype.visitDuration=Te,pt.prototype.visitFixedSizeList=Ss,pt.prototype.visitMap=Ss;class uc extends us{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,n){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new si,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Dt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return Ye(t)?t.then(n=>this.writeAll(n)):Ze(t)?Bs(this,t):Ns(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof si?this._sink=t:(this._sink=new si,t&&pp(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&yp(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!ys(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Bt&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof Lt&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!ys(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof Lt?t instanceof bs||this._writeRecordBatch(t):t instanceof Bt?this.writeAll(t.batches):Ln(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Rt.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===X.RecordBatch?this._recordBatchBlocks.push(new Fe(o,t.bodyLength,this._position)):t.headerType===X.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=H(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Rt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Wn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=pt.assemble(t),a=new kt(t.numRows,r,i),o=Rt.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=pt.assemble(new tt([t])),l=new kt(t.length,s,a),c=new he(l,n,r),d=Rt.from(c,i);return this._writeMessage(d)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[c,d]of a.entries())this._writeDictionaryBatch(d,i,c>0);else if(l<a.length)for(const c of a.slice(l))this._writeDictionaryBatch(c,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class Ts extends uc{static writeAll(t,n){const r=new Ts(n);return Ye(t)?t.then(i=>r.writeAll(i)):Ze(t)?Bs(r,t):Ns(r,t)}}class As extends uc{static writeAll(t){const n=new As;return Ye(t)?t.then(r=>n.writeAll(r)):Ze(t)?Bs(n,t):Ns(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Vn.encode(new Vn(t,yt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Ns(e,t){let n=t;t instanceof Bt&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Bs(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=je(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const c=l;e.write(c)}}catch(c){a={error:c}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function km(e,t="stream"){return(t==="stream"?Ts:As).writeAll(e).toUint8Array(!0)}var $m=Object.create,hc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Vm=Object.getOwnPropertyNames,zm=Object.getPrototypeOf,jm=Object.prototype.hasOwnProperty,Ym=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vm(t))!jm.call(e,i)&&i!==n&&hc(e,i,{get:()=>t[i],enumerable:!(r=Pm(t,i))||r.enumerable});return e},qm=(e,t,n)=>(n=e!=null?$m(zm(e)):{},Wm(!e||!e.__esModule?hc(n,"default",{value:e,enumerable:!0}):n,e)),Gm=Ym((e,t)=>{t.exports=Worker}),dc=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(dc||{}),fc=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(fc||{}),pc=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(pc||{}),yc=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(yc||{}),mc=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(mc||{}),bc=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(bc||{}),Hm=class{log(e){}},Km=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function Qm(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function Xm(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function Jm(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function Zm(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var gc=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(gc||{}),_c=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Gt.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Bt(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new Rs(this._bindings,this._conn,n),i=await Gt.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new vc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=km(e,"stream");await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},Rs=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},vc=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Gt.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Rs(this.bindings,this.connectionId,t),r=await Gt.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},wc=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(wc||{}),Ic=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(Ic||{}),K=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((n,r)=>{this.promiseResolver=n,this.promiseRejecter=r})}};function bi(e){switch(e.typeId){case f.Binary:return{sqlType:"binary"};case f.Bool:return{sqlType:"bool"};case f.Date:return{sqlType:"date"};case f.DateDay:return{sqlType:"date32[d]"};case f.DateMillisecond:return{sqlType:"date64[ms]"};case f.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case f.Float:return{sqlType:"float"};case f.Float16:return{sqlType:"float16"};case f.Float32:return{sqlType:"float32"};case f.Float64:return{sqlType:"float64"};case f.Int:return{sqlType:"int32"};case f.Int16:return{sqlType:"int16"};case f.Int32:return{sqlType:"int32"};case f.Int64:return{sqlType:"int64"};case f.Uint16:return{sqlType:"uint16"};case f.Uint32:return{sqlType:"uint32"};case f.Uint64:return{sqlType:"uint64"};case f.Uint8:return{sqlType:"uint8"};case f.IntervalDayTime:return{sqlType:"interval[dt]"};case f.IntervalYearMonth:return{sqlType:"interval[m]"};case f.List:return{sqlType:"list",valueType:bi(e.valueType)};case f.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case f.Null:return{sqlType:"null"};case f.Utf8:return{sqlType:"utf8"};case f.Struct:return{sqlType:"struct",fields:e.children.map(t=>Os(t.name,t.type))};case f.Map:{let t=e;return{sqlType:"map",keyType:bi(t.keyType),valueType:bi(t.valueType)}}case f.Time:return{sqlType:"time[s]"};case f.TimeMicrosecond:return{sqlType:"time[us]"};case f.TimeMillisecond:return{sqlType:"time[ms]"};case f.TimeNanosecond:return{sqlType:"time[ns]"};case f.TimeSecond:return{sqlType:"time[s]"};case f.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case f.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case f.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case f.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case f.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Os(e,t){let n=bi(t);return n.name=e,n}var tb=new TextEncoder,eb=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new K("RESET",null);return await this.postTask(e)}async ping(){let e=new K("PING",null);await this.postTask(e)}async dropFile(e){let t=new K("DROP_FILE",e);return await this.postTask(t)}async dropFiles(){let e=new K("DROP_FILES",null);return await this.postTask(e)}async flushFiles(){let e=new K("FLUSH_FILES",null);return await this.postTask(e)}async instantiate(e,t=null,n=r=>{}){this._onInstantiationProgress.push(n);let r=new K("INSTANTIATE",[e,t]);return await this.postTask(r)}async getVersion(){let e=new K("GET_VERSION",null);return await this.postTask(e)}async getFeatureFlags(){let e=new K("GET_FEATURE_FLAGS",null);return await this.postTask(e)}async open(e){let t=new K("OPEN",e);await this.postTask(t)}async tokenize(e){let t=new K("TOKENIZE",e);return await this.postTask(t)}async connectInternal(){let e=new K("CONNECT",null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new _c(this,e)}async disconnect(e){let t=new K("DISCONNECT",e);await this.postTask(t)}async runQuery(e,t){let n=new K("RUN_QUERY",[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){let r=new K("START_PENDING_QUERY",[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new K("POLL_PENDING_QUERY",e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new K("CANCEL_PENDING_QUERY",e);return await this.postTask(t)}async fetchQueryResults(e){let t=new K("FETCH_QUERY_RESULTS",e);return await this.postTask(t)}async getTableNames(e,t){let n=new K("GET_TABLE_NAMES",[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new K("CREATE_PREPARED",[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new K("CLOSE_PREPARED",[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new K("RUN_PREPARED",[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new K("SEND_PREPARED",[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new K("GLOB_FILE_INFOS",e);return await this.postTask(t)}async registerFileText(e,t){let n=tb.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new K("REGISTER_FILE_URL",[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new K("REGISTER_FILE_BUFFER",[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new K("REGISTER_FILE_HANDLE",[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new K("REGISTER_OPFS_FILE_NAME",[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new K("COLLECT_FILE_STATISTICS",[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new K("EXPORT_FILE_STATISTICS",e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new K("COPY_FILE_TO_BUFFER",e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new K("COPY_FILE_TO_PATH",[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new K("INSERT_ARROW_FROM_IPC_STREAM",[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("IMPORT_CSV_FROM_PATH",[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let i=[];for(let s in n.columns){let a=n.columns[s];i.push(Os(s,a))}n.columnsFlat=i,delete n.columns}let r=new K("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function nb(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}nb();var Sc=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(Sc||{}),rb=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},ib=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),sb=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),ab=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),ob=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Ds={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},Ec=Ds.name,Tc=Ds.version,Fs=Ds.version.split("."),lb=Fs[0],cb=Fs[1],ub=Fs[2],Ms=()=>typeof navigator>"u",Ac=()=>Ms()?"node":navigator.userAgent,hb=()=>Ac().includes("Firefox"),db=()=>/^((?!chrome|android).)*safari/i.test(Ac());function fb(){let e="https://cdn.jsdelivr.net/npm/".concat(Ec,"@").concat(Tc,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Ls=null,xs=null,Us=null,Cs=null,ks=null;async function Nc(){return Ls==null&&(Ls=typeof BigInt64Array<"u"),xs==null&&(xs=await sb()),Us==null&&(Us=await ob()),Cs==null&&(Cs=await ab()),ks==null&&(ks=await ib()),{bigInt64Array:Ls,crossOriginIsolated:Ms()||globalThis.crossOriginIsolated||!1,wasmExceptions:xs,wasmSIMD:Cs,wasmThreads:Us,wasmBulkMemory:ks}}async function pb(e){let t=await Nc();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var yb=qm(Gm());async function mb(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new yb.default(r)}const bb=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:eb,AsyncDuckDBConnection:_c,AsyncDuckDBDispatcher:rb,AsyncPreparedStatement:vc,AsyncResultStreamIterator:Rs,ConsoleLogger:Km,DuckDBAccessMode:dc,DuckDBDataProtocol:Sc,LogEvent:mc,LogLevel:pc,LogOrigin:bc,LogTopic:yc,PACKAGE_NAME:Ec,PACKAGE_VERSION:Tc,PACKAGE_VERSION_MAJOR:lb,PACKAGE_VERSION_MINOR:cb,PACKAGE_VERSION_PATCH:ub,StatusCode:gc,TokenType:fc,VoidLogger:Hm,WorkerRequestType:wc,WorkerResponseType:Ic,WorkerTask:K,createWorker:mb,getJsDelivrBundles:fb,getLogEventLabel:Xm,getLogLevelLabel:Qm,getLogOriginLabel:Zm,getLogTopicLabel:Jm,getPlatformFeatures:Nc,isFirefox:hb,isNode:Ms,isSafari:db,selectBundle:pb},Symbol.toStringTag,{value:"Module"}));async function gb(){var r,i,s,a;const e="@aws-amplify/auth";let t;try{t=await import(e)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:n}=t;return{token:((a=(s=(i=(r=await n())==null?void 0:r.tokens)==null?void 0:i.idToken)==null?void 0:s.toString)==null?void 0:a.call(s))??null,provider:"amplify"}}const Bc=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:gb},Symbol.toStringTag,{value:"Module"}));te.DataExplorer=lp,te.UMAP=up,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
|
|
46
|
+
]`}concat(...t){const n=this.schema,r=this.data.concat(t.flatMap(({data:i})=>i));return new Bt(n,r.map(i=>new xt(n,i)))}slice(t,n){const r=this.schema;[t,n]=Sl({length:this.numRows},t,n);const i=Ol(this.data,this._offsets,t,n);return new Bt(r,i.map(s=>new xt(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=H({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new nt(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 nt([H({type:new xe,length:this.numRows})]));const s=r.fields.slice(),a=s[t].clone({type:n.type}),o=this.schema.fields.map((l,c)=>this.getChildAt(c));[s[t],o[t]]=[a,n],[r,i]=gs(r,o)}return new Bt(r,i)}select(t){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(t.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(t){const n=this.schema.selectAt(t),r=this.batches.map(i=>i.selectAt(t));return new Bt(n,r)}assign(t){const n=this.schema.fields,[r,i]=t.schema.fields.reduce((o,l,c)=>{const[d,y]=o,_=n.findIndex(v=>v.name===l.name);return~_?y[_]=c:d.push(c),o},[[],[]]),s=this.schema.assign(t.schema),a=[...n.map((o,l)=>[l,i[l]]).map(([o,l])=>l===void 0?this.getChildAt(o):t.getChildAt(l)),...r.map(o=>t.getChildAt(o))].filter(Boolean);return new Bt(...gs(s,a))}}Vl=Symbol.toStringTag,Bt[Vl]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=ii(ls),e.get=ii(Lt.getVisitFn(f.Struct)),e.set=Dl(qt.getVisitFn(f.Struct)),e.indexOf=Ml(si.getVisitFn(f.Struct)),"Table"))(Bt.prototype);var zl;let xt=class or{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof rt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=H({nullCount:0,type:new At(this.schema.fields),children:this.schema.fields.map(n=>H({type:n.type,nullCount:0}))})]=t,!(this.data instanceof it))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=jl(this.schema,this.data.children);break}case 1:{const[n]=t,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,c,d)=>(l.children[d]=n[c],l.length=Math.max(l.length,n[c].length),l.fields[d]=ut.new({name:c,type:n[c].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),a=new rt(r),o=H({type:new At(r),length:s,children:i,nullCount:0});[this.schema,this.data]=jl(a,o.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Yl(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Lt.visit(this.data,t)}at(t){return this.get(rs(t,this.numRows))}set(t,n){return qt.visit(this.data,t,n)}indexOf(t,n){return si.visit(this.data,t,n)}[Symbol.iterator](){return cs.visit(new nt([this.data]))}toArray(){return[...this]}concat(...t){return new Bt(this.schema,[this,...t])}slice(t,n){const[r]=new nt([this.data]).slice(t,n).data;return new or(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 nt([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 nt([H({type:new xe,length:this.numRows})]));const s=r.fields.slice(),a=i.children.slice(),o=s[t].clone({type:n.type});[s[t],a[t]]=[o,n.data[0]],r=new rt(s,new Map(this.schema.metadata)),i=H({type:new At(s),children:a})}return new or(r,i)}select(t){const n=this.schema.select(t),r=new At(n.fields),i=[];for(const s of t){const a=this.schema.fields.findIndex(o=>o.name===s);~a&&(i[a]=this.data.children[a])}return new or(n,H({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=H({type:new At(n.fields),length:this.numRows,children:r});return new or(n,i)}};zl=Symbol.toStringTag,xt[zl]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(xt.prototype);function jl(e,t,n=t.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...e.fields],s=[...t],a=(n+63&-64)>>3;for(const[o,l]of e.fields.entries()){const c=t[o];(!c||c.length!==n)&&(i[o]=l.clone({nullable:!0}),s[o]=(r=c==null?void 0:c._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:H({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(i),H({type:new At(i),length:n,children:s})]}function Yl(e,t,n=new Map){var r,i;if(((r=e==null?void 0:e.length)!==null&&r!==void 0?r:0)>0&&(e==null?void 0:e.length)===(t==null?void 0:t.length))for(let s=-1,a=e.length;++s<a;){const{type:o}=e[s],l=t[s];for(const c of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Yl(o.children,c==null?void 0:c.children,n);if(D.isDictionary(o)){const{id:c}=o;if(!n.has(c))l!=null&&l.dictionary&&n.set(c,l.dictionary);else if(n.get(c)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return n}class _s extends xt{constructor(t){const n=t.fields.map(i=>H({type:i.type})),r=H({type:new At(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()+et),(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):mt.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):tt.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 wt).__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,mt.V1)}static addHeaderType(t,n){t.addFieldInt8(1,n,tt.NONE)}static addHeader(t,n){t.addFieldOffset(2,n,0)}static addBodyLength(t,n){t.addFieldInt64(3,n,BigInt("0"))}static addCustomMetadata(t,n){t.addFieldOffset(4,n,0)}static createCustomMetadataVector(t,n){t.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)t.addOffset(n[r]);return t.endVector()}static startCustomMetadataVector(t,n){t.startVector(4,n,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,n){t.finish(n)}static finishSizePrefixedMessageBuffer(t,n){t.finish(n,void 0,!0)}static createMessage(t,n,r,i,s,a){return ye.startMessage(t),ye.addVersion(t,n),ye.addHeaderType(t,r),ye.addHeader(t,i),ye.addBodyLength(t,s),ye.addCustomMetadata(t,a),ye.endMessage(t)}};class tm extends q{visit(t,n){return t==null||n==null?void 0:super.visit(t,n)}visitNull(t,n){return no.startNull(n),no.endNull(n)}visitInt(t,n){return Ct.startInt(n),Ct.addBitWidth(n,t.bitWidth),Ct.addIsSigned(n,t.isSigned),Ct.endInt(n)}visitFloat(t,n){return ce.startFloatingPoint(n),ce.addPrecision(n,t.precision),ce.endFloatingPoint(n)}visitBinary(t,n){return Xa.startBinary(n),Xa.endBinary(n)}visitLargeBinary(t,n){return Za.startLargeBinary(n),Za.endLargeBinary(n)}visitBool(t,n){return Ja.startBool(n),Ja.endBool(n)}visitUtf8(t,n){return ro.startUtf8(n),ro.endUtf8(n)}visitLargeUtf8(t,n){return to.startLargeUtf8(n),to.endLargeUtf8(n)}visitDecimal(t,n){return 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 Fr.startDate(n),Fr.addUnit(n,t.unit),Fr.endDate(n)}visitTime(t,n){return jt.startTime(n),jt.addUnit(n,t.unit),jt.addBitWidth(n,t.bitWidth),jt.endTime(n)}visitTimestamp(t,n){const r=t.timezone&&n.createString(t.timezone)||void 0;return Yt.startTimestamp(n),Yt.addUnit(n,t.unit),r!==void 0&&Yt.addTimezone(n,r),Yt.endTimestamp(n)}visitInterval(t,n){return ue.startInterval(n),ue.addUnit(n,t.unit),ue.endInterval(n)}visitDuration(t,n){return Lr.startDuration(n),Lr.addUnit(n,t.unit),Lr.endDuration(n)}visitList(t,n){return eo.startList(n),eo.endList(n)}visitStruct(t,n){return Je.startStruct_(n),Je.endStruct_(n)}visitUnion(t,n){Ft.startTypeIdsVector(n,t.typeIds.length);const r=Ft.createTypeIdsVector(n,t.typeIds);return Ft.startUnion(n),Ft.addMode(n,t.mode),Ft.addTypeIds(n,r),Ft.endUnion(n)}visitDictionary(t,n){const r=this.visit(t.indices,n);return 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 xr.startFixedSizeBinary(n),xr.addByteWidth(n,t.byteWidth),xr.endFixedSizeBinary(n)}visitFixedSizeList(t,n){return Ur.startFixedSizeList(n),Ur.addListSize(n,t.listSize),Ur.endFixedSizeList(n)}visitMap(t,n){return Cr.startMap(n),Cr.addKeysSorted(n,t.keysSorted),Cr.endMap(n)}}const vs=new tm;function em(e,t=new Map){return new rt(rm(e,t),di(e.metadata),t)}function Wl(e){return new kt(e.count,Gl(e.columns),Hl(e.columns))}function nm(e){return new fe(Wl(e.data),e.id,e.isDelta)}function rm(e,t){return(e.fields||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function ql(e,t){return(e.children||[]).filter(Boolean).map(n=>ut.fromJSON(n,t))}function Gl(e){return(e||[]).reduce((t,n)=>[...t,new Pe(n.count,im(n.VALIDITY)),...Gl(n.children)],[])}function Hl(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){const i=e[n];i.VALIDITY&&t.push(new 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=Hl(i.children,t)}return t}function im(e){return(e||[]).reduce((t,n)=>t+ +(n===0),0)}function sm(e,t){let n,r,i,s,a,o;return!t||!(s=e.dictionary)?(a=Ql(e,ql(e,t)),i=new ut(e.name,a,e.nullable,di(e.metadata))):t.has(n=s.id)?(r=(r=s.indexType)?Kl(r):new qn,o=new fn(t.get(n),r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,di(e.metadata))):(r=(r=s.indexType)?Kl(r):new qn,t.set(n,a=Ql(e,ql(e,t))),o=new fn(a,r,n,s.isOrdered),i=new ut(e.name,o,e.nullable,di(e.metadata))),i||null}function di(e=[]){return new Map(e.map(({key:t,value:n})=>[t,n]))}function Kl(e){return new Ze(e.isSigned,e.bitWidth)}function Ql(e,t){const n=e.type.name;switch(n){case"NONE":return new xe;case"null":return new xe;case"binary":return new kr;case"largebinary":return new Pr;case"utf8":return new Vr;case"largeutf8":return new zr;case"bool":return new jr;case"list":return new Qr((t||[])[0]);case"struct":return new At(t||[]);case"struct_":return new At(t||[])}switch(n){case"int":{const r=e.type;return new Ze(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=e.type;return new $r(Tt[r.precision])}case"decimal":{const r=e.type;return new Yr(r.scale,r.precision,r.bitWidth)}case"date":{const r=e.type;return new Wr(zt[r.unit])}case"time":{const r=e.type;return new qr($[r.unit],r.bitWidth)}case"timestamp":{const r=e.type;return new Gr($[r.unit],r.timezone)}case"interval":{const r=e.type;return new Hr(oe[r.unit])}case"duration":{const r=e.type;return new Kr($[r.unit])}case"union":{const r=e.type,[i,...s]=(r.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new Xr(Et[a],r.typeIds||[],t||[])}case"fixedsizebinary":{const r=e.type;return new Jr(r.byteWidth)}case"fixedsizelist":{const r=e.type;return new Zr(r.listSize,(t||[])[0])}case"map":{const r=e.type;return new ti((t||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var am=Ha,om=on;class Nt{static fromJSON(t,n){const r=new Nt(0,mt.V5,n);return r._createHeader=lm(t,n),r}static decode(t){t=new om(Q(t));const n=ke.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),s=n.headerType(),a=new Nt(r,i,s);return a._createHeader=cm(n,s),a}static encode(t){const n=new am;let r=-1;return t.isSchema()?r=rt.encode(n,t.header()):t.isRecordBatch()?r=kt.encode(n,t.header()):t.isDictionaryBatch()&&(r=fe.encode(n,t.header())),ke.startMessage(n),ke.addVersion(n,mt.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 rt)return new Nt(0,mt.V5,tt.Schema,t);if(t instanceof kt)return new Nt(n,mt.V5,tt.RecordBatch,t);if(t instanceof fe)return new Nt(n,mt.V5,tt.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===tt.Schema}isRecordBatch(){return this.headerType===tt.RecordBatch}isDictionaryBatch(){return this.headerType===tt.DictionaryBatch}constructor(t,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=lt(t)}}class kt{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,n,r){this._nodes=n,this._buffers=r,this._length=lt(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=lt(n)}}class pe{constructor(t,n){this.offset=lt(t),this.length=lt(n)}}class Pe{constructor(t,n){this.length=lt(t),this.nullCount=lt(n)}}function lm(e,t){return(()=>{switch(t){case tt.Schema:return rt.fromJSON(e);case tt.RecordBatch:return kt.fromJSON(e);case tt.DictionaryBatch:return fe.fromJSON(e)}throw new Error(`Unrecognized Message type: { name: ${tt[t]}, type: ${t} }`)})}function cm(e,t){return(()=>{switch(t){case tt.Schema:return rt.decode(e.header(new he),new Map,e.version());case tt.RecordBatch:return kt.decode(e.header(new we),e.version());case tt.DictionaryBatch:return fe.decode(e.header(new ln),e.version())}throw new Error(`Unrecognized Message type: { name: ${tt[t]}, type: ${t} }`)})}ut.encode=vm,ut.decode=gm,ut.fromJSON=sm,rt.encode=_m,rt.decode=um,rt.fromJSON=em,kt.encode=wm,kt.decode=hm,kt.fromJSON=Wl,fe.encode=Im,fe.decode=dm,fe.fromJSON=nm,Pe.encode=Sm,Pe.decode=pm,pe.encode=Em,pe.decode=fm;function um(e,t=new Map,n=mt.V5){const r=bm(e,t);return new rt(r,fi(e),t,n)}function hm(e,t=mt.V5){if(e.compression()!==null)throw new Error("Record batch compression not implemented");return new kt(e.length(),ym(e),mm(e,t))}function dm(e,t=mt.V5){return new fe(kt.decode(e.data(),t),e.id(),e.isDelta())}function fm(e){return new pe(e.offset(),e.length())}function pm(e){return new Pe(e.length(),e.nullCount())}function ym(e){const t=[];for(let n,r=-1,i=-1,s=e.nodesLength();++r<s;)(n=e.nodes(r))&&(t[++i]=Pe.decode(n));return t}function mm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.buffersLength();++i<a;)(r=e.buffers(i))&&(t<mt.V4&&(r.bb_pos+=8*(i+1)),n[++s]=pe.decode(r));return n}function bm(e,t){const n=[];for(let r,i=-1,s=-1,a=e.fieldsLength();++i<a;)(r=e.fields(i))&&(n[++s]=ut.decode(r,t));return n}function Xl(e,t){const n=[];for(let r,i=-1,s=-1,a=e.childrenLength();++i<a;)(r=e.children(i))&&(n[++s]=ut.decode(r,t));return n}function gm(e,t){let n,r,i,s,a,o;return!t||!(o=e.dictionary())?(i=Zl(e,Xl(e,t)),r=new ut(e.name(),i,e.nullable(),fi(e))):t.has(n=lt(o.id()))?(s=(s=o.indexType())?Jl(s):new qn,a=new fn(t.get(n),s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),fi(e))):(s=(s=o.indexType())?Jl(s):new qn,t.set(n,i=Zl(e,Xl(e,t))),a=new fn(i,s,n,o.isOrdered()),r=new ut(e.name(),a,e.nullable(),fi(e))),r||null}function fi(e){const t=new Map;if(e)for(let n,r,i=-1,s=Math.trunc(e.customMetadataLength());++i<s;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function Jl(e){return new Ze(e.isSigned(),e.bitWidth())}function Zl(e,t){const n=e.typeType();switch(n){case ct.NONE:return new xe;case ct.Null:return new xe;case ct.Binary:return new kr;case ct.LargeBinary:return new Pr;case ct.Utf8:return new Vr;case ct.LargeUtf8:return new zr;case ct.Bool:return new jr;case ct.List:return new Qr((t||[])[0]);case ct.Struct_:return new At(t||[])}switch(n){case ct.Int:{const r=e.type(new Ct);return new Ze(r.isSigned(),r.bitWidth())}case ct.FloatingPoint:{const r=e.type(new ce);return new $r(r.precision())}case ct.Decimal:{const r=e.type(new un);return new Yr(r.scale(),r.precision(),r.bitWidth())}case ct.Date:{const r=e.type(new Fr);return new Wr(r.unit())}case ct.Time:{const r=e.type(new jt);return new qr(r.unit(),r.bitWidth())}case ct.Timestamp:{const r=e.type(new Yt);return new Gr(r.unit(),r.timezone())}case ct.Interval:{const r=e.type(new ue);return new Hr(r.unit())}case ct.Duration:{const r=e.type(new Lr);return new Kr(r.unit())}case ct.Union:{const r=e.type(new Ft);return new Xr(r.mode(),r.typeIdsArray()||[],t||[])}case ct.FixedSizeBinary:{const r=e.type(new xr);return new Jr(r.byteWidth())}case ct.FixedSizeList:{const r=e.type(new Ur);return new Zr(r.listSize(),(t||[])[0])}case ct.Map:{const r=e.type(new Cr);return new ti((t||[])[0],r.keysSorted())}}throw new Error(`Unrecognized type: "${ct[n]}" (${n})`)}function _m(e,t){const n=t.fields.map(s=>ut.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,a])=>{const o=e.createString(`${s}`),l=e.createString(`${a}`);return wt.startKeyValue(e),wt.addKey(e,o),wt.addValue(e,l),wt.endKeyValue(e)})):-1;return he.startSchema(e),he.addFields(e,r),he.addEndianness(e,Tm?cn.Little:cn.Big),i!==-1&&he.addCustomMetadata(e,i),he.endSchema(e)}function vm(e,t){let n=-1,r=-1,i=-1;const s=t.type;let a=t.typeId;D.isDictionary(s)?(a=s.dictionary.typeId,i=vs.visit(s,e),r=vs.visit(s.dictionary,e)):r=vs.visit(s,e);const o=(s.children||[]).map(d=>ut.encode(e,d)),l=Wt.createChildrenVector(e,o),c=t.metadata&&t.metadata.size>0?Wt.createCustomMetadataVector(e,[...t.metadata].map(([d,y])=>{const _=e.createString(`${d}`),v=e.createString(`${y}`);return wt.startKeyValue(e),wt.addKey(e,_),wt.addValue(e,v),wt.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),Wt.startField(e),Wt.addType(e,r),Wt.addTypeType(e,a),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 wm(e,t){const n=t.nodes||[],r=t.buffers||[];we.startNodesVector(e,n.length);for(const a of n.slice().reverse())Pe.encode(e,a);const i=e.endVector();we.startBuffersVector(e,r.length);for(const a of r.slice().reverse())pe.encode(e,a);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 Im(e,t){const n=kt.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 Sm(e,t){return Qa.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function Em(e,t){return Ka.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const Tm=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),ws=e=>`Expected ${tt[e]} Message in stream, but was null or length 0.`,Is=e=>`Header pointer of flatbuffer-encoded ${tt[e]} Message is null or length 0.`,tc=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,ec=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;class nc{constructor(t){this.source=t instanceof ci?t:new ci(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?It: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(ws(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(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()}readSchema(t=!1){const n=tt.Schema,r=this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Is(n));return i}readMetadataLength(){const t=this.source.read(pi),n=t&&new on(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}}readMetadata(t){const n=this.source.read(t);if(!n)return It;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Nt.decode(n)}}}class Am{constructor(t,n){this.source=t instanceof wn?t:ka(t)?new ui(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?It: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(ws(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(ec(t,n.byteLength));return n.byteOffset%8===0&&n.byteOffset+n.byteLength<=n.buffer.byteLength?n:n.slice()})}readSchema(){return Y(this,arguments,void 0,function*(t=!1){const n=tt.Schema,r=yield this.readMessage(n),i=r==null?void 0:r.header();if(t&&!i)throw new Error(Is(n));return i})}readMetadataLength(){return Y(this,void 0,void 0,function*(){const t=yield this.source.read(pi),n=t&&new on(t),r=(n==null?void 0:n.readInt32(0))||0;return{done:r===0,value:r}})}readMetadata(t){return Y(this,void 0,void 0,function*(){const n=yield this.source.read(t);if(!n)return It;if(n.byteLength<t)throw new Error(tc(t,n.byteLength));return{done:!1,value:Nt.decode(n)}})}}class Rm extends nc{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Cl?t:new Cl(t)}next(){const{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Nt.fromJSON(t.schema,tt.Schema)};if(this._dictionaryIndex<t.dictionaries.length){const n=t.dictionaries[this._dictionaryIndex++];return this._body=n.data.columns,{done:!1,value:Nt.fromJSON(n,tt.DictionaryBatch)}}if(this._batchIndex<t.batches.length){const n=t.batches[this._batchIndex++];return this._body=n.columns,{done:!1,value:Nt.fromJSON(n,tt.RecordBatch)}}return this._body=[],It}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(ws(t));return n.value}readSchema(){const t=tt.Schema,n=this.readMessage(t),r=n==null?void 0:n.header();if(!n||!r)throw new Error(Is(t));return r}}const pi=4,Ss="ARROW1",Jn=new Uint8Array(Ss.length);for(let e=0;e<Ss.length;e+=1)Jn[e]=Ss.codePointAt(e);function Es(e,t=0){for(let n=-1,r=Jn.length;++n<r;)if(Jn[n]!==e[t+n])return!1;return!0}const Zn=Jn.length,rc=Zn+pi,Bm=Zn*2+pi;class Ht extends ds{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 Xe(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 Vt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Vt.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 Ht?t:Yi(t)?Mm(t):ka(t)?xm(t):Xe(t)?Y(this,void 0,void 0,function*(){return yield Ht.from(yield t)}):Pa(t)||Wi(t)||Va(t)||an(t)?Lm(new wn(t)):Fm(new ci(t))}static readAll(t){return t instanceof Ht?t.isSync()?lc(t):cc(t):Yi(t)||ArrayBuffer.isView(t)||Vn(t)||$a(t)?lc(t):cc(t)}}class yi extends Ht{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 W(yield*Ar(Qe(this[Symbol.iterator]())))})}}class mi extends Ht{constructor(t){super(t),this._impl=t}readAll(){return Y(this,void 0,void 0,function*(){var t,n,r,i;const s=new Array;try{for(var a=!0,o=Qe(this),l;l=yield o.next(),t=l.done,!t;a=!0){i=l.value,a=!1;const c=i;s.push(c)}}catch(c){n={error:c}}finally{try{!a&&!t&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class ic extends yi{constructor(t){super(t),this._impl=t}}class Nm extends mi{constructor(t){super(t),this._impl=t}}class sc{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,n){const r=this._loadVectors(t,n,this.schema.fields),i=H({type:new At(this.schema.fields),length:t.length,children:r});return new xt(this.schema,i)}_loadDictionaryBatch(t,n){const{id:r,isDelta:i}=t,{dictionaries:s,schema:a}=this,o=s.get(r),l=a.dictionaries.get(r),c=this._loadVectors(t.data,n,[l]);return(o&&i?o.concat(new nt(c)):new nt(c)).memoize()}_loadVectors(t,n,r){return new Pl(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}class bi extends sc{constructor(t,n){super(n),this._reader=Yi(t)?new Rm(this._handle=t):new nc(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):It}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):It}next(){if(this.closed)return It;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 _s(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class gi extends sc{constructor(t,n){super(n),this._reader=new Am(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return Y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=oc(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):It})}return(t){return Y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):It})}next(){return Y(this,void 0,void 0,function*(){if(this.closed)return It;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 _s(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class ac extends bi{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 $l?t:new $l(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(tt.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(tt.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}}_readFooter(){const{_handle:t}=this,n=t.size-rc,r=t.readInt32(n),i=t.readAt(n-r,r);return Hn.decode(i)}_readNextMessageAndValidate(t){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(this._recordBatchIndex);if(r&&this._handle.seek(r.offset))return this._reader.readMessage(t)}return null}}class Om extends gi{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 ui?t:new ui(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(tt.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return Y(this,void 0,void 0,function*(){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(t);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(tt.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),o=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,o)}}})}_readFooter(){return Y(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const n=t.size-rc,r=yield t.readInt32(n),i=yield t.readAt(n-r,r);return Hn.decode(i)})}_readNextMessageAndValidate(t){return Y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){const n=this._footer.getRecordBatch(this._recordBatchIndex);if(n&&(yield this._handle.seek(n.offset)))return yield this._reader.readMessage(t)}return null})}}class Dm extends bi{constructor(t,n){super(t,n)}_loadVectors(t,n,r){return new Yy(n,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(r)}}function oc(e,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:e.autoDestroy}function*lc(e){const t=Ht.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function cc(e){return se(this,arguments,function*(){const t=yield W(Ht.from(e));try{if(!(yield W(t.open({autoDestroy:!1}))).closed)do yield yield W(t);while(!(yield W(t.reset().open())).closed)}finally{yield W(t.cancel())}})}function Mm(e){return new yi(new Dm(e))}function Fm(e){const t=e.peek(Zn+7&-8);return t&&t.byteLength>=4?Es(t)?new ic(new ac(e.read())):new yi(new bi(e)):new yi(new bi((function*(){})()))}function Lm(e){return Y(this,void 0,void 0,function*(){const t=yield e.peek(Zn+7&-8);return t&&t.byteLength>=4?Es(t)?new ic(new ac(yield e.read())):new mi(new gi(e)):new mi(new gi((function(){return se(this,arguments,function*(){})})()))})}function xm(e){return Y(this,void 0,void 0,function*(){const{size:t}=yield e.stat(),n=new ui(e,t);return t>=Bm&&Es(yield n.readAt(0,Zn+7&-8))?new Nm(new Om(n)):new mi(new gi(n))})}class pt extends q{static assemble(...t){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof xt?s.data.children:s.data),r=new pt;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof nt)return this.visitMany(t.data),this;const{type:n}=t;if(!D.isDictionary(n)){const{length:r}=t;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(D.isUnion(n))this.nodes.push(new Pe(r,0));else{const{nullCount:i}=t;D.isNull(n)||Zt.call(this,i<=0?new Uint8Array(0):ni(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 Zt(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 Um(e){var t;const{type:n,length:r,typeIds:i,valueOffsets:s}=e;if(Zt.call(this,i),n.mode===Et.Sparse)return As.call(this,e);if(n.mode===Et.Dense){if(e.offset<=0)return Zt.call(this,s),As.call(this,e);{const a=new Int32Array(r),o=Object.create(null),l=Object.create(null);for(let c,d,y=-1;++y<r;)(c=i[y])!==void 0&&((d=o[c])===void 0&&(d=o[c]=s[y]),a[y]=s[y]-d,l[c]=((t=l[c])!==null&&t!==void 0?t:0)+1);Zt.call(this,a),this.visitMany(e.children.map((c,d)=>{const y=n.typeIds[d],_=o[y],v=l[y];return c.slice(_,Math.min(r,v))}))}}return this}function Cm(e){let t;return e.nullCount>=e.length?Zt.call(this,new Uint8Array(0)):(t=e.values)instanceof Uint8Array?Zt.call(this,ni(e.offset,e.length,t)):Zt.call(this,ri(e.values))}function Re(e){return Zt.call(this,e.values.subarray(0,e.length*e.stride))}function _i(e){const{length:t,values:n,valueOffsets:r}=e,i=lt(r[0]),s=lt(r[t]),a=Math.min(s-i,n.byteLength-i);return Zt.call(this,Wa(-i,t+1,r)),Zt.call(this,n.subarray(i,i+a)),this}function Ts(e){const{length:t,valueOffsets:n}=e;if(n){const{[0]:r,[t]:i}=n;return Zt.call(this,Wa(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function As(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}pt.prototype.visitBool=Cm,pt.prototype.visitInt=Re,pt.prototype.visitFloat=Re,pt.prototype.visitUtf8=_i,pt.prototype.visitLargeUtf8=_i,pt.prototype.visitBinary=_i,pt.prototype.visitLargeBinary=_i,pt.prototype.visitFixedSizeBinary=Re,pt.prototype.visitDate=Re,pt.prototype.visitTimestamp=Re,pt.prototype.visitTime=Re,pt.prototype.visitDecimal=Re,pt.prototype.visitList=Ts,pt.prototype.visitStruct=As,pt.prototype.visitUnion=Um,pt.prototype.visitInterval=Re,pt.prototype.visitDuration=Re,pt.prototype.visitFixedSizeList=Ts,pt.prototype.visitMap=Ts;class uc extends ds{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 li,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Mt(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 Xe(t)?t.then(n=>this.writeAll(n)):an(t)?Os(this,t):Ns(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,n=null){return t===this._sink||t instanceof li?this._sink=t:(this._sink=new li,t&&pp(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&yp(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!n||!bs(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(t){let n=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof Bt&&!(n=t.schema))return this.finish()&&void 0;if(t instanceof xt&&!(n=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!bs(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}t instanceof xt?t instanceof _s||this._writeRecordBatch(t):t instanceof Bt?this.writeAll(t.batches):Vn(t)&&this.writeAll(t)}_writeMessage(t,n=8){const r=n-1,i=Nt.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,o=s+a+r&~r,l=o-s-a;return t.headerType===tt.RecordBatch?this._recordBatchBlocks.push(new Ce(o,t.bodyLength,this._position)):t.headerType===tt.DictionaryBatch&&this._dictionaryBlocks.push(new Ce(o,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){const n=Q(t);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(t){return this._writeMessage(Nt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Jn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=pt.assemble(t),a=new kt(t.numRows,r,i),o=Nt.from(a,n);return this._writeDictionaries(t)._writeMessage(o)._writeBodyBuffers(s)}_writeDictionaryBatch(t,n,r=!1){const{byteLength:i,nodes:s,bufferRegions:a,buffers:o}=pt.assemble(new nt([t])),l=new kt(t.length,s,a),c=new fe(l,n,r),d=Nt.from(c,i);return this._writeMessage(d)._writeBodyBuffers(o)}_writeBodyBuffers(t){let n,r,i;for(let s=-1,a=t.length;++s<a;)(n=t[s])&&(r=n.byteLength)>0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(t){var n,r;for(const[i,s]of t.dictionaries){const a=(n=s==null?void 0:s.data)!==null&&n!==void 0?n:[],o=this._seenDictionaries.get(i),l=(r=this._dictionaryDeltaOffsets.get(i))!==null&&r!==void 0?r:0;if(!o||o.data[0]!==a[0])for(const[c,d]of a.entries())this._writeDictionaryBatch(d,i,c>0);else if(l<a.length)for(const c of a.slice(l))this._writeDictionaryBatch(c,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}}class Rs extends uc{static writeAll(t,n){const r=new Rs(n);return Xe(t)?t.then(i=>r.writeAll(i)):an(t)?Os(r,t):Ns(r,t)}}class Bs extends uc{static writeAll(t){const n=new Bs;return Xe(t)?t.then(r=>n.writeAll(r)):an(t)?Os(n,t):Ns(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,n,r=!1){if(!r&&this._seenDictionaries.has(n))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,n,r)}_writeFooter(t){const n=Hn.encode(new Hn(t,mt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function Ns(e,t){let n=t;t instanceof Bt&&(n=t.batches,e.reset(void 0,t.schema));for(const r of n)e.write(r);return e.finish()}function Os(e,t){return Y(this,void 0,void 0,function*(){var n,r,i,s,a,o,l;try{for(n=!0,r=Qe(t);i=yield r.next(),s=i.done,!s;n=!0){l=i.value,n=!1;const c=l;e.write(c)}}catch(c){a={error:c}}finally{try{!n&&!s&&(o=r.return)&&(yield o.call(r))}finally{if(a)throw a.error}}return e.finish()})}function $m(e,t="stream"){return(t==="stream"?Rs:Bs).writeAll(e).toUint8Array(!0)}var km=Object.create,hc=Object.defineProperty,Pm=Object.getOwnPropertyDescriptor,Vm=Object.getOwnPropertyNames,zm=Object.getPrototypeOf,jm=Object.prototype.hasOwnProperty,Ym=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Wm=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vm(t))!jm.call(e,i)&&i!==n&&hc(e,i,{get:()=>t[i],enumerable:!(r=Pm(t,i))||r.enumerable});return e},qm=(e,t,n)=>(n=e!=null?km(zm(e)):{},Wm(!e||!e.__esModule?hc(n,"default",{value:e,enumerable:!0}):n,e)),Gm=Ym((e,t)=>{t.exports=Worker}),dc=(e=>(e[e.UNDEFINED=0]="UNDEFINED",e[e.AUTOMATIC=1]="AUTOMATIC",e[e.READ_ONLY=2]="READ_ONLY",e[e.READ_WRITE=3]="READ_WRITE",e))(dc||{}),fc=(e=>(e[e.IDENTIFIER=0]="IDENTIFIER",e[e.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",e[e.STRING_CONSTANT=2]="STRING_CONSTANT",e[e.OPERATOR=3]="OPERATOR",e[e.KEYWORD=4]="KEYWORD",e[e.COMMENT=5]="COMMENT",e))(fc||{}),pc=(e=>(e[e.NONE=0]="NONE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARNING=3]="WARNING",e[e.ERROR=4]="ERROR",e))(pc||{}),yc=(e=>(e[e.NONE=0]="NONE",e[e.CONNECT=1]="CONNECT",e[e.DISCONNECT=2]="DISCONNECT",e[e.OPEN=3]="OPEN",e[e.QUERY=4]="QUERY",e[e.INSTANTIATE=5]="INSTANTIATE",e))(yc||{}),mc=(e=>(e[e.NONE=0]="NONE",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR",e[e.START=3]="START",e[e.RUN=4]="RUN",e[e.CAPTURE=5]="CAPTURE",e))(mc||{}),bc=(e=>(e[e.NONE=0]="NONE",e[e.WEB_WORKER=1]="WEB_WORKER",e[e.NODE_WORKER=2]="NODE_WORKER",e[e.BINDINGS=3]="BINDINGS",e[e.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",e))(bc||{}),Hm=class{log(e){}},Km=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function Qm(e){switch(e){case 0:return"NONE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARNING";case 4:return"ERROR";default:return"?"}}function Xm(e){switch(e){case 0:return"NONE";case 1:return"OK";case 2:return"ERROR";case 3:return"START";case 4:return"RUN";case 5:return"CAPTURE";default:return"?"}}function Jm(e){switch(e){case 1:return"CONNECT";case 2:return"DISCONNECT";case 5:return"INSTANTIATE";case 3:return"OPEN";case 4:return"QUERY";default:return"?"}}function Zm(e){switch(e){case 0:return"NONE";case 1:return"WEB WORKER";case 2:return"NODE WORKER";case 3:return"DUCKDB BINDINGS";case 4:return"DUCKDB";default:return"?"}}var gc=(e=>(e[e.SUCCESS=0]="SUCCESS",e))(gc||{}),_c=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=Ht.from(t);return console.assert(n.isSync(),"Reader is not sync"),console.assert(n.isFile(),"Reader is not file"),new Bt(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;)n=await this._bindings.pollPendingQuery(this._conn);let r=new Ds(this._bindings,this._conn,n),i=await Ht.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new vc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=$m(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)}},Ds=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e;return this._inFlight!=null?(e=await this._inFlight,this._inFlight=null):e=await this.db.fetchQueryResults(this.conn),this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},vc=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=Ht.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new Bt(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new Ds(this.bindings,this.connectionId,t),r=await Ht.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},wc=(e=>(e.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",e.CLOSE_PREPARED="CLOSE_PREPARED",e.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",e.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",e.CONNECT="CONNECT",e.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",e.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",e.CREATE_PREPARED="CREATE_PREPARED",e.DISCONNECT="DISCONNECT",e.DROP_FILE="DROP_FILE",e.DROP_FILES="DROP_FILES",e.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",e.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",e.FLUSH_FILES="FLUSH_FILES",e.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",e.GET_TABLE_NAMES="GET_TABLE_NAMES",e.GET_VERSION="GET_VERSION",e.GLOB_FILE_INFOS="GLOB_FILE_INFOS",e.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",e.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",e.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",e.INSTANTIATE="INSTANTIATE",e.OPEN="OPEN",e.PING="PING",e.POLL_PENDING_QUERY="POLL_PENDING_QUERY",e.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",e.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",e.REGISTER_FILE_URL="REGISTER_FILE_URL",e.RESET="RESET",e.RUN_PREPARED="RUN_PREPARED",e.RUN_QUERY="RUN_QUERY",e.SEND_PREPARED="SEND_PREPARED",e.START_PENDING_QUERY="START_PENDING_QUERY",e.TOKENIZE="TOKENIZE",e))(wc||{}),Ic=(e=>(e.CONNECTION_INFO="CONNECTION_INFO",e.ERROR="ERROR",e.FEATURE_FLAGS="FEATURE_FLAGS",e.FILE_BUFFER="FILE_BUFFER",e.FILE_INFOS="FILE_INFOS",e.FILE_SIZE="FILE_SIZE",e.FILE_STATISTICS="FILE_STATISTICS",e.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",e.LOG="LOG",e.PROGRESS_UPDATE="PROGRESS_UPDATE",e.OK="OK",e.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",e.QUERY_PLAN="QUERY_PLAN",e.QUERY_RESULT="QUERY_RESULT",e.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",e.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",e.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",e.REGISTERED_FILE="REGISTERED_FILE",e.SCRIPT_TOKENS="SCRIPT_TOKENS",e.SUCCESS="SUCCESS",e.TABLE_NAMES="TABLE_NAMES",e.VERSION_STRING="VERSION_STRING",e))(Ic||{}),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 vi(e){switch(e.typeId){case f.Binary:return{sqlType:"binary"};case f.Bool:return{sqlType:"bool"};case f.Date:return{sqlType:"date"};case f.DateDay:return{sqlType:"date32[d]"};case f.DateMillisecond:return{sqlType:"date64[ms]"};case f.Decimal:{let t=e;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case f.Float:return{sqlType:"float"};case f.Float16:return{sqlType:"float16"};case f.Float32:return{sqlType:"float32"};case f.Float64:return{sqlType:"float64"};case f.Int:return{sqlType:"int32"};case f.Int16:return{sqlType:"int16"};case f.Int32:return{sqlType:"int32"};case f.Int64:return{sqlType:"int64"};case f.Uint16:return{sqlType:"uint16"};case f.Uint32:return{sqlType:"uint32"};case f.Uint64:return{sqlType:"uint64"};case f.Uint8:return{sqlType:"uint8"};case f.IntervalDayTime:return{sqlType:"interval[dt]"};case f.IntervalYearMonth:return{sqlType:"interval[m]"};case f.List:return{sqlType:"list",valueType:vi(e.valueType)};case f.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:e.byteWidth};case f.Null:return{sqlType:"null"};case f.Utf8:return{sqlType:"utf8"};case f.Struct:return{sqlType:"struct",fields:e.children.map(t=>Ms(t.name,t.type))};case f.Map:{let t=e;return{sqlType:"map",keyType:vi(t.keyType),valueType:vi(t.valueType)}}case f.Time:return{sqlType:"time[s]"};case f.TimeMicrosecond:return{sqlType:"time[us]"};case f.TimeMillisecond:return{sqlType:"time[ms]"};case f.TimeNanosecond:return{sqlType:"time[ns]"};case f.TimeSecond:return{sqlType:"time[s]"};case f.Timestamp:return{sqlType:"timestamp",timezone:e.timezone||void 0};case f.TimestampSecond:return{sqlType:"timestamp[s]",timezone:e.timezone||void 0};case f.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:e.timezone||void 0};case f.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:e.timezone||void 0};case f.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:e.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(e.toString()))}function Ms(e,t){let n=vi(t);return n.name=e,n}var tb=new TextEncoder,eb=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}attach(e){this._worker=e,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,n)=>{this._workerShutdownResolver=t})}detach(){this._worker&&(this._worker.removeEventListener("message",this._onMessageHandler),this._worker.removeEventListener("error",this._onErrorHandler),this._worker.removeEventListener("close",this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case"PROGRESS_UPDATE":{for(let i of this._onExecutionProgress)i(n.data);return}case"LOG":{this._logger.log(n.data);return}case"INSTANTIATE_PROGRESS":{for(let i of this._onInstantiationProgress)i(n.data);return}}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn("unassociated response: [".concat(n.requestId,", ").concat(n.type.toString(),"]"));return}if(this._pendingRequests.delete(n.requestId),n.type=="ERROR"){let i=new Error(n.data.message);i.name=n.data.name,(t=Object.getOwnPropertyDescriptor(i,"stack"))!=null&&t.writable&&(i.stack=n.data.stack),r.promiseRejecter(i);return}switch(r.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(n.type=="OK"){r.promiseResolver(n.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],n.type=="OK"){r.promiseResolver(n.data);return}break;case"GLOB_FILE_INFOS":if(n.type=="FILE_INFOS"){r.promiseResolver(n.data);return}break;case"GET_VERSION":if(n.type=="VERSION_STRING"){r.promiseResolver(n.data);return}break;case"GET_FEATURE_FLAGS":if(n.type=="FEATURE_FLAGS"){r.promiseResolver(n.data);return}break;case"GET_TABLE_NAMES":if(n.type=="TABLE_NAMES"){r.promiseResolver(n.data);return}break;case"TOKENIZE":if(n.type=="SCRIPT_TOKENS"){r.promiseResolver(n.data);return}break;case"COPY_FILE_TO_BUFFER":if(n.type=="FILE_BUFFER"){r.promiseResolver(n.data);return}break;case"EXPORT_FILE_STATISTICS":if(n.type=="FILE_STATISTICS"){r.promiseResolver(n.data);return}break;case"CONNECT":if(n.type=="CONNECTION_INFO"){r.promiseResolver(n.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(n.type=="QUERY_RESULT"){r.promiseResolver(n.data);return}break;case"SEND_PREPARED":if(n.type=="QUERY_RESULT_HEADER"){r.promiseResolver(n.data);return}break;case"START_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"POLL_PENDING_QUERY":if(n.type=="QUERY_RESULT_HEADER_OR_NULL"){r.promiseResolver(n.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],n.type=="SUCCESS"){r.promiseResolver(n.data);return}break;case"FETCH_QUERY_RESULTS":if(n.type=="QUERY_RESULT_CHUNK"){r.promiseResolver(n.data);return}break;case"CREATE_PREPARED":if(n.type=="PREPARED_STATEMENT_ID"){r.promiseResolver(n.data);return}break}r.promiseRejecter(new Error("unexpected response type: ".concat(n.type.toString())))}onError(e){console.error(e),console.error("error in duckdb worker: ".concat(e.message)),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn("worker terminated with ".concat(this._pendingRequests.size," pending requests"));return}this._pendingRequests.clear()}async reset(){let e=new 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 _c(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=tb.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 a=n.columns[s];i.push(Ms(s,a))}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 a=n.columns[s];i.push(Ms(s,a))}n.columnsFlat=i,delete n.columns}let r=new X("IMPORT_JSON_FROM_PATH",[e,t,n]);await this.postTask(r)}};function nb(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}nb();var Sc=(e=>(e[e.BUFFER=0]="BUFFER",e[e.NODE_FS=1]="NODE_FS",e[e.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",e[e.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",e[e.HTTP=4]="HTTP",e[e.S3=5]="S3",e))(Sc||{}),rb=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:n},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let t=e.data.path;t!=null&&t.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:t.useUnsafe((n,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:t},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"RUN_QUERY":{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:t},[t.buffer]);break}case"SEND_PREPARED":{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:t},[t.buffer]);break}case"START_PENDING_QUERY":{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"POLL_PENDING_QUERY":{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:t},n);break}case"CANCEL_PENDING_QUERY":{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:t},[]);break}case"FETCH_QUERY_RESULTS":{let t=this._bindings.fetchQueryResults(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:t},[t.buffer]);break}case"GET_TABLE_NAMES":{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:t},[]);break}case"GLOB_FILE_INFOS":{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:t},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:t},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},ib=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),sb=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),ab=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),ob=()=>(async e=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Fs={name:"@duckdb/duckdb-wasm",version:"1.29.1-dev132.0"},Ec=Fs.name,Tc=Fs.version,Ls=Fs.version.split("."),lb=Ls[0],cb=Ls[1],ub=Ls[2],xs=()=>typeof navigator>"u",Ac=()=>xs()?"node":navigator.userAgent,hb=()=>Ac().includes("Firefox"),db=()=>/^((?!chrome|android).)*safari/i.test(Ac());function fb(){let e="https://cdn.jsdelivr.net/npm/".concat(Ec,"@").concat(Tc,"/dist/");return{mvp:{mainModule:"".concat(e,"duckdb-mvp.wasm"),mainWorker:"".concat(e,"duckdb-browser-mvp.worker.js")},eh:{mainModule:"".concat(e,"duckdb-eh.wasm"),mainWorker:"".concat(e,"duckdb-browser-eh.worker.js")}}}var Us=null,Cs=null,$s=null,ks=null,Ps=null;async function Rc(){return Us==null&&(Us=typeof BigInt64Array<"u"),Cs==null&&(Cs=await sb()),$s==null&&($s=await ob()),ks==null&&(ks=await ab()),Ps==null&&(Ps=await ib()),{bigInt64Array:Us,crossOriginIsolated:xs()||globalThis.crossOriginIsolated||!1,wasmExceptions:Cs,wasmSIMD:ks,wasmThreads:$s,wasmBulkMemory:Ps}}async function pb(e){let t=await Rc();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}var yb=qm(Gm());async function mb(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new yb.default(r)}const bb=Object.freeze(Object.defineProperty({__proto__:null,AsyncDuckDB:eb,AsyncDuckDBConnection:_c,AsyncDuckDBDispatcher:rb,AsyncPreparedStatement:vc,AsyncResultStreamIterator:Ds,ConsoleLogger:Km,DuckDBAccessMode:dc,DuckDBDataProtocol:Sc,LogEvent:mc,LogLevel:pc,LogOrigin:bc,LogTopic:yc,PACKAGE_NAME:Ec,PACKAGE_VERSION:Tc,PACKAGE_VERSION_MAJOR:lb,PACKAGE_VERSION_MINOR:cb,PACKAGE_VERSION_PATCH:ub,StatusCode:gc,TokenType:fc,VoidLogger:Hm,WorkerRequestType:wc,WorkerResponseType:Ic,WorkerTask:X,createWorker:mb,getJsDelivrBundles:fb,getLogEventLabel:Xm,getLogLevelLabel:Qm,getLogOriginLabel:Zm,getLogTopicLabel:Jm,getPlatformFeatures:Rc,isFirefox:hb,isNode:xs,isSafari:db,selectBundle:pb},Symbol.toStringTag,{value:"Module"}));async function gb(){var r,i,s,a;const e="@aws-amplify/auth";let t;try{t=await import(e)}catch{return{token:null,provider:"none"}}const{fetchAuthSession:n}=t;return{token:((a=(s=(i=(r=await n())==null?void 0:r.tokens)==null?void 0:i.idToken)==null?void 0:s.toString)==null?void 0:a.call(s))??null,provider:"amplify"}}const Bc=Object.freeze(Object.defineProperty({__proto__:null,useGetToken:gb},Symbol.toStringTag,{value:"Module"}));ne.DataExplorer=lp,ne.UMAP=up,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})}));
|