import { a as Config, I as ISymbolType, A as ASTNode } from './types-B8V5_S5n.js';
import { a as InterpreterResult } from './interpreter-CEwI0oqN.js';

interface TokenBuilder<T = unknown> {
    onResolve(tokenName: string, value: InterpreterResult): void;
    onError(tokenName: string, error: Error, originalValue: string): void;
    getResult(): T;
    readonly name: string;
}
type OutputFormat = "string" | "symbols";

/**
 * ObjectParser allows custom transformation of structured values into interpreter symbols.
 * This is useful for parsing complex nested structures like { value: 1, unit: "rem" } into NumberWithUnitSymbol.
 *
 * @example
 * const numberWithUnitParser: ObjectParser = {
 *   predicate: (value) => isObject(value) && 'value' in value && 'unit' in value,
 *   toSymbol: ({ value, unit }, config) => new NumberWithUnitSymbol(value, unit, config)
 * }
 */
type ObjectParser = {
    /**
     * Check if this parser should handle the given value
     */
    predicate: (value: unknown) => boolean;
    /**
     * Convert the matched value to an interpreter symbol
     */
    toSymbol: (value: any, config?: Config) => ISymbolType;
};

declare class DependencyGraph<N = string> {
    private nodes;
    addNode(node: N, dependencies?: N[] | Set<N>): void;
    getNodes(): Map<N, Set<N>>;
    entryNodes(): N[];
    private findCycle;
    topologicalSort(): N[];
}

/**
 * Structured token data containing value and optional type information
 */
interface TokenData {
    $value: unknown;
    $type?: string;
}

/**
 * Reference path (token name)
 */
type RefPath = string;
/**
 * Result of token interpretation - can be a successful value or an error
 */
type TokenResult = InterpreterResult | Error;
/**
 * Unresolved token data containing AST and dependency information
 */
interface UnresolvedToken {
    ast: ASTNode;
    dependencies: Set<RefPath>;
}

type ResolvedTokens = Map<RefPath, TokenResult>;
type UnresolvedTokens = Map<RefPath, UnresolvedToken>;
type ProcessorResult = {
    graph: DependencyGraph<RefPath>;
    resolved: ResolvedTokens;
    unresolved: UnresolvedTokens;
    subFieldPaths?: Set<RefPath>;
};
type ProcessorCallbacks = {
    onResolve?: (tokenName: RefPath, value: InterpreterResult) => void;
    onError?: (tokenName: RefPath, error: Error, originalValue: string) => void;
};
type ProcessorOutput = ProcessorResult & {
    tokens: Map<RefPath, InterpreterResult>;
    errors: Map<RefPath, Error>;
};
/**
 * TokenResolver - Resolves tokens with dependencies using prefix-aware resolution
 *
 * @example
 * const processor = new TokenResolver();
 * const tokens = new Map([
 *   ["a", { $value: "10" }],
 *   ["b", { $value: "{a} * 2" }],
 * ]);
 * const result = processor.build(tokens);
 */
declare class TokenResolver {
    processTokens(tokens: Map<RefPath, string | TokenData>, callbacks?: ProcessorCallbacks, config?: Config, objectParsers?: ObjectParser[]): ProcessorResult;
    build(tokens: Map<RefPath, TokenData>, config?: Config, objectParsers?: ObjectParser[]): ProcessorOutput;
}

interface ProcessOptions {
    config?: Config;
    output?: OutputFormat;
    builder?: TokenBuilder<any>;
    objectParsers?: ObjectParser[];
}
interface ProcessSetsOptions extends ProcessOptions {
    activeSets?: string[];
    activeTheme?: string;
}
interface ProcessResult<T = Map<string, string | InterpreterResult>> extends ProcessorOutput {
    output: T;
}
type ProcessFilesOptions<T = any> = {
    path: string;
    outputPath?: string;
    schemas?: string[];
    activeSets?: string[];
    activeTheme?: string;
    output?: "string" | "symbols";
    builder?: TokenBuilder<T>;
    objectParsers?: ObjectParser[];
};

export { type ProcessorOutput as P, type TokenBuilder as T, type ProcessorResult as a, TokenResolver as b, type TokenData as c, type ProcessFilesOptions as d, type ProcessResult as e, type ProcessSetsOptions as f, type ProcessOptions as g };
