import { I as ISymbolType, T as Token, C as Config, A as ASTNode } from '../config-Cp5BqDfR.js';

type InterpreterResult = ISymbolType | string | null;

declare enum ProcessorErrorCode {
    TOKEN_NOT_FOUND = "PROC_TOKEN_NOT_FOUND",
    TOKEN_ALREADY_EXISTS = "PROC_TOKEN_ALREADY_EXISTS",
    CIRCULAR_DEPENDENCY = "PROC_CIRCULAR_DEPENDENCY",
    SUB_FIELD_NOT_RESOLVED = "PROC_SUB_FIELD_NOT_RESOLVED",
    DEPENDENCY_ERROR = "PROC_DEPENDENCY_ERROR",
    NO_THEMES_FOUND = "PROC_NO_THEMES_FOUND",
    THEME_NOT_FOUND = "PROC_THEME_NOT_FOUND",
    TOKEN_SET_NOT_FOUND = "PROC_TOKEN_SET_NOT_FOUND",
    TOKEN_SET_INVALID = "PROC_TOKEN_SET_INVALID",
    NO_SETS_TO_PROCESS = "PROC_NO_SETS_TO_PROCESS",
    MULTIPLE_SETS_NO_SELECTION = "PROC_MULTIPLE_SETS_NO_SELECTION",
    UNKNOWN_PARSING_ERROR = "PROC_UNKNOWN_PARSING_ERROR",
    RESOLVER_NOT_INITIALIZED = "PROC_RESOLVER_NOT_INITIALIZED"
}

interface ErrorOptions {
    token?: Token;
    line?: number;
    data?: Record<string, unknown>;
    cause?: unknown;
}
declare class LanguageError extends Error {
    readonly code: string;
    readonly data: Record<string, unknown>;
    readonly line?: number;
    readonly token?: Token;
    readonly originalMessage: string;
    constructor(code: string, options?: ErrorOptions);
    private formatMessage;
}
declare class ProcessorError extends LanguageError {
    readonly code: ProcessorErrorCode;
    constructor(code: ProcessorErrorCode, options?: ErrorOptions);
}

