import type { PositionedDie, Wafer } from '../core/index.js';
export type PatternLabel = 'center' | 'donut' | 'edge-ring' | 'edge-local' | 'scratch' | 'near-full' | 'random' | 'none';
export interface PatternFeatures {
    /** Ratio of failing dies to total eligible dies (whole-wafer). */
    globalRdd: number;
    /** Ratio of failing dies in the outermost ring to total outermost-ring dies (whole-wafer). */
    edgeRdd: number;
    /** Distance from wafer centre to centroid of the salient region, normalised by wafer radius. */
    centroidDistNorm: number;
    /** Minimum distance from wafer centre among salient-region dies, normalised by radius. */
    minDistNorm: number;
    /** Maximum distance from wafer centre among salient-region dies, normalised by radius. */
    maxDistNorm: number;
    /**
     * 25th-percentile radial distance among ALL failing dies, normalised by radius.
     * Used for donut detection: a true donut has most fails away from the centre
     * even when the salient component incidentally touches the centre.
     */
    p25DistNorm: number;
    /**
     * Ratio of failure density in the inner half (r < 0.5) vs outer half (r >= 0.5).
     * Center: inner > outer (ratio > 1). Donut: outer > inner (ratio < 1).
     */
    innerOuterRatio: number;
    /**
     * Eccentricity of the bounding ellipse around the salient region (0 = circle, 1 = line).
     * Derived from the 2nd-order central moments of the salient-region die positions.
     */
    eccentricity: number;
    /**
     * Linear score: fraction of salient-region dies in the single best collinear run
     * (along row or column), normalised to [0, 1].
     */
    linearScore: number;
    /** Number of dies in the most salient (largest) connected component of failing dies. */
    salienceSize: number;
    /** Fraction of all failing dies that belong to the salient region. */
    salienceFraction: number;
    /**
     * Fraction of the full circumference (0–1) covered by edge-zone failing dies,
     * measured in 16 angular sectors. 1.0 = all sectors occupied (full ring),
     * low value = concentrated arc (edge-local).
     */
    edgeAngularSpread: number;
}
export interface PatternClassification {
    pattern: PatternLabel;
    confidence: 'high' | 'medium' | 'low';
    features: PatternFeatures;
    /** Human-readable note about classification uncertainty, when applicable. */
    note?: string;
}
export interface PatternThresholds {
    nearFullGlobalRdd: number;
    edgeRingEdgeRdd: number;
    edgeRingEdgeRddHigh: number;
    edgeRingRadialSpread: number;
    /** Minimum angular spread (0–1) for edge-ring vs edge-local classification. */
    edgeRingAngularSpread: number;
    edgeLocalEdgeRdd: number;
    /** p25DistNorm separator: ≥ this → edge-ring; [0.55, this) → edge-local. */
    edgeLocalCentroidDist: number;
    /** p25DistNorm separator: &lt; this → center; [this, 0.55) → donut. */
    donutP25Dist: number;
    centerCentroidDist: number;
    centerCentroidDistHigh: number;
    centerEdgeRdd: number;
    donutEdgeRdd: number;
    scratchLinearScore: number;
    scratchLinearScoreHigh: number;
    scratchEccentricity: number;
    minimumFailingDies: number;
}
/**
 * Default thresholds for the spatial pattern classifier.
 *
 * Calibrated against WM-811K — 25,519 labelled real-world wafers from TSMC
 * 300mm fabrication (Wu et al. 2015). Benchmark results on that dataset:
 *
 * | Pattern    | Recall | Notes                                      |
 * |------------|--------|--------------------------------------------|
 * | Near-full  | 100%   |                                            |
 * | Edge-ring  |  74%   |                                            |
 * | Edge-local |  65%   |                                            |
 * | Center     |  60%   |                                            |
 * | Random     |  59%   |                                            |
 * | Scratch    |  26%   | Fragmented patterns harder to detect       |
 * | Donut      |  15%   | Geometrically similar to center with noise |
 *
 * Overall accuracy: 64% exact match, 86% detection rate (any pattern flagged).
 */
export declare const DEFAULT_PATTERN_THRESHOLDS: PatternThresholds;
/**
 * Classify the spatial failure pattern of a wafer from its die data.
 *
 * Uses connected-component analysis to identify the most salient (largest)
 * failing region, then computes shape and position features on that region.
 * Global statistics (RDD, edge RDD) are computed over all failing dies.
 *
 * Returns `null` when the failing-die count is below the minimum threshold
 * (`thresholds.minimumFailingDies`, default 5) — too few failures to classify.
 */
export declare function classifyPattern(dies: PositionedDie[], wafer: Wafer, options: {
    passBins: number[];
    ringCount?: number;
}): PatternClassification | null;
//# sourceMappingURL=patternClassification.d.ts.map