
import { StyleResult } from "../pipeline/index.js";

//#region src/tasty/injector/types.d.ts
interface InjectResult {
  className: string;
  dispose: () => void;
}
interface GlobalInjectResult {
  dispose: () => void;
}
type DisposeFunction = () => void;
interface StyleInjectorConfig {
  nonce?: string;
  maxRulesPerSheet?: number;
  unusedStylesThreshold?: number;
  bulkCleanupDelay?: number;
  idleCleanup?: boolean;
  forceTextInjection?: boolean;
  /** Enable development mode features: performance metrics and debug information storage */
  devMode?: boolean;
  /**
   * Ratio of unused styles to delete per bulk cleanup run (0..1).
   * Defaults to 0.5 (oldest half) to reduce risk of removing styles
   * that may be restored shortly after being marked unused.
   */
  bulkCleanupBatchRatio?: number;
  /**
   * Minimum age (in ms) a style must remain unused before eligible for deletion.
   * Helps avoid races during rapid mount/unmount cycles. Default: 10000ms.
   */
  unusedStylesMinAgeMs?: number;
  /**
   * Global predefined states for advanced state mapping.
   * These are state aliases that can be used in any component.
   * Example: { '@mobile': '@media(w < 920px)', '@dark': '@root(theme=dark)' }
   */
  states?: Record<string, string>;
}
interface RuleInfo {
  className: string;
  ruleIndex: number;
  sheetIndex: number;
  /** Dev-only: full CSS texts inserted for this class; omitted in production */
  cssText?: string[];
  /** Inclusive end index of the contiguous block of inserted rules for this className */
  endRuleIndex?: number;
  /** NEW: exact indices of all inserted rules for this className */
  indices?: number[];
}
interface SheetInfo {
  sheet: HTMLStyleElement;
  ruleCount: number;
  holes: number[];
}
interface CleanupStats {
  timestamp: number;
  classesDeleted: number;
  cssSize: number;
  rulesDeleted: number;
}
interface CacheMetrics {
  hits: number;
  misses: number;
  bulkCleanups: number;
  totalInsertions: number;
  totalUnused: number;
  stylesCleanedUp: number;
  cleanupHistory: CleanupStats[];
  startTime: number;
  unusedHits?: number;
}
interface RootRegistry {
  sheets: SheetInfo[];
  refCounts: Map<string, number>;
  rules: Map<string, RuleInfo>;
  /** Cache key to className mapping to avoid dual storage of RuleInfo objects */
  cacheKeyToClassName: Map<string, string>;
  /** Deduplication set of fully materialized CSS rules inserted into sheets */
  ruleTextSet: Set<string>;
  /** Scheduled bulk cleanup timeout */
  bulkCleanupTimeout: ReturnType<typeof requestIdleCallback> | ReturnType<typeof setTimeout> | null;
  /** Scheduled cleanup check timeout */
  cleanupCheckTimeout: ReturnType<typeof setTimeout> | null;
  /** Performance metrics (optional) */
  metrics?: CacheMetrics;
  /** Counter for generating sequential class names like t0, t1, t2... */
  classCounter: number;
  /** Keyframes cache by content hash -> entry */
  keyframesCache: Map<string, KeyframesCacheEntry>;
  /** Keyframes name to content hash mapping for collision detection */
  keyframesNameToContent: Map<string, string>;
  /** Counter for generating keyframes names like k0, k1, k2... */
  keyframesCounter: number;
  /** Map of injected @property names to their normalized declarations for tracking */
  injectedProperties: Map<string, string>;
  /** Global rules tracking for index adjustment */
  globalRules: Map<string, RuleInfo>;
}
type StyleRule = StyleResult;
interface KeyframesInfo {
  name: string;
  sheetIndex: number;
  ruleIndex: number;
  /** Dev-only: full CSS text of the @keyframes rule; omitted in production */
  cssText?: string;
}
type KeyframeStep = string | Record<string, string | number>;
type KeyframesSteps = Record<string, KeyframeStep>;
interface KeyframesResult {
  toString(): string;
  dispose: () => void;
}
interface KeyframesCacheEntry {
  name: string;
  refCount: number;
  info: KeyframesInfo;
}
/**
 * Definition for a CSS @property at-rule.
 * Used to define custom property syntax, inheritance, and initial value.
 */
interface PropertyDefinition {
  /** CSS syntax string (e.g., '<color>', '<angle>', '<number>') */
  syntax?: string;
  /** Whether the property inherits (default: true) */
  inherits?: boolean;
  /** Initial value for the property */
  initialValue?: string | number;
}
interface RawCSSResult {
  dispose: () => void;
}
//#endregion
export { CacheMetrics, DisposeFunction, GlobalInjectResult, InjectResult, KeyframesCacheEntry, KeyframesInfo, KeyframesResult, KeyframesSteps, PropertyDefinition, RawCSSResult, RootRegistry, RuleInfo, SheetInfo, StyleInjectorConfig, StyleRule };
//# sourceMappingURL=types.d.ts.map