import{r as e}from"./chunk-zsgVPwQN.js";import{i as t,n,o as r,r as i}from"./esm-CIp61Ze4.js";var a=e({PGliteDialect:()=>s}),o=class{client;constructor(e){this.client=e}async executeQuery(e){let t=await this.client.query(e.sql,[...e.parameters]);return t.affectedRows?{numAffectedRows:BigInt(t.affectedRows),rows:t.rows}:{rows:t.rows}}async*streamQuery(e,t){if(!Number.isInteger(t)||t<=0)throw Error(`chunkSize must be a positive integer`);let n=await this.client.query(e.sql,[...e.parameters]);for(let e=0;e<n.rows.length;e+=t)yield{rows:n.rows.slice(e,e+t)}}},s=class{constructor(e){this.pgLite=e}createAdapter(){return new n}createDriver(){return new c(this.pgLite)}createQueryCompiler(){return new t}createIntrospector(e){return new i(e)}},c=class{client;connection;queue=[];constructor(e){this.client=e}async init(){}async acquireConnection(){if(this.client===void 0)throw Error(`PGLite not initialized`);return this.connection===void 0?(this.connection=new o(this.client),this.connection):new Promise(e=>{this.queue.push(e)})}async releaseConnection(e){if(e!==this.connection)throw Error(`Invalid connection`);let t=this.queue.splice(0,1)[0];if(t===void 0){this.connection=void 0;return}t(this.connection)}async beginTransaction(e,t){t.isolationLevel?await e.executeQuery(r.raw(`start transaction isolation level ${t.isolationLevel}`)):await e.executeQuery(r.raw(`begin`))}async commitTransaction(e){await e.executeQuery(r.raw(`commit`))}async rollbackTransaction(e){await e.executeQuery(r.raw(`rollback`))}async destroy(){this.client=void 0}};export{a as n,s as t};
//# sourceMappingURL=dist-DMkwH3CF.js.map