import { type SchematicBounds, type SchematicPoint, type SchematicSheetGeometry } from '../schematic-engine/geometry.js'; import { type ConnectivityFingerprint, type ConnectivityFingerprintDiff } from '../schematic-model/connectivity-fingerprint.js'; import { type StableReadOptions } from '../live/readback.js'; import { type SchematicOperation } from '../transactions/operation-log.js'; import { type TransactionBridgeCaller } from '../transactions/easyeda.js'; import type { TransactionManager } from '../transactions/manager.js'; import type { TransactionRecord } from '../transactions/model.js'; import { type PlacementConstraintRegion } from './placement.js'; export type AutofixPrimitiveType = 'component' | 'text' | 'label' | 'annotation' | 'section-box' | 'section-title' | 'wire' | 'power-symbol' | 'no-connect'; export type AutofixCosmeticProperty = 'position' | 'bounds'; export interface LayoutAutofixPrimitive { id: string; primitiveType: AutofixPrimitiveType; origin: SchematicPoint; combinedBounds: SchematicBounds; sectionId?: string; locked?: boolean; } export type LayoutAutofixViolationCode = 'TITLE_BLOCK_OVERLAP' | 'PAGE_BOUNDARY_OVERFLOW' | 'COMPONENT_OVERLAP' | 'TEXT_OVERLAP' | 'SECTION_BOX_TOO_SMALL'; export interface LayoutAutofixViolation { id: string; code: LayoutAutofixViolationCode; primitiveIds: string[]; message: string; } export interface LayoutAutofixAllowlist { primitiveTypes: readonly AutofixPrimitiveType[]; properties: readonly AutofixCosmeticProperty[]; } export interface LayoutAutofixMove { id: string; primitiveId: string; primitiveType: AutofixPrimitiveType; property: AutofixCosmeticProperty; from: SchematicPoint | SchematicBounds; to: SchematicPoint | SchematicBounds; reason: string; expectedQaImprovement: string; resolvesViolationIds: string[]; } export interface LayoutAutofixPreviewInput { sheet: SchematicSheetGeometry; primitives: readonly LayoutAutofixPrimitive[]; allowlist: LayoutAutofixAllowlist; hardKeepouts?: readonly PlacementConstraintRegion[]; callerReservedRegions?: readonly PlacementConstraintRegion[]; minimumClearance?: number; maxMoves?: number; } export interface LayoutAutofixReport { fixed: string[]; skipped: Array<{ violationId: string; reason: string; }>; remaining: string[]; } export interface LayoutAutofixPreview { mode: 'preview'; requiresConfirmWrite: true; violations: LayoutAutofixViolation[]; moves: LayoutAutofixMove[]; report: LayoutAutofixReport; allowlist: LayoutAutofixAllowlist; } export interface ApplyLayoutAutofixOptions { confirmWrite: boolean; documentId: string; transactionManager: TransactionManager; bridge: TransactionBridgeCaller; readConnectivity: () => Promise; operationFactory?: (move: LayoutAutofixMove, index: number) => SchematicOperation; batchSize?: number; stableRead?: StableReadOptions; } export interface LayoutAutofixApplyResult { applied: boolean; transaction?: TransactionRecord; preview: LayoutAutofixPreview; beforeFingerprint?: ConnectivityFingerprint; afterFingerprint?: ConnectivityFingerprint; connectivityDiff?: ConnectivityFingerprintDiff; batchesVerified: number; actualStateReadAfterFailure: boolean; report: LayoutAutofixReport; } export declare class LayoutAutofixConnectivityError extends Error { readonly result: LayoutAutofixApplyResult; constructor(message: string, result: LayoutAutofixApplyResult); } export declare function previewLayoutAutofix(input: LayoutAutofixPreviewInput): LayoutAutofixPreview; export declare function applyLayoutAutofix(preview: LayoutAutofixPreview, options: ApplyLayoutAutofixOptions): Promise; export declare function applyPreviewMovesToGeometry(primitives: readonly LayoutAutofixPrimitive[], preview: LayoutAutofixPreview): LayoutAutofixPrimitive[];