import { ClassValue } from 'clsx';

/**
 * Orbital State Machine Visualizer
 *
 * Renders SVG diagrams from Orbital schemas and Trait definitions.
 * Can be used in documentation, IDE previews, and other tools.
 */
interface VisualizerConfig {
    nodeRadius: number;
    nodeSpacing: number;
    initialIndicatorOffset: number;
    arrowSize: number;
    colors: {
        background: string;
        node: string;
        nodeBorder: string;
        nodeText: string;
        initialNode: string;
        finalNode: string;
        arrow: string;
        arrowText: string;
        effectText: string;
        guardText: string;
        initial: string;
    };
    fonts: {
        node: string;
        event: string;
        effect: string;
    };
}
interface StateDefinition {
    name: string;
    isInitial?: boolean;
    isFinal?: boolean;
    description?: string;
}
interface TransitionDefinition {
    from: string;
    to: string;
    event: string;
    guard?: unknown;
    effects?: unknown[];
}
interface StateMachineDefinition {
    states: StateDefinition[];
    transitions: TransitionDefinition[];
}
interface EntityDefinition {
    name: string;
    fields?: (string | {
        name: string;
    })[];
}
interface RenderOptions {
    title?: string;
    entity?: EntityDefinition;
}
/** Position data for a state node in DOM layout */
interface DomStateNode {
    id: string;
    name: string;
    x: number;
    y: number;
    radius: number;
    isInitial: boolean;
    isFinal: boolean;
    description?: string;
}
/** Position data for a transition arrow */
interface DomTransitionPath {
    id: string;
    from: string;
    to: string;
    /** SVG path data for the curved arrow */
    pathData: string;
    /** Midpoint for label positioning */
    labelX: number;
    labelY: number;
}
/** Position data for a transition label with guard/effect details */
interface DomTransitionLabel {
    id: string;
    from: string;
    to: string;
    event: string;
    x: number;
    y: number;
    /** Human-readable guard text (e.g., "if amount > 100") */
    guardText?: string;
    /** Human-readable effect texts */
    effectTexts: string[];
    /** Whether this transition has details to show in tooltip */
    hasDetails: boolean;
}
/** Entity input box data */
interface DomEntityBox {
    name: string;
    fields: string[];
    x: number;
    y: number;
    width: number;
    height: number;
}
/** Output effects box data */
interface DomOutputsBox {
    outputs: string[];
    x: number;
    y: number;
    width: number;
    height: number;
}
/** Complete DOM layout data for rendering */
interface DomLayoutData {
    width: number;
    height: number;
    title?: string;
    states: DomStateNode[];
    paths: DomTransitionPath[];
    labels: DomTransitionLabel[];
    entity?: DomEntityBox;
    outputs?: DomOutputsBox;
    config: VisualizerConfig;
}
declare const DEFAULT_CONFIG: VisualizerConfig;
declare function formatGuard(guard: unknown): string;
declare function getEffectSummary(effects: unknown[]): string;
declare function extractOutputsFromTransitions(transitions: TransitionDefinition[]): string[];
/**
 * Render a state machine to an SVG string.
 * Works in both browser and Node.js environments.
 */
declare function renderStateMachineToSvg(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): string;
/**
 * Extract state machine from various data formats (Trait, Orbital, or raw)
 */
declare function extractStateMachine(data: unknown): StateMachineDefinition | null;
/**
 * Render a state machine to DOM layout data.
 * This is used by the DOM-based visualizer component for hybrid SVG/DOM rendering.
 * Unlike renderStateMachineToSvg, this returns structured data instead of an SVG string.
 */
declare function renderStateMachineToDomData(stateMachine: StateMachineDefinition, options?: RenderOptions, config?: VisualizerConfig): DomLayoutData;

/**
 * Content Segment Parsing Utilities
 *
 * Parses rich content with code blocks and quiz tags into structured
 * segments for rendering. Detects orbital schemas in JSON code blocks
 * and marks them for JazariStateMachine rendering.
 */
/** Segment types for content rendering */
type ContentSegment = {
    type: 'markdown';
    content: string;
} | {
    type: 'code';
    language: string;
    content: string;
} | {
    type: 'orbital';
    language: string;
    content: string;
    schema: unknown;
} | {
    type: 'quiz';
    question: string;
    answer: string;
};
/**
 * Parse markdown content to extract code blocks.
 *
 * Splits markdown into segments of plain markdown and fenced code blocks.
 * JSON/orb code blocks containing orbital schemas are tagged as 'orbital'.
 */
declare function parseMarkdownWithCodeBlocks(content: string | undefined | null): ContentSegment[];
/**
 * Parse content to extract all segments including quiz tags and code blocks.
 *
 * Supported tags:
 * - <question>q</question><answer>a</answer> — Quiz Q&A
 *
 * Also handles fenced code blocks (```language...```) with orbital detection.
 */
declare function parseContentSegments(content: string | undefined | null): ContentSegment[];

/**
 * Verification Registry - Tracks runtime verification checks and transition traces
 *
 * Provides:
 * 1. A checklist of pass/fail checks (INIT has fetch, bridge connected, etc.)
 * 2. A full transition timeline with effect execution results
 * 3. ServerBridge health snapshot
 * 4. window.__orbitalVerification for Playwright/automation
 *
 * @packageDocumentation
 */