declare class DependencyGraph<N = string> {
    private nodes;
    addNode(node: N, dependencies?: N[] | Set<N>): void;
    removeNode(node: 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 delimited by `.`)
 */
type RefPath = string;
type TokenInputMap = Map<RefPath, string | TokenData>;
type TokenDataMap$1 = Map<RefPath, TokenData>;
type ResolvedValueMap = Map<RefPath, InterpreterResult>;
type TokenResult = InterpreterResult | Error;
type TokenResultMap = Map<RefPath, TokenResult>;
/**
 * An issue found during token resolution.
 * Can be a lint issue or a language error (lexer/parser/interpreter/processor).
 */
type ResolveIssue = LintIssue | LanguageError;
type IssuesMap = Map<RefPath, ResolveIssue[]>;
type TokenOperationBase = {
    tokenPath: RefPath;
};
type CreateTokenParams = TokenOperationBase & {
    tokenData: TokenData;
};
type UpdateTokenParams = TokenOperationBase & {
    tokenData?: TokenData;
    tokenPathRenamed?: RefPath;
    updateReferences?: boolean;
};
type DeleteTokenParams = TokenOperationBase;
type TokenOperationResult = {
    tokens: ResolvedValueMap;
    resolved?: InterpreterResult;
    issues?: IssuesMap;
    dependants?: {
        graph: DependencyGraph<RefPath>;
    };
};
type CreateTokenResult = TokenOperationResult & {
    created: boolean;
};
type UpdateTokenResult = TokenOperationResult & {
    updated: boolean;
};
type DeleteTokenResult = TokenOperationResult;

declare enum LintSeverity {
    ERROR = "error",
    WARNING = "warning",
    INFO = "info"
}
/**
 * A lint issue found during token validation.
 *
 * @property code - Unique error code for this specific issue type
 * @property severity - Severity level (ERROR, WARNING, INFO)
 * @property message - Human-readable description of the issue
 * @property tokenName - The token where the issue was found
 * @property path - Path to the specific field within a structured token (e.g., ["fontSize"] or [0, "blur"] for arrays)
 * @property line - Optional line number in the source
 * @property data - Additional structured data for debugging
 */
interface LintIssue {
    code: string;
    severity: LintSeverity;
    message: string;
    tokenName: RefPath;
    path?: (string | number)[];
    line?: number;
    data?: Record<string, unknown>;
}
/**
 * Map of token names to their lint issues.
 */
type LintResult = Map<RefPath, LintIssue[]>;
/**
 * Context provided to lint rules during validation.
 *
 * @property tokenName - The token being validated
 * @property tokenType - Token type (e.g., "color", "opacity")
 * @property config - Interpreter configuration
 * @property allTokens - All tokens in the current set
 * @property resolvedTokens - Previously resolved tokens for cross-validation
 * @property ast - The AST of the token expression
 */
interface LintContext {
    tokenName: RefPath;
    tokenType?: string;
    config?: Config;
    allTokens: TokenDataMap$1;
    resolvedTokens?: ResolvedValueMap;
    ast?: ASTNode;
}
/**
 * A lint rule that validates token values.
 *
 * @property id - Unique identifier for this rule
 * @property severity - Default severity level for issues
 * @property tokenTypes - Optional filter: only run for specific token types
 * @property validate - Validate a token value and return any issues found
 */
interface LintRule {
    id: string;
    severity: LintSeverity;
    tokenTypes?: string[];
    validate(value: InterpreterResult, context: LintContext): LintIssue[];
}
/**
 * Linter configuration.
 *
 * @property rules - Rule overrides: false to disable, severity to override default
 */
interface LintConfig {
    rules?: Record<string, boolean | LintSeverity>;
}
/**
 * Function to create a lint issue.
 */
type CreateIssueFn = (issue: LintIssue) => LintIssue;

declare abstract class BaseLintRule implements LintRule {
    abstract id: string;
    abstract severity: LintSeverity;
    tokenTypes?: string[];
    abstract validate(value: InterpreterResult, context: LintContext): LintIssue[];
    protected createIssue: CreateIssueFn;
}

type TokenTypeValidator = (value: InterpreterResult, context: LintContext, createIssue: CreateIssueFn) => LintIssue | LintIssue[] | null | undefined;
type TokenTypeValidatorMap = Record<string, TokenTypeValidator>;
declare class TypeBasedRule extends BaseLintRule {
    id: string;
    severity: LintSeverity;
    private validators;
    private defaultValidator?;
    constructor(validators?: TokenTypeValidatorMap);
    forType(tokenType: string, validator: TokenTypeValidator): this;
    forDefault(validator: TokenTypeValidator): this;
    /**
     * Returns a copy of the internal validator map.
     * Useful for extending rules.
     */
    getValidators(): Map<string, TokenTypeValidator>;
    /**
     * Returns the default validator, if set.
     */
    getDefaultValidator(): TokenTypeValidator | undefined;
    validate(value: InterpreterResult, context: LintContext): LintIssue[];
}

declare class LintRunner {
    private rules;
    private config;
    constructor(config?: LintConfig);
    addRule(rule: LintRule): this;
    /**
     * Creates a new LintRunner that extends this one with additional/overridden validators.
     *
     * Merges TypeBasedRule validators from the current runner with the provided overrides.
     * Override validators replace existing ones for the same token type.
     * Non-TypeBasedRule rules are preserved in their original order relative to TypeBasedRules.
     *
     * @param overrides - Map of token types to validators to add or override
     * @returns A new LintRunner with merged validators
     *
     * @example
     * const cssRules = css.createLintRunner();
     * const penpotRules = cssRules.extend({
     *   "border-radius": all(css.borderRadius, customValidator),
     *   "stroke-width": penpot.strokeWidthValidator,
     * });
     */
    extend(overrides: TokenTypeValidatorMap): LintRunner;
    lintResult(options: {
        tokenName: RefPath;
        tokenType: string | undefined;
        result: InterpreterResult;
        allTokens: TokenDataMap$1;
        resolvedTokens?: ResolvedValueMap;
        config?: Config;
        ast?: ASTNode;
    }): LintIssue[];
    private isRuleEnabled;
    private applyOverrides;
}

/**
 * Error codes for preset validators.
 * Used to identify specific validation failures.
 */
declare enum ValidatorCode {
    EXPECTED_NUMBER = "EXPECTED_NUMBER",
    EXPECTED_STRING = "EXPECTED_STRING",
    EXPECTED_BOOLEAN = "EXPECTED_BOOLEAN",
    EXPECTED_COLOR = "EXPECTED_COLOR",
    EXPECTED_NUMBER_WITH_UNIT = "EXPECTED_NUMBER_WITH_UNIT",
    EXPECTED_LIST = "EXPECTED_LIST",
    EXPECTED_STRUCTURED = "EXPECTED_STRUCTURED",
    VALUE_TOO_SMALL = "VALUE_TOO_SMALL",
    VALUE_TOO_LARGE = "VALUE_TOO_LARGE",
    VALUE_NOT_IN_ENUM = "VALUE_NOT_IN_ENUM",
    UNIT_NOT_ALLOWED = "UNIT_NOT_ALLOWED",
    UNIT_DISALLOWED = "UNIT_DISALLOWED",
    LIST_LENGTH_INVALID = "LIST_LENGTH_INVALID",
    REQUIRED_FIELD_MISSING = "REQUIRED_FIELD_MISSING",
    FIELD_MISSING = "FIELD_MISSING",
    UNKNOWN_FIELD = "UNKNOWN_FIELD"
}

/**
 * CSS border-radius: <length-percentage>{1,4}
 * https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius
 *
 * Accepts 1-4 non-negative length or percentage values:
 * - 1 value: all four corners
 * - 2 values: top-left/bottom-right, top-right/bottom-left
 * - 3 values: top-left, top-right/bottom-left, bottom-right
 * - 4 values: top-left, top-right, bottom-right, bottom-left
 *
 * Note: This validates simple border-radius, not the full syntax
 * with horizontal/vertical radii separated by "/".
 */
declare const borderRadius: ValueValidator;
declare const borderRadiusValidator: TokenTypeValidator;

/**
 * Single CSS box-shadow value
 * https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
 *
 * Syntax: inset? <offset-x> <offset-y> <blur-radius>? <spread-radius>? <color>?
 *
 * Note: CSS allows negative blur (treated as 0) and negative spread.
 * We validate according to spec - negative values are allowed.
 */
declare const boxShadowSingle: ValueValidator;
/**
 * CSS box-shadow: <shadow>#
 * https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow
 *
 * One or more shadow definitions.
 * Note: "none" keyword is not handled here - that would be at the token level.
 */
declare const boxShadow: ValueValidator;
declare const boxShadowValidator: TokenTypeValidator;
declare const boxShadowSingleValidator: TokenTypeValidator;

/**
 * CSS font-family: string or list of strings (font stack)
 * https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
 *
 * Can be:
 * - A single font name: "Arial"
 * - A font stack (list): ["Helvetica", "Arial", "sans-serif"]
 */
declare const fontFamily: ValueValidator;
declare const fontFamilyValidator: TokenTypeValidator;

/**
 * CSS font-weight keywords
 */
declare const CSS_FONT_WEIGHT_KEYWORDS: string[];
/**
 * CSS font-weight: <number> 1-1000 or keywords
 * https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
 *
 * Numeric values:
 * - 100-900 are the traditional font weights
 * - CSS Fonts Level 4 extends this to 1-1000
 *
 * Keywords:
 * - normal = 400
 * - bold = 700
 * - lighter/bolder = relative to parent
 */
declare const fontWeight: ValueValidator;
declare const fontWeightValidator: TokenTypeValidator;

/**
 * CSS letter-spacing: normal | <length>
 * https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing
 *
 * Note: CSS spec does NOT allow percentage for letter-spacing.
 * Only "normal" keyword or <length> values are valid.
 */
declare const letterSpacing$1: ValueValidator;
declare const letterSpacingValidator$1: TokenTypeValidator;

/**
 * CSS line-height: normal | <number> | <length> | <percentage>
 * https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
 *
 * - "normal" - browser default (typically 1.2)
 * - <number> - unitless multiplier (recommended)
 * - <length> - absolute length
 * - <percentage> - percentage of font-size
 *
 * All numeric values must be non-negative.
 */
declare const lineHeight$1: ValueValidator;
declare const lineHeightValidator: TokenTypeValidator;

/**
 * CSS opacity: <number> in range [0, 1]
 * https://developer.mozilla.org/en-US/docs/Web/CSS/opacity
 *
 * Note: CSS spec technically allows values outside 0-1, but they are clamped.
 * We validate for the clamped range as that's the practical valid range.
 */
declare const opacity: ValueValidator;
declare const opacityValidator: TokenTypeValidator;

/**
 * CSS token type to validator mapping.
 *
 * Maps token types to their CSS-spec compliant validators.
 * This can be used directly with TypeBasedRule or extended for
 * application-specific validation.
 */
declare const rules$1: TokenTypeValidatorMap;
/**
 * Creates a pre-configured LintRunner with all CSS rules.
 *
 * Use this as a base and extend with application-specific validators:
 *
 * @example
 * import { css, all } from "@tokenscript/processor/linter/presets";
 *
 * // Use CSS rules as-is
 * const linter = css.createLintRunner();
 *
 * // Extend with custom validators
 * const penpotLinter = css.createLintRunner().extend({
 *   "border-radius": all(css.borderRadius, customValidator),
 *   "stroke-width": penpot.strokeWidthValidator,
 * });
 */
declare function createLintRunner$1(): LintRunner;

/**
 * CSS text-decoration-line values
 */
declare const CSS_TEXT_DECORATION_LINE_VALUES: string[];
/**
 * CSS text-decoration-line
 * https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line
 *
 * Note: This validates a single value. CSS allows multiple values
 * like "underline overline", but design tokens typically use single values.
 */
declare const textDecorationLine: ValueValidator;
declare const textDecorationLineValidator: TokenTypeValidator;

/**
 * CSS text-transform values
 */
declare const CSS_TEXT_TRANSFORM_VALUES: string[];
/**
 * CSS text-transform
 * https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform
 */
declare const textTransform: ValueValidator;
declare const textTransformValidator: TokenTypeValidator;

/**
 * CSS <length> units
 * https://developer.mozilla.org/en-US/docs/Web/CSS/length
 */
declare const CSS_LENGTH_UNITS: string[];
/**
 * CSS <length> - number with length units or unitless 0
 * Unitless 0 is valid in CSS for length values.
 */
declare const length: ValueValidator;
/**
 * CSS <length> - non-negative values only
 */
declare const lengthNonNegative: ValueValidator;
declare const lengthValidator: TokenTypeValidator;
declare const lengthNonNegativeValidator: TokenTypeValidator;

/**
 * CSS <length-percentage> - either length or percentage
 * https://developer.mozilla.org/en-US/docs/Web/CSS/length-percentage
 */
declare const lengthPercentage: ValueValidator;
/**
 * CSS <length-percentage> - non-negative values only
 */
declare const lengthPercentageNonNegative: ValueValidator;
declare const lengthPercentageValidator: TokenTypeValidator;
declare const lengthPercentageNonNegativeValidator: TokenTypeValidator;

/**
 * CSS <percentage>
 * https://developer.mozilla.org/en-US/docs/Web/CSS/percentage
 */
declare const percentage: ValueValidator;
/**
 * CSS <percentage> - non-negative values only
 */
declare const percentageNonNegative: ValueValidator;
declare const percentageValidator: TokenTypeValidator;
declare const percentageNonNegativeValidator: TokenTypeValidator;

/**
+ * CSS Preset Validators
+ *
+ * Exports follow a consistent pattern:
+ * - `fooValidator` - TokenTypeValidator for use with TypeBasedRule
+ * - `foo` - Raw ValueValidator for composition with combinators
+ * - `FOO_VALUES` - Constants for allowed values (where applicable)
+ */

declare const index$2_CSS_FONT_WEIGHT_KEYWORDS: typeof CSS_FONT_WEIGHT_KEYWORDS;
declare const index$2_CSS_LENGTH_UNITS: typeof CSS_LENGTH_UNITS;
declare const index$2_CSS_TEXT_DECORATION_LINE_VALUES: typeof CSS_TEXT_DECORATION_LINE_VALUES;
declare const index$2_CSS_TEXT_TRANSFORM_VALUES: typeof CSS_TEXT_TRANSFORM_VALUES;
declare const index$2_borderRadius: typeof borderRadius;
declare const index$2_borderRadiusValidator: typeof borderRadiusValidator;
declare const index$2_boxShadow: typeof boxShadow;
declare const index$2_boxShadowSingle: typeof boxShadowSingle;
declare const index$2_boxShadowSingleValidator: typeof boxShadowSingleValidator;
declare const index$2_boxShadowValidator: typeof boxShadowValidator;
declare const index$2_fontFamily: typeof fontFamily;
declare const index$2_fontFamilyValidator: typeof fontFamilyValidator;
declare const index$2_fontWeight: typeof fontWeight;
declare const index$2_fontWeightValidator: typeof fontWeightValidator;
declare const index$2_length: typeof length;
declare const index$2_lengthNonNegative: typeof lengthNonNegative;
declare const index$2_lengthNonNegativeValidator: typeof lengthNonNegativeValidator;
declare const index$2_lengthPercentage: typeof lengthPercentage;
declare const index$2_lengthPercentageNonNegative: typeof lengthPercentageNonNegative;
declare const index$2_lengthPercentageNonNegativeValidator: typeof lengthPercentageNonNegativeValidator;
declare const index$2_lengthPercentageValidator: typeof lengthPercentageValidator;
declare const index$2_lengthValidator: typeof lengthValidator;
declare const index$2_lineHeightValidator: typeof lineHeightValidator;
declare const index$2_opacity: typeof opacity;
declare const index$2_opacityValidator: typeof opacityValidator;
declare const index$2_percentage: typeof percentage;
declare const index$2_percentageNonNegative: typeof percentageNonNegative;
declare const index$2_percentageNonNegativeValidator: typeof percentageNonNegativeValidator;
declare const index$2_percentageValidator: typeof percentageValidator;
declare const index$2_textDecorationLine: typeof textDecorationLine;
declare const index$2_textDecorationLineValidator: typeof textDecorationLineValidator;
declare const index$2_textTransform: typeof textTransform;
declare const index$2_textTransformValidator: typeof textTransformValidator;
declare namespace index$2 {
  export { index$2_CSS_FONT_WEIGHT_KEYWORDS as CSS_FONT_WEIGHT_KEYWORDS, index$2_CSS_LENGTH_UNITS as CSS_LENGTH_UNITS, index$2_CSS_TEXT_DECORATION_LINE_VALUES as CSS_TEXT_DECORATION_LINE_VALUES, index$2_CSS_TEXT_TRANSFORM_VALUES as CSS_TEXT_TRANSFORM_VALUES, index$2_borderRadius as borderRadius, index$2_borderRadiusValidator as borderRadiusValidator, index$2_boxShadow as boxShadow, index$2_boxShadowSingle as boxShadowSingle, index$2_boxShadowSingleValidator as boxShadowSingleValidator, index$2_boxShadowValidator as boxShadowValidator, createLintRunner$1 as createLintRunner, index$2_fontFamily as fontFamily, index$2_fontFamilyValidator as fontFamilyValidator, index$2_fontWeight as fontWeight, index$2_fontWeightValidator as fontWeightValidator, index$2_length as length, index$2_lengthNonNegative as lengthNonNegative, index$2_lengthNonNegativeValidator as lengthNonNegativeValidator, index$2_lengthPercentage as lengthPercentage, index$2_lengthPercentageNonNegative as lengthPercentageNonNegative, index$2_lengthPercentageNonNegativeValidator as lengthPercentageNonNegativeValidator, index$2_lengthPercentageValidator as lengthPercentageValidator, index$2_lengthValidator as lengthValidator, letterSpacing$1 as letterSpacing, letterSpacingValidator$1 as letterSpacingValidator, lineHeight$1 as lineHeight, index$2_lineHeightValidator as lineHeightValidator, index$2_opacity as opacity, index$2_opacityValidator as opacityValidator, index$2_percentage as percentage, index$2_percentageNonNegative as percentageNonNegative, index$2_percentageNonNegativeValidator as percentageNonNegativeValidator, index$2_percentageValidator as percentageValidator, rules$1 as rules, index$2_textDecorationLine as textDecorationLine, index$2_textDecorationLineValidator as textDecorationLineValidator, index$2_textTransform as textTransform, index$2_textTransformValidator as textTransformValidator };
}

/**
 * Penpot letter-spacing: number or number with unit (no percentage)
 *
 * CSS spec already disallows %, but Penpot additionally:
 * - Allows plain numbers (not just "normal" keyword)
 * - Does not support the "normal" keyword (resolves to actual value)
 */
declare const letterSpacing: ValueValidator;
declare const letterSpacingValidator: TokenTypeValidator;

/**
 * Penpot token type to validator mapping.
 *
 * Extends CSS rules with Penpot-specific validators.
 * Override validators replace CSS validators for the same token type.
 */
declare const rules: TokenTypeValidatorMap;
/**
 * Creates a pre-configured LintRunner with all Penpot rules.
 *
 * Penpot rules extend CSS rules with application-specific validators:
 * - Typography uses Penpot's value types (unitless line-height, text-case, etc.)
 * - Shadow uses Penpot's structure (non-negative blur/spread)
 * - Adds stroke-width support
 *
 * @example
 * import { penpot, all } from "@tokenscript/processor/linter/presets";
 *
 * // Use Penpot rules as-is
 * const linter = penpot.createLintRunner();
 *
 * // Extend with additional custom validators
 * const customLinter = penpot.createLintRunner().extend({
 *   "border-radius": all(penpot.rules["border-radius"], customValidator),
 * });
 */
declare function createLintRunner(): LintRunner;

/**
 * Single Penpot shadow definition
 *
 * Fields:
 * - offsetX: horizontal offset (can be negative)
 * - offsetY: vertical offset (can be negative)
 * - blur: blur radius (must be >= 0)
 * - spread: spread radius (must be >= 0)
 * - color: shadow color
 * - inset: whether shadow is inset (inner shadow)
 */
declare const shadowSingle: ValueValidator;
/**
 * Penpot shadow token: array of one or more shadows
 */
declare const shadow: ValueValidator;
declare const shadowValidator: TokenTypeValidator;
declare const shadowSingleValidator: TokenTypeValidator;

/**
 * Penpot stroke-width: non-negative number or dimension
 *
 * Differs from CSS:
 * - Must be non-negative (>= 0)
 * - No percentage allowed (uses CSS length units only)
 * - Plain numbers are allowed (interpreted as px)
 */
declare const strokeWidth: ValueValidator;
declare const strokeWidthValidator: TokenTypeValidator;

/**
 * Penpot text-case values (maps to CSS text-transform)
 *
 * Penpot uses a subset of CSS text-transform values.
 */
declare const PENPOT_TEXT_CASE_VALUES: string[];
declare const textCase: ValueValidator;
/**
 * Penpot text-decoration values
 *
 * Penpot uses a subset of CSS text-decoration-line values.
 */
declare const PENPOT_TEXT_DECORATION_VALUES: string[];
declare const textDecoration: ValueValidator;
/**
 * Penpot font-size: non-negative number or dimension
 */
declare const fontSize: ValueValidator;
/**
 * Penpot line-height: non-negative number (multiplier)
 *
 * Penpot normalizes line-height to a unitless multiplier,
 * unlike CSS which supports various formats.
 */
declare const lineHeight: ValueValidator;
/**
 * Penpot typography composite token
 *
 * All fields are optional. Validators match Penpot's expected value types.
 */
declare const typography: ValueValidator;
declare const typographyValidator: TokenTypeValidator;

declare const index$1_PENPOT_TEXT_CASE_VALUES: typeof PENPOT_TEXT_CASE_VALUES;
declare const index$1_PENPOT_TEXT_DECORATION_VALUES: typeof PENPOT_TEXT_DECORATION_VALUES;
declare const index$1_createLintRunner: typeof createLintRunner;
declare const index$1_fontSize: typeof fontSize;
declare const index$1_letterSpacing: typeof letterSpacing;
declare const index$1_letterSpacingValidator: typeof letterSpacingValidator;
declare const index$1_lineHeight: typeof lineHeight;
declare const index$1_rules: typeof rules;
declare const index$1_shadow: typeof shadow;
declare const index$1_shadowSingle: typeof shadowSingle;
declare const index$1_shadowSingleValidator: typeof shadowSingleValidator;
declare const index$1_shadowValidator: typeof shadowValidator;
declare const index$1_strokeWidth: typeof strokeWidth;
declare const index$1_strokeWidthValidator: typeof strokeWidthValidator;
declare const index$1_textCase: typeof textCase;
declare const index$1_textDecoration: typeof textDecoration;
declare const index$1_typography: typeof typography;
declare const index$1_typographyValidator: typeof typographyValidator;
declare namespace index$1 {
  export { index$1_PENPOT_TEXT_CASE_VALUES as PENPOT_TEXT_CASE_VALUES, index$1_PENPOT_TEXT_DECORATION_VALUES as PENPOT_TEXT_DECORATION_VALUES, index$1_createLintRunner as createLintRunner, index$1_fontSize as fontSize, index$1_letterSpacing as letterSpacing, index$1_letterSpacingValidator as letterSpacingValidator, index$1_lineHeight as lineHeight, index$1_rules as rules, index$1_shadow as shadow, index$1_shadowSingle as shadowSingle, index$1_shadowSingleValidator as shadowSingleValidator, index$1_shadowValidator as shadowValidator, index$1_strokeWidth as strokeWidth, index$1_strokeWidthValidator as strokeWidthValidator, index$1_textCase as textCase, index$1_textDecoration as textDecoration, index$1_typography as typography, index$1_typographyValidator as typographyValidator };
}

/**
 * Context passed to value validators during validation.
 */
interface ValidatorContext {
    /** The token being validated */
    tokenName: string;
    /** Path to the current field within a structured token */
    path: (string | number)[];
    /** Default severity for issues */
    severity: LintSeverity;
}
/**
 * A value validator checks a resolved value and returns issues or null for valid.
 *
 * @param value - The resolved symbol value to validate
 * @param ctx - Validation context with token name, path, and severity
 * @returns LintIssue(s) if invalid, null if valid
 */
type ValueValidator = (value: unknown, ctx: ValidatorContext) => LintIssue | LintIssue[] | null;
/**
 * Constraints for numeric validators (number, numberWithUnit)
 */
interface NumericConstraints {
    /** Minimum allowed value (inclusive) */
    min?: number;
    /** Maximum allowed value (inclusive) */
    max?: number;
}
/**
 * Constraints for numberWithUnit validator
 */
interface UnitConstraints extends NumericConstraints {
    /** Only allow these units (e.g., ["px", "em", "%"]) */
    allowedUnits?: string[];
    /** Disallow these units (e.g., ["%"]) */
    disallowedUnits?: string[];
    /** Require a unit (reject plain numbers). Default: false */
    requireUnit?: boolean;
}
/**
 * Constraints for string validator
 */
interface StringConstraints {
    /** Only allow these exact values (enum validation) */
    allowedValues?: string[];
    /** Case-sensitive comparison (default: false) */
    caseSensitive?: boolean;
}
/**
 * Field definition for structured token validation
 */
interface FieldDef {
    /** Validator for this field */
    validator: ValueValidator;
    /** Whether the field is required (default: false) */
    required?: boolean;
}
/**
 * Options for struct validator
 */
interface StructOptions {
    /** Error on unknown fields not defined in schema (default: false) */
    strict?: boolean;
    /** Warn when optional fields are missing (default: false) */
    warnMissing?: boolean;
}
/**
 * Options for list validators
 */
interface ListOptions {
    /** Exact count required */
    count?: number;
    /** Minimum count (inclusive) */
    minCount?: number;
    /** Maximum count (inclusive) */
    maxCount?: number;
    /** Specific allowed counts (e.g., [1, 2, 4] for CSS shorthand) */
    allowedCounts?: number[];
}

/**
 * Union validator - value must match at least one validator.
 *
 * Returns the first validation error encountered when none of the validators match.
 *
 * @example
 * // font-weight: number 1-1000 OR keywords
 * or(
 *   number({ min: 1, max: 1000 }),
 *   string({ allowedValues: ["normal", "bold", "lighter", "bolder"] })
 * )
 *
 * // length-percentage
 * or(length, percentage)
 */
declare function or(...validators: ValueValidator[]): ValueValidator;
/**
 * Validates a single value OR a list of values.
 * Handles CSS shorthand patterns (1, 2, 3, or 4 values).
 *
 * @example
 * // border-radius: single value or 1/2/3/4 values
 * oneOrList(
 *   lengthPercentageNonNegative,
 *   { allowedCounts: [1, 2, 3, 4] }
 * )
 */
declare function oneOrList(itemValidator: ValueValidator, options?: ListOptions): ValueValidator;
/**
 * Validates a list with count constraints.
 *
 * @example
 * list(color(), { minCount: 1 })  // At least one color
 * list(number(), { count: 4 })    // Exactly 4 numbers
 * list(shadowSingle, { minCount: 1 }) // At least one shadow
 */
declare function list(itemValidator: ValueValidator, options?: ListOptions): ValueValidator;
/**
 * Validates a structured token (TokenSymbol with Map value).
 *
 * @param fields - Field validators. Can be ValueValidator or FieldDef with required flag.
 * @param options - Struct validation options
 *
 * @example
 * struct({
 *   fontSize: numberWithUnit({ min: 0 }),
 *   lineHeight: number({ min: 0 }),
 * })
 *
 * struct({
 *   fontSize: { validator: numberWithUnit({ min: 0 }), required: true },
 *   lineHeight: number({ min: 0 }),
 * }, { strict: true, warnMissing: true })
 */
declare function struct(fields: Record<string, FieldDef | ValueValidator>, options?: StructOptions): ValueValidator;
/**
 * Shorthand for list with minCount: 1.
 * Useful for array-of-objects patterns like shadow.
 *
 * @example
 * arrayOf(shadowSingle)  // At least one shadow object
 */
declare function arrayOf(itemValidator: ValueValidator): ValueValidator;
/**
 * Intersection validator - value must pass ALL validators.
 * Collects issues from all validators that fail.
 *
 * Use this to compose validators, e.g., combining a CSS base validator
 * with application-specific validation.
 *
 * @example
 * // Combine CSS border-radius with custom Penpot validation
 * all(css.borderRadius, customPenpotValidator)
 *
 * // Multiple constraints
 * all(
 *   number({ min: 0 }),
 *   customSafeIntValidator,
 *   customAllowedUnitsValidator
 * )
 */
declare function all(...validators: ValueValidator[]): ValueValidator;

/**
 * Wraps a ValueValidator to create a TokenTypeValidator for use with TypeBasedRule.
 *
 * @param validator - The value validator to wrap
 * @param options - Options for the wrapper
 *
 * @example
 * import { number, createValidator } from "@tokenscript/processor/linter/presets";
 *
 * const opacityValidator = createValidator(number({ min: 0, max: 1 }));
 *
 * const linter = new LintRunner().addRule(
 *   new TypeBasedRule().forType("opacity", opacityValidator)
 * );
 */
declare function createValidator(validator: ValueValidator, options?: {
    severity?: LintSeverity;
}): TokenTypeValidator;

/**
 * Validates NumberSymbol with optional min/max constraints.
 * NullSymbol and null values are accepted as valid.
 *
 * @example
 * number()                    // Any number
 * number({ min: 0 })          // >= 0
 * number({ min: 0, max: 1 })  // 0-1 range (opacity)
 * number({ min: 100, max: 900 }) // font-weight numeric
 */
declare function number(constraints?: NumericConstraints): ValueValidator;
/**
 * Validates StringSymbol with optional enum constraint.
 * NullSymbol and null values are accepted as valid.
 *
 * @example
 * string()  // Any non-null string
 * string({ allowedValues: ["none", "uppercase", "lowercase"] })
 * string({ allowedValues: ["A", "B"], caseSensitive: true })
 */
declare function string(constraints?: StringConstraints): ValueValidator;
/**
 * Validates BooleanSymbol.
 * NullSymbol and null values are accepted as valid.
 *
 * @example
 * boolean()  // true or false
 */
declare function boolean(): ValueValidator;
/**
 * Validates ColorSymbol.
 * NullSymbol and null values are accepted as valid.
 *
 * @example
 * color()  // Any valid color
 */
declare function color(): ValueValidator;

/**
 * Validates NumberWithUnitSymbol or plain NumberSymbol with unit and value constraints.
 * NullSymbol and null values are accepted as valid.
 *
 * @example
 * numberWithUnit()                                      // Any number with or without unit
 * numberWithUnit({ min: 0 })                            // >= 0
 * numberWithUnit({ allowedUnits: ["px", "em", "%"] })   // Only these units
 * numberWithUnit({ disallowedUnits: ["%"] })            // Any unit except %
 * numberWithUnit({ requireUnit: true })                 // Must have a unit
 * numberWithUnit({ min: 0, allowedUnits: ["px", "rem"] })
 */
declare function numberWithUnit(constraints?: UnitConstraints): ValueValidator;

type index_BaseLintRule = BaseLintRule;
declare const index_BaseLintRule: typeof BaseLintRule;
type index_CreateIssueFn = CreateIssueFn;
type index_FieldDef = FieldDef;
type index_LintConfig = LintConfig;
type index_LintContext = LintContext;
type index_LintIssue = LintIssue;
type index_LintResult = LintResult;
type index_LintRule = LintRule;
type index_LintRunner = LintRunner;
declare const index_LintRunner: typeof LintRunner;
type index_LintSeverity = LintSeverity;
declare const index_LintSeverity: typeof LintSeverity;
type index_ListOptions = ListOptions;
type index_NumericConstraints = NumericConstraints;
type index_StringConstraints = StringConstraints;
type index_StructOptions = StructOptions;
type index_TokenTypeValidator = TokenTypeValidator;
type index_TokenTypeValidatorMap = TokenTypeValidatorMap;
type index_TypeBasedRule = TypeBasedRule;
declare const index_TypeBasedRule: typeof TypeBasedRule;
type index_UnitConstraints = UnitConstraints;
type index_ValidatorCode = ValidatorCode;
declare const index_ValidatorCode: typeof ValidatorCode;
type index_ValidatorContext = ValidatorContext;
type index_ValueValidator = ValueValidator;
declare const index_all: typeof all;
declare const index_arrayOf: typeof arrayOf;
declare const index_boolean: typeof boolean;
declare const index_color: typeof color;
declare const index_createValidator: typeof createValidator;
declare const index_list: typeof list;
declare const index_number: typeof number;
declare const index_numberWithUnit: typeof numberWithUnit;
declare const index_oneOrList: typeof oneOrList;
declare const index_or: typeof or;
declare const index_string: typeof string;
declare const index_struct: typeof struct;
declare namespace index {
  export { index_BaseLintRule as BaseLintRule, type index_CreateIssueFn as CreateIssueFn, type index_FieldDef as FieldDef, type index_LintConfig as LintConfig, type index_LintContext as LintContext, type index_LintIssue as LintIssue, type index_LintResult as LintResult, type index_LintRule as LintRule, index_LintRunner as LintRunner, index_LintSeverity as LintSeverity, type index_ListOptions as ListOptions, type index_NumericConstraints as NumericConstraints, type index_StringConstraints as StringConstraints, type index_StructOptions as StructOptions, type index_TokenTypeValidator as TokenTypeValidator, type index_TokenTypeValidatorMap as TokenTypeValidatorMap, index_TypeBasedRule as TypeBasedRule, type index_UnitConstraints as UnitConstraints, index_ValidatorCode as ValidatorCode, type index_ValidatorContext as ValidatorContext, type index_ValueValidator as ValueValidator, index_all as all, index_arrayOf as arrayOf, index_boolean as boolean, index_color as color, index_createValidator as createValidator, index$2 as css, index_list as list, index_number as number, index_numberWithUnit as numberWithUnit, index_oneOrList as oneOrList, index_or as or, index$1 as penpot, index_string as string, index_struct as struct };
}

declare const defaultObjectParsers: ObjectParser[];

/**
 * Matches objects with shape { value: number, unit: string }.
 */
declare const numberWithUnitParser: ObjectParser;

/**
 * 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;
};

type ProcessorResult = {
    graph: DependencyGraph<RefPath>;
    resolved: TokenResultMap;
    issues?: IssuesMap;
};
type ProcessorCallbacks = {
    onResolve?: (tokenName: RefPath, value: InterpreterResult) => void;
    onError?: (tokenName: RefPath, error: Error, originalValue: string | unknown, metadata?: {
        isSubField: boolean;
        parentToken?: string;
        fieldPath?: string;
    }) => void;
};
type ProcessorOutput = ProcessorResult & {
    tokens: ResolvedValueMap;
    resolver: TokenResolver;
    issues?: IssuesMap;
};
/**
 * 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 {
    private prefixResolver?;
    private tokens?;
    private config?;
    private objectParsers?;
    private linter?;
    processTokens(tokens: TokenInputMap, callbacks?: ProcessorCallbacks, config?: Config, objectParsers?: ObjectParser[], linter?: LintRunner): ProcessorResult;
    /**
     * Find all tokens affected by a change to the given token.
     *
     * Uses BFS traversal on the reverse dependency graph to identify
     * the changed token plus all tokens that transitively depend on it.
     *
     * @param tokenName - The token that changed
     * @returns Object containing affected tokens and a subgraph showing their relationships
     *
     * @example
     * const { resolver } = new TokenResolver().build(tokens);
     * const { tokens, subgraph } = resolver.getTokenDependencyGraph("color.primary");
     * console.log(tokens); // Set(['color.primary', 'button.background', ...])
     */
    getTokenDependencyGraph(tokenName: RefPath): {
        tokens: Set<RefPath>;
        subgraph: DependencyGraph<RefPath>;
    };
    build(tokens: TokenDataMap$1, config?: Config, objectParsers?: ObjectParser[], linter?: LintRunner): ProcessorOutput;
    private ensureInitialized;
    private normalizeTokenPath;
    private createOutputCallbacks;
    private rebuildResolver;
    updateToken(params: UpdateTokenParams): UpdateTokenResult;
    createToken(params: CreateTokenParams): CreateTokenResult;
    deleteToken(params: DeleteTokenParams): DeleteTokenResult;
}

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

