import type { ComponentType, ReactNode } from "react";

export interface ClientIdentity {
  platform?: string;
  version?: string;
  os?: string;
}

export interface AmasterEmbedProviderProps {
  children: ReactNode;
  apiBaseUrl?: string;
  wsUrl?: string;
  storage?: {
    getItem(key: string): string | null;
    setItem(key: string, value: string): void;
    removeItem(key: string): void;
  };
  cookieAuth?: boolean;
  onLogin?: () => void;
  onLogout?: () => void;
  identity?: ClientIdentity;
  realtime?: boolean;
  locale?: string;
  resources?: Record<string, unknown>;
  localeAdapter?: unknown;
  includeToaster?: boolean;
}

export declare const defaultAmasterEmbedIdentity: ClientIdentity;
export declare function AmasterEmbedProvider(props: AmasterEmbedProviderProps): ReactNode;

export interface AppliedAmasterWorkspaceContext {
  slug: string;
  id: string;
}

export type AmasterWorkspaceScopeState =
  | { kind: "loading"; workspaceSlug: string }
  | { kind: "auth-unavailable"; workspaceSlug: string }
  | { kind: "not-found"; workspaceSlug: string };

export interface AmasterWorkspaceScopeProps {
  workspaceSlug: string;
  children: ReactNode;
  renderState: (state: AmasterWorkspaceScopeState) => ReactNode;
}

export declare function AmasterWorkspaceScope(props: AmasterWorkspaceScopeProps): ReactNode;
export declare function isAmasterWorkspaceContextReady(input: {
  workspaceSlug: string;
  workspace: { id?: string | null } | null | undefined;
  applied: AppliedAmasterWorkspaceContext | null;
}): boolean;
export declare function amasterWorkspaceBySlugOptions(workspaceSlug: string): unknown;

export declare function buildAmasterDigitalApiBase(apiBase: string): string;
export declare function buildAmasterDigitalWsUrl(apiBase: string, endpoint?: string): string;

export interface NavigationAdapter {
  pathname: string;
  searchParams: URLSearchParams;
  push(path: string): void;
  replace(path: string): void;
  back(): void;
  openInNewTab?(path: string): void;
  getShareableUrl?(path: string): string;
}

export declare const NavigationProvider: ComponentType<{ value: NavigationAdapter; children: ReactNode }>;
export declare function useNavigation(): NavigationAdapter;
export declare const AppLink: ComponentType<Record<string, unknown>>;

export declare const ErrorBoundary: ComponentType<Record<string, unknown>>;
export declare const TaskPanelPage: ComponentType<Record<string, unknown>>;
export declare const AgentDetailPage: ComponentType<Record<string, unknown>>;
export declare const AgentsPage: ComponentType<Record<string, unknown>>;
export declare const InboxPage: ComponentType<Record<string, unknown>>;
export declare const IssueDetail: ComponentType<Record<string, unknown>>;
export declare const InvitationsPage: ComponentType<Record<string, unknown>>;
export declare const ModalRegistry: ComponentType<Record<string, unknown>>;
export declare const ProjectsPage: ComponentType<Record<string, unknown>>;
export declare const ProjectDetail: ComponentType<Record<string, unknown>>;
export declare const RuntimesPage: ComponentType<Record<string, unknown>>;
export declare const RuntimeDetailPage: ComponentType<Record<string, unknown>>;
export declare const TokensTab: ComponentType<Record<string, unknown>>;
export declare const NewWorkspacePage: ComponentType<Record<string, unknown>>;