type CheckStatus = "pass" | "fail" | "pending" | "warn";
interface VerificationCheck {
    id: string;
    label: string;
    status: CheckStatus;
    details?: string;
    /** Timestamp when status last changed */
    updatedAt: number;
}
interface EffectTrace {
    type: string;
    args: unknown[];
    status: "executed" | "failed" | "skipped";
    error?: string;
    durationMs?: number;
}
interface TransitionTrace {
    id: string;
    traitName: string;
    from: string;
    to: string;
    event: string;
    guardExpression?: string;
    guardResult?: boolean;
    effects: EffectTrace[];
    timestamp: number;
}
interface BridgeHealth {
    connected: boolean;
    eventsForwarded: number;
    eventsReceived: number;
    lastError?: string;
    lastHeartbeat: number;
}
interface VerificationSummary {
    totalChecks: number;
    passed: number;
    failed: number;
    warnings: number;
    pending: number;
}
interface VerificationSnapshot {
    checks: VerificationCheck[];
    transitions: TransitionTrace[];
    bridge: BridgeHealth | null;
    summary: VerificationSummary;
}
type ChangeListener = () => void;
declare function registerCheck(id: string, label: string, status?: CheckStatus, details?: string): void;
declare function updateCheck(id: string, status: CheckStatus, details?: string): void;
declare function getAllChecks(): VerificationCheck[];
declare function recordTransition(trace: Omit<TransitionTrace, "id">): void;
declare function getTransitions(): TransitionTrace[];
declare function getTransitionsForTrait(traitName: string): TransitionTrace[];
declare function updateBridgeHealth(health: BridgeHealth): void;
declare function getBridgeHealth(): BridgeHealth | null;
declare function getSummary(): VerificationSummary;
declare function getSnapshot(): VerificationSnapshot;
declare function subscribeToVerification(listener: ChangeListener): () => void;
/** Asset load status for canvas verification */
type AssetLoadStatus = "loaded" | "failed" | "pending";
/** Event bus log entry for verification */
interface EventLogEntry {
    type: string;
    payload?: Record<string, unknown>;
    timestamp: number;
}
/** Exposed on window for Playwright to query */
interface OrbitalVerificationAPI {
    getSnapshot: () => VerificationSnapshot;
    getChecks: () => VerificationCheck[];
    getTransitions: () => TransitionTrace[];
    getBridge: () => BridgeHealth | null;
    getSummary: () => VerificationSummary;
    /** Wait for a specific event to be processed */
    waitForTransition: (event: string, timeoutMs?: number) => Promise<TransitionTrace | null>;
    /** Send an event into the runtime (requires eventBus binding) */
    sendEvent?: (event: string, payload?: Record<string, unknown>) => void;
    /** Get current trait state */
    getTraitState?: (traitName: string) => string | undefined;
    /** Capture a canvas frame as PNG data URL. Registered by game organisms. */
    captureFrame?: () => string | null;
    /** Asset load status map. Registered by game organisms. */
    assetStatus?: Record<string, AssetLoadStatus>;
    /** Event bus log. Records all emit() calls for verification. */
    eventLog?: EventLogEntry[];
    /** Clear the event log. */
    clearEventLog?: () => void;
}
declare global {
    interface Window {
        __orbitalVerification?: OrbitalVerificationAPI;
    }
}
/**
 * Wait for a transition matching the given event to appear.
 * Returns the trace or null on timeout.
 */
declare function waitForTransition(event: string, timeoutMs?: number): Promise<TransitionTrace | null>;
/**
 * Bind the EventBus so automation can send events and log emissions.
 * Call this during app initialization.
 */
declare function bindEventBus(eventBus: {
    emit: (type: string, payload?: Record<string, unknown>) => void;
    onAny?: (listener: (event: {
        type: string;
        payload?: Record<string, unknown>;
    }) => void) => () => void;
}): void;
/**
 * Bind a trait state getter so automation can query current states.
 */
declare function bindTraitStateGetter(getter: (traitName: string) => string | undefined): void;
/**
 * Register a canvas frame capture function.
 * Called by game organisms (IsometricCanvas, PlatformerCanvas, SimulationCanvas)
 * so the verifier can snapshot canvas content at checkpoints.
 */
declare function bindCanvasCapture(captureFn: () => string | null): void;
/**
 * Update asset load status for canvas verification.
 * Game organisms call this when images load or fail.
 */
declare function updateAssetStatus(url: string, status: AssetLoadStatus): void;
declare function clearVerification(): void;

/**
 * Utility function to merge Tailwind CSS classes
 * Combines clsx for conditional classes with tailwind-merge to handle conflicts
 */
declare function cn(...inputs: ClassValue[]): string;

export { type AssetLoadStatus as A, type BridgeHealth as B, type CheckStatus as C, DEFAULT_CONFIG as D, type EffectTrace as E, getSummary as F, getTransitions as G, getTransitionsForTrait as H, parseContentSegments as I, parseMarkdownWithCodeBlocks as J, recordTransition as K, registerCheck as L, renderStateMachineToDomData as M, renderStateMachineToSvg as N, subscribeToVerification as O, updateAssetStatus as P, updateBridgeHealth as Q, type RenderOptions as R, type StateDefinition as S, type TransitionDefinition as T, updateCheck as U, type VerificationCheck as V, waitForTransition as W, type ContentSegment as a, type DomEntityBox as b, type DomLayoutData as c, type DomOutputsBox as d, type DomStateNode as e, type DomTransitionLabel as f, type DomTransitionPath as g, type EntityDefinition as h, type EventLogEntry as i, type StateMachineDefinition as j, type TransitionTrace as k, type VerificationSnapshot as l, type VerificationSummary as m, type VisualizerConfig as n, bindCanvasCapture as o, bindEventBus as p, bindTraitStateGetter as q, clearVerification as r, cn as s, extractOutputsFromTransitions as t, extractStateMachine as u, formatGuard as v, getAllChecks as w, getBridgeHealth as x, getEffectSummary as y, getSnapshot as z };