type TokenDataMap = Map<string, TokenData>;
interface BuildTokensOptions<T> {
    builder?: TokenBuilder<T>;
    config?: Config;
    objectParsers?: ObjectParser[];
    linter?: LintRunner;
}
/**
 * Builds tokens from a normalized TokenDataMap.
 *
 * This is the core token processing function. For most use cases, call this directly
 * rather than using the higher-level processTokens/processTokenSets wrappers.
 *
 * @param tokens - Map of token names to TokenData. Must be pre-normalized to TokenData format.
 * @param options - Build options (all optional):
 *   - builder: Custom token builder (default: MapBuilder)
 *   - config: Interpreter config
 *   - objectParsers: Array of object parsers
 *   - linter: Lint runner
 * @returns ProcessorOutput with resolved tokens, output, and optional lint results.
 *
 * @remarks
 * Consumers must normalize input to Map<string, TokenData> before calling this function.
 * Use processTokens/processTokenSets for automatic normalization of Records and Maps.
 */
declare function buildTokens<T = Map<string, InterpreterResult>>(tokens: TokenDataMap, options?: BuildTokensOptions<T>): ProcessorOutput & {
    output: T;
    issues?: IssuesMap;
};

type FlattenCallback<T> = (key: string, value: InterpreterResult) => T;
/**
 * Flatten a DictionarySymbol into key-value pairs
 *
 * @param result - The InterpreterResult to flatten (only DictionarySymbol will be flattened)
 * @param prefix - The prefix to prepend to keys
 * @param callback - Callback function that receives each flattened key-value pair
 *
 * @example
 * const result: Record<string, unknown> = {};
 * flattenChildrenObject(dictionarySymbol, "root", (key, value) => {
 *   result[key] = value;
 * });
 */
