"use strict";var dr=Object.create;var v=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var fr=Object.getOwnPropertyNames;var yr=Object.getPrototypeOf,gr=Object.prototype.hasOwnProperty;var hr=(r,e)=>()=>(r&&(e=r(r=0)),e);var P=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Sr=(r,e)=>{for(var t in e)v(r,t,{get:e[t],enumerable:!0})},W=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fr(e))!gr.call(r,i)&&i!==t&&v(r,i,{get:()=>e[i],enumerable:!(n=lr(e,i))||n.enumerable});return r};var A=(r,e,t)=>(t=r!=null?dr(yr(r)):{},W(e||!r||!r.__esModule?v(t,"default",{value:r,enumerable:!0}):t,r)),Fr=r=>W(v({},"__esModule",{value:!0}),r);var c=hr(()=>{"use strict"});var E=P((ie,m)=>{"use strict";c();var X=9007199254740991,K=function(r){return r}();function br(r){return r===K}function V(r){return typeof r=="string"||Object.prototype.toString.call(r)=="[object String]"}function Pr(r){return Object.prototype.toString.call(r)=="[object Date]"}function U(r){return r!==null&&typeof r=="object"}function N(r){return typeof r=="function"}function Tr(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=X}function Ar(r){return Object.prototype.toString.call(r)=="[object Array]"}function $(r){return U(r)&&!N(r)&&Tr(r.length)}function _(r){return Object.prototype.toString.call(r)=="[object ArrayBuffer]"}function Er(r,e){return Array.prototype.map.call(r,e)}function wr(r,e){var t=K;return N(e)&&Array.prototype.every.call(r,function(n,i,a){var s=e(n,i,a);return s&&(t=n),!s}),t}function xr(r){return Object.assign.apply(null,arguments)}function Z(r){var e,t,n;if(V(r)){for(t=r.length,n=new Uint8Array(t),e=0;e{"use strict";c();var L="\0";J.exports={NULL_CHAR:L,TMAGIC:"ustar"+L+"00",OLDGNU_MAGIC:"ustar "+L,REGTYPE:0,LNKTYPE:1,SYMTYPE:2,CHRTYPE:3,BLKTYPE:4,DIRTYPE:5,FIFOTYPE:6,CONTTYPE:7,TSUID:parseInt("4000",8),TSGID:parseInt("2000",8),TSVTX:parseInt("1000",8),TUREAD:parseInt("0400",8),TUWRITE:parseInt("0200",8),TUEXEC:parseInt("0100",8),TGREAD:parseInt("0040",8),TGWRITE:parseInt("0020",8),TGEXEC:parseInt("0010",8),TOREAD:parseInt("0004",8),TOWRITE:parseInt("0002",8),TOEXEC:parseInt("0001",8),TPERMALL:parseInt("0777",8),TPERMMASK:parseInt("0777",8)}});var j=P((ue,d)=>{"use strict";c();var Q=E(),p=w(),vr=512,G=p.TPERMALL,rr=0,er=0,H=[["name",100,0,function(r,e){return x(r[e[0]],e[1])},function(r,e,t){return F(r.slice(e,e+t[1]))}],["mode",8,100,function(r,e){var t=r[e[0]]||G;return t=t&p.TPERMMASK,T(t,e[1],G)},function(r,e,t){var n=y(r.slice(e,e+t[1]));return n&=p.TPERMMASK,n}],["uid",8,108,function(r,e){return T(r[e[0]],e[1],rr)},function(r,e,t){return y(r.slice(e,e+t[1]))}],["gid",8,116,function(r,e){return T(r[e[0]],e[1],er)},function(r,e,t){return y(r.slice(e,e+t[1]))}],["size",12,124,function(r,e){return T(r.data.length,e[1])},function(r,e,t){return y(r.slice(e,e+t[1]))}],["modifyTime",12,136,function(r,e){return D(r[e[0]],e[1])},function(r,e,t){return k(r.slice(e,e+t[1]))}],["checksum",8,148,function(r,e){return" "},function(r,e,t){return y(r.slice(e,e+t[1]))}],["type",1,156,function(r,e){return""+(parseInt(r[e[0]],10)||0)%8},function(r,e,t){return(parseInt(String.fromCharCode(r[e]),10)||0)%8}],["linkName",100,157,function(r,e){return""},function(r,e,t){return F(r.slice(e,e+t[1]))}],["ustar",8,257,function(r,e){return p.TMAGIC},function(r,e,t){return Ur(F(r.slice(e,e+t[1]),!0))},function(r,e){return r[e[0]]==p.TMAGIC||r[e[0]]==p.OLDGNU_MAGIC}],["owner",32,265,function(r,e){return x(r[e[0]],e[1])},function(r,e,t){return F(r.slice(e,e+t[1]))}],["group",32,297,function(r,e){return x(r[e[0]],e[1])},function(r,e,t){return F(r.slice(e,e+t[1]))}],["majorNumber",8,329,function(r,e){return""},function(r,e,t){return y(r.slice(e,e+t[1]))}],["minorNumber",8,337,function(r,e){return""},function(r,e,t){return y(r.slice(e,e+t[1]))}],["prefix",131,345,function(r,e){return x(r[e[0]],e[1])},function(r,e,t){return F(r.slice(e,e+t[1]))}],["accessTime",12,476,function(r,e){return D(r[e[0]],e[1])},function(r,e,t){return k(r.slice(e,e+t[1]))}],["createTime",12,488,function(r,e){return D(r[e[0]],e[1])},function(r,e,t){return k(r.slice(e,e+t[1]))}]],tr=function(r){var e=r[r.length-1];return e[2]+e[1]}(H);function Ur(r){if(r.length==8){var e=r.split("");if(e[5]==p.NULL_CHAR)return(e[6]==" "||e[6]==p.NULL_CHAR)&&(e[6]="0"),(e[7]==" "||e[7]==p.NULL_CHAR)&&(e[7]="0"),e=e.join(""),e==p.TMAGIC?e:r;if(e[7]==p.NULL_CHAR)return e[5]==p.NULL_CHAR&&(e[5]=" "),e[6]==p.NULL_CHAR&&(e[6]=" "),e==p.OLDGNU_MAGIC?e:r}return r}function x(r,e){return e-=1,Q.isUndefined(r)&&(r=""),r=(""+r).substr(0,e),r+p.NULL_CHAR}function T(r,e,t){for(t=parseInt(t)||0,e-=1,r=(parseInt(r)||t).toString(8).substr(-e,e);r.length=0?t.substr(0,n):t}function y(r){var e=String.fromCharCode.apply(null,r);return parseInt(e.replace(/^0+$/g,""),8)||0}function k(r){return r.length==0||r[0]==0?null:new Date(1e3*y(r))}function Nr(r,e,t){var n=parseInt(e,10)||0,i=Math.min(n+tr,r.length),a=0,s=0,o=0;t&&H.every(function(g){return g[0]=="checksum"?(s=n+g[2],o=s+g[1],!1):!0});for(var u=32,l=n;l=s&&l{"use strict";c();var Dr=w(),M=E(),S=j();function nr(r){return S.recordSize}function ir(r){return Math.ceil(r.data.length/S.recordSize)*S.recordSize}function kr(r){var e=0;return r.forEach(function(t){e+=nr(t)+ir(t)}),e+=S.recordSize*2,new Uint8Array(e)}function Mr(r,e,t){t=parseInt(t)||0;var n=t;S.posixHeader.forEach(function(u){for(var l=u[3](e,u),R=l.length,g=0;g{"use strict";c();var Cr=w(),q=E(),f=j(),Ir={extractData:!0,checkHeader:!0,checkChecksum:!0,checkFileSize:!0},Rr={size:!0,checksum:!0,ustar:!0},B={unexpectedEndOfFile:"Unexpected end of file.",fileCorrupted:"File is corrupted.",checksumCheckFailed:"Checksum check failed."};function _r(r){return f.recordSize}function Lr(r){return Math.ceil(r/f.recordSize)*f.recordSize}function Gr(r,e){for(var t=e,n=Math.min(r.length,e+f.recordSize*2),i=t;i=f.recordSize;){r=q.toUint8Array(r);var a=Hr(r,n,e);if(!a)break;n+=_r(a);var s=jr(r,n,a,e);if(t.push(Br(a,s)),n+=Lr(a.size),Gr(r,n))break}return t}sr.exports.untar=qr});var pr=P((fe,cr)=>{"use strict";c();var Yr=E(),Wr=w(),Xr=ar(),Kr=ur();Yr.extend(cr.exports,Xr,Kr,Wr)});var ee={};Sr(ee,{NodeFS:()=>Y});module.exports=Fr(ee);c();var C=A(require("fs"),1),I=A(require("path"),1);c();c();var b=A(pr(),1);async function mr(r,e,t="pgdata",n="auto"){let i=$r(r,e),[a,s]=await Zr(i,n),o=t+(s?".tar.gz":".tar"),u=s?"application/x-gzip":"application/x-tar";return typeof File<"u"?new File([a],o,{type:u}):new Blob([a],{type:u})}function Vr(r,e){let t=[],n=i=>{r.readdir(i).forEach(s=>{if(s==="."||s==="..")return;let o=i+"/"+s,u=r.stat(o),l=r.isFile(u.mode)?r.readFile(o,{encoding:"binary"}):new Uint8Array(0);t.push({name:o.substring(e.length),mode:u.mode,size:u.size,type:r.isFile(u.mode)?b.REGTYPE:b.DIRTYPE,modifyTime:u.mtime,data:l}),r.isDir(u.mode)&&n(o)})};return n(e),t}function $r(r,e){let t=Vr(r,e);return(0,b.tar)(t)}async function Zr(r,e="auto"){if(e==="none")return[r,!1];if(typeof CompressionStream<"u")return[await Jr(r),!0];if(typeof process<"u"&&process.versions&&process.versions.node)return[await Qr(r),!0];if(e==="auto")return[r,!1];throw new Error("Compression not supported in this environment")}async function Jr(r){let e=new CompressionStream("gzip"),t=e.writable.getWriter(),n=e.readable.getReader();t.write(r),t.close();let i=[];for(;;){let{value:o,done:u}=await n.read();if(u)break;o&&i.push(o)}let a=new Uint8Array(i.reduce((o,u)=>o+u.length,0)),s=0;return i.forEach(o=>{a.set(o,s),s+=o.length}),a}async function Qr(r){let{promisify:e}=await import("util"),{gzip:t}=await import("zlib");return await e(t)(r)}var re="/tmp/pglite",z=re+"/base",O=class{constructor(e){this.dataDir=e}async init(e,t){return this.pg=e,{emscriptenOpts:t}}async syncToFs(e){}async initialSyncFs(){}async closeFs(){}async dumpTar(e,t){return mr(this.pg.Module.FS,z,e,t)}};var Y=class extends O{constructor(e){super(e),this.rootDir=I.resolve(e),C.existsSync(I.join(this.rootDir))||C.mkdirSync(this.rootDir)}async init(e,t){return this.pg=e,{emscriptenOpts:{...t,preRun:[...t.preRun||[],i=>{let a=i.FS.filesystems.NODEFS;i.FS.mkdir(z),i.FS.mount(a,{root:this.rootDir},z)}]}}}async closeFs(){this.pg.Module.FS.quit()}};0&&(module.exports={NodeFS}); //# sourceMappingURL=nodefs.cjs.map