/**
 * Generated by tsnapi — public API snapshot of `devframe/client`
 */
// #region Interfaces
export interface DevframeConnection {
  connectionMeta: ConnectionMeta;
  metaBaseUrl: string;
  authToken?: string;
}
export interface DevframeRpcClient {
  events: EventEmitter<RpcClientEvents>;
  readonly isTrusted: boolean | null;
  readonly status: DevframeConnectionStatus;
  readonly connectionError: Error | null;
  readonly connection: DevframeConnection;
  readonly connectionMeta: ConnectionMeta;
  ensureTrusted: (_?: number) => Promise<boolean>;
  requestTrust: () => Promise<boolean>;
  requestTrustWithToken: (_: string) => Promise<boolean>;
  requestTrustWithCode: (_: string) => Promise<boolean>;
  call: DevframeRpcClientCall;
  callEvent: DevframeRpcClientCallEvent;
  callOptional: DevframeRpcClientCallOptional;
  client: DevframeClientRpcHost;
  sharedState: RpcSharedStateHost;
  streaming: RpcStreamingClientHost;
  cacheManager: RpcCacheManager;
  scope: {
    <NS extends string>(_: NS): DevframeScopedClientContext<NS, SettingsForNamespace<NS>>;
    (_?: null | ''): DevframeRpcClient;
  };
  close?: () => void;
}
export interface DevframeRpcClientMode {
  readonly isTrusted: boolean;
  readonly status: DevframeConnectionStatus;
  readonly connectionError: Error | null;
  ensureTrusted: DevframeRpcClient['ensureTrusted'];
  requestTrust: DevframeRpcClient['requestTrust'];
  requestTrustWithToken: DevframeRpcClient['requestTrustWithToken'];
  requestTrustWithCode: (_: string) => Promise<string | null>;
  call: DevframeRpcClient['call'];
  callEvent: DevframeRpcClient['callEvent'];
  callOptional: DevframeRpcClient['callOptional'];
  close?: () => void;
}
export interface DevframeRpcClientOptions extends SetupDevframeConnectionOptions {
  authToken?: string;
  otpParam?: string | false;
  simpleAuth?: boolean;
  wsOptions?: Partial<WsRpcChannelOptions>;
  rpcOptions?: Partial<BirpcOptions<DevframeRpcServerFunctions, DevframeRpcClientFunctions, boolean>>;
  cacheOptions?: boolean | Partial<RpcCacheOptions>;
  callTimeout?: number;
}
export interface DevframeRpcContext {
  readonly rpc: DevframeRpcClient;
}
export interface DevframeScopedClientContext<NS extends string = string, Settings extends Record<string, any> = Record<string, any>> {
  readonly namespace: NS;
  readonly base: DevframeRpcClient;
  rpc: DevframeScopedClientRpc<NS>;
  settings: DevframeSettings<Settings>;
  scope: DevframeRpcClient['scope'];
}
export interface DevframeScopedClientRpc<NS extends string = string> {
  readonly namespace: NS;
  register: (_: RpcFunctionDefinition<string, any, any, any, any, any, DevframeRpcContext>) => void;
  call: {
    <T extends keyof ScopedServerFunctions<NS> & string>(_: T, ..._: Parameters<ScopedRpcFn<DevframeRpcServerFunctions, NS, T>>): Promise<Awaited<ReturnType<ScopedRpcFn<DevframeRpcServerFunctions, NS, T>>>>;
    <T extends keyof DevframeRpcServerFunctions & string>(_: T, ..._: Parameters<Extract<DevframeRpcServerFunctions[T], AnyRpcFn>>): Promise<Awaited<ReturnType<Extract<DevframeRpcServerFunctions[T], AnyRpcFn>>>>;
    (_: string, ..._: any[]): Promise<any>;
  };
  callEvent: {
    <T extends keyof ScopedServerFunctions<NS> & string>(_: T, ..._: Parameters<ScopedRpcFn<DevframeRpcServerFunctions, NS, T>>): void;
    <T extends keyof DevframeRpcServerFunctions & string>(_: T, ..._: Parameters<Extract<DevframeRpcServerFunctions[T], AnyRpcFn>>): void;
    (_: string, ..._: any[]): void;
  };
  callOptional: {
    <T extends keyof ScopedServerFunctions<NS> & string>(_: T, ..._: Parameters<ScopedRpcFn<DevframeRpcServerFunctions, NS, T>>): Promise<Awaited<ReturnType<ScopedRpcFn<DevframeRpcServerFunctions, NS, T>>> | undefined>;
    <T extends keyof DevframeRpcServerFunctions & string>(_: T, ..._: Parameters<Extract<DevframeRpcServerFunctions[T], AnyRpcFn>>): Promise<Awaited<ReturnType<Extract<DevframeRpcServerFunctions[T], AnyRpcFn>>> | undefined>;
    (_: string, ..._: any[]): Promise<any>;
  };
  sharedState: {
    <T extends keyof ScopedSharedStates<NS> & string>(_: T, _?: RpcSharedStateGetOptions<ScopedSharedStates<NS>[T]>): Promise<SharedState<ScopedSharedStates<NS>[T]>>;
    <T extends Record<string, any> = Record<string, any>>(_: string, _?: RpcSharedStateGetOptions<T>): Promise<SharedState<T>>;
  };
  streaming: DevframeScopedClientStreamingHost;
}
export interface DevframeScopedClientStreamingHost {
  subscribe: <T = unknown>(_: string, _: string, _?: StreamingSubscribeOptions) => StreamReader<T>;
  upload: <T = unknown>(_: string, _: string) => StreamSink<T>;
}
export interface RpcClientEvents {
  'rpc:is-trusted:updated': (_: boolean) => void;
  'connection:status': (_: DevframeConnectionStatus, _: DevframeConnectionStatus) => void;
  'connection:error': (_: Error) => void;
  'rpc:error': (_: Error, _: string) => void;
}
export interface RpcStreamingClientHost {
  subscribe: <T = unknown>(_: string, _: string, _?: StreamingSubscribeOptions) => StreamReader<T>;
  upload: <T = unknown>(_: string, _: string) => StreamSink<T>;
}
export interface SetupDevframeConnectionOptions {
  connection?: DevframeConnection;
  connectionMeta?: ConnectionMeta;
  baseURL?: string | string[];
  authToken?: string;
}
export interface StreamingSubscribeOptions {
  highWaterMark?: number;
}
export interface WsUrlLocation {
  protocol: string;
  host: string;
  hostname: string;
  href: string;
}
// #endregion