declare function flattenChildrenObject<T>(result: InterpreterResult, prefix: string, callback: FlattenCallback<T>): void;
/**
 * Flatten a Map structure into key-value pairs
 *
 * @param map - The map to flatten (from Dictionary.value)
 * @param prefix - The prefix to prepend to keys
 * @param callback - Callback function that receives each flattened key-value pair
 *
 * @example
 * const result = new Map<string, unknown>();
 * flattenChildrenMap(dictionarySymbol.value, "root", (key, value) => {
 *   result.set(key, value);
 * });
 */
declare function flattenChildrenMap<T>(map: Map<string, InterpreterResult>, prefix: string, callback: FlattenCallback<T>): void;

declare class MapBuilder implements TokenBuilder<Map<string, string | InterpreterResult>> {
    readonly name = "map";
    protected result: Map<string, string | InterpreterResult>;
    private successfullyResolved;
    onResolve(tokenName: string, value: InterpreterResult): void;
    onError(tokenName: string, _error: Error, originalValue: string | unknown): void;
    getResult(): Map<string, string | InterpreterResult>;
    getResolvedTokens(): Map<string, InterpreterResult>;
}

/**
 * Nested Object Builder
 *
 * Builds a nested object structure incrementally as tokens are resolved.
 * Converts flat token paths to nested structure.
 * Example: "color.primary" -> { color: { primary: value } }
 */
