import { z } from 'zod';
import type { PDFParse } from 'pdf-parse';
export declare function countWords(text: string): number;
export declare function formatBytes(bytes: number): string;
export declare function formatNumber(n: number | null | undefined): string;
export declare function getExtension(filePath: string): string;
export declare function normalizeRelativePath(filePath: string): string;
export declare function buildExcludeDirGlobs(excludeDir: string[]): string[];
/**
 * Canonical directory names that are almost never wanted in scans or code
 * indexes: package installs, VCS internals, build output, and tool caches.
 * Exported so hosts can pass (or extend) one shared list instead of
 * maintaining their own.
 */
export declare const DEFAULT_EXCLUDE_DIRS: readonly string[];
export declare const EXTENSION_TO_TYPE: Record<string, string>;
export declare const OFFICE_EXTENSIONS: string[];
export declare const METRIC_FIELDS: readonly ["words", "pages", "paragraphs", "sheets", "rows", "cells", "slides"];
export declare const MetricFieldSchema: z.ZodEnum<{
    words: "words";
    pages: "pages";
    paragraphs: "paragraphs";
    sheets: "sheets";
    rows: "rows";
    cells: "cells";
    slides: "slides";
}>;
export type MetricField = z.infer<typeof MetricFieldSchema>;
export interface IgnoreMatcherOptions {
    excludeDir?: string[];
    noGitignore?: boolean;
    ignorePatterns?: string[];
    overlayIgnorePatterns?: string[];
}
export interface IgnoreMatcher {
    ignores(relativePath: string): boolean;
}
export declare function createIgnoreMatcher(rootDir: string, options?: IgnoreMatcherOptions): Promise<IgnoreMatcher>;
export declare function abortIfNeeded(signal?: AbortSignal): void;
export interface CooperativeYieldEvent {
    elapsedMs: number;
    sinceYieldMs: number;
}
export interface CooperativeConfig {
    yieldEveryMs?: number;
    onYield?: (event: CooperativeYieldEvent) => void;
}
export type CooperativeOption = boolean | CooperativeConfig;
export interface Yielder {
    tick(): Promise<void>;
}
export declare function isCooperative(option: CooperativeOption | undefined): option is true | CooperativeConfig;
export declare function createYielder(option: CooperativeOption | undefined, signal?: AbortSignal): Yielder;
/**
 * Map `items` through an async `fn` with at most `concurrency` calls in flight.
 *
 * Results are returned in input order (each worker writes into its item's slot).
 * Non-finite `concurrency` (NaN/Infinity) falls back to 1. The signal is checked
 * before each item is dispatched; an abort surfaces as OccAbortError. The first
 * rejection from `fn` propagates and stops further dispatch (in-flight items may
 * still complete) — callers that need per-item error capture should catch inside `fn`.
 */
export declare function mapWithConcurrency<T, R>(items: readonly T[], concurrency: number, fn: (item: T, index: number) => Promise<R>, signal?: AbortSignal): Promise<R[]>;
export declare function sanitizeForkExecArgv(execArgv?: string[]): string[];
export declare function hasKey(field: string): string;
export declare function writeStream(stream: NodeJS.WritableStream, text: string): Promise<void>;
/**
 * Serialize a machine-readable payload with the CLI's one JSON policy.
 *
 * Compact JSON is the wire default. Callers may opt into indentation for
 * humans with the global `--pretty` flag. NDJSON records, cache files, and
 * canonical/digested JSON deliberately do not use this presentation helper.
 */
export declare function formatPayloadJson(payload: unknown, pretty?: boolean): string;
/**
 * Open a PDF, hand it to `use`, and always release it.
 *
 * `PDFParse` holds a pdf.js document that must be destroyed; a call site that
 * forgets leaks it, and there are three call sites. Centralizing the lifecycle
 * makes forgetting impossible rather than merely discouraged.
 *
 * It lives here — Layer 0 — because the three callers sit in `parsers`,
 * `content`, and `inspect-commands`, which are peers or on different layers and
 * may not import each other. The `import()` is dynamic, so pdf-parse stays off
 * the static graph and out of the startup path; the type import beside it is
 * erased at compile time and does not put it back.
 *
 * `verbosity: ERRORS` is why nothing here patches `console`. pdf.js is chatty
 * about fonts and deprecated APIs, and it takes a verbosity setting — a library
 * asking for quiet should use the switch provided rather than reach into the
 * host's globals.
 */
/** One page's extracted body, in document order. */
export interface PdfPageText {
    num: number;
    text: string;
}
export interface PdfText {
    pages: PdfPageText[];
    /** The pages joined by a blank line, and nothing else. */
    text: string;
    total: number;
}
/**
 * A PDF's text, with the extractor's page furniture left out.
 *
 * `getText().text` interleaves a decorative `-- 1 of 2 --` separator between
 * pages. It reads well in a terminal and is wrong for every use OCC has: it
 * would add five words per page to a word count, and put text into the
 * document that is not in the document. The per-page bodies carry no such
 * decoration, so the joined form is rebuilt from those.
 */
export declare function readPdfText(document: PDFParse): Promise<PdfText>;
export declare function withPdfDocument<T>(buffer: Buffer, use: (document: PDFParse) => Promise<T>): Promise<T>;
/**
 * Rethrow a lazy `import()` failure with the offending package named, so a
 * missing/broken heavy dependency surfaces as an actionable diagnostic instead
 * of a generic per-file parse failure.
 */
export declare function wrapDependencyLoadError(pkg: string, error: unknown): never;
export declare function extractOfficeText(input: string | Buffer): Promise<string>;
/**
 * Locale-independent UTF-16 code-unit comparison. Deterministic wire output
 * must never use `localeCompare`, whose order follows the host locale.
 */
export declare function compareCodeUnits(a: string, b: string): number;
