function getDefaultExportFromCjs (x) {
	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

var offscreen$1 = {};

/**
 * Offscreen Document for SQLite Worker
 * 
 * This document hosts the Dedicated Worker that runs SQLite WASM
 * with OPFS sync access.
 */

var hasRequiredOffscreen;

function requireOffscreen () {
	if (hasRequiredOffscreen) return offscreen$1;
	hasRequiredOffscreen = 1;
	const worker = new Worker(new URL('./dist/workers/sqlite-worker.js', import.meta.url), {
	    type: 'module'
	});

	// Relay messages between background and worker
	chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
	    if (message.type === 'sqlite_request') {
	        // Forward to worker
	        worker.postMessage({
	            sqliteRequestId: message.sqliteRequestId,
	            operation: message.operation,
	            params: message.params
	        });
	        
	        // Response will come via worker.onmessage
	        return true; // Keep channel open for async response
	    }
	});

	// Handle worker responses
	worker.onmessage = (e) => {
	    const { sqliteRequestId, result, error } = e.data;
	    
	    // Send response back to background
	    chrome.runtime.sendMessage({
	        type: 'sqlite_response',
	        sqliteRequestId,
	        result,
	        error
	    });
	};

	self.addEventListener('beforeunload', () => {
	    worker.terminate();
	});
	return offscreen$1;
}

var offscreenExports = requireOffscreen();
var offscreen = /*@__PURE__*/getDefaultExportFromCjs(offscreenExports);

export { offscreen as default };
