import { __commonJSMin as e } from "../../../../_virtual/_rolldown/runtime.js";
import { require_api as t } from "../common/api.js";
import { require_ril as n } from "./ril.js";
//#region ../../node_modules/vscode-jsonrpc/lib/browser/main.js
var r = /* @__PURE__ */ e(((e) => {
	var r = e && e.__createBinding || (Object.create ? (function(e, t, n, r) {
		r === void 0 && (r = n);
		var i = Object.getOwnPropertyDescriptor(t, n);
		(!i || ("get" in i ? !t.__esModule : i.writable || i.configurable)) && (i = {
			enumerable: !0,
			get: function() {
				return t[n];
			}
		}), Object.defineProperty(e, r, i);
	}) : (function(e, t, n, r) {
		r === void 0 && (r = n), e[r] = t[n];
	})), i = e && e.__exportStar || function(e, t) {
		for (var n in e) n !== "default" && !Object.prototype.hasOwnProperty.call(t, n) && r(t, e, n);
	};
	Object.defineProperty(e, "__esModule", { value: !0 }), e.createMessageConnection = e.BrowserMessageWriter = e.BrowserMessageReader = void 0, n().default.install();
	var a = t();
	i(t(), e), e.BrowserMessageReader = class extends a.AbstractMessageReader {
		constructor(e) {
			super(), this._onData = new a.Emitter(), this._messageListener = (e) => {
				this._onData.fire(e.data);
			}, e.addEventListener("error", (e) => this.fireError(e)), e.onmessage = this._messageListener;
		}
		listen(e) {
			return this._onData.event(e);
		}
	}, e.BrowserMessageWriter = class extends a.AbstractMessageWriter {
		constructor(e) {
			super(), this.port = e, this.errorCount = 0, e.addEventListener("error", (e) => this.fireError(e));
		}
		write(e) {
			try {
				return this.port.postMessage(e), Promise.resolve();
			} catch (t) {
				return this.handleError(t, e), Promise.reject(t);
			}
		}
		handleError(e, t) {
			this.errorCount++, this.fireError(e, t, this.errorCount);
		}
		end() {}
	};
	function o(e, t, n, r) {
		return n === void 0 && (n = a.NullLogger), a.ConnectionStrategy.is(r) && (r = { connectionStrategy: r }), (0, a.createMessageConnection)(e, t, n, r);
	}
	e.createMessageConnection = o;
}));
//#endregion
export default r();
export { r as require_main };
