>>=1,ot<<=1,0<--Y;);return ot>>>1}function vt(R,Y,ot){var at,rt,ht=new Array(d+1),bt=0;for(at=1;at<=d;at++)ht[at]=bt=bt+ot[at-1]<<1;for(rt=0;rt<=Y;rt++){var pt=R[2*rt+1];pt!==0&&(R[2*rt]=yt(ht[pt]++,pt))}}function dt(R){var Y;for(Y=0;Y>1;1<=ot;ot--)Ct(R,ht,ot);for(rt=Ot;ot=R.heap[1],R.heap[1]=R.heap[R.heap_len--],Ct(R,ht,1),at=R.heap[1],R.heap[--R.heap_max]=ot,R.heap[--R.heap_max]=at,ht[2*rt]=ht[2*ot]+ht[2*at],R.depth[rt]=(R.depth[ot]>=R.depth[at]?R.depth[ot]:R.depth[at])+1,ht[2*ot+1]=ht[2*at+1]=rt,R.heap[1]=rt++,Ct(R,ht,1),2<=R.heap_len;);R.heap[--R.heap_max]=R.heap[1],function(oe,ir){var Ki,vr,Zi,Ae,Ji,ao,Qr=ir.dyn_tree,fs=ir.max_code,ma=ir.stat_desc.static_tree,hu=ir.stat_desc.has_stree,si=ir.stat_desc.extra_bits,ya=ir.stat_desc.extra_base,In=ir.stat_desc.max_length,En=0;for(Ae=0;Ae<=d;Ae++)oe.bl_count[Ae]=0;for(Qr[2*oe.heap[oe.heap_max]+1]=0,Ki=oe.heap_max+1;Ki>=7;rt>>=1)if(1&ye&&pt.dyn_ltree[2*Ot]!==0)return o;if(pt.dyn_ltree[18]!==0||pt.dyn_ltree[20]!==0||pt.dyn_ltree[26]!==0)return a;for(Ot=32;Ot>>3,(ht=R.static_len+3+7>>>3)<=rt&&(rt=ht)):rt=ht=ot+5,ot+4<=rt&&Y!==-1?N(R,Y,ot,at):R.strategy===4||ht===rt?(et(R,2+(at?1:0),3),ee(R,st,I)):(et(R,4+(at?1:0),3),function(pt,Ot,ye,oe){var ir;for(et(pt,Ot-257,5),et(pt,ye-1,5),et(pt,oe-4,4),ir=0;ir>>8&255,R.pending_buf[R.d_buf+2*R.last_lit+1]=255&Y,R.pending_buf[R.l_buf+R.last_lit]=255&ot,R.last_lit++,Y===0?R.dyn_ltree[2*ot]++:(R.matches++,Y--,R.dyn_ltree[2*(w[ot]+h+1)]++,R.dyn_dtree[2*A(Y)]++),R.last_lit===R.lit_bufsize-1},n._tr_align=function(R){et(R,2,3),J(R,S,st),function(Y){Y.bi_valid===16?($(Y,Y.bi_buf),Y.bi_buf=0,Y.bi_valid=0):8<=Y.bi_valid&&(Y.pending_buf[Y.pending++]=255&Y.bi_buf,Y.bi_buf>>=8,Y.bi_valid-=8)}(R)}},{"../utils/common":41}],53:[function(e,i,n){i.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,i,n){(function(s){(function(o,a){if(!o.setImmediate){var l,u,c,h,p=1,f={},y=!1,g=o.document,d=Object.getPrototypeOf&&Object.getPrototypeOf(o);d=d&&d.setTimeout?d:o,l={}.toString.call(o.process)==="[object process]"?function(E){process.nextTick(function(){_(E)})}:function(){if(o.postMessage&&!o.importScripts){var E=!0,b=o.onmessage;return o.onmessage=function(){E=!1},o.postMessage("","*"),o.onmessage=b,E}}()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",S,!1):o.attachEvent("onmessage",S),function(E){o.postMessage(h+E,"*")}):o.MessageChannel?((c=new MessageChannel).port1.onmessage=function(E){_(E.data)},function(E){c.port2.postMessage(E)}):g&&"onreadystatechange"in g.createElement("script")?(u=g.documentElement,function(E){var b=g.createElement("script");b.onreadystatechange=function(){_(E),b.onreadystatechange=null,u.removeChild(b),b=null},u.appendChild(b)}):function(E){setTimeout(_,0,E)},d.setImmediate=function(E){typeof E!="function"&&(E=new Function(""+E));for(var b=new Array(arguments.length-1),F=0;F"u"?s===void 0?this:s:self)}).call(this,typeof gi<"u"?gi:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})}(Gu)),Gu.exports}var dC=fC();const pC=Nh(dC);Ai.zipReader=(r,t)=>pC.loadAsync(r);const mC=Ai.createSettings;Ai.createSettings=async r=>{const t=Object.keys(r.files);return t.find(e=>yC(e))?mC(r):_C(t)};function yC(r){return r.endsWith("model3.json")}function gC(r){return r.endsWith(".moc3")}function vC(r){return r.split(/[\\/]/).pop()}function _C(r){const t=r.filter(u=>gC(u));if(t.length!==1){const u=t.length?`(${t.map(c=>`"${c}"`).join(",")})`:"";throw new Error(`Expected exactly one moc file, got ${t.length} ${u}`)}const e=t[0],i=vC(e).replace(/\.moc3?/,""),n=r.filter(u=>u.endsWith(".png"));if(!n.length)throw new Error("Textures not found");const s=r.filter(u=>u.endsWith(".mtn")||u.endsWith(".motion3.json")),o=r.find(u=>u.includes("physics")),a=r.find(u=>u.includes("pose")),l=new Jn({url:`${i}.model3.json`,Version:3,FileReferences:{Moc:e,Textures:n,Physics:o,Pose:a,Motions:s.length?{"":s.map(u=>({File:u}))}:void 0}});return l.name=i,l._objectURL=`example://${l.url}`,l}Ai.readText=(r,t)=>{const e=r.file(t);if(!e)throw new Error(`Cannot find file: ${t}`);return e.async("text")};Ai.getFilePaths=r=>{const t=[];return r.forEach(e=>t.push(e)),Promise.resolve(t)};Ai.getFiles=(r,t)=>Promise.all(t.map(async e=>{const i=e.slice(e.lastIndexOf("/")+1),n=await r.file(e).async("blob");return new File([n],i)}));function Zt(r,t,e,i){function n(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(c){try{u(i.next(c))}catch(h){o(h)}}function l(c){try{u(i.throw(c))}catch(h){o(h)}}function u(c){c.done?s(c.value):n(c.value).then(a,l)}u((i=i.apply(r,t||[])).next())})}function up(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],i=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pt(r){return this instanceof Pt?(this.v=r,this):new Pt(r)}function dr(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=e.apply(r,t||[]),n,s=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(f){return function(y){return Promise.resolve(y).then(f,h)}}function a(f,y){i[f]&&(n[f]=function(g){return new Promise(function(d,m){s.push([f,g,d,m])>1||l(f,g)})},y&&(n[f]=y(n[f])))}function l(f,y){try{u(i[f](y))}catch(g){p(s[0][3],g)}}function u(f){f.value instanceof Pt?Promise.resolve(f.value.v).then(c,h):p(s[0][2],f)}function c(f){l("next",f)}function h(f){l("throw",f)}function p(f,y){f(y),s.shift(),s.length&&l(s[0][0],s[0][1])}}function ts(r){var t,e;return t={},i("next"),i("throw",function(n){throw n}),i("return"),t[Symbol.iterator]=function(){return this},t;function i(n,s){t[n]=r[n]?function(o){return(e=!e)?{value:Pt(r[n](o)),done:!1}:s?s(o):o}:s}}function bi(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof up=="function"?up(r):r[Symbol.iterator](),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(s){e[s]=r[s]&&function(o){return new Promise(function(a,l){o=r[s](o),n(a,l,o.done,o.value)})}}function n(s,o,a,l){Promise.resolve(l).then(function(u){s({value:u,done:a})},o)}}const bC=new TextDecoder("utf-8"),eh=r=>bC.decode(r),wC=new TextEncoder,ef=r=>wC.encode(r),xC=r=>typeof r=="number",_v=r=>typeof r=="boolean",Ge=r=>typeof r=="function",pr=r=>r!=null&&Object(r)===r,rs=r=>pr(r)&&Ge(r.then),oa=r=>pr(r)&&Ge(r[Symbol.iterator]),no=r=>pr(r)&&Ge(r[Symbol.asyncIterator]),rh=r=>pr(r)&&pr(r.schema),bv=r=>pr(r)&&"done"in r&&"value"in r,wv=r=>pr(r)&&Ge(r.stat)&&xC(r.fd),xv=r=>pr(r)&&rf(r.body),tu=r=>"_getDOMStream"in r&&"_getNodeStream"in r,SC=r=>pr(r)&&Ge(r.abort)&&Ge(r.getWriter)&&!tu(r),rf=r=>pr(r)&&Ge(r.cancel)&&Ge(r.getReader)&&!tu(r),TC=r=>pr(r)&&Ge(r.end)&&Ge(r.write)&&_v(r.writable)&&!tu(r),Sv=r=>pr(r)&&Ge(r.read)&&Ge(r.pipe)&&_v(r.readable)&&!tu(r),IC=r=>pr(r)&&Ge(r.clear)&&Ge(r.bytes)&&Ge(r.position)&&Ge(r.setPosition)&&Ge(r.capacity)&&Ge(r.getBufferIdentifier)&&Ge(r.createLong),nf=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function EC(r){const t=r[0]?[r[0]]:[];let e,i,n,s;for(let o,a,l=0,u=0,c=r.length;++lc+h.byteLength,0);let n,s,o,a=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,i);for(const c=e.length;++l_e(Int32Array,r),hp=r=>_e(BigInt64Array,r),ae=r=>_e(Uint8Array,r),ih=r=>(r.next(),r);function*CC(r,t){const e=function*(n){yield n},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof nf?e(t):oa(t)?t:e(t);return yield*ih(function*(n){let s=null;do s=n.next(yield _e(r,s));while(!s.done)}(i[Symbol.iterator]())),new r}const AC=r=>CC(Uint8Array,r);function Tv(r,t){return dr(this,arguments,function*(){if(rs(t))return yield Pt(yield Pt(yield*ts(bi(Tv(r,yield Pt(t))))));const i=function(o){return dr(this,arguments,function*(){yield yield Pt(yield Pt(o))})},n=function(o){return dr(this,arguments,function*(){yield Pt(yield*ts(bi(ih(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof nf?i(t):oa(t)?n(t):no(t)?t:i(t);return yield Pt(yield*ts(bi(ih(function(o){return dr(this,arguments,function*(){let a=null;do a=yield Pt(o.next(yield yield Pt(_e(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield Pt(new r)})}const OC=r=>Tv(Uint8Array,r);function Iv(r,t,e){if(r!==0){e=e.slice(0,t);for(let i=-1,n=e.length;++i0)do if(r[e]!==t[e])return!1;while(++e(r.next(),r);function*PC(r){let t,e=!1,i=[],n,s,o,a=0;function l(){return s==="peek"?xi(i,o)[0]:([n,i,a]=xi(i,o),n)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});const u=AC(r)[Symbol.iterator]();try{do if({done:t,value:n}=Number.isNaN(o-a)?u.next():u.next(o-a),!t&&n.byteLength>0&&(i.push(n),a+=n.byteLength),t||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(n.push(s),l+=s.byteLength),e||a<=l)do({cmd:o,size:a}=yield yield Pt(u()));while(a0&&(n.push(ae(s)),l+=s.byteLength),e||a<=l)do({cmd:o,size:a}=yield yield Pt(u()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return Zt(this,void 0,void 0,function*(){const{reader:e,source:i}=this;e&&(yield e.cancel(t).catch(()=>{})),i&&i.locked&&this.releaseLock()})}read(t){return Zt(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};const e=yield this.reader.read();return!e.done&&(e.value=ae(e)),e})}}const Wu=(r,t)=>{const e=n=>i([t,n]);let i;return[t,e,new Promise(n=>(i=n)&&r.once(t,e))]};function NC(r){return dr(this,arguments,function*(){const e=[];let i="error",n=!1,s=null,o,a,l=0,u=[],c;function h(){return o==="peek"?xi(u,a)[0]:([c,u,l]=xi(u,a),c)}if({cmd:o,size:a}=(yield yield Pt(null))||{cmd:"read",size:0},r.isTTY)return yield yield Pt(new Uint8Array(0)),yield Pt(null);try{e[0]=Wu(r,"end"),e[1]=Wu(r,"error");do{if(e[2]=Wu(r,"readable"),[i,s]=yield Pt(Promise.race(e.map(f=>f[2]))),i==="error")break;if((n=i==="end")||(Number.isFinite(a-l)?(c=ae(r.read(a-l)),c.byteLength0&&(u.push(c),l+=c.byteLength)),n||a<=l)do({cmd:o,size:a}=yield yield Pt(h()));while(a{for(const[m,_]of f)r.off(m,_);try{const m=r.destroy;m&&m.call(r,y),y=void 0}catch(m){y=m||y}finally{y!=null?d(y):g()}})}})}var ke;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(ke||(ke={}));var er;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(er||(er={}));var tr;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(tr||(tr={}));var Hr;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(Hr||(Hr={}));var zt;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(zt||(zt={}));var Si;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Si||(Si={}));const Hu=2,pi=4,ji=4,me=4,on=new Int32Array(2),fp=new Float32Array(on.buffer),dp=new Float64Array(on.buffer),Na=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var nh;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(nh||(nh={}));let Qs=class Ev{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Ev(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))<>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){fp[0]=e,this.writeInt32(t,on[0])}writeFloat64(t,e){dp[0]=e,this.writeInt32(t,on[Na?0:1]),this.writeInt32(t+4,on[Na?1:0])}getBufferIdentifier(){if(this.bytes_.lengththis.minalign&&(this.minalign=t);const i=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space=0&&this.vtable[e]==0;e--);const i=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);const n=2;this.addInt16(t-this.object_start);const s=(i+n)*Hu;this.addInt16(s);let o=0;const a=this.space;t:for(e=0;e=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,pi+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const i=this.bb.capacity()-t,n=i-this.bb.readInt32(i);if(!(e=0;i--)t.addInt32(e[i]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,i){return hr.startUnion(t),hr.addMode(t,e),hr.addTypeIds(t,i),hr.endUnion(t)}}let bp=class Fo{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Fo).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+me),(e||new Fo).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Fo.startUtf8(t),Fo.endUtf8(t)}};var xe;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(xe||(xe={}));let Nr=class Ga{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new Ga).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+me),(e||new Ga).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,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):xe.NONE}type(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){const e=this.bb.__offset(this.bb_pos,12);return e?(t||new $i).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){const i=this.bb.__offset(this.bb_pos,14);return i?(e||new Ga).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){const i=this.bb.__offset(this.bb_pos,16);return i?(e||new We).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,xe.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}},ui=class Mi{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new Mi).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+me),(e||new Mi).__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):Ks.Little}fields(t,e){const i=this.bb.__offset(this.bb_pos,6);return i?(e||new Nr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){const i=this.bb.__offset(this.bb_pos,8);return i?(e||new We).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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 e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+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,e){t.addFieldInt16(0,e,Ks.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let i=e.length-1;i>=0;i--)t.addInt64(e[i]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,i,n,s){return Mi.startSchema(t),Mi.addEndianness(t,e),Mi.addFields(t,i),Mi.addCustomMetadata(t,n),Mi.addFeatures(t,s),Mi.endSchema(t)}};var fe;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(fe||(fe={}));var L;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(L||(L={}));var ki;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(ki||(ki={}));const LC=void 0;function Xo(r){if(r===null)return"null";if(r===LC)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>Xo(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}function we(r){if(typeof r=="bigint"&&(rNumber.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function Pv(r,t){return we(r/t)+we(r%t)/we(t)}const BC=Symbol.for("isArrowBigNum");function ri(r,...t){return t.length===0?Object.setPrototypeOf(_e(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ri.prototype[BC]=!0;ri.prototype.toJSON=function(){return`"${qo(this)}"`};ri.prototype.valueOf=function(r){return Mv(this,r)};ri.prototype.toString=function(){return qo(this)};ri.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Mv(this);case"string":return qo(this);case"default":return zC(this)}return qo(this)};function zs(...r){return ri.apply(this,r)}function js(...r){return ri.apply(this,r)}function Yo(...r){return ri.apply(this,r)}Object.setPrototypeOf(zs.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(js.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Yo.prototype,Object.create(Uint32Array.prototype));Object.assign(zs.prototype,ri.prototype,{constructor:zs,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(js.prototype,ri.prototype,{constructor:js,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Yo.prototype,ri.prototype,{constructor:Yo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const kC=BigInt(4294967296)*BigInt(4294967296),UC=kC-BigInt(1);function Mv(r,t){const{buffer:e,byteOffset:i,byteLength:n,signed:s}=r,o=new BigUint64Array(e,i,n/8),a=s&&o.at(-1)&BigInt(1)<=0)return Xu(r);t=t.slice();let i=1;for(let s=0;s(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(At.prototype);let pn=class extends At{constructor(){super(L.Null)}toString(){return"Null"}};Nv=Symbol.toStringTag;pn[Nv]=(r=>r[Symbol.toStringTag]="Null")(pn.prototype);let is=class extends At{constructor(t,e){super(L.Int),this.isSigned=t,this.bitWidth=e}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}`}};Lv=Symbol.toStringTag;is[Lv]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(is.prototype);class Qo extends is{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Qo.prototype,"ArrayType",{value:Int32Array});let cl=class extends At{constructor(t){super(L.Float),this.precision=t}get ArrayType(){switch(this.precision){case tr.HALF:return Uint16Array;case tr.SINGLE:return Float32Array;case tr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Bv=Symbol.toStringTag;cl[Bv]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(cl.prototype);let hl=class extends At{constructor(){super(L.Binary)}toString(){return"Binary"}};kv=Symbol.toStringTag;hl[kv]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(hl.prototype);let fl=class extends At{constructor(){super(L.LargeBinary)}toString(){return"LargeBinary"}};Uv=Symbol.toStringTag;fl[Uv]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(fl.prototype);let dl=class extends At{constructor(){super(L.Utf8)}toString(){return"Utf8"}};zv=Symbol.toStringTag;dl[zv]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(dl.prototype);let pl=class extends At{constructor(){super(L.LargeUtf8)}toString(){return"LargeUtf8"}};jv=Symbol.toStringTag;pl[jv]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(pl.prototype);let ml=class extends At{constructor(){super(L.Bool)}toString(){return"Bool"}};$v=Symbol.toStringTag;ml[$v]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(ml.prototype);let yl=class extends At{constructor(t,e,i=128){super(L.Decimal),this.scale=t,this.precision=e,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Vv=Symbol.toStringTag;yl[Vv]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(yl.prototype);let gl=class extends At{constructor(t){super(L.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${Hr[this.unit]}>`}get ArrayType(){return this.unit===Hr.DAY?Int32Array:BigInt64Array}};Gv=Symbol.toStringTag;gl[Gv]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(gl.prototype);let vl=class extends At{constructor(t,e){super(L.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${zt[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};Wv=Symbol.toStringTag;vl[Wv]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(vl.prototype);let _l=class extends At{constructor(t,e){super(L.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${zt[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};Hv=Symbol.toStringTag;_l[Hv]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(_l.prototype);let bl=class extends At{constructor(t){super(L.Interval),this.unit=t}toString(){return`Interval<${Si[this.unit]}>`}};Xv=Symbol.toStringTag;bl[Xv]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(bl.prototype);let wl=class extends At{constructor(t){super(L.Duration),this.unit=t}toString(){return`Duration<${zt[this.unit]}>`}};Yv=Symbol.toStringTag;wl[Yv]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(wl.prototype);let xl=class extends At{constructor(t){super(L.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}};qv=Symbol.toStringTag;xl[qv]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(xl.prototype);let sr=class extends At{constructor(t){super(L.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};Qv=Symbol.toStringTag;sr[Qv]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(sr.prototype);let Sl=class extends At{constructor(t,e,i){super(L.Union),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((n,s,o)=>(n[s]=o)&&n||n,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};Kv=Symbol.toStringTag;Sl[Kv]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Sl.prototype);let Tl=class extends At{constructor(t){super(L.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Zv=Symbol.toStringTag;Tl[Zv]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Tl.prototype);let Il=class extends At{constructor(t,e){super(L.FixedSizeList),this.listSize=t,this.children=[e]}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}>`}};Jv=Symbol.toStringTag;Il[Jv]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Il.prototype);let El=class extends At{constructor(t,e=!1){var i,n,s;if(super(L.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((i=t==null?void 0:t.type)===null||i===void 0)&&i.children)){const o=(n=t==null?void 0:t.type)===null||n===void 0?void 0:n.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};t_=Symbol.toStringTag;El[t_]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(El.prototype);const $C=(r=>()=>++r)(-1);let Zs=class extends At{constructor(t,e,i,n){super(L.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=i==null?$C():we(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};e_=Symbol.toStringTag;Zs[e_]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Zs.prototype);function Ui(r){const t=r;switch(r.typeId){case L.Decimal:return r.bitWidth/32;case L.Interval:return 1+t.unit;case L.FixedSizeList:return t.listSize;case L.FixedSizeBinary:return t.byteWidth;default:return 1}}let ie=class{visitMany(t,...e){return t.map((i,n)=>this.visit(i,...e.map(s=>s[n])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return VC(this,t,e)}getVisitFnByTypeId(t,e=!0){return As(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function VC(r,t,e=!0){return typeof t=="number"?As(r,t,e):typeof t=="string"&&t in L?As(r,L[t],e):t&&t instanceof At?As(r,wp(t),e):t!=null&&t.type&&t.type instanceof At?As(r,wp(t.type),e):As(r,L.NONE,e)}function As(r,t,e=!0){let i=null;switch(t){case L.Null:i=r.visitNull;break;case L.Bool:i=r.visitBool;break;case L.Int:i=r.visitInt;break;case L.Int8:i=r.visitInt8||r.visitInt;break;case L.Int16:i=r.visitInt16||r.visitInt;break;case L.Int32:i=r.visitInt32||r.visitInt;break;case L.Int64:i=r.visitInt64||r.visitInt;break;case L.Uint8:i=r.visitUint8||r.visitInt;break;case L.Uint16:i=r.visitUint16||r.visitInt;break;case L.Uint32:i=r.visitUint32||r.visitInt;break;case L.Uint64:i=r.visitUint64||r.visitInt;break;case L.Float:i=r.visitFloat;break;case L.Float16:i=r.visitFloat16||r.visitFloat;break;case L.Float32:i=r.visitFloat32||r.visitFloat;break;case L.Float64:i=r.visitFloat64||r.visitFloat;break;case L.Utf8:i=r.visitUtf8;break;case L.LargeUtf8:i=r.visitLargeUtf8;break;case L.Binary:i=r.visitBinary;break;case L.LargeBinary:i=r.visitLargeBinary;break;case L.FixedSizeBinary:i=r.visitFixedSizeBinary;break;case L.Date:i=r.visitDate;break;case L.DateDay:i=r.visitDateDay||r.visitDate;break;case L.DateMillisecond:i=r.visitDateMillisecond||r.visitDate;break;case L.Timestamp:i=r.visitTimestamp;break;case L.TimestampSecond:i=r.visitTimestampSecond||r.visitTimestamp;break;case L.TimestampMillisecond:i=r.visitTimestampMillisecond||r.visitTimestamp;break;case L.TimestampMicrosecond:i=r.visitTimestampMicrosecond||r.visitTimestamp;break;case L.TimestampNanosecond:i=r.visitTimestampNanosecond||r.visitTimestamp;break;case L.Time:i=r.visitTime;break;case L.TimeSecond:i=r.visitTimeSecond||r.visitTime;break;case L.TimeMillisecond:i=r.visitTimeMillisecond||r.visitTime;break;case L.TimeMicrosecond:i=r.visitTimeMicrosecond||r.visitTime;break;case L.TimeNanosecond:i=r.visitTimeNanosecond||r.visitTime;break;case L.Decimal:i=r.visitDecimal;break;case L.List:i=r.visitList;break;case L.Struct:i=r.visitStruct;break;case L.Union:i=r.visitUnion;break;case L.DenseUnion:i=r.visitDenseUnion||r.visitUnion;break;case L.SparseUnion:i=r.visitSparseUnion||r.visitUnion;break;case L.Dictionary:i=r.visitDictionary;break;case L.Interval:i=r.visitInterval;break;case L.IntervalDayTime:i=r.visitIntervalDayTime||r.visitInterval;break;case L.IntervalYearMonth:i=r.visitIntervalYearMonth||r.visitInterval;break;case L.Duration:i=r.visitDuration;break;case L.DurationSecond:i=r.visitDurationSecond||r.visitDuration;break;case L.DurationMillisecond:i=r.visitDurationMillisecond||r.visitDuration;break;case L.DurationMicrosecond:i=r.visitDurationMicrosecond||r.visitDuration;break;case L.DurationNanosecond:i=r.visitDurationNanosecond||r.visitDuration;break;case L.FixedSizeList:i=r.visitFixedSizeList;break;case L.Map:i=r.visitMap;break}if(typeof i=="function")return i;if(!e)return()=>null;throw new Error(`Unrecognized type '${L[t]}'`)}function wp(r){switch(r.typeId){case L.Null:return L.Null;case L.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?L.Int8:L.Uint8;case 16:return e?L.Int16:L.Uint16;case 32:return e?L.Int32:L.Uint32;case 64:return e?L.Int64:L.Uint64}return L.Int}case L.Float:switch(r.precision){case tr.HALF:return L.Float16;case tr.SINGLE:return L.Float32;case tr.DOUBLE:return L.Float64}return L.Float;case L.Binary:return L.Binary;case L.LargeBinary:return L.LargeBinary;case L.Utf8:return L.Utf8;case L.LargeUtf8:return L.LargeUtf8;case L.Bool:return L.Bool;case L.Decimal:return L.Decimal;case L.Time:switch(r.unit){case zt.SECOND:return L.TimeSecond;case zt.MILLISECOND:return L.TimeMillisecond;case zt.MICROSECOND:return L.TimeMicrosecond;case zt.NANOSECOND:return L.TimeNanosecond}return L.Time;case L.Timestamp:switch(r.unit){case zt.SECOND:return L.TimestampSecond;case zt.MILLISECOND:return L.TimestampMillisecond;case zt.MICROSECOND:return L.TimestampMicrosecond;case zt.NANOSECOND:return L.TimestampNanosecond}return L.Timestamp;case L.Date:switch(r.unit){case Hr.DAY:return L.DateDay;case Hr.MILLISECOND:return L.DateMillisecond}return L.Date;case L.Interval:switch(r.unit){case Si.DAY_TIME:return L.IntervalDayTime;case Si.YEAR_MONTH:return L.IntervalYearMonth}return L.Interval;case L.Duration:switch(r.unit){case zt.SECOND:return L.DurationSecond;case zt.MILLISECOND:return L.DurationMillisecond;case zt.MICROSECOND:return L.DurationMicrosecond;case zt.NANOSECOND:return L.DurationNanosecond}return L.Duration;case L.Map:return L.Map;case L.List:return L.List;case L.Struct:return L.Struct;case L.Union:switch(r.mode){case er.Dense:return L.DenseUnion;case er.Sparse:return L.SparseUnion}return L.Union;case L.FixedSizeBinary:return L.FixedSizeBinary;case L.FixedSizeList:return L.FixedSizeList;case L.Dictionary:return L.Dictionary}throw new Error(`Unrecognized type '${L[r.typeId]}'`)}ie.prototype.visitInt8=null;ie.prototype.visitInt16=null;ie.prototype.visitInt32=null;ie.prototype.visitInt64=null;ie.prototype.visitUint8=null;ie.prototype.visitUint16=null;ie.prototype.visitUint32=null;ie.prototype.visitUint64=null;ie.prototype.visitFloat16=null;ie.prototype.visitFloat32=null;ie.prototype.visitFloat64=null;ie.prototype.visitDateDay=null;ie.prototype.visitDateMillisecond=null;ie.prototype.visitTimestampSecond=null;ie.prototype.visitTimestampMillisecond=null;ie.prototype.visitTimestampMicrosecond=null;ie.prototype.visitTimestampNanosecond=null;ie.prototype.visitTimeSecond=null;ie.prototype.visitTimeMillisecond=null;ie.prototype.visitTimeMicrosecond=null;ie.prototype.visitTimeNanosecond=null;ie.prototype.visitDenseUnion=null;ie.prototype.visitSparseUnion=null;ie.prototype.visitIntervalDayTime=null;ie.prototype.visitIntervalYearMonth=null;ie.prototype.visitDuration=null;ie.prototype.visitDurationSecond=null;ie.prototype.visitDurationMillisecond=null;ie.prototype.visitDurationMicrosecond=null;ie.prototype.visitDurationNanosecond=null;const r_=new Float64Array(1),gs=new Uint32Array(r_.buffer);function i_(r){const t=(r&31744)>>10,e=(r&1023)/1024,i=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return i*(e?Number.NaN:1/0);case 0:return i*(e?6103515625e-14*e:0)}return i*Math.pow(2,t-15)*(1+e)}function GC(r){if(r!==r)return 32256;r_[0]=r;const t=(gs[1]&2147483648)>>16&65535;let e=gs[1]&2146435072,i=0;return e>=1089470464?gs[0]>0?e=31744:(e=(e&2080374784)>>16,i=(gs[1]&1048575)>>10):e<=1056964608?(i=1048576+(gs[1]&1048575),i=1048576+(i<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,i=(gs[1]&1048575)+512>>10),t|e|i&65535}let jt=class extends ie{};function Xt(r){return(t,e,i)=>{if(t.setValid(e,i!=null))return r(t,e,i)}}const WC=(r,t,e)=>{r[t]=Math.floor(e/864e5)},n_=(r,t,e,i)=>{if(e+1{const n=r+e;i?t[n>>3]|=1<>3]&=~(1<{r[t]=e},sf=({values:r},t,e)=>{r[t]=e},s_=({values:r},t,e)=>{r[t]=GC(e)},XC=(r,t,e)=>{switch(r.type.precision){case tr.HALF:return s_(r,t,e);case tr.SINGLE:case tr.DOUBLE:return sf(r,t,e)}},o_=({values:r},t,e)=>{WC(r,t,e.valueOf())},a_=({values:r},t,e)=>{r[t]=BigInt(e)},YC=({stride:r,values:t},e,i)=>{t.set(i.subarray(0,r),r*e)},l_=({values:r,valueOffsets:t},e,i)=>n_(r,t,e,i),u_=({values:r,valueOffsets:t},e,i)=>n_(r,t,e,ef(i)),qC=(r,t,e)=>{r.type.unit===Hr.DAY?o_(r,t,e):a_(r,t,e)},c_=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},h_=({values:r},t,e)=>{r[t]=BigInt(e)},f_=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},d_=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},QC=(r,t,e)=>{switch(r.type.unit){case zt.SECOND:return c_(r,t,e);case zt.MILLISECOND:return h_(r,t,e);case zt.MICROSECOND:return f_(r,t,e);case zt.NANOSECOND:return d_(r,t,e)}},p_=({values:r},t,e)=>{r[t]=e},m_=({values:r},t,e)=>{r[t]=e},y_=({values:r},t,e)=>{r[t]=e},g_=({values:r},t,e)=>{r[t]=e},KC=(r,t,e)=>{switch(r.type.unit){case zt.SECOND:return p_(r,t,e);case zt.MILLISECOND:return m_(r,t,e);case zt.MICROSECOND:return y_(r,t,e);case zt.NANOSECOND:return g_(r,t,e)}},ZC=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},JC=(r,t,e)=>{const i=r.children[0],n=r.valueOffsets,s=Xr.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=n[t],l=n[t+1];a{const i=r.children[0],{valueOffsets:n}=r,s=Xr.getVisitFn(i);let{[t]:o,[t+1]:a}=n;const l=e instanceof Map?e.entries():Object.entries(e);for(const u of l)if(s(i,o,u),++o>=a)break},eA=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[s]),rA=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(s)),iA=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(n.name)),nA=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[n.name]),sA=(r,t,e)=>{const i=r.type.children.map(s=>Xr.getVisitFn(s.type)),n=e instanceof Map?iA(t,e):e instanceof Me?rA(t,e):Array.isArray(e)?eA(t,e):nA(t,e);r.type.children.forEach((s,o)=>n(i[o],r.children[o],s,o))},oA=(r,t,e)=>{r.type.mode===er.Dense?v_(r,t,e):__(r,t,e)},v_=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Xr.visit(n,r.valueOffsets[t],e)},__=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Xr.visit(n,t,e)},aA=(r,t,e)=>{var i;(i=r.dictionary)===null||i===void 0||i.set(r.values[t],e)},lA=(r,t,e)=>{r.type.unit===Si.DAY_TIME?b_(r,t,e):w_(r,t,e)},b_=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},w_=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},x_=({values:r},t,e)=>{r[t]=e},S_=({values:r},t,e)=>{r[t]=e},T_=({values:r},t,e)=>{r[t]=e},I_=({values:r},t,e)=>{r[t]=e},uA=(r,t,e)=>{switch(r.type.unit){case zt.SECOND:return x_(r,t,e);case zt.MILLISECOND:return S_(r,t,e);case zt.MICROSECOND:return T_(r,t,e);case zt.NANOSECOND:return I_(r,t,e)}},cA=(r,t,e)=>{const{stride:i}=r,n=r.children[0],s=Xr.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=t*i;++o`${Xo(t)}: ${Xo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new hA(this[Kr],this[$s])}},hA=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[Kr].type.children.findIndex(i=>i.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[Kr].type.children.findIndex(i=>i.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Kr].type.children.findIndex(n=>n.name===e);if(i!==-1){const n=mr.visit(t[Kr].children[i],t[$s]);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Kr].type.children.findIndex(s=>s.name===e);return n!==-1?(Xr.visit(t[Kr].children[n],t[$s],i),Reflect.set(t,e,i)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,i):!1}},Mt=class extends ie{};function $t(r){return(t,e)=>t.getValid(e)?r(t,e):null}const dA=(r,t)=>864e5*r[t],pA=(r,t)=>null,E_=(r,t,e)=>{if(e+1>=t.length)return null;const i=we(t[e]),n=we(t[e+1]);return r.subarray(i,n)},mA=({offset:r,values:t},e)=>{const i=r+e;return(t[i>>3]&1<dA(r,t),A_=({values:r},t)=>we(r[t]),wn=({stride:r,values:t},e)=>t[r*e],yA=({stride:r,values:t},e)=>i_(t[r*e]),O_=({values:r},t)=>r[t],gA=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),F_=({values:r,valueOffsets:t},e)=>E_(r,t,e),P_=({values:r,valueOffsets:t},e)=>{const i=E_(r,t,e);return i!==null?eh(i):null},vA=({values:r},t)=>r[t],_A=({type:r,values:t},e)=>r.precision!==tr.HALF?t[e]:i_(t[e]),bA=(r,t)=>r.type.unit===Hr.DAY?C_(r,t):A_(r,t),M_=({values:r},t)=>1e3*we(r[t]),D_=({values:r},t)=>we(r[t]),R_=({values:r},t)=>Pv(r[t],BigInt(1e3)),N_=({values:r},t)=>Pv(r[t],BigInt(1e6)),wA=(r,t)=>{switch(r.type.unit){case zt.SECOND:return M_(r,t);case zt.MILLISECOND:return D_(r,t);case zt.MICROSECOND:return R_(r,t);case zt.NANOSECOND:return N_(r,t)}},L_=({values:r},t)=>r[t],B_=({values:r},t)=>r[t],k_=({values:r},t)=>r[t],U_=({values:r},t)=>r[t],xA=(r,t)=>{switch(r.type.unit){case zt.SECOND:return L_(r,t);case zt.MILLISECOND:return B_(r,t);case zt.MICROSECOND:return k_(r,t);case zt.NANOSECOND:return U_(r,t)}},SA=({values:r,stride:t},e)=>jC.decimal(r.subarray(t*e,t*(e+1))),TA=(r,t)=>{const{valueOffsets:e,stride:i,children:n}=r,{[t*i]:s,[t*i+1]:o}=e,l=n[0].slice(s,o-s);return new Me([l])},IA=(r,t)=>{const{valueOffsets:e,children:i}=r,{[t]:n,[t+1]:s}=e,o=i[0];return new af(o.slice(n,s-n))},EA=(r,t)=>new of(r,t),CA=(r,t)=>r.type.mode===er.Dense?z_(r,t):j_(r,t),z_=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mr.visit(i,r.valueOffsets[t])},j_=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return mr.visit(i,t)},AA=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},OA=(r,t)=>r.type.unit===Si.DAY_TIME?$_(r,t):V_(r,t),$_=({values:r},t)=>r.subarray(2*t,2*(t+1)),V_=({values:r},t)=>{const e=r[t],i=new Int32Array(2);return i[0]=Math.trunc(e/12),i[1]=Math.trunc(e%12),i},G_=({values:r},t)=>r[t],W_=({values:r},t)=>r[t],H_=({values:r},t)=>r[t],X_=({values:r},t)=>r[t],FA=(r,t)=>{switch(r.type.unit){case zt.SECOND:return G_(r,t);case zt.MILLISECOND:return W_(r,t);case zt.MICROSECOND:return H_(r,t);case zt.NANOSECOND:return X_(r,t)}},PA=(r,t)=>{const{stride:e,children:i}=r,s=i[0].slice(t*e,e);return new Me([s])};Mt.prototype.visitNull=$t(pA);Mt.prototype.visitBool=$t(mA);Mt.prototype.visitInt=$t(vA);Mt.prototype.visitInt8=$t(wn);Mt.prototype.visitInt16=$t(wn);Mt.prototype.visitInt32=$t(wn);Mt.prototype.visitInt64=$t(O_);Mt.prototype.visitUint8=$t(wn);Mt.prototype.visitUint16=$t(wn);Mt.prototype.visitUint32=$t(wn);Mt.prototype.visitUint64=$t(O_);Mt.prototype.visitFloat=$t(_A);Mt.prototype.visitFloat16=$t(yA);Mt.prototype.visitFloat32=$t(wn);Mt.prototype.visitFloat64=$t(wn);Mt.prototype.visitUtf8=$t(P_);Mt.prototype.visitLargeUtf8=$t(P_);Mt.prototype.visitBinary=$t(F_);Mt.prototype.visitLargeBinary=$t(F_);Mt.prototype.visitFixedSizeBinary=$t(gA);Mt.prototype.visitDate=$t(bA);Mt.prototype.visitDateDay=$t(C_);Mt.prototype.visitDateMillisecond=$t(A_);Mt.prototype.visitTimestamp=$t(wA);Mt.prototype.visitTimestampSecond=$t(M_);Mt.prototype.visitTimestampMillisecond=$t(D_);Mt.prototype.visitTimestampMicrosecond=$t(R_);Mt.prototype.visitTimestampNanosecond=$t(N_);Mt.prototype.visitTime=$t(xA);Mt.prototype.visitTimeSecond=$t(L_);Mt.prototype.visitTimeMillisecond=$t(B_);Mt.prototype.visitTimeMicrosecond=$t(k_);Mt.prototype.visitTimeNanosecond=$t(U_);Mt.prototype.visitDecimal=$t(SA);Mt.prototype.visitList=$t(TA);Mt.prototype.visitStruct=$t(EA);Mt.prototype.visitUnion=$t(CA);Mt.prototype.visitDenseUnion=$t(z_);Mt.prototype.visitSparseUnion=$t(j_);Mt.prototype.visitDictionary=$t(AA);Mt.prototype.visitInterval=$t(OA);Mt.prototype.visitIntervalDayTime=$t($_);Mt.prototype.visitIntervalYearMonth=$t(V_);Mt.prototype.visitDuration=$t(FA);Mt.prototype.visitDurationSecond=$t(G_);Mt.prototype.visitDurationMillisecond=$t(W_);Mt.prototype.visitDurationMicrosecond=$t(H_);Mt.prototype.visitDurationNanosecond=$t(X_);Mt.prototype.visitFixedSizeList=$t(PA);Mt.prototype.visitMap=$t(IA);const mr=new Mt,Os=Symbol.for("keys"),Vs=Symbol.for("vals"),Fs=Symbol.for("kKeysAsStrings"),lh=Symbol.for("_kKeysAsStrings");let af=class{constructor(t){return this[Os]=new Me([t.children[0]]).memoize(),this[Vs]=t.children[1],new Proxy(this,new DA)}get[Fs](){return this[lh]||(this[lh]=Array.from(this[Os].toArray(),String))}[Symbol.iterator](){return new MA(this[Os],this[Vs])}get size(){return this[Os].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Os],e=this[Vs],i={};for(let n=-1,s=t.length;++n`${Xo(t)}: ${Xo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},MA=class{constructor(t,e){this.keys=t,this.vals=e,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),mr.visit(this.vals,t)]})}},DA=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Fs]}has(t,e){return t[Fs].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Fs].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Fs].indexOf(e);if(i!==-1){const n=mr.visit(Reflect.get(t,Vs),i);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Fs].indexOf(e);return n!==-1?(Xr.visit(Reflect.get(t,Vs),n,i),Reflect.set(t,e,i)):Reflect.has(t,e)?Reflect.set(t,e,i):!1}};Object.defineProperties(af.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Os]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Vs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[lh]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let xp;function Y_(r,t,e,i){const{length:n=0}=r;let s=typeof t!="number"?0:t,o=typeof e!="number"?n:e;return s<0&&(s=(s%n+n)%n),o<0&&(o=(o%n+n)%n),on&&(o=n),i?i(r,s,o):[s,o]}const lf=(r,t)=>r<0?t+r:r,Sp=r=>r!==r;function so(r){if(typeof r!=="object"||r===null)return Sp(r)?Sp:e=>e===r;if(r instanceof Date){const e=r.valueOf();return i=>i instanceof Date?i.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?FC(r,e):!1:r instanceof Map?NA(r):Array.isArray(r)?RA(r):r instanceof Me?LA(r):BA(r,!0)}function RA(r){const t=[];for(let e=-1,i=r.length;++e!1;const i=[];for(let n=-1,s=e.length;++n{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return kA(r,e);case Map:return Tp(r,e,e.keys());case af:case of:case Object:case void 0:return Tp(r,e,t||Object.keys(e))}return e instanceof Me?UA(r,e):!1}}function kA(r,t){const e=r.length;if(t.length!==e)return!1;for(let i=-1;++i>i}function Cl(r,t,e){const i=e.byteLength+7&-8;if(r>0||e.byteLength>3):Al(new uf(e,r,t,null,q_)).subarray(0,i)),n}return e}function Al(r){const t=[];let e=0,i=0,n=0;for(const o of r)o&&(n|=1<0)&&(t[e++]=n);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}let uf=class{constructor(t,e,i,n,s){this.bytes=t,this.length=i,this.context=n,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,n=t+(t%8===0?0:8-t%8);return uh(r,t,n)+uh(r,i,e)+jA(r,n>>3,i-n>>3)}function jA(r,t,e){let i=0,n=Math.trunc(t);const s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:n+e;for(;o-n>=4;)i+=Yu(s.getUint32(n)),n+=4;for(;o-n>=2;)i+=Yu(s.getUint16(n)),n+=2;for(;o-n>=1;)i+=Yu(s.getUint8(n)),n+=1;return i}function Yu(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const $A=-1;let Se=class ch{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 At.isSparseUnion(t)?this.children.some(e=>e.nullable):At.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:i,nullBitmap:n,typeIds:s}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(At.isUnion(this.type))return this.children.reduce((i,n)=>i+n.nullCount,0);let t=this._nullCount,e;return t<=$A&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-uh(e,this.offset,this.offset+this.length)),t}constructor(t,e,i,n,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1));let l;s instanceof ch?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Ui(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:e}=this;if(At.isUnion(e)){const i=e,n=this.children[i.typeIdToChildIndex[this.typeIds[t]]],s=i.mode===er.Dense?this.valueOffsets[t]:t;return n.getValid(s)}if(this.nullable&&this.nullCount>0){const i=this.offset+t;return(this.nullBitmap[i>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Cl(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[c];i=(h&u)!==0,s[c]=e?h|u:h&~u}return i!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,i=this.length,n=this._nullCount,s=this,o=this.children){return new ch(t,e,i,n,s,o,this.dictionary)}slice(t,e){const{stride:i,typeId:n,children:s}=this,o=+(this._nullCount===0)-1,a=n===16?i:1,l=this._sliceBuffers(t,e,i,n);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===L.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:i}=this,n=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);n[e>>3]=(1<0&&n.set(Cl(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[ki.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),s)}_sliceBuffers(t,e,i,n){let s;const{buffers:o}=this;return(s=o[ki.TYPE])&&(o[ki.TYPE]=s.subarray(t,t+e)),(s=o[ki.OFFSET])&&(o[ki.OFFSET]=s.subarray(t,t+e+1))||(s=o[ki.DATA])&&(o[ki.DATA]=n===6?s:s.subarray(i*t,i*(t+e))),o}_sliceChildren(t,e,i){return t.map(n=>n.slice(e,i))}};Se.prototype.children=Object.freeze([]);class Ro extends ie{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){const{["type"]:e,["offset"]:i=0,["length"]:n=0}=t;return new Se(e,i,n,n)}visitBool(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitInt(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitFloat(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitUtf8(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.data),s=ae(t.nullBitmap),o=yo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,n,s])}visitLargeUtf8(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.data),s=ae(t.nullBitmap),o=hp(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,n,s])}visitBinary(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.data),s=ae(t.nullBitmap),o=yo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,n,s])}visitLargeBinary(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.data),s=ae(t.nullBitmap),o=hp(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,n,s])}visitFixedSizeBinary(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitDate(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitTimestamp(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitTime(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitDecimal(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitList(t){const{["type"]:e,["offset"]:i=0,["child"]:n}=t,s=ae(t.nullBitmap),o=yo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,void 0,s],[n])}visitStruct(t){const{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=ae(t.nullBitmap),{length:o=n.reduce((l,{length:u})=>Math.max(l,u),0),nullCount:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,void 0,s],n)}visitUnion(t){const{["type"]:e,["offset"]:i=0,["children"]:n=[]}=t,s=_e(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(At.isSparseUnion(e))return new Se(e,i,o,a,[void 0,void 0,void 0,s],n);const l=yo(t.valueOffsets);return new Se(e,i,o,a,[l,void 0,void 0,s],n)}visitDictionary(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.indices.ArrayType,t.data),{["dictionary"]:o=new Me([new Ro().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[void 0,s,n],[],o)}visitInterval(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitDuration(t){const{["type"]:e,["offset"]:i=0}=t,n=ae(t.nullBitmap),s=_e(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,s,n])}visitFixedSizeList(t){const{["type"]:e,["offset"]:i=0,["child"]:n=new Ro().visit({type:e.valueType})}=t,s=ae(t.nullBitmap),{["length"]:o=n.length/Ui(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new Se(e,i,o,a,[void 0,void 0,s],[n])}visitMap(t){const{["type"]:e,["offset"]:i=0,["child"]:n=new Ro().visit({type:e.childType})}=t,s=ae(t.nullBitmap),o=yo(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new Se(e,i,a,l,[o,void 0,s],[n])}}const VA=new Ro;function se(r){return VA.visit(r)}let Ip=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function Q_(r){return r.reduce((t,e)=>t+e.nullCount,0)}function K_(r){return r.reduce((t,e,i)=>(t[i+1]=t[i]+e.length,t),new Uint32Array(r.length+1))}function Z_(r,t,e,i){const n=[];for(let s=-1,o=r.length;++s=i)break;if(e>=l+u)continue;if(l>=e&&l+u<=i){n.push(a);continue}const c=Math.max(0,e-l),h=Math.min(i-l,u);n.push(a.slice(c,h-c))}return n.length===0&&n.push(r[0].slice(0,0)),n}function cf(r,t,e,i){let n=0,s=0,o=t.length-1;do{if(n>=o-1)return e0?0:-1}function HA(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let i=0;for(const n of new uf(e,r.offset+(t||0),r.length,e,q_)){if(!n)return i;++i}return-1}function Qt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case L.Union:break;case L.Dictionary:break;default:return HA(r,e)}const i=mr.getVisitFn(r),n=so(t);for(let s=(e||0)-1,o=r.length;++s{const n=r.data[i];return n.values.subarray(0,n.length)[Symbol.iterator]()});let e=0;return new Ip(r.data.length,i=>{const s=r.data[i].length,o=r.slice(e,e+s);return e+=s,new XA(o)})}let XA=class{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof Se)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:u}=i0[o.typeId],c=s[0];this.isValid=h=>hf(c,h),this.get=h=>a(c,h),this.set=(h,p)=>l(c,h,p),this.indexOf=h=>u(c,h),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,n0[o.typeId]),this._offsets=K_(s);break}this.data=s,this.type=o,this.stride=Ui(o),this.numChildren=(n=(i=o.children)===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return GA(this.data)}get nullCount(){return Q_(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${L[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(lf(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return ff.visit(this)}concat(...t){return new zn(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new zn(Y_(this,t,e,({data:i,_offsets:n},s,o)=>Z_(i,n,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:i,stride:n,ArrayType:s}=this;switch(t.typeId){case L.Int:case L.Float:case L.Decimal:case L.Time:case L.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*n),o.offset),o.offset+=l*n,o),{array:new s(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return At.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(At.isDictionary(this.type)){const t=new Ep(this.data[0].dictionary),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new zn(e)}return new Ep(this)}unmemoize(){if(At.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new zn(e)}return this}};r0=Symbol.toStringTag;Me[r0]=(r=>{r.type=At.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(L).map(e=>L[e]).filter(e=>typeof e=="number"&&e!==L.NONE);for(const e of t){const i=mr.getVisitFnByTypeId(e),n=Xr.getVisitFnByTypeId(e),s=Fl.getVisitFnByTypeId(e);i0[e]={get:i,set:n,indexOf:s},n0[e]=Object.create(r,{isValid:{value:Ol(hf)},get:{value:Ol(mr.getVisitFnByTypeId(e))},set:{value:J_(Xr.getVisitFnByTypeId(e))},indexOf:{value:t0(Fl.getVisitFnByTypeId(e))}})}return"Vector"})(Me.prototype);let Ep=class s0 extends Me{constructor(t){super(t.data);const e=this.get,i=this.set,n=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){i.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new s0(n.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Me(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};class hh{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,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,e,i,n){return t.prep(8,24),t.writeInt64(BigInt(n??0)),t.pad(4),t.writeInt32(i),t.writeInt64(BigInt(e??0)),t.offset()}}class _r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new _r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+me),(e||new _r).__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):ke.V1}schema(t){const e=this.bb.__offset(this.bb_pos,6);return e?(t||new ui).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){const i=this.bb.__offset(this.bb_pos,8);return i?(e||new hh).__init(this.bb.__vector(this.bb_pos+i)+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,e){const i=this.bb.__offset(this.bb_pos,10);return i?(e||new hh).__init(this.bb.__vector(this.bb_pos+i)+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,e){const i=this.bb.__offset(this.bb_pos,12);return i?(e||new We).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){t.addFieldInt16(0,e,ke.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}}let Pe=class jn{constructor(t=[],e,i,n=ke.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=fh(this.fields)),this.dictionaries=i,this.metadataVersion=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){const e=new Set(t),i=this.fields.filter(n=>e.has(n.name));return new jn(i,this.metadata)}selectAt(t){const e=t.map(i=>this.fields[i]).filter(Boolean);return new jn(e,this.metadata)}assign(...t){const e=t[0]instanceof jn?t[0]:Array.isArray(t[0])?new jn(t[0]):new jn(t),i=[...this.fields],n=La(La(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{const l=i.findIndex(u=>u.name===a.name);return~l?(i[l]=a.clone({metadata:La(La(new Map,i[l].metadata),a.metadata)}))&&!1:!0}),o=fh(s,new Map);return new jn([...i,...s],n,new Map([...this.dictionaries,...o]))}};Pe.prototype.fields=null;Pe.prototype.metadata=null;Pe.prototype.dictionaries=null;class Ce{static new(...t){let[e,i,n,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],i===void 0&&(i=t[0].type),n===void 0&&(n=t[0].nullable),s===void 0&&(s=t[0].metadata)),new Ce(`${e}`,i,n,s)}constructor(t,e,i=!1,n){this.name=t,this.type=e,this.nullable=i,this.metadata=n||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,i,n,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,i=this.type,n=this.nullable,s=this.metadata]=t:{name:e=this.name,type:i=this.type,nullable:n=this.nullable,metadata:s=this.metadata}=t[0],Ce.new(e,i,n,s)}}Ce.prototype.type=null;Ce.prototype.name=null;Ce.prototype.nullable=null;Ce.prototype.metadata=null;function La(r,t){return new Map([...r||new Map,...t||new Map])}function fh(r,t=new Map){for(let e=-1,i=r.length;++e0&&fh(s.children,t)}return t}var YA=Cv,qA=Qs;class Ko{static decode(t){t=new qA(ae(t));const e=_r.getRootAsFooter(t),i=Pe.decode(e.schema(),new Map,e.version());return new QA(i,e)}static encode(t){const e=new YA,i=Pe.encode(e,t.schema);_r.startRecordBatchesVector(e,t.numRecordBatches);for(const o of[...t.recordBatches()].slice().reverse())mn.encode(e,o);const n=e.endVector();_r.startDictionariesVector(e,t.numDictionaries);for(const o of[...t.dictionaryBatches()].slice().reverse())mn.encode(e,o);const s=e.endVector();return _r.startFooter(e),_r.addSchema(e,i),_r.addVersion(e,ke.V5),_r.addRecordBatches(e,n),_r.addDictionaries(e,s),_r.finishFooterBuffer(e,_r.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=ke.V5,i,n){this.schema=t,this.version=e,i&&(this._recordBatches=i),n&&(this._dictionaryBatches=n)}*recordBatches(){for(let t,e=-1,i=this.numRecordBatches;++e=0&&t=0&&t=0&&t=0&&tthis._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return Zt(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(De);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return kr.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return kr.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return Zt(this,void 0,void 0,function*(){return yield this.abort(t),De})}return(t){return Zt(this,void 0,void 0,function*(){return yield this.close(),De})}read(t){return Zt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Zt(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((e,i)=>{this.resolvers.push({resolve:e,reject:i})}):Promise.resolve(De)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Wa extends KA{write(t){if((t=ae(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?eh(this.toUint8Array(!0)):this.toUint8Array(!1).then(eh)}toUint8Array(t=!1){return t?xi(this._values)[0]:Zt(this,void 0,void 0,function*(){var e,i,n,s;const o=[];let a=0;try{for(var l=!0,u=bi(this),c;c=yield u.next(),e=c.done,!e;l=!0){s=c.value,l=!1;const h=s;o.push(h),a+=h.byteLength}}catch(h){i={error:h}}finally{try{!l&&!e&&(n=u.return)&&(yield n.call(u))}finally{if(i)throw i.error}}return xi(o,a)[0]})}}class Pl{constructor(t){t&&(this.source=new ZA(kr.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 Js{constructor(t){t instanceof Js?this.source=t.source:t instanceof Wa?this.source=new Mn(kr.fromAsyncIterable(t)):Sv(t)?this.source=new Mn(kr.fromNodeStream(t)):rf(t)?this.source=new Mn(kr.fromDOMStream(t)):xv(t)?this.source=new Mn(kr.fromDOMStream(t.body)):oa(t)?this.source=new Mn(kr.fromIterable(t)):rs(t)?this.source=new Mn(kr.fromAsyncIterable(t)):no(t)&&(this.source=new Mn(kr.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 ZA{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,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||De)}return(t){return Object.create(this.source.return&&this.source.return(t)||De)}}class Mn{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return Zt(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return Zt(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return Zt(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return Zt(this,arguments,void 0,function*(e,i="read"){return yield this.source.next({cmd:i,size:e})})}throw(t){return Zt(this,void 0,void 0,function*(){const e=this.source.throw&&(yield this.source.throw(t))||De;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return Zt(this,void 0,void 0,function*(){const e=this.source.return&&(yield this.source.return(t))||De;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}}class Ap extends Pl{constructor(t,e){super(),this.position=0,this.buffer=ae(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){const{buffer:e,byteOffset:i}=this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let n=e[3]*i[3];this.buffer[0]=n&65535;let s=n>>>16;return n=e[2]*i[3],s+=n,n=e[3]*i[2]>>>0,s+=n,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Ns(this.buffer[3])} ${Ns(this.buffer[2])} ${Ns(this.buffer[1])} ${Ns(this.buffer[0])}`}static multiply(t,e){return new Ni(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Ni(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Ni.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Ni.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const i=t.startsWith("-"),n=t.length,s=new Ni(e);for(let o=i?1:0;o0&&this.readData(t,i)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+e)}readDictionary(t){return this.dictionaries.get(t.id)}}class eO extends a0{constructor(t,e,i,n,s){super(new Uint8Array(0),e,i,n,s),this.sources=t}readNullBitmap(t,e,{offset:i}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Al(this.sources[i])}readOffsets(t,{offset:e}=this.nextBufferRange()){return _e(Uint8Array,_e(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return _e(Uint8Array,_e(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){const{sources:i}=this;return At.isTimestamp(t)||(At.isInt(t)||At.isTime(t))&&t.bitWidth===64||At.isDuration(t)||At.isDate(t)&&t.unit===Hr.MILLISECOND?_e(Uint8Array,No.convertArray(i[e])):At.isDecimal(t)?_e(Uint8Array,tO.convertArray(i[e])):At.isBinary(t)||At.isLargeBinary(t)||At.isFixedSizeBinary(t)?rO(i[e]):At.isBool(t)?Al(i[e]):At.isUtf8(t)||At.isLargeUtf8(t)?ef(i[e].join("")):_e(Uint8Array,_e(t.ArrayType,i[e].map(n=>+n)))}}function rO(r){const t=r.join(""),e=new Uint8Array(t.length/2);for(let i=0;i>1]=Number.parseInt(t.slice(i,i+2),16);return e}let Nt=class extends ie{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((i,n)=>this.compareFields(i,e[n]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function lr(r,t){return t instanceof r.constructor}function us(r,t){return r===t||lr(r,t)}function Xi(r,t){return r===t||lr(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function ru(r,t){return r===t||lr(r,t)&&r.precision===t.precision}function iO(r,t){return r===t||lr(r,t)&&r.byteWidth===t.byteWidth}function mf(r,t){return r===t||lr(r,t)&&r.unit===t.unit}function aa(r,t){return r===t||lr(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function la(r,t){return r===t||lr(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function nO(r,t){return r===t||lr(r,t)&&r.children.length===t.children.length&&yn.compareManyFields(r.children,t.children)}function sO(r,t){return r===t||lr(r,t)&&r.children.length===t.children.length&&yn.compareManyFields(r.children,t.children)}function yf(r,t){return r===t||lr(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&yn.compareManyFields(r.children,t.children)}function oO(r,t){return r===t||lr(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&yn.visit(r.indices,t.indices)&&yn.visit(r.dictionary,t.dictionary)}function gf(r,t){return r===t||lr(r,t)&&r.unit===t.unit}function ua(r,t){return r===t||lr(r,t)&&r.unit===t.unit}function aO(r,t){return r===t||lr(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&yn.compareManyFields(r.children,t.children)}function lO(r,t){return r===t||lr(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&yn.compareManyFields(r.children,t.children)}Nt.prototype.visitNull=us;Nt.prototype.visitBool=us;Nt.prototype.visitInt=Xi;Nt.prototype.visitInt8=Xi;Nt.prototype.visitInt16=Xi;Nt.prototype.visitInt32=Xi;Nt.prototype.visitInt64=Xi;Nt.prototype.visitUint8=Xi;Nt.prototype.visitUint16=Xi;Nt.prototype.visitUint32=Xi;Nt.prototype.visitUint64=Xi;Nt.prototype.visitFloat=ru;Nt.prototype.visitFloat16=ru;Nt.prototype.visitFloat32=ru;Nt.prototype.visitFloat64=ru;Nt.prototype.visitUtf8=us;Nt.prototype.visitLargeUtf8=us;Nt.prototype.visitBinary=us;Nt.prototype.visitLargeBinary=us;Nt.prototype.visitFixedSizeBinary=iO;Nt.prototype.visitDate=mf;Nt.prototype.visitDateDay=mf;Nt.prototype.visitDateMillisecond=mf;Nt.prototype.visitTimestamp=aa;Nt.prototype.visitTimestampSecond=aa;Nt.prototype.visitTimestampMillisecond=aa;Nt.prototype.visitTimestampMicrosecond=aa;Nt.prototype.visitTimestampNanosecond=aa;Nt.prototype.visitTime=la;Nt.prototype.visitTimeSecond=la;Nt.prototype.visitTimeMillisecond=la;Nt.prototype.visitTimeMicrosecond=la;Nt.prototype.visitTimeNanosecond=la;Nt.prototype.visitDecimal=us;Nt.prototype.visitList=nO;Nt.prototype.visitStruct=sO;Nt.prototype.visitUnion=yf;Nt.prototype.visitDenseUnion=yf;Nt.prototype.visitSparseUnion=yf;Nt.prototype.visitDictionary=oO;Nt.prototype.visitInterval=gf;Nt.prototype.visitIntervalDayTime=gf;Nt.prototype.visitIntervalYearMonth=gf;Nt.prototype.visitDuration=ua;Nt.prototype.visitDurationSecond=ua;Nt.prototype.visitDurationMillisecond=ua;Nt.prototype.visitDurationMicrosecond=ua;Nt.prototype.visitDurationNanosecond=ua;Nt.prototype.visitFixedSizeList=aO;Nt.prototype.visitMap=lO;const yn=new Nt;function dh(r,t){return yn.compareSchemas(r,t)}function qu(r,t){return uO(r,t.map(e=>e.data.concat()))}function uO(r,t){const e=[...r.fields],i=[],n={numBatches:t.reduce((h,p)=>Math.max(h,p.length),0)};let s=0,o=0,a=-1;const l=t.length;let u,c=[];for(;n.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(i[s++]=se({type:new sr(e),length:o,nullCount:0,children:c.slice()})))}return[r=r.assign(e),i.map(h=>new fr(r,h))]}function cO(r,t,e,i,n){var s;const o=(t+63&-64)>>3;for(let a=-1,l=i.length;++a=t)c===t?e[a]=u:(e[a]=u.slice(0,t),n.numBatches=Math.max(n.numBatches,i[a].unshift(u.slice(t,c-t))));else{const h=r[a];r[a]=h.clone({nullable:!0}),e[a]=(s=u==null?void 0:u._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:se({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var l0;let gn=class $n{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new Pe([]),this._offsets=[0],this;let n,s;t[0]instanceof Pe&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());const o=l=>{if(l){if(l instanceof fr)return[l];if(l instanceof $n)return l.batches;if(l instanceof Se){if(l.type instanceof sr)return[new fr(new Pe(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(u=>o(u));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(u=>o(u));if(typeof l=="object"){const u=Object.keys(l),c=u.map(f=>new Me([l[f]])),h=n??new Pe(u.map((f,y)=>new Ce(String(f),c[y].type,c[y].nullable))),[,p]=qu(h,c);return p.length===0?[new fr(l)]:p}}}return[]},a=t.flatMap(l=>o(l));if(n=(i=n??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&i!==void 0?i:new Pe([]),!(n instanceof Pe))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of a){if(!(l instanceof fr))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!dh(n,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=n,this.batches=a,this._offsets=s??K_(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,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=Q_(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(lf(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?ff.visit(new Me(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
${this.toArray().join(`,
`)}
-]`}concat(...t){const e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new $n(e,i.map(n=>new fr(e,n)))}slice(t,e){const i=this.schema;[t,e]=Y_({length:this.numRows},t,e);const n=Z_(this.data,this._offsets,t,e);return new $n(i,n.map(s=>new fr(i,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&ti.children[t]);if(e.length===0){const{type:i}=this.schema.fields[t],n=se({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new Me(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&tthis.getChildAt(u));[s[t],a[t]]=[o,e],[i,n]=qu(i,a)}return new $n(i,n)}select(t){const e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){const e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new $n(e,i)}assign(t){const e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,l,u)=>{const[c,h]=a,p=e.findIndex(f=>f.name===l.name);return~p?h[p]=u:c.push(u),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,l)=>[l,n[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):t.getChildAt(l)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new $n(...qu(s,o))}};l0=Symbol.toStringTag;gn[l0]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Ol(hf),r.get=Ol(mr.getVisitFn(L.Struct)),r.set=J_(Xr.getVisitFn(L.Struct)),r.indexOf=t0(Fl.getVisitFn(L.Struct)),"Table"))(gn.prototype);var u0;let fr=class Po{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Pe))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=se({nullCount:0,type:new sr(this.schema.fields),children:this.schema.fields.map(e=>se({type:e.type,nullCount:0}))})]=t,!(this.data instanceof Se))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Op(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((l,u,c)=>(l.children[c]=e[u],l.length=Math.max(l.length,e[u].length),l.fields[c]=Ce.new({name:u,type:e[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new Pe(i),a=se({type:new sr(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Op(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=c0(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 mr.visit(this.data,t)}at(t){return this.get(lf(t,this.numRows))}set(t,e){return Xr.visit(this.data,t,e)}indexOf(t,e){return Fl.visit(this.data,t,e)}[Symbol.iterator](){return ff.visit(new Me([this.data]))}toArray(){return[...this]}concat(...t){return new gn(this.schema,[this,...t])}slice(t,e){const[i]=new Me([this.data]).slice(t,e).data;return new Po(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&tn.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&ta.name===s);~o&&(n[o]=this.data.children[o])}return new Po(e,se({type:i,length:this.numRows,children:n}))}selectAt(t){const e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=se({type:new sr(e.fields),length:this.numRows,children:i});return new Po(e,n)}};u0=Symbol.toStringTag;fr[u0]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(fr.prototype);function Op(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;const n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(const[a,l]of r.fields.entries()){const u=t[a];(!u||u.length!==e)&&(n[a]=l.clone({nullable:!0}),s[a]=(i=u==null?void 0:u._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:se({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),se({type:new sr(n),length:e,children:s})]}function c0(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++sse({type:n.type})),i=se({type:new sr(t.fields),nullCount:0,children:e});super(t,i)}}let en=class ai{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ai).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+me),(e||new ai).__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):ke.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):fe.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const i=this.bb.__offset(this.bb_pos,12);return i?(e||new We).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){t.addFieldInt16(0,e,ke.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,fe.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,i,n,s,o){return ai.startMessage(t),ai.addVersion(t,e),ai.addHeaderType(t,i),ai.addHeader(t,n),ai.addBodyLength(t,s),ai.addCustomMetadata(t,o),ai.endMessage(t)}};class hO extends ie{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return _p.startNull(e),_p.endNull(e)}visitInt(t,e){return xr.startInt(e),xr.addBitWidth(e,t.bitWidth),xr.addIsSigned(e,t.isSigned),xr.endInt(e)}visitFloat(t,e){return mi.startFloatingPoint(e),mi.addPrecision(e,t.precision),mi.endFloatingPoint(e)}visitBinary(t,e){return pp.startBinary(e),pp.endBinary(e)}visitLargeBinary(t,e){return yp.startLargeBinary(e),yp.endLargeBinary(e)}visitBool(t,e){return mp.startBool(e),mp.endBool(e)}visitUtf8(t,e){return bp.startUtf8(e),bp.endUtf8(e)}visitLargeUtf8(t,e){return gp.startLargeUtf8(e),gp.endLargeUtf8(e)}visitDecimal(t,e){return Ss.startDecimal(e),Ss.addScale(e,t.scale),Ss.addPrecision(e,t.precision),Ss.addBitWidth(e,t.bitWidth),Ss.endDecimal(e)}visitDate(t,e){return Ua.startDate(e),Ua.addUnit(e,t.unit),Ua.endDate(e)}visitTime(t,e){return zr.startTime(e),zr.addUnit(e,t.unit),zr.addBitWidth(e,t.bitWidth),zr.endTime(e)}visitTimestamp(t,e){const i=t.timezone&&e.createString(t.timezone)||void 0;return jr.startTimestamp(e),jr.addUnit(e,t.unit),i!==void 0&&jr.addTimezone(e,i),jr.endTimestamp(e)}visitInterval(t,e){return yi.startInterval(e),yi.addUnit(e,t.unit),yi.endInterval(e)}visitDuration(t,e){return za.startDuration(e),za.addUnit(e,t.unit),za.endDuration(e)}visitList(t,e){return vp.startList(e),vp.endList(e)}visitStruct(t,e){return Yn.startStruct_(e),Yn.endStruct_(e)}visitUnion(t,e){hr.startTypeIdsVector(e,t.typeIds.length);const i=hr.createTypeIdsVector(e,t.typeIds);return hr.startUnion(e),hr.addMode(e,t.mode),hr.addTypeIds(e,i),hr.endUnion(e)}visitDictionary(t,e){const i=this.visit(t.indices,e);return $i.startDictionaryEncoding(e),$i.addId(e,BigInt(t.id)),$i.addIsOrdered(e,t.isOrdered),i!==void 0&&$i.addIndexType(e,i),$i.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return ja.startFixedSizeBinary(e),ja.addByteWidth(e,t.byteWidth),ja.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return $a.startFixedSizeList(e),$a.addListSize(e,t.listSize),$a.endFixedSizeList(e)}visitMap(t,e){return Va.startMap(e),Va.addKeysSorted(e,t.keysSorted),Va.endMap(e)}}const Qu=new hO;function fO(r,t=new Map){return new Pe(pO(r,t),Ha(r.metadata),t)}function h0(r){return new Fr(r.count,f0(r.columns),d0(r.columns))}function dO(r){return new Ti(h0(r.data),r.id,r.isDelta)}function pO(r,t){return(r.fields||[]).filter(Boolean).map(e=>Ce.fromJSON(e,t))}function Fp(r,t){return(r.children||[]).filter(Boolean).map(e=>Ce.fromJSON(e,t))}function f0(r){return(r||[]).reduce((t,e)=>[...t,new vn(e.count,mO(e.VALIDITY)),...f0(e.children)],[])}function d0(r,t=[]){for(let e=-1,i=(r||[]).length;++et+ +(e===0),0)}function yO(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=Mp(r,Fp(r,t)),n=new Ce(r.name,o,r.nullable,Ha(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?Pp(i):new Qo,a=new Zs(t.get(e),i,e,s.isOrdered),n=new Ce(r.name,a,r.nullable,Ha(r.metadata))):(i=(i=s.indexType)?Pp(i):new Qo,t.set(e,o=Mp(r,Fp(r,t))),a=new Zs(o,i,e,s.isOrdered),n=new Ce(r.name,a,r.nullable,Ha(r.metadata))),n||null}function Ha(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Pp(r){return new is(r.isSigned,r.bitWidth)}function Mp(r,t){const e=r.type.name;switch(e){case"NONE":return new pn;case"null":return new pn;case"binary":return new hl;case"largebinary":return new fl;case"utf8":return new dl;case"largeutf8":return new pl;case"bool":return new ml;case"list":return new xl((t||[])[0]);case"struct":return new sr(t||[]);case"struct_":return new sr(t||[])}switch(e){case"int":{const i=r.type;return new is(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=r.type;return new cl(tr[i.precision])}case"decimal":{const i=r.type;return new yl(i.scale,i.precision,i.bitWidth)}case"date":{const i=r.type;return new gl(Hr[i.unit])}case"time":{const i=r.type;return new vl(zt[i.unit],i.bitWidth)}case"timestamp":{const i=r.type;return new _l(zt[i.unit],i.timezone)}case"interval":{const i=r.type;return new bl(Si[i.unit])}case"duration":{const i=r.type;return new wl(zt[i.unit])}case"union":{const i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new Sl(er[o],i.typeIds||[],t||[])}case"fixedsizebinary":{const i=r.type;return new Tl(i.byteWidth)}case"fixedsizelist":{const i=r.type;return new Il(i.listSize,(t||[])[0])}case"map":{const i=r.type;return new El((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var gO=Cv,vO=Qs;class or{static fromJSON(t,e){const i=new or(0,ke.V5,e);return i._createHeader=_O(t,e),i}static decode(t){t=new vO(ae(t));const e=en.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new or(i,n,s);return o._createHeader=bO(e,s),o}static encode(t){const e=new gO;let i=-1;return t.isSchema()?i=Pe.encode(e,t.header()):t.isRecordBatch()?i=Fr.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ti.encode(e,t.header())),en.startMessage(e),en.addVersion(e,ke.V5),en.addHeader(e,i),en.addHeaderType(e,t.headerType),en.addBodyLength(e,BigInt(t.bodyLength)),en.finishMessageBuffer(e,en.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Pe)return new or(0,ke.V5,fe.Schema,t);if(t instanceof Fr)return new or(e,ke.V5,fe.RecordBatch,t);if(t instanceof Ti)return new or(e,ke.V5,fe.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===fe.Schema}isRecordBatch(){return this.headerType===fe.RecordBatch}isDictionaryBatch(){return this.headerType===fe.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),n&&(this._createHeader=()=>n),this._bodyLength=we(t)}}class Fr{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,i){this._nodes=e,this._buffers=i,this._length=we(t)}}class Ti{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,e,i=!1){this._data=t,this._isDelta=i,this._id=we(e)}}class vi{constructor(t,e){this.offset=we(t),this.length=we(e)}}class vn{constructor(t,e){this.length=we(t),this.nullCount=we(e)}}function _O(r,t){return()=>{switch(t){case fe.Schema:return Pe.fromJSON(r);case fe.RecordBatch:return Fr.fromJSON(r);case fe.DictionaryBatch:return Ti.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${fe[t]}, type: ${t} }`)}}function bO(r,t){return()=>{switch(t){case fe.Schema:return Pe.decode(r.header(new ui),new Map,r.version());case fe.RecordBatch:return Fr.decode(r.header(new Bi),r.version());case fe.DictionaryBatch:return Ti.decode(r.header(new ws),r.version())}throw new Error(`Unrecognized Message type: { name: ${fe[t]}, type: ${t} }`)}}Ce.encode=PO;Ce.decode=OO;Ce.fromJSON=yO;Pe.encode=FO;Pe.decode=wO;Pe.fromJSON=fO;Fr.encode=MO;Fr.decode=xO;Fr.fromJSON=h0;Ti.encode=DO;Ti.decode=SO;Ti.fromJSON=dO;vn.encode=RO;vn.decode=IO;vi.encode=NO;vi.decode=TO;function wO(r,t=new Map,e=ke.V5){const i=AO(r,t);return new Pe(i,Xa(r),t,e)}function xO(r,t=ke.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Fr(r.length(),EO(r),CO(r,t))}function SO(r,t=ke.V5){return new Ti(Fr.decode(r.data(),t),r.id(),r.isDelta())}function TO(r){return new vi(r.offset(),r.length())}function IO(r){return new vn(r.length(),r.nullCount())}function EO(r){const t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++iCe.encode(r,s));ui.startFieldsVector(r,e.length);const i=ui.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?ui.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{const a=r.createString(`${s}`),l=r.createString(`${o}`);return We.startKeyValue(r),We.addKey(r,a),We.addValue(r,l),We.endKeyValue(r)})):-1;return ui.startSchema(r),ui.addFields(r,i),ui.addEndianness(r,LO?Ks.Little:Ks.Big),n!==-1&&ui.addCustomMetadata(r,n),ui.endSchema(r)}function PO(r,t){let e=-1,i=-1,n=-1;const s=t.type;let o=t.typeId;At.isDictionary(s)?(o=s.dictionary.typeId,n=Qu.visit(s,r),i=Qu.visit(s.dictionary,r)):i=Qu.visit(s,r);const a=(s.children||[]).map(c=>Ce.encode(r,c)),l=Nr.createChildrenVector(r,a),u=t.metadata&&t.metadata.size>0?Nr.createCustomMetadataVector(r,[...t.metadata].map(([c,h])=>{const p=r.createString(`${c}`),f=r.createString(`${h}`);return We.startKeyValue(r),We.addKey(r,p),We.addValue(r,f),We.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Nr.startField(r),Nr.addType(r,i),Nr.addTypeType(r,o),Nr.addChildren(r,l),Nr.addNullable(r,!!t.nullable),e!==-1&&Nr.addName(r,e),n!==-1&&Nr.addDictionary(r,n),u!==-1&&Nr.addCustomMetadata(r,u),Nr.endField(r)}function MO(r,t){const e=t.nodes||[],i=t.buffers||[];Bi.startNodesVector(r,e.length);for(const o of e.slice().reverse())vn.encode(r,o);const n=r.endVector();Bi.startBuffersVector(r,i.length);for(const o of i.slice().reverse())vi.encode(r,o);const s=r.endVector();return Bi.startRecordBatch(r),Bi.addLength(r,BigInt(t.length)),Bi.addNodes(r,n),Bi.addBuffers(r,s),Bi.endRecordBatch(r)}function DO(r,t){const e=Fr.encode(r,t.data);return ws.startDictionaryBatch(r),ws.addId(r,BigInt(t.id)),ws.addIsDelta(r,t.isDelta),ws.addData(r,e),ws.endDictionaryBatch(r)}function RO(r,t){return Fv.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function NO(r,t){return Ov.createBuffer(r,BigInt(t.offset),BigInt(t.length))}const LO=(()=>{const r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})(),_f=r=>`Expected ${fe[r]} Message in stream, but was null or length 0.`,bf=r=>`Header pointer of flatbuffer-encoded ${fe[r]} Message is null or length 0.`,p0=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,m0=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`;class y0{constructor(t){this.source=t instanceof Pl?t:new Pl(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?De:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(_f(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=ae(this.source.read(t));if(e.byteLength[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(_f(t));return e.value}readSchema(){const t=fe.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(bf(t));return i}}const iu=4,ph="ARROW1",Zo=new Uint8Array(ph.length);for(let r=0;rthis):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 kr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return kr.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,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Vr?t:rh(t)?VO(t):wv(t)?HO(t):rs(t)?Zt(this,void 0,void 0,function*(){return yield Vr.from(yield t)}):xv(t)||rf(t)||Sv(t)||no(t)?WO(new Js(t)):GO(new Pl(t))}static readAll(t){return t instanceof Vr?t.isSync()?Lp(t):Bp(t):rh(t)||ArrayBuffer.isView(t)||oa(t)||bv(t)?Lp(t):Bp(t)}}class Dl extends Vr{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return dr(this,arguments,function*(){yield Pt(yield*ts(bi(this[Symbol.iterator]())))})}}class Rl extends Vr{constructor(t){super(t),this._impl=t}readAll(){return Zt(this,void 0,void 0,function*(){var t,e,i,n;const s=new Array;try{for(var o=!0,a=bi(this),l;l=yield a.next(),t=l.done,!t;o=!0){n=l.value,o=!1;const u=n;s.push(u)}}catch(u){e={error:u}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class v0 extends Dl{constructor(t){super(t),this._impl=t}}class zO extends Rl{constructor(t){super(t),this._impl=t}}class _0{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,e){const i=this._loadVectors(t,e,this.schema.fields),n=se({type:new sr(this.schema.fields),length:t.length,children:i});return new fr(this.schema,n)}_loadDictionaryBatch(t,e){const{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),l=o.dictionaries.get(i),u=this._loadVectors(t.data,e,[l]);return(a&&n?a.concat(new Me(u)):new Me(u)).memoize()}_loadVectors(t,e,i){return new a0(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class Nl extends _0{constructor(t,e){super(e),this._reader=rh(t)?new kO(this._handle=t):new y0(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=w0(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):De}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):De}next(){if(this.closed)return De;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vf(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ll extends _0{constructor(t,e){super(e),this._reader=new BO(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Zt(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 Zt(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=w0(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Zt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):De})}return(t){return Zt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):De})}next(){return Zt(this,void 0,void 0,function*(){if(this.closed)return De;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vf(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Zt(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class b0 extends Nl{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,e){super(t instanceof Ap?t:new Ap(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){const n=this._reader.readMessage(fe.RecordBatch);if(n!=null&&n.isRecordBatch()){const s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;const i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){const n=this._reader.readMessage(fe.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){const s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,e=t.size-g0,i=t.readInt32(e),n=t.readAt(e-i,i);return Ko.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Zt(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return Zt(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){const n=yield this._reader.readMessage(fe.RecordBatch);if(n!=null&&n.isRecordBatch()){const s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return Zt(this,void 0,void 0,function*(){var e;const i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){const n=yield this._reader.readMessage(fe.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){const s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return Zt(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-g0,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Ko.decode(n)})}_readNextMessageAndValidate(t){return Zt(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?wf(t)?new v0(new b0(r.read())):new Dl(new Nl(r)):new Dl(new Nl(function*(){}()))}function WO(r){return Zt(this,void 0,void 0,function*(){const t=yield r.peek(ca+7&-8);return t&&t.byteLength>=4?wf(t)?new v0(new b0(yield r.read())):new Rl(new Ll(r)):new Rl(new Ll(function(){return dr(this,arguments,function*(){})}()))})}function HO(r){return Zt(this,void 0,void 0,function*(){const{size:t}=yield r.stat(),e=new Ml(r,t);return t>=UO&&wf(yield e.readAt(0,ca+7&-8))?new zO(new jO(e)):new Rl(new Ll(e))})}class Ne extends ie{static assemble(...t){const e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof fr?s.data.children:s.data),i=new Ne;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof Me)return this.visitMany(t.data),this;const{type:e}=t;if(!At.isDictionary(e)){const{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(At.isUnion(e))this.nodes.push(new vn(i,0));else{const{nullCount:n}=t;At.isNull(e)||ti.call(this,n<=0?new Uint8Array(0):Cl(t.offset,i,t.nullBitmap)),this.nodes.push(new vn(i,n))}}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 ti(r){const t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new vi(this._byteLength,t)),this._byteLength+=t,this}function XO(r){var t;const{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(ti.call(this,n),e.mode===er.Sparse)return mh.call(this,r);if(e.mode===er.Dense){if(r.offset<=0)return ti.call(this,s),mh.call(this,r);{const o=new Int32Array(i),a=Object.create(null),l=Object.create(null);for(let u,c,h=-1;++h{const h=e.typeIds[c],p=a[h],f=l[h];return u.slice(p,Math.min(i,f))}))}}return this}function YO(r){let t;return r.nullCount>=r.length?ti.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?ti.call(this,Cl(r.offset,r.length,t)):ti.call(this,Al(r.values))}function Yi(r){return ti.call(this,r.values.subarray(0,r.length*r.stride))}function nu(r){const{length:t,values:e,valueOffsets:i}=r,n=we(i[0]),s=we(i[t]),o=Math.min(s-n,e.byteLength-n);return ti.call(this,Iv(-n,t+1,i)),ti.call(this,e.subarray(n,n+o)),this}function xf(r){const{length:t,valueOffsets:e}=r;if(e){const{[0]:i,[t]:n}=e;return ti.call(this,Iv(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function mh(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Ne.prototype.visitBool=YO;Ne.prototype.visitInt=Yi;Ne.prototype.visitFloat=Yi;Ne.prototype.visitUtf8=nu;Ne.prototype.visitLargeUtf8=nu;Ne.prototype.visitBinary=nu;Ne.prototype.visitLargeBinary=nu;Ne.prototype.visitFixedSizeBinary=Yi;Ne.prototype.visitDate=Yi;Ne.prototype.visitTimestamp=Yi;Ne.prototype.visitTime=Yi;Ne.prototype.visitDecimal=Yi;Ne.prototype.visitList=xf;Ne.prototype.visitStruct=mh;Ne.prototype.visitUnion=XO;Ne.prototype.visitInterval=Yi;Ne.prototype.visitDuration=Yi;Ne.prototype.visitFixedSizeList=xf;Ne.prototype.visitMap=xf;class x0 extends df{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Wa,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,pr(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 rs(t)?t.then(e=>this.writeAll(e)):no(t)?Ef(this,t):If(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,e=null){return t===this._sink||t instanceof Wa?this._sink=t:(this._sink=new Wa,t&&SC(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&TC(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,(!e||!dh(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof gn&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof fr&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!dh(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof fr?t instanceof vf||this._writeRecordBatch(t):t instanceof gn?this.writeAll(t.batches):oa(t)&&this.writeAll(t)}_writeMessage(t,e=8){const i=e-1,n=or.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,l=a-s-o;return t.headerType===fe.RecordBatch?this._recordBatchBlocks.push(new mn(a,t.bodyLength,this._position)):t.headerType===fe.DictionaryBatch&&this._dictionaryBlocks.push(new mn(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(l)}_write(t){if(this._started){const e=ae(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(or.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Zo)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=Ne.assemble(t),o=new Fr(t.numRows,i,n),a=or.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,i=!1){const{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=Ne.assemble(new Me([t])),l=new Fr(t.length,s,o),u=new Ti(l,e,i),c=or.from(u,n);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,i,n;for(let s=-1,o=t.length;++s0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){var e,i;for(const[n,s]of t.dictionaries){const o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),l=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(const[u,c]of o.entries())this._writeDictionaryBatch(c,n,u>0);else if(li.writeAll(n)):no(t)?Ef(i,t):If(i,t)}}class Tf extends x0{static writeAll(t){const e=new Tf;return rs(t)?t.then(i=>e.writeAll(i)):no(t)?Ef(e,t):If(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){const e=Ko.encode(new Ko(t,ke.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function If(r,t){let e=t;t instanceof gn&&(e=t.batches,r.reset(void 0,t.schema));for(const i of e)r.write(i);return r.finish()}function Ef(r,t){return Zt(this,void 0,void 0,function*(){var e,i,n,s,o,a,l;try{for(e=!0,i=bi(t);n=yield i.next(),s=n.done,!s;e=!0){l=n.value,e=!1;const u=l;r.write(u)}}catch(u){o={error:u}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function qO(r,t="stream"){return(t==="stream"?Sf:Tf).writeAll(r).toUint8Array(!0)}var QO=Object.create,S0=Object.defineProperty,KO=Object.getOwnPropertyDescriptor,ZO=Object.getOwnPropertyNames,JO=Object.getPrototypeOf,t2=Object.prototype.hasOwnProperty,e2=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),r2=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ZO(t))!t2.call(r,n)&&n!==e&&S0(r,n,{get:()=>t[n],enumerable:!(i=KO(t,n))||i.enumerable});return r},i2=(r,t,e)=>(e=r!=null?QO(JO(r)):{},r2(!r||!r.__esModule?S0(e,"default",{value:r,enumerable:!0}):e,r)),n2=e2((r,t)=>{t.exports=Worker}),T0=(r=>(r[r.UNDEFINED=0]="UNDEFINED",r[r.AUTOMATIC=1]="AUTOMATIC",r[r.READ_ONLY=2]="READ_ONLY",r[r.READ_WRITE=3]="READ_WRITE",r))(T0||{}),s2=(r=>(r[r.IDENTIFIER=0]="IDENTIFIER",r[r.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",r[r.STRING_CONSTANT=2]="STRING_CONSTANT",r[r.OPERATOR=3]="OPERATOR",r[r.KEYWORD=4]="KEYWORD",r[r.COMMENT=5]="COMMENT",r))(s2||{}),o2=(r=>(r[r.NONE=0]="NONE",r[r.DEBUG=1]="DEBUG",r[r.INFO=2]="INFO",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR",r))(o2||{}),a2=(r=>(r[r.NONE=0]="NONE",r[r.CONNECT=1]="CONNECT",r[r.DISCONNECT=2]="DISCONNECT",r[r.OPEN=3]="OPEN",r[r.QUERY=4]="QUERY",r[r.INSTANTIATE=5]="INSTANTIATE",r))(a2||{}),l2=(r=>(r[r.NONE=0]="NONE",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR",r[r.START=3]="START",r[r.RUN=4]="RUN",r[r.CAPTURE=5]="CAPTURE",r))(l2||{}),u2=(r=>(r[r.NONE=0]="NONE",r[r.WEB_WORKER=1]="WEB_WORKER",r[r.NODE_WORKER=2]="NODE_WORKER",r[r.BINDINGS=3]="BINDINGS",r[r.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",r))(u2||{}),c2=class{log(r){}},I0=class{constructor(r=2){this.level=r}log(r){r.level>=this.level&&console.log(r)}},h2=(r=>(r[r.SUCCESS=0]="SUCCESS",r))(h2||{}),f2=class{constructor(r,t){this._bindings=r,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(r){return r(this._bindings,this._conn)}async query(r){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let t=await this._bindings.runQuery(this._conn,r),e=Vr.from(t);return console.assert(e.isSync(),"Reader is not sync"),console.assert(e.isFile(),"Reader is not file"),new gn(e)}async send(r,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let e=await this._bindings.startPendingQuery(this._conn,r,t);for(;e==null;)e=await this._bindings.pollPendingQuery(this._conn);let i=new E0(this._bindings,this._conn,e),n=await Vr.from(i);return console.assert(n.isAsync()),console.assert(n.isStream()),n}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(r){return await this._bindings.getTableNames(this._conn,r)}async prepare(r){let t=await this._bindings.createPrepared(this._conn,r);return new d2(this._bindings,this._conn,t)}async insertArrowTable(r,t){let e=qO(r,"stream");await this.insertArrowFromIPCStream(e,t)}async insertArrowFromIPCStream(r,t){await this._bindings.insertArrowFromIPCStream(this._conn,r,t)}async insertCSVFromPath(r,t){await this._bindings.insertCSVFromPath(this._conn,r,t)}async insertJSONFromPath(r,t){await this._bindings.insertJSONFromPath(this._conn,r,t)}},E0=class{constructor(r,t,e){this.db=r,this.conn=t,this.header=e,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 r;return this._inFlight!=null?(r=await this._inFlight,this._inFlight=null):r=await this.db.fetchQueryResults(this.conn),this._depleted=r.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:r}}[Symbol.asyncIterator](){return this}},d2=class{constructor(r,t,e){this.bindings=r,this.connectionId=t,this.statementId=e}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...r){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,r),e=Vr.from(t);return console.assert(e.isSync()),console.assert(e.isFile()),new gn(e)}async send(...r){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,r),e=new E0(this.bindings,this.connectionId,t),i=await Vr.from(e);return console.assert(i.isAsync()),console.assert(i.isStream()),i}},p2=(r=>(r.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",r.CLOSE_PREPARED="CLOSE_PREPARED",r.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",r.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",r.CONNECT="CONNECT",r.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",r.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",r.CREATE_PREPARED="CREATE_PREPARED",r.DISCONNECT="DISCONNECT",r.DROP_FILE="DROP_FILE",r.DROP_FILES="DROP_FILES",r.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",r.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",r.FLUSH_FILES="FLUSH_FILES",r.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",r.GET_TABLE_NAMES="GET_TABLE_NAMES",r.GET_VERSION="GET_VERSION",r.GLOB_FILE_INFOS="GLOB_FILE_INFOS",r.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",r.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",r.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",r.INSTANTIATE="INSTANTIATE",r.OPEN="OPEN",r.PING="PING",r.POLL_PENDING_QUERY="POLL_PENDING_QUERY",r.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",r.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",r.REGISTER_FILE_URL="REGISTER_FILE_URL",r.RESET="RESET",r.RUN_PREPARED="RUN_PREPARED",r.RUN_QUERY="RUN_QUERY",r.SEND_PREPARED="SEND_PREPARED",r.START_PENDING_QUERY="START_PENDING_QUERY",r.TOKENIZE="TOKENIZE",r))(p2||{}),m2=(r=>(r.CONNECTION_INFO="CONNECTION_INFO",r.ERROR="ERROR",r.FEATURE_FLAGS="FEATURE_FLAGS",r.FILE_BUFFER="FILE_BUFFER",r.FILE_INFOS="FILE_INFOS",r.FILE_SIZE="FILE_SIZE",r.FILE_STATISTICS="FILE_STATISTICS",r.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",r.LOG="LOG",r.OK="OK",r.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",r.QUERY_PLAN="QUERY_PLAN",r.QUERY_RESULT="QUERY_RESULT",r.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",r.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",r.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",r.REGISTERED_FILE="REGISTERED_FILE",r.SCRIPT_TOKENS="SCRIPT_TOKENS",r.SUCCESS="SUCCESS",r.TABLE_NAMES="TABLE_NAMES",r.VERSION_STRING="VERSION_STRING",r))(m2||{}),ue=class{constructor(r,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=r,this.data=t,this.promise=new Promise((e,i)=>{this.promiseResolver=e,this.promiseRejecter=i})}};function Ya(r){switch(r.typeId){case L.Binary:return{sqlType:"binary"};case L.Bool:return{sqlType:"bool"};case L.Date:return{sqlType:"date"};case L.DateDay:return{sqlType:"date32[d]"};case L.DateMillisecond:return{sqlType:"date64[ms]"};case L.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case L.Float:return{sqlType:"float"};case L.Float16:return{sqlType:"float16"};case L.Float32:return{sqlType:"float32"};case L.Float64:return{sqlType:"float64"};case L.Int:return{sqlType:"int32"};case L.Int16:return{sqlType:"int16"};case L.Int32:return{sqlType:"int32"};case L.Int64:return{sqlType:"int64"};case L.Uint16:return{sqlType:"uint16"};case L.Uint32:return{sqlType:"uint32"};case L.Uint64:return{sqlType:"uint64"};case L.Uint8:return{sqlType:"uint8"};case L.IntervalDayTime:return{sqlType:"interval[dt]"};case L.IntervalYearMonth:return{sqlType:"interval[m]"};case L.List:return{sqlType:"list",valueType:Ya(r.valueType)};case L.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case L.Null:return{sqlType:"null"};case L.Utf8:return{sqlType:"utf8"};case L.Struct:return{sqlType:"struct",fields:r.children.map(t=>yh(t.name,t.type))};case L.Map:{let t=r;return{sqlType:"map",keyType:Ya(t.keyType),valueType:Ya(t.valueType)}}case L.Time:return{sqlType:"time[s]"};case L.TimeMicrosecond:return{sqlType:"time[us]"};case L.TimeMillisecond:return{sqlType:"time[ms]"};case L.TimeNanosecond:return{sqlType:"time[ns]"};case L.TimeSecond:return{sqlType:"time[s]"};case L.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case L.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case L.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case L.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case L.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function yh(r,t){let e=Ya(t);return e.name=r,e}var y2=new TextEncoder,g2=class{constructor(r,t=null){this._onInstantiationProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=r,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(r){this._worker=r,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,e)=>{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(r,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let e=this._nextMessageId++;return this._pendingRequests.set(e,r),this._worker.postMessage({messageId:e,type:r.type,data:r.data},t),await r.promise}onMessage(r){var t;let e=r.data;switch(e.type){case"LOG":{this._logger.log(e.data);return}case"INSTANTIATE_PROGRESS":{for(let n of this._onInstantiationProgress)n(e.data);return}}let i=this._pendingRequests.get(e.requestId);if(!i){console.warn("unassociated response: [".concat(e.requestId,", ").concat(e.type.toString(),"]"));return}if(this._pendingRequests.delete(e.requestId),e.type=="ERROR"){let n=new Error(e.data.message);n.name=e.data.name,(t=Object.getOwnPropertyDescriptor(n,"stack"))!=null&&t.writable&&(n.stack=e.data.stack),i.promiseRejecter(n);return}switch(i.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(e.type=="OK"){i.promiseResolver(e.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],e.type=="OK"){i.promiseResolver(e.data);return}break;case"GLOB_FILE_INFOS":if(e.type=="FILE_INFOS"){i.promiseResolver(e.data);return}break;case"GET_VERSION":if(e.type=="VERSION_STRING"){i.promiseResolver(e.data);return}break;case"GET_FEATURE_FLAGS":if(e.type=="FEATURE_FLAGS"){i.promiseResolver(e.data);return}break;case"GET_TABLE_NAMES":if(e.type=="TABLE_NAMES"){i.promiseResolver(e.data);return}break;case"TOKENIZE":if(e.type=="SCRIPT_TOKENS"){i.promiseResolver(e.data);return}break;case"COPY_FILE_TO_BUFFER":if(e.type=="FILE_BUFFER"){i.promiseResolver(e.data);return}break;case"EXPORT_FILE_STATISTICS":if(e.type=="FILE_STATISTICS"){i.promiseResolver(e.data);return}break;case"CONNECT":if(e.type=="CONNECTION_INFO"){i.promiseResolver(e.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(e.type=="QUERY_RESULT"){i.promiseResolver(e.data);return}break;case"SEND_PREPARED":if(e.type=="QUERY_RESULT_HEADER"){i.promiseResolver(e.data);return}break;case"START_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(e.data);return}break;case"POLL_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(e.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],e.type=="SUCCESS"){i.promiseResolver(e.data);return}break;case"FETCH_QUERY_RESULTS":if(e.type=="QUERY_RESULT_CHUNK"){i.promiseResolver(e.data);return}break;case"CREATE_PREPARED":if(e.type=="PREPARED_STATEMENT_ID"){i.promiseResolver(e.data);return}break}i.promiseRejecter(new Error("unexpected response type: ".concat(e.type.toString())))}onError(r){console.error(r),console.error("error in duckdb worker: ".concat(r.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 r=new ue("RESET",null);return await this.postTask(r)}async ping(){let r=new ue("PING",null);await this.postTask(r)}async dropFile(r){let t=new ue("DROP_FILE",r);return await this.postTask(t)}async dropFiles(){let r=new ue("DROP_FILES",null);return await this.postTask(r)}async flushFiles(){let r=new ue("FLUSH_FILES",null);return await this.postTask(r)}async instantiate(r,t=null,e=i=>{}){this._onInstantiationProgress.push(e);let i=new ue("INSTANTIATE",[r,t]);return await this.postTask(i)}async getVersion(){let r=new ue("GET_VERSION",null);return await this.postTask(r)}async getFeatureFlags(){let r=new ue("GET_FEATURE_FLAGS",null);return await this.postTask(r)}async open(r){let t=new ue("OPEN",r);await this.postTask(t)}async tokenize(r){let t=new ue("TOKENIZE",r);return await this.postTask(t)}async connectInternal(){let r=new ue("CONNECT",null);return await this.postTask(r)}async connect(){let r=await this.connectInternal();return new f2(this,r)}async disconnect(r){let t=new ue("DISCONNECT",r);await this.postTask(t)}async runQuery(r,t){let e=new ue("RUN_QUERY",[r,t]);return await this.postTask(e)}async startPendingQuery(r,t,e=!1){let i=new ue("START_PENDING_QUERY",[r,t,e]);return await this.postTask(i)}async pollPendingQuery(r){let t=new ue("POLL_PENDING_QUERY",r);return await this.postTask(t)}async cancelPendingQuery(r){let t=new ue("CANCEL_PENDING_QUERY",r);return await this.postTask(t)}async fetchQueryResults(r){let t=new ue("FETCH_QUERY_RESULTS",r);return await this.postTask(t)}async getTableNames(r,t){let e=new ue("GET_TABLE_NAMES",[r,t]);return await this.postTask(e)}async createPrepared(r,t){let e=new ue("CREATE_PREPARED",[r,t]);return await this.postTask(e)}async closePrepared(r,t){let e=new ue("CLOSE_PREPARED",[r,t]);await this.postTask(e)}async runPrepared(r,t,e){let i=new ue("RUN_PREPARED",[r,t,e]);return await this.postTask(i)}async sendPrepared(r,t,e){let i=new ue("SEND_PREPARED",[r,t,e]);return await this.postTask(i)}async globFiles(r){let t=new ue("GLOB_FILE_INFOS",r);return await this.postTask(t)}async registerFileText(r,t){let e=y2.encode(t);await this.registerFileBuffer(r,e)}async registerFileURL(r,t,e,i){t===void 0&&(t=r);let n=new ue("REGISTER_FILE_URL",[r,t,e,i]);await this.postTask(n)}async registerEmptyFileBuffer(r){}async registerFileBuffer(r,t){let e=new ue("REGISTER_FILE_BUFFER",[r,t]);await this.postTask(e,[t.buffer])}async registerFileHandle(r,t,e,i){let n=new ue("REGISTER_FILE_HANDLE",[r,t,e,i]);await this.postTask(n,[])}async registerOPFSFileName(r){let t=new ue("REGISTER_OPFS_FILE_NAME",[r]);await this.postTask(t,[])}async collectFileStatistics(r,t){let e=new ue("COLLECT_FILE_STATISTICS",[r,t]);await this.postTask(e,[])}async exportFileStatistics(r){let t=new ue("EXPORT_FILE_STATISTICS",r);return await this.postTask(t,[])}async copyFileToBuffer(r){let t=new ue("COPY_FILE_TO_BUFFER",r);return await this.postTask(t)}async copyFileToPath(r,t){let e=new ue("COPY_FILE_TO_PATH",[r,t]);await this.postTask(e)}async insertArrowFromIPCStream(r,t,e){if(t.length==0)return;let i=new ue("INSERT_ARROW_FROM_IPC_STREAM",[r,t,e]);await this.postTask(i,[t.buffer])}async insertCSVFromPath(r,t,e){if(e.columns!==void 0){let n=[];for(let s in e.columns){let o=e.columns[s];n.push(yh(s,o))}e.columnsFlat=n,delete e.columns}let i=new ue("IMPORT_CSV_FROM_PATH",[r,t,e]);await this.postTask(i)}async insertJSONFromPath(r,t,e){if(e.columns!==void 0){let n=[];for(let s in e.columns){let o=e.columns[s];n.push(yh(s,o))}e.columnsFlat=n,delete e.columns}let i=new ue("IMPORT_JSON_FROM_PATH",[r,t,e]);await this.postTask(i)}};function v2(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}v2();var _2=(r=>(r[r.BUFFER=0]="BUFFER",r[r.NODE_FS=1]="NODE_FS",r[r.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",r[r.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",r[r.HTTP=4]="HTTP",r[r.S3=5]="S3",r))(_2||{}),b2=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])),w2=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])),x2=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])),S2=()=>(async r=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(r)}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])),T2={version:"1.29.1-dev68.0"},Cf=T2.version.split(".");Cf[0];Cf[1];Cf[2];var I2=()=>typeof navigator>"u",Ku=null,Zu=null,Ju=null,tc=null,ec=null;async function E2(){return Ku==null&&(Ku=typeof BigInt64Array<"u"),Zu==null&&(Zu=await w2()),Ju==null&&(Ju=await S2()),tc==null&&(tc=await x2()),ec==null&&(ec=await b2()),{bigInt64Array:Ku,crossOriginIsolated:I2()||globalThis.crossOriginIsolated||!1,wasmExceptions:Zu,wasmSIMD:tc,wasmThreads:Ju,wasmBulkMemory:ec}}async function kp(r){let t=await E2();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&r.coi)return{mainModule:r.coi.mainModule,mainWorker:r.coi.mainWorker,pthreadWorker:r.coi.pthreadWorker};if(r.eh)return{mainModule:r.eh.mainModule,mainWorker:r.eh.mainWorker,pthreadWorker:null}}return{mainModule:r.mvp.mainModule,mainWorker:r.mvp.mainWorker,pthreadWorker:null}}i2(n2());const rc={},Mo={};function Lo(r,t){try{const i=(rc[r]||(rc[r]=new Intl.DateTimeFormat("en-GB",{timeZone:r,hour:"numeric",timeZoneName:"longOffset"}).format))(t).split("GMT")[1]||"";return i in Mo?Mo[i]:Up(i,i.split(":"))}catch{if(r in Mo)return Mo[r];const e=r==null?void 0:r.match(C2);return e?Up(r,e.slice(1)):NaN}}const C2=/([+-]\d\d):?(\d\d)?/;function Up(r,t){const e=+t[0],i=+(t[1]||0);return Mo[r]=e>0?e*60+i:e*60-i}class Er extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Lo(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),C0(this),gh(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new Er(...e,t):new Er(Date.now(),t)}withTimeZone(t){return new Er(+this,t)}getTimezoneOffset(){return-Lo(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),gh(this),+this}[Symbol.for("constructDateFrom")](t){return new Er(+new Date(t),this.timeZone)}}const zp=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(r=>{if(!zp.test(r))return;const t=r.replace(zp,"$1UTC");Er.prototype[t]&&(r.startsWith("get")?Er.prototype[r]=function(){return this.internal[t]()}:(Er.prototype[r]=function(){return Date.prototype[t].apply(this.internal,arguments),A2(this),+this},Er.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),gh(this),+this}))});function gh(r){r.internal.setTime(+r),r.internal.setUTCMinutes(r.internal.getUTCMinutes()-r.getTimezoneOffset())}function A2(r){Date.prototype.setFullYear.call(r,r.internal.getUTCFullYear(),r.internal.getUTCMonth(),r.internal.getUTCDate()),Date.prototype.setHours.call(r,r.internal.getUTCHours(),r.internal.getUTCMinutes(),r.internal.getUTCSeconds(),r.internal.getUTCMilliseconds()),C0(r)}function C0(r){const t=Lo(r.timeZone,r),e=new Date(+r);e.setUTCHours(e.getUTCHours()-1);const i=-new Date(+r).getTimezoneOffset(),n=-new Date(+e).getTimezoneOffset(),s=i-n,o=Date.prototype.getHours.apply(r)!==r.internal.getUTCHours();s&&o&&r.internal.setUTCMinutes(r.internal.getUTCMinutes()+s);const a=i-t;a&&Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+a);const l=Lo(r.timeZone,r),c=-new Date(+r).getTimezoneOffset()-l,h=l!==t,p=c-a;if(h&&p){Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+p);const f=Lo(r.timeZone,r),y=l-f;y&&(r.internal.setUTCMinutes(r.internal.getUTCMinutes()+y),Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+y))}}const O2=new TextDecoder("utf-8"),F2=r=>O2.decode(r),P2=new TextEncoder,A0=r=>P2.encode(r),hi=r=>typeof r=="function",ha=r=>r!=null&&Object(r)===r,M2=r=>ha(r)&&hi(r.then),O0=r=>ha(r)&&hi(r[Symbol.iterator]),D2=r=>ha(r)&&hi(r[Symbol.asyncIterator]),R2=r=>ha(r)&&"done"in r&&"value"in r,N2=r=>ha(r)&&hi(r.clear)&&hi(r.bytes)&&hi(r.position)&&hi(r.setPosition)&&hi(r.capacity)&&hi(r.getBufferIdentifier)&&hi(r.createLong),Af=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function L2(r){const t=r[0]?[r[0]]:[];let e,i,n,s;for(let o,a,l=0,u=0,c=r.length;++lc+h.byteLength,0);let n,s,o,a=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,i);for(const c=e.length;++lrr(Int8Array,r),U2=r=>rr(Int16Array,r),z2=r=>rr(Int32Array,r),j2=r=>rr(BigInt64Array,r),$2=r=>rr(Uint8Array,r),V2=r=>rr(Uint16Array,r),G2=r=>rr(Uint32Array,r),W2=r=>rr(BigUint64Array,r),H2=r=>rr(Float32Array,r),X2=r=>rr(Float64Array,r),Y2=r=>rr(Uint8ClampedArray,r),_h=r=>(r.next(),r);function*Oi(r,t){const e=function*(n){yield n},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Af?e(t):O0(t)?t:e(t);return yield*_h(function*(n){let s=null;do s=n.next(yield rr(r,s));while(!s.done)}(i[Symbol.iterator]())),new r}const q2=r=>Oi(Int8Array,r),Q2=r=>Oi(Int16Array,r),K2=r=>Oi(Int32Array,r),Z2=r=>Oi(Uint8Array,r),J2=r=>Oi(Uint16Array,r),tF=r=>Oi(Uint32Array,r),eF=r=>Oi(Float32Array,r),rF=r=>Oi(Float64Array,r),iF=r=>Oi(Uint8ClampedArray,r);function ii(r,t){return dr(this,arguments,function*(){if(M2(t))return yield Pt(yield Pt(yield*ts(bi(ii(r,yield Pt(t))))));const i=function(o){return dr(this,arguments,function*(){yield yield Pt(yield Pt(o))})},n=function(o){return dr(this,arguments,function*(){yield Pt(yield*ts(bi(_h(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Af?i(t):O0(t)?n(t):D2(t)?t:i(t);return yield Pt(yield*ts(bi(_h(function(o){return dr(this,arguments,function*(){let a=null;do a=yield Pt(o.next(yield yield Pt(rr(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield Pt(new r)})}const nF=r=>ii(Int8Array,r),sF=r=>ii(Int16Array,r),oF=r=>ii(Int32Array,r),aF=r=>ii(Uint8Array,r),lF=r=>ii(Uint16Array,r),uF=r=>ii(Uint32Array,r),cF=r=>ii(Float32Array,r),hF=r=>ii(Float64Array,r),fF=r=>ii(Uint8ClampedArray,r);function dF(r,t,e){if(r!==0){e=e.slice(0,t);for(let i=-1,n=e.length;++i0)do if(r[e]!==t[e])return!1;while(++eeo(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}const yF=Object.freeze(Object.defineProperty({__proto__:null,valueToString:eo},Symbol.toStringTag,{value:"Module"}));function ar(r){if(typeof r=="bigint"&&(rNumber.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function P0(r,t){return ar(r/t)+ar(r%t)/ar(t)}const M0=Symbol.for("isArrowBigNum");function ni(r,...t){return t.length===0?Object.setPrototypeOf(rr(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ni.prototype[M0]=!0;ni.prototype.toJSON=function(){return`"${ro(this)}"`};ni.prototype.valueOf=function(r){return Of(this,r)};ni.prototype.toString=function(){return ro(this)};ni.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Of(this);case"string":return ro(this);case"default":return D0(this)}return ro(this)};function Gs(...r){return ni.apply(this,r)}function Ws(...r){return ni.apply(this,r)}function Jo(...r){return ni.apply(this,r)}Object.setPrototypeOf(Gs.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Ws.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Jo.prototype,Object.create(Uint32Array.prototype));Object.assign(Gs.prototype,ni.prototype,{constructor:Gs,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Ws.prototype,ni.prototype,{constructor:Ws,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Jo.prototype,ni.prototype,{constructor:Jo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const gF=BigInt(4294967296)*BigInt(4294967296),vF=gF-BigInt(1);function Of(r,t){const{buffer:e,byteOffset:i,byteLength:n,signed:s}=r,o=new BigUint64Array(e,i,n/8),a=s&&o.at(-1)&BigInt(1)<=0)return ic(r);t=t.slice();let i=1;for(let s=0;s(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(Et.prototype);class jp extends Et{constructor(){super(W.Null)}toString(){return"Null"}}N0=Symbol.toStringTag;jp[N0]=(r=>r[Symbol.toStringTag]="Null")(jp.prototype);class $p extends Et{constructor(t,e){super(W.Int),this.isSigned=t,this.bitWidth=e}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}`}}L0=Symbol.toStringTag;$p[L0]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))($p.prototype);class Vp extends Et{constructor(t){super(W.Float),this.precision=t}get ArrayType(){switch(this.precision){case Cr.HALF:return Uint16Array;case Cr.SINGLE:return Float32Array;case Cr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}B0=Symbol.toStringTag;Vp[B0]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Vp.prototype);class Gp extends Et{constructor(){super(W.Binary)}toString(){return"Binary"}}k0=Symbol.toStringTag;Gp[k0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Gp.prototype);class Wp extends Et{constructor(){super(W.LargeBinary)}toString(){return"LargeBinary"}}U0=Symbol.toStringTag;Wp[U0]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Wp.prototype);class Hp extends Et{constructor(){super(W.Utf8)}toString(){return"Utf8"}}z0=Symbol.toStringTag;Hp[z0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Hp.prototype);class Xp extends Et{constructor(){super(W.LargeUtf8)}toString(){return"LargeUtf8"}}j0=Symbol.toStringTag;Xp[j0]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Xp.prototype);class Yp extends Et{constructor(){super(W.Bool)}toString(){return"Bool"}}$0=Symbol.toStringTag;Yp[$0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Yp.prototype);class qp extends Et{constructor(t,e,i=128){super(W.Decimal),this.scale=t,this.precision=e,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}V0=Symbol.toStringTag;qp[V0]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(qp.prototype);class Qp extends Et{constructor(t){super(W.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${_n[this.unit]}>`}get ArrayType(){return this.unit===_n.DAY?Int32Array:BigInt64Array}}G0=Symbol.toStringTag;Qp[G0]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Qp.prototype);class Kp extends Et{constructor(t,e){super(W.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${Jt[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}W0=Symbol.toStringTag;Kp[W0]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Kp.prototype);class Zp extends Et{constructor(t,e){super(W.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${Jt[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}H0=Symbol.toStringTag;Zp[H0]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Zp.prototype);class Jp extends Et{constructor(t){super(W.Interval),this.unit=t}toString(){return`Interval<${ns[this.unit]}>`}}X0=Symbol.toStringTag;Jp[X0]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Jp.prototype);class tm extends Et{constructor(t){super(W.Duration),this.unit=t}toString(){return`Duration<${Jt[this.unit]}>`}}Y0=Symbol.toStringTag;tm[Y0]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(tm.prototype);class em extends Et{constructor(t){super(W.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}}q0=Symbol.toStringTag;em[q0]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(em.prototype);class bh extends Et{constructor(t){super(W.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Q0=Symbol.toStringTag;bh[Q0]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(bh.prototype);class rm extends Et{constructor(t,e,i){super(W.Union),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((n,s,o)=>(n[s]=o)&&n||n,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}K0=Symbol.toStringTag;rm[K0]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(rm.prototype);class im extends Et{constructor(t){super(W.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Z0=Symbol.toStringTag;im[Z0]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(im.prototype);class nm extends Et{constructor(t,e){super(W.FixedSizeList),this.listSize=t,this.children=[e]}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}>`}}J0=Symbol.toStringTag;nm[J0]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(nm.prototype);class sm extends Et{constructor(t,e=!1){var i,n,s;if(super(W.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((i=t==null?void 0:t.type)===null||i===void 0)&&i.children)){const o=(n=t==null?void 0:t.type)===null||n===void 0?void 0:n.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}tb=Symbol.toStringTag;sm[tb]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(sm.prototype);const bF=(r=>()=>++r)(-1);class om extends Et{constructor(t,e,i,n){super(W.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=i==null?bF():ar(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}eb=Symbol.toStringTag;om[eb]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(om.prototype);function rb(r){const t=r;switch(r.typeId){case W.Decimal:return r.bitWidth/32;case W.Interval:return 1+t.unit;case W.FixedSizeList:return t.listSize;case W.FixedSizeBinary:return t.byteWidth;default:return 1}}class le{visitMany(t,...e){return t.map((i,n)=>this.visit(i,...e.map(s=>s[n])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return wF(this,t,e)}getVisitFnByTypeId(t,e=!0){return Ps(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function wF(r,t,e=!0){return typeof t=="number"?Ps(r,t,e):typeof t=="string"&&t in W?Ps(r,W[t],e):t&&t instanceof Et?Ps(r,am(t),e):t!=null&&t.type&&t.type instanceof Et?Ps(r,am(t.type),e):Ps(r,W.NONE,e)}function Ps(r,t,e=!0){let i=null;switch(t){case W.Null:i=r.visitNull;break;case W.Bool:i=r.visitBool;break;case W.Int:i=r.visitInt;break;case W.Int8:i=r.visitInt8||r.visitInt;break;case W.Int16:i=r.visitInt16||r.visitInt;break;case W.Int32:i=r.visitInt32||r.visitInt;break;case W.Int64:i=r.visitInt64||r.visitInt;break;case W.Uint8:i=r.visitUint8||r.visitInt;break;case W.Uint16:i=r.visitUint16||r.visitInt;break;case W.Uint32:i=r.visitUint32||r.visitInt;break;case W.Uint64:i=r.visitUint64||r.visitInt;break;case W.Float:i=r.visitFloat;break;case W.Float16:i=r.visitFloat16||r.visitFloat;break;case W.Float32:i=r.visitFloat32||r.visitFloat;break;case W.Float64:i=r.visitFloat64||r.visitFloat;break;case W.Utf8:i=r.visitUtf8;break;case W.LargeUtf8:i=r.visitLargeUtf8;break;case W.Binary:i=r.visitBinary;break;case W.LargeBinary:i=r.visitLargeBinary;break;case W.FixedSizeBinary:i=r.visitFixedSizeBinary;break;case W.Date:i=r.visitDate;break;case W.DateDay:i=r.visitDateDay||r.visitDate;break;case W.DateMillisecond:i=r.visitDateMillisecond||r.visitDate;break;case W.Timestamp:i=r.visitTimestamp;break;case W.TimestampSecond:i=r.visitTimestampSecond||r.visitTimestamp;break;case W.TimestampMillisecond:i=r.visitTimestampMillisecond||r.visitTimestamp;break;case W.TimestampMicrosecond:i=r.visitTimestampMicrosecond||r.visitTimestamp;break;case W.TimestampNanosecond:i=r.visitTimestampNanosecond||r.visitTimestamp;break;case W.Time:i=r.visitTime;break;case W.TimeSecond:i=r.visitTimeSecond||r.visitTime;break;case W.TimeMillisecond:i=r.visitTimeMillisecond||r.visitTime;break;case W.TimeMicrosecond:i=r.visitTimeMicrosecond||r.visitTime;break;case W.TimeNanosecond:i=r.visitTimeNanosecond||r.visitTime;break;case W.Decimal:i=r.visitDecimal;break;case W.List:i=r.visitList;break;case W.Struct:i=r.visitStruct;break;case W.Union:i=r.visitUnion;break;case W.DenseUnion:i=r.visitDenseUnion||r.visitUnion;break;case W.SparseUnion:i=r.visitSparseUnion||r.visitUnion;break;case W.Dictionary:i=r.visitDictionary;break;case W.Interval:i=r.visitInterval;break;case W.IntervalDayTime:i=r.visitIntervalDayTime||r.visitInterval;break;case W.IntervalYearMonth:i=r.visitIntervalYearMonth||r.visitInterval;break;case W.Duration:i=r.visitDuration;break;case W.DurationSecond:i=r.visitDurationSecond||r.visitDuration;break;case W.DurationMillisecond:i=r.visitDurationMillisecond||r.visitDuration;break;case W.DurationMicrosecond:i=r.visitDurationMicrosecond||r.visitDuration;break;case W.DurationNanosecond:i=r.visitDurationNanosecond||r.visitDuration;break;case W.FixedSizeList:i=r.visitFixedSizeList;break;case W.Map:i=r.visitMap;break}if(typeof i=="function")return i;if(!e)return()=>null;throw new Error(`Unrecognized type '${W[t]}'`)}function am(r){switch(r.typeId){case W.Null:return W.Null;case W.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?W.Int8:W.Uint8;case 16:return e?W.Int16:W.Uint16;case 32:return e?W.Int32:W.Uint32;case 64:return e?W.Int64:W.Uint64}return W.Int}case W.Float:switch(r.precision){case Cr.HALF:return W.Float16;case Cr.SINGLE:return W.Float32;case Cr.DOUBLE:return W.Float64}return W.Float;case W.Binary:return W.Binary;case W.LargeBinary:return W.LargeBinary;case W.Utf8:return W.Utf8;case W.LargeUtf8:return W.LargeUtf8;case W.Bool:return W.Bool;case W.Decimal:return W.Decimal;case W.Time:switch(r.unit){case Jt.SECOND:return W.TimeSecond;case Jt.MILLISECOND:return W.TimeMillisecond;case Jt.MICROSECOND:return W.TimeMicrosecond;case Jt.NANOSECOND:return W.TimeNanosecond}return W.Time;case W.Timestamp:switch(r.unit){case Jt.SECOND:return W.TimestampSecond;case Jt.MILLISECOND:return W.TimestampMillisecond;case Jt.MICROSECOND:return W.TimestampMicrosecond;case Jt.NANOSECOND:return W.TimestampNanosecond}return W.Timestamp;case W.Date:switch(r.unit){case _n.DAY:return W.DateDay;case _n.MILLISECOND:return W.DateMillisecond}return W.Date;case W.Interval:switch(r.unit){case ns.DAY_TIME:return W.IntervalDayTime;case ns.YEAR_MONTH:return W.IntervalYearMonth}return W.Interval;case W.Duration:switch(r.unit){case Jt.SECOND:return W.DurationSecond;case Jt.MILLISECOND:return W.DurationMillisecond;case Jt.MICROSECOND:return W.DurationMicrosecond;case Jt.NANOSECOND:return W.DurationNanosecond}return W.Duration;case W.Map:return W.Map;case W.List:return W.List;case W.Struct:return W.Struct;case W.Union:switch(r.mode){case Ii.Dense:return W.DenseUnion;case Ii.Sparse:return W.SparseUnion}return W.Union;case W.FixedSizeBinary:return W.FixedSizeBinary;case W.FixedSizeList:return W.FixedSizeList;case W.Dictionary:return W.Dictionary}throw new Error(`Unrecognized type '${W[r.typeId]}'`)}le.prototype.visitInt8=null;le.prototype.visitInt16=null;le.prototype.visitInt32=null;le.prototype.visitInt64=null;le.prototype.visitUint8=null;le.prototype.visitUint16=null;le.prototype.visitUint32=null;le.prototype.visitUint64=null;le.prototype.visitFloat16=null;le.prototype.visitFloat32=null;le.prototype.visitFloat64=null;le.prototype.visitDateDay=null;le.prototype.visitDateMillisecond=null;le.prototype.visitTimestampSecond=null;le.prototype.visitTimestampMillisecond=null;le.prototype.visitTimestampMicrosecond=null;le.prototype.visitTimestampNanosecond=null;le.prototype.visitTimeSecond=null;le.prototype.visitTimeMillisecond=null;le.prototype.visitTimeMicrosecond=null;le.prototype.visitTimeNanosecond=null;le.prototype.visitDenseUnion=null;le.prototype.visitSparseUnion=null;le.prototype.visitIntervalDayTime=null;le.prototype.visitIntervalYearMonth=null;le.prototype.visitDuration=null;le.prototype.visitDurationSecond=null;le.prototype.visitDurationMillisecond=null;le.prototype.visitDurationMicrosecond=null;le.prototype.visitDurationNanosecond=null;const ib=new Float64Array(1),vs=new Uint32Array(ib.buffer);function Ff(r){const t=(r&31744)>>10,e=(r&1023)/1024,i=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return i*(e?Number.NaN:1/0);case 0:return i*(e?6103515625e-14*e:0)}return i*Math.pow(2,t-15)*(1+e)}function nb(r){if(r!==r)return 32256;ib[0]=r;const t=(vs[1]&2147483648)>>16&65535;let e=vs[1]&2146435072,i=0;return e>=1089470464?vs[0]>0?e=31744:(e=(e&2080374784)>>16,i=(vs[1]&1048575)>>10):e<=1056964608?(i=1048576+(vs[1]&1048575),i=1048576+(i<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,i=(vs[1]&1048575)+512>>10),t|e|i&65535}const xF=Object.freeze(Object.defineProperty({__proto__:null,float64ToUint16:nb,uint16ToFloat64:Ff},Symbol.toStringTag,{value:"Module"}));class Gt extends le{}function Yt(r){return(t,e,i)=>{if(t.setValid(e,i!=null))return r(t,e,i)}}const SF=(r,t,e)=>{r[t]=Math.floor(e/864e5)},sb=(r,t,e,i)=>{if(e+1{const n=r+e;i?t[n>>3]|=1<>3]&=~(1<{r[t]=e},Pf=({values:r},t,e)=>{r[t]=e},ob=({values:r},t,e)=>{r[t]=nb(e)},IF=(r,t,e)=>{switch(r.type.precision){case Cr.HALF:return ob(r,t,e);case Cr.SINGLE:case Cr.DOUBLE:return Pf(r,t,e)}},ab=({values:r},t,e)=>{SF(r,t,e.valueOf())},lb=({values:r},t,e)=>{r[t]=BigInt(e)},EF=({stride:r,values:t},e,i)=>{t.set(i.subarray(0,r),r*e)},ub=({values:r,valueOffsets:t},e,i)=>sb(r,t,e,i),cb=({values:r,valueOffsets:t},e,i)=>sb(r,t,e,A0(i)),CF=(r,t,e)=>{r.type.unit===_n.DAY?ab(r,t,e):lb(r,t,e)},hb=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},fb=({values:r},t,e)=>{r[t]=BigInt(e)},db=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},pb=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},AF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return hb(r,t,e);case Jt.MILLISECOND:return fb(r,t,e);case Jt.MICROSECOND:return db(r,t,e);case Jt.NANOSECOND:return pb(r,t,e)}},mb=({values:r},t,e)=>{r[t]=e},yb=({values:r},t,e)=>{r[t]=e},gb=({values:r},t,e)=>{r[t]=e},vb=({values:r},t,e)=>{r[t]=e},OF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return mb(r,t,e);case Jt.MILLISECOND:return yb(r,t,e);case Jt.MICROSECOND:return gb(r,t,e);case Jt.NANOSECOND:return vb(r,t,e)}},FF=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},PF=(r,t,e)=>{const i=r.children[0],n=r.valueOffsets,s=Ei.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=n[t],l=n[t+1];a{const i=r.children[0],{valueOffsets:n}=r,s=Ei.getVisitFn(i);let{[t]:o,[t+1]:a}=n;const l=e instanceof Map?e.entries():Object.entries(e);for(const u of l)if(s(i,o,u),++o>=a)break},DF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[s]),RF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(s)),NF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(n.name)),LF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[n.name]),BF=(r,t,e)=>{const i=r.type.children.map(s=>Ei.getVisitFn(s.type)),n=e instanceof Map?NF(t,e):e instanceof Qe?RF(t,e):Array.isArray(e)?DF(t,e):LF(t,e);r.type.children.forEach((s,o)=>n(i[o],r.children[o],s,o))},kF=(r,t,e)=>{r.type.mode===Ii.Dense?_b(r,t,e):bb(r,t,e)},_b=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Ei.visit(n,r.valueOffsets[t],e)},bb=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Ei.visit(n,t,e)},UF=(r,t,e)=>{var i;(i=r.dictionary)===null||i===void 0||i.set(r.values[t],e)},zF=(r,t,e)=>{r.type.unit===ns.DAY_TIME?wb(r,t,e):xb(r,t,e)},wb=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},xb=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Sb=({values:r},t,e)=>{r[t]=e},Tb=({values:r},t,e)=>{r[t]=e},Ib=({values:r},t,e)=>{r[t]=e},Eb=({values:r},t,e)=>{r[t]=e},jF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return Sb(r,t,e);case Jt.MILLISECOND:return Tb(r,t,e);case Jt.MICROSECOND:return Ib(r,t,e);case Jt.NANOSECOND:return Eb(r,t,e)}},$F=(r,t,e)=>{const{stride:i}=r,n=r.children[0],s=Ei.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=t*i;++o`${eo(t)}: ${eo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new VF(this[Zr],this[Hs])}}class VF{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[Zr].type.children.some(i=>i.name===e)}getOwnPropertyDescriptor(t,e){if(t[Zr].type.children.some(i=>i.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Zr].type.children.findIndex(n=>n.name===e);if(i!==-1){const n=Yr.visit(t[Zr].children[i],t[Hs]);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Zr].type.children.findIndex(s=>s.name===e);return n!==-1?(Ei.visit(t[Zr].children[n],t[Hs],i),Reflect.set(t,e,i)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,i):!1}}const WF=new GF;class Lt extends le{}function Wt(r){return(t,e)=>t.getValid(e)?r(t,e):null}const HF=(r,t)=>864e5*r[t],XF=(r,t)=>null,Cb=(r,t,e)=>{if(e+1>=t.length)return null;const i=ar(t[e]),n=ar(t[e+1]);return r.subarray(i,n)},YF=({offset:r,values:t},e)=>{const i=r+e;return(t[i>>3]&1<HF(r,t),Ob=({values:r},t)=>ar(r[t]),xn=({stride:r,values:t},e)=>t[r*e],qF=({stride:r,values:t},e)=>Ff(t[r*e]),Fb=({values:r},t)=>r[t],QF=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Pb=({values:r,valueOffsets:t},e)=>Cb(r,t,e),Mb=({values:r,valueOffsets:t},e)=>{const i=Cb(r,t,e);return i!==null?F2(i):null},KF=({values:r},t)=>r[t],ZF=({type:r,values:t},e)=>r.precision!==Cr.HALF?t[e]:Ff(t[e]),JF=(r,t)=>r.type.unit===_n.DAY?Ab(r,t):Ob(r,t),Db=({values:r},t)=>1e3*ar(r[t]),Rb=({values:r},t)=>ar(r[t]),Nb=({values:r},t)=>P0(r[t],BigInt(1e3)),Lb=({values:r},t)=>P0(r[t],BigInt(1e6)),tP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Db(r,t);case Jt.MILLISECOND:return Rb(r,t);case Jt.MICROSECOND:return Nb(r,t);case Jt.NANOSECOND:return Lb(r,t)}},Bb=({values:r},t)=>r[t],kb=({values:r},t)=>r[t],Ub=({values:r},t)=>r[t],zb=({values:r},t)=>r[t],eP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Bb(r,t);case Jt.MILLISECOND:return kb(r,t);case Jt.MICROSECOND:return Ub(r,t);case Jt.NANOSECOND:return zb(r,t)}},rP=({values:r,stride:t},e)=>su.decimal(r.subarray(t*e,t*(e+1))),iP=(r,t)=>{const{valueOffsets:e,stride:i,children:n}=r,{[t*i]:s,[t*i+1]:o}=e,l=n[0].slice(s,o-s);return new Qe([l])},nP=(r,t)=>{const{valueOffsets:e,children:i}=r,{[t]:n,[t+1]:s}=e,o=i[0];return new Df(o.slice(n,s-n))},sP=(r,t)=>new Mf(r,t),oP=(r,t)=>r.type.mode===Ii.Dense?jb(r,t):$b(r,t),jb=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return Yr.visit(i,r.valueOffsets[t])},$b=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return Yr.visit(i,t)},aP=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},lP=(r,t)=>r.type.unit===ns.DAY_TIME?Vb(r,t):Gb(r,t),Vb=({values:r},t)=>r.subarray(2*t,2*(t+1)),Gb=({values:r},t)=>{const e=r[t],i=new Int32Array(2);return i[0]=Math.trunc(e/12),i[1]=Math.trunc(e%12),i},Wb=({values:r},t)=>r[t],Hb=({values:r},t)=>r[t],Xb=({values:r},t)=>r[t],Yb=({values:r},t)=>r[t],uP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Wb(r,t);case Jt.MILLISECOND:return Hb(r,t);case Jt.MICROSECOND:return Xb(r,t);case Jt.NANOSECOND:return Yb(r,t)}},cP=(r,t)=>{const{stride:e,children:i}=r,s=i[0].slice(t*e,e);return new Qe([s])};Lt.prototype.visitNull=Wt(XF);Lt.prototype.visitBool=Wt(YF);Lt.prototype.visitInt=Wt(KF);Lt.prototype.visitInt8=Wt(xn);Lt.prototype.visitInt16=Wt(xn);Lt.prototype.visitInt32=Wt(xn);Lt.prototype.visitInt64=Wt(Fb);Lt.prototype.visitUint8=Wt(xn);Lt.prototype.visitUint16=Wt(xn);Lt.prototype.visitUint32=Wt(xn);Lt.prototype.visitUint64=Wt(Fb);Lt.prototype.visitFloat=Wt(ZF);Lt.prototype.visitFloat16=Wt(qF);Lt.prototype.visitFloat32=Wt(xn);Lt.prototype.visitFloat64=Wt(xn);Lt.prototype.visitUtf8=Wt(Mb);Lt.prototype.visitLargeUtf8=Wt(Mb);Lt.prototype.visitBinary=Wt(Pb);Lt.prototype.visitLargeBinary=Wt(Pb);Lt.prototype.visitFixedSizeBinary=Wt(QF);Lt.prototype.visitDate=Wt(JF);Lt.prototype.visitDateDay=Wt(Ab);Lt.prototype.visitDateMillisecond=Wt(Ob);Lt.prototype.visitTimestamp=Wt(tP);Lt.prototype.visitTimestampSecond=Wt(Db);Lt.prototype.visitTimestampMillisecond=Wt(Rb);Lt.prototype.visitTimestampMicrosecond=Wt(Nb);Lt.prototype.visitTimestampNanosecond=Wt(Lb);Lt.prototype.visitTime=Wt(eP);Lt.prototype.visitTimeSecond=Wt(Bb);Lt.prototype.visitTimeMillisecond=Wt(kb);Lt.prototype.visitTimeMicrosecond=Wt(Ub);Lt.prototype.visitTimeNanosecond=Wt(zb);Lt.prototype.visitDecimal=Wt(rP);Lt.prototype.visitList=Wt(iP);Lt.prototype.visitStruct=Wt(sP);Lt.prototype.visitUnion=Wt(oP);Lt.prototype.visitDenseUnion=Wt(jb);Lt.prototype.visitSparseUnion=Wt($b);Lt.prototype.visitDictionary=Wt(aP);Lt.prototype.visitInterval=Wt(lP);Lt.prototype.visitIntervalDayTime=Wt(Vb);Lt.prototype.visitIntervalYearMonth=Wt(Gb);Lt.prototype.visitDuration=Wt(uP);Lt.prototype.visitDurationSecond=Wt(Wb);Lt.prototype.visitDurationMillisecond=Wt(Hb);Lt.prototype.visitDurationMicrosecond=Wt(Xb);Lt.prototype.visitDurationNanosecond=Wt(Yb);Lt.prototype.visitFixedSizeList=Wt(cP);Lt.prototype.visitMap=Wt(nP);const Yr=new Lt,Ms=Symbol.for("keys"),Xs=Symbol.for("vals"),Ds=Symbol.for("kKeysAsStrings"),wh=Symbol.for("_kKeysAsStrings");class Df{constructor(t){return this[Ms]=new Qe([t.children[0]]).memoize(),this[Xs]=t.children[1],new Proxy(this,new fP)}get[Ds](){return this[wh]||(this[wh]=Array.from(this[Ms].toArray(),String))}[Symbol.iterator](){return new hP(this[Ms],this[Xs])}get size(){return this[Ms].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Ms],e=this[Xs],i={};for(let n=-1,s=t.length;++n`${eo(t)}: ${eo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class hP{constructor(t,e){this.keys=t,this.vals=e,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),Yr.visit(this.vals,t)]})}}class fP{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ds]}has(t,e){return t[Ds].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Ds].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Ds].indexOf(e);if(i!==-1){const n=Yr.visit(Reflect.get(t,Xs),i);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Ds].indexOf(e);return n!==-1?(Ei.visit(Reflect.get(t,Xs),n,i),Reflect.set(t,e,i)):Reflect.has(t,e)?Reflect.set(t,e,i):!1}}Object.defineProperties(Df.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ms]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Xs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wh]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let lm;function qb(r,t,e,i){const{length:n=0}=r;let s=typeof t!="number"?0:t,o=typeof e!="number"?n:e;return s<0&&(s=(s%n+n)%n),o<0&&(o=(o%n+n)%n),on&&(o=n),i?i(r,s,o):[s,o]}const Qb=(r,t)=>r<0?t+r:r,um=r=>r!==r;function cs(r){if(typeof r!=="object"||r===null)return um(r)?um:e=>e===r;if(r instanceof Date){const e=r.valueOf();return i=>i instanceof Date?i.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?F0(r,e):!1:r instanceof Map?pP(r):Array.isArray(r)?dP(r):r instanceof Qe?mP(r):yP(r,!0)}function dP(r){const t=[];for(let e=-1,i=r.length;++e!1;const i=[];for(let n=-1,s=e.length;++n{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return gP(r,e);case Map:return cm(r,e,e.keys());case Df:case Mf:case Object:case void 0:return cm(r,e,t||Object.keys(e))}return e instanceof Qe?vP(r,e):!1}}function gP(r,t){const e=r.length;if(t.length!==e)return!1;for(let i=-1;++i>i}function bP(r,t,e){return e?!!(r[t>>3]|=1<>3]&=~(1<0||e.byteLength>3):Zb(new au(e,r,t,null,Rf)).subarray(0,i)),n}return e}function Zb(r){const t=[];let e=0,i=0,n=0;for(const o of r)o&&(n|=1<0)&&(t[e++]=n);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class au{constructor(t,e,i,n,s){this.bytes=t,this.length=i,this.context=n,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,n=t+(t%8===0?0:8-t%8);return Bl(r,t,n)+Bl(r,i,e)+Jb(r,n>>3,i-n>>3)}function Jb(r,t,e){let i=0,n=Math.trunc(t);const s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:n+e;for(;o-n>=4;)i+=qa(s.getUint32(n)),n+=4;for(;o-n>=2;)i+=qa(s.getUint16(n)),n+=2;for(;o-n>=1;)i+=qa(s.getUint8(n)),n+=1;return i}function qa(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const wP=Object.freeze(Object.defineProperty({__proto__:null,BitIterator:au,getBit:Kb,getBool:Rf,packBools:Zb,popcnt_array:Jb,popcnt_bit_range:Bl,popcnt_uint32:qa,setBool:bP,truncateBitmap:xh},Symbol.toStringTag,{value:"Module"})),xP=-1;class ta{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 Et.isSparseUnion(t)?this.children.some(e=>e.nullable):Et.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:i,nullBitmap:n,typeIds:s}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(Et.isUnion(this.type))return this.children.reduce((i,n)=>i+n.nullCount,0);let t=this._nullCount,e;return t<=xP&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Bl(e,this.offset,this.offset+this.length)),t}constructor(t,e,i,n,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1));let l;s instanceof ta?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=rb(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:e}=this;if(Et.isUnion(e)){const i=e,n=this.children[i.typeIdToChildIndex[this.typeIds[t]]],s=i.mode===Ii.Dense?this.valueOffsets[t]:t;return n.getValid(s)}if(this.nullable&&this.nullCount>0){const i=this.offset+t;return(this.nullBitmap[i>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(xh(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[c];i=(h&u)!==0,s[c]=e?h|u:h&~u}return i!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,i=this.length,n=this._nullCount,s=this,o=this.children){return new ta(t,e,i,n,s,o,this.dictionary)}slice(t,e){const{stride:i,typeId:n,children:s}=this,o=+(this._nullCount===0)-1,a=n===16?i:1,l=this._sliceBuffers(t,e,i,n);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===W.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:i}=this,n=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);n[e>>3]=(1<0&&n.set(xh(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[zi.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),s)}_sliceBuffers(t,e,i,n){let s;const{buffers:o}=this;return(s=o[zi.TYPE])&&(o[zi.TYPE]=s.subarray(t,t+e)),(s=o[zi.OFFSET])&&(o[zi.OFFSET]=s.subarray(t,t+e+1))||(s=o[zi.DATA])&&(o[zi.DATA]=n===6?s:s.subarray(i*t,i*(t+e))),o}_sliceChildren(t,e,i){return t.map(n=>n.slice(e,i))}}ta.prototype.children=Object.freeze([]);class hm{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function TP(r){return r.reduce((t,e)=>t+e.nullCount,0)}function IP(r){return r.reduce((t,e,i)=>(t[i+1]=t[i]+e.length,t),new Uint32Array(r.length+1))}function EP(r,t,e,i){const n=[];for(let s=-1,o=r.length;++s=i)break;if(e>=l+u)continue;if(l>=e&&l+u<=i){n.push(a);continue}const c=Math.max(0,e-l),h=Math.min(i-l,u);n.push(a.slice(c,h-c))}return n.length===0&&n.push(r[0].slice(0,0)),n}function Nf(r,t,e,i){let n=0,s=0,o=t.length-1;do{if(n>=o-1)return e0?0:-1}function FP(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let i=0;for(const n of new au(e,r.offset+(t||0),r.length,e,Rf)){if(!n)return i;++i}return-1}function Kt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case W.Union:break;case W.Dictionary:break;default:return FP(r,e)}const i=Yr.getVisitFn(r),n=cs(t);for(let s=(e||0)-1,o=r.length;++s{const n=r.data[i];return n.values.subarray(0,n.length)[Symbol.iterator]()});let e=0;return new hm(r.data.length,i=>{const s=r.data[i].length,o=r.slice(e,e+s);return e+=s,new PP(o)})}class PP{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof ta)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:u}=iw[o.typeId],c=s[0];this.isValid=h=>tw(c,h),this.get=h=>a(c,h),this.set=(h,p)=>l(c,h,p),this.indexOf=h=>u(c,h),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,nw[o.typeId]),this._offsets=IP(s);break}this.data=s,this.type=o,this.stride=rb(o),this.numChildren=(n=(i=o.children)===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return SP(this.data)}get nullCount(){return TP(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${W[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Qb(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return MP.visit(this)}concat(...t){return new Qe(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Qe(qb(this,t,e,({data:i,_offsets:n},s,o)=>EP(i,n,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:i,stride:n,ArrayType:s}=this;switch(t.typeId){case W.Int:case W.Float:case W.Decimal:case W.Time:case W.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*n),o.offset),o.offset+=l*n,o),{array:new s(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return Et.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(Et.isDictionary(this.type)){const t=new kl(this.data[0].dictionary),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new Qe(e)}return new kl(this)}unmemoize(){if(Et.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new Qe(e)}return this}}rw=Symbol.toStringTag;Qe[rw]=(r=>{r.type=Et.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(W).map(e=>W[e]).filter(e=>typeof e=="number"&&e!==W.NONE);for(const e of t){const i=Yr.getVisitFnByTypeId(e),n=Ei.getVisitFnByTypeId(e),s=dm.getVisitFnByTypeId(e);iw[e]={get:i,set:n,indexOf:s},nw[e]=Object.create(r,{isValid:{value:fm(tw)},get:{value:fm(Yr.getVisitFnByTypeId(e))},set:{value:CP(Ei.getVisitFnByTypeId(e))},indexOf:{value:AP(dm.getVisitFnByTypeId(e))}})}return"Vector"})(Qe.prototype);class kl extends Qe{constructor(t){super(t.data);const e=this.get,i=this.set,n=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){i.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new kl(n.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Qe(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}const DP=65536;function Ls(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}const io=8,Lf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class Bf{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let n=e[3]*i[3];this.buffer[0]=n&65535;let s=n>>>16;return n=e[2]*i[3],s+=n,n=e[3]*i[2]>>>0,s+=n,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Ls(this.buffer[3])} ${Ls(this.buffer[2])} ${Ls(this.buffer[1])} ${Ls(this.buffer[0])}`}static multiply(t,e){return new ci(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ci(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ci.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ci.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const i=t.startsWith("-"),n=t.length,s=new ci(e);for(let o=i?1:0;othis.compareFields(i,e[n]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function ur(r,t){return t instanceof r.constructor}function hs(r,t){return r===t||ur(r,t)}function Qi(r,t){return r===t||ur(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function lu(r,t){return r===t||ur(r,t)&&r.precision===t.precision}function NP(r,t){return r===t||ur(r,t)&&r.byteWidth===t.byteWidth}function kf(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function fa(r,t){return r===t||ur(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function da(r,t){return r===t||ur(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function LP(r,t){return r===t||ur(r,t)&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function BP(r,t){return r===t||ur(r,t)&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function Uf(r,t){return r===t||ur(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Ci.compareManyFields(r.children,t.children)}function kP(r,t){return r===t||ur(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ci.visit(r.indices,t.indices)&&Ci.visit(r.dictionary,t.dictionary)}function zf(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function pa(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function UP(r,t){return r===t||ur(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function zP(r,t){return r===t||ur(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}Ut.prototype.visitNull=hs;Ut.prototype.visitBool=hs;Ut.prototype.visitInt=Qi;Ut.prototype.visitInt8=Qi;Ut.prototype.visitInt16=Qi;Ut.prototype.visitInt32=Qi;Ut.prototype.visitInt64=Qi;Ut.prototype.visitUint8=Qi;Ut.prototype.visitUint16=Qi;Ut.prototype.visitUint32=Qi;Ut.prototype.visitUint64=Qi;Ut.prototype.visitFloat=lu;Ut.prototype.visitFloat16=lu;Ut.prototype.visitFloat32=lu;Ut.prototype.visitFloat64=lu;Ut.prototype.visitUtf8=hs;Ut.prototype.visitLargeUtf8=hs;Ut.prototype.visitBinary=hs;Ut.prototype.visitLargeBinary=hs;Ut.prototype.visitFixedSizeBinary=NP;Ut.prototype.visitDate=kf;Ut.prototype.visitDateDay=kf;Ut.prototype.visitDateMillisecond=kf;Ut.prototype.visitTimestamp=fa;Ut.prototype.visitTimestampSecond=fa;Ut.prototype.visitTimestampMillisecond=fa;Ut.prototype.visitTimestampMicrosecond=fa;Ut.prototype.visitTimestampNanosecond=fa;Ut.prototype.visitTime=da;Ut.prototype.visitTimeSecond=da;Ut.prototype.visitTimeMillisecond=da;Ut.prototype.visitTimeMicrosecond=da;Ut.prototype.visitTimeNanosecond=da;Ut.prototype.visitDecimal=hs;Ut.prototype.visitList=LP;Ut.prototype.visitStruct=BP;Ut.prototype.visitUnion=Uf;Ut.prototype.visitDenseUnion=Uf;Ut.prototype.visitSparseUnion=Uf;Ut.prototype.visitDictionary=kP;Ut.prototype.visitInterval=zf;Ut.prototype.visitIntervalDayTime=zf;Ut.prototype.visitIntervalYearMonth=zf;Ut.prototype.visitDuration=pa;Ut.prototype.visitDurationSecond=pa;Ut.prototype.visitDurationMillisecond=pa;Ut.prototype.visitDurationMicrosecond=pa;Ut.prototype.visitDurationNanosecond=pa;Ut.prototype.visitFixedSizeList=UP;Ut.prototype.visitMap=zP;const Ci=new Ut;function jP(r,t){return Ci.compareSchemas(r,t)}function $P(r,t){return Ci.compareFields(r,t)}function VP(r,t){return Ci.visit(r,t)}const pm=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_F),RP),wP),xF),pF),_P),yF),{compareSchemas:jP,compareFields:$P,compareTypes:VP}),sw=6048e5,GP=864e5,mm=Symbol.for("constructDateFrom");function Gi(r,t){return typeof r=="function"?r(t):r&&typeof r=="object"&&mm in r?r[mm](t):r instanceof Date?new r.constructor(t):new Date(t)}function qr(r,t){return Gi(t||r,r)}let WP={};function uu(){return WP}function ea(r,t){var a,l,u,c;const e=uu(),i=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,n=qr(r,t==null?void 0:t.in),s=n.getDay(),o=(s=s.getTime()?i+1:e.getTime()>=a.getTime()?i:i-1}function ym(r){const t=qr(r),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+r-+e}function HP(r,...t){const e=Gi.bind(null,t.find(i=>typeof i=="object"));return t.map(e)}function gm(r,t){const e=qr(r,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}function XP(r,t,e){const[i,n]=HP(e==null?void 0:e.in,r,t),s=gm(i),o=gm(n),a=+s-ym(s),l=+o-ym(o);return Math.round((a-l)/GP)}function YP(r,t){const e=ow(r,t),i=Gi(r,0);return i.setFullYear(e,0,4),i.setHours(0,0,0,0),Ul(i)}function qP(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function QP(r){return!(!qP(r)&&typeof r!="number"||isNaN(+qr(r)))}function KP(r,t){const e=qr(r,t==null?void 0:t.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}const ZP={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},JP=(r,t,e)=>{let i;const n=ZP[r];return typeof n=="string"?i=n:t===1?i=n.one:i=n.other.replace("{{count}}",t.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+i:i+" ago":i};function nc(r){return(t={})=>{const e=t.width?String(t.width):r.defaultWidth;return r.formats[e]||r.formats[r.defaultWidth]}}const tM={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},eM={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},rM={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},iM={date:nc({formats:tM,defaultWidth:"full"}),time:nc({formats:eM,defaultWidth:"full"}),dateTime:nc({formats:rM,defaultWidth:"full"})},nM={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},sM=(r,t,e,i)=>nM[r];function go(r){return(t,e)=>{const i=e!=null&&e.context?String(e.context):"standalone";let n;if(i==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,a=e!=null&&e.width?String(e.width):o;n=r.formattingValues[a]||r.formattingValues[o]}else{const o=r.defaultWidth,a=e!=null&&e.width?String(e.width):r.defaultWidth;n=r.values[a]||r.values[o]}const s=r.argumentCallback?r.argumentCallback(t):t;return n[s]}}const oM={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},aM={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},lM={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},uM={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},cM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},hM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},fM=(r,t)=>{const e=Number(r),i=e%100;if(i>20||i<10)switch(i%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},dM={ordinalNumber:fM,era:go({values:oM,defaultWidth:"wide"}),quarter:go({values:aM,defaultWidth:"wide",argumentCallback:r=>r-1}),month:go({values:lM,defaultWidth:"wide"}),day:go({values:uM,defaultWidth:"wide"}),dayPeriod:go({values:cM,defaultWidth:"wide",formattingValues:hM,defaultFormattingWidth:"wide"})};function vo(r){return(t,e={})=>{const i=e.width,n=i&&r.matchPatterns[i]||r.matchPatterns[r.defaultMatchWidth],s=t.match(n);if(!s)return null;const o=s[0],a=i&&r.parsePatterns[i]||r.parsePatterns[r.defaultParseWidth],l=Array.isArray(a)?mM(a,h=>h.test(o)):pM(a,h=>h.test(o));let u;u=r.valueCallback?r.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const c=t.slice(o.length);return{value:u,rest:c}}}function pM(r,t){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)&&t(r[e]))return e}function mM(r,t){for(let e=0;e{const i=t.match(r.matchPattern);if(!i)return null;const n=i[0],s=t.match(r.parsePattern);if(!s)return null;let o=r.valueCallback?r.valueCallback(s[0]):s[0];o=e.valueCallback?e.valueCallback(o):o;const a=t.slice(n.length);return{value:o,rest:a}}}const gM=/^(\d+)(th|st|nd|rd)?/i,vM=/\d+/i,_M={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bM={any:[/^b/i,/^(a|c)/i]},wM={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xM={any:[/1/i,/2/i,/3/i,/4/i]},SM={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},TM={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},IM={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},EM={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},CM={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},AM={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},OM={ordinalNumber:yM({matchPattern:gM,parsePattern:vM,valueCallback:r=>parseInt(r,10)}),era:vo({matchPatterns:_M,defaultMatchWidth:"wide",parsePatterns:bM,defaultParseWidth:"any"}),quarter:vo({matchPatterns:wM,defaultMatchWidth:"wide",parsePatterns:xM,defaultParseWidth:"any",valueCallback:r=>r+1}),month:vo({matchPatterns:SM,defaultMatchWidth:"wide",parsePatterns:TM,defaultParseWidth:"any"}),day:vo({matchPatterns:IM,defaultMatchWidth:"wide",parsePatterns:EM,defaultParseWidth:"any"}),dayPeriod:vo({matchPatterns:CM,defaultMatchWidth:"any",parsePatterns:AM,defaultParseWidth:"any"})},FM={code:"en-US",formatDistance:JP,formatLong:iM,formatRelative:sM,localize:dM,match:OM,options:{weekStartsOn:0,firstWeekContainsDate:1}};function PM(r,t){const e=qr(r,t==null?void 0:t.in);return XP(e,KP(e))+1}function MM(r,t){const e=qr(r,t==null?void 0:t.in),i=+Ul(e)-+YP(e);return Math.round(i/sw)+1}function aw(r,t){var c,h,p,f;const e=qr(r,t==null?void 0:t.in),i=e.getFullYear(),n=uu(),s=(t==null?void 0:t.firstWeekContainsDate)??((h=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(p=n.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??1,o=Gi((t==null?void 0:t.in)||r,0);o.setFullYear(i+1,0,s),o.setHours(0,0,0,0);const a=ea(o,t),l=Gi((t==null?void 0:t.in)||r,0);l.setFullYear(i,0,s),l.setHours(0,0,0,0);const u=ea(l,t);return+e>=+a?i+1:+e>=+u?i:i-1}function DM(r,t){var a,l,u,c;const e=uu(),i=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,n=aw(r,t),s=Gi((t==null?void 0:t.in)||r,0);return s.setFullYear(n,0,i),s.setHours(0,0,0,0),ea(s,t)}function RM(r,t){const e=qr(r,t==null?void 0:t.in),i=+ea(e,t)-+DM(e,t);return Math.round(i/sw)+1}function ve(r,t){const e=r<0?"-":"",i=Math.abs(r).toString().padStart(t,"0");return e+i}const rn={y(r,t){const e=r.getFullYear(),i=e>0?e:1-e;return ve(t==="yy"?i%100:i,t.length)},M(r,t){const e=r.getMonth();return t==="M"?String(e+1):ve(e+1,2)},d(r,t){return ve(r.getDate(),t.length)},a(r,t){const e=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(r,t){return ve(r.getHours()%12||12,t.length)},H(r,t){return ve(r.getHours(),t.length)},m(r,t){return ve(r.getMinutes(),t.length)},s(r,t){return ve(r.getSeconds(),t.length)},S(r,t){const e=t.length,i=r.getMilliseconds(),n=Math.trunc(i*Math.pow(10,e-3));return ve(n,t.length)}},_s={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},vm={G:function(r,t,e){const i=r.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(i,{width:"abbreviated"});case"GGGGG":return e.era(i,{width:"narrow"});case"GGGG":default:return e.era(i,{width:"wide"})}},y:function(r,t,e){if(t==="yo"){const i=r.getFullYear(),n=i>0?i:1-i;return e.ordinalNumber(n,{unit:"year"})}return rn.y(r,t)},Y:function(r,t,e,i){const n=aw(r,i),s=n>0?n:1-n;if(t==="YY"){const o=s%100;return ve(o,2)}return t==="Yo"?e.ordinalNumber(s,{unit:"year"}):ve(s,t.length)},R:function(r,t){const e=ow(r);return ve(e,t.length)},u:function(r,t){const e=r.getFullYear();return ve(e,t.length)},Q:function(r,t,e){const i=Math.ceil((r.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return ve(i,2);case"Qo":return e.ordinalNumber(i,{unit:"quarter"});case"QQQ":return e.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(i,{width:"wide",context:"formatting"})}},q:function(r,t,e){const i=Math.ceil((r.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return ve(i,2);case"qo":return e.ordinalNumber(i,{unit:"quarter"});case"qqq":return e.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(i,{width:"wide",context:"standalone"})}},M:function(r,t,e){const i=r.getMonth();switch(t){case"M":case"MM":return rn.M(r,t);case"Mo":return e.ordinalNumber(i+1,{unit:"month"});case"MMM":return e.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(i,{width:"wide",context:"formatting"})}},L:function(r,t,e){const i=r.getMonth();switch(t){case"L":return String(i+1);case"LL":return ve(i+1,2);case"Lo":return e.ordinalNumber(i+1,{unit:"month"});case"LLL":return e.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(i,{width:"wide",context:"standalone"})}},w:function(r,t,e,i){const n=RM(r,i);return t==="wo"?e.ordinalNumber(n,{unit:"week"}):ve(n,t.length)},I:function(r,t,e){const i=MM(r);return t==="Io"?e.ordinalNumber(i,{unit:"week"}):ve(i,t.length)},d:function(r,t,e){return t==="do"?e.ordinalNumber(r.getDate(),{unit:"date"}):rn.d(r,t)},D:function(r,t,e){const i=PM(r);return t==="Do"?e.ordinalNumber(i,{unit:"dayOfYear"}):ve(i,t.length)},E:function(r,t,e){const i=r.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(i,{width:"short",context:"formatting"});case"EEEE":default:return e.day(i,{width:"wide",context:"formatting"})}},e:function(r,t,e,i){const n=r.getDay(),s=(n-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ve(s,2);case"eo":return e.ordinalNumber(s,{unit:"day"});case"eee":return e.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(n,{width:"short",context:"formatting"});case"eeee":default:return e.day(n,{width:"wide",context:"formatting"})}},c:function(r,t,e,i){const n=r.getDay(),s=(n-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ve(s,t.length);case"co":return e.ordinalNumber(s,{unit:"day"});case"ccc":return e.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(n,{width:"narrow",context:"standalone"});case"cccccc":return e.day(n,{width:"short",context:"standalone"});case"cccc":default:return e.day(n,{width:"wide",context:"standalone"})}},i:function(r,t,e){const i=r.getDay(),n=i===0?7:i;switch(t){case"i":return String(n);case"ii":return ve(n,t.length);case"io":return e.ordinalNumber(n,{unit:"day"});case"iii":return e.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(i,{width:"short",context:"formatting"});case"iiii":default:return e.day(i,{width:"wide",context:"formatting"})}},a:function(r,t,e){const n=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(r,t,e){const i=r.getHours();let n;switch(i===12?n=_s.noon:i===0?n=_s.midnight:n=i/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(r,t,e){const i=r.getHours();let n;switch(i>=17?n=_s.evening:i>=12?n=_s.afternoon:i>=4?n=_s.morning:n=_s.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(r,t,e){if(t==="ho"){let i=r.getHours()%12;return i===0&&(i=12),e.ordinalNumber(i,{unit:"hour"})}return rn.h(r,t)},H:function(r,t,e){return t==="Ho"?e.ordinalNumber(r.getHours(),{unit:"hour"}):rn.H(r,t)},K:function(r,t,e){const i=r.getHours()%12;return t==="Ko"?e.ordinalNumber(i,{unit:"hour"}):ve(i,t.length)},k:function(r,t,e){let i=r.getHours();return i===0&&(i=24),t==="ko"?e.ordinalNumber(i,{unit:"hour"}):ve(i,t.length)},m:function(r,t,e){return t==="mo"?e.ordinalNumber(r.getMinutes(),{unit:"minute"}):rn.m(r,t)},s:function(r,t,e){return t==="so"?e.ordinalNumber(r.getSeconds(),{unit:"second"}):rn.s(r,t)},S:function(r,t){return rn.S(r,t)},X:function(r,t,e){const i=r.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return bm(i);case"XXXX":case"XX":return Vn(i);case"XXXXX":case"XXX":default:return Vn(i,":")}},x:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"x":return bm(i);case"xxxx":case"xx":return Vn(i);case"xxxxx":case"xxx":default:return Vn(i,":")}},O:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_m(i,":");case"OOOO":default:return"GMT"+Vn(i,":")}},z:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_m(i,":");case"zzzz":default:return"GMT"+Vn(i,":")}},t:function(r,t,e){const i=Math.trunc(+r/1e3);return ve(i,t.length)},T:function(r,t,e){return ve(+r,t.length)}};function _m(r,t=""){const e=r>0?"-":"+",i=Math.abs(r),n=Math.trunc(i/60),s=i%60;return s===0?e+String(n):e+String(n)+t+ve(s,2)}function bm(r,t){return r%60===0?(r>0?"-":"+")+ve(Math.abs(r)/60,2):Vn(r,t)}function Vn(r,t=""){const e=r>0?"-":"+",i=Math.abs(r),n=ve(Math.trunc(i/60),2),s=ve(i%60,2);return e+n+t+s}const wm=(r,t)=>{switch(r){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},lw=(r,t)=>{switch(r){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},NM=(r,t)=>{const e=r.match(/(P+)(p+)?/)||[],i=e[1],n=e[2];if(!n)return wm(r,t);let s;switch(i){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",wm(i,t)).replace("{{time}}",lw(n,t))},LM={p:lw,P:NM},BM=/^D+$/,kM=/^Y+$/,UM=["D","DD","YY","YYYY"];function zM(r){return BM.test(r)}function jM(r){return kM.test(r)}function $M(r,t,e){const i=VM(r,t,e);if(console.warn(i),UM.includes(r))throw new RangeError(i)}function VM(r,t,e){const i=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${t}\`) for formatting ${i} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const GM=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,WM=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,HM=/^'([^]*?)'?$/,XM=/''/g,YM=/[a-zA-Z]/;function uw(r,t,e){var c,h,p,f;const i=uu(),n=i.locale??FM,s=i.firstWeekContainsDate??((h=(c=i.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??1,o=i.weekStartsOn??((f=(p=i.locale)==null?void 0:p.options)==null?void 0:f.weekStartsOn)??0,a=qr(r,e==null?void 0:e.in);if(!QP(a))throw new RangeError("Invalid time value");let l=t.match(WM).map(y=>{const g=y[0];if(g==="p"||g==="P"){const d=LM[g];return d(y,n.formatLong)}return y}).join("").match(GM).map(y=>{if(y==="''")return{isToken:!1,value:"'"};const g=y[0];if(g==="'")return{isToken:!1,value:qM(y)};if(vm[g])return{isToken:!0,value:y};if(g.match(YM))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:y}});n.localize.preprocessor&&(l=n.localize.preprocessor(a,l));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:n};return l.map(y=>{if(!y.isToken)return y.value;const g=y.value;(jM(g)||zM(g))&&$M(g,t,String(r));const d=vm[g[0]];return d(a,g,n.localize,u)}).join("")}function qM(r){const t=r.match(HM);return t?t[1].replace(XM,"'"):r}function QM(r,t){return qr(r*1e3,t==null?void 0:t.in)}function KM(r,t){const e=ZM(t)?new t(0):Gi(t,0);return e.setFullYear(r.getFullYear(),r.getMonth(),r.getDate()),e.setHours(r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()),e}function ZM(r){var t;return typeof r=="function"&&((t=r.prototype)==null?void 0:t.constructor)===r}function JM(r,t){let e=r.length;switch("string"){case"string":{if(t.length!==1)throw new Error("The 'chars' parameter should be a single character string.");for(;e>0&&r[e-1]===t;)e--;break}}return r.substring(0,e)}function gr(r){return r==null}function tD(r){return r!=null}async function Sh(){if(typeof window<"u"&&window!==null)return"browser";try{const r=await ln(()=>import("./__vite-browser-external-FmFgRqLi.js"),[]);return typeof r<"u"&&r.versions!=null&&r.versions.node!=null?"node":"unknown"}catch{return"unknown"}}function eD(r){return gr(r)?!1:Et.isInt(r.type)&&!cw(r)||rD(r)}function rD(r){return gr(r)?!1:Et.isInt(r.type)&&r.type.isSigned===!1}function iD(r){return gr(r)?!1:Et.isFloat(r.type)??!1}function nD(r){return gr(r)?!1:Et.isDecimal(r.type)}function sD(r){return gr(r)?!1:Et.isBool(r.type)}function oD(r){return gr(r)?!1:Et.isDuration(r.type)}function cw(r){return gr(r)?!1:Et.isInt(r.type)&&r.metadata.get("ARROW:extension:name")==="period"}function aD(r){return gr(r)?!1:Et.isTimestamp(r.type)}function lD(r){return gr(r)?!1:Et.isDate(r.type)}function uD(r){return gr(r)?!1:Et.isTime(r.type)}function cD(r){return gr(r)?!1:Et.isList(r.type)||Et.isFixedSizeList(r.type)}function hD(r){return gr(r)?!1:Et.isStruct(r.type)||Et.isMap(r.type)}function fD(r){return gr(r)?!1:Et.isStruct(r.type)&&r.metadata.get("ARROW:extension:name")==="interval"||Et.isInterval(r.type)}function dD(r,t){let e;if(t===Jt.MILLISECOND)e=1e3;else if(t===Jt.MICROSECOND)e=1e3*1e3;else if(t===Jt.NANOSECOND)e=1e3*1e3*1e3;else return Number(r);return typeof r=="bigint"&&!Number.isSafeInteger(Number(r))?Number(r/BigInt(e)):Number(r)/e}function pD(r,t){var i;const e=dD(r,((i=t==null?void 0:t.type)==null?void 0:i.unit)??Jt.SECOND);return QM(e)}function mD(r,t){const e=pD(r,t);return uw(e,e.getMilliseconds()===0?"HH:mm:ss":"HH:mm:ss.SSS")}function yD(r){const t="yyyy-MM-dd";return r instanceof Date||typeof r=="number"&&Number.isFinite(r)?uw(r,t):(console.warn(`Unsupported date value: ${r}`),String(r))}function gD(r,t){var n;if(!(r instanceof Date||typeof r=="number"&&Number.isFinite(r)))return console.warn(`Unsupported datetime value: ${r}`),null;let e;const i=(n=t==null?void 0:t.type)==null?void 0:n.timezone;return typeof r=="number"?i?e=new Er(r,i):e=new Er(r):i?e=new Er(r,i):e=new Er(r),KM(e,Date)}function vD(r,t){var a;const e=((a=t==null?void 0:t.type)==null?void 0:a.scale)||0;let i=pm.bigNumToString(new pm.BN(r)).padStart(e,"0");if(e===0)return i;let n="";i.startsWith("-")&&(n="-",i=i.slice(1));const s=i.slice(0,-e)||"0",o=JM(i.slice(-e),"0")||"";return`${n}${s}${o?`.${o}`:""}`}function _D(r){const t=r[0],e=r[1],i=[];return t!==0&&i.push(`${t} year${t>1?"s":""}`),e!==0&&i.push(`${e} month${e>1?"s":""}`),i.length?i.join(" "):"0 months"}function bD(r,t){var i,n,s,o;if(Et.isInterval(t==null?void 0:t.type))return _D(r);const e=t&&t.metadata.get("ARROW:extension:name");if(e&&e==="pandas.interval"){const a=JSON.parse(t.metadata.get("ARROW:extension:metadata")),{closed:l}=a,u=r.toJSON(),c=l==="both"||l==="left"?"[":"(",h=l==="both"||l==="right"?"]":")",p=Th(u.left,(n=(i=t.type)==null?void 0:i.children)==null?void 0:n[0]),f=Th(u.right,(o=(s=t.type)==null?void 0:s.children)==null?void 0:o[1]);return`${c+p}, ${f+h}`}return String(r)}function wD(r,t){return(t==null?void 0:t.type)instanceof bh?JSON.parse(JSON.stringify(r,(e,i)=>{if(tD(i))return typeof i=="bigint"?Number(i):i})):JSON.parse(JSON.stringify(r,(e,i)=>typeof i=="bigint"?Number(i):i))}function Th(r,t){if(gr(r))return null;const e=r instanceof Date||Number.isFinite(r);if(e&&lD(t))return yD(r);if(typeof r=="bigint"&&uD(t))return mD(Number(r),t);if(e&&aD(t))return gD(r,t);if(cw(t))throw new Error("Period type is not supported yet");if(fD(t))return bD(r,t);if(oD(t))throw new Error("Duration type is not supported yet");return nD(t)?vD(r,t):iD(t)&&Number.isFinite(r)||eD(t)?r:hD(t)||cD(t)?wD(r,t):sD(t)?!!r:String(r)}function xm(r){return((r.toArray()||[]).map(i=>i.toJSON())||[]).map(i=>(r.schema.fields.forEach(n=>i[n.name]=Th(i[n.name],n)),i))}var ra=(r=>(r.ORIGIN_PRIVATE_FS="origin-private-fs",r.NODE_FS="node-fs",r))(ra||{});async function hw(r){const t=Cx(r,{logger:!1});let e,i;const n=await Sh();if(n==="browser"){if(typeof t.bundles>"u"){const{getBundles:l}=await ln(async()=>{const{getBundles:u}=await import("./default-browser-BrgSDbLD.js");return{getBundles:u}},[]);t.bundles=await l()}i=await kp(await t.bundles),e=new Worker(i.mainWorker)}else if(n==="node"){if(typeof t.bundles>"u"){const{getBundles:c}=await ln(async()=>{const{getBundles:h}=await import("./default-node-CUehHPTd.js");return{getBundles:h}},__vite__mapDeps([0,1,2]));t.bundles=await c()}i=await kp(await t.bundles);let l=i.mainWorker;l.startsWith("/@fs/")&&(l=l.replace("/@fs/","file://"));const u=await ln(()=>import("./index-Cp8iQ_hy.js"),[]);e=new u.default(l,{type:"module"})}else throw new Error(`Unsupported environment: ${n}`);let s;t.logger===!0?s=new I0:t.logger===!1?s=new c2:s=t.logger;const o=new g2(s,e);if(await o.instantiate(i.mainModule,i.pthreadWorker),t.storage)switch(t.storage.type){case ra.ORIGIN_PRIVATE_FS:{try{let l=t.storage.path;l.startsWith("/")&&(l=l.slice(1)),await o.open({path:`opfs://${l}`,accessMode:t.storage.accessMode})}catch(l){throw await o.terminate(),await e.terminate(),l}break}case ra.NODE_FS:{try{await o.open({path:t.storage.path,accessMode:t.storage.accessMode,useDirectIO:!0})}catch(l){throw await o.terminate(),await e.terminate(),l}break}}const a=await o.connect();return{worker:e,db:o,conn:a,query:async(l,u=[])=>{if(!u||u.length===0){const f=await a.query(l);return xm(f)}const c=await a.prepare(l),h=await c.query(...u),p=xm(h);return c.close(),p},close:async()=>{await a.close(),await o.terminate(),await e.terminate()}}}async function xD(r,t){await(await r).conn.send("BEGIN TRANSACTION");try{const e=await t(r);return await(await r).conn.send("COMMIT"),e}catch(e){throw await(await r).conn.send("ROLLBACK"),e}}async function SD(r,t,e){await(await r).conn.send(`SAVEPOINT ${t}`);try{const i=await e(r);return await(await r).conn.send(`RELEASE SAVEPOINT ${t}`),i}catch(i){throw await(await r).conn.send(`ROLLBACK TO SAVEPOINT ${t}`),i}}const xt=Symbol.for("drizzle:entityKind");function lt(r,t){if(!r||typeof r!="object")return!1;if(r instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,xt))throw new Error(`Class "${t.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let e=Object.getPrototypeOf(r).constructor;if(e)for(;e;){if(xt in e&&e[xt]===t[xt])return!0;e=Object.getPrototypeOf(e)}return!1}var Mm;Mm=xt;class Ke{constructor(t,e){G(this,"name");G(this,"keyAsName");G(this,"primary");G(this,"notNull");G(this,"default");G(this,"defaultFn");G(this,"onUpdateFn");G(this,"hasDefault");G(this,"isUnique");G(this,"uniqueName");G(this,"uniqueType");G(this,"dataType");G(this,"columnType");G(this,"enumValues");G(this,"generated");G(this,"generatedIdentity");G(this,"config");this.table=t,this.config=e,this.name=e.name,this.keyAsName=e.keyAsName,this.notNull=e.notNull,this.default=e.default,this.defaultFn=e.defaultFn,this.onUpdateFn=e.onUpdateFn,this.hasDefault=e.hasDefault,this.primary=e.primaryKey,this.isUnique=e.isUnique,this.uniqueName=e.uniqueName,this.uniqueType=e.uniqueType,this.dataType=e.dataType,this.columnType=e.columnType,this.generated=e.generated,this.generatedIdentity=e.generatedIdentity}mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}G(Ke,Mm,"Column");const Ys=Symbol.for("drizzle:Name");function TD(r,t){return`${r[Ys]}_${t.join("_")}_unique`}var Dm,Rm;class Ar extends(Rm=Ke,Dm=xt,Rm){constructor(t,e){e.uniqueName||(e.uniqueName=TD(t,[e.name])),super(t,e),this.table=t}}G(Ar,Dm,"PgColumn");const Sm=Symbol.for("drizzle:isPgEnum");function ID(r){return!!r&&typeof r=="function"&&Sm in r&&r[Sm]===!0}var Nm;Nm=xt;class Or{constructor(t,e,i,n=!1){this._={brand:"Subquery",sql:t,selectedFields:e,alias:i,isWith:n}}}G(Or,Nm,"Subquery");var Lm,Bm;class jf extends(Bm=Or,Lm=xt,Bm){}G(jf,Lm,"WithSubquery");const Pr={startActiveSpan(r,t){return t()}},He=Symbol.for("drizzle:ViewBaseConfig"),Qa=Symbol.for("drizzle:Schema"),Ih=Symbol.for("drizzle:Columns"),Tm=Symbol.for("drizzle:ExtraConfigColumns"),sc=Symbol.for("drizzle:OriginalName"),oc=Symbol.for("drizzle:BaseName"),zl=Symbol.for("drizzle:IsAlias"),Im=Symbol.for("drizzle:ExtraConfigBuilder"),ED=Symbol.for("drizzle:IsDrizzleTable");var km,Um,zm,jm,$m,Vm,Gm,Wm,Hm,Xm;Xm=xt,Hm=Ys,Wm=sc,Gm=Qa,Vm=Ih,$m=Tm,jm=oc,zm=zl,Um=ED,km=Im;class Tt{constructor(t,e,i){G(this,Hm);G(this,Wm);G(this,Gm);G(this,Vm);G(this,$m);G(this,jm);G(this,zm,!1);G(this,Um,!0);G(this,km);this[Ys]=this[sc]=t,this[Qa]=e,this[oc]=i}}G(Tt,Xm,"Table"),G(Tt,"Symbol",{Name:Ys,Schema:Qa,OriginalName:sc,Columns:Ih,ExtraConfigColumns:Tm,BaseName:oc,IsAlias:zl,ExtraConfigBuilder:Im});function qn(r){return r[Ys]}function ia(r){return`${r[Qa]??"public"}.${r[Ys]}`}function fw(r){return r!=null&&typeof r.getSQL=="function"}function CD(r){var e;const t={sql:"",params:[]};for(const i of r)t.sql+=i.sql,t.params.push(...i.params),(e=i.typings)!=null&&e.length&&(t.typings||(t.typings=[]),t.typings.push(...i.typings));return t}var Ym;Ym=xt;class Xe{constructor(t){G(this,"value");this.value=Array.isArray(t)?t:[t]}getSQL(){return new Ft([this])}}G(Xe,Ym,"StringChunk");var qm;qm=xt;const Hn=class Hn{constructor(t){G(this,"decoder",dw);G(this,"shouldInlineParams",!1);this.queryChunks=t}append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return Pr.startActiveSpan("drizzle.buildSQL",e=>{const i=this.buildQueryFromSourceParams(this.queryChunks,t);return e==null||e.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})}buildQueryFromSourceParams(t,e){const i=Object.assign({},e,{inlineParams:e.inlineParams||this.shouldInlineParams,paramStartIndex:e.paramStartIndex||{value:0}}),{casing:n,escapeName:s,escapeParam:o,prepareTyping:a,inlineParams:l,paramStartIndex:u}=i;return CD(t.map(c=>{var h;if(lt(c,Xe))return{sql:c.value.join(""),params:[]};if(lt(c,jl))return{sql:s(c.value),params:[]};if(c===void 0)return{sql:"",params:[]};if(Array.isArray(c)){const p=[new Xe("(")];for(const[f,y]of c.entries())p.push(y),fr},pw={mapToDriverValue:r=>r};({...dw,...pw});var Km;Km=xt;class Wi{constructor(t,e=pw){G(this,"brand");this.value=t,this.encoder=e}getSQL(){return new Ft([this])}}G(Wi,Km,"Param");function X(r,...t){const e=[];(t.length>0||r.length>0&&r[0]!=="")&&e.push(new Xe(r[0]));for(const[i,n]of t.entries())e.push(n,new Xe(r[i+1]));return new Ft(e)}(r=>{function t(){return new Ft([])}r.empty=t;function e(l){return new Ft(l)}r.fromList=e;function i(l){return new Ft([new Xe(l)])}r.raw=i;function n(l,u){const c=[];for(const[h,p]of l.entries())h>0&&u!==void 0&&c.push(u),c.push(p);return new Ft(c)}r.join=n;function s(l){return new jl(l)}r.identifier=s;function o(l){return new ss(l)}r.placeholder=o;function a(l,u){return new Wi(l,u)}r.param=a})(X||(X={}));(r=>{var e;e=xt;const i=class i{constructor(s,o){G(this,"isSelectionField",!1);this.sql=s,this.fieldAlias=o}getSQL(){return this.sql}clone(){return new i(this.sql,this.fieldAlias)}};G(i,e,"SQL.Aliased");let t=i;r.Aliased=t})(Ft||(Ft={}));var Zm;Zm=xt;class ss{constructor(t){this.name=t}getSQL(){return new Ft([this])}}G(ss,Zm,"Placeholder");function Em(r,t){return r.map(e=>{if(lt(e,ss)){if(!(e.name in t))throw new Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(lt(e,Wi)&<(e.value,ss)){if(!(e.value.name in t))throw new Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}const OD=Symbol.for("drizzle:IsDrizzleView");var Jm,ty,ey;ey=xt,ty=He,Jm=OD;class Sn{constructor({name:t,schema:e,selectedFields:i,query:n}){G(this,ty);G(this,Jm,!0);this[He]={name:t,originalName:t,schema:e,selectedFields:i,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new Ft([this])}}G(Sn,ey,"View");Ke.prototype.getSQL=function(){return new Ft([this])};Tt.prototype.getSQL=function(){return new Ft([this])};Or.prototype.getSQL=function(){return new Ft([this])};var ry;ry=xt;class na{constructor(t){this.table=t}get(t,e){return e==="table"?this.table:t[e]}}G(na,ry,"ColumnAliasProxyHandler");var iy;iy=xt;class cu{constructor(t,e){this.alias=t,this.replaceOriginalName=e}get(t,e){if(e===Tt.Symbol.IsAlias)return!0;if(e===Tt.Symbol.Name)return this.alias;if(this.replaceOriginalName&&e===Tt.Symbol.OriginalName)return this.alias;if(e===He)return{...t[He],name:this.alias,isAlias:!0};if(e===Tt.Symbol.Columns){const n=t[Tt.Symbol.Columns];if(!n)return n;const s={};return Object.keys(n).map(o=>{s[o]=new Proxy(n[o],new na(new Proxy(t,this)))}),s}const i=t[e];return lt(i,Ke)?new Proxy(i,new na(new Proxy(t,this))):i}}G(cu,iy,"TableAliasProxyHandler");function ac(r,t){return new Proxy(r,new cu(t,!1))}function Li(r,t){return new Proxy(r,new na(new Proxy(r.table,new cu(t,!1))))}function mw(r,t){return new Ft.Aliased($l(r.sql,t),r.fieldAlias)}function $l(r,t){return X.join(r.queryChunks.map(e=>lt(e,Ke)?Li(e,t):lt(e,Ft)?$l(e,t):lt(e,Ft.Aliased)?mw(e,t):e))}var ny,sy;class $f extends(sy=Error,ny=xt,sy){constructor({message:t,cause:e}){super(t),this.name="DrizzleError",this.cause=e}}G($f,ny,"DrizzleError");var oy,ay;class yw extends(ay=$f,oy=xt,ay){constructor(){super({message:"Rollback"})}}G(yw,oy,"TransactionRollbackError");function yr(r,t){return AD(t)&&!fw(r)&&!lt(r,Wi)&&!lt(r,ss)&&!lt(r,Ke)&&!lt(r,Tt)&&!lt(r,Sn)?new Wi(r,t):r}const gw=(r,t)=>X`${r} = ${yr(t,r)}`,FD=(r,t)=>X`${r} <> ${yr(t,r)}`;function Eh(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Ft(t):new Ft([new Xe("("),X.join(t,new Xe(" and ")),new Xe(")")])}function PD(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Ft(t):new Ft([new Xe("("),X.join(t,new Xe(" or ")),new Xe(")")])}function MD(r){return X`not ${r}`}const DD=(r,t)=>X`${r} > ${yr(t,r)}`,RD=(r,t)=>X`${r} >= ${yr(t,r)}`,ND=(r,t)=>X`${r} < ${yr(t,r)}`,LD=(r,t)=>X`${r} <= ${yr(t,r)}`;function BD(r,t){return Array.isArray(t)?t.length===0?X`false`:X`${r} in ${t.map(e=>yr(e,r))}`:X`${r} in ${yr(t,r)}`}function kD(r,t){return Array.isArray(t)?t.length===0?X`true`:X`${r} not in ${t.map(e=>yr(e,r))}`:X`${r} not in ${yr(t,r)}`}function UD(r){return X`${r} is null`}function zD(r){return X`${r} is not null`}function jD(r){return X`exists ${r}`}function $D(r){return X`not exists ${r}`}function VD(r,t,e){return X`${r} between ${yr(t,r)} and ${yr(e,r)}`}function GD(r,t,e){return X`${r} not between ${yr(t,r)} and ${yr(e,r)}`}function WD(r,t){return X`${r} like ${t}`}function HD(r,t){return X`${r} not like ${t}`}function XD(r,t){return X`${r} ilike ${t}`}function YD(r,t){return X`${r} not ilike ${t}`}function qD(r){return X`${r} asc`}function QD(r){return X`${r} desc`}var ly;ly=xt;class vw{write(t){console.log(t)}}G(vw,ly,"ConsoleLogWriter");var uy;uy=xt;class _w{constructor(t){G(this,"writer");this.writer=(t==null?void 0:t.writer)??new vw}logQuery(t,e){const i=e.map(s=>{try{return JSON.stringify(s)}catch{return String(s)}}),n=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${t}${n}`)}}G(_w,uy,"DefaultLogger");var cy;cy=xt;class bw{logQuery(){}}G(bw,cy,"NoopLogger");var hy,fy;fy=xt,hy=Symbol.toStringTag;class Tn{constructor(){G(this,hy,"QueryPromise")}catch(t){return this.then(void 0,t)}finally(t){return this.then(e=>(t==null||t(),e),e=>{throw t==null||t(),e})}then(t,e){return this.execute().then(t,e)}}G(Tn,fy,"QueryPromise");function os(r,t){return Object.entries(r).reduce((e,[i,n])=>{if(typeof i!="string")return e;const s=t?[...t,i]:[i];return lt(n,Ke)||lt(n,Ft)||lt(n,Ft.Aliased)?e.push({path:s,field:n}):lt(n,Tt)?e.push(...os(n[Tt.Symbol.Columns],s)):e.push(...os(n,s)),e},[])}function Vf(r,t){const e=Object.keys(r),i=Object.keys(t);if(e.length!==i.length)return!1;for(const[n,s]of e.entries())if(s!==i[n])return!1;return!0}function ww(r,t){const e=Object.entries(t).filter(([,i])=>i!==void 0).map(([i,n])=>lt(n,Ft)||lt(n,Ke)?[i,n]:[i,new Wi(n,r[Tt.Symbol.Columns][i])]);if(e.length===0)throw new Error("No values to set");return Object.fromEntries(e)}function KD(r,t){for(const e of t)for(const i of Object.getOwnPropertyNames(e.prototype))i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}function ZD(r){return r[Tt.Symbol.Columns]}function Wn(r){return lt(r,Or)?r._.alias:lt(r,Sn)?r[He].name:lt(r,Ft)?void 0:r[Tt.Symbol.IsAlias]?r[Tt.Symbol.Name]:r[Tt.Symbol.BaseName]}function JD(r){if(typeof r!="object"||r===null||r.constructor.name!=="Object")return!1;if("logger"in r){const t=typeof r.logger;return!(t!=="boolean"&&(t!=="object"||typeof r.logger.logQuery!="function")&&t!=="undefined")}if("schema"in r){const t=typeof r.schema;return!(t!=="object"&&t!=="undefined")}if("casing"in r){const t=typeof r.casing;return!(t!=="string"&&t!=="undefined")}if("mode"in r)return!(r.mode!=="default"||r.mode!=="planetscale"||r.mode!==void 0);if("connection"in r){const t=typeof r.connection;return!(t!=="string"&&t!=="object"&&t!=="undefined")}if("client"in r){const t=typeof r.client;return!(t!=="object"&&t!=="function"&&t!=="undefined")}return Object.keys(r).length===0}var dy,py;class xw extends(py=Ar,dy=xt,py){getSQLType(){return"date"}mapFromDriverValue(t){return new Date(t)}mapToDriverValue(t){return t.toISOString()}}G(xw,dy,"PgDate");var my,yy;class Sw extends(yy=Ar,my=xt,yy){getSQLType(){return"date"}}G(Sw,my,"PgDateString");var gy,vy;class Tw extends(vy=Ar,gy=xt,vy){constructor(t,e){super(t,e)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}G(Tw,gy,"PgJson");var _y,by;class Iw extends(by=Ar,_y=xt,by){constructor(t,e){super(t,e)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}G(Iw,_y,"PgJsonb");var wy,xy;class Ew extends(xy=Ar,wy=xt,xy){constructor(e,i){super(e,i);G(this,"precision");G(this,"scale");this.precision=i.precision,this.scale=i.scale}mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}G(Ew,wy,"PgNumeric");var Sy,Ty;class Cw extends(Ty=Ar,Sy=xt,Ty){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Cw,Sy,"PgTime");var Iy,Ey;class Aw extends(Ey=Ar,Iy=xt,Ey){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");G(this,"mapFromDriverValue",e=>new Date(this.withTimezone?e:e+"+0000"));G(this,"mapToDriverValue",e=>e.toISOString());this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Aw,Iy,"PgTimestamp");var Cy,Ay;class Ow extends(Ay=Ar,Cy=xt,Ay){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Ow,Cy,"PgTimestampString");var Oy,Fy;class Fw extends(Fy=Ar,Oy=xt,Fy){getSQLType(){return"uuid"}}G(Fw,Oy,"PgUUID");const Cm=Symbol.for("drizzle:PgInlineForeignKeys"),Am=Symbol.for("drizzle:EnableRLS");var Py,My,Dy,Ry,Ny,Ly;class Br extends(Ly=Tt,Ny=xt,Ry=Cm,Dy=Am,My=Tt.Symbol.ExtraConfigBuilder,Py=Tt.Symbol.ExtraConfigColumns,Ly){constructor(){super(...arguments);G(this,Ry,[]);G(this,Dy,!1);G(this,My);G(this,Py,{})}}G(Br,Ny,"PgTable"),G(Br,"Symbol",Object.assign({},Tt.Symbol,{InlineForeignKeys:Cm,EnableRLS:Am}));var By;By=xt;class Pw{constructor(t,e){G(this,"columns");G(this,"name");this.columns=t,this.name=e}build(t){return new Mw(t,this.columns,this.name)}}G(Pw,By,"PgPrimaryKeyBuilder");var ky;ky=xt;class Mw{constructor(t,e,i){G(this,"columns");G(this,"name");this.table=t,this.columns=e,this.name=i}getName(){return this.name??`${this.table[Br.Symbol.Name]}_${this.columns.map(t=>t.name).join("_")}_pk`}}G(Mw,ky,"PgPrimaryKey");var Uy;Uy=xt;class Gf{constructor(t,e,i){G(this,"referencedTableName");G(this,"fieldName");this.sourceTable=t,this.referencedTable=e,this.relationName=i,this.referencedTableName=e[Tt.Symbol.Name]}}G(Gf,Uy,"Relation");var zy;zy=xt;class Dw{constructor(t,e){this.table=t,this.config=e}}G(Dw,zy,"Relations");var jy,$y;const Wl=class Wl extends($y=Gf,jy=xt,$y){constructor(t,e,i,n){super(t,e,i==null?void 0:i.relationName),this.config=i,this.isNullable=n}withFieldName(t){const e=new Wl(this.sourceTable,this.referencedTable,this.config,this.isNullable);return e.fieldName=t,e}};G(Wl,jy,"One");let as=Wl;var Vy,Gy;const Hl=class Hl extends(Gy=Gf,Vy=xt,Gy){constructor(t,e,i){super(t,e,i==null?void 0:i.relationName),this.config=i}withFieldName(t){const e=new Hl(this.sourceTable,this.referencedTable,this.config);return e.fieldName=t,e}};G(Hl,Vy,"Many");let Vl=Hl;function tR(){return{and:Eh,between:VD,eq:gw,exists:jD,gt:DD,gte:RD,ilike:XD,inArray:BD,isNull:UD,isNotNull:zD,like:WD,lt:ND,lte:LD,ne:FD,not:MD,notBetween:GD,notExists:$D,notLike:HD,notIlike:YD,notInArray:kD,or:PD,sql:X}}function eR(){return{sql:X,asc:qD,desc:QD}}function rR(r,t){var s;Object.keys(r).length===1&&"default"in r&&!lt(r.default,Tt)&&(r=r.default);const e={},i={},n={};for(const[o,a]of Object.entries(r))if(lt(a,Tt)){const l=ia(a),u=i[l];e[l]=o,n[o]={tsName:o,dbName:a[Tt.Symbol.Name],schema:a[Tt.Symbol.Schema],columns:a[Tt.Symbol.Columns],relations:(u==null?void 0:u.relations)??{},primaryKey:(u==null?void 0:u.primaryKey)??[]};for(const h of Object.values(a[Tt.Symbol.Columns]))h.primary&&n[o].primaryKey.push(h);const c=(s=a[Tt.Symbol.ExtraConfigBuilder])==null?void 0:s.call(a,a[Tt.Symbol.ExtraConfigColumns]);if(c)for(const h of Object.values(c))lt(h,Pw)&&n[o].primaryKey.push(...h.columns)}else if(lt(a,Dw)){const l=ia(a.table),u=e[l],c=a.config(t(a.table));let h;for(const[p,f]of Object.entries(c))if(u){const y=n[u];y.relations[p]=f}else l in i||(i[l]={relations:{},primaryKey:h}),i[l].relations[p]=f}return{tables:n,tableNamesMap:e}}function iR(r){return function(e,i){return new as(r,e,i,(i==null?void 0:i.fields.reduce((n,s)=>n&&s.notNull,!0))??!1)}}function nR(r){return function(e,i){return new Vl(r,e,i)}}function sR(r,t,e){if(lt(e,as)&&e.config)return{fields:e.config.fields,references:e.config.references};const i=t[ia(e.referencedTable)];if(!i)throw new Error(`Table "${e.referencedTable[Tt.Symbol.Name]}" not found in schema`);const n=r[i];if(!n)throw new Error(`Table "${i}" not found in schema`);const s=e.sourceTable,o=t[ia(s)];if(!o)throw new Error(`Table "${s[Tt.Symbol.Name]}" not found in schema`);const a=[];for(const l of Object.values(n.relations))(e.relationName&&e!==l&&l.relationName===e.relationName||!e.relationName&&l.referencedTable===e.sourceTable)&&a.push(l);if(a.length>1)throw e.relationName?new Error(`There are multiple relations with name "${e.relationName}" in table "${i}"`):new Error(`There are multiple relations between "${i}" and "${e.sourceTable[Tt.Symbol.Name]}". Please specify relation name`);if(a[0]&<(a[0],as)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw new Error(`There is not enough information to infer relation "${o}.${e.fieldName}"`)}function oR(r){return{one:iR(r),many:nR(r)}}function Ch(r,t,e,i,n=s=>s){const s={};for(const[o,a]of i.entries())if(a.isJson){const l=t.relations[a.tsKey],u=e[o],c=typeof u=="string"?JSON.parse(u):u;s[a.tsKey]=lt(l,as)?c&&Ch(r,r[a.relationTableTsKey],c,a.selection,n):c.map(h=>Ch(r,r[a.relationTableTsKey],h,a.selection,n))}else{const l=n(e[o]),u=a.field;let c;lt(u,Ke)?c=u:lt(u,Ft)?c=u.decoder:c=u.sql.decoder,s[a.tsKey]=l===null?null:c.mapFromDriverValue(l)}return s}var Wy;Wy=xt;const Xl=class Xl{constructor(t){G(this,"config");this.config={...t}}get(t,e){if(e==="_")return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(e===He)return{...t[He],selectedFields:new Proxy(t[He].selectedFields,this)};if(typeof e=="symbol")return t[e];const n=(lt(t,Or)?t._.selectedFields:lt(t,Sn)?t[He].selectedFields:t)[e];if(lt(n,Ft.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!n.isSelectionField)return n.sql;const s=n.clone();return s.isSelectionField=!0,s}if(lt(n,Ft)){if(this.config.sqlBehavior==="sql")return n;throw new Error(`You tried to reference "${e}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return lt(n,Ke)?this.config.alias?new Proxy(n,new na(new Proxy(n.table,new cu(this.config.alias,this.config.replaceOriginalName??!1)))):n:typeof n!="object"||n===null?n:new Proxy(n,new Xl(this.config))}};G(Xl,Wy,"SelectionProxyHandler");let Je=Xl;var Hy,Xy;class Ah extends(Xy=Tn,Hy=xt,Xy){constructor(e,i,n,s){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=i,this.dialect=n,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}returning(e=this.config.table[Tt.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=os(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(Ah,Hy,"PgDelete");function aR(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function lR(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,i,n)=>{const s=n===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return e+s},"")}function uR(r){return r}var Yy;Yy=xt;class Rw{constructor(t){G(this,"cache",{});G(this,"cachedTables",{});G(this,"convert");this.convert=t==="snake_case"?aR:t==="camelCase"?lR:uR}getColumnCasing(t){if(!t.keyAsName)return t.name;const e=t.table[Tt.Symbol.Schema]??"public",i=t.table[Tt.Symbol.OriginalName],n=`${e}.${i}.${t.name}`;return this.cache[n]||this.cacheTable(t.table),this.cache[n]}cacheTable(t){const e=t[Tt.Symbol.Schema]??"public",i=t[Tt.Symbol.OriginalName],n=`${e}.${i}`;if(!this.cachedTables[n]){for(const s of Object.values(t[Tt.Symbol.Columns])){const o=`${n}.${s.name}`;this.cache[o]=this.convert(s.name)}this.cachedTables[n]=!0}}clearCache(){this.cache={},this.cachedTables={}}}G(Rw,Yy,"CasingCache");var qy,Qy;class Wf extends(Qy=Sn,qy=xt,Qy){}G(Wf,qy,"PgViewBase");var Ky;Ky=xt;class Bo{constructor(t){G(this,"casing");this.casing=new Rw(t==null?void 0:t.casing)}async migrate(t,e,i){const n=typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",s=typeof i=="string"?"drizzle":i.migrationsSchema??"drizzle",o=X`
+]`}concat(...t){const e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new $n(e,i.map(n=>new fr(e,n)))}slice(t,e){const i=this.schema;[t,e]=Y_({length:this.numRows},t,e);const n=Z_(this.data,this._offsets,t,e);return new $n(i,n.map(s=>new fr(i,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&ti.children[t]);if(e.length===0){const{type:i}=this.schema.fields[t],n=se({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new Me(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&tthis.getChildAt(u));[s[t],a[t]]=[o,e],[i,n]=qu(i,a)}return new $n(i,n)}select(t){const e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){const e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new $n(e,i)}assign(t){const e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,l,u)=>{const[c,h]=a,p=e.findIndex(f=>f.name===l.name);return~p?h[p]=u:c.push(u),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,l)=>[l,n[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):t.getChildAt(l)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new $n(...qu(s,o))}};l0=Symbol.toStringTag;gn[l0]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Ol(hf),r.get=Ol(mr.getVisitFn(L.Struct)),r.set=J_(Xr.getVisitFn(L.Struct)),r.indexOf=t0(Fl.getVisitFn(L.Struct)),"Table"))(gn.prototype);var u0;let fr=class Po{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Pe))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=se({nullCount:0,type:new sr(this.schema.fields),children:this.schema.fields.map(e=>se({type:e.type,nullCount:0}))})]=t,!(this.data instanceof Se))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Op(this.schema,this.data.children);break}case 1:{const[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((l,u,c)=>(l.children[c]=e[u],l.length=Math.max(l.length,e[u].length),l.fields[c]=Ce.new({name:u,type:e[u].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new Pe(i),a=se({type:new sr(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Op(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=c0(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 mr.visit(this.data,t)}at(t){return this.get(lf(t,this.numRows))}set(t,e){return Xr.visit(this.data,t,e)}indexOf(t,e){return Fl.visit(this.data,t,e)}[Symbol.iterator](){return ff.visit(new Me([this.data]))}toArray(){return[...this]}concat(...t){return new gn(this.schema,[this,...t])}slice(t,e){const[i]=new Me([this.data]).slice(t,e).data;return new Po(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&tn.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&ta.name===s);~o&&(n[o]=this.data.children[o])}return new Po(e,se({type:i,length:this.numRows,children:n}))}selectAt(t){const e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=se({type:new sr(e.fields),length:this.numRows,children:i});return new Po(e,n)}};u0=Symbol.toStringTag;fr[u0]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(fr.prototype);function Op(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;const n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(const[a,l]of r.fields.entries()){const u=t[a];(!u||u.length!==e)&&(n[a]=l.clone({nullable:!0}),s[a]=(i=u==null?void 0:u._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:se({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),se({type:new sr(n),length:e,children:s})]}function c0(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++sse({type:n.type})),i=se({type:new sr(t.fields),nullCount:0,children:e});super(t,i)}}let en=class ai{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ai).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+me),(e||new ai).__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):ke.V1}headerType(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):fe.NONE}header(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){const i=this.bb.__offset(this.bb_pos,12);return i?(e||new We).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+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,e){t.addFieldInt16(0,e,ke.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,fe.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,i,n,s,o){return ai.startMessage(t),ai.addVersion(t,e),ai.addHeaderType(t,i),ai.addHeader(t,n),ai.addBodyLength(t,s),ai.addCustomMetadata(t,o),ai.endMessage(t)}};class hO extends ie{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return _p.startNull(e),_p.endNull(e)}visitInt(t,e){return xr.startInt(e),xr.addBitWidth(e,t.bitWidth),xr.addIsSigned(e,t.isSigned),xr.endInt(e)}visitFloat(t,e){return mi.startFloatingPoint(e),mi.addPrecision(e,t.precision),mi.endFloatingPoint(e)}visitBinary(t,e){return pp.startBinary(e),pp.endBinary(e)}visitLargeBinary(t,e){return yp.startLargeBinary(e),yp.endLargeBinary(e)}visitBool(t,e){return mp.startBool(e),mp.endBool(e)}visitUtf8(t,e){return bp.startUtf8(e),bp.endUtf8(e)}visitLargeUtf8(t,e){return gp.startLargeUtf8(e),gp.endLargeUtf8(e)}visitDecimal(t,e){return Ss.startDecimal(e),Ss.addScale(e,t.scale),Ss.addPrecision(e,t.precision),Ss.addBitWidth(e,t.bitWidth),Ss.endDecimal(e)}visitDate(t,e){return Ua.startDate(e),Ua.addUnit(e,t.unit),Ua.endDate(e)}visitTime(t,e){return zr.startTime(e),zr.addUnit(e,t.unit),zr.addBitWidth(e,t.bitWidth),zr.endTime(e)}visitTimestamp(t,e){const i=t.timezone&&e.createString(t.timezone)||void 0;return jr.startTimestamp(e),jr.addUnit(e,t.unit),i!==void 0&&jr.addTimezone(e,i),jr.endTimestamp(e)}visitInterval(t,e){return yi.startInterval(e),yi.addUnit(e,t.unit),yi.endInterval(e)}visitDuration(t,e){return za.startDuration(e),za.addUnit(e,t.unit),za.endDuration(e)}visitList(t,e){return vp.startList(e),vp.endList(e)}visitStruct(t,e){return Yn.startStruct_(e),Yn.endStruct_(e)}visitUnion(t,e){hr.startTypeIdsVector(e,t.typeIds.length);const i=hr.createTypeIdsVector(e,t.typeIds);return hr.startUnion(e),hr.addMode(e,t.mode),hr.addTypeIds(e,i),hr.endUnion(e)}visitDictionary(t,e){const i=this.visit(t.indices,e);return $i.startDictionaryEncoding(e),$i.addId(e,BigInt(t.id)),$i.addIsOrdered(e,t.isOrdered),i!==void 0&&$i.addIndexType(e,i),$i.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return ja.startFixedSizeBinary(e),ja.addByteWidth(e,t.byteWidth),ja.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return $a.startFixedSizeList(e),$a.addListSize(e,t.listSize),$a.endFixedSizeList(e)}visitMap(t,e){return Va.startMap(e),Va.addKeysSorted(e,t.keysSorted),Va.endMap(e)}}const Qu=new hO;function fO(r,t=new Map){return new Pe(pO(r,t),Ha(r.metadata),t)}function h0(r){return new Fr(r.count,f0(r.columns),d0(r.columns))}function dO(r){return new Ti(h0(r.data),r.id,r.isDelta)}function pO(r,t){return(r.fields||[]).filter(Boolean).map(e=>Ce.fromJSON(e,t))}function Fp(r,t){return(r.children||[]).filter(Boolean).map(e=>Ce.fromJSON(e,t))}function f0(r){return(r||[]).reduce((t,e)=>[...t,new vn(e.count,mO(e.VALIDITY)),...f0(e.children)],[])}function d0(r,t=[]){for(let e=-1,i=(r||[]).length;++et+ +(e===0),0)}function yO(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=Mp(r,Fp(r,t)),n=new Ce(r.name,o,r.nullable,Ha(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?Pp(i):new Qo,a=new Zs(t.get(e),i,e,s.isOrdered),n=new Ce(r.name,a,r.nullable,Ha(r.metadata))):(i=(i=s.indexType)?Pp(i):new Qo,t.set(e,o=Mp(r,Fp(r,t))),a=new Zs(o,i,e,s.isOrdered),n=new Ce(r.name,a,r.nullable,Ha(r.metadata))),n||null}function Ha(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Pp(r){return new is(r.isSigned,r.bitWidth)}function Mp(r,t){const e=r.type.name;switch(e){case"NONE":return new pn;case"null":return new pn;case"binary":return new hl;case"largebinary":return new fl;case"utf8":return new dl;case"largeutf8":return new pl;case"bool":return new ml;case"list":return new xl((t||[])[0]);case"struct":return new sr(t||[]);case"struct_":return new sr(t||[])}switch(e){case"int":{const i=r.type;return new is(i.isSigned,i.bitWidth)}case"floatingpoint":{const i=r.type;return new cl(tr[i.precision])}case"decimal":{const i=r.type;return new yl(i.scale,i.precision,i.bitWidth)}case"date":{const i=r.type;return new gl(Hr[i.unit])}case"time":{const i=r.type;return new vl(zt[i.unit],i.bitWidth)}case"timestamp":{const i=r.type;return new _l(zt[i.unit],i.timezone)}case"interval":{const i=r.type;return new bl(Si[i.unit])}case"duration":{const i=r.type;return new wl(zt[i.unit])}case"union":{const i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new Sl(er[o],i.typeIds||[],t||[])}case"fixedsizebinary":{const i=r.type;return new Tl(i.byteWidth)}case"fixedsizelist":{const i=r.type;return new Il(i.listSize,(t||[])[0])}case"map":{const i=r.type;return new El((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var gO=Cv,vO=Qs;class or{static fromJSON(t,e){const i=new or(0,ke.V5,e);return i._createHeader=_O(t,e),i}static decode(t){t=new vO(ae(t));const e=en.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new or(i,n,s);return o._createHeader=bO(e,s),o}static encode(t){const e=new gO;let i=-1;return t.isSchema()?i=Pe.encode(e,t.header()):t.isRecordBatch()?i=Fr.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ti.encode(e,t.header())),en.startMessage(e),en.addVersion(e,ke.V5),en.addHeader(e,i),en.addHeaderType(e,t.headerType),en.addBodyLength(e,BigInt(t.bodyLength)),en.finishMessageBuffer(e,en.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Pe)return new or(0,ke.V5,fe.Schema,t);if(t instanceof Fr)return new or(e,ke.V5,fe.RecordBatch,t);if(t instanceof Ti)return new or(e,ke.V5,fe.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===fe.Schema}isRecordBatch(){return this.headerType===fe.RecordBatch}isDictionaryBatch(){return this.headerType===fe.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),n&&(this._createHeader=()=>n),this._bodyLength=we(t)}}class Fr{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,i){this._nodes=e,this._buffers=i,this._length=we(t)}}class Ti{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,e,i=!1){this._data=t,this._isDelta=i,this._id=we(e)}}class vi{constructor(t,e){this.offset=we(t),this.length=we(e)}}class vn{constructor(t,e){this.length=we(t),this.nullCount=we(e)}}function _O(r,t){return()=>{switch(t){case fe.Schema:return Pe.fromJSON(r);case fe.RecordBatch:return Fr.fromJSON(r);case fe.DictionaryBatch:return Ti.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${fe[t]}, type: ${t} }`)}}function bO(r,t){return()=>{switch(t){case fe.Schema:return Pe.decode(r.header(new ui),new Map,r.version());case fe.RecordBatch:return Fr.decode(r.header(new Bi),r.version());case fe.DictionaryBatch:return Ti.decode(r.header(new ws),r.version())}throw new Error(`Unrecognized Message type: { name: ${fe[t]}, type: ${t} }`)}}Ce.encode=PO;Ce.decode=OO;Ce.fromJSON=yO;Pe.encode=FO;Pe.decode=wO;Pe.fromJSON=fO;Fr.encode=MO;Fr.decode=xO;Fr.fromJSON=h0;Ti.encode=DO;Ti.decode=SO;Ti.fromJSON=dO;vn.encode=RO;vn.decode=IO;vi.encode=NO;vi.decode=TO;function wO(r,t=new Map,e=ke.V5){const i=AO(r,t);return new Pe(i,Xa(r),t,e)}function xO(r,t=ke.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Fr(r.length(),EO(r),CO(r,t))}function SO(r,t=ke.V5){return new Ti(Fr.decode(r.data(),t),r.id(),r.isDelta())}function TO(r){return new vi(r.offset(),r.length())}function IO(r){return new vn(r.length(),r.nullCount())}function EO(r){const t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++iCe.encode(r,s));ui.startFieldsVector(r,e.length);const i=ui.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?ui.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{const a=r.createString(`${s}`),l=r.createString(`${o}`);return We.startKeyValue(r),We.addKey(r,a),We.addValue(r,l),We.endKeyValue(r)})):-1;return ui.startSchema(r),ui.addFields(r,i),ui.addEndianness(r,LO?Ks.Little:Ks.Big),n!==-1&&ui.addCustomMetadata(r,n),ui.endSchema(r)}function PO(r,t){let e=-1,i=-1,n=-1;const s=t.type;let o=t.typeId;At.isDictionary(s)?(o=s.dictionary.typeId,n=Qu.visit(s,r),i=Qu.visit(s.dictionary,r)):i=Qu.visit(s,r);const a=(s.children||[]).map(c=>Ce.encode(r,c)),l=Nr.createChildrenVector(r,a),u=t.metadata&&t.metadata.size>0?Nr.createCustomMetadataVector(r,[...t.metadata].map(([c,h])=>{const p=r.createString(`${c}`),f=r.createString(`${h}`);return We.startKeyValue(r),We.addKey(r,p),We.addValue(r,f),We.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Nr.startField(r),Nr.addType(r,i),Nr.addTypeType(r,o),Nr.addChildren(r,l),Nr.addNullable(r,!!t.nullable),e!==-1&&Nr.addName(r,e),n!==-1&&Nr.addDictionary(r,n),u!==-1&&Nr.addCustomMetadata(r,u),Nr.endField(r)}function MO(r,t){const e=t.nodes||[],i=t.buffers||[];Bi.startNodesVector(r,e.length);for(const o of e.slice().reverse())vn.encode(r,o);const n=r.endVector();Bi.startBuffersVector(r,i.length);for(const o of i.slice().reverse())vi.encode(r,o);const s=r.endVector();return Bi.startRecordBatch(r),Bi.addLength(r,BigInt(t.length)),Bi.addNodes(r,n),Bi.addBuffers(r,s),Bi.endRecordBatch(r)}function DO(r,t){const e=Fr.encode(r,t.data);return ws.startDictionaryBatch(r),ws.addId(r,BigInt(t.id)),ws.addIsDelta(r,t.isDelta),ws.addData(r,e),ws.endDictionaryBatch(r)}function RO(r,t){return Fv.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function NO(r,t){return Ov.createBuffer(r,BigInt(t.offset),BigInt(t.length))}const LO=(()=>{const r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})(),_f=r=>`Expected ${fe[r]} Message in stream, but was null or length 0.`,bf=r=>`Header pointer of flatbuffer-encoded ${fe[r]} Message is null or length 0.`,p0=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,m0=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`;class y0{constructor(t){this.source=t instanceof Pl?t:new Pl(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?De:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(_f(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);const e=ae(this.source.read(t));if(e.byteLength[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(_f(t));return e.value}readSchema(){const t=fe.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(bf(t));return i}}const iu=4,ph="ARROW1",Zo=new Uint8Array(ph.length);for(let r=0;rthis):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 kr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return kr.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,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Vr?t:rh(t)?VO(t):wv(t)?HO(t):rs(t)?Zt(this,void 0,void 0,function*(){return yield Vr.from(yield t)}):xv(t)||rf(t)||Sv(t)||no(t)?WO(new Js(t)):GO(new Pl(t))}static readAll(t){return t instanceof Vr?t.isSync()?Lp(t):Bp(t):rh(t)||ArrayBuffer.isView(t)||oa(t)||bv(t)?Lp(t):Bp(t)}}class Dl extends Vr{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return dr(this,arguments,function*(){yield Pt(yield*ts(bi(this[Symbol.iterator]())))})}}class Rl extends Vr{constructor(t){super(t),this._impl=t}readAll(){return Zt(this,void 0,void 0,function*(){var t,e,i,n;const s=new Array;try{for(var o=!0,a=bi(this),l;l=yield a.next(),t=l.done,!t;o=!0){n=l.value,o=!1;const u=n;s.push(u)}}catch(u){e={error:u}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class v0 extends Dl{constructor(t){super(t),this._impl=t}}class zO extends Rl{constructor(t){super(t),this._impl=t}}class _0{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,e){const i=this._loadVectors(t,e,this.schema.fields),n=se({type:new sr(this.schema.fields),length:t.length,children:i});return new fr(this.schema,n)}_loadDictionaryBatch(t,e){const{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),l=o.dictionaries.get(i),u=this._loadVectors(t.data,e,[l]);return(a&&n?a.concat(new Me(u)):new Me(u)).memoize()}_loadVectors(t,e,i){return new a0(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}}class Nl extends _0{constructor(t,e){super(e),this._reader=rh(t)?new kO(this._handle=t):new y0(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=w0(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):De}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):De}next(){if(this.closed)return De;let t;const{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vf(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}}class Ll extends _0{constructor(t,e){super(e),this._reader=new BO(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return Zt(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 Zt(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=w0(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return Zt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):De})}return(t){return Zt(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):De})}next(){return Zt(this,void 0,void 0,function*(){if(this.closed)return De;let t;const{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;const i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new vf(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return Zt(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}}class b0 extends Nl{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,e){super(t instanceof Ap?t:new Ap(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();const i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){const n=this._reader.readMessage(fe.RecordBatch);if(n!=null&&n.isRecordBatch()){const s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;const i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){const n=this._reader.readMessage(fe.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){const s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:t}=this,e=t.size-g0,i=t.readInt32(e),n=t.readAt(e-i,i);return Ko.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return Zt(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return Zt(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());const i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){const n=yield this._reader.readMessage(fe.RecordBatch);if(n!=null&&n.isRecordBatch()){const s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return Zt(this,void 0,void 0,function*(){var e;const i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){const n=yield this._reader.readMessage(fe.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){const s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return Zt(this,void 0,void 0,function*(){const{_handle:t}=this;t._pending&&(yield t._pending);const e=t.size-g0,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return Ko.decode(n)})}_readNextMessageAndValidate(t){return Zt(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?wf(t)?new v0(new b0(r.read())):new Dl(new Nl(r)):new Dl(new Nl(function*(){}()))}function WO(r){return Zt(this,void 0,void 0,function*(){const t=yield r.peek(ca+7&-8);return t&&t.byteLength>=4?wf(t)?new v0(new b0(yield r.read())):new Rl(new Ll(r)):new Rl(new Ll(function(){return dr(this,arguments,function*(){})}()))})}function HO(r){return Zt(this,void 0,void 0,function*(){const{size:t}=yield r.stat(),e=new Ml(r,t);return t>=UO&&wf(yield e.readAt(0,ca+7&-8))?new zO(new jO(e)):new Rl(new Ll(e))})}class Ne extends ie{static assemble(...t){const e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof fr?s.data.children:s.data),i=new Ne;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof Me)return this.visitMany(t.data),this;const{type:e}=t;if(!At.isDictionary(e)){const{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(At.isUnion(e))this.nodes.push(new vn(i,0));else{const{nullCount:n}=t;At.isNull(e)||ti.call(this,n<=0?new Uint8Array(0):Cl(t.offset,i,t.nullBitmap)),this.nodes.push(new vn(i,n))}}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 ti(r){const t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new vi(this._byteLength,t)),this._byteLength+=t,this}function XO(r){var t;const{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(ti.call(this,n),e.mode===er.Sparse)return mh.call(this,r);if(e.mode===er.Dense){if(r.offset<=0)return ti.call(this,s),mh.call(this,r);{const o=new Int32Array(i),a=Object.create(null),l=Object.create(null);for(let u,c,h=-1;++h{const h=e.typeIds[c],p=a[h],f=l[h];return u.slice(p,Math.min(i,f))}))}}return this}function YO(r){let t;return r.nullCount>=r.length?ti.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?ti.call(this,Cl(r.offset,r.length,t)):ti.call(this,Al(r.values))}function Yi(r){return ti.call(this,r.values.subarray(0,r.length*r.stride))}function nu(r){const{length:t,values:e,valueOffsets:i}=r,n=we(i[0]),s=we(i[t]),o=Math.min(s-n,e.byteLength-n);return ti.call(this,Iv(-n,t+1,i)),ti.call(this,e.subarray(n,n+o)),this}function xf(r){const{length:t,valueOffsets:e}=r;if(e){const{[0]:i,[t]:n}=e;return ti.call(this,Iv(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function mh(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Ne.prototype.visitBool=YO;Ne.prototype.visitInt=Yi;Ne.prototype.visitFloat=Yi;Ne.prototype.visitUtf8=nu;Ne.prototype.visitLargeUtf8=nu;Ne.prototype.visitBinary=nu;Ne.prototype.visitLargeBinary=nu;Ne.prototype.visitFixedSizeBinary=Yi;Ne.prototype.visitDate=Yi;Ne.prototype.visitTimestamp=Yi;Ne.prototype.visitTime=Yi;Ne.prototype.visitDecimal=Yi;Ne.prototype.visitList=xf;Ne.prototype.visitStruct=mh;Ne.prototype.visitUnion=XO;Ne.prototype.visitInterval=Yi;Ne.prototype.visitDuration=Yi;Ne.prototype.visitFixedSizeList=xf;Ne.prototype.visitMap=xf;class x0 extends df{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Wa,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,pr(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 rs(t)?t.then(e=>this.writeAll(e)):no(t)?Ef(this,t):If(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,e=null){return t===this._sink||t instanceof Wa?this._sink=t:(this._sink=new Wa,t&&SC(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&TC(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,(!e||!dh(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof gn&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof fr&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!dh(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof fr?t instanceof vf||this._writeRecordBatch(t):t instanceof gn?this.writeAll(t.batches):oa(t)&&this.writeAll(t)}_writeMessage(t,e=8){const i=e-1,n=or.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,l=a-s-o;return t.headerType===fe.RecordBatch?this._recordBatchBlocks.push(new mn(a,t.bodyLength,this._position)):t.headerType===fe.DictionaryBatch&&this._dictionaryBlocks.push(new mn(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(l)}_write(t){if(this._started){const e=ae(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(or.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Zo)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){const{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=Ne.assemble(t),o=new Fr(t.numRows,i,n),a=or.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,i=!1){const{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=Ne.assemble(new Me([t])),l=new Fr(t.length,s,o),u=new Ti(l,e,i),c=or.from(u,n);return this._writeMessage(c)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,i,n;for(let s=-1,o=t.length;++s0&&(this._write(e),(n=(i+7&-8)-i)>0&&this._writePadding(n));return this}_writeDictionaries(t){var e,i;for(const[n,s]of t.dictionaries){const o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),l=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(const[u,c]of o.entries())this._writeDictionaryBatch(c,n,u>0);else if(li.writeAll(n)):no(t)?Ef(i,t):If(i,t)}}class Tf extends x0{static writeAll(t){const e=new Tf;return rs(t)?t.then(i=>e.writeAll(i)):no(t)?Ef(e,t):If(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){const e=Ko.encode(new Ko(t,ke.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}}function If(r,t){let e=t;t instanceof gn&&(e=t.batches,r.reset(void 0,t.schema));for(const i of e)r.write(i);return r.finish()}function Ef(r,t){return Zt(this,void 0,void 0,function*(){var e,i,n,s,o,a,l;try{for(e=!0,i=bi(t);n=yield i.next(),s=n.done,!s;e=!0){l=n.value,e=!1;const u=l;r.write(u)}}catch(u){o={error:u}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function qO(r,t="stream"){return(t==="stream"?Sf:Tf).writeAll(r).toUint8Array(!0)}var QO=Object.create,S0=Object.defineProperty,KO=Object.getOwnPropertyDescriptor,ZO=Object.getOwnPropertyNames,JO=Object.getPrototypeOf,t2=Object.prototype.hasOwnProperty,e2=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),r2=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ZO(t))!t2.call(r,n)&&n!==e&&S0(r,n,{get:()=>t[n],enumerable:!(i=KO(t,n))||i.enumerable});return r},i2=(r,t,e)=>(e=r!=null?QO(JO(r)):{},r2(!r||!r.__esModule?S0(e,"default",{value:r,enumerable:!0}):e,r)),n2=e2((r,t)=>{t.exports=Worker}),T0=(r=>(r[r.UNDEFINED=0]="UNDEFINED",r[r.AUTOMATIC=1]="AUTOMATIC",r[r.READ_ONLY=2]="READ_ONLY",r[r.READ_WRITE=3]="READ_WRITE",r))(T0||{}),s2=(r=>(r[r.IDENTIFIER=0]="IDENTIFIER",r[r.NUMERIC_CONSTANT=1]="NUMERIC_CONSTANT",r[r.STRING_CONSTANT=2]="STRING_CONSTANT",r[r.OPERATOR=3]="OPERATOR",r[r.KEYWORD=4]="KEYWORD",r[r.COMMENT=5]="COMMENT",r))(s2||{}),o2=(r=>(r[r.NONE=0]="NONE",r[r.DEBUG=1]="DEBUG",r[r.INFO=2]="INFO",r[r.WARNING=3]="WARNING",r[r.ERROR=4]="ERROR",r))(o2||{}),a2=(r=>(r[r.NONE=0]="NONE",r[r.CONNECT=1]="CONNECT",r[r.DISCONNECT=2]="DISCONNECT",r[r.OPEN=3]="OPEN",r[r.QUERY=4]="QUERY",r[r.INSTANTIATE=5]="INSTANTIATE",r))(a2||{}),l2=(r=>(r[r.NONE=0]="NONE",r[r.OK=1]="OK",r[r.ERROR=2]="ERROR",r[r.START=3]="START",r[r.RUN=4]="RUN",r[r.CAPTURE=5]="CAPTURE",r))(l2||{}),u2=(r=>(r[r.NONE=0]="NONE",r[r.WEB_WORKER=1]="WEB_WORKER",r[r.NODE_WORKER=2]="NODE_WORKER",r[r.BINDINGS=3]="BINDINGS",r[r.ASYNC_DUCKDB=4]="ASYNC_DUCKDB",r))(u2||{}),c2=class{log(r){}},I0=class{constructor(r=2){this.level=r}log(r){r.level>=this.level&&console.log(r)}},h2=(r=>(r[r.SUCCESS=0]="SUCCESS",r))(h2||{}),f2=class{constructor(r,t){this._bindings=r,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(r){return r(this._bindings,this._conn)}async query(r){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let t=await this._bindings.runQuery(this._conn,r),e=Vr.from(t);return console.assert(e.isSync(),"Reader is not sync"),console.assert(e.isFile(),"Reader is not file"),new gn(e)}async send(r,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:r});let e=await this._bindings.startPendingQuery(this._conn,r,t);for(;e==null;)e=await this._bindings.pollPendingQuery(this._conn);let i=new E0(this._bindings,this._conn,e),n=await Vr.from(i);return console.assert(n.isAsync()),console.assert(n.isStream()),n}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(r){return await this._bindings.getTableNames(this._conn,r)}async prepare(r){let t=await this._bindings.createPrepared(this._conn,r);return new d2(this._bindings,this._conn,t)}async insertArrowTable(r,t){let e=qO(r,"stream");await this.insertArrowFromIPCStream(e,t)}async insertArrowFromIPCStream(r,t){await this._bindings.insertArrowFromIPCStream(this._conn,r,t)}async insertCSVFromPath(r,t){await this._bindings.insertCSVFromPath(this._conn,r,t)}async insertJSONFromPath(r,t){await this._bindings.insertJSONFromPath(this._conn,r,t)}},E0=class{constructor(r,t,e){this.db=r,this.conn=t,this.header=e,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 r;return this._inFlight!=null?(r=await this._inFlight,this._inFlight=null):r=await this.db.fetchQueryResults(this.conn),this._depleted=r.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:r}}[Symbol.asyncIterator](){return this}},d2=class{constructor(r,t,e){this.bindings=r,this.connectionId=t,this.statementId=e}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...r){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,r),e=Vr.from(t);return console.assert(e.isSync()),console.assert(e.isFile()),new gn(e)}async send(...r){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,r),e=new E0(this.bindings,this.connectionId,t),i=await Vr.from(e);return console.assert(i.isAsync()),console.assert(i.isStream()),i}},p2=(r=>(r.CANCEL_PENDING_QUERY="CANCEL_PENDING_QUERY",r.CLOSE_PREPARED="CLOSE_PREPARED",r.COLLECT_FILE_STATISTICS="COLLECT_FILE_STATISTICS",r.REGISTER_OPFS_FILE_NAME="REGISTER_OPFS_FILE_NAME",r.CONNECT="CONNECT",r.COPY_FILE_TO_BUFFER="COPY_FILE_TO_BUFFER",r.COPY_FILE_TO_PATH="COPY_FILE_TO_PATH",r.CREATE_PREPARED="CREATE_PREPARED",r.DISCONNECT="DISCONNECT",r.DROP_FILE="DROP_FILE",r.DROP_FILES="DROP_FILES",r.EXPORT_FILE_STATISTICS="EXPORT_FILE_STATISTICS",r.FETCH_QUERY_RESULTS="FETCH_QUERY_RESULTS",r.FLUSH_FILES="FLUSH_FILES",r.GET_FEATURE_FLAGS="GET_FEATURE_FLAGS",r.GET_TABLE_NAMES="GET_TABLE_NAMES",r.GET_VERSION="GET_VERSION",r.GLOB_FILE_INFOS="GLOB_FILE_INFOS",r.INSERT_ARROW_FROM_IPC_STREAM="INSERT_ARROW_FROM_IPC_STREAM",r.INSERT_CSV_FROM_PATH="IMPORT_CSV_FROM_PATH",r.INSERT_JSON_FROM_PATH="IMPORT_JSON_FROM_PATH",r.INSTANTIATE="INSTANTIATE",r.OPEN="OPEN",r.PING="PING",r.POLL_PENDING_QUERY="POLL_PENDING_QUERY",r.REGISTER_FILE_BUFFER="REGISTER_FILE_BUFFER",r.REGISTER_FILE_HANDLE="REGISTER_FILE_HANDLE",r.REGISTER_FILE_URL="REGISTER_FILE_URL",r.RESET="RESET",r.RUN_PREPARED="RUN_PREPARED",r.RUN_QUERY="RUN_QUERY",r.SEND_PREPARED="SEND_PREPARED",r.START_PENDING_QUERY="START_PENDING_QUERY",r.TOKENIZE="TOKENIZE",r))(p2||{}),m2=(r=>(r.CONNECTION_INFO="CONNECTION_INFO",r.ERROR="ERROR",r.FEATURE_FLAGS="FEATURE_FLAGS",r.FILE_BUFFER="FILE_BUFFER",r.FILE_INFOS="FILE_INFOS",r.FILE_SIZE="FILE_SIZE",r.FILE_STATISTICS="FILE_STATISTICS",r.INSTANTIATE_PROGRESS="INSTANTIATE_PROGRESS",r.LOG="LOG",r.OK="OK",r.PREPARED_STATEMENT_ID="PREPARED_STATEMENT_ID",r.QUERY_PLAN="QUERY_PLAN",r.QUERY_RESULT="QUERY_RESULT",r.QUERY_RESULT_CHUNK="QUERY_RESULT_CHUNK",r.QUERY_RESULT_HEADER="QUERY_RESULT_HEADER",r.QUERY_RESULT_HEADER_OR_NULL="QUERY_RESULT_HEADER_OR_NULL",r.REGISTERED_FILE="REGISTERED_FILE",r.SCRIPT_TOKENS="SCRIPT_TOKENS",r.SUCCESS="SUCCESS",r.TABLE_NAMES="TABLE_NAMES",r.VERSION_STRING="VERSION_STRING",r))(m2||{}),ue=class{constructor(r,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=r,this.data=t,this.promise=new Promise((e,i)=>{this.promiseResolver=e,this.promiseRejecter=i})}};function Ya(r){switch(r.typeId){case L.Binary:return{sqlType:"binary"};case L.Bool:return{sqlType:"bool"};case L.Date:return{sqlType:"date"};case L.DateDay:return{sqlType:"date32[d]"};case L.DateMillisecond:return{sqlType:"date64[ms]"};case L.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case L.Float:return{sqlType:"float"};case L.Float16:return{sqlType:"float16"};case L.Float32:return{sqlType:"float32"};case L.Float64:return{sqlType:"float64"};case L.Int:return{sqlType:"int32"};case L.Int16:return{sqlType:"int16"};case L.Int32:return{sqlType:"int32"};case L.Int64:return{sqlType:"int64"};case L.Uint16:return{sqlType:"uint16"};case L.Uint32:return{sqlType:"uint32"};case L.Uint64:return{sqlType:"uint64"};case L.Uint8:return{sqlType:"uint8"};case L.IntervalDayTime:return{sqlType:"interval[dt]"};case L.IntervalYearMonth:return{sqlType:"interval[m]"};case L.List:return{sqlType:"list",valueType:Ya(r.valueType)};case L.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case L.Null:return{sqlType:"null"};case L.Utf8:return{sqlType:"utf8"};case L.Struct:return{sqlType:"struct",fields:r.children.map(t=>yh(t.name,t.type))};case L.Map:{let t=r;return{sqlType:"map",keyType:Ya(t.keyType),valueType:Ya(t.valueType)}}case L.Time:return{sqlType:"time[s]"};case L.TimeMicrosecond:return{sqlType:"time[us]"};case L.TimeMillisecond:return{sqlType:"time[ms]"};case L.TimeNanosecond:return{sqlType:"time[ns]"};case L.TimeSecond:return{sqlType:"time[s]"};case L.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case L.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case L.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case L.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case L.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function yh(r,t){let e=Ya(t);return e.name=r,e}var y2=new TextEncoder,g2=class{constructor(r,t=null){this._onInstantiationProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._logger=r,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(r){this._worker=r,this._worker.addEventListener("message",this._onMessageHandler),this._worker.addEventListener("error",this._onErrorHandler),this._worker.addEventListener("close",this._onCloseHandler),this._workerShutdownPromise=new Promise((t,e)=>{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(r,t=[]){if(!this._worker){console.error("cannot send a message since the worker is not set!");return}let e=this._nextMessageId++;return this._pendingRequests.set(e,r),this._worker.postMessage({messageId:e,type:r.type,data:r.data},t),await r.promise}onMessage(r){var t;let e=r.data;switch(e.type){case"LOG":{this._logger.log(e.data);return}case"INSTANTIATE_PROGRESS":{for(let n of this._onInstantiationProgress)n(e.data);return}}let i=this._pendingRequests.get(e.requestId);if(!i){console.warn("unassociated response: [".concat(e.requestId,", ").concat(e.type.toString(),"]"));return}if(this._pendingRequests.delete(e.requestId),e.type=="ERROR"){let n=new Error(e.data.message);n.name=e.data.name,(t=Object.getOwnPropertyDescriptor(n,"stack"))!=null&&t.writable&&(n.stack=e.data.stack),i.promiseRejecter(n);return}switch(i.type){case"CLOSE_PREPARED":case"COLLECT_FILE_STATISTICS":case"REGISTER_OPFS_FILE_NAME":case"COPY_FILE_TO_PATH":case"DISCONNECT":case"DROP_FILE":case"DROP_FILES":case"FLUSH_FILES":case"INSERT_ARROW_FROM_IPC_STREAM":case"IMPORT_CSV_FROM_PATH":case"IMPORT_JSON_FROM_PATH":case"OPEN":case"PING":case"REGISTER_FILE_BUFFER":case"REGISTER_FILE_HANDLE":case"REGISTER_FILE_URL":case"RESET":if(e.type=="OK"){i.promiseResolver(e.data);return}break;case"INSTANTIATE":if(this._onInstantiationProgress=[],e.type=="OK"){i.promiseResolver(e.data);return}break;case"GLOB_FILE_INFOS":if(e.type=="FILE_INFOS"){i.promiseResolver(e.data);return}break;case"GET_VERSION":if(e.type=="VERSION_STRING"){i.promiseResolver(e.data);return}break;case"GET_FEATURE_FLAGS":if(e.type=="FEATURE_FLAGS"){i.promiseResolver(e.data);return}break;case"GET_TABLE_NAMES":if(e.type=="TABLE_NAMES"){i.promiseResolver(e.data);return}break;case"TOKENIZE":if(e.type=="SCRIPT_TOKENS"){i.promiseResolver(e.data);return}break;case"COPY_FILE_TO_BUFFER":if(e.type=="FILE_BUFFER"){i.promiseResolver(e.data);return}break;case"EXPORT_FILE_STATISTICS":if(e.type=="FILE_STATISTICS"){i.promiseResolver(e.data);return}break;case"CONNECT":if(e.type=="CONNECTION_INFO"){i.promiseResolver(e.data);return}break;case"RUN_PREPARED":case"RUN_QUERY":if(e.type=="QUERY_RESULT"){i.promiseResolver(e.data);return}break;case"SEND_PREPARED":if(e.type=="QUERY_RESULT_HEADER"){i.promiseResolver(e.data);return}break;case"START_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(e.data);return}break;case"POLL_PENDING_QUERY":if(e.type=="QUERY_RESULT_HEADER_OR_NULL"){i.promiseResolver(e.data);return}break;case"CANCEL_PENDING_QUERY":if(this._onInstantiationProgress=[],e.type=="SUCCESS"){i.promiseResolver(e.data);return}break;case"FETCH_QUERY_RESULTS":if(e.type=="QUERY_RESULT_CHUNK"){i.promiseResolver(e.data);return}break;case"CREATE_PREPARED":if(e.type=="PREPARED_STATEMENT_ID"){i.promiseResolver(e.data);return}break}i.promiseRejecter(new Error("unexpected response type: ".concat(e.type.toString())))}onError(r){console.error(r),console.error("error in duckdb worker: ".concat(r.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 r=new ue("RESET",null);return await this.postTask(r)}async ping(){let r=new ue("PING",null);await this.postTask(r)}async dropFile(r){let t=new ue("DROP_FILE",r);return await this.postTask(t)}async dropFiles(){let r=new ue("DROP_FILES",null);return await this.postTask(r)}async flushFiles(){let r=new ue("FLUSH_FILES",null);return await this.postTask(r)}async instantiate(r,t=null,e=i=>{}){this._onInstantiationProgress.push(e);let i=new ue("INSTANTIATE",[r,t]);return await this.postTask(i)}async getVersion(){let r=new ue("GET_VERSION",null);return await this.postTask(r)}async getFeatureFlags(){let r=new ue("GET_FEATURE_FLAGS",null);return await this.postTask(r)}async open(r){let t=new ue("OPEN",r);await this.postTask(t)}async tokenize(r){let t=new ue("TOKENIZE",r);return await this.postTask(t)}async connectInternal(){let r=new ue("CONNECT",null);return await this.postTask(r)}async connect(){let r=await this.connectInternal();return new f2(this,r)}async disconnect(r){let t=new ue("DISCONNECT",r);await this.postTask(t)}async runQuery(r,t){let e=new ue("RUN_QUERY",[r,t]);return await this.postTask(e)}async startPendingQuery(r,t,e=!1){let i=new ue("START_PENDING_QUERY",[r,t,e]);return await this.postTask(i)}async pollPendingQuery(r){let t=new ue("POLL_PENDING_QUERY",r);return await this.postTask(t)}async cancelPendingQuery(r){let t=new ue("CANCEL_PENDING_QUERY",r);return await this.postTask(t)}async fetchQueryResults(r){let t=new ue("FETCH_QUERY_RESULTS",r);return await this.postTask(t)}async getTableNames(r,t){let e=new ue("GET_TABLE_NAMES",[r,t]);return await this.postTask(e)}async createPrepared(r,t){let e=new ue("CREATE_PREPARED",[r,t]);return await this.postTask(e)}async closePrepared(r,t){let e=new ue("CLOSE_PREPARED",[r,t]);await this.postTask(e)}async runPrepared(r,t,e){let i=new ue("RUN_PREPARED",[r,t,e]);return await this.postTask(i)}async sendPrepared(r,t,e){let i=new ue("SEND_PREPARED",[r,t,e]);return await this.postTask(i)}async globFiles(r){let t=new ue("GLOB_FILE_INFOS",r);return await this.postTask(t)}async registerFileText(r,t){let e=y2.encode(t);await this.registerFileBuffer(r,e)}async registerFileURL(r,t,e,i){t===void 0&&(t=r);let n=new ue("REGISTER_FILE_URL",[r,t,e,i]);await this.postTask(n)}async registerEmptyFileBuffer(r){}async registerFileBuffer(r,t){let e=new ue("REGISTER_FILE_BUFFER",[r,t]);await this.postTask(e,[t.buffer])}async registerFileHandle(r,t,e,i){let n=new ue("REGISTER_FILE_HANDLE",[r,t,e,i]);await this.postTask(n,[])}async registerOPFSFileName(r){let t=new ue("REGISTER_OPFS_FILE_NAME",[r]);await this.postTask(t,[])}async collectFileStatistics(r,t){let e=new ue("COLLECT_FILE_STATISTICS",[r,t]);await this.postTask(e,[])}async exportFileStatistics(r){let t=new ue("EXPORT_FILE_STATISTICS",r);return await this.postTask(t,[])}async copyFileToBuffer(r){let t=new ue("COPY_FILE_TO_BUFFER",r);return await this.postTask(t)}async copyFileToPath(r,t){let e=new ue("COPY_FILE_TO_PATH",[r,t]);await this.postTask(e)}async insertArrowFromIPCStream(r,t,e){if(t.length==0)return;let i=new ue("INSERT_ARROW_FROM_IPC_STREAM",[r,t,e]);await this.postTask(i,[t.buffer])}async insertCSVFromPath(r,t,e){if(e.columns!==void 0){let n=[];for(let s in e.columns){let o=e.columns[s];n.push(yh(s,o))}e.columnsFlat=n,delete e.columns}let i=new ue("IMPORT_CSV_FROM_PATH",[r,t,e]);await this.postTask(i)}async insertJSONFromPath(r,t,e){if(e.columns!==void 0){let n=[];for(let s in e.columns){let o=e.columns[s];n.push(yh(s,o))}e.columnsFlat=n,delete e.columns}let i=new ue("IMPORT_JSON_FROM_PATH",[r,t,e]);await this.postTask(i)}};function v2(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}v2();var _2=(r=>(r[r.BUFFER=0]="BUFFER",r[r.NODE_FS=1]="NODE_FS",r[r.BROWSER_FILEREADER=2]="BROWSER_FILEREADER",r[r.BROWSER_FSACCESS=3]="BROWSER_FSACCESS",r[r.HTTP=4]="HTTP",r[r.S3=5]="S3",r))(_2||{}),b2=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])),w2=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])),x2=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])),S2=()=>(async r=>{try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(r)}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])),T2={version:"1.29.1-dev68.0"},Cf=T2.version.split(".");Cf[0];Cf[1];Cf[2];var I2=()=>typeof navigator>"u",Ku=null,Zu=null,Ju=null,tc=null,ec=null;async function E2(){return Ku==null&&(Ku=typeof BigInt64Array<"u"),Zu==null&&(Zu=await w2()),Ju==null&&(Ju=await S2()),tc==null&&(tc=await x2()),ec==null&&(ec=await b2()),{bigInt64Array:Ku,crossOriginIsolated:I2()||globalThis.crossOriginIsolated||!1,wasmExceptions:Zu,wasmSIMD:tc,wasmThreads:Ju,wasmBulkMemory:ec}}async function kp(r){let t=await E2();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&r.coi)return{mainModule:r.coi.mainModule,mainWorker:r.coi.mainWorker,pthreadWorker:r.coi.pthreadWorker};if(r.eh)return{mainModule:r.eh.mainModule,mainWorker:r.eh.mainWorker,pthreadWorker:null}}return{mainModule:r.mvp.mainModule,mainWorker:r.mvp.mainWorker,pthreadWorker:null}}i2(n2());const rc={},Mo={};function Lo(r,t){try{const i=(rc[r]||(rc[r]=new Intl.DateTimeFormat("en-GB",{timeZone:r,hour:"numeric",timeZoneName:"longOffset"}).format))(t).split("GMT")[1]||"";return i in Mo?Mo[i]:Up(i,i.split(":"))}catch{if(r in Mo)return Mo[r];const e=r==null?void 0:r.match(C2);return e?Up(r,e.slice(1)):NaN}}const C2=/([+-]\d\d):?(\d\d)?/;function Up(r,t){const e=+t[0],i=+(t[1]||0);return Mo[r]=e>0?e*60+i:e*60-i}class Er extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Lo(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),C0(this),gh(this)):this.setTime(Date.now())}static tz(t,...e){return e.length?new Er(...e,t):new Er(Date.now(),t)}withTimeZone(t){return new Er(+this,t)}getTimezoneOffset(){return-Lo(this.timeZone,this)}setTime(t){return Date.prototype.setTime.apply(this,arguments),gh(this),+this}[Symbol.for("constructDateFrom")](t){return new Er(+new Date(t),this.timeZone)}}const zp=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(r=>{if(!zp.test(r))return;const t=r.replace(zp,"$1UTC");Er.prototype[t]&&(r.startsWith("get")?Er.prototype[r]=function(){return this.internal[t]()}:(Er.prototype[r]=function(){return Date.prototype[t].apply(this.internal,arguments),A2(this),+this},Er.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),gh(this),+this}))});function gh(r){r.internal.setTime(+r),r.internal.setUTCMinutes(r.internal.getUTCMinutes()-r.getTimezoneOffset())}function A2(r){Date.prototype.setFullYear.call(r,r.internal.getUTCFullYear(),r.internal.getUTCMonth(),r.internal.getUTCDate()),Date.prototype.setHours.call(r,r.internal.getUTCHours(),r.internal.getUTCMinutes(),r.internal.getUTCSeconds(),r.internal.getUTCMilliseconds()),C0(r)}function C0(r){const t=Lo(r.timeZone,r),e=new Date(+r);e.setUTCHours(e.getUTCHours()-1);const i=-new Date(+r).getTimezoneOffset(),n=-new Date(+e).getTimezoneOffset(),s=i-n,o=Date.prototype.getHours.apply(r)!==r.internal.getUTCHours();s&&o&&r.internal.setUTCMinutes(r.internal.getUTCMinutes()+s);const a=i-t;a&&Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+a);const l=Lo(r.timeZone,r),c=-new Date(+r).getTimezoneOffset()-l,h=l!==t,p=c-a;if(h&&p){Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+p);const f=Lo(r.timeZone,r),y=l-f;y&&(r.internal.setUTCMinutes(r.internal.getUTCMinutes()+y),Date.prototype.setUTCMinutes.call(r,Date.prototype.getUTCMinutes.call(r)+y))}}const O2=new TextDecoder("utf-8"),F2=r=>O2.decode(r),P2=new TextEncoder,A0=r=>P2.encode(r),hi=r=>typeof r=="function",ha=r=>r!=null&&Object(r)===r,M2=r=>ha(r)&&hi(r.then),O0=r=>ha(r)&&hi(r[Symbol.iterator]),D2=r=>ha(r)&&hi(r[Symbol.asyncIterator]),R2=r=>ha(r)&&"done"in r&&"value"in r,N2=r=>ha(r)&&hi(r.clear)&&hi(r.bytes)&&hi(r.position)&&hi(r.setPosition)&&hi(r.capacity)&&hi(r.getBufferIdentifier)&&hi(r.createLong),Af=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function L2(r){const t=r[0]?[r[0]]:[];let e,i,n,s;for(let o,a,l=0,u=0,c=r.length;++lc+h.byteLength,0);let n,s,o,a=0,l=-1;const u=Math.min(t||Number.POSITIVE_INFINITY,i);for(const c=e.length;++lrr(Int8Array,r),U2=r=>rr(Int16Array,r),z2=r=>rr(Int32Array,r),j2=r=>rr(BigInt64Array,r),$2=r=>rr(Uint8Array,r),V2=r=>rr(Uint16Array,r),G2=r=>rr(Uint32Array,r),W2=r=>rr(BigUint64Array,r),H2=r=>rr(Float32Array,r),X2=r=>rr(Float64Array,r),Y2=r=>rr(Uint8ClampedArray,r),_h=r=>(r.next(),r);function*Oi(r,t){const e=function*(n){yield n},i=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Af?e(t):O0(t)?t:e(t);return yield*_h(function*(n){let s=null;do s=n.next(yield rr(r,s));while(!s.done)}(i[Symbol.iterator]())),new r}const q2=r=>Oi(Int8Array,r),Q2=r=>Oi(Int16Array,r),K2=r=>Oi(Int32Array,r),Z2=r=>Oi(Uint8Array,r),J2=r=>Oi(Uint16Array,r),tF=r=>Oi(Uint32Array,r),eF=r=>Oi(Float32Array,r),rF=r=>Oi(Float64Array,r),iF=r=>Oi(Uint8ClampedArray,r);function ii(r,t){return dr(this,arguments,function*(){if(M2(t))return yield Pt(yield Pt(yield*ts(bi(ii(r,yield Pt(t))))));const i=function(o){return dr(this,arguments,function*(){yield yield Pt(yield Pt(o))})},n=function(o){return dr(this,arguments,function*(){yield Pt(yield*ts(bi(_h(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Af?i(t):O0(t)?n(t):D2(t)?t:i(t);return yield Pt(yield*ts(bi(_h(function(o){return dr(this,arguments,function*(){let a=null;do a=yield Pt(o.next(yield yield Pt(rr(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield Pt(new r)})}const nF=r=>ii(Int8Array,r),sF=r=>ii(Int16Array,r),oF=r=>ii(Int32Array,r),aF=r=>ii(Uint8Array,r),lF=r=>ii(Uint16Array,r),uF=r=>ii(Uint32Array,r),cF=r=>ii(Float32Array,r),hF=r=>ii(Float64Array,r),fF=r=>ii(Uint8ClampedArray,r);function dF(r,t,e){if(r!==0){e=e.slice(0,t);for(let i=-1,n=e.length;++i0)do if(r[e]!==t[e])return!1;while(++eeo(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}const yF=Object.freeze(Object.defineProperty({__proto__:null,valueToString:eo},Symbol.toStringTag,{value:"Module"}));function ar(r){if(typeof r=="bigint"&&(rNumber.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function P0(r,t){return ar(r/t)+ar(r%t)/ar(t)}const M0=Symbol.for("isArrowBigNum");function ni(r,...t){return t.length===0?Object.setPrototypeOf(rr(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ni.prototype[M0]=!0;ni.prototype.toJSON=function(){return`"${ro(this)}"`};ni.prototype.valueOf=function(r){return Of(this,r)};ni.prototype.toString=function(){return ro(this)};ni.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Of(this);case"string":return ro(this);case"default":return D0(this)}return ro(this)};function Gs(...r){return ni.apply(this,r)}function Ws(...r){return ni.apply(this,r)}function Jo(...r){return ni.apply(this,r)}Object.setPrototypeOf(Gs.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Ws.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Jo.prototype,Object.create(Uint32Array.prototype));Object.assign(Gs.prototype,ni.prototype,{constructor:Gs,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Ws.prototype,ni.prototype,{constructor:Ws,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Jo.prototype,ni.prototype,{constructor:Jo,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const gF=BigInt(4294967296)*BigInt(4294967296),vF=gF-BigInt(1);function Of(r,t){const{buffer:e,byteOffset:i,byteLength:n,signed:s}=r,o=new BigUint64Array(e,i,n/8),a=s&&o.at(-1)&BigInt(1)<=0)return ic(r);t=t.slice();let i=1;for(let s=0;s(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(Et.prototype);class jp extends Et{constructor(){super(W.Null)}toString(){return"Null"}}N0=Symbol.toStringTag;jp[N0]=(r=>r[Symbol.toStringTag]="Null")(jp.prototype);class $p extends Et{constructor(t,e){super(W.Int),this.isSigned=t,this.bitWidth=e}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}`}}L0=Symbol.toStringTag;$p[L0]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))($p.prototype);class Vp extends Et{constructor(t){super(W.Float),this.precision=t}get ArrayType(){switch(this.precision){case Cr.HALF:return Uint16Array;case Cr.SINGLE:return Float32Array;case Cr.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}B0=Symbol.toStringTag;Vp[B0]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Vp.prototype);class Gp extends Et{constructor(){super(W.Binary)}toString(){return"Binary"}}k0=Symbol.toStringTag;Gp[k0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Gp.prototype);class Wp extends Et{constructor(){super(W.LargeBinary)}toString(){return"LargeBinary"}}U0=Symbol.toStringTag;Wp[U0]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Wp.prototype);class Hp extends Et{constructor(){super(W.Utf8)}toString(){return"Utf8"}}z0=Symbol.toStringTag;Hp[z0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Hp.prototype);class Xp extends Et{constructor(){super(W.LargeUtf8)}toString(){return"LargeUtf8"}}j0=Symbol.toStringTag;Xp[j0]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Xp.prototype);class Yp extends Et{constructor(){super(W.Bool)}toString(){return"Bool"}}$0=Symbol.toStringTag;Yp[$0]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Yp.prototype);class qp extends Et{constructor(t,e,i=128){super(W.Decimal),this.scale=t,this.precision=e,this.bitWidth=i}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}}V0=Symbol.toStringTag;qp[V0]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(qp.prototype);class Qp extends Et{constructor(t){super(W.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${_n[this.unit]}>`}get ArrayType(){return this.unit===_n.DAY?Int32Array:BigInt64Array}}G0=Symbol.toStringTag;Qp[G0]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Qp.prototype);class Kp extends Et{constructor(t,e){super(W.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${Jt[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}W0=Symbol.toStringTag;Kp[W0]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Kp.prototype);class Zp extends Et{constructor(t,e){super(W.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${Jt[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}H0=Symbol.toStringTag;Zp[H0]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Zp.prototype);class Jp extends Et{constructor(t){super(W.Interval),this.unit=t}toString(){return`Interval<${ns[this.unit]}>`}}X0=Symbol.toStringTag;Jp[X0]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Jp.prototype);class tm extends Et{constructor(t){super(W.Duration),this.unit=t}toString(){return`Duration<${Jt[this.unit]}>`}}Y0=Symbol.toStringTag;tm[Y0]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(tm.prototype);class em extends Et{constructor(t){super(W.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}}q0=Symbol.toStringTag;em[q0]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(em.prototype);class bh extends Et{constructor(t){super(W.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}Q0=Symbol.toStringTag;bh[Q0]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(bh.prototype);class rm extends Et{constructor(t,e,i){super(W.Union),this.mode=t,this.children=i,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((n,s,o)=>(n[s]=o)&&n||n,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}}K0=Symbol.toStringTag;rm[K0]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(rm.prototype);class im extends Et{constructor(t){super(W.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}Z0=Symbol.toStringTag;im[Z0]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(im.prototype);class nm extends Et{constructor(t,e){super(W.FixedSizeList),this.listSize=t,this.children=[e]}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}>`}}J0=Symbol.toStringTag;nm[J0]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(nm.prototype);class sm extends Et{constructor(t,e=!1){var i,n,s;if(super(W.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((i=t==null?void 0:t.type)===null||i===void 0)&&i.children)){const o=(n=t==null?void 0:t.type)===null||n===void 0?void 0:n.children[0];o&&(o.name="key");const a=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}}tb=Symbol.toStringTag;sm[tb]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(sm.prototype);const bF=(r=>()=>++r)(-1);class om extends Et{constructor(t,e,i,n){super(W.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=n||!1,this.id=i==null?bF():ar(i)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}eb=Symbol.toStringTag;om[eb]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(om.prototype);function rb(r){const t=r;switch(r.typeId){case W.Decimal:return r.bitWidth/32;case W.Interval:return 1+t.unit;case W.FixedSizeList:return t.listSize;case W.FixedSizeBinary:return t.byteWidth;default:return 1}}class le{visitMany(t,...e){return t.map((i,n)=>this.visit(i,...e.map(s=>s[n])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return wF(this,t,e)}getVisitFnByTypeId(t,e=!0){return Ps(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}}function wF(r,t,e=!0){return typeof t=="number"?Ps(r,t,e):typeof t=="string"&&t in W?Ps(r,W[t],e):t&&t instanceof Et?Ps(r,am(t),e):t!=null&&t.type&&t.type instanceof Et?Ps(r,am(t.type),e):Ps(r,W.NONE,e)}function Ps(r,t,e=!0){let i=null;switch(t){case W.Null:i=r.visitNull;break;case W.Bool:i=r.visitBool;break;case W.Int:i=r.visitInt;break;case W.Int8:i=r.visitInt8||r.visitInt;break;case W.Int16:i=r.visitInt16||r.visitInt;break;case W.Int32:i=r.visitInt32||r.visitInt;break;case W.Int64:i=r.visitInt64||r.visitInt;break;case W.Uint8:i=r.visitUint8||r.visitInt;break;case W.Uint16:i=r.visitUint16||r.visitInt;break;case W.Uint32:i=r.visitUint32||r.visitInt;break;case W.Uint64:i=r.visitUint64||r.visitInt;break;case W.Float:i=r.visitFloat;break;case W.Float16:i=r.visitFloat16||r.visitFloat;break;case W.Float32:i=r.visitFloat32||r.visitFloat;break;case W.Float64:i=r.visitFloat64||r.visitFloat;break;case W.Utf8:i=r.visitUtf8;break;case W.LargeUtf8:i=r.visitLargeUtf8;break;case W.Binary:i=r.visitBinary;break;case W.LargeBinary:i=r.visitLargeBinary;break;case W.FixedSizeBinary:i=r.visitFixedSizeBinary;break;case W.Date:i=r.visitDate;break;case W.DateDay:i=r.visitDateDay||r.visitDate;break;case W.DateMillisecond:i=r.visitDateMillisecond||r.visitDate;break;case W.Timestamp:i=r.visitTimestamp;break;case W.TimestampSecond:i=r.visitTimestampSecond||r.visitTimestamp;break;case W.TimestampMillisecond:i=r.visitTimestampMillisecond||r.visitTimestamp;break;case W.TimestampMicrosecond:i=r.visitTimestampMicrosecond||r.visitTimestamp;break;case W.TimestampNanosecond:i=r.visitTimestampNanosecond||r.visitTimestamp;break;case W.Time:i=r.visitTime;break;case W.TimeSecond:i=r.visitTimeSecond||r.visitTime;break;case W.TimeMillisecond:i=r.visitTimeMillisecond||r.visitTime;break;case W.TimeMicrosecond:i=r.visitTimeMicrosecond||r.visitTime;break;case W.TimeNanosecond:i=r.visitTimeNanosecond||r.visitTime;break;case W.Decimal:i=r.visitDecimal;break;case W.List:i=r.visitList;break;case W.Struct:i=r.visitStruct;break;case W.Union:i=r.visitUnion;break;case W.DenseUnion:i=r.visitDenseUnion||r.visitUnion;break;case W.SparseUnion:i=r.visitSparseUnion||r.visitUnion;break;case W.Dictionary:i=r.visitDictionary;break;case W.Interval:i=r.visitInterval;break;case W.IntervalDayTime:i=r.visitIntervalDayTime||r.visitInterval;break;case W.IntervalYearMonth:i=r.visitIntervalYearMonth||r.visitInterval;break;case W.Duration:i=r.visitDuration;break;case W.DurationSecond:i=r.visitDurationSecond||r.visitDuration;break;case W.DurationMillisecond:i=r.visitDurationMillisecond||r.visitDuration;break;case W.DurationMicrosecond:i=r.visitDurationMicrosecond||r.visitDuration;break;case W.DurationNanosecond:i=r.visitDurationNanosecond||r.visitDuration;break;case W.FixedSizeList:i=r.visitFixedSizeList;break;case W.Map:i=r.visitMap;break}if(typeof i=="function")return i;if(!e)return()=>null;throw new Error(`Unrecognized type '${W[t]}'`)}function am(r){switch(r.typeId){case W.Null:return W.Null;case W.Int:{const{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?W.Int8:W.Uint8;case 16:return e?W.Int16:W.Uint16;case 32:return e?W.Int32:W.Uint32;case 64:return e?W.Int64:W.Uint64}return W.Int}case W.Float:switch(r.precision){case Cr.HALF:return W.Float16;case Cr.SINGLE:return W.Float32;case Cr.DOUBLE:return W.Float64}return W.Float;case W.Binary:return W.Binary;case W.LargeBinary:return W.LargeBinary;case W.Utf8:return W.Utf8;case W.LargeUtf8:return W.LargeUtf8;case W.Bool:return W.Bool;case W.Decimal:return W.Decimal;case W.Time:switch(r.unit){case Jt.SECOND:return W.TimeSecond;case Jt.MILLISECOND:return W.TimeMillisecond;case Jt.MICROSECOND:return W.TimeMicrosecond;case Jt.NANOSECOND:return W.TimeNanosecond}return W.Time;case W.Timestamp:switch(r.unit){case Jt.SECOND:return W.TimestampSecond;case Jt.MILLISECOND:return W.TimestampMillisecond;case Jt.MICROSECOND:return W.TimestampMicrosecond;case Jt.NANOSECOND:return W.TimestampNanosecond}return W.Timestamp;case W.Date:switch(r.unit){case _n.DAY:return W.DateDay;case _n.MILLISECOND:return W.DateMillisecond}return W.Date;case W.Interval:switch(r.unit){case ns.DAY_TIME:return W.IntervalDayTime;case ns.YEAR_MONTH:return W.IntervalYearMonth}return W.Interval;case W.Duration:switch(r.unit){case Jt.SECOND:return W.DurationSecond;case Jt.MILLISECOND:return W.DurationMillisecond;case Jt.MICROSECOND:return W.DurationMicrosecond;case Jt.NANOSECOND:return W.DurationNanosecond}return W.Duration;case W.Map:return W.Map;case W.List:return W.List;case W.Struct:return W.Struct;case W.Union:switch(r.mode){case Ii.Dense:return W.DenseUnion;case Ii.Sparse:return W.SparseUnion}return W.Union;case W.FixedSizeBinary:return W.FixedSizeBinary;case W.FixedSizeList:return W.FixedSizeList;case W.Dictionary:return W.Dictionary}throw new Error(`Unrecognized type '${W[r.typeId]}'`)}le.prototype.visitInt8=null;le.prototype.visitInt16=null;le.prototype.visitInt32=null;le.prototype.visitInt64=null;le.prototype.visitUint8=null;le.prototype.visitUint16=null;le.prototype.visitUint32=null;le.prototype.visitUint64=null;le.prototype.visitFloat16=null;le.prototype.visitFloat32=null;le.prototype.visitFloat64=null;le.prototype.visitDateDay=null;le.prototype.visitDateMillisecond=null;le.prototype.visitTimestampSecond=null;le.prototype.visitTimestampMillisecond=null;le.prototype.visitTimestampMicrosecond=null;le.prototype.visitTimestampNanosecond=null;le.prototype.visitTimeSecond=null;le.prototype.visitTimeMillisecond=null;le.prototype.visitTimeMicrosecond=null;le.prototype.visitTimeNanosecond=null;le.prototype.visitDenseUnion=null;le.prototype.visitSparseUnion=null;le.prototype.visitIntervalDayTime=null;le.prototype.visitIntervalYearMonth=null;le.prototype.visitDuration=null;le.prototype.visitDurationSecond=null;le.prototype.visitDurationMillisecond=null;le.prototype.visitDurationMicrosecond=null;le.prototype.visitDurationNanosecond=null;const ib=new Float64Array(1),vs=new Uint32Array(ib.buffer);function Ff(r){const t=(r&31744)>>10,e=(r&1023)/1024,i=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return i*(e?Number.NaN:1/0);case 0:return i*(e?6103515625e-14*e:0)}return i*Math.pow(2,t-15)*(1+e)}function nb(r){if(r!==r)return 32256;ib[0]=r;const t=(vs[1]&2147483648)>>16&65535;let e=vs[1]&2146435072,i=0;return e>=1089470464?vs[0]>0?e=31744:(e=(e&2080374784)>>16,i=(vs[1]&1048575)>>10):e<=1056964608?(i=1048576+(vs[1]&1048575),i=1048576+(i<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,i=(vs[1]&1048575)+512>>10),t|e|i&65535}const xF=Object.freeze(Object.defineProperty({__proto__:null,float64ToUint16:nb,uint16ToFloat64:Ff},Symbol.toStringTag,{value:"Module"}));class Gt extends le{}function Yt(r){return(t,e,i)=>{if(t.setValid(e,i!=null))return r(t,e,i)}}const SF=(r,t,e)=>{r[t]=Math.floor(e/864e5)},sb=(r,t,e,i)=>{if(e+1{const n=r+e;i?t[n>>3]|=1<>3]&=~(1<{r[t]=e},Pf=({values:r},t,e)=>{r[t]=e},ob=({values:r},t,e)=>{r[t]=nb(e)},IF=(r,t,e)=>{switch(r.type.precision){case Cr.HALF:return ob(r,t,e);case Cr.SINGLE:case Cr.DOUBLE:return Pf(r,t,e)}},ab=({values:r},t,e)=>{SF(r,t,e.valueOf())},lb=({values:r},t,e)=>{r[t]=BigInt(e)},EF=({stride:r,values:t},e,i)=>{t.set(i.subarray(0,r),r*e)},ub=({values:r,valueOffsets:t},e,i)=>sb(r,t,e,i),cb=({values:r,valueOffsets:t},e,i)=>sb(r,t,e,A0(i)),CF=(r,t,e)=>{r.type.unit===_n.DAY?ab(r,t,e):lb(r,t,e)},hb=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},fb=({values:r},t,e)=>{r[t]=BigInt(e)},db=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},pb=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},AF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return hb(r,t,e);case Jt.MILLISECOND:return fb(r,t,e);case Jt.MICROSECOND:return db(r,t,e);case Jt.NANOSECOND:return pb(r,t,e)}},mb=({values:r},t,e)=>{r[t]=e},yb=({values:r},t,e)=>{r[t]=e},gb=({values:r},t,e)=>{r[t]=e},vb=({values:r},t,e)=>{r[t]=e},OF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return mb(r,t,e);case Jt.MILLISECOND:return yb(r,t,e);case Jt.MICROSECOND:return gb(r,t,e);case Jt.NANOSECOND:return vb(r,t,e)}},FF=({values:r,stride:t},e,i)=>{r.set(i.subarray(0,t),t*e)},PF=(r,t,e)=>{const i=r.children[0],n=r.valueOffsets,s=Ei.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=n[t],l=n[t+1];a{const i=r.children[0],{valueOffsets:n}=r,s=Ei.getVisitFn(i);let{[t]:o,[t+1]:a}=n;const l=e instanceof Map?e.entries():Object.entries(e);for(const u of l)if(s(i,o,u),++o>=a)break},DF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[s]),RF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(s)),NF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t.get(n.name)),LF=(r,t)=>(e,i,n,s)=>i&&e(i,r,t[n.name]),BF=(r,t,e)=>{const i=r.type.children.map(s=>Ei.getVisitFn(s.type)),n=e instanceof Map?NF(t,e):e instanceof Qe?RF(t,e):Array.isArray(e)?DF(t,e):LF(t,e);r.type.children.forEach((s,o)=>n(i[o],r.children[o],s,o))},kF=(r,t,e)=>{r.type.mode===Ii.Dense?_b(r,t,e):bb(r,t,e)},_b=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Ei.visit(n,r.valueOffsets[t],e)},bb=(r,t,e)=>{const i=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[i];Ei.visit(n,t,e)},UF=(r,t,e)=>{var i;(i=r.dictionary)===null||i===void 0||i.set(r.values[t],e)},zF=(r,t,e)=>{r.type.unit===ns.DAY_TIME?wb(r,t,e):xb(r,t,e)},wb=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},xb=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Sb=({values:r},t,e)=>{r[t]=e},Tb=({values:r},t,e)=>{r[t]=e},Ib=({values:r},t,e)=>{r[t]=e},Eb=({values:r},t,e)=>{r[t]=e},jF=(r,t,e)=>{switch(r.type.unit){case Jt.SECOND:return Sb(r,t,e);case Jt.MILLISECOND:return Tb(r,t,e);case Jt.MICROSECOND:return Ib(r,t,e);case Jt.NANOSECOND:return Eb(r,t,e)}},$F=(r,t,e)=>{const{stride:i}=r,n=r.children[0],s=Ei.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=t*i;++o`${eo(t)}: ${eo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new VF(this[Zr],this[Hs])}}class VF{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const t=this.childIndex;return te.name)}has(t,e){return t[Zr].type.children.some(i=>i.name===e)}getOwnPropertyDescriptor(t,e){if(t[Zr].type.children.some(i=>i.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Zr].type.children.findIndex(n=>n.name===e);if(i!==-1){const n=Yr.visit(t[Zr].children[i],t[Hs]);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Zr].type.children.findIndex(s=>s.name===e);return n!==-1?(Ei.visit(t[Zr].children[n],t[Hs],i),Reflect.set(t,e,i)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,i):!1}}const WF=new GF;class Lt extends le{}function Wt(r){return(t,e)=>t.getValid(e)?r(t,e):null}const HF=(r,t)=>864e5*r[t],XF=(r,t)=>null,Cb=(r,t,e)=>{if(e+1>=t.length)return null;const i=ar(t[e]),n=ar(t[e+1]);return r.subarray(i,n)},YF=({offset:r,values:t},e)=>{const i=r+e;return(t[i>>3]&1<HF(r,t),Ob=({values:r},t)=>ar(r[t]),xn=({stride:r,values:t},e)=>t[r*e],qF=({stride:r,values:t},e)=>Ff(t[r*e]),Fb=({values:r},t)=>r[t],QF=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Pb=({values:r,valueOffsets:t},e)=>Cb(r,t,e),Mb=({values:r,valueOffsets:t},e)=>{const i=Cb(r,t,e);return i!==null?F2(i):null},KF=({values:r},t)=>r[t],ZF=({type:r,values:t},e)=>r.precision!==Cr.HALF?t[e]:Ff(t[e]),JF=(r,t)=>r.type.unit===_n.DAY?Ab(r,t):Ob(r,t),Db=({values:r},t)=>1e3*ar(r[t]),Rb=({values:r},t)=>ar(r[t]),Nb=({values:r},t)=>P0(r[t],BigInt(1e3)),Lb=({values:r},t)=>P0(r[t],BigInt(1e6)),tP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Db(r,t);case Jt.MILLISECOND:return Rb(r,t);case Jt.MICROSECOND:return Nb(r,t);case Jt.NANOSECOND:return Lb(r,t)}},Bb=({values:r},t)=>r[t],kb=({values:r},t)=>r[t],Ub=({values:r},t)=>r[t],zb=({values:r},t)=>r[t],eP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Bb(r,t);case Jt.MILLISECOND:return kb(r,t);case Jt.MICROSECOND:return Ub(r,t);case Jt.NANOSECOND:return zb(r,t)}},rP=({values:r,stride:t},e)=>su.decimal(r.subarray(t*e,t*(e+1))),iP=(r,t)=>{const{valueOffsets:e,stride:i,children:n}=r,{[t*i]:s,[t*i+1]:o}=e,l=n[0].slice(s,o-s);return new Qe([l])},nP=(r,t)=>{const{valueOffsets:e,children:i}=r,{[t]:n,[t+1]:s}=e,o=i[0];return new Df(o.slice(n,s-n))},sP=(r,t)=>new Mf(r,t),oP=(r,t)=>r.type.mode===Ii.Dense?jb(r,t):$b(r,t),jb=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return Yr.visit(i,r.valueOffsets[t])},$b=(r,t)=>{const e=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[e];return Yr.visit(i,t)},aP=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},lP=(r,t)=>r.type.unit===ns.DAY_TIME?Vb(r,t):Gb(r,t),Vb=({values:r},t)=>r.subarray(2*t,2*(t+1)),Gb=({values:r},t)=>{const e=r[t],i=new Int32Array(2);return i[0]=Math.trunc(e/12),i[1]=Math.trunc(e%12),i},Wb=({values:r},t)=>r[t],Hb=({values:r},t)=>r[t],Xb=({values:r},t)=>r[t],Yb=({values:r},t)=>r[t],uP=(r,t)=>{switch(r.type.unit){case Jt.SECOND:return Wb(r,t);case Jt.MILLISECOND:return Hb(r,t);case Jt.MICROSECOND:return Xb(r,t);case Jt.NANOSECOND:return Yb(r,t)}},cP=(r,t)=>{const{stride:e,children:i}=r,s=i[0].slice(t*e,e);return new Qe([s])};Lt.prototype.visitNull=Wt(XF);Lt.prototype.visitBool=Wt(YF);Lt.prototype.visitInt=Wt(KF);Lt.prototype.visitInt8=Wt(xn);Lt.prototype.visitInt16=Wt(xn);Lt.prototype.visitInt32=Wt(xn);Lt.prototype.visitInt64=Wt(Fb);Lt.prototype.visitUint8=Wt(xn);Lt.prototype.visitUint16=Wt(xn);Lt.prototype.visitUint32=Wt(xn);Lt.prototype.visitUint64=Wt(Fb);Lt.prototype.visitFloat=Wt(ZF);Lt.prototype.visitFloat16=Wt(qF);Lt.prototype.visitFloat32=Wt(xn);Lt.prototype.visitFloat64=Wt(xn);Lt.prototype.visitUtf8=Wt(Mb);Lt.prototype.visitLargeUtf8=Wt(Mb);Lt.prototype.visitBinary=Wt(Pb);Lt.prototype.visitLargeBinary=Wt(Pb);Lt.prototype.visitFixedSizeBinary=Wt(QF);Lt.prototype.visitDate=Wt(JF);Lt.prototype.visitDateDay=Wt(Ab);Lt.prototype.visitDateMillisecond=Wt(Ob);Lt.prototype.visitTimestamp=Wt(tP);Lt.prototype.visitTimestampSecond=Wt(Db);Lt.prototype.visitTimestampMillisecond=Wt(Rb);Lt.prototype.visitTimestampMicrosecond=Wt(Nb);Lt.prototype.visitTimestampNanosecond=Wt(Lb);Lt.prototype.visitTime=Wt(eP);Lt.prototype.visitTimeSecond=Wt(Bb);Lt.prototype.visitTimeMillisecond=Wt(kb);Lt.prototype.visitTimeMicrosecond=Wt(Ub);Lt.prototype.visitTimeNanosecond=Wt(zb);Lt.prototype.visitDecimal=Wt(rP);Lt.prototype.visitList=Wt(iP);Lt.prototype.visitStruct=Wt(sP);Lt.prototype.visitUnion=Wt(oP);Lt.prototype.visitDenseUnion=Wt(jb);Lt.prototype.visitSparseUnion=Wt($b);Lt.prototype.visitDictionary=Wt(aP);Lt.prototype.visitInterval=Wt(lP);Lt.prototype.visitIntervalDayTime=Wt(Vb);Lt.prototype.visitIntervalYearMonth=Wt(Gb);Lt.prototype.visitDuration=Wt(uP);Lt.prototype.visitDurationSecond=Wt(Wb);Lt.prototype.visitDurationMillisecond=Wt(Hb);Lt.prototype.visitDurationMicrosecond=Wt(Xb);Lt.prototype.visitDurationNanosecond=Wt(Yb);Lt.prototype.visitFixedSizeList=Wt(cP);Lt.prototype.visitMap=Wt(nP);const Yr=new Lt,Ms=Symbol.for("keys"),Xs=Symbol.for("vals"),Ds=Symbol.for("kKeysAsStrings"),wh=Symbol.for("_kKeysAsStrings");class Df{constructor(t){return this[Ms]=new Qe([t.children[0]]).memoize(),this[Xs]=t.children[1],new Proxy(this,new fP)}get[Ds](){return this[wh]||(this[wh]=Array.from(this[Ms].toArray(),String))}[Symbol.iterator](){return new hP(this[Ms],this[Xs])}get size(){return this[Ms].length}toArray(){return Object.values(this.toJSON())}toJSON(){const t=this[Ms],e=this[Xs],i={};for(let n=-1,s=t.length;++n`${eo(t)}: ${eo(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class hP{constructor(t,e){this.keys=t,this.vals=e,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),Yr.visit(this.vals,t)]})}}class fP{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ds]}has(t,e){return t[Ds].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Ds].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];const i=t[Ds].indexOf(e);if(i!==-1){const n=Yr.visit(Reflect.get(t,Xs),i);return Reflect.set(t,e,n),n}}set(t,e,i){const n=t[Ds].indexOf(e);return n!==-1?(Ei.visit(Reflect.get(t,Xs),n,i),Reflect.set(t,e,i)):Reflect.has(t,e)?Reflect.set(t,e,i):!1}}Object.defineProperties(Df.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ms]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Xs]:{writable:!0,enumerable:!1,configurable:!1,value:null},[wh]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let lm;function qb(r,t,e,i){const{length:n=0}=r;let s=typeof t!="number"?0:t,o=typeof e!="number"?n:e;return s<0&&(s=(s%n+n)%n),o<0&&(o=(o%n+n)%n),on&&(o=n),i?i(r,s,o):[s,o]}const Qb=(r,t)=>r<0?t+r:r,um=r=>r!==r;function cs(r){if(typeof r!=="object"||r===null)return um(r)?um:e=>e===r;if(r instanceof Date){const e=r.valueOf();return i=>i instanceof Date?i.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?F0(r,e):!1:r instanceof Map?pP(r):Array.isArray(r)?dP(r):r instanceof Qe?mP(r):yP(r,!0)}function dP(r){const t=[];for(let e=-1,i=r.length;++e!1;const i=[];for(let n=-1,s=e.length;++n{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return gP(r,e);case Map:return cm(r,e,e.keys());case Df:case Mf:case Object:case void 0:return cm(r,e,t||Object.keys(e))}return e instanceof Qe?vP(r,e):!1}}function gP(r,t){const e=r.length;if(t.length!==e)return!1;for(let i=-1;++i>i}function bP(r,t,e){return e?!!(r[t>>3]|=1<>3]&=~(1<0||e.byteLength>3):Zb(new au(e,r,t,null,Rf)).subarray(0,i)),n}return e}function Zb(r){const t=[];let e=0,i=0,n=0;for(const o of r)o&&(n|=1<0)&&(t[e++]=n);const s=new Uint8Array(t.length+7&-8);return s.set(t),s}class au{constructor(t,e,i,n,s){this.bytes=t,this.length=i,this.context=n,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index>3<<3,n=t+(t%8===0?0:8-t%8);return Bl(r,t,n)+Bl(r,i,e)+Jb(r,n>>3,i-n>>3)}function Jb(r,t,e){let i=0,n=Math.trunc(t);const s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:n+e;for(;o-n>=4;)i+=qa(s.getUint32(n)),n+=4;for(;o-n>=2;)i+=qa(s.getUint16(n)),n+=2;for(;o-n>=1;)i+=qa(s.getUint8(n)),n+=1;return i}function qa(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}const wP=Object.freeze(Object.defineProperty({__proto__:null,BitIterator:au,getBit:Kb,getBool:Rf,packBools:Zb,popcnt_array:Jb,popcnt_bit_range:Bl,popcnt_uint32:qa,setBool:bP,truncateBitmap:xh},Symbol.toStringTag,{value:"Module"})),xP=-1;class ta{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 Et.isSparseUnion(t)?this.children.some(e=>e.nullable):Et.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0;const{valueOffsets:e,values:i,nullBitmap:n,typeIds:s}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(Et.isUnion(this.type))return this.children.reduce((i,n)=>i+n.nullCount,0);let t=this._nullCount,e;return t<=xP&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Bl(e,this.offset,this.offset+this.length)),t}constructor(t,e,i,n,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(i||0,0)),this._nullCount=Math.floor(Math.max(n||0,-1));let l;s instanceof ta?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=rb(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:e}=this;if(Et.isUnion(e)){const i=e,n=this.children[i.typeIdToChildIndex[this.typeIds[t]]],s=i.mode===Ii.Dense?this.valueOffsets[t]:t;return n.getValid(s)}if(this.nullable&&this.nullCount>0){const i=this.offset+t;return(this.nullBitmap[i>>3]&1<>3;(!s||s.byteLength<=c)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(xh(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));const h=s[c];i=(h&u)!==0,s[c]=e?h|u:h&~u}return i!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,i=this.length,n=this._nullCount,s=this,o=this.children){return new ta(t,e,i,n,s,o,this.dictionary)}slice(t,e){const{stride:i,typeId:n,children:s}=this,o=+(this._nullCount===0)-1,a=n===16?i:1,l=this._sliceBuffers(t,e,i,n);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===W.Null)return this.clone(this.type,0,t,0);const{length:e,nullCount:i}=this,n=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);n[e>>3]=(1<0&&n.set(xh(this.offset,e,this.nullBitmap),0);const s=this.buffers;return s[zi.VALIDITY]=n,this.clone(this.type,0,t,i+(t-e),s)}_sliceBuffers(t,e,i,n){let s;const{buffers:o}=this;return(s=o[zi.TYPE])&&(o[zi.TYPE]=s.subarray(t,t+e)),(s=o[zi.OFFSET])&&(o[zi.OFFSET]=s.subarray(t,t+e+1))||(s=o[zi.DATA])&&(o[zi.DATA]=n===6?s:s.subarray(i*t,i*(t+e))),o}_sliceChildren(t,e,i){return t.map(n=>n.slice(e,i))}}ta.prototype.children=Object.freeze([]);class hm{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndext.nullable)}function TP(r){return r.reduce((t,e)=>t+e.nullCount,0)}function IP(r){return r.reduce((t,e,i)=>(t[i+1]=t[i]+e.length,t),new Uint32Array(r.length+1))}function EP(r,t,e,i){const n=[];for(let s=-1,o=r.length;++s=i)break;if(e>=l+u)continue;if(l>=e&&l+u<=i){n.push(a);continue}const c=Math.max(0,e-l),h=Math.min(i-l,u);n.push(a.slice(c,h-c))}return n.length===0&&n.push(r[0].slice(0,0)),n}function Nf(r,t,e,i){let n=0,s=0,o=t.length-1;do{if(n>=o-1)return e0?0:-1}function FP(r,t){const{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let i=0;for(const n of new au(e,r.offset+(t||0),r.length,e,Rf)){if(!n)return i;++i}return-1}function Kt(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case W.Union:break;case W.Dictionary:break;default:return FP(r,e)}const i=Yr.getVisitFn(r),n=cs(t);for(let s=(e||0)-1,o=r.length;++s{const n=r.data[i];return n.values.subarray(0,n.length)[Symbol.iterator]()});let e=0;return new hm(r.data.length,i=>{const s=r.data[i].length,o=r.slice(e,e+s);return e+=s,new PP(o)})}class PP{constructor(t){this.vector=t,this.index=0}next(){return this.indexa.data):t;if(s.length===0||s.some(a=>!(a instanceof ta)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:u}=iw[o.typeId],c=s[0];this.isValid=h=>tw(c,h),this.get=h=>a(c,h),this.set=(h,p)=>l(c,h,p),this.indexOf=h=>u(c,h),this._offsets=[0,c.length];break}default:Object.setPrototypeOf(this,nw[o.typeId]),this._offsets=IP(s);break}this.data=s,this.type=o,this.stride=rb(o),this.numChildren=(n=(i=o.children)===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return SP(this.data)}get nullCount(){return TP(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${W[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Qb(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return MP.visit(this)}concat(...t){return new Qe(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new Qe(qb(this,t,e,({data:i,_offsets:n},s,o)=>EP(i,n,s,o)))}toJSON(){return[...this]}toArray(){const{type:t,data:e,length:i,stride:n,ArrayType:s}=this;switch(t.typeId){case W.Int:case W.Float:case W.Decimal:case W.Time:case W.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,i*n);default:return e.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*n),o.offset),o.offset+=l*n,o),{array:new s(i*n),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&te[t])):null}get isMemoized(){return Et.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(Et.isDictionary(this.type)){const t=new kl(this.data[0].dictionary),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new Qe(e)}return new kl(this)}unmemoize(){if(Et.isDictionary(this.type)&&this.isMemoized){const t=this.data[0].dictionary.unmemoize(),e=this.data.map(i=>{const n=i.clone();return n.dictionary=t,n});return new Qe(e)}return this}}rw=Symbol.toStringTag;Qe[rw]=(r=>{r.type=Et.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;const t=Object.keys(W).map(e=>W[e]).filter(e=>typeof e=="number"&&e!==W.NONE);for(const e of t){const i=Yr.getVisitFnByTypeId(e),n=Ei.getVisitFnByTypeId(e),s=dm.getVisitFnByTypeId(e);iw[e]={get:i,set:n,indexOf:s},nw[e]=Object.create(r,{isValid:{value:fm(tw)},get:{value:fm(Yr.getVisitFnByTypeId(e))},set:{value:CP(Ei.getVisitFnByTypeId(e))},indexOf:{value:AP(dm.getVisitFnByTypeId(e))}})}return"Vector"})(Qe.prototype);class kl extends Qe{constructor(t){super(t.data);const e=this.get,i=this.set,n=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){i.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new kl(n.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Qe(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}const DP=65536;function Ls(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}const io=8,Lf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];class Bf{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){const e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]);let n=e[3]*i[3];this.buffer[0]=n&65535;let s=n>>>16;return n=e[2]*i[3],s+=n,n=e[3]*i[2]>>>0,s+=n,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){const e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]>>0&&++e[1],e[1]>>0&&++e[2],e[2]>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Ls(this.buffer[3])} ${Ls(this.buffer[2])} ${Ls(this.buffer[1])} ${Ls(this.buffer[0])}`}static multiply(t,e){return new ci(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ci(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ci.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ci.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){const i=t.startsWith("-"),n=t.length,s=new ci(e);for(let o=i?1:0;othis.compareFields(i,e[n]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}}function ur(r,t){return t instanceof r.constructor}function hs(r,t){return r===t||ur(r,t)}function Qi(r,t){return r===t||ur(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function lu(r,t){return r===t||ur(r,t)&&r.precision===t.precision}function NP(r,t){return r===t||ur(r,t)&&r.byteWidth===t.byteWidth}function kf(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function fa(r,t){return r===t||ur(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function da(r,t){return r===t||ur(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function LP(r,t){return r===t||ur(r,t)&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function BP(r,t){return r===t||ur(r,t)&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function Uf(r,t){return r===t||ur(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Ci.compareManyFields(r.children,t.children)}function kP(r,t){return r===t||ur(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ci.visit(r.indices,t.indices)&&Ci.visit(r.dictionary,t.dictionary)}function zf(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function pa(r,t){return r===t||ur(r,t)&&r.unit===t.unit}function UP(r,t){return r===t||ur(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}function zP(r,t){return r===t||ur(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ci.compareManyFields(r.children,t.children)}Ut.prototype.visitNull=hs;Ut.prototype.visitBool=hs;Ut.prototype.visitInt=Qi;Ut.prototype.visitInt8=Qi;Ut.prototype.visitInt16=Qi;Ut.prototype.visitInt32=Qi;Ut.prototype.visitInt64=Qi;Ut.prototype.visitUint8=Qi;Ut.prototype.visitUint16=Qi;Ut.prototype.visitUint32=Qi;Ut.prototype.visitUint64=Qi;Ut.prototype.visitFloat=lu;Ut.prototype.visitFloat16=lu;Ut.prototype.visitFloat32=lu;Ut.prototype.visitFloat64=lu;Ut.prototype.visitUtf8=hs;Ut.prototype.visitLargeUtf8=hs;Ut.prototype.visitBinary=hs;Ut.prototype.visitLargeBinary=hs;Ut.prototype.visitFixedSizeBinary=NP;Ut.prototype.visitDate=kf;Ut.prototype.visitDateDay=kf;Ut.prototype.visitDateMillisecond=kf;Ut.prototype.visitTimestamp=fa;Ut.prototype.visitTimestampSecond=fa;Ut.prototype.visitTimestampMillisecond=fa;Ut.prototype.visitTimestampMicrosecond=fa;Ut.prototype.visitTimestampNanosecond=fa;Ut.prototype.visitTime=da;Ut.prototype.visitTimeSecond=da;Ut.prototype.visitTimeMillisecond=da;Ut.prototype.visitTimeMicrosecond=da;Ut.prototype.visitTimeNanosecond=da;Ut.prototype.visitDecimal=hs;Ut.prototype.visitList=LP;Ut.prototype.visitStruct=BP;Ut.prototype.visitUnion=Uf;Ut.prototype.visitDenseUnion=Uf;Ut.prototype.visitSparseUnion=Uf;Ut.prototype.visitDictionary=kP;Ut.prototype.visitInterval=zf;Ut.prototype.visitIntervalDayTime=zf;Ut.prototype.visitIntervalYearMonth=zf;Ut.prototype.visitDuration=pa;Ut.prototype.visitDurationSecond=pa;Ut.prototype.visitDurationMillisecond=pa;Ut.prototype.visitDurationMicrosecond=pa;Ut.prototype.visitDurationNanosecond=pa;Ut.prototype.visitFixedSizeList=UP;Ut.prototype.visitMap=zP;const Ci=new Ut;function jP(r,t){return Ci.compareSchemas(r,t)}function $P(r,t){return Ci.compareFields(r,t)}function VP(r,t){return Ci.visit(r,t)}const pm=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_F),RP),wP),xF),pF),_P),yF),{compareSchemas:jP,compareFields:$P,compareTypes:VP}),sw=6048e5,GP=864e5,mm=Symbol.for("constructDateFrom");function Gi(r,t){return typeof r=="function"?r(t):r&&typeof r=="object"&&mm in r?r[mm](t):r instanceof Date?new r.constructor(t):new Date(t)}function qr(r,t){return Gi(t||r,r)}let WP={};function uu(){return WP}function ea(r,t){var a,l,u,c;const e=uu(),i=(t==null?void 0:t.weekStartsOn)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.weekStartsOn)??e.weekStartsOn??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.weekStartsOn)??0,n=qr(r,t==null?void 0:t.in),s=n.getDay(),o=(s=s.getTime()?i+1:e.getTime()>=a.getTime()?i:i-1}function ym(r){const t=qr(r),e=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return e.setUTCFullYear(t.getFullYear()),+r-+e}function HP(r,...t){const e=Gi.bind(null,t.find(i=>typeof i=="object"));return t.map(e)}function gm(r,t){const e=qr(r,t==null?void 0:t.in);return e.setHours(0,0,0,0),e}function XP(r,t,e){const[i,n]=HP(e==null?void 0:e.in,r,t),s=gm(i),o=gm(n),a=+s-ym(s),l=+o-ym(o);return Math.round((a-l)/GP)}function YP(r,t){const e=ow(r,t),i=Gi(r,0);return i.setFullYear(e,0,4),i.setHours(0,0,0,0),Ul(i)}function qP(r){return r instanceof Date||typeof r=="object"&&Object.prototype.toString.call(r)==="[object Date]"}function QP(r){return!(!qP(r)&&typeof r!="number"||isNaN(+qr(r)))}function KP(r,t){const e=qr(r,t==null?void 0:t.in);return e.setFullYear(e.getFullYear(),0,1),e.setHours(0,0,0,0),e}const ZP={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},JP=(r,t,e)=>{let i;const n=ZP[r];return typeof n=="string"?i=n:t===1?i=n.one:i=n.other.replace("{{count}}",t.toString()),e!=null&&e.addSuffix?e.comparison&&e.comparison>0?"in "+i:i+" ago":i};function nc(r){return(t={})=>{const e=t.width?String(t.width):r.defaultWidth;return r.formats[e]||r.formats[r.defaultWidth]}}const tM={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},eM={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},rM={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},iM={date:nc({formats:tM,defaultWidth:"full"}),time:nc({formats:eM,defaultWidth:"full"}),dateTime:nc({formats:rM,defaultWidth:"full"})},nM={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},sM=(r,t,e,i)=>nM[r];function go(r){return(t,e)=>{const i=e!=null&&e.context?String(e.context):"standalone";let n;if(i==="formatting"&&r.formattingValues){const o=r.defaultFormattingWidth||r.defaultWidth,a=e!=null&&e.width?String(e.width):o;n=r.formattingValues[a]||r.formattingValues[o]}else{const o=r.defaultWidth,a=e!=null&&e.width?String(e.width):r.defaultWidth;n=r.values[a]||r.values[o]}const s=r.argumentCallback?r.argumentCallback(t):t;return n[s]}}const oM={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},aM={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},lM={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},uM={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},cM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},hM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},fM=(r,t)=>{const e=Number(r),i=e%100;if(i>20||i<10)switch(i%10){case 1:return e+"st";case 2:return e+"nd";case 3:return e+"rd"}return e+"th"},dM={ordinalNumber:fM,era:go({values:oM,defaultWidth:"wide"}),quarter:go({values:aM,defaultWidth:"wide",argumentCallback:r=>r-1}),month:go({values:lM,defaultWidth:"wide"}),day:go({values:uM,defaultWidth:"wide"}),dayPeriod:go({values:cM,defaultWidth:"wide",formattingValues:hM,defaultFormattingWidth:"wide"})};function vo(r){return(t,e={})=>{const i=e.width,n=i&&r.matchPatterns[i]||r.matchPatterns[r.defaultMatchWidth],s=t.match(n);if(!s)return null;const o=s[0],a=i&&r.parsePatterns[i]||r.parsePatterns[r.defaultParseWidth],l=Array.isArray(a)?mM(a,h=>h.test(o)):pM(a,h=>h.test(o));let u;u=r.valueCallback?r.valueCallback(l):l,u=e.valueCallback?e.valueCallback(u):u;const c=t.slice(o.length);return{value:u,rest:c}}}function pM(r,t){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e)&&t(r[e]))return e}function mM(r,t){for(let e=0;e{const i=t.match(r.matchPattern);if(!i)return null;const n=i[0],s=t.match(r.parsePattern);if(!s)return null;let o=r.valueCallback?r.valueCallback(s[0]):s[0];o=e.valueCallback?e.valueCallback(o):o;const a=t.slice(n.length);return{value:o,rest:a}}}const gM=/^(\d+)(th|st|nd|rd)?/i,vM=/\d+/i,_M={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bM={any:[/^b/i,/^(a|c)/i]},wM={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},xM={any:[/1/i,/2/i,/3/i,/4/i]},SM={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},TM={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},IM={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},EM={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},CM={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},AM={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},OM={ordinalNumber:yM({matchPattern:gM,parsePattern:vM,valueCallback:r=>parseInt(r,10)}),era:vo({matchPatterns:_M,defaultMatchWidth:"wide",parsePatterns:bM,defaultParseWidth:"any"}),quarter:vo({matchPatterns:wM,defaultMatchWidth:"wide",parsePatterns:xM,defaultParseWidth:"any",valueCallback:r=>r+1}),month:vo({matchPatterns:SM,defaultMatchWidth:"wide",parsePatterns:TM,defaultParseWidth:"any"}),day:vo({matchPatterns:IM,defaultMatchWidth:"wide",parsePatterns:EM,defaultParseWidth:"any"}),dayPeriod:vo({matchPatterns:CM,defaultMatchWidth:"any",parsePatterns:AM,defaultParseWidth:"any"})},FM={code:"en-US",formatDistance:JP,formatLong:iM,formatRelative:sM,localize:dM,match:OM,options:{weekStartsOn:0,firstWeekContainsDate:1}};function PM(r,t){const e=qr(r,t==null?void 0:t.in);return XP(e,KP(e))+1}function MM(r,t){const e=qr(r,t==null?void 0:t.in),i=+Ul(e)-+YP(e);return Math.round(i/sw)+1}function aw(r,t){var c,h,p,f;const e=qr(r,t==null?void 0:t.in),i=e.getFullYear(),n=uu(),s=(t==null?void 0:t.firstWeekContainsDate)??((h=(c=t==null?void 0:t.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??n.firstWeekContainsDate??((f=(p=n.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??1,o=Gi((t==null?void 0:t.in)||r,0);o.setFullYear(i+1,0,s),o.setHours(0,0,0,0);const a=ea(o,t),l=Gi((t==null?void 0:t.in)||r,0);l.setFullYear(i,0,s),l.setHours(0,0,0,0);const u=ea(l,t);return+e>=+a?i+1:+e>=+u?i:i-1}function DM(r,t){var a,l,u,c;const e=uu(),i=(t==null?void 0:t.firstWeekContainsDate)??((l=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:l.firstWeekContainsDate)??e.firstWeekContainsDate??((c=(u=e.locale)==null?void 0:u.options)==null?void 0:c.firstWeekContainsDate)??1,n=aw(r,t),s=Gi((t==null?void 0:t.in)||r,0);return s.setFullYear(n,0,i),s.setHours(0,0,0,0),ea(s,t)}function RM(r,t){const e=qr(r,t==null?void 0:t.in),i=+ea(e,t)-+DM(e,t);return Math.round(i/sw)+1}function ve(r,t){const e=r<0?"-":"",i=Math.abs(r).toString().padStart(t,"0");return e+i}const rn={y(r,t){const e=r.getFullYear(),i=e>0?e:1-e;return ve(t==="yy"?i%100:i,t.length)},M(r,t){const e=r.getMonth();return t==="M"?String(e+1):ve(e+1,2)},d(r,t){return ve(r.getDate(),t.length)},a(r,t){const e=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.toUpperCase();case"aaa":return e;case"aaaaa":return e[0];case"aaaa":default:return e==="am"?"a.m.":"p.m."}},h(r,t){return ve(r.getHours()%12||12,t.length)},H(r,t){return ve(r.getHours(),t.length)},m(r,t){return ve(r.getMinutes(),t.length)},s(r,t){return ve(r.getSeconds(),t.length)},S(r,t){const e=t.length,i=r.getMilliseconds(),n=Math.trunc(i*Math.pow(10,e-3));return ve(n,t.length)}},_s={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},vm={G:function(r,t,e){const i=r.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return e.era(i,{width:"abbreviated"});case"GGGGG":return e.era(i,{width:"narrow"});case"GGGG":default:return e.era(i,{width:"wide"})}},y:function(r,t,e){if(t==="yo"){const i=r.getFullYear(),n=i>0?i:1-i;return e.ordinalNumber(n,{unit:"year"})}return rn.y(r,t)},Y:function(r,t,e,i){const n=aw(r,i),s=n>0?n:1-n;if(t==="YY"){const o=s%100;return ve(o,2)}return t==="Yo"?e.ordinalNumber(s,{unit:"year"}):ve(s,t.length)},R:function(r,t){const e=ow(r);return ve(e,t.length)},u:function(r,t){const e=r.getFullYear();return ve(e,t.length)},Q:function(r,t,e){const i=Math.ceil((r.getMonth()+1)/3);switch(t){case"Q":return String(i);case"QQ":return ve(i,2);case"Qo":return e.ordinalNumber(i,{unit:"quarter"});case"QQQ":return e.quarter(i,{width:"abbreviated",context:"formatting"});case"QQQQQ":return e.quarter(i,{width:"narrow",context:"formatting"});case"QQQQ":default:return e.quarter(i,{width:"wide",context:"formatting"})}},q:function(r,t,e){const i=Math.ceil((r.getMonth()+1)/3);switch(t){case"q":return String(i);case"qq":return ve(i,2);case"qo":return e.ordinalNumber(i,{unit:"quarter"});case"qqq":return e.quarter(i,{width:"abbreviated",context:"standalone"});case"qqqqq":return e.quarter(i,{width:"narrow",context:"standalone"});case"qqqq":default:return e.quarter(i,{width:"wide",context:"standalone"})}},M:function(r,t,e){const i=r.getMonth();switch(t){case"M":case"MM":return rn.M(r,t);case"Mo":return e.ordinalNumber(i+1,{unit:"month"});case"MMM":return e.month(i,{width:"abbreviated",context:"formatting"});case"MMMMM":return e.month(i,{width:"narrow",context:"formatting"});case"MMMM":default:return e.month(i,{width:"wide",context:"formatting"})}},L:function(r,t,e){const i=r.getMonth();switch(t){case"L":return String(i+1);case"LL":return ve(i+1,2);case"Lo":return e.ordinalNumber(i+1,{unit:"month"});case"LLL":return e.month(i,{width:"abbreviated",context:"standalone"});case"LLLLL":return e.month(i,{width:"narrow",context:"standalone"});case"LLLL":default:return e.month(i,{width:"wide",context:"standalone"})}},w:function(r,t,e,i){const n=RM(r,i);return t==="wo"?e.ordinalNumber(n,{unit:"week"}):ve(n,t.length)},I:function(r,t,e){const i=MM(r);return t==="Io"?e.ordinalNumber(i,{unit:"week"}):ve(i,t.length)},d:function(r,t,e){return t==="do"?e.ordinalNumber(r.getDate(),{unit:"date"}):rn.d(r,t)},D:function(r,t,e){const i=PM(r);return t==="Do"?e.ordinalNumber(i,{unit:"dayOfYear"}):ve(i,t.length)},E:function(r,t,e){const i=r.getDay();switch(t){case"E":case"EE":case"EEE":return e.day(i,{width:"abbreviated",context:"formatting"});case"EEEEE":return e.day(i,{width:"narrow",context:"formatting"});case"EEEEEE":return e.day(i,{width:"short",context:"formatting"});case"EEEE":default:return e.day(i,{width:"wide",context:"formatting"})}},e:function(r,t,e,i){const n=r.getDay(),s=(n-i.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return ve(s,2);case"eo":return e.ordinalNumber(s,{unit:"day"});case"eee":return e.day(n,{width:"abbreviated",context:"formatting"});case"eeeee":return e.day(n,{width:"narrow",context:"formatting"});case"eeeeee":return e.day(n,{width:"short",context:"formatting"});case"eeee":default:return e.day(n,{width:"wide",context:"formatting"})}},c:function(r,t,e,i){const n=r.getDay(),s=(n-i.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return ve(s,t.length);case"co":return e.ordinalNumber(s,{unit:"day"});case"ccc":return e.day(n,{width:"abbreviated",context:"standalone"});case"ccccc":return e.day(n,{width:"narrow",context:"standalone"});case"cccccc":return e.day(n,{width:"short",context:"standalone"});case"cccc":default:return e.day(n,{width:"wide",context:"standalone"})}},i:function(r,t,e){const i=r.getDay(),n=i===0?7:i;switch(t){case"i":return String(n);case"ii":return ve(n,t.length);case"io":return e.ordinalNumber(n,{unit:"day"});case"iii":return e.day(i,{width:"abbreviated",context:"formatting"});case"iiiii":return e.day(i,{width:"narrow",context:"formatting"});case"iiiiii":return e.day(i,{width:"short",context:"formatting"});case"iiii":default:return e.day(i,{width:"wide",context:"formatting"})}},a:function(r,t,e){const n=r.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"aaaa":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(r,t,e){const i=r.getHours();let n;switch(i===12?n=_s.noon:i===0?n=_s.midnight:n=i/12>=1?"pm":"am",t){case"b":case"bb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"bbbb":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(r,t,e){const i=r.getHours();let n;switch(i>=17?n=_s.evening:i>=12?n=_s.afternoon:i>=4?n=_s.morning:n=_s.night,t){case"B":case"BB":case"BBB":return e.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return e.dayPeriod(n,{width:"narrow",context:"formatting"});case"BBBB":default:return e.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(r,t,e){if(t==="ho"){let i=r.getHours()%12;return i===0&&(i=12),e.ordinalNumber(i,{unit:"hour"})}return rn.h(r,t)},H:function(r,t,e){return t==="Ho"?e.ordinalNumber(r.getHours(),{unit:"hour"}):rn.H(r,t)},K:function(r,t,e){const i=r.getHours()%12;return t==="Ko"?e.ordinalNumber(i,{unit:"hour"}):ve(i,t.length)},k:function(r,t,e){let i=r.getHours();return i===0&&(i=24),t==="ko"?e.ordinalNumber(i,{unit:"hour"}):ve(i,t.length)},m:function(r,t,e){return t==="mo"?e.ordinalNumber(r.getMinutes(),{unit:"minute"}):rn.m(r,t)},s:function(r,t,e){return t==="so"?e.ordinalNumber(r.getSeconds(),{unit:"second"}):rn.s(r,t)},S:function(r,t){return rn.S(r,t)},X:function(r,t,e){const i=r.getTimezoneOffset();if(i===0)return"Z";switch(t){case"X":return bm(i);case"XXXX":case"XX":return Vn(i);case"XXXXX":case"XXX":default:return Vn(i,":")}},x:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"x":return bm(i);case"xxxx":case"xx":return Vn(i);case"xxxxx":case"xxx":default:return Vn(i,":")}},O:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+_m(i,":");case"OOOO":default:return"GMT"+Vn(i,":")}},z:function(r,t,e){const i=r.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+_m(i,":");case"zzzz":default:return"GMT"+Vn(i,":")}},t:function(r,t,e){const i=Math.trunc(+r/1e3);return ve(i,t.length)},T:function(r,t,e){return ve(+r,t.length)}};function _m(r,t=""){const e=r>0?"-":"+",i=Math.abs(r),n=Math.trunc(i/60),s=i%60;return s===0?e+String(n):e+String(n)+t+ve(s,2)}function bm(r,t){return r%60===0?(r>0?"-":"+")+ve(Math.abs(r)/60,2):Vn(r,t)}function Vn(r,t=""){const e=r>0?"-":"+",i=Math.abs(r),n=ve(Math.trunc(i/60),2),s=ve(i%60,2);return e+n+t+s}const wm=(r,t)=>{switch(r){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},lw=(r,t)=>{switch(r){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},NM=(r,t)=>{const e=r.match(/(P+)(p+)?/)||[],i=e[1],n=e[2];if(!n)return wm(r,t);let s;switch(i){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",wm(i,t)).replace("{{time}}",lw(n,t))},LM={p:lw,P:NM},BM=/^D+$/,kM=/^Y+$/,UM=["D","DD","YY","YYYY"];function zM(r){return BM.test(r)}function jM(r){return kM.test(r)}function $M(r,t,e){const i=VM(r,t,e);if(console.warn(i),UM.includes(r))throw new RangeError(i)}function VM(r,t,e){const i=r[0]==="Y"?"years":"days of the month";return`Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${t}\`) for formatting ${i} to the input \`${e}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const GM=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,WM=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,HM=/^'([^]*?)'?$/,XM=/''/g,YM=/[a-zA-Z]/;function uw(r,t,e){var c,h,p,f;const i=uu(),n=i.locale??FM,s=i.firstWeekContainsDate??((h=(c=i.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??1,o=i.weekStartsOn??((f=(p=i.locale)==null?void 0:p.options)==null?void 0:f.weekStartsOn)??0,a=qr(r,e==null?void 0:e.in);if(!QP(a))throw new RangeError("Invalid time value");let l=t.match(WM).map(y=>{const g=y[0];if(g==="p"||g==="P"){const d=LM[g];return d(y,n.formatLong)}return y}).join("").match(GM).map(y=>{if(y==="''")return{isToken:!1,value:"'"};const g=y[0];if(g==="'")return{isToken:!1,value:qM(y)};if(vm[g])return{isToken:!0,value:y};if(g.match(YM))throw new RangeError("Format string contains an unescaped latin alphabet character `"+g+"`");return{isToken:!1,value:y}});n.localize.preprocessor&&(l=n.localize.preprocessor(a,l));const u={firstWeekContainsDate:s,weekStartsOn:o,locale:n};return l.map(y=>{if(!y.isToken)return y.value;const g=y.value;(jM(g)||zM(g))&&$M(g,t,String(r));const d=vm[g[0]];return d(a,g,n.localize,u)}).join("")}function qM(r){const t=r.match(HM);return t?t[1].replace(XM,"'"):r}function QM(r,t){return qr(r*1e3,t==null?void 0:t.in)}function KM(r,t){const e=ZM(t)?new t(0):Gi(t,0);return e.setFullYear(r.getFullYear(),r.getMonth(),r.getDate()),e.setHours(r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()),e}function ZM(r){var t;return typeof r=="function"&&((t=r.prototype)==null?void 0:t.constructor)===r}function JM(r,t){let e=r.length;switch("string"){case"string":{if(t.length!==1)throw new Error("The 'chars' parameter should be a single character string.");for(;e>0&&r[e-1]===t;)e--;break}}return r.substring(0,e)}function gr(r){return r==null}function tD(r){return r!=null}async function Sh(){if(typeof window<"u"&&window!==null)return"browser";try{const r=await ln(()=>import("./__vite-browser-external-FmFgRqLi.js"),[]);return typeof r<"u"&&r.versions!=null&&r.versions.node!=null?"node":"unknown"}catch{return"unknown"}}function eD(r){return gr(r)?!1:Et.isInt(r.type)&&!cw(r)||rD(r)}function rD(r){return gr(r)?!1:Et.isInt(r.type)&&r.type.isSigned===!1}function iD(r){return gr(r)?!1:Et.isFloat(r.type)??!1}function nD(r){return gr(r)?!1:Et.isDecimal(r.type)}function sD(r){return gr(r)?!1:Et.isBool(r.type)}function oD(r){return gr(r)?!1:Et.isDuration(r.type)}function cw(r){return gr(r)?!1:Et.isInt(r.type)&&r.metadata.get("ARROW:extension:name")==="period"}function aD(r){return gr(r)?!1:Et.isTimestamp(r.type)}function lD(r){return gr(r)?!1:Et.isDate(r.type)}function uD(r){return gr(r)?!1:Et.isTime(r.type)}function cD(r){return gr(r)?!1:Et.isList(r.type)||Et.isFixedSizeList(r.type)}function hD(r){return gr(r)?!1:Et.isStruct(r.type)||Et.isMap(r.type)}function fD(r){return gr(r)?!1:Et.isStruct(r.type)&&r.metadata.get("ARROW:extension:name")==="interval"||Et.isInterval(r.type)}function dD(r,t){let e;if(t===Jt.MILLISECOND)e=1e3;else if(t===Jt.MICROSECOND)e=1e3*1e3;else if(t===Jt.NANOSECOND)e=1e3*1e3*1e3;else return Number(r);return typeof r=="bigint"&&!Number.isSafeInteger(Number(r))?Number(r/BigInt(e)):Number(r)/e}function pD(r,t){var i;const e=dD(r,((i=t==null?void 0:t.type)==null?void 0:i.unit)??Jt.SECOND);return QM(e)}function mD(r,t){const e=pD(r,t);return uw(e,e.getMilliseconds()===0?"HH:mm:ss":"HH:mm:ss.SSS")}function yD(r){const t="yyyy-MM-dd";return r instanceof Date||typeof r=="number"&&Number.isFinite(r)?uw(r,t):(console.warn(`Unsupported date value: ${r}`),String(r))}function gD(r,t){var n;if(!(r instanceof Date||typeof r=="number"&&Number.isFinite(r)))return console.warn(`Unsupported datetime value: ${r}`),null;let e;const i=(n=t==null?void 0:t.type)==null?void 0:n.timezone;return typeof r=="number"?i?e=new Er(r,i):e=new Er(r):i?e=new Er(r,i):e=new Er(r),KM(e,Date)}function vD(r,t){var a;const e=((a=t==null?void 0:t.type)==null?void 0:a.scale)||0;let i=pm.bigNumToString(new pm.BN(r)).padStart(e,"0");if(e===0)return i;let n="";i.startsWith("-")&&(n="-",i=i.slice(1));const s=i.slice(0,-e)||"0",o=JM(i.slice(-e),"0")||"";return`${n}${s}${o?`.${o}`:""}`}function _D(r){const t=r[0],e=r[1],i=[];return t!==0&&i.push(`${t} year${t>1?"s":""}`),e!==0&&i.push(`${e} month${e>1?"s":""}`),i.length?i.join(" "):"0 months"}function bD(r,t){var i,n,s,o;if(Et.isInterval(t==null?void 0:t.type))return _D(r);const e=t&&t.metadata.get("ARROW:extension:name");if(e&&e==="pandas.interval"){const a=JSON.parse(t.metadata.get("ARROW:extension:metadata")),{closed:l}=a,u=r.toJSON(),c=l==="both"||l==="left"?"[":"(",h=l==="both"||l==="right"?"]":")",p=Th(u.left,(n=(i=t.type)==null?void 0:i.children)==null?void 0:n[0]),f=Th(u.right,(o=(s=t.type)==null?void 0:s.children)==null?void 0:o[1]);return`${c+p}, ${f+h}`}return String(r)}function wD(r,t){return(t==null?void 0:t.type)instanceof bh?JSON.parse(JSON.stringify(r,(e,i)=>{if(tD(i))return typeof i=="bigint"?Number(i):i})):JSON.parse(JSON.stringify(r,(e,i)=>typeof i=="bigint"?Number(i):i))}function Th(r,t){if(gr(r))return null;const e=r instanceof Date||Number.isFinite(r);if(e&&lD(t))return yD(r);if(typeof r=="bigint"&&uD(t))return mD(Number(r),t);if(e&&aD(t))return gD(r,t);if(cw(t))throw new Error("Period type is not supported yet");if(fD(t))return bD(r,t);if(oD(t))throw new Error("Duration type is not supported yet");return nD(t)?vD(r,t):iD(t)&&Number.isFinite(r)||eD(t)?r:hD(t)||cD(t)?wD(r,t):sD(t)?!!r:String(r)}function xm(r){return((r.toArray()||[]).map(i=>i.toJSON())||[]).map(i=>(r.schema.fields.forEach(n=>i[n.name]=Th(i[n.name],n)),i))}var ra=(r=>(r.ORIGIN_PRIVATE_FS="origin-private-fs",r.NODE_FS="node-fs",r))(ra||{});async function hw(r){const t=Cx(r,{logger:!1});let e,i;const n=await Sh();if(n==="browser"){if(typeof t.bundles>"u"){const{getBundles:l}=await ln(async()=>{const{getBundles:u}=await import("./default-browser-BrgSDbLD.js");return{getBundles:u}},[]);t.bundles=await l()}i=await kp(await t.bundles),e=new Worker(i.mainWorker)}else if(n==="node"){if(typeof t.bundles>"u"){const{getBundles:c}=await ln(async()=>{const{getBundles:h}=await import("./default-node-E6uRkI3P.js");return{getBundles:h}},__vite__mapDeps([0,1,2]));t.bundles=await c()}i=await kp(await t.bundles);let l=i.mainWorker;l.startsWith("/@fs/")&&(l=l.replace("/@fs/","file://"));const u=await ln(()=>import("./index-Cp8iQ_hy.js"),[]);e=new u.default(l,{type:"module"})}else throw new Error(`Unsupported environment: ${n}`);let s;t.logger===!0?s=new I0:t.logger===!1?s=new c2:s=t.logger;const o=new g2(s,e);if(await o.instantiate(i.mainModule,i.pthreadWorker),t.storage)switch(t.storage.type){case ra.ORIGIN_PRIVATE_FS:{try{let l=t.storage.path;l.startsWith("/")&&(l=l.slice(1)),await o.open({path:`opfs://${l}`,accessMode:t.storage.accessMode})}catch(l){throw await o.terminate(),await e.terminate(),l}break}case ra.NODE_FS:{try{await o.open({path:t.storage.path,accessMode:t.storage.accessMode,useDirectIO:!0})}catch(l){throw await o.terminate(),await e.terminate(),l}break}}const a=await o.connect();return{worker:e,db:o,conn:a,query:async(l,u=[])=>{if(!u||u.length===0){const f=await a.query(l);return xm(f)}const c=await a.prepare(l),h=await c.query(...u),p=xm(h);return c.close(),p},close:async()=>{await a.close(),await o.terminate(),await e.terminate()}}}async function xD(r,t){await(await r).conn.send("BEGIN TRANSACTION");try{const e=await t(r);return await(await r).conn.send("COMMIT"),e}catch(e){throw await(await r).conn.send("ROLLBACK"),e}}async function SD(r,t,e){await(await r).conn.send(`SAVEPOINT ${t}`);try{const i=await e(r);return await(await r).conn.send(`RELEASE SAVEPOINT ${t}`),i}catch(i){throw await(await r).conn.send(`ROLLBACK TO SAVEPOINT ${t}`),i}}const xt=Symbol.for("drizzle:entityKind");function lt(r,t){if(!r||typeof r!="object")return!1;if(r instanceof t)return!0;if(!Object.prototype.hasOwnProperty.call(t,xt))throw new Error(`Class "${t.name??""}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);let e=Object.getPrototypeOf(r).constructor;if(e)for(;e;){if(xt in e&&e[xt]===t[xt])return!0;e=Object.getPrototypeOf(e)}return!1}var Mm;Mm=xt;class Ke{constructor(t,e){G(this,"name");G(this,"keyAsName");G(this,"primary");G(this,"notNull");G(this,"default");G(this,"defaultFn");G(this,"onUpdateFn");G(this,"hasDefault");G(this,"isUnique");G(this,"uniqueName");G(this,"uniqueType");G(this,"dataType");G(this,"columnType");G(this,"enumValues");G(this,"generated");G(this,"generatedIdentity");G(this,"config");this.table=t,this.config=e,this.name=e.name,this.keyAsName=e.keyAsName,this.notNull=e.notNull,this.default=e.default,this.defaultFn=e.defaultFn,this.onUpdateFn=e.onUpdateFn,this.hasDefault=e.hasDefault,this.primary=e.primaryKey,this.isUnique=e.isUnique,this.uniqueName=e.uniqueName,this.uniqueType=e.uniqueType,this.dataType=e.dataType,this.columnType=e.columnType,this.generated=e.generated,this.generatedIdentity=e.generatedIdentity}mapFromDriverValue(t){return t}mapToDriverValue(t){return t}shouldDisableInsert(){return this.config.generated!==void 0&&this.config.generated.type!=="byDefault"}}G(Ke,Mm,"Column");const Ys=Symbol.for("drizzle:Name");function TD(r,t){return`${r[Ys]}_${t.join("_")}_unique`}var Dm,Rm;class Ar extends(Rm=Ke,Dm=xt,Rm){constructor(t,e){e.uniqueName||(e.uniqueName=TD(t,[e.name])),super(t,e),this.table=t}}G(Ar,Dm,"PgColumn");const Sm=Symbol.for("drizzle:isPgEnum");function ID(r){return!!r&&typeof r=="function"&&Sm in r&&r[Sm]===!0}var Nm;Nm=xt;class Or{constructor(t,e,i,n=!1){this._={brand:"Subquery",sql:t,selectedFields:e,alias:i,isWith:n}}}G(Or,Nm,"Subquery");var Lm,Bm;class jf extends(Bm=Or,Lm=xt,Bm){}G(jf,Lm,"WithSubquery");const Pr={startActiveSpan(r,t){return t()}},He=Symbol.for("drizzle:ViewBaseConfig"),Qa=Symbol.for("drizzle:Schema"),Ih=Symbol.for("drizzle:Columns"),Tm=Symbol.for("drizzle:ExtraConfigColumns"),sc=Symbol.for("drizzle:OriginalName"),oc=Symbol.for("drizzle:BaseName"),zl=Symbol.for("drizzle:IsAlias"),Im=Symbol.for("drizzle:ExtraConfigBuilder"),ED=Symbol.for("drizzle:IsDrizzleTable");var km,Um,zm,jm,$m,Vm,Gm,Wm,Hm,Xm;Xm=xt,Hm=Ys,Wm=sc,Gm=Qa,Vm=Ih,$m=Tm,jm=oc,zm=zl,Um=ED,km=Im;class Tt{constructor(t,e,i){G(this,Hm);G(this,Wm);G(this,Gm);G(this,Vm);G(this,$m);G(this,jm);G(this,zm,!1);G(this,Um,!0);G(this,km);this[Ys]=this[sc]=t,this[Qa]=e,this[oc]=i}}G(Tt,Xm,"Table"),G(Tt,"Symbol",{Name:Ys,Schema:Qa,OriginalName:sc,Columns:Ih,ExtraConfigColumns:Tm,BaseName:oc,IsAlias:zl,ExtraConfigBuilder:Im});function qn(r){return r[Ys]}function ia(r){return`${r[Qa]??"public"}.${r[Ys]}`}function fw(r){return r!=null&&typeof r.getSQL=="function"}function CD(r){var e;const t={sql:"",params:[]};for(const i of r)t.sql+=i.sql,t.params.push(...i.params),(e=i.typings)!=null&&e.length&&(t.typings||(t.typings=[]),t.typings.push(...i.typings));return t}var Ym;Ym=xt;class Xe{constructor(t){G(this,"value");this.value=Array.isArray(t)?t:[t]}getSQL(){return new Ft([this])}}G(Xe,Ym,"StringChunk");var qm;qm=xt;const Hn=class Hn{constructor(t){G(this,"decoder",dw);G(this,"shouldInlineParams",!1);this.queryChunks=t}append(t){return this.queryChunks.push(...t.queryChunks),this}toQuery(t){return Pr.startActiveSpan("drizzle.buildSQL",e=>{const i=this.buildQueryFromSourceParams(this.queryChunks,t);return e==null||e.setAttributes({"drizzle.query.text":i.sql,"drizzle.query.params":JSON.stringify(i.params)}),i})}buildQueryFromSourceParams(t,e){const i=Object.assign({},e,{inlineParams:e.inlineParams||this.shouldInlineParams,paramStartIndex:e.paramStartIndex||{value:0}}),{casing:n,escapeName:s,escapeParam:o,prepareTyping:a,inlineParams:l,paramStartIndex:u}=i;return CD(t.map(c=>{var h;if(lt(c,Xe))return{sql:c.value.join(""),params:[]};if(lt(c,jl))return{sql:s(c.value),params:[]};if(c===void 0)return{sql:"",params:[]};if(Array.isArray(c)){const p=[new Xe("(")];for(const[f,y]of c.entries())p.push(y),fr},pw={mapToDriverValue:r=>r};({...dw,...pw});var Km;Km=xt;class Wi{constructor(t,e=pw){G(this,"brand");this.value=t,this.encoder=e}getSQL(){return new Ft([this])}}G(Wi,Km,"Param");function X(r,...t){const e=[];(t.length>0||r.length>0&&r[0]!=="")&&e.push(new Xe(r[0]));for(const[i,n]of t.entries())e.push(n,new Xe(r[i+1]));return new Ft(e)}(r=>{function t(){return new Ft([])}r.empty=t;function e(l){return new Ft(l)}r.fromList=e;function i(l){return new Ft([new Xe(l)])}r.raw=i;function n(l,u){const c=[];for(const[h,p]of l.entries())h>0&&u!==void 0&&c.push(u),c.push(p);return new Ft(c)}r.join=n;function s(l){return new jl(l)}r.identifier=s;function o(l){return new ss(l)}r.placeholder=o;function a(l,u){return new Wi(l,u)}r.param=a})(X||(X={}));(r=>{var e;e=xt;const i=class i{constructor(s,o){G(this,"isSelectionField",!1);this.sql=s,this.fieldAlias=o}getSQL(){return this.sql}clone(){return new i(this.sql,this.fieldAlias)}};G(i,e,"SQL.Aliased");let t=i;r.Aliased=t})(Ft||(Ft={}));var Zm;Zm=xt;class ss{constructor(t){this.name=t}getSQL(){return new Ft([this])}}G(ss,Zm,"Placeholder");function Em(r,t){return r.map(e=>{if(lt(e,ss)){if(!(e.name in t))throw new Error(`No value for placeholder "${e.name}" was provided`);return t[e.name]}if(lt(e,Wi)&<(e.value,ss)){if(!(e.value.name in t))throw new Error(`No value for placeholder "${e.value.name}" was provided`);return e.encoder.mapToDriverValue(t[e.value.name])}return e})}const OD=Symbol.for("drizzle:IsDrizzleView");var Jm,ty,ey;ey=xt,ty=He,Jm=OD;class Sn{constructor({name:t,schema:e,selectedFields:i,query:n}){G(this,ty);G(this,Jm,!0);this[He]={name:t,originalName:t,schema:e,selectedFields:i,query:n,isExisting:!n,isAlias:!1}}getSQL(){return new Ft([this])}}G(Sn,ey,"View");Ke.prototype.getSQL=function(){return new Ft([this])};Tt.prototype.getSQL=function(){return new Ft([this])};Or.prototype.getSQL=function(){return new Ft([this])};var ry;ry=xt;class na{constructor(t){this.table=t}get(t,e){return e==="table"?this.table:t[e]}}G(na,ry,"ColumnAliasProxyHandler");var iy;iy=xt;class cu{constructor(t,e){this.alias=t,this.replaceOriginalName=e}get(t,e){if(e===Tt.Symbol.IsAlias)return!0;if(e===Tt.Symbol.Name)return this.alias;if(this.replaceOriginalName&&e===Tt.Symbol.OriginalName)return this.alias;if(e===He)return{...t[He],name:this.alias,isAlias:!0};if(e===Tt.Symbol.Columns){const n=t[Tt.Symbol.Columns];if(!n)return n;const s={};return Object.keys(n).map(o=>{s[o]=new Proxy(n[o],new na(new Proxy(t,this)))}),s}const i=t[e];return lt(i,Ke)?new Proxy(i,new na(new Proxy(t,this))):i}}G(cu,iy,"TableAliasProxyHandler");function ac(r,t){return new Proxy(r,new cu(t,!1))}function Li(r,t){return new Proxy(r,new na(new Proxy(r.table,new cu(t,!1))))}function mw(r,t){return new Ft.Aliased($l(r.sql,t),r.fieldAlias)}function $l(r,t){return X.join(r.queryChunks.map(e=>lt(e,Ke)?Li(e,t):lt(e,Ft)?$l(e,t):lt(e,Ft.Aliased)?mw(e,t):e))}var ny,sy;class $f extends(sy=Error,ny=xt,sy){constructor({message:t,cause:e}){super(t),this.name="DrizzleError",this.cause=e}}G($f,ny,"DrizzleError");var oy,ay;class yw extends(ay=$f,oy=xt,ay){constructor(){super({message:"Rollback"})}}G(yw,oy,"TransactionRollbackError");function yr(r,t){return AD(t)&&!fw(r)&&!lt(r,Wi)&&!lt(r,ss)&&!lt(r,Ke)&&!lt(r,Tt)&&!lt(r,Sn)?new Wi(r,t):r}const gw=(r,t)=>X`${r} = ${yr(t,r)}`,FD=(r,t)=>X`${r} <> ${yr(t,r)}`;function Eh(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Ft(t):new Ft([new Xe("("),X.join(t,new Xe(" and ")),new Xe(")")])}function PD(...r){const t=r.filter(e=>e!==void 0);if(t.length!==0)return t.length===1?new Ft(t):new Ft([new Xe("("),X.join(t,new Xe(" or ")),new Xe(")")])}function MD(r){return X`not ${r}`}const DD=(r,t)=>X`${r} > ${yr(t,r)}`,RD=(r,t)=>X`${r} >= ${yr(t,r)}`,ND=(r,t)=>X`${r} < ${yr(t,r)}`,LD=(r,t)=>X`${r} <= ${yr(t,r)}`;function BD(r,t){return Array.isArray(t)?t.length===0?X`false`:X`${r} in ${t.map(e=>yr(e,r))}`:X`${r} in ${yr(t,r)}`}function kD(r,t){return Array.isArray(t)?t.length===0?X`true`:X`${r} not in ${t.map(e=>yr(e,r))}`:X`${r} not in ${yr(t,r)}`}function UD(r){return X`${r} is null`}function zD(r){return X`${r} is not null`}function jD(r){return X`exists ${r}`}function $D(r){return X`not exists ${r}`}function VD(r,t,e){return X`${r} between ${yr(t,r)} and ${yr(e,r)}`}function GD(r,t,e){return X`${r} not between ${yr(t,r)} and ${yr(e,r)}`}function WD(r,t){return X`${r} like ${t}`}function HD(r,t){return X`${r} not like ${t}`}function XD(r,t){return X`${r} ilike ${t}`}function YD(r,t){return X`${r} not ilike ${t}`}function qD(r){return X`${r} asc`}function QD(r){return X`${r} desc`}var ly;ly=xt;class vw{write(t){console.log(t)}}G(vw,ly,"ConsoleLogWriter");var uy;uy=xt;class _w{constructor(t){G(this,"writer");this.writer=(t==null?void 0:t.writer)??new vw}logQuery(t,e){const i=e.map(s=>{try{return JSON.stringify(s)}catch{return String(s)}}),n=i.length?` -- params: [${i.join(", ")}]`:"";this.writer.write(`Query: ${t}${n}`)}}G(_w,uy,"DefaultLogger");var cy;cy=xt;class bw{logQuery(){}}G(bw,cy,"NoopLogger");var hy,fy;fy=xt,hy=Symbol.toStringTag;class Tn{constructor(){G(this,hy,"QueryPromise")}catch(t){return this.then(void 0,t)}finally(t){return this.then(e=>(t==null||t(),e),e=>{throw t==null||t(),e})}then(t,e){return this.execute().then(t,e)}}G(Tn,fy,"QueryPromise");function os(r,t){return Object.entries(r).reduce((e,[i,n])=>{if(typeof i!="string")return e;const s=t?[...t,i]:[i];return lt(n,Ke)||lt(n,Ft)||lt(n,Ft.Aliased)?e.push({path:s,field:n}):lt(n,Tt)?e.push(...os(n[Tt.Symbol.Columns],s)):e.push(...os(n,s)),e},[])}function Vf(r,t){const e=Object.keys(r),i=Object.keys(t);if(e.length!==i.length)return!1;for(const[n,s]of e.entries())if(s!==i[n])return!1;return!0}function ww(r,t){const e=Object.entries(t).filter(([,i])=>i!==void 0).map(([i,n])=>lt(n,Ft)||lt(n,Ke)?[i,n]:[i,new Wi(n,r[Tt.Symbol.Columns][i])]);if(e.length===0)throw new Error("No values to set");return Object.fromEntries(e)}function KD(r,t){for(const e of t)for(const i of Object.getOwnPropertyNames(e.prototype))i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))}function ZD(r){return r[Tt.Symbol.Columns]}function Wn(r){return lt(r,Or)?r._.alias:lt(r,Sn)?r[He].name:lt(r,Ft)?void 0:r[Tt.Symbol.IsAlias]?r[Tt.Symbol.Name]:r[Tt.Symbol.BaseName]}function JD(r){if(typeof r!="object"||r===null||r.constructor.name!=="Object")return!1;if("logger"in r){const t=typeof r.logger;return!(t!=="boolean"&&(t!=="object"||typeof r.logger.logQuery!="function")&&t!=="undefined")}if("schema"in r){const t=typeof r.schema;return!(t!=="object"&&t!=="undefined")}if("casing"in r){const t=typeof r.casing;return!(t!=="string"&&t!=="undefined")}if("mode"in r)return!(r.mode!=="default"||r.mode!=="planetscale"||r.mode!==void 0);if("connection"in r){const t=typeof r.connection;return!(t!=="string"&&t!=="object"&&t!=="undefined")}if("client"in r){const t=typeof r.client;return!(t!=="object"&&t!=="function"&&t!=="undefined")}return Object.keys(r).length===0}var dy,py;class xw extends(py=Ar,dy=xt,py){getSQLType(){return"date"}mapFromDriverValue(t){return new Date(t)}mapToDriverValue(t){return t.toISOString()}}G(xw,dy,"PgDate");var my,yy;class Sw extends(yy=Ar,my=xt,yy){getSQLType(){return"date"}}G(Sw,my,"PgDateString");var gy,vy;class Tw extends(vy=Ar,gy=xt,vy){constructor(t,e){super(t,e)}getSQLType(){return"json"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}G(Tw,gy,"PgJson");var _y,by;class Iw extends(by=Ar,_y=xt,by){constructor(t,e){super(t,e)}getSQLType(){return"jsonb"}mapToDriverValue(t){return JSON.stringify(t)}mapFromDriverValue(t){if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t}}G(Iw,_y,"PgJsonb");var wy,xy;class Ew extends(xy=Ar,wy=xt,xy){constructor(e,i){super(e,i);G(this,"precision");G(this,"scale");this.precision=i.precision,this.scale=i.scale}mapFromDriverValue(e){return typeof e=="string"?e:String(e)}getSQLType(){return this.precision!==void 0&&this.scale!==void 0?`numeric(${this.precision}, ${this.scale})`:this.precision===void 0?"numeric":`numeric(${this.precision})`}}G(Ew,wy,"PgNumeric");var Sy,Ty;class Cw extends(Ty=Ar,Sy=xt,Ty){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`time${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Cw,Sy,"PgTime");var Iy,Ey;class Aw extends(Ey=Ar,Iy=xt,Ey){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");G(this,"mapFromDriverValue",e=>new Date(this.withTimezone?e:e+"+0000"));G(this,"mapToDriverValue",e=>e.toISOString());this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`timestamp${this.precision===void 0?"":` (${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Aw,Iy,"PgTimestamp");var Cy,Ay;class Ow extends(Ay=Ar,Cy=xt,Ay){constructor(e,i){super(e,i);G(this,"withTimezone");G(this,"precision");this.withTimezone=i.withTimezone,this.precision=i.precision}getSQLType(){return`timestamp${this.precision===void 0?"":`(${this.precision})`}${this.withTimezone?" with time zone":""}`}}G(Ow,Cy,"PgTimestampString");var Oy,Fy;class Fw extends(Fy=Ar,Oy=xt,Fy){getSQLType(){return"uuid"}}G(Fw,Oy,"PgUUID");const Cm=Symbol.for("drizzle:PgInlineForeignKeys"),Am=Symbol.for("drizzle:EnableRLS");var Py,My,Dy,Ry,Ny,Ly;class Br extends(Ly=Tt,Ny=xt,Ry=Cm,Dy=Am,My=Tt.Symbol.ExtraConfigBuilder,Py=Tt.Symbol.ExtraConfigColumns,Ly){constructor(){super(...arguments);G(this,Ry,[]);G(this,Dy,!1);G(this,My);G(this,Py,{})}}G(Br,Ny,"PgTable"),G(Br,"Symbol",Object.assign({},Tt.Symbol,{InlineForeignKeys:Cm,EnableRLS:Am}));var By;By=xt;class Pw{constructor(t,e){G(this,"columns");G(this,"name");this.columns=t,this.name=e}build(t){return new Mw(t,this.columns,this.name)}}G(Pw,By,"PgPrimaryKeyBuilder");var ky;ky=xt;class Mw{constructor(t,e,i){G(this,"columns");G(this,"name");this.table=t,this.columns=e,this.name=i}getName(){return this.name??`${this.table[Br.Symbol.Name]}_${this.columns.map(t=>t.name).join("_")}_pk`}}G(Mw,ky,"PgPrimaryKey");var Uy;Uy=xt;class Gf{constructor(t,e,i){G(this,"referencedTableName");G(this,"fieldName");this.sourceTable=t,this.referencedTable=e,this.relationName=i,this.referencedTableName=e[Tt.Symbol.Name]}}G(Gf,Uy,"Relation");var zy;zy=xt;class Dw{constructor(t,e){this.table=t,this.config=e}}G(Dw,zy,"Relations");var jy,$y;const Wl=class Wl extends($y=Gf,jy=xt,$y){constructor(t,e,i,n){super(t,e,i==null?void 0:i.relationName),this.config=i,this.isNullable=n}withFieldName(t){const e=new Wl(this.sourceTable,this.referencedTable,this.config,this.isNullable);return e.fieldName=t,e}};G(Wl,jy,"One");let as=Wl;var Vy,Gy;const Hl=class Hl extends(Gy=Gf,Vy=xt,Gy){constructor(t,e,i){super(t,e,i==null?void 0:i.relationName),this.config=i}withFieldName(t){const e=new Hl(this.sourceTable,this.referencedTable,this.config);return e.fieldName=t,e}};G(Hl,Vy,"Many");let Vl=Hl;function tR(){return{and:Eh,between:VD,eq:gw,exists:jD,gt:DD,gte:RD,ilike:XD,inArray:BD,isNull:UD,isNotNull:zD,like:WD,lt:ND,lte:LD,ne:FD,not:MD,notBetween:GD,notExists:$D,notLike:HD,notIlike:YD,notInArray:kD,or:PD,sql:X}}function eR(){return{sql:X,asc:qD,desc:QD}}function rR(r,t){var s;Object.keys(r).length===1&&"default"in r&&!lt(r.default,Tt)&&(r=r.default);const e={},i={},n={};for(const[o,a]of Object.entries(r))if(lt(a,Tt)){const l=ia(a),u=i[l];e[l]=o,n[o]={tsName:o,dbName:a[Tt.Symbol.Name],schema:a[Tt.Symbol.Schema],columns:a[Tt.Symbol.Columns],relations:(u==null?void 0:u.relations)??{},primaryKey:(u==null?void 0:u.primaryKey)??[]};for(const h of Object.values(a[Tt.Symbol.Columns]))h.primary&&n[o].primaryKey.push(h);const c=(s=a[Tt.Symbol.ExtraConfigBuilder])==null?void 0:s.call(a,a[Tt.Symbol.ExtraConfigColumns]);if(c)for(const h of Object.values(c))lt(h,Pw)&&n[o].primaryKey.push(...h.columns)}else if(lt(a,Dw)){const l=ia(a.table),u=e[l],c=a.config(t(a.table));let h;for(const[p,f]of Object.entries(c))if(u){const y=n[u];y.relations[p]=f}else l in i||(i[l]={relations:{},primaryKey:h}),i[l].relations[p]=f}return{tables:n,tableNamesMap:e}}function iR(r){return function(e,i){return new as(r,e,i,(i==null?void 0:i.fields.reduce((n,s)=>n&&s.notNull,!0))??!1)}}function nR(r){return function(e,i){return new Vl(r,e,i)}}function sR(r,t,e){if(lt(e,as)&&e.config)return{fields:e.config.fields,references:e.config.references};const i=t[ia(e.referencedTable)];if(!i)throw new Error(`Table "${e.referencedTable[Tt.Symbol.Name]}" not found in schema`);const n=r[i];if(!n)throw new Error(`Table "${i}" not found in schema`);const s=e.sourceTable,o=t[ia(s)];if(!o)throw new Error(`Table "${s[Tt.Symbol.Name]}" not found in schema`);const a=[];for(const l of Object.values(n.relations))(e.relationName&&e!==l&&l.relationName===e.relationName||!e.relationName&&l.referencedTable===e.sourceTable)&&a.push(l);if(a.length>1)throw e.relationName?new Error(`There are multiple relations with name "${e.relationName}" in table "${i}"`):new Error(`There are multiple relations between "${i}" and "${e.sourceTable[Tt.Symbol.Name]}". Please specify relation name`);if(a[0]&<(a[0],as)&&a[0].config)return{fields:a[0].config.references,references:a[0].config.fields};throw new Error(`There is not enough information to infer relation "${o}.${e.fieldName}"`)}function oR(r){return{one:iR(r),many:nR(r)}}function Ch(r,t,e,i,n=s=>s){const s={};for(const[o,a]of i.entries())if(a.isJson){const l=t.relations[a.tsKey],u=e[o],c=typeof u=="string"?JSON.parse(u):u;s[a.tsKey]=lt(l,as)?c&&Ch(r,r[a.relationTableTsKey],c,a.selection,n):c.map(h=>Ch(r,r[a.relationTableTsKey],h,a.selection,n))}else{const l=n(e[o]),u=a.field;let c;lt(u,Ke)?c=u:lt(u,Ft)?c=u.decoder:c=u.sql.decoder,s[a.tsKey]=l===null?null:c.mapFromDriverValue(l)}return s}var Wy;Wy=xt;const Xl=class Xl{constructor(t){G(this,"config");this.config={...t}}get(t,e){if(e==="_")return{...t._,selectedFields:new Proxy(t._.selectedFields,this)};if(e===He)return{...t[He],selectedFields:new Proxy(t[He].selectedFields,this)};if(typeof e=="symbol")return t[e];const n=(lt(t,Or)?t._.selectedFields:lt(t,Sn)?t[He].selectedFields:t)[e];if(lt(n,Ft.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!n.isSelectionField)return n.sql;const s=n.clone();return s.isSelectionField=!0,s}if(lt(n,Ft)){if(this.config.sqlBehavior==="sql")return n;throw new Error(`You tried to reference "${e}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return lt(n,Ke)?this.config.alias?new Proxy(n,new na(new Proxy(n.table,new cu(this.config.alias,this.config.replaceOriginalName??!1)))):n:typeof n!="object"||n===null?n:new Proxy(n,new Xl(this.config))}};G(Xl,Wy,"SelectionProxyHandler");let Je=Xl;var Hy,Xy;class Ah extends(Xy=Tn,Hy=xt,Xy){constructor(e,i,n,s){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=i,this.dialect=n,this.config={table:e,withList:s}}where(e){return this.config.where=e,this}returning(e=this.config.table[Tt.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=os(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(Ah,Hy,"PgDelete");function aR(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function lR(r){return(r.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,i,n)=>{const s=n===0?i.toLowerCase():`${i[0].toUpperCase()}${i.slice(1)}`;return e+s},"")}function uR(r){return r}var Yy;Yy=xt;class Rw{constructor(t){G(this,"cache",{});G(this,"cachedTables",{});G(this,"convert");this.convert=t==="snake_case"?aR:t==="camelCase"?lR:uR}getColumnCasing(t){if(!t.keyAsName)return t.name;const e=t.table[Tt.Symbol.Schema]??"public",i=t.table[Tt.Symbol.OriginalName],n=`${e}.${i}.${t.name}`;return this.cache[n]||this.cacheTable(t.table),this.cache[n]}cacheTable(t){const e=t[Tt.Symbol.Schema]??"public",i=t[Tt.Symbol.OriginalName],n=`${e}.${i}`;if(!this.cachedTables[n]){for(const s of Object.values(t[Tt.Symbol.Columns])){const o=`${n}.${s.name}`;this.cache[o]=this.convert(s.name)}this.cachedTables[n]=!0}}clearCache(){this.cache={},this.cachedTables={}}}G(Rw,Yy,"CasingCache");var qy,Qy;class Wf extends(Qy=Sn,qy=xt,Qy){}G(Wf,qy,"PgViewBase");var Ky;Ky=xt;class Bo{constructor(t){G(this,"casing");this.casing=new Rw(t==null?void 0:t.casing)}async migrate(t,e,i){const n=typeof i=="string"?"__drizzle_migrations":i.migrationsTable??"__drizzle_migrations",s=typeof i=="string"?"drizzle":i.migrationsSchema??"drizzle",o=X`
CREATE TABLE IF NOT EXISTS ${X.identifier(s)}.${X.identifier(n)} (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at bigint
)
- `;await e.execute(X`CREATE SCHEMA IF NOT EXISTS ${X.identifier(s)}`),await e.execute(o);const l=(await e.all(X`select id, hash, created_at from ${X.identifier(s)}.${X.identifier(n)} order by created_at desc limit 1`))[0];await e.transaction(async u=>{for await(const c of t)if(!l||Number(l.created_at){var a;return e[o]!==void 0||((a=i[o])==null?void 0:a.onUpdateFn)!==void 0}),s=n.length;return X.join(n.flatMap((o,a)=>{const l=i[o],u=e[o]??X.param(l.onUpdateFn(),l),c=X`${X.identifier(this.casing.getColumnCasing(l))} = ${u}`;return a{const a=[];if(lt(s,Ft.Aliased)&&s.isSelectionField)a.push(X.identifier(s.fieldAlias));else if(lt(s,Ft.Aliased)||lt(s,Ft)){const l=lt(s,Ft.Aliased)?s.sql:s;e?a.push(new Ft(l.queryChunks.map(u=>lt(u,Ar)?X.identifier(this.casing.getColumnCasing(u)):u))):a.push(l),lt(s,Ft.Aliased)&&a.push(X` as ${X.identifier(s.fieldAlias)}`)}else lt(s,Ke)&&(e?a.push(X.identifier(this.casing.getColumnCasing(s))):a.push(s));return oa==null?void 0:a.some(({alias:M})=>M===(it[Tt.Symbol.IsAlias]?qn(it):it[Tt.Symbol.BaseName])))(w.field.table)){const it=qn(w.field.table);throw new Error(`Your "${w.path.join("->")}" field references a column "${it}"."${w.field.name}", but the table "${it}" is not part of the query! Did you forget to join it?`)}const d=!a||a.length===0,m=this.buildWithCTE(t);let _;f&&(_=f===!0?X` distinct`:X` distinct on (${X.join(f.on,X`, `)})`);const S=this.buildSelection(g,{isSingleTable:d}),E=this.buildFromTable(o),b=this.buildJoins(a),F=n?X` where ${n}`:void 0,x=s?X` having ${s}`:void 0;let z;l&&l.length>0&&(z=X` order by ${X.join(l,X`, `)}`);let B;u&&u.length>0&&(B=X` group by ${X.join(u,X`, `)}`);const tt=typeof c=="object"||typeof c=="number"&&c>=0?X` limit ${c}`:void 0,st=h?X` offset ${h}`:void 0,I=X.empty();if(p){const w=X` for ${X.raw(p.strength)}`;p.config.of&&w.append(X` of ${X.join(Array.isArray(p.config.of)?p.config.of:[p.config.of],X`, `)}`),p.config.noWait?w.append(X` no wait`):p.config.skipLocked&&w.append(X` skip locked`),I.append(w)}const Z=X`${m}select${_} ${S} from ${E}${b}${F}${B}${x}${z}${tt}${st}${I}`;return y.length>0?this.buildSetOperations(Z,y):Z}buildSetOperations(t,e){const[i,...n]=e;if(!i)throw new Error("Cannot pass undefined values to any set operator");return n.length===0?this.buildSetOperationQuery({leftSelect:t,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:t,setOperator:i}),n)}buildSetOperationQuery({leftSelect:t,setOperator:{type:e,isAll:i,rightSelect:n,limit:s,orderBy:o,offset:a}}){const l=X`(${t.getSQL()}) `,u=X`(${n.getSQL()})`;let c;if(o&&o.length>0){const y=[];for(const g of o)if(lt(g,Ar))y.push(X.identifier(g.name));else if(lt(g,Ft)){for(let d=0;d=0?X` limit ${s}`:void 0,p=X.raw(`${e} ${i?"all ":""}`),f=a?X` offset ${a}`:void 0;return X`${l}${p}${u}${c}${h}${f}`}buildInsertQuery({table:t,values:e,onConflict:i,returning:n,withList:s,select:o,overridingSystemValue_:a}){const l=[],u=t[Tt.Symbol.Columns],c=Object.entries(u).filter(([m,_])=>!_.shouldDisableInsert()),h=c.map(([,m])=>X.identifier(this.casing.getColumnCasing(m)));if(o){const m=e;lt(m,Ft)?l.push(m):l.push(m.getSQL())}else{const m=e;l.push(X.raw("values "));for(const[_,S]of m.entries()){const E=[];for(const[b,F]of c){const x=S[b];if(x===void 0||lt(x,Wi)&&x.value===void 0)if(F.defaultFn!==void 0){const z=F.defaultFn(),B=lt(z,Ft)?z:X.param(z,F);E.push(B)}else if(!F.default&&F.onUpdateFn!==void 0){const z=F.onUpdateFn(),B=lt(z,Ft)?z:X.param(z,F);E.push(B)}else E.push(X`default`);else E.push(x)}l.push(E),_({dbKey:S.name,tsKey:_,field:Li(S,a),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const m=Object.fromEntries(Object.entries(s.columns).map(([x,z])=>[x,Li(z,a)]));if(o.where){const x=typeof o.where=="function"?o.where(m,tR()):o.where;y=x&&$l(x,a)}const _=[];let S=[];if(o.columns){let x=!1;for(const[z,B]of Object.entries(o.columns))B!==void 0&&z in s.columns&&(!x&&B===!0&&(x=!0),S.push(z));S.length>0&&(S=x?S.filter(z=>{var B;return((B=o.columns)==null?void 0:B[z])===!0}):Object.keys(s.columns).filter(z=>!S.includes(z)))}else S=Object.keys(s.columns);for(const x of S){const z=s.columns[x];_.push({tsKey:x,value:z})}let E=[];o.with&&(E=Object.entries(o.with).filter(x=>!!x[1]).map(([x,z])=>({tsKey:x,queryConfig:z,relation:s.relations[x]})));let b;if(o.extras){b=typeof o.extras=="function"?o.extras(m,{sql:X}):o.extras;for(const[x,z]of Object.entries(b))_.push({tsKey:x,value:mw(z,a)})}for(const{tsKey:x,value:z}of _)c.push({dbKey:lt(z,Ft.Aliased)?z.fieldAlias:s.columns[x].name,tsKey:x,field:lt(z,Ke)?Li(z,a):z,relationTableTsKey:void 0,isJson:!1,selection:[]});let F=typeof o.orderBy=="function"?o.orderBy(m,eR()):o.orderBy??[];Array.isArray(F)||(F=[F]),f=F.map(x=>lt(x,Ke)?Li(x,a):$l(x,a)),h=o.limit,p=o.offset;for(const{tsKey:x,queryConfig:z,relation:B}of E){const tt=sR(e,i,B),st=ia(B.referencedTable),I=i[st],Z=`${a}_${x}`,w=Eh(...tt.fields.map((O,D)=>gw(Li(tt.references[D],Z),Li(O,a)))),it=this.buildRelationalQueryWithoutPK({fullSchema:t,schema:e,tableNamesMap:i,table:t[I],tableConfig:e[I],queryConfig:lt(B,as)?z===!0?{limit:1}:{...z,limit:1}:z,tableAlias:Z,joinOn:w,nestedQueryRelation:B}),M=X`${X.identifier(Z)}.${X.identifier("data")}`.as(x);g.push({on:X`true`,table:new Or(it.sql,{},Z),alias:Z,joinType:"left",lateral:!0}),c.push({dbKey:x,tsKey:x,field:M,relationTableTsKey:I,isJson:!0,selection:it.selection})}}if(c.length===0)throw new $f({message:`No fields selected for table "${s.tsName}" ("${a}")`});let d;if(y=Eh(u,y),l){let m=X`json_build_array(${X.join(c.map(({field:E,tsKey:b,isJson:F})=>F?X`${X.identifier(`${a}_${b}`)}.${X.identifier("data")}`:lt(E,Ft.Aliased)?E.sql:E),X`, `)})`;lt(l,Vl)&&(m=X`coalesce(json_agg(${m}${f.length>0?X` order by ${X.join(f,X`, `)}`:void 0}), '[]'::json)`);const _=[{dbKey:"data",tsKey:"data",field:m.as("data"),isJson:!0,relationTableTsKey:s.tsName,selection:c}];h!==void 0||p!==void 0||f.length>0?(d=this.buildSelectQuery({table:ac(n,a),fields:{},fieldsFlat:[{path:[],field:X.raw("*")}],where:y,limit:h,offset:p,orderBy:f,setOperators:[]}),y=void 0,h=void 0,p=void 0,f=[]):d=ac(n,a),d=this.buildSelectQuery({table:lt(d,Br)?d:new Or(d,{},a),fields:{},fieldsFlat:_.map(({field:E})=>({path:[],field:lt(E,Ke)?Li(E,a):E})),joins:g,where:y,limit:h,offset:p,orderBy:f,setOperators:[]})}else d=this.buildSelectQuery({table:ac(n,a),fields:{},fieldsFlat:c.map(({field:m})=>({path:[],field:lt(m,Ke)?Li(m,a):m})),joins:g,where:y,limit:h,offset:p,orderBy:f,setOperators:[]});return{tableTsKey:s.tsName,sql:d,selection:c}}}G(Bo,Ky,"PgDialect");var Zy;Zy=xt;class Nw{getSelectedFields(){return this._.selectedFields}}G(Nw,Zy,"TypedQueryBuilder");var Jy;Jy=xt;class Sr{constructor(t){G(this,"fields");G(this,"session");G(this,"dialect");G(this,"withList",[]);G(this,"distinct");G(this,"authToken");this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,t.withList&&(this.withList=t.withList),this.distinct=t.distinct}setToken(t){return this.authToken=t,this}from(t){const e=!!this.fields,i=t;let n;return this.fields?n=this.fields:lt(i,Or)?n=Object.fromEntries(Object.keys(i._.selectedFields).map(s=>[s,i[s]])):lt(i,Wf)?n=i[He].selectedFields:lt(i,Ft)?n={}:n=ZD(i),new Hf({table:i,fields:n,isPartialSelect:e,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}G(Sr,Jy,"PgSelectBuilder");var tg,eg;class Lw extends(eg=Nw,tg=xt,eg){constructor({table:e,fields:i,isPartialSelect:n,session:s,dialect:o,withList:a,distinct:l}){super();G(this,"_");G(this,"config");G(this,"joinsNotNullableMap");G(this,"tableName");G(this,"isPartialSelect");G(this,"session");G(this,"dialect");G(this,"leftJoin",this.createJoin("left"));G(this,"rightJoin",this.createJoin("right"));G(this,"innerJoin",this.createJoin("inner"));G(this,"fullJoin",this.createJoin("full"));G(this,"union",this.createSetOperator("union",!1));G(this,"unionAll",this.createSetOperator("union",!0));G(this,"intersect",this.createSetOperator("intersect",!1));G(this,"intersectAll",this.createSetOperator("intersect",!0));G(this,"except",this.createSetOperator("except",!1));G(this,"exceptAll",this.createSetOperator("except",!0));this.config={withList:a,table:e,fields:{...i},distinct:l,setOperators:[]},this.isPartialSelect=n,this.session=s,this.dialect=o,this._={selectedFields:i},this.tableName=Wn(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}createJoin(e){return(i,n)=>{var a;const s=this.tableName,o=Wn(i);if(typeof o=="string"&&((a=this.config.joins)!=null&&a.some(l=>l.alias===o)))throw new Error(`Alias "${o}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof o=="string"&&!lt(i,Ft))){const l=lt(i,Or)?i._.selectedFields:lt(i,Sn)?i[He].selectedFields:i[Tt.Symbol.Columns];this.config.fields[o]=l}if(typeof n=="function"&&(n=n(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:n,table:i,joinType:e,alias:o}),typeof o=="string")switch(e){case"left":{this.joinsNotNullableMap[o]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!0;break}case"inner":{this.joinsNotNullableMap[o]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!1;break}}return this}}createSetOperator(e,i){return n=>{const s=typeof n=="function"?n(cR()):n;if(!Vf(this.getSelectedFields(),s.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:i,rightSelect:s}),this}}addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){const i=e[0](new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(i)?i:[i]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){const i=e[0](new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),n=Array.isArray(i)?i:[i];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{const i=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,i={}){return this.config.lockingClause={strength:e,config:i},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}as(e){return new Proxy(new Or(this.getSQL(),this.config.fields,e),new Je({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new Je({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}G(Lw,tg,"PgSelectQueryBuilder");var rg,ig;class Hf extends(ig=Lw,rg=xt,ig){constructor(){super(...arguments);G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)))}_prepare(e){const{session:i,config:n,dialect:s,joinsNotNullableMap:o,authToken:a}=this;if(!i)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return Pr.startActiveSpan("drizzle.prepareQuery",()=>{const l=os(n.fields),u=i.prepareQuery(s.sqlToQuery(this.getSQL()),l,e,!0);return u.joinsNotNullableMap=o,u.setToken(a)})}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}G(Hf,rg,"PgSelect");KD(Hf,[Tn]);function oo(r,t){return(e,i,...n)=>{const s=[i,...n].map(o=>({type:r,isAll:t,rightSelect:o}));for(const o of s)if(!Vf(e.getSelectedFields(),o.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return e.addSetOperators(s)}}const cR=()=>({union:hR,unionAll:fR,intersect:dR,intersectAll:pR,except:mR,exceptAll:yR}),hR=oo("union",!1),fR=oo("union",!0),dR=oo("intersect",!1),pR=oo("intersect",!0),mR=oo("except",!1),yR=oo("except",!0);var ng;ng=xt;class Xf{constructor(t){G(this,"dialect");G(this,"dialectConfig");G(this,"$with",(t,e)=>{const i=this;return{as:s=>(typeof s=="function"&&(s=s(i)),new Proxy(new jf(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new Je({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});this.dialect=lt(t,Bo)?t:void 0,this.dialectConfig=lt(t,Bo)?void 0:t}with(...t){const e=this;function i(o){return new Sr({fields:o??void 0,session:void 0,dialect:e.getDialect(),withList:t})}function n(o){return new Sr({fields:o??void 0,session:void 0,dialect:e.getDialect(),distinct:!0})}function s(o,a){return new Sr({fields:a??void 0,session:void 0,dialect:e.getDialect(),distinct:{on:o}})}return{select:i,selectDistinct:n,selectDistinctOn:s}}select(t){return new Sr({fields:t??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(t){return new Sr({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(t,e){return new Sr({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:t}})}getDialect(){return this.dialect||(this.dialect=new Bo(this.dialectConfig)),this.dialect}}G(Xf,ng,"PgQueryBuilder");var sg;sg=xt;class Oh{constructor(t,e,i,n,s){G(this,"authToken");this.table=t,this.session=e,this.dialect=i,this.withList=n,this.overridingSystemValue_=s}setToken(t){return this.authToken=t,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(t){if(t=Array.isArray(t)?t:[t],t.length===0)throw new Error("values() must be called with at least one value");const e=t.map(i=>{const n={},s=this.table[Tt.Symbol.Columns];for(const o of Object.keys(i)){const a=i[o];n[o]=lt(a,Ft)?a:new Wi(a,s[o])}return n});return new Fh(this.table,e,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(t){const e=typeof t=="function"?t(new Xf):t;if(!lt(e,Ft)&&!Vf(this.table[Ih],e._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Fh(this.table,e,this.session,this.dialect,this.withList,!0)}}G(Oh,sg,"PgInsertBuilder");var og,ag;class Fh extends(ag=Tn,og=xt,ag){constructor(e,i,n,s,o,a,l){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=n,this.dialect=s,this.config={table:e,values:i,withList:o,select:a,overridingSystemValue_:l}}returning(e=this.config.table[Tt.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=os(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=X`do nothing`;else{let i="";i=Array.isArray(e.target)?e.target.map(s=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(s))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));const n=e.where?X` where ${e.where}`:void 0;this.config.onConflict=X`(${X.raw(i)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');const i=e.where?X` where ${e.where}`:void 0,n=e.targetWhere?X` where ${e.targetWhere}`:void 0,s=e.setWhere?X` where ${e.setWhere}`:void 0,o=this.dialect.buildUpdateSet(this.config.table,ww(this.config.table,e.set));let a="";return a=Array.isArray(e.target)?e.target.map(l=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(l))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=X`(${X.raw(a)})${n} do update set ${o}${i}${s}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(Fh,og,"PgInsert");var lg,ug;class Bw extends(ug=Tn,lg=xt,ug){constructor(e,i,n){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=i,this.dialect=n,this.config={view:e}}concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}G(Bw,lg,"PgRefreshMaterializedView");var cg;cg=xt;class Ph{constructor(t,e,i,n){G(this,"authToken");this.table=t,this.session=e,this.dialect=i,this.withList=n}setToken(t){return this.authToken=t,this}set(t){return new kw(this.table,ww(this.table,t),this.session,this.dialect,this.withList).setToken(this.authToken)}}G(Ph,cg,"PgUpdateBuilder");var hg,fg;class kw extends(fg=Tn,hg=xt,fg){constructor(e,i,n,s,o){super();G(this,"config");G(this,"tableName");G(this,"joinsNotNullableMap");G(this,"leftJoin",this.createJoin("left"));G(this,"rightJoin",this.createJoin("right"));G(this,"innerJoin",this.createJoin("inner"));G(this,"fullJoin",this.createJoin("full"));G(this,"authToken");G(this,"execute",e=>this._prepare().execute(e,this.authToken));this.session=n,this.dialect=s,this.config={set:i,table:e,withList:o,joins:[]},this.tableName=Wn(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}from(e){const i=e,n=Wn(i);return typeof n=="string"&&(this.joinsNotNullableMap[n]=!0),this.config.from=i,this}getTableLikeFields(e){return lt(e,Br)?e[Tt.Symbol.Columns]:lt(e,Or)?e._.selectedFields:e[He].selectedFields}createJoin(e){return(i,n)=>{const s=Wn(i);if(typeof s=="string"&&this.config.joins.some(o=>o.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof n=="function"){const o=this.config.from&&!lt(this.config.from,Ft)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[Tt.Symbol.Columns],new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),o&&new Proxy(o,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:n,table:i,joinType:e,alias:s}),typeof s=="string")switch(e){case"left":{this.joinsNotNullableMap[s]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!0;break}case"inner":{this.joinsNotNullableMap[s]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!1;break}}return this}}where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[Tt.Symbol.Columns]),this.config.from)){const i=Wn(this.config.from);if(typeof i=="string"&&this.config.from&&!lt(this.config.from,Ft)){const n=this.getTableLikeFields(this.config.from);e[i]=n}for(const n of this.config.joins){const s=Wn(n.table);if(typeof s=="string"&&!lt(n.table,Ft)){const o=this.getTableLikeFields(n.table);e[s]=o}}}return this.config.returningFields=e,this.config.returning=os(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){const i=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(kw,hg,"PgUpdate");var dg,pg,mg;const Uo=class Uo extends(mg=Ft,pg=xt,dg=Symbol.toStringTag,mg){constructor(e){super(Uo.buildEmbeddedCount(e.source,e.filters).queryChunks);G(this,"sql");G(this,"token");G(this,dg,"PgCountBuilder");G(this,"session");this.params=e,this.mapWith(Number),this.session=e.session,this.sql=Uo.buildCount(e.source,e.filters)}static buildEmbeddedCount(e,i){return X`(select count(*) from ${e}${X.raw(" where ").if(i)}${i})`}static buildCount(e,i){return X`select count(*) as count from ${e}${X.raw(" where ").if(i)}${i};`}setToken(e){return this.token=e,this}then(e,i){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,i)}catch(e){return this.then(void 0,e)}finally(e){return this.then(i=>(e==null||e(),i),i=>{throw e==null||e(),i})}};G(Uo,pg,"PgCountBuilder");let Mh=Uo;var yg;yg=xt;class Uw{constructor(t,e,i,n,s,o,a){this.fullSchema=t,this.schema=e,this.tableNamesMap=i,this.table=n,this.tableConfig=s,this.dialect=o,this.session=a}findMany(t){return new Dh(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t||{},"many")}findFirst(t){return new Dh(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t?{...t,limit:1}:{limit:1},"first")}}G(Uw,yg,"PgRelationalQueryBuilder");var gg,vg;class Dh extends(vg=Tn,gg=xt,vg){constructor(e,i,n,s,o,a,l,u,c){super();G(this,"authToken");this.fullSchema=e,this.schema=i,this.tableNamesMap=n,this.table=s,this.tableConfig=o,this.dialect=a,this.session=l,this.config=u,this.mode=c}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>{const{query:i,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,e,!0,(s,o)=>{const a=s.map(l=>Ch(this.schema,this.tableConfig,l,i.selection,o));return this.mode==="first"?a[0]:a})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){const e=this._getQuery(),i=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:i}}toSQL(){return this._toSQL().builtQuery}setToken(e){return this.authToken=e,this}execute(){return Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}G(Dh,gg,"PgRelationalQuery");var _g,bg;class zw extends(bg=Tn,_g=xt,bg){constructor(t,e,i,n){super(),this.execute=t,this.sql=e,this.query=i,this.mapBatchResult=n}getSQL(){return this.sql}getQuery(){return this.query}mapResult(t,e){return e?this.mapBatchResult(t):t}_prepare(){return this}isResponseInArrayMode(){return!1}}G(zw,_g,"PgRaw");var wg;wg=xt;class Yf{constructor(t,e,i){G(this,"query");G(this,"$with",(t,e)=>{const i=this;return{as:s=>(typeof s=="function"&&(s=s(new Xf(i.dialect))),new Proxy(new jf(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new Je({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});G(this,"authToken");if(this.dialect=t,this.session=e,this._=i?{schema:i.schema,fullSchema:i.fullSchema,tableNamesMap:i.tableNamesMap,session:e}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:e},this.query={},this._.schema)for(const[n,s]of Object.entries(this._.schema))this.query[n]=new Uw(i.fullSchema,this._.schema,this._.tableNamesMap,i.fullSchema[n],s,t,e)}$count(t,e){return new Mh({source:t,filters:e,session:this.session})}with(...t){const e=this;function i(u){return new Sr({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t})}function n(u){return new Sr({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:!0})}function s(u,c){return new Sr({fields:c??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:{on:u}})}function o(u){return new Ph(u,e.session,e.dialect,t)}function a(u){return new Oh(u,e.session,e.dialect,t)}function l(u){return new Ah(u,e.session,e.dialect,t)}return{select:i,selectDistinct:n,selectDistinctOn:s,update:o,insert:a,delete:l}}select(t){return new Sr({fields:t??void 0,session:this.session,dialect:this.dialect})}selectDistinct(t){return new Sr({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(t,e){return new Sr({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:{on:t}})}update(t){return new Ph(t,this.session,this.dialect)}insert(t){return new Oh(t,this.session,this.dialect)}delete(t){return new Ah(t,this.session,this.dialect)}refreshMaterializedView(t){return new Bw(t,this.session,this.dialect)}execute(t){const e=typeof t=="string"?X.raw(t):t.getSQL(),i=this.dialect.sqlToQuery(e),n=this.session.prepareQuery(i,void 0,void 0,!1);return new zw(()=>n.execute(void 0,this.authToken),e,i,s=>n.mapResult(s,!0))}transaction(t,e){return this.session.transaction(t,e)}}G(Yf,wg,"PgDatabase");var xg;xg=xt;class jw{constructor(t){G(this,"authToken");G(this,"joinsNotNullableMap");this.query=t}getQuery(){return this.query}mapResult(t,e){return t}setToken(t){return this.authToken=t,this}}G(jw,xg,"PgPreparedQuery");var Sg;Sg=xt;class $w{constructor(t){this.dialect=t}execute(t,e){return Pr.startActiveSpan("drizzle.operation",()=>Pr.startActiveSpan("drizzle.prepareQuery",()=>this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1)).setToken(e).execute(void 0,e))}all(t){return this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1).all()}async count(t,e){const i=await this.execute(t,e);return Number(i[0].count)}}G($w,Sg,"PgSession");var Tg,Ig;class Vw extends(Ig=Yf,Tg=xt,Ig){constructor(t,e,i,n=0){super(t,e,i),this.schema=i,this.nestedIndex=n}rollback(){throw new yw}getTransactionConfigSQL(t){const e=[];return t.isolationLevel&&e.push(`isolation level ${t.isolationLevel}`),t.accessMode&&e.push(t.accessMode),typeof t.deferrable=="boolean"&&e.push(t.deferrable?"deferrable":"not deferrable"),X.raw(e.join(" "))}setTransaction(t){return this.session.execute(X`set transaction ${this.getTransactionConfigSQL(t)}`)}}G(Vw,Tg,"PgTransaction");function Om(r){return typeof r=="string"&&/^true$/i.test(r)}function gR(r){const t={scheme:"duckdb-wasm:"},e=new URL(r);if(!e.protocol.startsWith("duckdb-wasm:"))throw new Error(`Expected scheme to be "duckdb-wasm:" but got "${e.protocol}"`);e.searchParams.get("bundles")==="import-url"&&(t.bundles="import-url");const i=e.searchParams.get("logger");i&&Om(i)&&(t.logger=!0);const n=e.searchParams.get("storage");switch(n){case ra.ORIGIN_PRIVATE_FS:{e.host.length>0&&console.warn(`Host "${e.host}" will be ignored while using Origin Private FS`);const s=e.searchParams.get("write");t.storage={type:ra.ORIGIN_PRIVATE_FS,path:e.pathname.startsWith("/")?e.pathname.slice(1):e.pathname,...s&&Om(s)&&{accessMode:T0.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${n}"`);break}return t}var Eg,Cg;class Gw extends(Cg=jw,Eg=xt,Cg){constructor(t,e,i,n,s,o){super({sql:e,params:i}),this.client=t,this.queryString=e,this.params=i,this.logger=n,this.fields=s,this.customResultMapper=o}async execute(t={}){const e=Em(this.params,t);this.logger.logQuery(this.queryString,e);const{fields:i,queryString:n,client:s,customResultMapper:o}=this,a=await s;return a.query(n,e)}async all(t={}){const e=Em(this.params,t);return this.logger.logQuery(this.queryString,e),(await this.client).query(this.queryString,e)}}G(Gw,Eg,"DuckDBWasmPreparedQuery");var Ag,Og;const Yl=class Yl extends(Og=$w,Ag=xt,Og){constructor(e,i,n,s={}){super(i);G(this,"logger");this.client=e,this.schema=n,this.options=s,this.logger=s.logger??new bw}prepareQuery(e,i,n,s,o){return new Gw(this.client,e.sql,e.params,this.logger,i,o)}async query(e,i){return this.logger.logQuery(e,i),(await this.client).query(e,i)}async queryObjects(e,i){return this.logger.logQuery(e,i),(await this.client).query(e,i)}transaction(e,i){return xD(this.client,async n=>{const s=new Yl(n,this.dialect,this.schema,this.options),o=new Rh(this.dialect,s,this.schema);return i&&await o.setTransaction(i),e(o)})}};G(Yl,Ag,"DuckDBWasmSession");let Gl=Yl;var Fg,Pg;const ql=class ql extends(Pg=Vw,Fg=xt,Pg){constructor(e,i,n,s=0){super(e,i,n,s);G(this,"dialect");G(this,"session");this.dialect=e,this.session=i}async transaction(e){return SD(this.session.client,"",async i=>{const n=new Gl(i,this.dialect,this.schema,this.session.options),s=new ql(this.dialect,n,this.schema);return e(s)})}};G(ql,Fg,"DuckDBWasmTransaction");let Rh=ql;var Mg,Dg;class Ww extends(Dg=Yf,Mg=xt,Dg){}G(Ww,Mg,"DuckDBWasmDatabase");function ko(r,t={}){const e=new Bo({casing:t.casing});let i;t.logger===!0?i=new _w:t.logger!==!1&&(i=t.logger);let n;if(t.schema){const a=rR(t.schema,oR);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}const s=new Gl(r,e,n,{logger:i}),o=new Ww(e,s,n);return o.$client=r,o}function Fm(r,t){const e=gR(r);let i;return e.bundles==="import-url"?i=(async()=>{const s=await Sh();switch(s){case"browser":return(await ln(async()=>{const{getImportUrlBundles:o}=await import("./import-url-browser-CPN8ipMD.js");return{getImportUrlBundles:o}},__vite__mapDeps([3,4]))).getImportUrlBundles();case"node":return await(await ln(async()=>{const{getImportUrlBundles:o}=await import("./import-url-node-BfNoxhRr.js");return{getImportUrlBundles:o}},__vite__mapDeps([5,4]))).getImportUrlBundles();default:throw new Error(`Unsupported environment: "${s}"`)}})():i=(async()=>{const s=await Sh();switch(s){case"browser":return(await ln(async()=>{const{getBundles:o}=await import("./default-browser-BrgSDbLD.js");return{getBundles:o}},[])).getBundles();case"node":return await(await ln(async()=>{const{getBundles:o}=await import("./default-node-CUehHPTd.js");return{getBundles:o}},__vite__mapDeps([0,1,2]))).getBundles();default:throw new Error(`Unsupported environment: "${s}"`)}})(),ko(hw({bundles:i,logger:e.logger?new I0:void 0,storage:e.storage}),t)}function Pm(...r){if(typeof r[0]=="string")return Fm(r[0],r[1]);if(JD(r[0])){const{connection:t,client:e,...i}=r[0];if(e)return ko(e,i);if(typeof t=="string")return Fm(t,i);if(typeof t>"u")throw new Error("connection option is required");return ko(hw({bundles:t.bundles,logger:t.logger,storage:t.storage}),i)}return ko(r[0],r[1])}(r=>{function t(e){return ko({options:{parsers:{},serializers:{}}},e)}r.mock=t})(Pm||(Pm={}));export{L1 as A,TR as D,xR as I,pC as J,eI as L,_c as M,wR as T,fi as a,Re as b,Pm as d,sa as e,SR as l};
+ `;await e.execute(X`CREATE SCHEMA IF NOT EXISTS ${X.identifier(s)}`),await e.execute(o);const l=(await e.all(X`select id, hash, created_at from ${X.identifier(s)}.${X.identifier(n)} order by created_at desc limit 1`))[0];await e.transaction(async u=>{for await(const c of t)if(!l||Number(l.created_at){var a;return e[o]!==void 0||((a=i[o])==null?void 0:a.onUpdateFn)!==void 0}),s=n.length;return X.join(n.flatMap((o,a)=>{const l=i[o],u=e[o]??X.param(l.onUpdateFn(),l),c=X`${X.identifier(this.casing.getColumnCasing(l))} = ${u}`;return a{const a=[];if(lt(s,Ft.Aliased)&&s.isSelectionField)a.push(X.identifier(s.fieldAlias));else if(lt(s,Ft.Aliased)||lt(s,Ft)){const l=lt(s,Ft.Aliased)?s.sql:s;e?a.push(new Ft(l.queryChunks.map(u=>lt(u,Ar)?X.identifier(this.casing.getColumnCasing(u)):u))):a.push(l),lt(s,Ft.Aliased)&&a.push(X` as ${X.identifier(s.fieldAlias)}`)}else lt(s,Ke)&&(e?a.push(X.identifier(this.casing.getColumnCasing(s))):a.push(s));return oa==null?void 0:a.some(({alias:M})=>M===(it[Tt.Symbol.IsAlias]?qn(it):it[Tt.Symbol.BaseName])))(w.field.table)){const it=qn(w.field.table);throw new Error(`Your "${w.path.join("->")}" field references a column "${it}"."${w.field.name}", but the table "${it}" is not part of the query! Did you forget to join it?`)}const d=!a||a.length===0,m=this.buildWithCTE(t);let _;f&&(_=f===!0?X` distinct`:X` distinct on (${X.join(f.on,X`, `)})`);const S=this.buildSelection(g,{isSingleTable:d}),E=this.buildFromTable(o),b=this.buildJoins(a),F=n?X` where ${n}`:void 0,x=s?X` having ${s}`:void 0;let z;l&&l.length>0&&(z=X` order by ${X.join(l,X`, `)}`);let B;u&&u.length>0&&(B=X` group by ${X.join(u,X`, `)}`);const tt=typeof c=="object"||typeof c=="number"&&c>=0?X` limit ${c}`:void 0,st=h?X` offset ${h}`:void 0,I=X.empty();if(p){const w=X` for ${X.raw(p.strength)}`;p.config.of&&w.append(X` of ${X.join(Array.isArray(p.config.of)?p.config.of:[p.config.of],X`, `)}`),p.config.noWait?w.append(X` no wait`):p.config.skipLocked&&w.append(X` skip locked`),I.append(w)}const Z=X`${m}select${_} ${S} from ${E}${b}${F}${B}${x}${z}${tt}${st}${I}`;return y.length>0?this.buildSetOperations(Z,y):Z}buildSetOperations(t,e){const[i,...n]=e;if(!i)throw new Error("Cannot pass undefined values to any set operator");return n.length===0?this.buildSetOperationQuery({leftSelect:t,setOperator:i}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:t,setOperator:i}),n)}buildSetOperationQuery({leftSelect:t,setOperator:{type:e,isAll:i,rightSelect:n,limit:s,orderBy:o,offset:a}}){const l=X`(${t.getSQL()}) `,u=X`(${n.getSQL()})`;let c;if(o&&o.length>0){const y=[];for(const g of o)if(lt(g,Ar))y.push(X.identifier(g.name));else if(lt(g,Ft)){for(let d=0;d=0?X` limit ${s}`:void 0,p=X.raw(`${e} ${i?"all ":""}`),f=a?X` offset ${a}`:void 0;return X`${l}${p}${u}${c}${h}${f}`}buildInsertQuery({table:t,values:e,onConflict:i,returning:n,withList:s,select:o,overridingSystemValue_:a}){const l=[],u=t[Tt.Symbol.Columns],c=Object.entries(u).filter(([m,_])=>!_.shouldDisableInsert()),h=c.map(([,m])=>X.identifier(this.casing.getColumnCasing(m)));if(o){const m=e;lt(m,Ft)?l.push(m):l.push(m.getSQL())}else{const m=e;l.push(X.raw("values "));for(const[_,S]of m.entries()){const E=[];for(const[b,F]of c){const x=S[b];if(x===void 0||lt(x,Wi)&&x.value===void 0)if(F.defaultFn!==void 0){const z=F.defaultFn(),B=lt(z,Ft)?z:X.param(z,F);E.push(B)}else if(!F.default&&F.onUpdateFn!==void 0){const z=F.onUpdateFn(),B=lt(z,Ft)?z:X.param(z,F);E.push(B)}else E.push(X`default`);else E.push(x)}l.push(E),_({dbKey:S.name,tsKey:_,field:Li(S,a),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const m=Object.fromEntries(Object.entries(s.columns).map(([x,z])=>[x,Li(z,a)]));if(o.where){const x=typeof o.where=="function"?o.where(m,tR()):o.where;y=x&&$l(x,a)}const _=[];let S=[];if(o.columns){let x=!1;for(const[z,B]of Object.entries(o.columns))B!==void 0&&z in s.columns&&(!x&&B===!0&&(x=!0),S.push(z));S.length>0&&(S=x?S.filter(z=>{var B;return((B=o.columns)==null?void 0:B[z])===!0}):Object.keys(s.columns).filter(z=>!S.includes(z)))}else S=Object.keys(s.columns);for(const x of S){const z=s.columns[x];_.push({tsKey:x,value:z})}let E=[];o.with&&(E=Object.entries(o.with).filter(x=>!!x[1]).map(([x,z])=>({tsKey:x,queryConfig:z,relation:s.relations[x]})));let b;if(o.extras){b=typeof o.extras=="function"?o.extras(m,{sql:X}):o.extras;for(const[x,z]of Object.entries(b))_.push({tsKey:x,value:mw(z,a)})}for(const{tsKey:x,value:z}of _)c.push({dbKey:lt(z,Ft.Aliased)?z.fieldAlias:s.columns[x].name,tsKey:x,field:lt(z,Ke)?Li(z,a):z,relationTableTsKey:void 0,isJson:!1,selection:[]});let F=typeof o.orderBy=="function"?o.orderBy(m,eR()):o.orderBy??[];Array.isArray(F)||(F=[F]),f=F.map(x=>lt(x,Ke)?Li(x,a):$l(x,a)),h=o.limit,p=o.offset;for(const{tsKey:x,queryConfig:z,relation:B}of E){const tt=sR(e,i,B),st=ia(B.referencedTable),I=i[st],Z=`${a}_${x}`,w=Eh(...tt.fields.map((O,D)=>gw(Li(tt.references[D],Z),Li(O,a)))),it=this.buildRelationalQueryWithoutPK({fullSchema:t,schema:e,tableNamesMap:i,table:t[I],tableConfig:e[I],queryConfig:lt(B,as)?z===!0?{limit:1}:{...z,limit:1}:z,tableAlias:Z,joinOn:w,nestedQueryRelation:B}),M=X`${X.identifier(Z)}.${X.identifier("data")}`.as(x);g.push({on:X`true`,table:new Or(it.sql,{},Z),alias:Z,joinType:"left",lateral:!0}),c.push({dbKey:x,tsKey:x,field:M,relationTableTsKey:I,isJson:!0,selection:it.selection})}}if(c.length===0)throw new $f({message:`No fields selected for table "${s.tsName}" ("${a}")`});let d;if(y=Eh(u,y),l){let m=X`json_build_array(${X.join(c.map(({field:E,tsKey:b,isJson:F})=>F?X`${X.identifier(`${a}_${b}`)}.${X.identifier("data")}`:lt(E,Ft.Aliased)?E.sql:E),X`, `)})`;lt(l,Vl)&&(m=X`coalesce(json_agg(${m}${f.length>0?X` order by ${X.join(f,X`, `)}`:void 0}), '[]'::json)`);const _=[{dbKey:"data",tsKey:"data",field:m.as("data"),isJson:!0,relationTableTsKey:s.tsName,selection:c}];h!==void 0||p!==void 0||f.length>0?(d=this.buildSelectQuery({table:ac(n,a),fields:{},fieldsFlat:[{path:[],field:X.raw("*")}],where:y,limit:h,offset:p,orderBy:f,setOperators:[]}),y=void 0,h=void 0,p=void 0,f=[]):d=ac(n,a),d=this.buildSelectQuery({table:lt(d,Br)?d:new Or(d,{},a),fields:{},fieldsFlat:_.map(({field:E})=>({path:[],field:lt(E,Ke)?Li(E,a):E})),joins:g,where:y,limit:h,offset:p,orderBy:f,setOperators:[]})}else d=this.buildSelectQuery({table:ac(n,a),fields:{},fieldsFlat:c.map(({field:m})=>({path:[],field:lt(m,Ke)?Li(m,a):m})),joins:g,where:y,limit:h,offset:p,orderBy:f,setOperators:[]});return{tableTsKey:s.tsName,sql:d,selection:c}}}G(Bo,Ky,"PgDialect");var Zy;Zy=xt;class Nw{getSelectedFields(){return this._.selectedFields}}G(Nw,Zy,"TypedQueryBuilder");var Jy;Jy=xt;class Sr{constructor(t){G(this,"fields");G(this,"session");G(this,"dialect");G(this,"withList",[]);G(this,"distinct");G(this,"authToken");this.fields=t.fields,this.session=t.session,this.dialect=t.dialect,t.withList&&(this.withList=t.withList),this.distinct=t.distinct}setToken(t){return this.authToken=t,this}from(t){const e=!!this.fields,i=t;let n;return this.fields?n=this.fields:lt(i,Or)?n=Object.fromEntries(Object.keys(i._.selectedFields).map(s=>[s,i[s]])):lt(i,Wf)?n=i[He].selectedFields:lt(i,Ft)?n={}:n=ZD(i),new Hf({table:i,fields:n,isPartialSelect:e,session:this.session,dialect:this.dialect,withList:this.withList,distinct:this.distinct}).setToken(this.authToken)}}G(Sr,Jy,"PgSelectBuilder");var tg,eg;class Lw extends(eg=Nw,tg=xt,eg){constructor({table:e,fields:i,isPartialSelect:n,session:s,dialect:o,withList:a,distinct:l}){super();G(this,"_");G(this,"config");G(this,"joinsNotNullableMap");G(this,"tableName");G(this,"isPartialSelect");G(this,"session");G(this,"dialect");G(this,"leftJoin",this.createJoin("left"));G(this,"rightJoin",this.createJoin("right"));G(this,"innerJoin",this.createJoin("inner"));G(this,"fullJoin",this.createJoin("full"));G(this,"union",this.createSetOperator("union",!1));G(this,"unionAll",this.createSetOperator("union",!0));G(this,"intersect",this.createSetOperator("intersect",!1));G(this,"intersectAll",this.createSetOperator("intersect",!0));G(this,"except",this.createSetOperator("except",!1));G(this,"exceptAll",this.createSetOperator("except",!0));this.config={withList:a,table:e,fields:{...i},distinct:l,setOperators:[]},this.isPartialSelect=n,this.session=s,this.dialect=o,this._={selectedFields:i},this.tableName=Wn(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}createJoin(e){return(i,n)=>{var a;const s=this.tableName,o=Wn(i);if(typeof o=="string"&&((a=this.config.joins)!=null&&a.some(l=>l.alias===o)))throw new Error(`Alias "${o}" is already used in this query`);if(!this.isPartialSelect&&(Object.keys(this.joinsNotNullableMap).length===1&&typeof s=="string"&&(this.config.fields={[s]:this.config.fields}),typeof o=="string"&&!lt(i,Ft))){const l=lt(i,Or)?i._.selectedFields:lt(i,Sn)?i[He].selectedFields:i[Tt.Symbol.Columns];this.config.fields[o]=l}if(typeof n=="function"&&(n=n(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.joins||(this.config.joins=[]),this.config.joins.push({on:n,table:i,joinType:e,alias:o}),typeof o=="string")switch(e){case"left":{this.joinsNotNullableMap[o]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!0;break}case"inner":{this.joinsNotNullableMap[o]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([l])=>[l,!1])),this.joinsNotNullableMap[o]=!1;break}}return this}}createSetOperator(e,i){return n=>{const s=typeof n=="function"?n(cR()):n;if(!Vf(this.getSelectedFields(),s.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return this.config.setOperators.push({type:e,isAll:i,rightSelect:s}),this}}addSetOperators(e){return this.config.setOperators.push(...e),this}where(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.where=e,this}having(e){return typeof e=="function"&&(e=e(new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))),this.config.having=e,this}groupBy(...e){if(typeof e[0]=="function"){const i=e[0](new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"alias",sqlBehavior:"sql"})));this.config.groupBy=Array.isArray(i)?i:[i]}else this.config.groupBy=e;return this}orderBy(...e){if(typeof e[0]=="function"){const i=e[0](new Proxy(this.config.fields,new Je({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),n=Array.isArray(i)?i:[i];this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=n:this.config.orderBy=n}else{const i=e;this.config.setOperators.length>0?this.config.setOperators.at(-1).orderBy=i:this.config.orderBy=i}return this}limit(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).limit=e:this.config.limit=e,this}offset(e){return this.config.setOperators.length>0?this.config.setOperators.at(-1).offset=e:this.config.offset=e,this}for(e,i={}){return this.config.lockingClause={strength:e,config:i},this}getSQL(){return this.dialect.buildSelectQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}as(e){return new Proxy(new Or(this.getSQL(),this.config.fields,e),new Je({alias:e,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}getSelectedFields(){return new Proxy(this.config.fields,new Je({alias:this.tableName,sqlAliasedBehavior:"alias",sqlBehavior:"error"}))}$dynamic(){return this}}G(Lw,tg,"PgSelectQueryBuilder");var rg,ig;class Hf extends(ig=Lw,rg=xt,ig){constructor(){super(...arguments);G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)))}_prepare(e){const{session:i,config:n,dialect:s,joinsNotNullableMap:o,authToken:a}=this;if(!i)throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");return Pr.startActiveSpan("drizzle.prepareQuery",()=>{const l=os(n.fields),u=i.prepareQuery(s.sqlToQuery(this.getSQL()),l,e,!0);return u.joinsNotNullableMap=o,u.setToken(a)})}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}G(Hf,rg,"PgSelect");KD(Hf,[Tn]);function oo(r,t){return(e,i,...n)=>{const s=[i,...n].map(o=>({type:r,isAll:t,rightSelect:o}));for(const o of s)if(!Vf(e.getSelectedFields(),o.rightSelect.getSelectedFields()))throw new Error("Set operator error (union / intersect / except): selected fields are not the same or are in a different order");return e.addSetOperators(s)}}const cR=()=>({union:hR,unionAll:fR,intersect:dR,intersectAll:pR,except:mR,exceptAll:yR}),hR=oo("union",!1),fR=oo("union",!0),dR=oo("intersect",!1),pR=oo("intersect",!0),mR=oo("except",!1),yR=oo("except",!0);var ng;ng=xt;class Xf{constructor(t){G(this,"dialect");G(this,"dialectConfig");G(this,"$with",(t,e)=>{const i=this;return{as:s=>(typeof s=="function"&&(s=s(i)),new Proxy(new jf(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new Je({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});this.dialect=lt(t,Bo)?t:void 0,this.dialectConfig=lt(t,Bo)?void 0:t}with(...t){const e=this;function i(o){return new Sr({fields:o??void 0,session:void 0,dialect:e.getDialect(),withList:t})}function n(o){return new Sr({fields:o??void 0,session:void 0,dialect:e.getDialect(),distinct:!0})}function s(o,a){return new Sr({fields:a??void 0,session:void 0,dialect:e.getDialect(),distinct:{on:o}})}return{select:i,selectDistinct:n,selectDistinctOn:s}}select(t){return new Sr({fields:t??void 0,session:void 0,dialect:this.getDialect()})}selectDistinct(t){return new Sr({fields:t??void 0,session:void 0,dialect:this.getDialect(),distinct:!0})}selectDistinctOn(t,e){return new Sr({fields:e??void 0,session:void 0,dialect:this.getDialect(),distinct:{on:t}})}getDialect(){return this.dialect||(this.dialect=new Bo(this.dialectConfig)),this.dialect}}G(Xf,ng,"PgQueryBuilder");var sg;sg=xt;class Oh{constructor(t,e,i,n,s){G(this,"authToken");this.table=t,this.session=e,this.dialect=i,this.withList=n,this.overridingSystemValue_=s}setToken(t){return this.authToken=t,this}overridingSystemValue(){return this.overridingSystemValue_=!0,this}values(t){if(t=Array.isArray(t)?t:[t],t.length===0)throw new Error("values() must be called with at least one value");const e=t.map(i=>{const n={},s=this.table[Tt.Symbol.Columns];for(const o of Object.keys(i)){const a=i[o];n[o]=lt(a,Ft)?a:new Wi(a,s[o])}return n});return new Fh(this.table,e,this.session,this.dialect,this.withList,!1,this.overridingSystemValue_).setToken(this.authToken)}select(t){const e=typeof t=="function"?t(new Xf):t;if(!lt(e,Ft)&&!Vf(this.table[Ih],e._.selectedFields))throw new Error("Insert select error: selected fields are not the same or are in a different order compared to the table definition");return new Fh(this.table,e,this.session,this.dialect,this.withList,!0)}}G(Oh,sg,"PgInsertBuilder");var og,ag;class Fh extends(ag=Tn,og=xt,ag){constructor(e,i,n,s,o,a,l){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=n,this.dialect=s,this.config={table:e,values:i,withList:o,select:a,overridingSystemValue_:l}}returning(e=this.config.table[Tt.Symbol.Columns]){return this.config.returningFields=e,this.config.returning=os(e),this}onConflictDoNothing(e={}){if(e.target===void 0)this.config.onConflict=X`do nothing`;else{let i="";i=Array.isArray(e.target)?e.target.map(s=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(s))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target));const n=e.where?X` where ${e.where}`:void 0;this.config.onConflict=X`(${X.raw(i)})${n} do nothing`}return this}onConflictDoUpdate(e){if(e.where&&(e.targetWhere||e.setWhere))throw new Error('You cannot use both "where" and "targetWhere"/"setWhere" at the same time - "where" is deprecated, use "targetWhere" or "setWhere" instead.');const i=e.where?X` where ${e.where}`:void 0,n=e.targetWhere?X` where ${e.targetWhere}`:void 0,s=e.setWhere?X` where ${e.setWhere}`:void 0,o=this.dialect.buildUpdateSet(this.config.table,ww(this.config.table,e.set));let a="";return a=Array.isArray(e.target)?e.target.map(l=>this.dialect.escapeName(this.dialect.casing.getColumnCasing(l))).join(","):this.dialect.escapeName(this.dialect.casing.getColumnCasing(e.target)),this.config.onConflict=X`(${X.raw(a)})${n} do update set ${o}${i}${s}`,this}getSQL(){return this.dialect.buildInsertQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(Fh,og,"PgInsert");var lg,ug;class Bw extends(ug=Tn,lg=xt,ug){constructor(e,i,n){super();G(this,"config");G(this,"authToken");G(this,"execute",e=>Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(e,this.authToken)));this.session=i,this.dialect=n,this.config={view:e}}concurrently(){if(this.config.withNoData!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.concurrently=!0,this}withNoData(){if(this.config.concurrently!==void 0)throw new Error("Cannot use concurrently and withNoData together");return this.config.withNoData=!0,this}getSQL(){return this.dialect.buildRefreshMaterializedViewQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),void 0,e,!0))}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}}G(Bw,lg,"PgRefreshMaterializedView");var cg;cg=xt;class Ph{constructor(t,e,i,n){G(this,"authToken");this.table=t,this.session=e,this.dialect=i,this.withList=n}setToken(t){return this.authToken=t,this}set(t){return new kw(this.table,ww(this.table,t),this.session,this.dialect,this.withList).setToken(this.authToken)}}G(Ph,cg,"PgUpdateBuilder");var hg,fg;class kw extends(fg=Tn,hg=xt,fg){constructor(e,i,n,s,o){super();G(this,"config");G(this,"tableName");G(this,"joinsNotNullableMap");G(this,"leftJoin",this.createJoin("left"));G(this,"rightJoin",this.createJoin("right"));G(this,"innerJoin",this.createJoin("inner"));G(this,"fullJoin",this.createJoin("full"));G(this,"authToken");G(this,"execute",e=>this._prepare().execute(e,this.authToken));this.session=n,this.dialect=s,this.config={set:i,table:e,withList:o,joins:[]},this.tableName=Wn(e),this.joinsNotNullableMap=typeof this.tableName=="string"?{[this.tableName]:!0}:{}}from(e){const i=e,n=Wn(i);return typeof n=="string"&&(this.joinsNotNullableMap[n]=!0),this.config.from=i,this}getTableLikeFields(e){return lt(e,Br)?e[Tt.Symbol.Columns]:lt(e,Or)?e._.selectedFields:e[He].selectedFields}createJoin(e){return(i,n)=>{const s=Wn(i);if(typeof s=="string"&&this.config.joins.some(o=>o.alias===s))throw new Error(`Alias "${s}" is already used in this query`);if(typeof n=="function"){const o=this.config.from&&!lt(this.config.from,Ft)?this.getTableLikeFields(this.config.from):void 0;n=n(new Proxy(this.config.table[Tt.Symbol.Columns],new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})),o&&new Proxy(o,new Je({sqlAliasedBehavior:"sql",sqlBehavior:"sql"})))}if(this.config.joins.push({on:n,table:i,joinType:e,alias:s}),typeof s=="string")switch(e){case"left":{this.joinsNotNullableMap[s]=!1;break}case"right":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!0;break}case"inner":{this.joinsNotNullableMap[s]=!0;break}case"full":{this.joinsNotNullableMap=Object.fromEntries(Object.entries(this.joinsNotNullableMap).map(([o])=>[o,!1])),this.joinsNotNullableMap[s]=!1;break}}return this}}where(e){return this.config.where=e,this}returning(e){if(!e&&(e=Object.assign({},this.config.table[Tt.Symbol.Columns]),this.config.from)){const i=Wn(this.config.from);if(typeof i=="string"&&this.config.from&&!lt(this.config.from,Ft)){const n=this.getTableLikeFields(this.config.from);e[i]=n}for(const n of this.config.joins){const s=Wn(n.table);if(typeof s=="string"&&!lt(n.table,Ft)){const o=this.getTableLikeFields(n.table);e[s]=o}}}return this.config.returningFields=e,this.config.returning=os(e),this}getSQL(){return this.dialect.buildUpdateQuery(this.config)}toSQL(){const{typings:e,...i}=this.dialect.sqlToQuery(this.getSQL());return i}_prepare(e){const i=this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()),this.config.returning,e,!0);return i.joinsNotNullableMap=this.joinsNotNullableMap,i}prepare(e){return this._prepare(e)}setToken(e){return this.authToken=e,this}getSelectedFields(){return this.config.returningFields?new Proxy(this.config.returningFields,new Je({alias:qn(this.config.table),sqlAliasedBehavior:"alias",sqlBehavior:"error"})):void 0}$dynamic(){return this}}G(kw,hg,"PgUpdate");var dg,pg,mg;const Uo=class Uo extends(mg=Ft,pg=xt,dg=Symbol.toStringTag,mg){constructor(e){super(Uo.buildEmbeddedCount(e.source,e.filters).queryChunks);G(this,"sql");G(this,"token");G(this,dg,"PgCountBuilder");G(this,"session");this.params=e,this.mapWith(Number),this.session=e.session,this.sql=Uo.buildCount(e.source,e.filters)}static buildEmbeddedCount(e,i){return X`(select count(*) from ${e}${X.raw(" where ").if(i)}${i})`}static buildCount(e,i){return X`select count(*) as count from ${e}${X.raw(" where ").if(i)}${i};`}setToken(e){return this.token=e,this}then(e,i){return Promise.resolve(this.session.count(this.sql,this.token)).then(e,i)}catch(e){return this.then(void 0,e)}finally(e){return this.then(i=>(e==null||e(),i),i=>{throw e==null||e(),i})}};G(Uo,pg,"PgCountBuilder");let Mh=Uo;var yg;yg=xt;class Uw{constructor(t,e,i,n,s,o,a){this.fullSchema=t,this.schema=e,this.tableNamesMap=i,this.table=n,this.tableConfig=s,this.dialect=o,this.session=a}findMany(t){return new Dh(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t||{},"many")}findFirst(t){return new Dh(this.fullSchema,this.schema,this.tableNamesMap,this.table,this.tableConfig,this.dialect,this.session,t?{...t,limit:1}:{limit:1},"first")}}G(Uw,yg,"PgRelationalQueryBuilder");var gg,vg;class Dh extends(vg=Tn,gg=xt,vg){constructor(e,i,n,s,o,a,l,u,c){super();G(this,"authToken");this.fullSchema=e,this.schema=i,this.tableNamesMap=n,this.table=s,this.tableConfig=o,this.dialect=a,this.session=l,this.config=u,this.mode=c}_prepare(e){return Pr.startActiveSpan("drizzle.prepareQuery",()=>{const{query:i,builtQuery:n}=this._toSQL();return this.session.prepareQuery(n,void 0,e,!0,(s,o)=>{const a=s.map(l=>Ch(this.schema,this.tableConfig,l,i.selection,o));return this.mode==="first"?a[0]:a})})}prepare(e){return this._prepare(e)}_getQuery(){return this.dialect.buildRelationalQueryWithoutPK({fullSchema:this.fullSchema,schema:this.schema,tableNamesMap:this.tableNamesMap,table:this.table,tableConfig:this.tableConfig,queryConfig:this.config,tableAlias:this.tableConfig.tsName})}getSQL(){return this._getQuery().sql}_toSQL(){const e=this._getQuery(),i=this.dialect.sqlToQuery(e.sql);return{query:e,builtQuery:i}}toSQL(){return this._toSQL().builtQuery}setToken(e){return this.authToken=e,this}execute(){return Pr.startActiveSpan("drizzle.operation",()=>this._prepare().execute(void 0,this.authToken))}}G(Dh,gg,"PgRelationalQuery");var _g,bg;class zw extends(bg=Tn,_g=xt,bg){constructor(t,e,i,n){super(),this.execute=t,this.sql=e,this.query=i,this.mapBatchResult=n}getSQL(){return this.sql}getQuery(){return this.query}mapResult(t,e){return e?this.mapBatchResult(t):t}_prepare(){return this}isResponseInArrayMode(){return!1}}G(zw,_g,"PgRaw");var wg;wg=xt;class Yf{constructor(t,e,i){G(this,"query");G(this,"$with",(t,e)=>{const i=this;return{as:s=>(typeof s=="function"&&(s=s(new Xf(i.dialect))),new Proxy(new jf(s.getSQL(),e??("getSelectedFields"in s?s.getSelectedFields()??{}:{}),t,!0),new Je({alias:t,sqlAliasedBehavior:"alias",sqlBehavior:"error"})))}});G(this,"authToken");if(this.dialect=t,this.session=e,this._=i?{schema:i.schema,fullSchema:i.fullSchema,tableNamesMap:i.tableNamesMap,session:e}:{schema:void 0,fullSchema:{},tableNamesMap:{},session:e},this.query={},this._.schema)for(const[n,s]of Object.entries(this._.schema))this.query[n]=new Uw(i.fullSchema,this._.schema,this._.tableNamesMap,i.fullSchema[n],s,t,e)}$count(t,e){return new Mh({source:t,filters:e,session:this.session})}with(...t){const e=this;function i(u){return new Sr({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t})}function n(u){return new Sr({fields:u??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:!0})}function s(u,c){return new Sr({fields:c??void 0,session:e.session,dialect:e.dialect,withList:t,distinct:{on:u}})}function o(u){return new Ph(u,e.session,e.dialect,t)}function a(u){return new Oh(u,e.session,e.dialect,t)}function l(u){return new Ah(u,e.session,e.dialect,t)}return{select:i,selectDistinct:n,selectDistinctOn:s,update:o,insert:a,delete:l}}select(t){return new Sr({fields:t??void 0,session:this.session,dialect:this.dialect})}selectDistinct(t){return new Sr({fields:t??void 0,session:this.session,dialect:this.dialect,distinct:!0})}selectDistinctOn(t,e){return new Sr({fields:e??void 0,session:this.session,dialect:this.dialect,distinct:{on:t}})}update(t){return new Ph(t,this.session,this.dialect)}insert(t){return new Oh(t,this.session,this.dialect)}delete(t){return new Ah(t,this.session,this.dialect)}refreshMaterializedView(t){return new Bw(t,this.session,this.dialect)}execute(t){const e=typeof t=="string"?X.raw(t):t.getSQL(),i=this.dialect.sqlToQuery(e),n=this.session.prepareQuery(i,void 0,void 0,!1);return new zw(()=>n.execute(void 0,this.authToken),e,i,s=>n.mapResult(s,!0))}transaction(t,e){return this.session.transaction(t,e)}}G(Yf,wg,"PgDatabase");var xg;xg=xt;class jw{constructor(t){G(this,"authToken");G(this,"joinsNotNullableMap");this.query=t}getQuery(){return this.query}mapResult(t,e){return t}setToken(t){return this.authToken=t,this}}G(jw,xg,"PgPreparedQuery");var Sg;Sg=xt;class $w{constructor(t){this.dialect=t}execute(t,e){return Pr.startActiveSpan("drizzle.operation",()=>Pr.startActiveSpan("drizzle.prepareQuery",()=>this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1)).setToken(e).execute(void 0,e))}all(t){return this.prepareQuery(this.dialect.sqlToQuery(t),void 0,void 0,!1).all()}async count(t,e){const i=await this.execute(t,e);return Number(i[0].count)}}G($w,Sg,"PgSession");var Tg,Ig;class Vw extends(Ig=Yf,Tg=xt,Ig){constructor(t,e,i,n=0){super(t,e,i),this.schema=i,this.nestedIndex=n}rollback(){throw new yw}getTransactionConfigSQL(t){const e=[];return t.isolationLevel&&e.push(`isolation level ${t.isolationLevel}`),t.accessMode&&e.push(t.accessMode),typeof t.deferrable=="boolean"&&e.push(t.deferrable?"deferrable":"not deferrable"),X.raw(e.join(" "))}setTransaction(t){return this.session.execute(X`set transaction ${this.getTransactionConfigSQL(t)}`)}}G(Vw,Tg,"PgTransaction");function Om(r){return typeof r=="string"&&/^true$/i.test(r)}function gR(r){const t={scheme:"duckdb-wasm:"},e=new URL(r);if(!e.protocol.startsWith("duckdb-wasm:"))throw new Error(`Expected scheme to be "duckdb-wasm:" but got "${e.protocol}"`);e.searchParams.get("bundles")==="import-url"&&(t.bundles="import-url");const i=e.searchParams.get("logger");i&&Om(i)&&(t.logger=!0);const n=e.searchParams.get("storage");switch(n){case ra.ORIGIN_PRIVATE_FS:{e.host.length>0&&console.warn(`Host "${e.host}" will be ignored while using Origin Private FS`);const s=e.searchParams.get("write");t.storage={type:ra.ORIGIN_PRIVATE_FS,path:e.pathname.startsWith("/")?e.pathname.slice(1):e.pathname,...s&&Om(s)&&{accessMode:T0.READ_WRITE}};break}case null:break;default:console.warn(`Unknown storage type "${n}"`);break}return t}var Eg,Cg;class Gw extends(Cg=jw,Eg=xt,Cg){constructor(t,e,i,n,s,o){super({sql:e,params:i}),this.client=t,this.queryString=e,this.params=i,this.logger=n,this.fields=s,this.customResultMapper=o}async execute(t={}){const e=Em(this.params,t);this.logger.logQuery(this.queryString,e);const{fields:i,queryString:n,client:s,customResultMapper:o}=this,a=await s;return a.query(n,e)}async all(t={}){const e=Em(this.params,t);return this.logger.logQuery(this.queryString,e),(await this.client).query(this.queryString,e)}}G(Gw,Eg,"DuckDBWasmPreparedQuery");var Ag,Og;const Yl=class Yl extends(Og=$w,Ag=xt,Og){constructor(e,i,n,s={}){super(i);G(this,"logger");this.client=e,this.schema=n,this.options=s,this.logger=s.logger??new bw}prepareQuery(e,i,n,s,o){return new Gw(this.client,e.sql,e.params,this.logger,i,o)}async query(e,i){return this.logger.logQuery(e,i),(await this.client).query(e,i)}async queryObjects(e,i){return this.logger.logQuery(e,i),(await this.client).query(e,i)}transaction(e,i){return xD(this.client,async n=>{const s=new Yl(n,this.dialect,this.schema,this.options),o=new Rh(this.dialect,s,this.schema);return i&&await o.setTransaction(i),e(o)})}};G(Yl,Ag,"DuckDBWasmSession");let Gl=Yl;var Fg,Pg;const ql=class ql extends(Pg=Vw,Fg=xt,Pg){constructor(e,i,n,s=0){super(e,i,n,s);G(this,"dialect");G(this,"session");this.dialect=e,this.session=i}async transaction(e){return SD(this.session.client,"",async i=>{const n=new Gl(i,this.dialect,this.schema,this.session.options),s=new ql(this.dialect,n,this.schema);return e(s)})}};G(ql,Fg,"DuckDBWasmTransaction");let Rh=ql;var Mg,Dg;class Ww extends(Dg=Yf,Mg=xt,Dg){}G(Ww,Mg,"DuckDBWasmDatabase");function ko(r,t={}){const e=new Bo({casing:t.casing});let i;t.logger===!0?i=new _w:t.logger!==!1&&(i=t.logger);let n;if(t.schema){const a=rR(t.schema,oR);n={fullSchema:t.schema,schema:a.tables,tableNamesMap:a.tableNamesMap}}const s=new Gl(r,e,n,{logger:i}),o=new Ww(e,s,n);return o.$client=r,o}function Fm(r,t){const e=gR(r);let i;return e.bundles==="import-url"?i=(async()=>{const s=await Sh();switch(s){case"browser":return(await ln(async()=>{const{getImportUrlBundles:o}=await import("./import-url-browser-CPN8ipMD.js");return{getImportUrlBundles:o}},__vite__mapDeps([3,4]))).getImportUrlBundles();case"node":return await(await ln(async()=>{const{getImportUrlBundles:o}=await import("./import-url-node-BfNoxhRr.js");return{getImportUrlBundles:o}},__vite__mapDeps([5,4]))).getImportUrlBundles();default:throw new Error(`Unsupported environment: "${s}"`)}})():i=(async()=>{const s=await Sh();switch(s){case"browser":return(await ln(async()=>{const{getBundles:o}=await import("./default-browser-BrgSDbLD.js");return{getBundles:o}},[])).getBundles();case"node":return await(await ln(async()=>{const{getBundles:o}=await import("./default-node-E6uRkI3P.js");return{getBundles:o}},__vite__mapDeps([0,1,2]))).getBundles();default:throw new Error(`Unsupported environment: "${s}"`)}})(),ko(hw({bundles:i,logger:e.logger?new I0:void 0,storage:e.storage}),t)}function Pm(...r){if(typeof r[0]=="string")return Fm(r[0],r[1]);if(JD(r[0])){const{connection:t,client:e,...i}=r[0];if(e)return ko(e,i);if(typeof t=="string")return Fm(t,i);if(typeof t>"u")throw new Error("connection option is required");return ko(hw({bundles:t.bundles,logger:t.logger,storage:t.storage}),i)}return ko(r[0],r[1])}(r=>{function t(e){return ko({options:{parsers:{},serializers:{}}},e)}r.mock=t})(Pm||(Pm={}));export{L1 as A,TR as D,xR as I,pC as J,eI as L,_c as M,wR as T,fi as a,Re as b,Pm as d,sa as e,SR as l};
diff --git a/assets/Textarea.vue_vue_type_script_setup_true_lang-DYkvi4WW.js b/assets/Textarea.vue_vue_type_script_setup_true_lang-CSJMxNAW.js
similarity index 71%
rename from assets/Textarea.vue_vue_type_script_setup_true_lang-DYkvi4WW.js
rename to assets/Textarea.vue_vue_type_script_setup_true_lang-CSJMxNAW.js
index 8aaf89b3b97e0f6f60c620dafed88c7c96543af1..3504ac6ff159217650aaf76cea1e65833152e61c 100644
--- a/assets/Textarea.vue_vue_type_script_setup_true_lang-DYkvi4WW.js
+++ b/assets/Textarea.vue_vue_type_script_setup_true_lang-CSJMxNAW.js
@@ -1 +1 @@
-import{_ as u}from"./Basic.vue_vue_type_script_setup_true_lang-Xbv52Zmk.js";import{d as t,bL as r,m as n,o as d}from"./index-5LjD1Eoi.js";const p=t({__name:"Textarea",props:{modelValue:{default:""},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=r(o,"modelValue");return(s,a)=>(d(),n(u,{modelValue:e.value,"onUpdate:modelValue":a[0]||(a[0]=l=>e.value=l),border:"neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700",transition:"all duration-250 ease-in-out",bg:"neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900","rounded-lg":"","px-3":"","py-2":"","text-sm":"","outline-none":""},null,8,["modelValue"]))}});export{p as _};
+import{_ as u}from"./Basic.vue_vue_type_script_setup_true_lang-Csgn84Sg.js";import{d as t,bL as r,m as n,o as d}from"./index-DCMFRrFG.js";const p=t({__name:"Textarea",props:{modelValue:{default:""},modelModifiers:{}},emits:["update:modelValue"],setup(o){const e=r(o,"modelValue");return(s,a)=>(d(),n(u,{modelValue:e.value,"onUpdate:modelValue":a[0]||(a[0]=l=>e.value=l),border:"neutral-100 dark:neutral-800 solid 2 focus:neutral-200 dark:focus:neutral-700",transition:"all duration-250 ease-in-out",bg:"neutral-100 dark:neutral-800 focus:neutral-50 dark:focus:neutral-900","rounded-lg":"","px-3":"","py-2":"","text-sm":"","outline-none":""},null,8,["modelValue"]))}});export{p as _};
diff --git a/assets/TransitionVertical.vue_vue_type_script_setup_true_lang-D3UjhNfr.js b/assets/TransitionVertical.vue_vue_type_script_setup_true_lang-Yuy6gf0o.js
similarity index 93%
rename from assets/TransitionVertical.vue_vue_type_script_setup_true_lang-D3UjhNfr.js
rename to assets/TransitionVertical.vue_vue_type_script_setup_true_lang-Yuy6gf0o.js
index ff08b1580d0633eebde7c019019796d202878f52..8663f2807e299b1e7779ab594e33eee301fc5251 100644
--- a/assets/TransitionVertical.vue_vue_type_script_setup_true_lang-D3UjhNfr.js
+++ b/assets/TransitionVertical.vue_vue_type_script_setup_true_lang-Yuy6gf0o.js
@@ -1 +1 @@
-import{d as m,m as T,o as l,bE as B,E as b,B as v}from"./index-5LjD1Eoi.js";const n="0px",E=m({__name:"TransitionVertical",props:{duration:{default:250},easingEnter:{default:"ease-in-out"},easingLeave:{default:"ease-in-out"},opacityClosed:{default:0},opacityOpened:{default:1}},setup(c){const r=c;function p(o){return{height:o.style.height,width:o.style.width,position:o.style.position,visibility:o.style.visibility,overflow:o.style.overflow,paddingTop:o.style.paddingTop,paddingBottom:o.style.paddingBottom,borderTopWidth:o.style.borderTopWidth,borderBottomWidth:o.style.borderBottomWidth,marginTop:o.style.marginTop,marginBottom:o.style.marginBottom}}function y(o,t){const{width:i}=getComputedStyle(o);o.style.width=i,o.style.position="absolute",o.style.visibility="hidden",o.style.height="";const{height:s}=getComputedStyle(o);return o.style.width=t.width,o.style.position=t.position,o.style.visibility=t.visibility,o.style.height=n,o.style.overflow="hidden",t.height&&t.height!==n?t.height:s}function h(o,t,i,s,d){const e=o.animate(s,d);o.style.height=t.height,e.onfinish=()=>{o.style.overflow=t.overflow,i()}}function g(o,t){return[{height:n,opacity:r.opacityClosed,paddingTop:n,paddingBottom:n,borderTopWidth:n,borderBottomWidth:n,marginTop:n,marginBottom:n},{height:o,opacity:r.opacityOpened,paddingTop:t.paddingTop,paddingBottom:t.paddingBottom,borderTopWidth:t.borderTopWidth,borderBottomWidth:t.borderBottomWidth,marginTop:t.marginTop,marginBottom:t.marginBottom}]}function u(o,t){const i=o,s=p(i),d=y(i,s),e=g(d,s),a={duration:r.duration,easing:r.easingEnter};h(i,s,t,e,a)}function f(o,t){const i=o,s=p(i),{height:d}=getComputedStyle(i);i.style.height=d,i.style.overflow="hidden";const e=g(d,s).reverse(),a={duration:r.duration,easing:r.easingLeave};h(i,s,t,e,a)}return(o,t)=>(l(),T(B,{css:!1,onEnter:u,onLeave:f},{default:b(()=>[v(o.$slots,"default")]),_:3}))}});export{E as _};
+import{d as m,m as T,o as l,bE as B,E as b,B as v}from"./index-DCMFRrFG.js";const n="0px",E=m({__name:"TransitionVertical",props:{duration:{default:250},easingEnter:{default:"ease-in-out"},easingLeave:{default:"ease-in-out"},opacityClosed:{default:0},opacityOpened:{default:1}},setup(c){const r=c;function p(o){return{height:o.style.height,width:o.style.width,position:o.style.position,visibility:o.style.visibility,overflow:o.style.overflow,paddingTop:o.style.paddingTop,paddingBottom:o.style.paddingBottom,borderTopWidth:o.style.borderTopWidth,borderBottomWidth:o.style.borderBottomWidth,marginTop:o.style.marginTop,marginBottom:o.style.marginBottom}}function y(o,t){const{width:i}=getComputedStyle(o);o.style.width=i,o.style.position="absolute",o.style.visibility="hidden",o.style.height="";const{height:s}=getComputedStyle(o);return o.style.width=t.width,o.style.position=t.position,o.style.visibility=t.visibility,o.style.height=n,o.style.overflow="hidden",t.height&&t.height!==n?t.height:s}function h(o,t,i,s,d){const e=o.animate(s,d);o.style.height=t.height,e.onfinish=()=>{o.style.overflow=t.overflow,i()}}function g(o,t){return[{height:n,opacity:r.opacityClosed,paddingTop:n,paddingBottom:n,borderTopWidth:n,borderBottomWidth:n,marginTop:n,marginBottom:n},{height:o,opacity:r.opacityOpened,paddingTop:t.paddingTop,paddingBottom:t.paddingBottom,borderTopWidth:t.borderTopWidth,borderBottomWidth:t.borderBottomWidth,marginTop:t.marginTop,marginBottom:t.marginBottom}]}function u(o,t){const i=o,s=p(i),d=y(i,s),e=g(d,s),a={duration:r.duration,easing:r.easingEnter};h(i,s,t,e,a)}function f(o,t){const i=o,s=p(i),{height:d}=getComputedStyle(i);i.style.height=d,i.style.overflow="hidden";const e=g(d,s).reverse(),a={duration:r.duration,easing:r.easingLeave};h(i,s,t,e,a)}return(o,t)=>(l(),T(B,{css:!1,onEnter:u,onLeave:f},{default:b(()=>[v(o.$slots,"default")]),_:3}))}});export{E as _};
diff --git a/assets/_...all_-CoqBSN50.js b/assets/_...all_-64lFrRuT.js
similarity index 63%
rename from assets/_...all_-CoqBSN50.js
rename to assets/_...all_-64lFrRuT.js
index e964aada8c4cace17513ec9f45fec87a3641a22e..27a6dc45765ae2b2534fa4d094cc5b95c40d072f 100644
--- a/assets/_...all_-CoqBSN50.js
+++ b/assets/_...all_-64lFrRuT.js
@@ -1 +1 @@
-import{bq as e,c,o as n}from"./index-5LjD1Eoi.js";const o={};function _(t,r){return n(),c("div",null," 404 - Page not found ")}const s=e(o,[["render",_]]);export{s as default};
+import{bq as e,c,o as n}from"./index-DCMFRrFG.js";const o={};function _(t,r){return n(),c("div",null," 404 - Page not found ")}const s=e(o,[["render",_]]);export{s as default};
diff --git a/assets/airi-card-BWkmdsVt.js b/assets/airi-card-DTE6eySa.js
similarity index 94%
rename from assets/airi-card-BWkmdsVt.js
rename to assets/airi-card-DTE6eySa.js
index 121544e06b282ab3afe923a4baed6012cde3add4..23bc0c3472920887f92b81c2fbb7a90c1dccffc0 100644
--- a/assets/airi-card-BWkmdsVt.js
+++ b/assets/airi-card-DTE6eySa.js
@@ -1,4 +1,4 @@
-import{v as W,bG as L,l as g,s as O,f as $,k as b,w as k}from"./index-5LjD1Eoi.js";import{e as D}from"./emotions-CAex_2dA.js";import{u as H}from"./consciousness-D7jKnAf3.js";import{u as N}from"./speech-BYL-UWPg.js";function q(a,u){return{role:"system",content:[a,D.map(n=>`- ${n}`).join(`
+import{v as W,bG as L,l as g,s as O,f as $,k as b,w as k}from"./index-DCMFRrFG.js";import{e as D}from"./emotions-CAex_2dA.js";import{u as H}from"./consciousness-DGPhIG2M.js";import{u as N}from"./speech-Bc-BAopv.js";function q(a,u){return{role:"system",content:[a,D.map(n=>`- ${n}`).join(`
`),u].join(`
`)}}const Q=W("airi-card",()=>{const a=L("airi-cards",new Map),u=L("airi-card-active-id","default"),n=g(()=>a.value.get(u.value)),P=H(),R=N(),{activeModel:l}=O(P),{activeSpeechVoiceId:m,activeSpeechModel:p}=O(R),B=s=>{const e=crypto.randomUUID();return a.value.set(e,f(s)),e},G=s=>{a.value.delete(s)},V=s=>a.value.get(s);function v(s){var t,r,i,c,d,h,_,y,S,x,C,M,I,w,E,A,T,U,j;const e="data"in s?(r=(t=s.data)==null?void 0:t.extensions)==null?void 0:r.airi:(i=s.extensions)==null?void 0:i.airi,o={consciousness:{model:l.value},speech:{model:p.value,voice_id:m.value}};return e?{modules:{consciousness:{model:((d=(c=e.modules)==null?void 0:c.consciousness)==null?void 0:d.model)??o.consciousness.model},speech:{model:((_=(h=e.modules)==null?void 0:h.speech)==null?void 0:_.model)??o.speech.model,voice_id:((S=(y=e.modules)==null?void 0:y.speech)==null?void 0:S.voice_id)??o.speech.voice_id,pitch:(C=(x=e.modules)==null?void 0:x.speech)==null?void 0:C.pitch,rate:(I=(M=e.modules)==null?void 0:M.speech)==null?void 0:I.rate,ssml:(E=(w=e.modules)==null?void 0:w.speech)==null?void 0:E.ssml,language:(T=(A=e.modules)==null?void 0:A.speech)==null?void 0:T.language},vrm:(U=e.modules)==null?void 0:U.vrm,live2d:(j=e.modules)==null?void 0:j.live2d},agents:e.agents??{}}:{modules:o,agents:{}}}function f(s){if("data"in s){const e=s;return{name:e.data.name,version:e.data.character_version??"1.0.0",description:e.data.description??"",creator:e.data.creator??"",notes:e.data.creator_notes??"",notesMultilingual:e.data.creator_notes_multilingual,personality:e.data.personality??"",scenario:e.data.scenario??"",greetings:[e.data.first_mes,...e.data.alternate_greetings??[]],greetingsGroupOnly:e.data.group_only_greetings??[],systemPrompt:e.data.system_prompt??"",postHistoryInstructions:e.data.post_history_instructions??"",messageExample:e.data.mes_example?e.data.mes_example.split(`
diff --git a/assets/alibaba-cloud-model-studio-Dsotw8H2.js b/assets/alibaba-cloud-model-studio-B6pk_ef1.js
similarity index 72%
rename from assets/alibaba-cloud-model-studio-Dsotw8H2.js
rename to assets/alibaba-cloud-model-studio-B6pk_ef1.js
index 5ad7093ee2b469622c1c33735597ece0805a82be..8c9f195f98cdfbd42ac2aa14af45608dd315cfc0 100644
--- a/assets/alibaba-cloud-model-studio-Dsotw8H2.js
+++ b/assets/alibaba-cloud-model-studio-B6pk_ef1.js
@@ -1 +1 @@
-import"./Stage.vue_vue_type_style_index_0_scoped_e41b35dc_lang-n5GTlT-F.js";import{d as x,r as m,s as k,k as F,l as V,f as $,w as v,m as B,o as E,E as y,b as c,u as i,a as I}from"./index-5LjD1Eoi.js";import"./three-vrm-animation.module-C_NwwsBw.js";import"./emotions-CAex_2dA.js";import{u as U}from"./providers-CIeQW25J.js";import{u as K}from"./speech-BYL-UWPg.js";import{_ as f}from"./FieldRange.vue_vue_type_script_setup_true_lang-DE5xbp80.js";/* empty css */import{_ as L,a as N}from"./SpeechProviderSettings.vue_vue_type_script_setup_true_lang-DSERPeKE.js";import{b as P}from"./route-block-B_A1xBdJ.js";import"./index-LHmcipjy.js";import"./ProviderBaseUrlInput.vue_vue_type_script_setup_true_lang-D9SKEJp0.js";import"./Collapsable.vue_vue_type_script_setup_true_lang-DpXv3nH9.js";import"./TransitionVertical.vue_vue_type_script_setup_true_lang-D3UjhNfr.js";import"./FieldInput.vue_vue_type_script_setup_true_lang-Bh1sgUoJ.js";import"./Input.vue_vue_type_script_setup_true_lang-DsX6dEPd.js";import"./ProviderApiKeyInput.vue_vue_type_script_setup_true_lang-C1ZXS-LL.js";import"./ProviderSettingsContainer.vue_vue_type_script_setup_true_lang-D7TMP6cs.js";const T={flex:"~ col gap-4"},o="alibaba-cloud-model-studio",_="cosyvoice-v1",z=x({__name:"alibaba-cloud-model-studio",setup(G){const u={speed:1},d=m(0),l=m(1),n=m(0),p=K(),a=U(),{providers:g}=k(a),{t:s}=F(),h=V(()=>{var e;return!!((e=g.value[o])!=null&&e.apiKey)}),w=V(()=>p.availableVoices[o]||[]);async function M(e,r,t){const b=a.getProviderInstance(o);if(!b)throw new Error("Failed to initialize speech provider");const C=a.getProviderConfig(o),S=C.model||_;return await p.speech(b,S,e,r,{...C,...u})}return $(async()=>{const e=a.getProviderConfig(o);await a.getProviderMetadata(o).validators.validateProviderConfig(e)?await p.loadVoicesForProvider(o):console.error("Failed to validate provider config",e)}),v(d,async()=>{const e=a.getProviderConfig(o);e.pitch=d.value}),v(l,async()=>{const e=a.getProviderConfig(o);e.speed=l.value}),v(n,async()=>{const e=a.getProviderConfig(o);e.volume=n.value}),v(g,async()=>{const e=a.getProviderConfig(o);await a.getProviderMetadata(o).validators.validateProviderConfig(e)?await p.loadVoicesForProvider(o):console.error("Failed to validate provider config",e)},{immediate:!0}),(e,r)=>(E(),B(i(N),{"provider-id":o,"default-model":_,"additional-settings":u},{"voice-settings":y(()=>[I("div",T,[c(i(f),{modelValue:d.value,"onUpdate:modelValue":r[0]||(r[0]=t=>d.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.pitch.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.pitch.description"),min:-100,max:100,step:1,"format-value":t=>`${t}%`},null,8,["modelValue","label","description","format-value"]),c(i(f),{modelValue:l.value,"onUpdate:modelValue":r[1]||(r[1]=t=>l.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.speed.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.speed.description"),min:.5,max:2,step:.01},null,8,["modelValue","label","description"]),c(i(f),{modelValue:n.value,"onUpdate:modelValue":r[2]||(r[2]=t=>n.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.volume.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.volume.description"),min:-100,max:100,step:1,"format-value":t=>`${t}%`},null,8,["modelValue","label","description","format-value"])])]),playground:y(()=>[c(i(L),{"available-voices":w.value,"generate-speech":M,"api-key-configured":h.value,"default-text":"Hello! This is a test of the ElevenLabs voice synthesis."},null,8,["available-voices","api-key-configured"])]),_:1}))}});typeof P=="function"&&P(z);export{z as default};
+import"./Stage.vue_vue_type_style_index_0_scoped_e41b35dc_lang-CCN_Z2a8.js";import{d as x,r as m,s as k,k as F,l as V,f as $,w as v,m as B,o as E,E as y,b as c,u as i,a as I}from"./index-DCMFRrFG.js";import"./three-vrm-animation.module-BGS11oHQ.js";import"./emotions-CAex_2dA.js";import{u as U}from"./providers-DHuI5XmA.js";import{u as K}from"./speech-Bc-BAopv.js";import{_ as f}from"./FieldRange.vue_vue_type_script_setup_true_lang-Ce59C1I_.js";/* empty css */import{_ as L,a as N}from"./SpeechProviderSettings.vue_vue_type_script_setup_true_lang-CAgqr_ja.js";import{b as P}from"./route-block-B_A1xBdJ.js";import"./index-LHmcipjy.js";import"./ProviderBaseUrlInput.vue_vue_type_script_setup_true_lang-AB_S7IzY.js";import"./Collapsable.vue_vue_type_script_setup_true_lang-DbG6TvxL.js";import"./TransitionVertical.vue_vue_type_script_setup_true_lang-Yuy6gf0o.js";import"./FieldInput.vue_vue_type_script_setup_true_lang-BvI8TIYI.js";import"./Input.vue_vue_type_script_setup_true_lang-GR9BTiwF.js";import"./ProviderApiKeyInput.vue_vue_type_script_setup_true_lang-DLiQJ2rl.js";import"./ProviderSettingsContainer.vue_vue_type_script_setup_true_lang-C908HZJI.js";const T={flex:"~ col gap-4"},o="alibaba-cloud-model-studio",_="cosyvoice-v1",z=x({__name:"alibaba-cloud-model-studio",setup(G){const u={speed:1},d=m(0),l=m(1),n=m(0),p=K(),a=U(),{providers:g}=k(a),{t:s}=F(),h=V(()=>{var e;return!!((e=g.value[o])!=null&&e.apiKey)}),w=V(()=>p.availableVoices[o]||[]);async function M(e,r,t){const b=a.getProviderInstance(o);if(!b)throw new Error("Failed to initialize speech provider");const C=a.getProviderConfig(o),S=C.model||_;return await p.speech(b,S,e,r,{...C,...u})}return $(async()=>{const e=a.getProviderConfig(o);await a.getProviderMetadata(o).validators.validateProviderConfig(e)?await p.loadVoicesForProvider(o):console.error("Failed to validate provider config",e)}),v(d,async()=>{const e=a.getProviderConfig(o);e.pitch=d.value}),v(l,async()=>{const e=a.getProviderConfig(o);e.speed=l.value}),v(n,async()=>{const e=a.getProviderConfig(o);e.volume=n.value}),v(g,async()=>{const e=a.getProviderConfig(o);await a.getProviderMetadata(o).validators.validateProviderConfig(e)?await p.loadVoicesForProvider(o):console.error("Failed to validate provider config",e)},{immediate:!0}),(e,r)=>(E(),B(i(N),{"provider-id":o,"default-model":_,"additional-settings":u},{"voice-settings":y(()=>[I("div",T,[c(i(f),{modelValue:d.value,"onUpdate:modelValue":r[0]||(r[0]=t=>d.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.pitch.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.pitch.description"),min:-100,max:100,step:1,"format-value":t=>`${t}%`},null,8,["modelValue","label","description","format-value"]),c(i(f),{modelValue:l.value,"onUpdate:modelValue":r[1]||(r[1]=t=>l.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.speed.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.speed.description"),min:.5,max:2,step:.01},null,8,["modelValue","label","description"]),c(i(f),{modelValue:n.value,"onUpdate:modelValue":r[2]||(r[2]=t=>n.value=t),label:i(s)("settings.pages.providers.provider.common.fields.field.volume.label"),description:i(s)("settings.pages.providers.provider.common.fields.field.volume.description"),min:-100,max:100,step:1,"format-value":t=>`${t}%`},null,8,["modelValue","label","description","format-value"])])]),playground:y(()=>[c(i(L),{"available-voices":w.value,"generate-speech":M,"api-key-configured":h.value,"default-text":"Hello! This is a test of the ElevenLabs voice synthesis."},null,8,["available-voices","api-key-configured"])]),_:1}))}});typeof P=="function"&&P(z);export{z as default};
diff --git a/assets/anthropic-Bb59KvNZ.js b/assets/anthropic-BqfnlV64.js
similarity index 79%
rename from assets/anthropic-Bb59KvNZ.js
rename to assets/anthropic-BqfnlV64.js
index 87aa14925807921d6942ad73ffc6008a39643da8..4e11876e9141c59b5d30c4e3dc7d11c6d9aae046 100644
--- a/assets/anthropic-Bb59KvNZ.js
+++ b/assets/anthropic-BqfnlV64.js
@@ -1 +1 @@
-import"./Stage.vue_vue_type_style_index_0_scoped_e41b35dc_lang-n5GTlT-F.js";import{d as S,k as x,h as U,s as w,l as v,f as V,w as C,m as K,o as R,E as u,a as i,b as l,bN as p,u as a}from"./index-5LjD1Eoi.js";import"./three-vrm-animation.module-C_NwwsBw.js";import"./emotions-CAex_2dA.js";import{u as N}from"./providers-CIeQW25J.js";/* empty css */import{_ as O,a as $}from"./ProviderBaseUrlInput.vue_vue_type_script_setup_true_lang-D9SKEJp0.js";import{_ as A}from"./ProviderApiKeyInput.vue_vue_type_script_setup_true_lang-C1ZXS-LL.js";import{_ as I,a as B}from"./ProviderSettingsContainer.vue_vue_type_script_setup_true_lang-D7TMP6cs.js";import{_ as T}from"./ProviderSettingsLayout.vue_vue_type_script_setup_true_lang-BTE92S8w.js";import{b as _}from"./route-block-B_A1xBdJ.js";import"./index-LHmcipjy.js";import"./Collapsable.vue_vue_type_script_setup_true_lang-DpXv3nH9.js";import"./TransitionVertical.vue_vue_type_script_setup_true_lang-D3UjhNfr.js";import"./FieldInput.vue_vue_type_script_setup_true_lang-Bh1sgUoJ.js";import"./Input.vue_vue_type_script_setup_true_lang-DsX6dEPd.js";const e="anthropic",z=S({__name:"anthropic",setup(M){const{t:c}=x(),g=U(),h=N(),{providers:o}=w(h),m=v(()=>h.getProviderMetadata(e)),s=v({get:()=>{var t;return((t=o.value[e])==null?void 0:t.apiKey)||""},set:t=>{o.value[e]||(o.value[e]={}),o.value[e].apiKey=t}}),n=v({get:()=>{var t;return((t=o.value[e])==null?void 0:t.baseUrl)||"https://api.anthropic.com/v1/"},set:t=>{o.value[e]||(o.value[e]={}),o.value[e].baseUrl=t}});V(()=>{var t,r;o.value[e]||(o.value[e]={baseUrl:"https://api.anthropic.com/v1/"}),s.value=((t=o.value[e])==null?void 0:t.apiKey)||"",n.value=((r=o.value[e])==null?void 0:r.baseUrl)||"https://api.anthropic.com/v1/"}),C([s,n],()=>{o.value[e]={...o.value[e],apiKey:s.value,baseUrl:n.value||"https://api.anthropic.com/v1/"}});function y(){o.value[e]={baseUrl:"https://api.anthropic.com/v1/"}}return(t,r)=>{var f,b;return R(),K(a(T),{"provider-name":((f=m.value)==null?void 0:f.localizedName)||"Anthropic | Claude","provider-icon":(b=m.value)==null?void 0:b.icon,"on-back":()=>a(g).back()},{default:u(()=>[r[2]||(r[2]=i("div",{bg:"orange-50 dark:orange-900/20","rounded-xl":"","p-4":"",flex:"~ col gap-3"},[i("h2",{"text-xl":"","font-bold":"",text:"orange-700 dark:orange-500"}," Before you start "),i("p",null,[p(" While Anthropic recently did announce that they are having a beta support for OpenAI SDK compatibility "),i("a",{underline:"",href:"https://docs.anthropic.com/en/api/openai-sdk"},"(you can read more here)"),p(", but due to the implementation details comes with "),i("a",{underline:"",href:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS"},"CORS"),p(" restrictions which not aligned with the OpenAI SDK, it's currently not possible to use this provider in the browser. ")]),i("p",null,[p(" If you do need to use this provider, you will need a dedicated proxy backend like a Serverless Function running on "),i("a",{underline:"",href:"https://workers.cloudflare.com/"},"Cloudflare Workers"),p(" or some CORS bypassing services to bypass the CORS restrictions. ")])],-1)),l(a(I),null,{default:u(()=>[l(a(B),{title:a(c)("settings.pages.providers.common.section.basic.title"),description:a(c)("settings.pages.providers.common.section.basic.description"),"on-reset":y},{default:u(()=>{var d;return[l(a(A),{modelValue:s.value,"onUpdate:modelValue":r[0]||(r[0]=k=>s.value=k),"provider-name":((d=m.value)==null?void 0:d.localizedName)||"Anthropic",placeholder:"sk-..."},null,8,["modelValue","provider-name"])]}),_:1},8,["title","description"]),l(a(O),{title:a(c)("settings.pages.providers.common.section.advanced.title")},{default:u(()=>[l(a($),{modelValue:n.value,"onUpdate:modelValue":r[1]||(r[1]=d=>n.value=d),placeholder:"https://api.anthropic.com/v1/"},null,8,["modelValue"])]),_:1},8,["title"])]),_:1})]),_:1},8,["provider-name","provider-icon","on-back"])}}});typeof _=="function"&&_(z);export{z as default};
+import"./Stage.vue_vue_type_style_index_0_scoped_e41b35dc_lang-CCN_Z2a8.js";import{d as S,k as x,h as U,s as w,l as v,f as V,w as C,m as K,o as R,E as u,a as i,b as l,bN as p,u as a}from"./index-DCMFRrFG.js";import"./three-vrm-animation.module-BGS11oHQ.js";import"./emotions-CAex_2dA.js";import{u as N}from"./providers-DHuI5XmA.js";/* empty css */import{_ as O,a as $}from"./ProviderBaseUrlInput.vue_vue_type_script_setup_true_lang-AB_S7IzY.js";import{_ as A}from"./ProviderApiKeyInput.vue_vue_type_script_setup_true_lang-DLiQJ2rl.js";import{_ as I,a as B}from"./ProviderSettingsContainer.vue_vue_type_script_setup_true_lang-C908HZJI.js";import{_ as T}from"./ProviderSettingsLayout.vue_vue_type_script_setup_true_lang-DAGrVFOe.js";import{b as _}from"./route-block-B_A1xBdJ.js";import"./index-LHmcipjy.js";import"./Collapsable.vue_vue_type_script_setup_true_lang-DbG6TvxL.js";import"./TransitionVertical.vue_vue_type_script_setup_true_lang-Yuy6gf0o.js";import"./FieldInput.vue_vue_type_script_setup_true_lang-BvI8TIYI.js";import"./Input.vue_vue_type_script_setup_true_lang-GR9BTiwF.js";const e="anthropic",z=S({__name:"anthropic",setup(M){const{t:c}=x(),g=U(),h=N(),{providers:o}=w(h),m=v(()=>h.getProviderMetadata(e)),s=v({get:()=>{var t;return((t=o.value[e])==null?void 0:t.apiKey)||""},set:t=>{o.value[e]||(o.value[e]={}),o.value[e].apiKey=t}}),n=v({get:()=>{var t;return((t=o.value[e])==null?void 0:t.baseUrl)||"https://api.anthropic.com/v1/"},set:t=>{o.value[e]||(o.value[e]={}),o.value[e].baseUrl=t}});V(()=>{var t,r;o.value[e]||(o.value[e]={baseUrl:"https://api.anthropic.com/v1/"}),s.value=((t=o.value[e])==null?void 0:t.apiKey)||"",n.value=((r=o.value[e])==null?void 0:r.baseUrl)||"https://api.anthropic.com/v1/"}),C([s,n],()=>{o.value[e]={...o.value[e],apiKey:s.value,baseUrl:n.value||"https://api.anthropic.com/v1/"}});function y(){o.value[e]={baseUrl:"https://api.anthropic.com/v1/"}}return(t,r)=>{var f,b;return R(),K(a(T),{"provider-name":((f=m.value)==null?void 0:f.localizedName)||"Anthropic | Claude","provider-icon":(b=m.value)==null?void 0:b.icon,"on-back":()=>a(g).back()},{default:u(()=>[r[2]||(r[2]=i("div",{bg:"orange-50 dark:orange-900/20","rounded-xl":"","p-4":"",flex:"~ col gap-3"},[i("h2",{"text-xl":"","font-bold":"",text:"orange-700 dark:orange-500"}," Before you start "),i("p",null,[p(" While Anthropic recently did announce that they are having a beta support for OpenAI SDK compatibility "),i("a",{underline:"",href:"https://docs.anthropic.com/en/api/openai-sdk"},"(you can read more here)"),p(", but due to the implementation details comes with "),i("a",{underline:"",href:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS"},"CORS"),p(" restrictions which not aligned with the OpenAI SDK, it's currently not possible to use this provider in the browser. ")]),i("p",null,[p(" If you do need to use this provider, you will need a dedicated proxy backend like a Serverless Function running on "),i("a",{underline:"",href:"https://workers.cloudflare.com/"},"Cloudflare Workers"),p(" or some CORS bypassing services to bypass the CORS restrictions. ")])],-1)),l(a(I),null,{default:u(()=>[l(a(B),{title:a(c)("settings.pages.providers.common.section.basic.title"),description:a(c)("settings.pages.providers.common.section.basic.description"),"on-reset":y},{default:u(()=>{var d;return[l(a(A),{modelValue:s.value,"onUpdate:modelValue":r[0]||(r[0]=k=>s.value=k),"provider-name":((d=m.value)==null?void 0:d.localizedName)||"Anthropic",placeholder:"sk-..."},null,8,["modelValue","provider-name"])]}),_:1},8,["title","description"]),l(a(O),{title:a(c)("settings.pages.providers.common.section.advanced.title")},{default:u(()=>[l(a($),{modelValue:n.value,"onUpdate:modelValue":r[1]||(r[1]=d=>n.value=d),placeholder:"https://api.anthropic.com/v1/"},null,8,["modelValue"])]),_:1},8,["title"])]),_:1})]),_:1},8,["provider-name","provider-icon","on-back"])}}});typeof _=="function"&&_(z);export{z as default};
diff --git a/assets/audio-CbrHTbIi.js b/assets/audio--U4J5B5-.js
similarity index 88%
rename from assets/audio-CbrHTbIi.js
rename to assets/audio--U4J5B5-.js
index 693c3c87643e7f83f71df308bb1151512e5c73c4..ccfbc119b6623039b314300c60864bd826ab5283 100644
--- a/assets/audio-CbrHTbIi.js
+++ b/assets/audio--U4J5B5-.js
@@ -1 +1 @@
-import{d as s,r as f,c as d,o as p,a as t}from"./index-5LjD1Eoi.js";const R=s({__name:"audio",setup(_){const a=f(),l=f();function u(o){var r,c,i;if(!o)return;const n=(c=(r=l.value)==null?void 0:r.files)==null?void 0:c[0];if(!n)return;const e=document.createElement("audio");(i=a.value)==null||i.appendChild(e),e.src=URL.createObjectURL(n),e.controls=!0,e.load(),e.play()}return(o,n)=>(p(),d("div",null,[t("div",null,[t("div",{ref_key:"containerRef",ref:a},null,512),t("input",{ref_key:"fileInputRef",ref:l,type:"file",onChange:u},null,544)])]))}});export{R as default};
+import{d as s,r as f,c as d,o as p,a as t}from"./index-DCMFRrFG.js";const R=s({__name:"audio",setup(_){const a=f(),l=f();function u(o){var r,c,i;if(!o)return;const n=(c=(r=l.value)==null?void 0:r.files)==null?void 0:c[0];if(!n)return;const e=document.createElement("audio");(i=a.value)==null||i.appendChild(e),e.src=URL.createObjectURL(n),e.controls=!0,e.load(),e.play()}return(o,n)=>(p(),d("div",null,[t("div",null,[t("div",{ref_key:"containerRef",ref:a},null,512),t("input",{ref_key:"fileInputRef",ref:l,type:"file",onChange:u},null,544)])]))}});export{R as default};
diff --git a/assets/background-remove-CAElzeUN.js b/assets/background-remove-DG4rn_jW.js
similarity index 99%
rename from assets/background-remove-CAElzeUN.js
rename to assets/background-remove-DG4rn_jW.js
index b603bbf0bc8017af2bf40b2dde10c8e5d9368fa0..35613b01c2d9d3a90f81b9fae845bad5caac3615 100644
--- a/assets/background-remove-CAElzeUN.js
+++ b/assets/background-remove-DG4rn_jW.js
@@ -1,4 +1,4 @@
-var uv=Object.defineProperty;var dv=(e,r,t)=>r in e?uv(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var te=(e,r,t)=>dv(e,typeof r!="symbol"?r+"":r,t);/* empty css */import{_ as cv}from"./InputFile.vue_vue_type_script_setup_true_lang-DjtsZn7R.js";import{d as pv,r as ks,l as hv,f as mv,c as Tn,o as En,a as Sr,b as fv,t as wf,bA as bf,bB as Mf,i as yf,q as _v,u as gv}from"./index-5LjD1Eoi.js";const la=new Map,kn=[],wv=(e,r,t)=>{if(r&&typeof r.init=="function"&&typeof r.createInferenceSessionHandler=="function"){const s=la.get(e);if(s===void 0)la.set(e,{backend:r,priority:t});else{if(s.priority>t)return;if(s.priority===t&&s.backend!==r)throw new Error(`cannot register backend "${e}" using priority ${t}`)}if(t>=0){const o=kn.indexOf(e);o!==-1&&kn.splice(o,1);for(let n=0;n{const r=la.get(e);if(!r)return"backend not found.";if(r.initialized)return r.backend;if(r.aborted)return r.error;{const t=!!r.initPromise;try{return t||(r.initPromise=r.backend.init(e)),await r.initPromise,r.initialized=!0,r.backend}catch(s){return t||(r.error=`${s}`,r.aborted=!0),r.error}finally{delete r.initPromise}}},Mv=async e=>{const r=e.executionProviders||[],t=r.map(l=>typeof l=="string"?l:l.name),s=t.length===0?kn:t;let o;const n=[],i=new Set;for(const l of s){const u=await bv(l);typeof u=="string"?n.push({name:l,err:u}):(o||(o=u),o===u&&i.add(l))}if(!o)throw new Error(`no available backend found. ERR: ${n.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(const{name:l,err:u}of n)t.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${u}`);const a=r.filter(l=>i.has(typeof l=="string"?l:l.name));return[o,new Proxy(e,{get:(l,u)=>u==="executionProviders"?a:Reflect.get(l,u)})]},yv="1.21.1";let vf="warning";const ms={wasm:{},webgl:{},webgpu:{},versions:{common:yv},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);vf=e}},get logLevel(){return vf}};Object.defineProperty(ms,"logLevel",{enumerable:!0});const vv=ms,xv=(e,r)=>{const t=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);t.width=e.dims[3],t.height=e.dims[2];const s=t.getContext("2d");if(s!=null){let o,n;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(o=e.dims[2],n=e.dims[3]):(o=e.dims[3],n=e.dims[2]);const i=(r==null?void 0:r.format)!==void 0?r.format:"RGB",a=r==null?void 0:r.norm;let l,u;a===void 0||a.mean===void 0?l=[255,255,255,255]:typeof a.mean=="number"?l=[a.mean,a.mean,a.mean,a.mean]:(l=[a.mean[0],a.mean[1],a.mean[2],0],a.mean[3]!==void 0&&(l[3]=a.mean[3])),a===void 0||a.bias===void 0?u=[0,0,0,0]:typeof a.bias=="number"?u=[a.bias,a.bias,a.bias,a.bias]:(u=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(u[3]=a.bias[3]));const p=n*o;let d=0,c=p,_=p*2,f=-1;i==="RGBA"?(d=0,c=p,_=p*2,f=p*3):i==="RGB"?(d=0,c=p,_=p*2):i==="RBG"&&(d=0,_=p,c=p*2);for(let v=0;v{const t=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let s;if(t!=null){let o,n,i;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(o=e.dims[2],n=e.dims[1],i=e.dims[3]):(o=e.dims[3],n=e.dims[2],i=e.dims[1]);const a=r!==void 0&&r.format!==void 0?r.format:"RGB",l=r==null?void 0:r.norm;let u,p;l===void 0||l.mean===void 0?u=[255,255,255,255]:typeof l.mean=="number"?u=[l.mean,l.mean,l.mean,l.mean]:(u=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(u[3]=l.mean[3])),l===void 0||l.bias===void 0?p=[0,0,0,0]:typeof l.bias=="number"?p=[l.bias,l.bias,l.bias,l.bias]:(p=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(p[3]=l.bias[3]));const d=n*o;if(r!==void 0&&(r.format!==void 0&&i===4&&r.format!=="RGBA"||i===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const c=4;let _=0,f=1,v=2,$=3,w=0,g=d,C=d*2,E=-1;a==="RGBA"?(w=0,g=d,C=d*2,E=d*3):a==="RGB"?(w=0,g=d,C=d*2):a==="RBG"&&(w=0,C=d,g=d*2),s=t.createImageData(o,n);for(let y=0;y{if(e===void 0)throw new Error("Image buffer must be defined");if(r.height===void 0||r.width===void 0)throw new Error("Image height and width must be defined");if(r.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");const{height:t,width:s}=r,o=r.norm??{mean:255,bias:0};let n,i;typeof o.mean=="number"?n=[o.mean,o.mean,o.mean,o.mean]:n=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?i=[o.bias,o.bias,o.bias,o.bias]:i=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];const a=r.format!==void 0?r.format:"RGBA",l=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",u=t*s,p=l==="RGBA"?new Float32Array(u*4):new Float32Array(u*3);let d=4,c=0,_=1,f=2,v=3,$=0,w=u,g=u*2,C=-1;a==="RGB"&&(d=3,c=0,_=1,f=2,v=-1),l==="RGBA"?C=u*3:l==="RBG"?($=0,g=u,w=u*2):l==="BGR"&&(g=0,w=u,$=u*2);for(let y=0;y{const t=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,s=typeof ImageData<"u"&&e instanceof ImageData,o=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,n=typeof e=="string";let i,a=r??{};const l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=p=>typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||p instanceof OffscreenCanvas?p.getContext("2d"):null;if(t){const p=l();p.width=e.width,p.height=e.height;const d=u(p);if(d!=null){let c=e.height,_=e.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(c=r.resizedHeight,_=r.resizedWidth),r!==void 0){if(a=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=c,a.width=_}else a.tensorFormat="RGBA",a.height=c,a.width=_;d.drawImage(e,0,0),i=d.getImageData(0,0,_,c).data}else throw new Error("Can not access image data")}else if(s){let p,d;if(r!==void 0&&r.resizedWidth!==void 0&&r.resizedHeight!==void 0?(p=r.resizedHeight,d=r.resizedWidth):(p=e.height,d=e.width),r!==void 0&&(a=r),a.format="RGBA",a.height=p,a.width=d,r!==void 0){const c=l();c.width=d,c.height=p;const _=u(c);if(_!=null)_.putImageData(e,0,0),i=_.getImageData(0,0,d,p).data;else throw new Error("Can not access image data")}else i=e.data}else if(o){if(r===void 0)throw new Error("Please provide image config with format for Imagebitmap");const p=l();p.width=e.width,p.height=e.height;const d=u(p);if(d!=null){const c=e.height,_=e.width;return d.drawImage(e,0,0,_,c),i=d.getImageData(0,0,_,c).data,a.height=c,a.width=_,kl(i,a)}else throw new Error("Can not access image data")}else{if(n)return new Promise((p,d)=>{const c=l(),_=u(c);if(!e||!_)return d();const f=new Image;f.crossOrigin="Anonymous",f.src=e,f.onload=()=>{c.width=f.width,c.height=f.height,_.drawImage(f,0,0,c.width,c.height);const v=_.getImageData(0,0,c.width,c.height);a.height=c.height,a.width=c.width,p(kl(v.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(i!==void 0)return kl(i,a);throw new Error("Input data provided is not supported - aborted tensor creation")},Pv=(e,r)=>{const{width:t,height:s,download:o,dispose:n}=r,i=[1,s,t,4];return new Qr({location:"texture",type:"float32",texture:e,dims:i,download:o,dispose:n})},Cv=(e,r)=>{const{dataType:t,dims:s,download:o,dispose:n}=r;return new Qr({location:"gpu-buffer",type:t??"float32",gpuBuffer:e,dims:s,download:o,dispose:n})},Sv=(e,r)=>{const{dataType:t,dims:s,download:o,dispose:n}=r;return new Qr({location:"ml-tensor",type:t??"float32",mlTensor:e,dims:s,download:o,dispose:n})},$v=(e,r,t)=>new Qr({location:"cpu-pinned",type:e,data:r,dims:t??[r.length]}),so=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),ua=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let xf=!1;const kv=()=>{if(!xf){xf=!0;const e=typeof BigInt64Array<"u"&&BigInt64Array.from,r=typeof BigUint64Array<"u"&&BigUint64Array.from,t=globalThis.Float16Array,s=typeof t<"u"&&t.from;e&&(so.set("int64",BigInt64Array),ua.set(BigInt64Array,"int64")),r&&(so.set("uint64",BigUint64Array),ua.set(BigUint64Array,"uint64")),s?(so.set("float16",t),ua.set(t,"float16")):so.set("float16",Uint16Array)}},Iv=e=>{let r=1;for(let t=0;t{switch(e.location){case"cpu":return new Qr(e.type,e.data,r);case"cpu-pinned":return new Qr({location:"cpu-pinned",data:e.data,type:e.type,dims:r});case"texture":return new Qr({location:"texture",texture:e.texture,type:e.type,dims:r});case"gpu-buffer":return new Qr({location:"gpu-buffer",gpuBuffer:e.gpuBuffer,type:e.type,dims:r});case"ml-tensor":return new Qr({location:"ml-tensor",mlTensor:e.mlTensor,type:e.type,dims:r});default:throw new Error(`tensorReshape: tensor location ${e.location} is not supported`)}};let Qr=class{constructor(r,t,s){kv();let o,n;if(typeof r=="object"&&"location"in r)switch(this.dataLocation=r.location,o=r.type,n=r.dims,r.location){case"cpu-pinned":{const a=so.get(o);if(!a)throw new TypeError(`unsupported type "${o}" to create tensor from pinned buffer`);if(!(r.data instanceof a))throw new TypeError(`buffer should be of type ${a.name}`);this.cpuData=r.data;break}case"texture":{if(o!=="float32")throw new TypeError(`unsupported type "${o}" to create tensor from texture`);this.gpuTextureData=r.texture,this.downloader=r.download,this.disposer=r.dispose;break}case"gpu-buffer":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from gpu buffer`);this.gpuBufferData=r.gpuBuffer,this.downloader=r.download,this.disposer=r.dispose;break}case"ml-tensor":{if(o!=="float32"&&o!=="float16"&&o!=="int32"&&o!=="int64"&&o!=="uint32"&&o!=="uint64"&&o!=="int8"&&o!=="uint8"&&o!=="bool"&&o!=="uint4"&&o!=="int4")throw new TypeError(`unsupported type "${o}" to create tensor from MLTensor`);this.mlTensorData=r.mlTensor,this.downloader=r.download,this.disposer=r.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let a,l;if(typeof r=="string")if(o=r,l=s,r==="string"){if(!Array.isArray(t))throw new TypeError("A string tensor's data must be a string array.");a=t}else{const u=so.get(r);if(u===void 0)throw new TypeError(`Unsupported tensor type: ${r}.`);if(Array.isArray(t)){if(r==="float16"&&u===Uint16Array||r==="uint4"||r==="int4")throw new TypeError(`Creating a ${r} tensor from number array is not supported. Please use ${u.name} as data.`);r==="uint64"||r==="int64"?a=u.from(t,BigInt):a=u.from(t)}else if(t instanceof u)a=t;else if(t instanceof Uint8ClampedArray)if(r==="uint8")a=Uint8Array.from(t);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(r==="float16"&&t instanceof Uint16Array&&u!==Uint16Array)a=new globalThis.Float16Array(t.buffer,t.byteOffset,t.length);else throw new TypeError(`A ${o} tensor's data must be type of ${u}`)}else if(l=t,Array.isArray(r)){if(r.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");const u=typeof r[0];if(u==="string")o="string",a=r;else if(u==="boolean")o="bool",a=Uint8Array.from(r);else throw new TypeError(`Invalid element type of data array: ${u}.`)}else if(r instanceof Uint8ClampedArray)o="uint8",a=Uint8Array.from(r);else{const u=ua.get(r.constructor);if(u===void 0)throw new TypeError(`Unsupported type for tensor data: ${r.constructor}.`);o=u,a=r}if(l===void 0)l=[a.length];else if(!Array.isArray(l))throw new TypeError("A tensor's dims must be a number array");n=l,this.cpuData=a,this.dataLocation="cpu"}const i=Iv(n);if(this.cpuData&&i!==this.cpuData.length&&!((o==="uint4"||o==="int4")&&Math.ceil(i/2)===this.cpuData.length))throw new Error(`Tensor's size(${i}) does not match data length(${this.cpuData.length}).`);this.type=o,this.dims=n,this.size=i}static async fromImage(r,t){return Ev(r,t)}static fromTexture(r,t){return Pv(r,t)}static fromGpuBuffer(r,t){return Cv(r,t)}static fromMLTensor(r,t){return Sv(r,t)}static fromPinnedBuffer(r,t,s){return $v(r,t,s)}toDataURL(r){return xv(this,r)}toImageData(r){return Tv(this,r)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(r){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;const t=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=t,r&&this.disposer&&(this.disposer(),this.disposer=void 0),t}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(r){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Av(this,r)}};const to=Qr,nb=(e,r)=>{(typeof ms.trace>"u"?!ms.wasm.trace:!ms.trace)||console.timeStamp(`${e}::ORT::${r}`)},ob=(e,r)=>{var o;const t=((o=new Error().stack)==null?void 0:o.split(/\r\n|\r|\n/g))||[];let s=!1;for(let n=0;n{(typeof ms.trace>"u"?!ms.wasm.trace:!ms.trace)||ob("BEGIN",e)},Iu=e=>{(typeof ms.trace>"u"?!ms.wasm.trace:!ms.trace)||ob("END",e)};let Fv=class ib{constructor(r){this.handler=r}async run(r,t,s){ku();const o={};let n={};if(typeof r!="object"||r===null||r instanceof to||Array.isArray(r))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let i=!0;if(typeof t=="object"){if(t===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(t instanceof to)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(t)){if(t.length===0)throw new TypeError("'fetches' cannot be an empty array.");i=!1;for(const u of t){if(typeof u!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(u)===-1)throw new RangeError(`'fetches' contains invalid output name: ${u}.`);o[u]=null}if(typeof s=="object"&&s!==null)n=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else{let u=!1;const p=Object.getOwnPropertyNames(t);for(const d of this.outputNames)if(p.indexOf(d)!==-1){const c=t[d];(c===null||c instanceof to)&&(u=!0,i=!1,o[d]=c)}if(u){if(typeof s=="object"&&s!==null)n=s;else if(typeof s<"u")throw new TypeError("'options' must be an object.")}else n=t}}else if(typeof t<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(const u of this.inputNames)if(typeof r[u]>"u")throw new Error(`input '${u}' is missing in 'feeds'.`);if(i)for(const u of this.outputNames)o[u]=null;const a=await this.handler.run(r,o,n),l={};for(const u in a)if(Object.hasOwnProperty.call(a,u)){const p=a[u];p instanceof to?l[u]=p:l[u]=new to(p.type,p.data,p.dims)}return Iu(),l}async release(){return this.handler.dispose()}static async create(r,t,s,o){ku();let n,i={};if(typeof r=="string"){if(n=r,typeof t=="object"&&t!==null)i=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof Uint8Array){if(n=r,typeof t=="object"&&t!==null)i=t;else if(typeof t<"u")throw new TypeError("'options' must be an object.")}else if(r instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer){const p=r;let d=0,c=r.byteLength;if(typeof t=="object"&&t!==null)i=t;else if(typeof t=="number"){if(d=t,!Number.isSafeInteger(d))throw new RangeError("'byteOffset' must be an integer.");if(d<0||d>=p.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${p.byteLength}).`);if(c=r.byteLength-d,typeof s=="number"){if(c=s,!Number.isSafeInteger(c))throw new RangeError("'byteLength' must be an integer.");if(c<=0||d+c>p.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${p.byteLength-d}].`);if(typeof o=="object"&&o!==null)i=o;else if(typeof o<"u")throw new TypeError("'options' must be an object.")}else if(typeof s<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof t<"u")throw new TypeError("'options' must be an object.");n=new Uint8Array(p,d,c)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");const[a,l]=await Mv(i),u=await a.createInferenceSessionHandler(n,l);return Iu(),new ib(u)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}};const Ov=Fv,Dv=Object.freeze(Object.defineProperty({__proto__:null,InferenceSession:Ov,TRACE:nb,TRACE_FUNC_BEGIN:ku,TRACE_FUNC_END:Iu,Tensor:to,env:vv,registerBackend:wv},Symbol.toStringTag,{value:"Module"}));/*!
+var uv=Object.defineProperty;var dv=(e,r,t)=>r in e?uv(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var te=(e,r,t)=>dv(e,typeof r!="symbol"?r+"":r,t);/* empty css */import{_ as cv}from"./InputFile.vue_vue_type_script_setup_true_lang-CYiBTlgF.js";import{d as pv,r as ks,l as hv,f as mv,c as Tn,o as En,a as Sr,b as fv,t as wf,bA as bf,bB as Mf,i as yf,q as _v,u as gv}from"./index-DCMFRrFG.js";const la=new Map,kn=[],wv=(e,r,t)=>{if(r&&typeof r.init=="function"&&typeof r.createInferenceSessionHandler=="function"){const s=la.get(e);if(s===void 0)la.set(e,{backend:r,priority:t});else{if(s.priority>t)return;if(s.priority===t&&s.backend!==r)throw new Error(`cannot register backend "${e}" using priority ${t}`)}if(t>=0){const o=kn.indexOf(e);o!==-1&&kn.splice(o,1);for(let n=0;n{const r=la.get(e);if(!r)return"backend not found.";if(r.initialized)return r.backend;if(r.aborted)return r.error;{const t=!!r.initPromise;try{return t||(r.initPromise=r.backend.init(e)),await r.initPromise,r.initialized=!0,r.backend}catch(s){return t||(r.error=`${s}`,r.aborted=!0),r.error}finally{delete r.initPromise}}},Mv=async e=>{const r=e.executionProviders||[],t=r.map(l=>typeof l=="string"?l:l.name),s=t.length===0?kn:t;let o;const n=[],i=new Set;for(const l of s){const u=await bv(l);typeof u=="string"?n.push({name:l,err:u}):(o||(o=u),o===u&&i.add(l))}if(!o)throw new Error(`no available backend found. ERR: ${n.map(l=>`[${l.name}] ${l.err}`).join(", ")}`);for(const{name:l,err:u}of n)t.includes(l)&&console.warn(`removing requested execution provider "${l}" from session options because it is not available: ${u}`);const a=r.filter(l=>i.has(typeof l=="string"?l:l.name));return[o,new Proxy(e,{get:(l,u)=>u==="executionProviders"?a:Reflect.get(l,u)})]},yv="1.21.1";let vf="warning";const ms={wasm:{},webgl:{},webgpu:{},versions:{common:yv},set logLevel(e){if(e!==void 0){if(typeof e!="string"||["verbose","info","warning","error","fatal"].indexOf(e)===-1)throw new Error(`Unsupported logging level: ${e}`);vf=e}},get logLevel(){return vf}};Object.defineProperty(ms,"logLevel",{enumerable:!0});const vv=ms,xv=(e,r)=>{const t=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);t.width=e.dims[3],t.height=e.dims[2];const s=t.getContext("2d");if(s!=null){let o,n;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(o=e.dims[2],n=e.dims[3]):(o=e.dims[3],n=e.dims[2]);const i=(r==null?void 0:r.format)!==void 0?r.format:"RGB",a=r==null?void 0:r.norm;let l,u;a===void 0||a.mean===void 0?l=[255,255,255,255]:typeof a.mean=="number"?l=[a.mean,a.mean,a.mean,a.mean]:(l=[a.mean[0],a.mean[1],a.mean[2],0],a.mean[3]!==void 0&&(l[3]=a.mean[3])),a===void 0||a.bias===void 0?u=[0,0,0,0]:typeof a.bias=="number"?u=[a.bias,a.bias,a.bias,a.bias]:(u=[a.bias[0],a.bias[1],a.bias[2],0],a.bias[3]!==void 0&&(u[3]=a.bias[3]));const p=n*o;let d=0,c=p,_=p*2,f=-1;i==="RGBA"?(d=0,c=p,_=p*2,f=p*3):i==="RGB"?(d=0,c=p,_=p*2):i==="RBG"&&(d=0,_=p,c=p*2);for(let v=0;v{const t=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d");let s;if(t!=null){let o,n,i;(r==null?void 0:r.tensorLayout)!==void 0&&r.tensorLayout==="NHWC"?(o=e.dims[2],n=e.dims[1],i=e.dims[3]):(o=e.dims[3],n=e.dims[2],i=e.dims[1]);const a=r!==void 0&&r.format!==void 0?r.format:"RGB",l=r==null?void 0:r.norm;let u,p;l===void 0||l.mean===void 0?u=[255,255,255,255]:typeof l.mean=="number"?u=[l.mean,l.mean,l.mean,l.mean]:(u=[l.mean[0],l.mean[1],l.mean[2],255],l.mean[3]!==void 0&&(u[3]=l.mean[3])),l===void 0||l.bias===void 0?p=[0,0,0,0]:typeof l.bias=="number"?p=[l.bias,l.bias,l.bias,l.bias]:(p=[l.bias[0],l.bias[1],l.bias[2],0],l.bias[3]!==void 0&&(p[3]=l.bias[3]));const d=n*o;if(r!==void 0&&(r.format!==void 0&&i===4&&r.format!=="RGBA"||i===3&&r.format!=="RGB"&&r.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");const c=4;let _=0,f=1,v=2,$=3,w=0,g=d,C=d*2,E=-1;a==="RGBA"?(w=0,g=d,C=d*2,E=d*3):a==="RGB"?(w=0,g=d,C=d*2):a==="RBG"&&(w=0,C=d,g=d*2),s=t.createImageData(o,n);for(let y=0;y{if(e===void 0)throw new Error("Image buffer must be defined");if(r.height===void 0||r.width===void 0)throw new Error("Image height and width must be defined");if(r.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");const{height:t,width:s}=r,o=r.norm??{mean:255,bias:0};let n,i;typeof o.mean=="number"?n=[o.mean,o.mean,o.mean,o.mean]:n=[o.mean[0],o.mean[1],o.mean[2],o.mean[3]??255],typeof o.bias=="number"?i=[o.bias,o.bias,o.bias,o.bias]:i=[o.bias[0],o.bias[1],o.bias[2],o.bias[3]??0];const a=r.format!==void 0?r.format:"RGBA",l=r.tensorFormat!==void 0&&r.tensorFormat!==void 0?r.tensorFormat:"RGB",u=t*s,p=l==="RGBA"?new Float32Array(u*4):new Float32Array(u*3);let d=4,c=0,_=1,f=2,v=3,$=0,w=u,g=u*2,C=-1;a==="RGB"&&(d=3,c=0,_=1,f=2,v=-1),l==="RGBA"?C=u*3:l==="RBG"?($=0,g=u,w=u*2):l==="BGR"&&(g=0,w=u,$=u*2);for(let y=0;y{const t=typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement,s=typeof ImageData<"u"&&e instanceof ImageData,o=typeof ImageBitmap<"u"&&e instanceof ImageBitmap,n=typeof e=="string";let i,a=r??{};const l=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},u=p=>typeof HTMLCanvasElement<"u"&&p instanceof HTMLCanvasElement||p instanceof OffscreenCanvas?p.getContext("2d"):null;if(t){const p=l();p.width=e.width,p.height=e.height;const d=u(p);if(d!=null){let c=e.height,_=e.width;if(r!==void 0&&r.resizedHeight!==void 0&&r.resizedWidth!==void 0&&(c=r.resizedHeight,_=r.resizedWidth),r!==void 0){if(a=r,r.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");a.tensorFormat="RGBA",a.height=c,a.width=_}else a.tensorFormat="RGBA",a.height=c,a.width=_;d.drawImage(e,0,0),i=d.getImageData(0,0,_,c).data}else throw new Error("Can not access image data")}else if(s){let p,d;if(r!==void 0&&r.resizedWidth!==void 0&&r.resizedHeight!==void 0?(p=r.resizedHeight,d=r.resizedWidth):(p=e.height,d=e.width),r!==void 0&&(a=r),a.format="RGBA",a.height=p,a.width=d,r!==void 0){const c=l();c.width=d,c.height=p;const _=u(c);if(_!=null)_.putImageData(e,0,0),i=_.getImageData(0,0,d,p).data;else throw new Error("Can not access image data")}else i=e.data}else if(o){if(r===void 0)throw new Error("Please provide image config with format for Imagebitmap");const p=l();p.width=e.width,p.height=e.height;const d=u(p);if(d!=null){const c=e.height,_=e.width;return d.drawImage(e,0,0,_,c),i=d.getImageData(0,0,_,c).data,a.height=c,a.width=_,kl(i,a)}else throw new Error("Can not access image data")}else{if(n)return new Promise((p,d)=>{const c=l(),_=u(c);if(!e||!_)return d();const f=new Image;f.crossOrigin="Anonymous",f.src=e,f.onload=()=>{c.width=f.width,c.height=f.height,_.drawImage(f,0,0,c.width,c.height);const v=_.getImageData(0,0,c.width,c.height);a.height=c.height,a.width=c.width,p(kl(v.data,a))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(i!==void 0)return kl(i,a);throw new Error("Input data provided is not supported - aborted tensor creation")},Pv=(e,r)=>{const{width:t,height:s,download:o,dispose:n}=r,i=[1,s,t,4];return new Qr({location:"texture",type:"float32",texture:e,dims:i,download:o,dispose:n})},Cv=(e,r)=>{const{dataType:t,dims:s,download:o,dispose:n}=r;return new Qr({location:"gpu-buffer",type:t??"float32",gpuBuffer:e,dims:s,download:o,dispose:n})},Sv=(e,r)=>{const{dataType:t,dims:s,download:o,dispose:n}=r;return new Qr({location:"ml-tensor",type:t??"float32",mlTensor:e,dims:s,download:o,dispose:n})},$v=(e,r,t)=>new Qr({location:"cpu-pinned",type:e,data:r,dims:t??[r.length]}),so=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),ua=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);let xf=!1;const kv=()=>{if(!xf){xf=!0;const e=typeof BigInt64Array<"u"&&BigInt64Array.from,r=typeof BigUint64Array<"u"&&BigUint64Array.from,t=globalThis.Float16Array,s=typeof t<"u"&&t.from;e&&(so.set("int64",BigInt64Array),ua.set(BigInt64Array,"int64")),r&&(so.set("uint64",BigUint64Array),ua.set(BigUint64Array,"uint64")),s?(so.set("float16",t),ua.set(t,"float16")):so.set("float16",Uint16Array)}},Iv=e=>{let r=1;for(let t=0;t