// modules/react/sockets/index.ts
import { io } from "socket.io-client";
var lolySocket = (namespace, opts) => {
  if (typeof window === "undefined") {
    throw new Error(
      "[loly:socket] lolySocket can only be called on the client side."
    );
  }
  const normalizedNamespace = namespace.startsWith("/") ? namespace : `/${namespace}`;
  console.log("[loly:socket] Connecting to namespace:", normalizedNamespace, "path:", "/wss");
  const socket = io(normalizedNamespace, {
    path: "/wss",
    transports: ["websocket", "polling"],
    autoConnect: true,
    ...opts
  });
  socket.on("connect_error", (error) => {
    console.error("[loly:socket] Connection error:", error.message);
    console.error("[loly:socket] Namespace:", normalizedNamespace);
  });
  socket.on("connect", () => {
    console.log("[loly:socket] \u2705 Connected to namespace:", normalizedNamespace);
  });
  return socket;
};
export {
  lolySocket
};
//# sourceMappingURL=sockets.js.map