import { C as ClientPlugin } from '../../shared/stack.7n9Y_u7N.js';
export { P as PluginOverrides } from '../../shared/stack.7n9Y_u7N.js';
import { Route } from '@btst/yar';
export { Route, createRoute, createRouter } from '@btst/yar';
import { createClient } from 'better-call/client';
export { createClient } from 'better-call/client';
import { Router, Endpoint } from 'better-call';
import '@btst/db';

/**
 * Client-side equivalent of runHookWithShim — throws a plain Error instead of an HTTP error.
 * Hooks may deny by returning false (old) or throwing (new); both normalize to an Error.
 *
 * See `runHookWithShim` for the full migration note on boolean-vs-void semantics.
 */
declare function runClientHookWithShim<T>(hookFn: () => Promise<T> | T, defaultMessage: string): Promise<Exclude<Awaited<T>, false>>;
/**
 * Returns true when a fetch error is a connection-refused / no-server error.
 * Used in SSR loaders to emit an actionable build-time warning when
 * `route.loader()` is called during `next build` with no HTTP server running.
 */
declare function isConnectionError(err: unknown): boolean;

interface CreateApiClientOptions {
    baseURL?: string;
    basePath?: string;
}
/**
 * Creates a Better Call API client with proper URL handling for both server and client side
 * @param options - Configuration options
 * @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
 * @param options.basePath - The API base path (defaults to '/')
 * @template TRouter - The router type (Router or Record<string, Endpoint>)
 */
declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;

/**
 * Plugin utilities and types for building standalone plugins
 *
 * This module exports everything needed to create custom plugins
 * for BTST outside of this package.
 *
 * Note: Backend and Client plugins are separate to prevent SSR issues
 * and enable better code splitting. Import them separately:
 * - Backend: import type { BackendPlugin } from "@btst/stack/plugins/api"
 * - Client: import type { ClientPlugin } from "@btst/stack/plugins/client"
 */

/**
 * Helper to define a client plugin with full type inference
 *
 * Automatically infers route keys, hook names, and their types without needing casts.
 *
 * @example
 * ```ts
 * const messagesPlugin = defineClientPlugin({
 *   name: "messages",
 *   routes: () => ({
 *     messagesList: createRoute("/messages", () => ({ ... }))
 *   }),
 *   sitemap: () => [{ url: "/messages", lastModified: new Date(), priority: 0.8 }]
 * });
 * ```
 *
 * @template TOverrides - The shape of overridable components/functions this plugin requires
 * @template TRoutes - The exact shape of routes this plugin provides (preserves keys and route types)
 */
declare function defineClientPlugin<TOverrides = Record<string, never>, TRoutes extends Record<string, Route> = Record<string, Route>>(plugin: ClientPlugin<TOverrides, TRoutes>): ClientPlugin<TOverrides, TRoutes>;

export { ClientPlugin, createApiClient, defineClientPlugin, isConnectionError, runClientHookWithShim };