// #region Types
export type DevframeClientRpcHost = RpcFunctionsCollector<DevframeRpcClientFunctions, DevframeRpcContext>;
export type DevframeConnectionErrorKind = 'connection' | 'auth' | 'timeout';
export type DevframeConnectionStatus = 'connecting' | 'connected' | 'unauthorized' | 'disconnected' | 'error';
export type DevframeRpcClientCall = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$call'];
export type DevframeRpcClientCallEvent = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callEvent'];
export type DevframeRpcClientCallOptional = BirpcReturn<DevframeRpcServerFunctions, DevframeRpcClientFunctions>['$callOptional'];
// #endregion

// #region Classes
export declare class DevframeConnectionError extends Error {
  name: string;
  readonly kind: DevframeConnectionErrorKind;
  constructor(_: DevframeConnectionErrorKind, _: string, _?: {
    cause?: unknown;
  });
}
// #endregion

// #region Functions
export declare function authenticateWithUrlOtp(_: Pick<DevframeRpcClient, 'isTrusted' | 'requestTrustWithCode'>, _?: {
  param?: string;
}): Promise<boolean>;
export declare function consumeOtpFromUrl(_?: string): string | undefined;
export declare function createClientSettings<T extends Record<string, any> = Record<string, any>>(_: DevframeRpcClient, _: string): DevframeSettings<T>;
export declare function createRpcStreamingClientHost(_: DevframeRpcClient): RpcStreamingClientHost;
export declare function createScopedClientContext<NS extends string = string>(_: DevframeRpcClient, _: NS): DevframeScopedClientContext<NS>;
export declare function getDevframeConnection(): DevframeConnection | undefined;
export declare function getDevframeRpcClient(_?: DevframeRpcClientOptions): Promise<DevframeRpcClient>;
export declare function isCallableStatus(_: DevframeConnectionStatus): boolean;
export declare function readOtpFromUrl(_?: string): string | undefined;
export declare function registerDevframeViewerOrigin(_: DevframeConnection, _?: any): Promise<boolean>;
export declare function resolveWsUrl(_: ConnectionMeta['websocket'], _: string, _: WsUrlLocation): string;
export declare function setupDevframeConnection(_?: SetupDevframeConnectionOptions): Promise<DevframeConnection>;
// #endregion

// #region Variables
export declare const connectDevframe: typeof getDevframeRpcClient;
// #endregion