#!/usr/bin/env node
import {
  __privateAdd,
  __privateGet,
  __privateSet,
  __publicField
} from "./chunk-EVQGJID7.js";

// ../../node_modules/puppeteer-core/lib/esm/puppeteer/common/BrowserWebSocketTransport.js
var _ws;
var _BrowserWebSocketTransport = class _BrowserWebSocketTransport {
  constructor(ws) {
    __privateAdd(this, _ws);
    __publicField(this, "onmessage");
    __publicField(this, "onclose");
    __privateSet(this, _ws, ws);
    __privateGet(this, _ws).addEventListener("message", (event) => {
      if (this.onmessage) {
        this.onmessage.call(null, event.data);
      }
    });
    __privateGet(this, _ws).addEventListener("close", () => {
      if (this.onclose) {
        this.onclose.call(null);
      }
    });
    __privateGet(this, _ws).addEventListener("error", () => {
    });
  }
  static create(url) {
    return new Promise((resolve, reject) => {
      const ws = new WebSocket(url);
      ws.addEventListener("open", () => {
        return resolve(new _BrowserWebSocketTransport(ws));
      });
      ws.addEventListener("error", reject);
    });
  }
  send(message) {
    __privateGet(this, _ws).send(message);
  }
  close() {
    __privateGet(this, _ws).close();
  }
};
_ws = new WeakMap();
var BrowserWebSocketTransport = _BrowserWebSocketTransport;

export {
  BrowserWebSocketTransport
};
