const e = class {
  static detectEnvironment() {
    var e2;
    if ("undefined" != typeof WebSocket)
      return { type: "native", constructor: WebSocket };
    if ("undefined" != typeof globalThis && void 0 !== globalThis.WebSocket)
      return { type: "native", constructor: globalThis.WebSocket };
    if ("undefined" != typeof global && void 0 !== global.WebSocket)
      return { type: "native", constructor: global.WebSocket };
    if ("undefined" != typeof globalThis && void 0 !== globalThis.WebSocketPair && void 0 === globalThis.WebSocket)
      return { type: "cloudflare", error: "Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.", workaround: "Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime." };
    if ("undefined" != typeof globalThis && globalThis.EdgeRuntime || "undefined" != typeof navigator && (null === (e2 = navigator.userAgent) || void 0 === e2 ? void 0 : e2.includes("Vercel-Edge")))
      return { type: "unsupported", error: "Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.", workaround: "Use serverless functions or a different deployment target for WebSocket functionality." };
    if ("undefined" != typeof process && process.versions && process.versions.node) {
      const e3 = parseInt(process.versions.node.split(".")[0]);
      return e3 >= 22 ? void 0 !== globalThis.WebSocket ? { type: "native", constructor: globalThis.WebSocket } : { type: "unsupported", error: `Node.js ${e3} detected but native WebSocket not found.`, workaround: "Provide a WebSocket implementation via the transport option." } : { type: "unsupported", error: `Node.js ${e3} detected without native WebSocket support.`, workaround: 'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })' };
    }
    return { type: "unsupported", error: "Unknown JavaScript runtime without WebSocket support.", workaround: "Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation." };
  }
  static getWebSocketConstructor() {
    const e2 = this.detectEnvironment();
    if (e2.constructor)
      return e2.constructor;
    let t = e2.error || "WebSocket not supported in this environment.";
    throw e2.workaround && (t += `

Suggested solution: ${e2.workaround}`), new Error(t);
  }
  static createWebSocket(e2, t) {
    return new (this.getWebSocketConstructor())(e2, t);
  }
  static isWebSocketSupported() {
    try {
      const e2 = this.detectEnvironment();
      return "native" === e2.type || "ws" === e2.type;
    } catch (e2) {
      return false;
    }
  }
};
export {
  e as W
};
