import { IdbFs, PGlite } from "@electric-sql/pglite";
import { live } from "@electric-sql/pglite/live";
import { worker } from "@electric-sql/pglite/worker";
worker({
    async init(options) {
        const databaseName = options.meta.databaseName;
        if (!databaseName) {
            throw new Error("Database name not provided");
        }
        const idbFs = new IdbFs(databaseName);
        // Create and return a PGlite instance
        const db = PGlite.create({
            fs: idbFs,
            relaxedDurability: true,
            extensions: {
                live,
            },
        });
        return db;
    },
}).catch((error) => {
    console.error("Error initializing PGlite worker:", error);
    throw error;
});
//# sourceMappingURL=pglite-worker.js.map