import { ref, readonly } from 'vue';

function useWebSocket(options = {}) {
  const { autoConnect = true, reconnectDelay = 3e3, maxReconnectAttempts = 5 } = options;
  const isConnected = ref(false);
  const lastMessage = ref(null);
  const clientId = ref(null);
  ref(0);
  let ws = null;
  const connect = () => {
    return;
  };
  const disconnect = () => {
    isConnected.value = false;
    clientId.value = null;
  };
  const send = (message) => {
    if (ws?.readyState === WebSocket.OPEN) {
      ws.send(JSON.stringify(message));
    } else {
      console.warn("[WS] Cannot send message: not connected");
    }
  };
  const subscribe = (channel) => {
    if (ws?.readyState === WebSocket.OPEN) {
      ws.send(JSON.stringify({ type: "subscribe", channel }));
    }
  };
  const unsubscribe = (channel) => {
    if (ws?.readyState === WebSocket.OPEN) {
      ws.send(JSON.stringify({ type: "unsubscribe", channel }));
    }
  };
  return {
    isConnected: readonly(isConnected),
    lastMessage,
    clientId: readonly(clientId),
    connect,
    disconnect,
    send,
    subscribe,
    unsubscribe
  };
}

export { useWebSocket as u };
//# sourceMappingURL=useWebSocket-UbMCn0vY.mjs.map