declare class NestedObjectBuilder implements TokenBuilder<Record<string, unknown>> {
    readonly name = "nested";
    private result;
    onResolve(tokenName: string, value: InterpreterResult): void;
    onError(tokenName: string, _error: Error, originalValue: string | unknown): void;
    getResult(): Record<string, unknown>;
}
/**
 * Flat Object Builder
 *
 * Builds a flat key-value object incrementally as tokens are resolved.
 * Example: "color.primary" -> { "color.primary": value }
 */
declare class FlatObjectBuilder implements TokenBuilder<Record<string, unknown>> {
    readonly name = "flat";
    private result;
    onResolve(tokenName: string, value: InterpreterResult): void;
    onError(tokenName: string, _error: Error, originalValue: string | unknown): void;
    getResult(): Record<string, unknown>;
}

declare class StringMapBuilder extends MapBuilder {
    onResolve(tokenName: string, value: InterpreterResult): void;
    getResult(): Map<string, string>;
}

/**
 * Create a ProcessorError for dependency-related failures.
 * Builds the dependency chain and extracts the root cause.
 */
declare function createDependencyError(tokenName: string, dependencyName: string, originalError: Error): ProcessorError;

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

/**
 * Process flat token collection.
 *
 * @param tokens - Token input in various formats (Map or Record)
 * @param options - Processing options
 * @returns Processed tokens with resolved values
 *
 * @note Performance optimization: If you already have a `Map<string, TokenData>`,
 * you can skip this function and call `buildTokens` directly to avoid unnecessary flattening.
 */
