/**
 * simvsm-import module — public entrypoint (ADR 019).
 *
 * Owner: Wertstrom
 *
 * Wertstrom P6 (KAR-878/KAR-986, execution-prompt §14, Capability-Matrix
 * A16): optional SimVSM-file import adapter — parse, recognize Familien
 * (model + alternatives + paired SVGs), map onto the existing P2 data model
 * (VsmNode/VsmConnection/ScenarioKind, zero schema changes), preview before
 * any write, confirm idempotently. Feature-gated off by default
 * (`wertstromSimvsmImport`, `false` in all 3 profiles) — see README.md.
 *
 * Anything not re-exported from this file is internal and may change without
 * notice. Cross-module access goes through this entrypoint only — no deep
 * imports into this module's internal/.
 */

// ── Parser ───────────────────────────────────────────────────────────────
export { parseSimVsmJsonText, parseSimVsmValue, PARSER_VERSION, PARSER_MAX_JSON_BYTES } from './internal/parser'
export type {
  SimVsmParseResult,
  SimVsmParsedFile,
  SimVsmParseFailure,
  SimVsmParsedAlternative,
  SimVsmParsedNode,
  SimVsmParsedLink,
  SimVsmParseIssue,
} from './internal/types'

// ── Mapping registry (§14.3) ────────────────────────────────────────────────
export {
  NODE_MAPPING_REGISTRY,
  LINK_MAPPING_REGISTRY,
  MAPPING_VERSION,
  classifyNode,
  classifyLink,
  findUnknownNodeClasses,
  findUnknownLinkClasses,
} from './internal/mapping-registry'
export type { MappingEntry, NodeMappingEntry, UnsupportedMappingEntry, LinkMappingEntry } from './internal/mapping-registry'

// ── Per-node / per-link field mapping ───────────────────────────────────────
export { mapSimVsmNode } from './internal/node-mapper'
export type { NodeMapOutcome } from './internal/node-mapper'
export { mapSimVsmLink } from './internal/link-mapper'
export type { LinkMapOutcome } from './internal/link-mapper'

// ── Alternativen → Szenarien (§9/A9 reuse) ──────────────────────────────────
export { mapStream, resolveCurrentStreamIndex } from './internal/streams'
export type { MappedStream, ScenarioRole } from './internal/streams'

// ── Familie / SVG-Namenskonvention ──────────────────────────────────────────
export { pairSvgFiles, groupRelatedFileNames } from './internal/families'
export type { FamilyJsonInput, FamilySvgPairing } from './internal/families'

// ── Signaturen (Duplikate / Idempotenz) ─────────────────────────────────────
export { computeSourceSignature, computeConfirmationSignature, shortSignature, SIMVSM_ADAPTER_VERSION } from './internal/signature'

// ── Upload-Größen-/Typ-Prüfung (geteilt zwischen preview- und confirm-Route) ─
export { classifyUploadFile, checkTotalUploadSize, JSON_FILE_MAX_BYTES, SVG_FILE_MAX_BYTES, TOTAL_REQUEST_MAX_BYTES } from './internal/upload-limits'
export type { UploadFileKind, UploadRejectionReason, UploadFileCheckInput, UploadFileCheckResult } from './internal/upload-limits'

// ── Import-Report (§14.4) ───────────────────────────────────────────────────
export { buildImportReport } from './internal/report'
export type { SimvsmImportReport, ReportTransformedEntity, ReportUnsupportedEntity } from './internal/report'

// ── Preview (pure, DB-frei) ──────────────────────────────────────────────────
export { buildSimvsmImportPreview, mapFileToStreams } from './internal/preview'
export type {
  SimvsmImportPreview,
  PreviewFamily,
  PreviewStream,
  PreviewClassCoverageRow,
  BuildPreviewInput,
  PreviewJsonFileInput,
} from './internal/preview'

// ── DB-backed (RLS-scoped Supabase client only) ─────────────────────────────
export { findSimvsmDuplicatesBySignature, findSimvsmImportByConfirmationSignature } from './internal/duplicates'
export type { SimvsmDuplicateHit, FindSimvsmDuplicatesResult } from './internal/duplicates'
export { persistSimvsmImport } from './internal/persist'
export type {
  PersistSimvsmInput,
  PersistSimvsmSelection,
  PersistSimvsmOutcome,
  PersistedStream,
  SimvsmSourceMetadata,
} from './internal/persist'
