'use client'

// hooks/index.ts
import {
  useQuery,
  useMutation,
  useInfiniteQuery,
  useTransport,
  createConnectQueryKey
} from "@connectrpc/connect-query";
import { ConnectError as ConnectError2, Code as Code2 } from "@connectrpc/connect";

// utils/error.ts
import { Code, ConnectError } from "@connectrpc/connect";
var DEFAULT_ERROR_MESSAGE = "Something went wrong";
function handleConnectError(error, handlers) {
  var _a;
  const connectError = error instanceof ConnectError ? error : new ConnectError(
    typeof error === "string" ? error : error instanceof Error ? error.message : DEFAULT_ERROR_MESSAGE
  );
  const defaultHandler = (_a = handlers == null ? void 0 : handlers.Default) != null ? _a : (err) => console.error(err.message);
  switch (connectError.code) {
    case Code.AlreadyExists:
      (handlers == null ? void 0 : handlers.AlreadyExists) ? handlers.AlreadyExists(connectError) : defaultHandler(connectError);
      break;
    case Code.InvalidArgument:
      (handlers == null ? void 0 : handlers.InvalidArgument) ? handlers.InvalidArgument(connectError) : defaultHandler(connectError);
      break;
    case Code.PermissionDenied:
      (handlers == null ? void 0 : handlers.PermissionDenied) ? handlers.PermissionDenied(connectError) : defaultHandler(connectError);
      break;
    case Code.NotFound:
      (handlers == null ? void 0 : handlers.NotFound) ? handlers.NotFound(connectError) : defaultHandler(connectError);
      break;
    case Code.FailedPrecondition:
      (handlers == null ? void 0 : handlers.FailedPrecondition) ? handlers.FailedPrecondition(connectError) : defaultHandler(connectError);
      break;
    default:
      defaultHandler(connectError);
  }
}

// hooks/index.ts
import { FrontierServiceQueries } from "@raystack/proton/frontier";
import { useQueryClient } from "@tanstack/react-query";
import { create } from "@bufbuild/protobuf";
export {
  Code2 as Code,
  ConnectError2 as ConnectError,
  FrontierServiceQueries,
  create,
  createConnectQueryKey,
  handleConnectError,
  useInfiniteQuery,
  useMutation,
  useQuery,
  useQueryClient,
  useTransport
};