declare function processTokens<T = Map<string, string | InterpreterResult>>(tokens: Map<string, TokenData> | Map<string, string> | Record<string, any>, options?: ProcessOptions): ProcessResult<T>;
/**
 * Process token sets with theme or set selection.
 */
declare function processTokenSets<T = Map<string, string | InterpreterResult>>(normalizedFiles: Record<string, unknown>, options?: ProcessSetsOptions): ProcessResult<T>;

/**
 * Get all affected token paths from the dependants graph.
 * Returns the set of all tokens that depend on the changed token.
 */
declare function getAffectedTokens(result: TokenOperationResult): Set<RefPath>;
/**
 * Get broken references from issues.
 * Filters issues for TOKEN_NOT_FOUND or DEPENDENCY_ERROR codes.
 */
declare function getBrokenReferences(result: TokenOperationResult): Set<RefPath>;
/**
 * For rename operations: get tokens whose references were updated.
 * Pass the set of tokens that were modified during rename.
 */
declare function getRenamedReferences(_result: TokenOperationResult, modifiedTokens: Set<RefPath>): Set<RefPath>;
/**
 * Get tokens from the dependants graph whose values actually changed.
 * Compares the old token values with the new result to filter only modified tokens.
 */
declare function getModifiedDependants(oldTokens: Map<RefPath, any>, result: TokenOperationResult): Set<RefPath>;

/**
 * Check if issues map contains an error with the specified code.
 * Useful for checking if any token has a specific type of error.
 *
 * @example
 * ```typescript
 * const result = resolver.updateToken({ ... });
 * if (hasIssueWithCode(result.issues, ProcessorErrorCode.CIRCULAR_DEPENDENCY)) {
 *   console.error("Circular dependency detected");
 * }
 * ```
 */
declare function hasIssueWithCode(issues: IssuesMap | undefined, code: ProcessorErrorCode): boolean;
/**
 * Check if a specific token has an issue with the specified code.
 *
 * @example
 * ```typescript
 * const result = resolver.updateToken({ tokenPath: "foo", ... });
 * if (tokenHasIssueWithCode(result.issues, "foo", ProcessorErrorCode.CIRCULAR_DEPENDENCY)) {
 *   console.error("Token 'foo' has a circular dependency");
 * }
 * ```
 */
declare function tokenHasIssueWithCode(issues: IssuesMap | undefined, tokenName: string, code: ProcessorErrorCode): boolean;
/**
 * Get all tokens that have issues of any kind.
 *
 * @example
 * ```typescript
 * const result = resolver.build(tokens);
 * const tokensWithIssues = getTokensWithIssues(result.issues);
 * console.log(`${tokensWithIssues.size} tokens have issues`);
 * ```
 */
declare function getTokensWithIssues(issues: IssuesMap | undefined): Set<string>;
/**
 * Check if there are any issues at all.
 *
 * @example
 * ```typescript
 * const result = resolver.build(tokens);
 * if (hasAnyIssues(result.issues)) {
 *   console.error("There are issues with the tokens");
 * }
 * ```
 */
declare function hasAnyIssues(issues: IssuesMap | undefined): boolean;

export { type BuildTokensOptions, type BuilderFormat, type CreateTokenParams, type CreateTokenResult, type DeleteTokenParams, type DeleteTokenResult, FlatObjectBuilder, type FlattenCallback, type IssuesMap, MapBuilder, NestedObjectBuilder, type ObjectParser, type ProcessFilesOptions, type ProcessOptions, type ProcessResult, type ProcessSetsOptions, type ProcessorOutput, type ProcessorResult, type ResolveIssue, StringMapBuilder, type TokenBuilder, type TokenDataMap, type TokenOperationResult, TokenResolver, type UpdateTokenParams, type UpdateTokenResult, buildTokens, createDependencyError, defaultObjectParsers, flattenChildrenMap, flattenChildrenObject, getAffectedTokens, getBrokenReferences, getModifiedDependants, getRenamedReferences, getTokensWithIssues, hasAnyIssues, hasIssueWithCode, index as linter, numberWithUnitParser, processTokenSets, processTokens, tokenHasIssueWithCode };
