{
  "version": 3,
  "sources": ["../src/errors.ts", "../src/default-module.ts", "../src/version.ts", "../src/kernel.ts", "../src/index.browser.ts"],
  "sourcesContent": ["/**\r\n * Structured error types for occt-kernel-wasm.\r\n */\r\n\r\nexport type KernelErrorCode =\r\n    | 'INVALID_HANDLE'\r\n    | 'SESSION_MISMATCH'\r\n    | 'INVALID_PARAMS'\r\n    | 'INVALID_CHECKPOINT'\r\n    | 'OPERATION_FAILED'\r\n    | 'IMPORT_FAILED'\r\n    | 'EXPORT_FAILED'\r\n    | 'NOT_INITIALIZED'\r\n    | 'UNKNOWN';\r\n\r\n/** Structured error returned by all kernel operations. */\r\nexport class KernelError extends Error {\r\n    public readonly code: KernelErrorCode;\r\n    public readonly detail: string;\r\n\r\n    constructor(code: KernelErrorCode, detail: string) {\r\n        super(`[${code}] ${detail}`);\r\n        this.name = 'KernelError';\r\n        this.code = code;\r\n        this.detail = detail;\r\n    }\r\n}\r\n\r\n/** @internal Parse a JSON error descriptor returned by the C++ kernel. */\r\nexport function parseNativeError(raw: unknown): KernelError {\r\n    if (typeof raw === 'string') {\r\n        try {\r\n            const parsed = JSON.parse(raw) as { code?: string; detail?: string };\r\n            const code = (parsed.code ?? 'UNKNOWN') as KernelErrorCode;\r\n            const detail = parsed.detail ?? raw;\r\n            return new KernelError(code, detail);\r\n        } catch {\r\n            return new KernelError('UNKNOWN', raw);\r\n        }\r\n    }\r\n    if (raw instanceof KernelError) return raw;\r\n    if (raw instanceof Error) return new KernelError('UNKNOWN', raw.message);\r\n    return new KernelError('UNKNOWN', String(raw));\r\n}\r\n", "import type { WasmModule } from './kernel';\r\n\r\nexport type WasmModuleFactory = (opts?: Record<string, unknown>) => Promise<WasmModule>;\r\n\r\nexport function unwrapFactory(candidate: unknown): WasmModuleFactory | undefined {\r\n    if (typeof candidate === 'function') {\r\n        return candidate as WasmModuleFactory;\r\n    }\r\n\r\n    if (typeof candidate === 'object' && candidate !== null) {\r\n        const maybeDefault = (candidate as { default?: unknown }).default;\r\n        if (typeof maybeDefault === 'function') {\r\n            return maybeDefault as WasmModuleFactory;\r\n        }\r\n    }\r\n\r\n    return undefined;\r\n}", "export const LIBRARY_VERSION = '1.2.0';\r\nexport const API_VERSION = 1;\r\nexport const CHECKPOINT_SCHEMA_VERSION = 1;\r\nexport const OPERATION_SCHEMA_VERSION = 1;\r\nexport const SUPPORTED_RUNTIMES = ['browser', 'worker', 'node'] as const;", "/**\r\n * OcctKernel \u2013 the primary public class of occt-kernel-wasm.\r\n *\r\n * Wraps the native OCCT WASM module behind a clean, high-level TypeScript API.\r\n * All shapes are referenced by opaque {@link ShapeHandle} objects. No OCCT types\r\n * are ever exposed to the caller.\r\n *\r\n * Usage:\r\n * ```ts\r\n * import { createKernel } from 'occt-kernel-wasm';\r\n *\r\n * const kernel = await createKernel();\r\n * const box = kernel.createBox({ dx: 10, dy: 10, dz: 10 });\r\n * const mesh = kernel.tessellate({ shape: box });\r\n * const step = kernel.exportStep({ shape: box });\r\n * kernel.disposeShape({ shape: box });\r\n * ```\r\n */\r\n\r\nimport { KernelError, parseNativeError } from './errors';\r\nimport {\r\n    API_VERSION,\r\n    CHECKPOINT_SCHEMA_VERSION,\r\n    LIBRARY_VERSION,\r\n    OPERATION_SCHEMA_VERSION,\r\n    SUPPORTED_RUNTIMES,\r\n} from './version';\r\nimport type {\r\n    BooleanParams,\r\n    BlendOperationResult,\r\n    BoundingBox,\r\n    BoxParams,\r\n    ChamferFeatureParams,\r\n    ChamferParams,\r\n    ClosestPointOnShapeParams,\r\n    ClosestPointOnShapeResult,\r\n    CreateCheckpointParams,\r\n    CylinderParams,\r\n    DisposeParams,\r\n    EdgeCurveResult,\r\n    EdgeEvaluationParams,\r\n    EdgeEvaluationResult,\r\n    EdgeRef,\r\n    EdgeSampleResult,\r\n    EntityRevisionMapResult,\r\n    ExportStepParams,\r\n    ExtrudeCutProfileFeatureParams,\r\n    ExtrudeParams,\r\n    ExtrudeProfileFeatureParams,\r\n    ExtrudeProfileSpec,\r\n    FaceEvaluationParams,\r\n    FaceEvaluationResult,\r\n    FaceRef,\r\n    FeatureEdgeChain,\r\n    FeaturePreviewParams,\r\n    FeaturePreviewResult,\r\n    FilletFeatureParams,\r\n    FilletParams,\r\n    ImportStepDetailedResult,\r\n    ImportStepParams,\r\n    ImportStepPackageParams,\r\n    ImportStepPackageResult,\r\n    KernelCapabilities,\r\n    KernelVersionInfo,\r\n    HydrateCheckpointParams,\r\n    LoftFeatureParams,\r\n    LoftSection,\r\n    LoftSpec,\r\n    MapEntitiesAcrossRevisionsParams,\r\n    PlaneFrame,\r\n    PlanarFaceWiresParams,\r\n    PlanarFaceWiresResult,\r\n    PointContainmentParams,\r\n    PointContainmentResult,\r\n    Point2,\r\n    Point3,\r\n    Profile,\r\n    ProfileSegment,\r\n    ProfileWire,\r\n    ReleaseRevisionParams,\r\n    ResolveStableEntityParams,\r\n    RetainRevisionParams,\r\n    RevolveCutProfileFeatureParams,\r\n    RevolveParams,\r\n    RevolveProfileFeatureParams,\r\n    RevolveProfileSpec,\r\n    RevisionCheckpoint,\r\n    RevisionInfo,\r\n    RotationTransform,\r\n    SampleEdgeParams,\r\n    ShapeHandle,\r\n    ShapeAnalysisParams,\r\n    ShapeAnalysisResult,\r\n    ShapeDistanceParams,\r\n    ShapeDistanceResult,\r\n    ShapeIntersectionParams,\r\n    ShapeIntersectionResult,\r\n    ShapeTransform,\r\n    SphereParams,\r\n    SpatialCurveSegment,\r\n    SpatialWire,\r\n    StableEntityResolution,\r\n    StepImportMessage,\r\n    StepImportOptions,\r\n    StepImportReadStatus,\r\n    StepImportTransferStatus,\r\n    SweepProfileFeatureParams,\r\n    SweepProfileSpec,\r\n    TessellateParams,\r\n    TessellationResult,\r\n    TopologyResult,\r\n    TransformParams,\r\n    Vector3,\r\n    OperationSchema,\r\n} from './types';\r\n\r\n// ---------------------------------------------------------------------------\r\n// Native module interface\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * Interface of the native OcctKernel C++ class as exposed via Emscripten embind.\r\n * @internal\r\n */\r\nexport interface NativeKernel {\r\n    createBox(dx: number, dy: number, dz: number): number;\r\n    createCylinder(radius: number, height: number): number;\r\n    createSphere(radius: number): number;\r\n    extrudeProfile(profileJson: string, optionsJson: string): number;\r\n    extrudeProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number;\r\n    extrudeCutProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number;\r\n    revolveProfile(profileJson: string, optionsJson: string): number;\r\n    revolveProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number;\r\n    revolveCutProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number;\r\n    sweepProfileWithSpec?: (id: number, profileJson: string, specJson: string) => number;\r\n    loftWithSpec?: (id: number, sectionsJson: string, specJson: string) => number;\r\n    booleanUnion(id1: number, id2: number): number;\r\n    booleanSubtract(id1: number, id2: number): number;\r\n    booleanIntersect(id1: number, id2: number): number;\r\n    filletEdges(id: number, radius: number): number;\r\n    chamferEdges(id: number, distance: number): number;\r\n    filletEdgesWithSpec?: (id: number, specJson: string) => string;\r\n    chamferEdgesWithSpec?: (id: number, specJson: string) => string;\r\n    getLastError?: () => string;\r\n    clearLastError?: () => void;\r\n    transformShape(id: number, transformJson: string): number;\r\n    getTopology(id: number): string;\r\n    getRevisionInfo?: (id: number) => string;\r\n    resolveStableEntity?: (id: number, stableHash: string) => string;\r\n    mapEntitiesAcrossRevisions?: (fromRevisionId: string, toRevisionId: string, stableHashesJson: string) => string;\r\n    evaluateEdge?: (id: number, edgeRefJson: string, t: number) => string;\r\n    sampleEdge?: (id: number, edgeRefJson: string, optionsJson: string) => string;\r\n    getEdgeCurve?: (id: number, edgeRefJson: string) => string;\r\n    evaluateFace?: (id: number, faceRefJson: string, u: number, v: number) => string;\r\n    getPlanarFaceWires?: (id: number, faceRefJson: string) => string;\r\n    getOperationSchema?: () => string;\r\n    getCapabilities?: () => string;\r\n    getKernelVersionInfo?: () => string;\r\n    analyzeShape?: (id: number) => string;\r\n    classifyPointContainment?: (id: number, pointJson: string, tolerance: number) => string;\r\n    intersectShapes?: (id1: number, id2: number) => string;\r\n    findClosestPointOnShape?: (id: number, pointJson: string, tolerance: number) => string;\r\n    measureShapeDistance?: (id1: number, id2: number, tolerance: number) => string;\r\n    checkValidity(id: number): boolean;\r\n    tessellate(id: number, linearDeflection: number, angularDeflection: number): string;\r\n    tessellateWithOptions?: (id: number, linearDeflection: number, angularDeflection: number, optionsJson: string) => string;\r\n    importStep(content: string): number;\r\n    importStepDetailed(\r\n        content: string,\r\n        heal: boolean,\r\n        sew: boolean,\r\n        fixSameParameter: boolean,\r\n        fixSolid: boolean,\r\n        sewingTolerance: number,\r\n    ): string;\r\n    importStepPackage?(\r\n        content: string,\r\n        heal: boolean,\r\n        sew: boolean,\r\n        fixSameParameter: boolean,\r\n        fixSolid: boolean,\r\n        sewingTolerance: number,\r\n        linearDeflection: number,\r\n        angularDeflection: number,\r\n    ): string;\r\n    exportStep(id: number): string;\r\n    createCheckpoint?: (id: number) => string;\r\n    hydrateCheckpoint?: (checkpointJson: string) => number;\r\n    disposeShape(id: number): void;\r\n    retainRevision?: (id: number) => void;\r\n    releaseRevision?: (id: number) => boolean;\r\n}\r\n\r\nexport interface WasmModule {\r\n    OcctKernel: new () => NativeKernel;\r\n}\r\n\r\ntype ResolveShapeId = (shape: ShapeHandle, name: string) => number;\r\n\r\n// ---------------------------------------------------------------------------\r\n// Helpers\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Make a {@link ShapeHandle} from a raw integer. */\r\nlet sessionCounter = 0;\r\n\r\nfunction createSessionId(): string {\r\n    sessionCounter += 1;\r\n    return `session_${Date.now().toString(36)}_${sessionCounter.toString(36)}`;\r\n}\r\n\r\nfunction makeHandle(id: number, sessionId: string): ShapeHandle {\r\n    if (!Number.isInteger(id) || id <= 0) {\r\n        throw new KernelError('OPERATION_FAILED', `Native operation returned an invalid shape handle: ${String(id)}`);\r\n    }\r\n    return Object.freeze({ id, sessionId });\r\n}\r\n\r\nfunction resolveShapeId(shape: ShapeHandle, sessionId: string, name: string): number {\r\n    if (!Number.isInteger(shape.id) || shape.id <= 0) {\r\n        throw new KernelError('INVALID_HANDLE', `${name} must contain a positive integer id`);\r\n    }\r\n    if (typeof shape.sessionId !== 'string' || shape.sessionId.length === 0) {\r\n        throw new KernelError('INVALID_HANDLE', `${name} was not created by a valid kernel session`);\r\n    }\r\n    if (shape.sessionId !== sessionId) {\r\n        throw new KernelError('SESSION_MISMATCH', `${name} belongs to kernel session ${shape.sessionId}, not ${sessionId}`);\r\n    }\r\n    return shape.id;\r\n}\r\n\r\n/**\r\n * Wrap a native call, converting any thrown value (native C++ exception\r\n * or KernelError from the mock) to a {@link KernelError}.\r\n */\r\nfunction isOpaqueNativeException(value: unknown): boolean {\r\n    return typeof value === 'number'\r\n        || typeof value === 'bigint'\r\n        || (typeof value === 'string' && /^\\d+$/.test(value));\r\n}\r\n\r\nfunction wrap<T>(fn: () => T, native?: NativeKernel): T {\r\n    native?.clearLastError?.();\r\n    try {\r\n        return fn();\r\n    } catch (err) {\r\n        if (isOpaqueNativeException(err)) {\r\n            const lastError = native?.getLastError?.();\r\n            if (typeof lastError === 'string' && lastError.length > 0) {\r\n                throw parseNativeError(lastError);\r\n            }\r\n        }\r\n        throw parseNativeError(err);\r\n    }\r\n}\r\n\r\n/**\r\n * Parse a JSON string returned by the native layer.\r\n * Throws {@link KernelError} with code `OPERATION_FAILED` on failure.\r\n */\r\nfunction parseJson<T>(raw: string, context: string): T {\r\n    try {\r\n        return JSON.parse(raw) as T;\r\n    } catch {\r\n        throw new KernelError('OPERATION_FAILED', `Failed to parse ${context} result: ${raw}`);\r\n    }\r\n}\r\n\r\n/** Assert that a value is a positive finite number. */\r\nfunction requirePositive(value: number, name: string): void {\r\n    if (!Number.isFinite(value) || value <= 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must be a positive finite number`);\r\n    }\r\n}\r\n\r\nfunction requireFinite(value: number, name: string): void {\r\n    if (!Number.isFinite(value)) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must be a finite number`);\r\n    }\r\n}\r\n\r\nfunction requirePoint2(value: Point2, name: string): void {\r\n    if (!Array.isArray(value) || value.length !== 2) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must be a 2-element array`);\r\n    }\r\n    requireFinite(value[0], `${name}[0]`);\r\n    requireFinite(value[1], `${name}[1]`);\r\n}\r\n\r\nfunction requirePoint3(value: Point3, name: string): void {\r\n    if (!Array.isArray(value) || value.length !== 3) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must be a 3-element array`);\r\n    }\r\n    requireFinite(value[0], `${name}[0]`);\r\n    requireFinite(value[1], `${name}[1]`);\r\n    requireFinite(value[2], `${name}[2]`);\r\n}\r\n\r\nfunction requirePositiveInteger(value: number, name: string): void {\r\n    if (!Number.isInteger(value) || value <= 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must be a positive integer`);\r\n    }\r\n}\r\n\r\nfunction requireSchemaVersion(value: { readonly schemaVersion?: number }, name: string): void {\r\n    if (value.schemaVersion !== 1) {\r\n        throw new KernelError('INVALID_PARAMS', `${name}.schemaVersion must be 1`);\r\n    }\r\n}\r\n\r\nfunction throwStructuredInvalid(operation: string, path: string, reason: string, unsupportedFeature?: string): never {\r\n    throw new KernelError('INVALID_PARAMS', JSON.stringify({\r\n        phase: 'validation',\r\n        operation,\r\n        path,\r\n        reason,\r\n        ...(unsupportedFeature !== undefined ? { unsupportedFeature } : {}),\r\n    }));\r\n}\r\n\r\nfunction requireSupportedBlendControls(\r\n    operation: 'filletEdges' | 'chamferEdges',\r\n    path: string,\r\n    value: {\r\n        readonly limits?: unknown;\r\n        readonly tangentPropagation?: boolean;\r\n        readonly cornerMode?: string;\r\n        readonly overflowMode?: string;\r\n    },\r\n): void {\r\n    const family = operation === 'filletEdges' ? 'fillet' : 'chamfer';\r\n    if (value.limits !== undefined) {\r\n        throwStructuredInvalid(operation, `${path}.limits`, 'Partial-edge blends are not exposed by this OCCT build', `${family}.partialEdge`);\r\n    }\r\n    if (value.tangentPropagation === false) {\r\n        throwStructuredInvalid(operation, `${path}.tangentPropagation`, 'Disabling tangent propagation is not exposed by this OCCT build', `${family}.nonPropagatingEdges`);\r\n    }\r\n    if (value.cornerMode !== undefined && value.cornerMode !== 'rollingBall') {\r\n        throwStructuredInvalid(operation, `${path}.cornerMode`, 'Only rollingBall corner handling is supported by this OCCT build', `${family}.cornerModes`);\r\n    }\r\n    if (value.overflowMode !== undefined && value.overflowMode !== 'fail') {\r\n        throwStructuredInvalid(operation, `${path}.overflowMode`, 'Only fail-fast overflow handling is supported by this OCCT build', `${family}.overflowModes`);\r\n    }\r\n}\r\n\r\nfunction requireEdgeRef(value: EdgeRef, name: string): void {\r\n    if (value.topoId === undefined && value.stableHash === undefined) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must include topoId or stableHash`);\r\n    }\r\n    if (value.topoId !== undefined) {\r\n        requirePositiveInteger(value.topoId, `${name}.topoId`);\r\n    }\r\n    if (value.stableHash !== undefined && value.stableHash.length === 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${name}.stableHash must be non-empty`);\r\n    }\r\n}\r\n\r\nfunction requireFaceRef(value: FaceRef, name: string): void {\r\n    requireEdgeRef(value, name);\r\n}\r\n\r\nfunction withShapeHandle(result: Omit<BlendOperationResult, 'shape'>, sessionId: string, context: string): BlendOperationResult {\r\n    if (typeof result !== 'object' || result === null || !Number.isInteger(result.shapeId) || result.shapeId <= 0) {\r\n        throw new KernelError('OPERATION_FAILED', `${context} did not include a valid shapeId`);\r\n    }\r\n    return {\r\n        ...result,\r\n        shape: makeHandle(result.shapeId, sessionId),\r\n    };\r\n}\r\n\r\nfunction requirePoint2Array(values: readonly Point2[], name: string, minimumLength: number): void {\r\n    if (!Array.isArray(values) || values.length < minimumLength) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must contain at least ${minimumLength} points`);\r\n    }\r\n    values.forEach((value, index) => requirePoint2(value, `${name}[${index}]`));\r\n}\r\n\r\nfunction requirePoint3Array(values: readonly Point3[], name: string, minimumLength: number): void {\r\n    if (!Array.isArray(values) || values.length < minimumLength) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must contain at least ${minimumLength} points`);\r\n    }\r\n    values.forEach((value, index) => requirePoint3(value, `${name}[${index}]`));\r\n}\r\n\r\nfunction requireFiniteNumberArray(values: readonly number[], name: string, minimumLength: number): void {\r\n    if (!Array.isArray(values) || values.length < minimumLength) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must contain at least ${minimumLength} values`);\r\n    }\r\n    values.forEach((value, index) => requireFinite(value, `${name}[${index}]`));\r\n}\r\n\r\nfunction requireStrictlyIncreasing(values: readonly number[], name: string): void {\r\n    for (let index = 1; index < values.length; index += 1) {\r\n        if (values[index] <= values[index - 1]) {\r\n            throw new KernelError('INVALID_PARAMS', `${name} must be strictly increasing`);\r\n        }\r\n    }\r\n}\r\n\r\nfunction requireVector3(value: Vector3, name: string, allowZero = false): void {\r\n    requirePoint3(value, name);\r\n    if (!allowZero && value[0] === 0 && value[1] === 0 && value[2] === 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${name} must not be the zero vector`);\r\n    }\r\n}\r\n\r\nfunction requireNonParallelVectors(a: Vector3, b: Vector3, aName: string, bName: string): void {\r\n    const crossX = a[1] * b[2] - a[2] * b[1];\r\n    const crossY = a[2] * b[0] - a[0] * b[2];\r\n    const crossZ = a[0] * b[1] - a[1] * b[0];\r\n    if (crossX === 0 && crossY === 0 && crossZ === 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${aName} must not be parallel to ${bName}`);\r\n    }\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Raw tessellation JSON from native layer\r\n// ---------------------------------------------------------------------------\r\n\r\ninterface RawTessellation {\r\n    positions: number[];\r\n    normals: number[];\r\n    indices: number[];\r\n    triangleNormals?: number[];\r\n    triangleTopoFaceIds?: number[];\r\n    triangleFaceGroups?: number[];\r\n    triangleStableHashes?: string[];\r\n    featureEdges?: FeatureEdgeChain[];\r\n    rawEdgeSegments?: number[];\r\n}\r\n\r\ninterface TessellationNativeOptions {\r\n    includeMetadata?: boolean;\r\n    includeTriangleNormals?: boolean;\r\n    includeTriangleTopoFaceIds?: boolean;\r\n    includeTriangleFaceGroups?: boolean;\r\n    includeTriangleStableHashes?: boolean;\r\n    includeFeatureEdges?: boolean;\r\n    includeRawEdgeSegments?: boolean;\r\n    faces?: readonly FaceRef[];\r\n}\r\n\r\ninterface RawTopology {\r\n    revisionId?: string;\r\n    operationId?: string | null;\r\n    sourceFeatureId?: string | null;\r\n    operationType?: string;\r\n    operandRevisionIds?: string[];\r\n    parameterHash?: string | null;\r\n    topologyHash?: string;\r\n    historySchemaVersion?: number;\r\n    createdFromCheckpoint?: boolean;\r\n    shapeType?: string;\r\n    solidCount?: number;\r\n    shellCount?: number;\r\n    wireCount?: number;\r\n    faceCount: number;\r\n    edgeCount: number;\r\n    vertexCount: number;\r\n    boundingBox: BoundingBox;\r\n    isValid: boolean;\r\n}\r\n\r\ninterface RawKernelVersionInfo {\r\n    kernelVersion: string;\r\n    kernelVersionMajor: number;\r\n    kernelVersionMinor: number;\r\n    kernelVersionMaintenance: number;\r\n    checkpointSchemaVersion?: number;\r\n    operationSchemaVersion?: number;\r\n}\r\n\r\ninterface RawShapeIntersectionResult {\r\n    hasIntersection: boolean;\r\n    edgeCount: number;\r\n    vertexCount: number;\r\n    sectionShapeId?: number;\r\n}\r\n\r\nconst fallbackCapabilities: KernelCapabilities = {\r\n    featureEdgesV1: false,\r\n    rawEdgeSegmentsV1: false,\r\n    featurePreviewV1: true,\r\n    tessellationOptionsV1: false,\r\n    triangleNormalsV1: false,\r\n    triangleFaceMappingV1: false,\r\n    topologySubshapesV1: false,\r\n    topologyHierarchyV1: false,\r\n    geometricStableHashesV1: false,\r\n    revisionInfoV1: false,\r\n    entityResolutionV1: false,\r\n    entityRemapV1: false,\r\n    revisionRetentionV1: false,\r\n    historyV1: false,\r\n    stableNamingV1: false,\r\n    checkpointV1: false,\r\n    versionInfoV1: false,\r\n    analysisV1: false,\r\n    sessionHandlesV1: false,\r\n};\r\n\r\ninterface RawStepImportMessage extends StepImportMessage {}\r\n\r\ninterface RawStepImportDetailedResult {\r\n    readStatus: StepImportReadStatus;\r\n    transferStatus: StepImportTransferStatus;\r\n    rootCount: number;\r\n    transferredRootCount: number;\r\n    messageList: RawStepImportMessage[];\r\n    shapeId?: number;\r\n    isValid: boolean;\r\n    wasValidBeforeHealing: boolean;\r\n    healed: boolean;\r\n}\r\n\r\ninterface NormalizedStepImportOptions {\r\n    heal: boolean;\r\n    sew: boolean;\r\n    fixSameParameter: boolean;\r\n    fixSolid: boolean;\r\n    sewingTolerance: number;\r\n}\r\n\r\nfunction normalizeImportOptions(options?: StepImportOptions): NormalizedStepImportOptions {\r\n    const sewingTolerance = options?.sewingTolerance ?? 1e-6;\r\n    requirePositive(sewingTolerance, 'sewingTolerance');\r\n\r\n    return {\r\n        heal: options?.heal ?? false,\r\n        sew: options?.sew ?? false,\r\n        fixSameParameter: options?.fixSameParameter ?? false,\r\n        fixSolid: options?.fixSolid ?? false,\r\n        sewingTolerance,\r\n    };\r\n}\r\n\r\nfunction formatImportFailure(result: ImportStepDetailedResult): string {\r\n    const firstFailure = result.messageList.find((message) => message.severity === 'fail');\r\n    if (firstFailure) {\r\n        return firstFailure.text;\r\n    }\r\n\r\n    const firstWarning = result.messageList.find((message) => message.severity === 'warning');\r\n    if (firstWarning) {\r\n        return firstWarning.text;\r\n    }\r\n\r\n    return `STEP import failed (${result.readStatus}/${result.transferStatus})`;\r\n}\r\n\r\nfunction toImportStepDetailedResult(raw: RawStepImportDetailedResult, sessionId: string): ImportStepDetailedResult {\r\n    return {\r\n        readStatus: raw.readStatus,\r\n        transferStatus: raw.transferStatus,\r\n        rootCount: raw.rootCount,\r\n        transferredRootCount: raw.transferredRootCount,\r\n        messageList: raw.messageList,\r\n        ...(raw.shapeId !== undefined ? { shape: makeHandle(raw.shapeId, sessionId) } : {}),\r\n        isValid: raw.isValid,\r\n        wasValidBeforeHealing: raw.wasValidBeforeHealing,\r\n        healed: raw.healed,\r\n    };\r\n}\r\n\r\ninterface RawStepImportPackageResult {\r\n    readStatus: StepImportReadStatus;\r\n    transferStatus: StepImportTransferStatus;\r\n    healed: boolean;\r\n    isValid: boolean;\r\n    messageList: RawStepImportMessage[];\r\n    shapeId?: number;\r\n    revision?: {\r\n        revisionId: string;\r\n        topologyHash: string;\r\n    };\r\n    topology?: {\r\n        solidCount: number;\r\n        shellCount: number;\r\n        wireCount: number;\r\n        faceCount: number;\r\n        edgeCount: number;\r\n        vertexCount: number;\r\n        isValid: boolean;\r\n    };\r\n    properties?: {\r\n        boundingBox: BoundingBox;\r\n        volume: number;\r\n        surfaceArea: number;\r\n        linearLength: number;\r\n        centerOfMass: Point3 | null;\r\n        centerOfMassBasis: 'volume' | 'surface' | 'linear' | 'none';\r\n    };\r\n    mesh?: RawTessellation;\r\n    checkpoint?: RevisionCheckpoint;\r\n}\r\n\r\nfunction toImportStepPackageResult(raw: RawStepImportPackageResult, sessionId: string): ImportStepPackageResult {\r\n    const mesh = raw.mesh ? {\r\n        positions: new Float32Array(raw.mesh.positions),\r\n        normals:   new Float32Array(raw.mesh.normals),\r\n        indices:   new Uint32Array(raw.mesh.indices),\r\n        ...(raw.mesh.triangleNormals !== undefined\r\n            ? { triangleNormals: new Float32Array(raw.mesh.triangleNormals) }\r\n            : {}),\r\n        ...(raw.mesh.triangleTopoFaceIds !== undefined\r\n            ? { triangleTopoFaceIds: new Uint32Array(raw.mesh.triangleTopoFaceIds) }\r\n            : {}),\r\n        ...(raw.mesh.triangleFaceGroups !== undefined\r\n            ? { triangleFaceGroups: new Uint32Array(raw.mesh.triangleFaceGroups) }\r\n            : {}),\r\n        ...(raw.mesh.triangleStableHashes !== undefined\r\n            ? { triangleStableHashes: raw.mesh.triangleStableHashes }\r\n            : {}),\r\n        ...(raw.mesh.featureEdges !== undefined\r\n            ? { featureEdges: raw.mesh.featureEdges }\r\n            : {}),\r\n        ...(raw.mesh.rawEdgeSegments !== undefined\r\n            ? { rawEdgeSegments: new Float32Array(raw.mesh.rawEdgeSegments) }\r\n            : {}),\r\n    } : undefined;\r\n\r\n    return {\r\n        readStatus: raw.readStatus,\r\n        transferStatus: raw.transferStatus,\r\n        healed: raw.healed,\r\n        isValid: raw.isValid,\r\n        messageList: raw.messageList,\r\n        ...(raw.shapeId !== undefined && raw.shapeId !== null ? { shape: makeHandle(raw.shapeId, sessionId) } : {}),\r\n        ...(raw.revision ? { revision: raw.revision } : {}),\r\n        ...(raw.topology ? { topology: raw.topology } : {}),\r\n        ...(raw.properties ? { properties: raw.properties } : {}),\r\n        ...(mesh ? { mesh } : {}),\r\n        ...(raw.checkpoint ? { checkpoint: raw.checkpoint } : {}),\r\n    };\r\n}\r\n\r\ninterface CanonicalProfileWire {\r\n    segments: ProfileSegment[];\r\n}\r\n\r\ninterface CanonicalProfile {\r\n    wires: CanonicalProfileWire[];\r\n}\r\n\r\ninterface CanonicalSpatialWire {\r\n    segments: SpatialCurveSegment[];\r\n}\r\n\r\ninterface ExtrudeOptionsPayload {\r\n    height?: number;\r\n    vector?: Vector3;\r\n    plane?: PlaneFrame;\r\n}\r\n\r\ninterface ExtrudeProfileSpecPayload {\r\n    schemaVersion: 1;\r\n    allowUnknownFields?: boolean;\r\n    unit?: { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n    plane?: PlaneFrame;\r\n    direction?: Vector3;\r\n    reverseDirection?: boolean;\r\n    draftAngleRadians?: number;\r\n    extent: { type: 'blind'; distance: number }\r\n        | { type: 'upToNext' }\r\n        | { type: 'throughAll' }\r\n        | { type: 'upToSurface'; surface: { shapeId?: number; face: FaceRef } }\r\n        | { type: 'offsetFromSurface'; surface: { shapeId?: number; face: FaceRef }; offset: number };\r\n    metadata?: Record<string, unknown>;\r\n}\r\n\r\ninterface RevolveOptionsPayload {\r\n    angleDegrees: number;\r\n    axisOrigin?: Point3;\r\n    axisDirection?: Vector3;\r\n}\r\n\r\ninterface RevolveProfileSpecPayload {\r\n    schemaVersion: 1;\r\n    allowUnknownFields?: boolean;\r\n    unit?: { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n    plane?: PlaneFrame;\r\n    axisOrigin?: Point3;\r\n    axisDirection?: Vector3;\r\n    reverseDirection?: boolean;\r\n    slidingEdges?: Array<{ profileEdgeIndex: number; face: FaceRef }>;\r\n    extent:\r\n        | { type: 'angle'; angleRadians: number }\r\n        | { type: 'upToSurface'; surface: { shapeId?: number; face: FaceRef } }\r\n        | { type: 'fromSurfaceToSurface'; fromSurface: { shapeId?: number; face: FaceRef }; untilSurface: { shapeId?: number; face: FaceRef } }\r\n        | { type: 'throughAll' }\r\n        | { type: 'upToSurfaceAtAngle'; surface: { shapeId?: number; face: FaceRef }; angleRadians: number };\r\n    metadata?: Record<string, unknown>;\r\n}\r\n\r\ninterface SweepTrihedronModePayload {\r\n    type: 'correctedFrenet' | 'frenet' | 'discrete' | 'fixedTrihedron' | 'fixedBinormal' | 'auxiliarySpine';\r\n    frame?: PlaneFrame;\r\n    binormal?: Vector3;\r\n    spineJson?: string;\r\n    curvilinearEquivalence?: boolean;\r\n    contact?: 'none' | 'contact' | 'contactOnBorder';\r\n}\r\n\r\ninterface SweepProfileSpecPayload {\r\n    schemaVersion: 1;\r\n    allowUnknownFields?: boolean;\r\n    unit?: { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n    plane?: PlaneFrame;\r\n    spineJson: string;\r\n    trihedronMode?: SweepTrihedronModePayload;\r\n    sectionWithContact?: boolean;\r\n    sectionWithCorrection?: boolean;\r\n    solid?: boolean;\r\n    forceApproxC1?: boolean;\r\n    transitionMode?: 'transformed' | 'rightCorner' | 'roundCorner';\r\n    tolerance?: { tol3d?: number; boundTol?: number; angularTol?: number };\r\n    maxDegree?: number;\r\n    maxSegments?: number;\r\n    cut?: boolean;\r\n    metadata?: Record<string, unknown>;\r\n}\r\n\r\ntype LoftSectionPayload =\r\n    | { type: 'profile'; profileJson: string; plane?: PlaneFrame }\r\n    | { type: 'wire'; wireJson: string }\r\n    | { type: 'point'; point: Point3 };\r\n\r\ninterface LoftSpecPayload {\r\n    schemaVersion: 1;\r\n    allowUnknownFields?: boolean;\r\n    solid?: boolean;\r\n    ruled?: boolean;\r\n    pres3d?: number;\r\n    checkCompatibility?: boolean;\r\n    smoothing?: boolean;\r\n    parametrization?: 'chordLength' | 'centripetal' | 'isoParametric';\r\n    continuity?: 'C0' | 'G1' | 'C1' | 'G2' | 'C2' | 'C3' | 'CN';\r\n    criteriumWeight?: { w1: number; w2: number; w3: number };\r\n    maxDegree?: number;\r\n    mutableInput?: boolean;\r\n    cut?: boolean;\r\n    metadata?: Record<string, unknown>;\r\n}\r\n\r\nfunction validateProfileSegment(segment: ProfileSegment, indexLabel: string): void {\r\n    switch (segment.type) {\r\n        case 'line':\r\n            requirePoint2(segment.start, `${indexLabel}.start`);\r\n            requirePoint2(segment.end, `${indexLabel}.end`);\r\n            break;\r\n        case 'arc':\r\n            requirePoint2(segment.start, `${indexLabel}.start`);\r\n            requirePoint2(segment.mid, `${indexLabel}.mid`);\r\n            requirePoint2(segment.end, `${indexLabel}.end`);\r\n            break;\r\n        case 'circle':\r\n            requirePoint2(segment.centre, `${indexLabel}.centre`);\r\n            requirePositive(segment.radius, `${indexLabel}.radius`);\r\n            break;\r\n        case 'bezier':\r\n            requirePoint2Array(segment.controlPoints, `${indexLabel}.controlPoints`, 2);\r\n            break;\r\n        case 'bspline': {\r\n            requirePoint2Array(segment.controlPoints, `${indexLabel}.controlPoints`, 2);\r\n            requirePositiveInteger(segment.degree, `${indexLabel}.degree`);\r\n            requireFiniteNumberArray(segment.knots, `${indexLabel}.knots`, 2);\r\n            requireStrictlyIncreasing(segment.knots, `${indexLabel}.knots`);\r\n            if (!Array.isArray(segment.multiplicities) || segment.multiplicities.length !== segment.knots.length) {\r\n                throw new KernelError('INVALID_PARAMS', `${indexLabel}.multiplicities must match ${indexLabel}.knots in length`);\r\n            }\r\n            segment.multiplicities.forEach((value, index) => requirePositiveInteger(value, `${indexLabel}.multiplicities[${index}]`));\r\n\r\n            const multiplicitySum = segment.multiplicities.reduce((sum, value) => sum + value, 0);\r\n            if (multiplicitySum - segment.degree - 1 !== segment.controlPoints.length) {\r\n                throw new KernelError('INVALID_PARAMS', `${indexLabel} has inconsistent controlPoints, degree, and multiplicities`);\r\n            }\r\n            break;\r\n        }\r\n        default:\r\n            throw new KernelError('INVALID_PARAMS', `${indexLabel}.type is not supported`);\r\n    }\r\n}\r\n\r\nfunction validateSpatialSegment(segment: SpatialCurveSegment, indexLabel: string): void {\r\n    switch (segment.type) {\r\n        case 'line':\r\n            requirePoint3(segment.start, `${indexLabel}.start`);\r\n            requirePoint3(segment.end, `${indexLabel}.end`);\r\n            break;\r\n        case 'arc':\r\n            requirePoint3(segment.start, `${indexLabel}.start`);\r\n            requirePoint3(segment.mid, `${indexLabel}.mid`);\r\n            requirePoint3(segment.end, `${indexLabel}.end`);\r\n            break;\r\n        case 'circle':\r\n            requirePoint3(segment.center, `${indexLabel}.center`);\r\n            requireVector3(segment.normal, `${indexLabel}.normal`);\r\n            requirePositive(segment.radius, `${indexLabel}.radius`);\r\n            if (segment.xDirection !== undefined) {\r\n                requireVector3(segment.xDirection, `${indexLabel}.xDirection`);\r\n                requireNonParallelVectors(segment.normal, segment.xDirection, `${indexLabel}.normal`, `${indexLabel}.xDirection`);\r\n            }\r\n            break;\r\n        case 'bezier':\r\n            requirePoint3Array(segment.controlPoints, `${indexLabel}.controlPoints`, 2);\r\n            break;\r\n        case 'bspline': {\r\n            requirePoint3Array(segment.controlPoints, `${indexLabel}.controlPoints`, 2);\r\n            requirePositiveInteger(segment.degree, `${indexLabel}.degree`);\r\n            requireFiniteNumberArray(segment.knots, `${indexLabel}.knots`, 2);\r\n            requireStrictlyIncreasing(segment.knots, `${indexLabel}.knots`);\r\n            if (!Array.isArray(segment.multiplicities) || segment.multiplicities.length !== segment.knots.length) {\r\n                throw new KernelError('INVALID_PARAMS', `${indexLabel}.multiplicities must match ${indexLabel}.knots in length`);\r\n            }\r\n            segment.multiplicities.forEach((value, index) => requirePositiveInteger(value, `${indexLabel}.multiplicities[${index}]`));\r\n\r\n            const multiplicitySum = segment.multiplicities.reduce((sum, value) => sum + value, 0);\r\n            if (multiplicitySum - segment.degree - 1 !== segment.controlPoints.length) {\r\n                throw new KernelError('INVALID_PARAMS', `${indexLabel} has inconsistent controlPoints, degree, and multiplicities`);\r\n            }\r\n            break;\r\n        }\r\n        default:\r\n            throw new KernelError('INVALID_PARAMS', `${indexLabel}.type is not supported`);\r\n    }\r\n}\r\n\r\nfunction normalizeWire(wire: ProfileWire, index: number): CanonicalProfileWire {\r\n    if (!wire || !Array.isArray(wire.segments) || wire.segments.length === 0) {\r\n        throw new KernelError('INVALID_PARAMS', `profile wire ${index} must have at least one segment`);\r\n    }\r\n    wire.segments.forEach((segment, segmentIndex) => validateProfileSegment(segment, `profile.wires[${index}].segments[${segmentIndex}]`));\r\n    return { segments: [...wire.segments] };\r\n}\r\n\r\nfunction normalizeProfile(profile: Profile): CanonicalProfile {\r\n    const wires = profile.wires\r\n        ?? (profile.outer ? [profile.outer, ...(profile.holes ?? [])] : undefined)\r\n        ?? (profile.segments ? [{ segments: profile.segments }] : undefined);\r\n\r\n    if (!wires || wires.length === 0) {\r\n        throw new KernelError('INVALID_PARAMS', \"Profile must include 'segments', 'outer', or 'wires'\");\r\n    }\r\n\r\n    return {\r\n        wires: wires.map((wire, index) => normalizeWire(wire, index)),\r\n    };\r\n}\r\n\r\nfunction normalizeSpatialWire(wire: SpatialWire, path: string): CanonicalSpatialWire {\r\n    if (!wire || !Array.isArray(wire.segments) || wire.segments.length === 0) {\r\n        throw new KernelError('INVALID_PARAMS', `${path} must have at least one segment`);\r\n    }\r\n    wire.segments.forEach((segment, segmentIndex) => validateSpatialSegment(segment, `${path}.segments[${segmentIndex}]`));\r\n    return {\r\n        segments: [...wire.segments],\r\n    };\r\n}\r\n\r\nfunction requireSingleWireProfile(profile: CanonicalProfile, path: string): CanonicalProfile {\r\n    if (profile.wires.length !== 1) {\r\n        throw new KernelError('INVALID_PARAMS', `${path} must contain exactly one closed wire for this operation`);\r\n    }\r\n    return profile;\r\n}\r\n\r\nfunction normalizePlaneFrame(plane?: PlaneFrame): PlaneFrame | undefined {\r\n    if (!plane) {\r\n        return undefined;\r\n    }\r\n\r\n    requirePoint3(plane.origin, 'plane.origin');\r\n    requireVector3(plane.normal, 'plane.normal');\r\n    requireVector3(plane.xDirection, 'plane.xDirection');\r\n    requireNonParallelVectors(plane.normal, plane.xDirection, 'plane.normal', 'plane.xDirection');\r\n\r\n    return {\r\n        origin: [...plane.origin] as Point3,\r\n        normal: [...plane.normal] as Vector3,\r\n        xDirection: [...plane.xDirection] as Vector3,\r\n    };\r\n}\r\n\r\nfunction normalizeExtrudeOptions(params: ExtrudeParams): ExtrudeOptionsPayload {\r\n    const hasHeight = params.height !== undefined;\r\n    const hasVector = params.vector !== undefined;\r\n\r\n    if (hasHeight === hasVector) {\r\n        throw new KernelError('INVALID_PARAMS', \"Extrude params must specify exactly one of 'height' or 'vector'\");\r\n    }\r\n\r\n    const plane = normalizePlaneFrame(params.plane);\r\n    if (hasHeight) {\r\n        requirePositive(params.height as number, 'height');\r\n        return {\r\n            height: params.height,\r\n            ...(plane ? { plane } : {}),\r\n        };\r\n    }\r\n\r\n    requireVector3(params.vector as Vector3, 'vector');\r\n    return {\r\n        vector: [...(params.vector as Vector3)] as Vector3,\r\n        ...(plane ? { plane } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeExtrudeProfileSpec(spec: ExtrudeProfileSpec, getShapeId?: ResolveShapeId): ExtrudeProfileSpecPayload {\r\n    requireSchemaVersion(spec, 'extrude spec');\r\n\r\n    const unit = spec.unit !== undefined\r\n        ? (() => {\r\n            if (spec.unit.length !== undefined && spec.unit.length !== 'model') {\r\n                throw new KernelError('INVALID_PARAMS', 'extrude spec.unit.length must be model');\r\n            }\r\n            if (spec.unit.angle !== undefined && spec.unit.angle !== 'radians' && spec.unit.angle !== 'degrees') {\r\n                throw new KernelError('INVALID_PARAMS', 'extrude spec.unit.angle must be radians or degrees');\r\n            }\r\n            return {\r\n                ...(spec.unit.length !== undefined ? { length: spec.unit.length } : {}),\r\n                ...(spec.unit.angle !== undefined ? { angle: spec.unit.angle } : {}),\r\n            } as { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n        })()\r\n        : undefined;\r\n\r\n    const plane = normalizePlaneFrame(spec.plane);\r\n    const direction = spec.direction !== undefined\r\n        ? (() => {\r\n            requireVector3(spec.direction, 'spec.direction');\r\n            return [...spec.direction] as Vector3;\r\n        })()\r\n        : undefined;\r\n\r\n    const hasDraftAngleRadians = spec.draftAngleRadians !== undefined;\r\n    const hasDraftAngleDegrees = spec.draftAngleDegrees !== undefined;\r\n    if (hasDraftAngleRadians && hasDraftAngleDegrees) {\r\n        throw new KernelError('INVALID_PARAMS', 'extrude spec must not specify both draftAngleRadians and draftAngleDegrees');\r\n    }\r\n\r\n    let draftAngleRadians: number | undefined;\r\n    if (hasDraftAngleRadians) {\r\n        requireFinite(spec.draftAngleRadians as number, 'spec.draftAngleRadians');\r\n        if (Math.abs(spec.draftAngleRadians as number) >= Math.PI / 2) {\r\n            throw new KernelError('INVALID_PARAMS', 'spec.draftAngleRadians must be in (-pi/2, pi/2)');\r\n        }\r\n        draftAngleRadians = spec.draftAngleRadians;\r\n    } else if (hasDraftAngleDegrees) {\r\n        requireFinite(spec.draftAngleDegrees as number, 'spec.draftAngleDegrees');\r\n        if (Math.abs(spec.draftAngleDegrees as number) >= 90) {\r\n            throw new KernelError('INVALID_PARAMS', 'spec.draftAngleDegrees must be in (-90, 90)');\r\n        }\r\n        draftAngleRadians = (spec.draftAngleDegrees as number) * Math.PI / 180;\r\n    }\r\n\r\n    const normalizeSurface = (name: string, surface: { readonly shape?: ShapeHandle; readonly face: FaceRef }) => ({\r\n        ...(surface.shape !== undefined\r\n            ? { shapeId: getShapeId ? getShapeId(surface.shape, `${name}.shape`) : surface.shape.id }\r\n            : {}),\r\n        face: (() => {\r\n            requireFaceRef(surface.face, `${name}.face`);\r\n            return { ...surface.face };\r\n        })(),\r\n    });\r\n\r\n    const extent = (() => {\r\n        if (!spec.extent || typeof spec.extent !== 'object' || typeof spec.extent.type !== 'string') {\r\n            throw new KernelError('INVALID_PARAMS', 'spec.extent must be a structured extent descriptor');\r\n        }\r\n\r\n        switch (spec.extent.type) {\r\n            case 'blind':\r\n                requirePositive(spec.extent.distance, 'spec.extent.distance');\r\n                return { type: 'blind' as const, distance: spec.extent.distance };\r\n            case 'upToNext':\r\n                return { type: 'upToNext' as const };\r\n            case 'throughAll':\r\n                return { type: 'throughAll' as const };\r\n            case 'upToSurface':\r\n                return {\r\n                    type: 'upToSurface' as const,\r\n                    surface: normalizeSurface('spec.extent.surface', spec.extent.surface),\r\n                };\r\n            case 'offsetFromSurface':\r\n                requirePositive(spec.extent.offset, 'spec.extent.offset');\r\n                return {\r\n                    type: 'offsetFromSurface' as const,\r\n                    surface: normalizeSurface('spec.extent.surface', spec.extent.surface),\r\n                    offset: spec.extent.offset,\r\n                };\r\n            default:\r\n                throw new KernelError('INVALID_PARAMS', `spec.extent.type '${(spec.extent as { type: string }).type}' is not supported`);\r\n        }\r\n    })();\r\n\r\n    return {\r\n        schemaVersion: 1,\r\n        ...(spec.allowUnknownFields !== undefined ? { allowUnknownFields: spec.allowUnknownFields } : {}),\r\n        ...(unit ? { unit } : {}),\r\n        ...(plane ? { plane } : {}),\r\n        ...(direction ? { direction } : {}),\r\n        ...(spec.reverseDirection !== undefined ? { reverseDirection: spec.reverseDirection } : {}),\r\n        ...(draftAngleRadians !== undefined ? { draftAngleRadians } : {}),\r\n        extent,\r\n        ...(spec.metadata !== undefined ? { metadata: spec.metadata } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeSurfaceTarget(\r\n    name: string,\r\n    surface: { readonly shape?: ShapeHandle; readonly face: FaceRef },\r\n    getShapeId?: ResolveShapeId,\r\n): { shapeId?: number; face: FaceRef } {\r\n    return {\r\n        ...(surface.shape !== undefined\r\n            ? { shapeId: getShapeId ? getShapeId(surface.shape, `${name}.shape`) : surface.shape.id }\r\n            : {}),\r\n        face: (() => {\r\n            requireFaceRef(surface.face, `${name}.face`);\r\n            return { ...surface.face };\r\n        })(),\r\n    };\r\n}\r\n\r\nfunction normalizeRevolveAngleRadians(\r\n    path: string,\r\n    angleRadians?: number,\r\n    angleDegrees?: number,\r\n): number {\r\n    const hasRadians = angleRadians !== undefined;\r\n    const hasDegrees = angleDegrees !== undefined;\r\n    if (hasRadians && hasDegrees) {\r\n        throw new KernelError('INVALID_PARAMS', `${path} must not specify both angleRadians and angleDegrees`);\r\n    }\r\n    if (!hasRadians && !hasDegrees) {\r\n        throw new KernelError('INVALID_PARAMS', `${path} must specify angleRadians or angleDegrees`);\r\n    }\r\n\r\n    if (hasRadians) {\r\n        requireFinite(angleRadians as number, `${path}.angleRadians`);\r\n        if ((angleRadians as number) === 0 || Math.abs(angleRadians as number) > Math.PI * 2) {\r\n            throw new KernelError('INVALID_PARAMS', `${path}.angleRadians must be in [-2pi, 2pi] excluding 0`);\r\n        }\r\n        return angleRadians as number;\r\n    }\r\n\r\n    requireFinite(angleDegrees as number, `${path}.angleDegrees`);\r\n    if ((angleDegrees as number) === 0 || Math.abs(angleDegrees as number) > 360) {\r\n        throw new KernelError('INVALID_PARAMS', `${path}.angleDegrees must be in [-360, 360] excluding 0`);\r\n    }\r\n    return (angleDegrees as number) * Math.PI / 180;\r\n}\r\n\r\nfunction normalizeRevolveProfileSpec(spec: RevolveProfileSpec, getShapeId?: ResolveShapeId): RevolveProfileSpecPayload {\r\n    requireSchemaVersion(spec, 'revolve spec');\r\n\r\n    const unit = spec.unit !== undefined\r\n        ? (() => {\r\n            if (spec.unit.length !== undefined && spec.unit.length !== 'model') {\r\n                throw new KernelError('INVALID_PARAMS', 'revolve spec.unit.length must be model');\r\n            }\r\n            if (spec.unit.angle !== undefined && spec.unit.angle !== 'radians' && spec.unit.angle !== 'degrees') {\r\n                throw new KernelError('INVALID_PARAMS', 'revolve spec.unit.angle must be radians or degrees');\r\n            }\r\n            return {\r\n                ...(spec.unit.length !== undefined ? { length: spec.unit.length } : {}),\r\n                ...(spec.unit.angle !== undefined ? { angle: spec.unit.angle } : {}),\r\n            } as { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n        })()\r\n        : undefined;\r\n\r\n    const plane = normalizePlaneFrame(spec.plane);\r\n    const axisOrigin = spec.axisOrigin !== undefined\r\n        ? (() => {\r\n            requirePoint3(spec.axisOrigin, 'spec.axisOrigin');\r\n            return [...spec.axisOrigin] as Point3;\r\n        })()\r\n        : undefined;\r\n    const axisDirection = spec.axisDirection !== undefined\r\n        ? (() => {\r\n            requireVector3(spec.axisDirection, 'spec.axisDirection');\r\n            return [...spec.axisDirection] as Vector3;\r\n        })()\r\n        : undefined;\r\n\r\n    const slidingEdges = spec.slidingEdges !== undefined\r\n        ? spec.slidingEdges.map((entry, index) => {\r\n            requirePositiveInteger(entry.profileEdgeIndex, `spec.slidingEdges[${index}].profileEdgeIndex`);\r\n            requireFaceRef(entry.face, `spec.slidingEdges[${index}].face`);\r\n            return {\r\n                profileEdgeIndex: entry.profileEdgeIndex,\r\n                face: { ...entry.face },\r\n            };\r\n        })\r\n        : undefined;\r\n\r\n    const extent = (() => {\r\n        if (!spec.extent || typeof spec.extent !== 'object' || typeof spec.extent.type !== 'string') {\r\n            throw new KernelError('INVALID_PARAMS', 'spec.extent must be a structured extent descriptor');\r\n        }\r\n\r\n        switch (spec.extent.type) {\r\n            case 'angle':\r\n                return {\r\n                    type: 'angle' as const,\r\n                    angleRadians: normalizeRevolveAngleRadians('spec.extent', spec.extent.angleRadians, spec.extent.angleDegrees),\r\n                };\r\n            case 'upToSurface':\r\n                return {\r\n                    type: 'upToSurface' as const,\r\n                    surface: normalizeSurfaceTarget('spec.extent.surface', spec.extent.surface, getShapeId),\r\n                };\r\n            case 'fromSurfaceToSurface':\r\n                return {\r\n                    type: 'fromSurfaceToSurface' as const,\r\n                    fromSurface: normalizeSurfaceTarget('spec.extent.fromSurface', spec.extent.fromSurface, getShapeId),\r\n                    untilSurface: normalizeSurfaceTarget('spec.extent.untilSurface', spec.extent.untilSurface, getShapeId),\r\n                };\r\n            case 'throughAll':\r\n                return { type: 'throughAll' as const };\r\n            case 'upToSurfaceAtAngle':\r\n                return {\r\n                    type: 'upToSurfaceAtAngle' as const,\r\n                    surface: normalizeSurfaceTarget('spec.extent.surface', spec.extent.surface, getShapeId),\r\n                    angleRadians: normalizeRevolveAngleRadians('spec.extent', spec.extent.angleRadians, spec.extent.angleDegrees),\r\n                };\r\n            default:\r\n                throw new KernelError('INVALID_PARAMS', `spec.extent.type '${(spec.extent as { type: string }).type}' is not supported`);\r\n        }\r\n    })();\r\n\r\n    return {\r\n        schemaVersion: 1,\r\n        ...(spec.allowUnknownFields !== undefined ? { allowUnknownFields: spec.allowUnknownFields } : {}),\r\n        ...(unit ? { unit } : {}),\r\n        ...(plane ? { plane } : {}),\r\n        ...(axisOrigin ? { axisOrigin } : {}),\r\n        ...(axisDirection ? { axisDirection } : {}),\r\n        ...(spec.reverseDirection !== undefined ? { reverseDirection: spec.reverseDirection } : {}),\r\n        ...(slidingEdges !== undefined ? { slidingEdges } : {}),\r\n        extent,\r\n        ...(spec.metadata !== undefined ? { metadata: spec.metadata } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeSweepProfileSpec(spec: SweepProfileSpec, cut: boolean): SweepProfileSpecPayload {\r\n    requireSchemaVersion(spec, 'sweep spec');\r\n\r\n    const unit = spec.unit !== undefined\r\n        ? (() => {\r\n            if (spec.unit.length !== undefined && spec.unit.length !== 'model') {\r\n                throw new KernelError('INVALID_PARAMS', 'sweep spec.unit.length must be model');\r\n            }\r\n            if (spec.unit.angle !== undefined && spec.unit.angle !== 'radians' && spec.unit.angle !== 'degrees') {\r\n                throw new KernelError('INVALID_PARAMS', 'sweep spec.unit.angle must be radians or degrees');\r\n            }\r\n            return {\r\n                ...(spec.unit.length !== undefined ? { length: spec.unit.length } : {}),\r\n                ...(spec.unit.angle !== undefined ? { angle: spec.unit.angle } : {}),\r\n            } as { length?: 'model'; angle?: 'radians' | 'degrees' };\r\n        })()\r\n        : undefined;\r\n\r\n    const plane = normalizePlaneFrame(spec.plane);\r\n    const spineJson = JSON.stringify(normalizeSpatialWire(spec.spine, 'spec.spine'));\r\n    const solid = spec.solid ?? true;\r\n    if (cut && !solid) {\r\n        throw new KernelError('INVALID_PARAMS', 'sweep cut operations require spec.solid !== false');\r\n    }\r\n\r\n    const trihedronMode = spec.trihedronMode !== undefined\r\n        ? (() => {\r\n            switch (spec.trihedronMode.type) {\r\n                case 'correctedFrenet':\r\n                case 'frenet':\r\n                case 'discrete':\r\n                    return { type: spec.trihedronMode.type } as SweepTrihedronModePayload;\r\n                case 'fixedTrihedron':\r\n                    return {\r\n                        type: 'fixedTrihedron' as const,\r\n                        frame: normalizePlaneFrame(spec.trihedronMode.frame) as PlaneFrame,\r\n                    };\r\n                case 'fixedBinormal':\r\n                    requireVector3(spec.trihedronMode.binormal, 'spec.trihedronMode.binormal');\r\n                    return {\r\n                        type: 'fixedBinormal' as const,\r\n                        binormal: [...spec.trihedronMode.binormal] as Vector3,\r\n                    };\r\n                case 'auxiliarySpine':\r\n                    return {\r\n                        type: 'auxiliarySpine' as const,\r\n                        spineJson: JSON.stringify(normalizeSpatialWire(spec.trihedronMode.spine, 'spec.trihedronMode.spine')),\r\n                        ...(spec.trihedronMode.curvilinearEquivalence !== undefined ? { curvilinearEquivalence: spec.trihedronMode.curvilinearEquivalence } : {}),\r\n                        ...(spec.trihedronMode.contact !== undefined ? { contact: spec.trihedronMode.contact } : {}),\r\n                    };\r\n                default:\r\n                    throw new KernelError('INVALID_PARAMS', 'spec.trihedronMode.type is not supported');\r\n            }\r\n        })()\r\n        : undefined;\r\n\r\n    const tolerance = spec.tolerance !== undefined\r\n        ? (() => {\r\n            if (spec.tolerance.tol3d !== undefined) {\r\n                requirePositive(spec.tolerance.tol3d, 'spec.tolerance.tol3d');\r\n            }\r\n            if (spec.tolerance.boundTol !== undefined) {\r\n                requirePositive(spec.tolerance.boundTol, 'spec.tolerance.boundTol');\r\n            }\r\n            if (spec.tolerance.angularTol !== undefined) {\r\n                requirePositive(spec.tolerance.angularTol, 'spec.tolerance.angularTol');\r\n            }\r\n            return {\r\n                ...(spec.tolerance.tol3d !== undefined ? { tol3d: spec.tolerance.tol3d } : {}),\r\n                ...(spec.tolerance.boundTol !== undefined ? { boundTol: spec.tolerance.boundTol } : {}),\r\n                ...(spec.tolerance.angularTol !== undefined ? { angularTol: spec.tolerance.angularTol } : {}),\r\n            };\r\n        })()\r\n        : undefined;\r\n\r\n    if (spec.maxDegree !== undefined) {\r\n        requirePositiveInteger(spec.maxDegree, 'spec.maxDegree');\r\n    }\r\n    if (spec.maxSegments !== undefined) {\r\n        requirePositiveInteger(spec.maxSegments, 'spec.maxSegments');\r\n    }\r\n\r\n    return {\r\n        schemaVersion: 1,\r\n        ...(spec.allowUnknownFields !== undefined ? { allowUnknownFields: spec.allowUnknownFields } : {}),\r\n        ...(unit ? { unit } : {}),\r\n        ...(plane ? { plane } : {}),\r\n        spineJson,\r\n        ...(trihedronMode ? { trihedronMode } : {}),\r\n        ...(spec.sectionWithContact !== undefined ? { sectionWithContact: spec.sectionWithContact } : {}),\r\n        ...(spec.sectionWithCorrection !== undefined ? { sectionWithCorrection: spec.sectionWithCorrection } : {}),\r\n        ...(spec.solid !== undefined ? { solid: spec.solid } : {}),\r\n        ...(spec.forceApproxC1 !== undefined ? { forceApproxC1: spec.forceApproxC1 } : {}),\r\n        ...(spec.transitionMode !== undefined ? { transitionMode: spec.transitionMode } : {}),\r\n        ...(tolerance ? { tolerance } : {}),\r\n        ...(spec.maxDegree !== undefined ? { maxDegree: spec.maxDegree } : {}),\r\n        ...(spec.maxSegments !== undefined ? { maxSegments: spec.maxSegments } : {}),\r\n        ...(cut ? { cut: true } : {}),\r\n        ...(spec.metadata !== undefined ? { metadata: spec.metadata } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeLoftSections(sections: readonly LoftSection[]): LoftSectionPayload[] {\r\n    if (!Array.isArray(sections) || sections.length < 2) {\r\n        throw new KernelError('INVALID_PARAMS', 'loft sections must contain at least two entries');\r\n    }\r\n\r\n    return sections.map((section, index) => {\r\n        switch (section.type) {\r\n            case 'profile':\r\n                return (() => {\r\n                    const profile = requireSingleWireProfile(normalizeProfile(section.profile), `sections[${index}].profile`);\r\n                    return {\r\n                        type: 'profile' as const,\r\n                        profileJson: JSON.stringify(profile),\r\n                        ...(section.plane !== undefined ? { plane: normalizePlaneFrame(section.plane) as PlaneFrame } : {}),\r\n                    };\r\n                })();\r\n            case 'wire':\r\n                return {\r\n                    type: 'wire' as const,\r\n                    wireJson: JSON.stringify(normalizeSpatialWire(section.wire, `sections[${index}].wire`)),\r\n                };\r\n            case 'point':\r\n                requirePoint3(section.point, `sections[${index}].point`);\r\n                return {\r\n                    type: 'point' as const,\r\n                    point: [section.point[0], section.point[1], section.point[2]] as Point3,\r\n                };\r\n            default:\r\n                throw new KernelError('INVALID_PARAMS', `sections[${index}].type is not supported`);\r\n        }\r\n    });\r\n}\r\n\r\nfunction normalizeLoftSpec(spec: LoftSpec, cut: boolean): LoftSpecPayload {\r\n    requireSchemaVersion(spec, 'loft spec');\r\n\r\n    const solid = spec.solid ?? true;\r\n    if (cut && !solid) {\r\n        throw new KernelError('INVALID_PARAMS', 'loft cut operations require spec.solid !== false');\r\n    }\r\n\r\n    if (spec.pres3d !== undefined) {\r\n        requirePositive(spec.pres3d, 'spec.pres3d');\r\n    }\r\n    if (spec.maxDegree !== undefined) {\r\n        requirePositiveInteger(spec.maxDegree, 'spec.maxDegree');\r\n    }\r\n\r\n    const criteriumWeight = spec.criteriumWeight !== undefined\r\n        ? (() => {\r\n            requirePositive(spec.criteriumWeight.w1, 'spec.criteriumWeight.w1');\r\n            requirePositive(spec.criteriumWeight.w2, 'spec.criteriumWeight.w2');\r\n            requirePositive(spec.criteriumWeight.w3, 'spec.criteriumWeight.w3');\r\n            return {\r\n                w1: spec.criteriumWeight.w1,\r\n                w2: spec.criteriumWeight.w2,\r\n                w3: spec.criteriumWeight.w3,\r\n            };\r\n        })()\r\n        : undefined;\r\n\r\n    return {\r\n        schemaVersion: 1,\r\n        ...(spec.allowUnknownFields !== undefined ? { allowUnknownFields: spec.allowUnknownFields } : {}),\r\n        ...(spec.solid !== undefined ? { solid: spec.solid } : {}),\r\n        ...(spec.ruled !== undefined ? { ruled: spec.ruled } : {}),\r\n        ...(spec.pres3d !== undefined ? { pres3d: spec.pres3d } : {}),\r\n        ...(spec.checkCompatibility !== undefined ? { checkCompatibility: spec.checkCompatibility } : {}),\r\n        ...(spec.smoothing !== undefined ? { smoothing: spec.smoothing } : {}),\r\n        ...(spec.parametrization !== undefined ? { parametrization: spec.parametrization } : {}),\r\n        ...(spec.continuity !== undefined ? { continuity: spec.continuity } : {}),\r\n        ...(criteriumWeight ? { criteriumWeight } : {}),\r\n        ...(spec.maxDegree !== undefined ? { maxDegree: spec.maxDegree } : {}),\r\n        ...(spec.mutableInput !== undefined ? { mutableInput: spec.mutableInput } : {}),\r\n        ...(cut ? { cut: true } : {}),\r\n        ...(spec.metadata !== undefined ? { metadata: spec.metadata } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeRevolveOptions(params: RevolveParams): RevolveOptionsPayload {\r\n    if (!Number.isFinite(params.angleDegrees) || params.angleDegrees <= 0 || params.angleDegrees > 360) {\r\n        throw new KernelError('INVALID_PARAMS', 'angleDegrees must be in the range (0, 360]');\r\n    }\r\n\r\n    if (params.axisOrigin) {\r\n        requirePoint3(params.axisOrigin, 'axisOrigin');\r\n    }\r\n    if (params.axisDirection) {\r\n        requireVector3(params.axisDirection, 'axisDirection');\r\n    }\r\n\r\n    return {\r\n        angleDegrees: params.angleDegrees,\r\n        ...(params.axisOrigin ? { axisOrigin: [...params.axisOrigin] as Point3 } : {}),\r\n        ...(params.axisDirection ? { axisDirection: [...params.axisDirection] as Vector3 } : {}),\r\n    };\r\n}\r\n\r\nfunction normalizeRotationTransform(rotation: RotationTransform): RotationTransform {\r\n    requirePoint3(rotation.axisOrigin, 'transform.rotation.axisOrigin');\r\n    requireVector3(rotation.axisDirection, 'transform.rotation.axisDirection');\r\n    requireFinite(rotation.angleDegrees, 'transform.rotation.angleDegrees');\r\n\r\n    return {\r\n        axisOrigin: [...rotation.axisOrigin] as Point3,\r\n        axisDirection: [...rotation.axisDirection] as Vector3,\r\n        angleDegrees: rotation.angleDegrees,\r\n    };\r\n}\r\n\r\nfunction normalizeShapeTransform(transform: ShapeTransform): ShapeTransform {\r\n    if (!transform.translation && !transform.rotation) {\r\n        throw new KernelError('INVALID_PARAMS', 'Transform must specify translation and/or rotation');\r\n    }\r\n\r\n    const translation = transform.translation\r\n        ? (() => {\r\n            requireVector3(transform.translation as Vector3, 'transform.translation', true);\r\n            return [...transform.translation] as Vector3;\r\n        })()\r\n        : undefined;\r\n\r\n    const rotation = transform.rotation\r\n        ? normalizeRotationTransform(transform.rotation)\r\n        : undefined;\r\n\r\n    return {\r\n        ...(translation ? { translation } : {}),\r\n        ...(rotation ? { rotation } : {}),\r\n    };\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// OcctKernel\r\n// ---------------------------------------------------------------------------\r\n\r\n/**\r\n * High-level CAD kernel wrapper around the OCCT WASM module.\r\n *\r\n * Obtain an instance via {@link createKernel}.\r\n */\r\nexport class OcctKernel {\r\n    private readonly _native: NativeKernel;\r\n    private readonly _sessionId: string;\r\n\r\n    /** @internal \u2013 use {@link createKernel} instead. */\r\n    constructor(wasmModule: WasmModule) {\r\n        this._native = new wasmModule.OcctKernel();\r\n        this._sessionId = createSessionId();\r\n    }\r\n\r\n    private makeHandle(id: number): ShapeHandle {\r\n        return makeHandle(id, this._sessionId);\r\n    }\r\n\r\n    private shapeId(shape: ShapeHandle, name = 'shape'): number {\r\n        return resolveShapeId(shape, this._sessionId, name);\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Primitives\r\n    // -----------------------------------------------------------------------\r\n\r\n    /** Create a solid box aligned with the world axes, with one corner at the origin. */\r\n    createBox(params: BoxParams): ShapeHandle {\r\n        requirePositive(params.dx, 'dx');\r\n        requirePositive(params.dy, 'dy');\r\n        requirePositive(params.dz, 'dz');\r\n        return this.makeHandle(wrap(() => this._native.createBox(params.dx, params.dy, params.dz)));\r\n    }\r\n\r\n    /** Create a solid cylinder with its axis along +Z, base centred at the origin. */\r\n    createCylinder(params: CylinderParams): ShapeHandle {\r\n        requirePositive(params.radius, 'radius');\r\n        requirePositive(params.height, 'height');\r\n        return this.makeHandle(wrap(() => this._native.createCylinder(params.radius, params.height)));\r\n    }\r\n\r\n    /** Create a solid sphere centred at the origin. */\r\n    createSphere(params: SphereParams): ShapeHandle {\r\n        requirePositive(params.radius, 'radius');\r\n        return this.makeHandle(wrap(() => this._native.createSphere(params.radius)));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Sketch-based features\r\n    // -----------------------------------------------------------------------\r\n\r\n    /**\r\n     * Extrude a closed 2-D profile using either a local-plane height or an explicit vector.\r\n     */\r\n    extrudeProfile(params: ExtrudeParams): ShapeHandle {\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const optionsJson = JSON.stringify(normalizeExtrudeOptions(params));\r\n        return this.makeHandle(wrap(() => this._native.extrudeProfile(profileJson, optionsJson)));\r\n    }\r\n\r\n    /** Apply a versioned additive profile extrusion feature spec to a resident shape. */\r\n    extrudeProfileWithSpec(params: ExtrudeProfileFeatureParams): ShapeHandle {\r\n        if (typeof this._native.extrudeProfileWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support extrudeProfileWithSpec');\r\n        }\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const specJson = JSON.stringify(normalizeExtrudeProfileSpec(params.spec, (shape, name) => this.shapeId(shape, name)));\r\n        return this.makeHandle(wrap(() => this._native.extrudeProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    /** Apply a versioned subtractive profile extrusion feature spec to a resident shape. */\r\n    extrudeCutProfileWithSpec(params: ExtrudeCutProfileFeatureParams): ShapeHandle {\r\n        if (typeof this._native.extrudeCutProfileWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support extrudeCutProfileWithSpec');\r\n        }\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const specJson = JSON.stringify(normalizeExtrudeProfileSpec(params.spec, (shape, name) => this.shapeId(shape, name)));\r\n        return this.makeHandle(wrap(() => this._native.extrudeCutProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    /**\r\n     * Revolve a closed 2-D profile about an arbitrary world-space axis.\r\n     */\r\n    revolveProfile(params: RevolveParams): ShapeHandle {\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const optionsJson = JSON.stringify(normalizeRevolveOptions(params));\r\n        return this.makeHandle(wrap(() => this._native.revolveProfile(profileJson, optionsJson)));\r\n    }\r\n\r\n    /** Apply a versioned additive profile revolve feature spec to a resident shape. */\r\n    revolveProfileWithSpec(params: RevolveProfileFeatureParams): ShapeHandle {\r\n        if (params.cut === true) {\r\n            if (typeof this._native.revolveCutProfileWithSpec !== 'function') {\r\n                throw new KernelError('UNKNOWN', 'Native module does not support revolveCutProfileWithSpec');\r\n            }\r\n            const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n            const specJson = JSON.stringify(normalizeRevolveProfileSpec(params.spec, (shape, name) => this.shapeId(shape, name)));\r\n            return this.makeHandle(wrap(() => this._native.revolveCutProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n        }\r\n\r\n        if (typeof this._native.revolveProfileWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support revolveProfileWithSpec');\r\n        }\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const specJson = JSON.stringify(normalizeRevolveProfileSpec(params.spec, (shape, name) => this.shapeId(shape, name)));\r\n        return this.makeHandle(wrap(() => this._native.revolveProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    /** Apply a versioned subtractive profile revolve feature spec to a resident shape. */\r\n    revolveCutProfileWithSpec(params: RevolveCutProfileFeatureParams): ShapeHandle {\r\n        if (typeof this._native.revolveCutProfileWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support revolveCutProfileWithSpec');\r\n        }\r\n        const profileJson = JSON.stringify(normalizeProfile(params.profile));\r\n        const specJson = JSON.stringify(normalizeRevolveProfileSpec(params.spec, (shape, name) => this.shapeId(shape, name)));\r\n        return this.makeHandle(wrap(() => this._native.revolveCutProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    /** Apply a versioned sweep feature spec to a resident shape. */\r\n    sweepProfileWithSpec(params: SweepProfileFeatureParams): ShapeHandle {\r\n        if (typeof this._native.sweepProfileWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support sweepProfileWithSpec');\r\n        }\r\n        const profileJson = JSON.stringify(requireSingleWireProfile(normalizeProfile(params.profile), 'profile'));\r\n        const specJson = JSON.stringify(normalizeSweepProfileSpec(params.spec, params.cut === true));\r\n        return this.makeHandle(wrap(() => this._native.sweepProfileWithSpec?.(this.shapeId(params.shape), profileJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    /** Apply a versioned loft feature spec to a resident shape. */\r\n    loftWithSpec(params: LoftFeatureParams): ShapeHandle {\r\n        if (typeof this._native.loftWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support loftWithSpec');\r\n        }\r\n        const sectionsJson = JSON.stringify(normalizeLoftSections(params.sections));\r\n        const specJson = JSON.stringify(normalizeLoftSpec(params.spec, params.cut === true));\r\n        return this.makeHandle(wrap(() => this._native.loftWithSpec?.(this.shapeId(params.shape), sectionsJson, specJson) ?? 0, this._native));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Boolean operations\r\n    // -----------------------------------------------------------------------\r\n\r\n    /** Compute the union of two shapes. Returns a new shape handle. */\r\n    booleanUnion(params: BooleanParams): ShapeHandle {\r\n        return this.makeHandle(wrap(() => this._native.booleanUnion(this.shapeId(params.base, 'base'), this.shapeId(params.tool, 'tool'))));\r\n    }\r\n\r\n    /** Subtract `tool` from `base`. Returns a new shape handle. */\r\n    booleanSubtract(params: BooleanParams): ShapeHandle {\r\n        return this.makeHandle(wrap(() => this._native.booleanSubtract(this.shapeId(params.base, 'base'), this.shapeId(params.tool, 'tool'))));\r\n    }\r\n\r\n    /** Compute the intersection of two shapes. Returns a new shape handle. */\r\n    booleanIntersect(params: BooleanParams): ShapeHandle {\r\n        return this.makeHandle(wrap(() => this._native.booleanIntersect(this.shapeId(params.base, 'base'), this.shapeId(params.tool, 'tool'))));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Modifiers\r\n    // -----------------------------------------------------------------------\r\n\r\n    /**\r\n     * Apply a constant-radius fillet to all edges of a shape.\r\n     * Returns a new shape handle (original is unchanged).\r\n     */\r\n    filletEdges(params: FilletParams): ShapeHandle {\r\n        requirePositive(params.radius, 'radius');\r\n        return this.makeHandle(wrap(() => this._native.filletEdges(this.shapeId(params.shape), params.radius)));\r\n    }\r\n\r\n    /**\r\n     * Apply a constant-distance chamfer to all edges of a shape.\r\n     * Returns a new shape handle (original is unchanged).\r\n     */\r\n    chamferEdges(params: ChamferParams): ShapeHandle {\r\n        requirePositive(params.distance, 'distance');\r\n        return this.makeHandle(wrap(() => this._native.chamferEdges(this.shapeId(params.shape), params.distance)));\r\n    }\r\n\r\n    /** Apply a versioned native OCCT fillet spec and return exact blend lineage. */\r\n    filletEdgesWithSpec(params: FilletFeatureParams): BlendOperationResult {\r\n        if (typeof this._native.filletEdgesWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support filletEdgesWithSpec');\r\n        }\r\n        requireSchemaVersion(params.spec, 'fillet spec');\r\n        requireSupportedBlendControls('filletEdges', 'fillet', params.spec);\r\n        if (params.spec.edges !== undefined) {\r\n            params.spec.edges.forEach((entry, index) => {\r\n                const edge = entry.edge ?? entry.edgeRef ?? entry;\r\n                requireEdgeRef(edge, `fillet spec.edges[${index}]`);\r\n                requireSupportedBlendControls('filletEdges', `fillet.edges[${index}]`, entry);\r\n            });\r\n        }\r\n        const raw = wrap(() => this._native.filletEdgesWithSpec?.(this.shapeId(params.shape), JSON.stringify(params.spec)) ?? '{}', this._native);\r\n        return withShapeHandle(parseJson<Omit<BlendOperationResult, 'shape'>>(raw, 'fillet result'), this._sessionId, 'fillet result');\r\n    }\r\n\r\n    /** Apply a versioned native OCCT chamfer spec and return exact blend lineage. */\r\n    chamferEdgesWithSpec(params: ChamferFeatureParams): BlendOperationResult {\r\n        if (typeof this._native.chamferEdgesWithSpec !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support chamferEdgesWithSpec');\r\n        }\r\n        requireSchemaVersion(params.spec, 'chamfer spec');\r\n        requireSupportedBlendControls('chamferEdges', 'chamfer', params.spec);\r\n        if (params.spec.referenceFace !== undefined) {\r\n            requireFaceRef(params.spec.referenceFace, 'chamfer spec.referenceFace');\r\n        }\r\n        if (params.spec.edges !== undefined) {\r\n            params.spec.edges.forEach((entry, index) => {\r\n                const edge = entry.edge ?? entry.edgeRef ?? entry;\r\n                requireEdgeRef(edge, `chamfer spec.edges[${index}]`);\r\n                requireSupportedBlendControls('chamferEdges', `chamfer.edges[${index}]`, entry);\r\n                if (entry.referenceFace !== undefined) {\r\n                    requireFaceRef(entry.referenceFace, `chamfer spec.edges[${index}].referenceFace`);\r\n                }\r\n            });\r\n        }\r\n        const raw = wrap(() => this._native.chamferEdgesWithSpec?.(this.shapeId(params.shape), JSON.stringify(params.spec)) ?? '{}', this._native);\r\n        return withShapeHandle(parseJson<Omit<BlendOperationResult, 'shape'>>(raw, 'chamfer result'), this._sessionId, 'chamfer result');\r\n    }\r\n\r\n    /**\r\n     * Evaluate an exact feature as a temporary live preview.\r\n     *\r\n     * The source model is not mutated. By default the exact preview result is\r\n     * tessellated with lightweight metadata and then released immediately.\r\n     */\r\n    previewFeature(params: FeaturePreviewParams): FeaturePreviewResult {\r\n        const execution = this.executePreviewFeature(params);\r\n        let shouldDisposePreview = true;\r\n\r\n        try {\r\n            const includeMesh = params.includeMesh !== false;\r\n            const includeWireframe = params.includeWireframe === true;\r\n            const needsTessellation = includeMesh || includeWireframe;\r\n            const meshForPreview = needsTessellation\r\n                ? this.tessellate({\r\n                    shape: execution.shape,\r\n                    includeMetadata: false,\r\n                    ...params.tessellation,\r\n                    ...(includeWireframe ? { includeFeatureEdges: true } : {}),\r\n                })\r\n                : undefined;\r\n\r\n            const result: FeaturePreviewResult = {\r\n                operation: params.operation,\r\n                ...(includeMesh && meshForPreview !== undefined ? { mesh: meshForPreview } : {}),\r\n                ...(includeWireframe ? { wireframe: meshForPreview?.featureEdges ?? [] } : {}),\r\n                ...(params.includeTopology === true ? { topology: execution.topology ?? this.getTopology(execution.shape) } : {}),\r\n                ...(execution.revision !== undefined ? { revision: execution.revision } : {}),\r\n                ...(execution.lineage !== undefined ? { lineage: execution.lineage } : {}),\r\n                ...(execution.blendFaces !== undefined ? { blendFaces: execution.blendFaces } : {}),\r\n                ...(execution.status !== undefined ? { status: execution.status } : {}),\r\n                ...(params.retainPreviewShape === true ? { previewShape: execution.shape } : {}),\r\n            };\r\n\r\n            if (params.retainPreviewShape === true) {\r\n                shouldDisposePreview = false;\r\n            }\r\n            return result;\r\n        } finally {\r\n            if (shouldDisposePreview) {\r\n                try {\r\n                    this.disposeShape({ shape: execution.shape });\r\n                } catch {\r\n                    // Preserve the original preview error if extraction failed.\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    private executePreviewFeature(params: FeaturePreviewParams): {\r\n        shape: ShapeHandle;\r\n        revision?: RevisionInfo;\r\n        topology?: TopologyResult;\r\n        lineage?: BlendOperationResult['lineage'];\r\n        blendFaces?: BlendOperationResult['blendFaces'];\r\n        status?: BlendOperationResult['status'];\r\n    } {\r\n        switch (params.operation) {\r\n            case 'extrudeProfile':\r\n                return { shape: this.extrudeProfileWithSpec(params.params) };\r\n            case 'extrudeCutProfile':\r\n                return { shape: this.extrudeCutProfileWithSpec(params.params) };\r\n            case 'revolveProfile':\r\n                return { shape: this.revolveProfileWithSpec(params.params) };\r\n            case 'revolveCutProfile':\r\n                return { shape: this.revolveCutProfileWithSpec(params.params) };\r\n            case 'sweepProfile':\r\n                return { shape: this.sweepProfileWithSpec(params.params) };\r\n            case 'loft':\r\n                return { shape: this.loftWithSpec(params.params) };\r\n            case 'filletEdges': {\r\n                const result = this.filletEdgesWithSpec(params.params);\r\n                return {\r\n                    shape: result.shape,\r\n                    revision: result.revision,\r\n                    topology: result.topology,\r\n                    lineage: result.lineage,\r\n                    blendFaces: result.blendFaces,\r\n                    status: result.status,\r\n                };\r\n            }\r\n            case 'chamferEdges': {\r\n                const result = this.chamferEdgesWithSpec(params.params);\r\n                return {\r\n                    shape: result.shape,\r\n                    revision: result.revision,\r\n                    topology: result.topology,\r\n                    lineage: result.lineage,\r\n                    blendFaces: result.blendFaces,\r\n                    status: result.status,\r\n                };\r\n            }\r\n            case 'transformShape':\r\n                return { shape: this.transformShape(params.params) };\r\n            case 'booleanUnion':\r\n                return { shape: this.booleanUnion(params.params) };\r\n            case 'booleanSubtract':\r\n                return { shape: this.booleanSubtract(params.params) };\r\n            case 'booleanIntersect':\r\n                return { shape: this.booleanIntersect(params.params) };\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Apply a world-space transform to a resident shape and return a new handle.\r\n     * When both are provided, rotation is applied before translation.\r\n     */\r\n    transformShape(params: TransformParams): ShapeHandle {\r\n        const transformJson = JSON.stringify(normalizeShapeTransform(params.transform));\r\n        return this.makeHandle(wrap(() => this._native.transformShape(this.shapeId(params.shape), transformJson)));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Queries\r\n    // -----------------------------------------------------------------------\r\n\r\n    /** Return additive contract flags supported by the loaded native module. */\r\n    getCapabilities(): KernelCapabilities {\r\n        if (typeof this._native.getCapabilities !== 'function') {\r\n            return fallbackCapabilities;\r\n        }\r\n        return {\r\n            ...fallbackCapabilities,\r\n            ...parseJson<Partial<KernelCapabilities>>(wrap(() => this._native.getCapabilities?.() ?? '{}'), 'capabilities'),\r\n        };\r\n    }\r\n\r\n    /** Return the wrapper and native version contract for this kernel session. */\r\n    getVersionInfo(): KernelVersionInfo {\r\n        if (typeof this._native.getKernelVersionInfo !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support getKernelVersionInfo');\r\n        }\r\n        const raw = parseJson<RawKernelVersionInfo>(wrap(() => this._native.getKernelVersionInfo?.() ?? '{}'), 'version info');\r\n        return {\r\n            libraryVersion: LIBRARY_VERSION,\r\n            apiVersion: API_VERSION,\r\n            kernelVersion: raw.kernelVersion,\r\n            kernelVersionMajor: raw.kernelVersionMajor,\r\n            kernelVersionMinor: raw.kernelVersionMinor,\r\n            kernelVersionMaintenance: raw.kernelVersionMaintenance,\r\n            checkpointSchemaVersion: raw.checkpointSchemaVersion ?? CHECKPOINT_SCHEMA_VERSION,\r\n            operationSchemaVersion: raw.operationSchemaVersion ?? OPERATION_SCHEMA_VERSION,\r\n            sessionId: this._sessionId,\r\n            supportedRuntimes: SUPPORTED_RUNTIMES,\r\n        };\r\n    }\r\n\r\n    /** Return face, edge, vertex counts, bounding box, and validity flag. */\r\n    getTopology(shape: ShapeHandle): TopologyResult {\r\n        const raw = wrap(() => this._native.getTopology(this.shapeId(shape)));\r\n        return parseJson<RawTopology>(raw, 'topology');\r\n    }\r\n\r\n    /** Return immutable revision metadata for a resident shape handle. */\r\n    getRevisionInfo(shape: ShapeHandle): RevisionInfo {\r\n        if (typeof this._native.getRevisionInfo !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support getRevisionInfo');\r\n        }\r\n        return parseJson<RevisionInfo>(wrap(() => this._native.getRevisionInfo?.(this.shapeId(shape)) ?? '{}'), 'revision info');\r\n    }\r\n\r\n    /** Resolve a stable face/edge/vertex hash in the current resident revision. */\r\n    resolveStableEntity(params: ResolveStableEntityParams): StableEntityResolution {\r\n        if (typeof this._native.resolveStableEntity !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support resolveStableEntity');\r\n        }\r\n        const raw = wrap(() => this._native.resolveStableEntity?.(this.shapeId(params.shape), params.stableHash) ?? '{}');\r\n        return parseJson<StableEntityResolution>(raw, 'stable entity resolution');\r\n    }\r\n\r\n    /** Map stable hashes between two resident revisions without JS mesh inference. */\r\n    mapEntitiesAcrossRevisions(params: MapEntitiesAcrossRevisionsParams): EntityRevisionMapResult {\r\n        if (typeof this._native.mapEntitiesAcrossRevisions !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support mapEntitiesAcrossRevisions');\r\n        }\r\n        const raw = wrap(() => this._native.mapEntitiesAcrossRevisions?.(\r\n            params.fromRevisionId,\r\n            params.toRevisionId,\r\n            JSON.stringify(params.stableHashes),\r\n        ) ?? '{}');\r\n        return parseJson<EntityRevisionMapResult>(raw, 'entity revision mapping');\r\n    }\r\n\r\n    /** Evaluate an exact edge point/tangent without tessellation. */\r\n    evaluateEdge(params: EdgeEvaluationParams): EdgeEvaluationResult {\r\n        if (typeof this._native.evaluateEdge !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support evaluateEdge');\r\n        }\r\n        requireEdgeRef(params.edge, 'edge');\r\n        requireFinite(params.t, 't');\r\n        const raw = wrap(() => this._native.evaluateEdge?.(this.shapeId(params.shape), JSON.stringify(params.edge), params.t) ?? '{}');\r\n        return parseJson<EdgeEvaluationResult>(raw, 'edge evaluation');\r\n    }\r\n\r\n    /** Return exact OCCT analysis properties for a resident shape. */\r\n    analyzeShape(params: ShapeAnalysisParams): ShapeAnalysisResult {\r\n        if (typeof this._native.analyzeShape !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support analyzeShape');\r\n        }\r\n        const raw = wrap(() => this._native.analyzeShape?.(this.shapeId(params.shape)) ?? '{}');\r\n        return parseJson<ShapeAnalysisResult>(raw, 'shape analysis');\r\n    }\r\n\r\n    /** Classify a world-space point against the exact resident solid model. */\r\n    classifyPointContainment(params: PointContainmentParams): PointContainmentResult {\r\n        if (typeof this._native.classifyPointContainment !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support classifyPointContainment');\r\n        }\r\n        requirePoint3(params.point, 'point');\r\n        const tolerance = params.tolerance ?? 1e-7;\r\n        requirePositive(tolerance, 'tolerance');\r\n        const raw = wrap(() => this._native.classifyPointContainment?.(\r\n            this.shapeId(params.shape),\r\n            JSON.stringify(params.point),\r\n            tolerance,\r\n        ) ?? '{}');\r\n        return parseJson<PointContainmentResult>(raw, 'point containment');\r\n    }\r\n\r\n    /** Return the exact section edges and vertices between two resident shapes. */\r\n    intersectShapes(params: ShapeIntersectionParams): ShapeIntersectionResult {\r\n        if (typeof this._native.intersectShapes !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support intersectShapes');\r\n        }\r\n        const raw = parseJson<RawShapeIntersectionResult>(wrap(() => this._native.intersectShapes?.(\r\n            this.shapeId(params.shapeA, 'shapeA'),\r\n            this.shapeId(params.shapeB, 'shapeB'),\r\n        ) ?? '{}'), 'shape intersection');\r\n        const result: ShapeIntersectionResult = {\r\n            hasIntersection: raw.hasIntersection,\r\n            edgeCount: raw.edgeCount,\r\n            vertexCount: raw.vertexCount,\r\n        };\r\n        if (raw.sectionShapeId !== undefined) {\r\n            return { ...result, sectionShape: makeHandle(raw.sectionShapeId, this._sessionId) };\r\n        }\r\n        return result;\r\n    }\r\n\r\n    /** Return the closest point on the exact resident shape to a world-space query point. */\r\n    findClosestPointOnShape(params: ClosestPointOnShapeParams): ClosestPointOnShapeResult {\r\n        if (typeof this._native.findClosestPointOnShape !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support findClosestPointOnShape');\r\n        }\r\n        requirePoint3(params.point, 'point');\r\n        const tolerance = params.tolerance ?? 1e-7;\r\n        requirePositive(tolerance, 'tolerance');\r\n        const raw = wrap(() => this._native.findClosestPointOnShape?.(\r\n            this.shapeId(params.shape),\r\n            JSON.stringify(params.point),\r\n            tolerance,\r\n        ) ?? '{}');\r\n        return parseJson<ClosestPointOnShapeResult>(raw, 'closest point query');\r\n    }\r\n\r\n    /** Return the exact minimum distance / clearance between two resident shapes. */\r\n    measureShapeDistance(params: ShapeDistanceParams): ShapeDistanceResult {\r\n        if (typeof this._native.measureShapeDistance !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support measureShapeDistance');\r\n        }\r\n        const tolerance = params.tolerance ?? 1e-7;\r\n        requirePositive(tolerance, 'tolerance');\r\n        const raw = wrap(() => this._native.measureShapeDistance?.(\r\n            this.shapeId(params.shapeA, 'shapeA'),\r\n            this.shapeId(params.shapeB, 'shapeB'),\r\n            tolerance,\r\n        ) ?? '{}');\r\n        return parseJson<ShapeDistanceResult>(raw, 'shape distance query');\r\n    }\r\n\r\n    /** Sample an exact edge curve without tessellation. */\r\n    sampleEdge(params: SampleEdgeParams): EdgeSampleResult {\r\n        if (typeof this._native.sampleEdge !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support sampleEdge');\r\n        }\r\n        requireEdgeRef(params.edge, 'edge');\r\n        if (params.count !== undefined) requirePositiveInteger(params.count, 'count');\r\n        const options = {\r\n            count: params.count,\r\n            start: params.start,\r\n            end: params.end,\r\n            normalized: params.normalized,\r\n            includeTangents: params.includeTangents,\r\n        };\r\n        const raw = wrap(() => this._native.sampleEdge?.(this.shapeId(params.shape), JSON.stringify(params.edge), JSON.stringify(options)) ?? '{}');\r\n        return parseJson<EdgeSampleResult>(raw, 'edge samples');\r\n    }\r\n\r\n    /** Return exact curve metadata for an edge. */\r\n    getEdgeCurve(params: { readonly shape: ShapeHandle; readonly edge: EdgeRef }): EdgeCurveResult {\r\n        if (typeof this._native.getEdgeCurve !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support getEdgeCurve');\r\n        }\r\n        requireEdgeRef(params.edge, 'edge');\r\n        const raw = wrap(() => this._native.getEdgeCurve?.(this.shapeId(params.shape), JSON.stringify(params.edge)) ?? '{}');\r\n        return parseJson<EdgeCurveResult>(raw, 'edge curve');\r\n    }\r\n\r\n    /** Evaluate an exact face point/normal without tessellation. */\r\n    evaluateFace(params: FaceEvaluationParams): FaceEvaluationResult {\r\n        if (typeof this._native.evaluateFace !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support evaluateFace');\r\n        }\r\n        requireFaceRef(params.face, 'face');\r\n        requireFinite(params.u, 'u');\r\n        requireFinite(params.v, 'v');\r\n        const raw = wrap(() => this._native.evaluateFace?.(this.shapeId(params.shape), JSON.stringify(params.face), params.u, params.v) ?? '{}');\r\n        return parseJson<FaceEvaluationResult>(raw, 'face evaluation');\r\n    }\r\n\r\n    /** Return the exact trimmed wires of a planar face in both local 2-D and world 3-D form. */\r\n    getPlanarFaceWires(params: PlanarFaceWiresParams): PlanarFaceWiresResult {\r\n        if (typeof this._native.getPlanarFaceWires !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support getPlanarFaceWires');\r\n        }\r\n        requireFaceRef(params.face, 'face');\r\n        const raw = wrap(() => this._native.getPlanarFaceWires?.(this.shapeId(params.shape), JSON.stringify(params.face)) ?? '{}');\r\n        return parseJson<PlanarFaceWiresResult>(raw, 'planar face wires');\r\n    }\r\n\r\n    /** Return the versioned operation schema advertised by the native kernel. */\r\n    getOperationSchema(): OperationSchema {\r\n        if (typeof this._native.getOperationSchema !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support getOperationSchema');\r\n        }\r\n        return parseJson<OperationSchema>(wrap(() => this._native.getOperationSchema?.() ?? '{}'), 'operation schema');\r\n    }\r\n\r\n    /** Return true when the shape is geometrically and topologically valid. */\r\n    checkValidity(shape: ShapeHandle): boolean {\r\n        return wrap(() => this._native.checkValidity(this.shapeId(shape)));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Tessellation\r\n    // -----------------------------------------------------------------------\r\n\r\n    /**\r\n     * Triangulate a shape for WebGL / Three.js rendering.\r\n     *\r\n     * @param params.linearDeflection  \u2013 chord-height tolerance (default 0.1).\r\n     * @param params.angularDeflection \u2013 angular tolerance in radians (default 0.5).\r\n     */\r\n    tessellate(params: TessellateParams): TessellationResult {\r\n        const linearDeflection = params.linearDeflection ?? 0.1;\r\n        const angularDeflection = params.angularDeflection ?? 0.5;\r\n        requirePositive(linearDeflection, 'linearDeflection');\r\n        requirePositive(angularDeflection, 'angularDeflection');\r\n\r\n        const options: TessellationNativeOptions = {\r\n            ...(params.includeMetadata !== undefined ? { includeMetadata: params.includeMetadata } : {}),\r\n            ...(params.includeTriangleNormals !== undefined ? { includeTriangleNormals: params.includeTriangleNormals } : {}),\r\n            ...(params.includeTriangleTopoFaceIds !== undefined ? { includeTriangleTopoFaceIds: params.includeTriangleTopoFaceIds } : {}),\r\n            ...(params.includeTriangleFaceGroups !== undefined ? { includeTriangleFaceGroups: params.includeTriangleFaceGroups } : {}),\r\n            ...(params.includeTriangleStableHashes !== undefined ? { includeTriangleStableHashes: params.includeTriangleStableHashes } : {}),\r\n            ...(params.includeFeatureEdges !== undefined ? { includeFeatureEdges: params.includeFeatureEdges } : {}),\r\n            ...(params.includeRawEdgeSegments !== undefined ? { includeRawEdgeSegments: params.includeRawEdgeSegments } : {}),\r\n            ...(params.faces !== undefined ? { faces: params.faces } : {}),\r\n        };\r\n        params.faces?.forEach((face, index) => requireFaceRef(face, `faces[${index}]`));\r\n        const hasOptions = Object.keys(options).length > 0;\r\n        if (hasOptions && typeof this._native.tessellateWithOptions !== 'function') {\r\n            throw new KernelError('OPERATION_FAILED', 'This native kernel does not support tessellation options');\r\n        }\r\n        const raw = wrap(() => hasOptions && typeof this._native.tessellateWithOptions === 'function'\r\n            ? this._native.tessellateWithOptions(this.shapeId(params.shape), linearDeflection, angularDeflection, JSON.stringify(options))\r\n            : this._native.tessellate(this.shapeId(params.shape), linearDeflection, angularDeflection));\r\n        const data = parseJson<RawTessellation>(raw, 'tessellation');\r\n\r\n        return {\r\n            positions: new Float32Array(data.positions),\r\n            normals:   new Float32Array(data.normals),\r\n            indices:   new Uint32Array(data.indices),\r\n            ...(data.triangleNormals !== undefined\r\n                ? { triangleNormals: new Float32Array(data.triangleNormals) }\r\n                : {}),\r\n            ...(data.triangleTopoFaceIds !== undefined\r\n                ? { triangleTopoFaceIds: new Uint32Array(data.triangleTopoFaceIds) }\r\n                : {}),\r\n            ...(data.triangleFaceGroups !== undefined\r\n                ? { triangleFaceGroups: new Uint32Array(data.triangleFaceGroups) }\r\n                : {}),\r\n            ...(data.triangleStableHashes !== undefined\r\n                ? { triangleStableHashes: data.triangleStableHashes }\r\n                : {}),\r\n            ...(data.featureEdges !== undefined\r\n                ? { featureEdges: data.featureEdges }\r\n                : {}),\r\n            ...(data.rawEdgeSegments !== undefined\r\n                ? { rawEdgeSegments: new Float32Array(data.rawEdgeSegments) }\r\n                : {}),\r\n        };\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Import / export\r\n    // -----------------------------------------------------------------------\r\n\r\n    /**\r\n     * Import a STEP file from a UTF-8 string. Returns a handle to the imported shape.\r\n     * Throws {@link KernelError} with code `IMPORT_FAILED` on parse errors.\r\n     */\r\n    importStep(params: ImportStepParams): ShapeHandle {\r\n        if (typeof params.content !== 'string') {\r\n            throw new KernelError('INVALID_PARAMS', 'STEP content must be a string');\r\n        }\r\n\r\n        const result = this.importStepDetailed(params);\r\n        if (!result.shape) {\r\n            throw new KernelError('IMPORT_FAILED', formatImportFailure(result));\r\n        }\r\n        return result.shape;\r\n    }\r\n\r\n    /**\r\n     * Import a STEP file and return reader, transfer, and validity diagnostics.\r\n     *\r\n     * Unlike {@link importStep}, this method does not throw on STEP parse or\r\n     * transfer failures; those are returned in the structured result.\r\n     */\r\n    importStepDetailed(params: ImportStepParams): ImportStepDetailedResult {\r\n        if (typeof params.content !== 'string') {\r\n            throw new KernelError('INVALID_PARAMS', 'STEP content must be a string');\r\n        }\r\n\r\n        const options = normalizeImportOptions(params.options);\r\n        const raw = wrap(() => this._native.importStepDetailed(\r\n            params.content,\r\n            options.heal,\r\n            options.sew,\r\n            options.fixSameParameter,\r\n            options.fixSolid,\r\n            options.sewingTolerance,\r\n        ));\r\n\r\n        return toImportStepDetailedResult(parseJson<RawStepImportDetailedResult>(raw, 'STEP import'), this._sessionId);\r\n    }\r\n\r\n    /**\r\n     * Import a STEP file and return a fully fused result package.\r\n     */\r\n    importStepPackage(params: ImportStepPackageParams): ImportStepPackageResult {\r\n        if (typeof params.content !== 'string') {\r\n            throw new KernelError('INVALID_PARAMS', 'STEP content must be a string');\r\n        }\r\n\r\n        if (typeof this._native.importStepPackage !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support importStepPackage');\r\n        }\r\n\r\n        const options = normalizeImportOptions(params.options);\r\n        const linearDeflection = params.options?.linearDeflection ?? 0.1;\r\n        const angularDeflection = params.options?.angularDeflection ?? 0.5;\r\n\r\n        const raw = wrap(() => this._native.importStepPackage!(\r\n            params.content,\r\n            options.heal,\r\n            options.sew,\r\n            options.fixSameParameter,\r\n            options.fixSolid,\r\n            options.sewingTolerance,\r\n            linearDeflection,\r\n            angularDeflection,\r\n        ));\r\n\r\n        return toImportStepPackageResult(parseJson<RawStepImportPackageResult>(raw, 'STEP package import'), this._sessionId);\r\n    }\r\n\r\n    /**\r\n     * Export a shape to STEP format. Returns the STEP file content as a UTF-8 string.\r\n     * Throws {@link KernelError} with code `EXPORT_FAILED` on failure.\r\n     */\r\n    exportStep(params: ExportStepParams): string {\r\n        return wrap(() => this._native.exportStep(this.shapeId(params.shape)));\r\n    }\r\n\r\n    /** Create a JSON checkpoint containing CBREP plus revision/history metadata. */\r\n    createCheckpoint(params: CreateCheckpointParams): RevisionCheckpoint {\r\n        if (typeof this._native.createCheckpoint !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support createCheckpoint');\r\n        }\r\n        return parseJson<RevisionCheckpoint>(wrap(() => this._native.createCheckpoint?.(this.shapeId(params.shape)) ?? '{}'), 'checkpoint');\r\n    }\r\n\r\n    /** Hydrate a checkpoint created by {@link createCheckpoint}. */\r\n    hydrateCheckpoint(params: HydrateCheckpointParams): ShapeHandle {\r\n        if (typeof this._native.hydrateCheckpoint !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support hydrateCheckpoint');\r\n        }\r\n        const checkpointJson = typeof params.checkpoint === 'string'\r\n            ? params.checkpoint\r\n            : JSON.stringify(params.checkpoint);\r\n        return this.makeHandle(wrap(() => this._native.hydrateCheckpoint?.(checkpointJson) ?? 0));\r\n    }\r\n\r\n    // -----------------------------------------------------------------------\r\n    // Memory management\r\n    // -----------------------------------------------------------------------\r\n\r\n    /**\r\n     * Release the native memory held by the given shape handle.\r\n     *\r\n     * After calling this method the handle must not be used again.\r\n     */\r\n    disposeShape(params: DisposeParams): void {\r\n        wrap(() => this._native.disposeShape(this.shapeId(params.shape)));\r\n    }\r\n\r\n    /** Increment the native reference count for a resident immutable revision. */\r\n    retainRevision(params: RetainRevisionParams): void {\r\n        if (typeof this._native.retainRevision !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support retainRevision');\r\n        }\r\n        wrap(() => this._native.retainRevision?.(this.shapeId(params.shape)));\r\n    }\r\n\r\n    /** Decrement the native reference count and return true when the revision was evicted. */\r\n    releaseRevision(params: ReleaseRevisionParams): boolean {\r\n        if (typeof this._native.releaseRevision !== 'function') {\r\n            throw new KernelError('UNKNOWN', 'Native module does not support releaseRevision');\r\n        }\r\n        return wrap(() => this._native.releaseRevision?.(this.shapeId(params.shape)) ?? false);\r\n    }\r\n}\r\n", "import { KernelError } from './errors';\r\nimport { unwrapFactory, type WasmModuleFactory } from './default-module';\r\nimport { OcctKernel, type WasmModule } from './kernel';\r\nimport type { CreateKernelOptions, KernelVariant } from './index';\r\n\r\nexport * from './api';\r\n\r\ndeclare global {\r\n    var createOcctKernelModule: WasmModuleFactory | undefined;\r\n}\r\n\r\nlet browserFactoryPromise: Promise<WasmModuleFactory> | undefined;\r\nlet browserFactoryVariant: KernelVariant | undefined;\r\n\r\nfunction normalizeCreateKernelInput(input?: WasmModule | CreateKernelOptions): CreateKernelOptions {\r\n    if (!input) {\r\n        return {};\r\n    }\r\n    if (typeof input === 'object' && ('variant' in input || 'wasmModule' in input)) {\r\n        return input as CreateKernelOptions;\r\n    }\r\n    return { wasmModule: input as WasmModule };\r\n}\r\n\r\nfunction normalizeKernelVariant(variant?: KernelVariant): KernelVariant {\r\n    return variant === 'mt' ? 'mt' : 'st';\r\n}\r\n\r\nfunction kernelBasename(variant: KernelVariant): string {\r\n    return variant === 'mt' ? 'occt-kernel.mt' : 'occt-kernel.st';\r\n}\r\n\r\nfunction getGlobalFactory(): WasmModuleFactory | undefined {\r\n    return unwrapFactory((globalThis as { createOcctKernelModule?: unknown }).createOcctKernelModule);\r\n}\r\n\r\nasync function loadBrowserFactory(variant: KernelVariant): Promise<WasmModuleFactory> {\r\n    const existingFactory = getGlobalFactory();\r\n    if (existingFactory && browserFactoryVariant === variant) {\r\n        return existingFactory;\r\n    }\r\n\r\n    if (browserFactoryPromise && browserFactoryVariant === variant) {\r\n        return browserFactoryPromise;\r\n    }\r\n\r\n    browserFactoryVariant = variant;\r\n    browserFactoryPromise = (async () => {\r\n        const scriptUrl = new URL(`./${kernelBasename(variant)}.js`, import.meta.url).href;\r\n\r\n        if (typeof importScripts === 'function') {\r\n            importScripts(scriptUrl);\r\n            const workerFactory = getGlobalFactory();\r\n            if (!workerFactory) {\r\n                throw new KernelError('NOT_INITIALIZED', 'Loaded occt-kernel.js in a worker, but no factory became available');\r\n            }\r\n            return workerFactory;\r\n        }\r\n\r\n        if (typeof document === 'undefined') {\r\n            throw new KernelError('NOT_INITIALIZED', 'No browser loader is available in this runtime; pass a pre-loaded wasmModule instead');\r\n        }\r\n\r\n        await new Promise<void>((resolve, reject) => {\r\n            const existingScript = Array.from(document.getElementsByTagName('script')).find((script) => script.src === scriptUrl);\r\n\r\n            const handleLoad = () => resolve();\r\n            const handleError = () => reject(new KernelError('NOT_INITIALIZED', `Failed to load ${scriptUrl}`));\r\n\r\n            if (existingScript) {\r\n                if (getGlobalFactory()) {\r\n                    resolve();\r\n                    return;\r\n                }\r\n\r\n                existingScript.addEventListener('load', handleLoad, { once: true });\r\n                existingScript.addEventListener('error', handleError, { once: true });\r\n                return;\r\n            }\r\n\r\n            const script = document.createElement('script');\r\n            script.src = scriptUrl;\r\n            script.async = true;\r\n            script.addEventListener('load', handleLoad, { once: true });\r\n            script.addEventListener('error', handleError, { once: true });\r\n            (document.head ?? document.body ?? document.documentElement).appendChild(script);\r\n        });\r\n\r\n        const loadedFactory = getGlobalFactory();\r\n        if (!loadedFactory) {\r\n            throw new KernelError('NOT_INITIALIZED', 'Loaded occt-kernel.js, but no WASM module factory was registered on globalThis');\r\n        }\r\n\r\n        return loadedFactory;\r\n    })();\r\n\r\n    try {\r\n        return await browserFactoryPromise;\r\n    } catch (error) {\r\n        browserFactoryPromise = undefined;\r\n        throw error;\r\n    }\r\n}\r\n\r\nexport async function createKernel(wasmModule?: WasmModule): Promise<OcctKernel> {\r\n    const options = normalizeCreateKernelInput(wasmModule);\r\n    if (options.wasmModule) {\r\n        return new OcctKernel(options.wasmModule);\r\n    }\r\n\r\n    const mod = await (await loadBrowserFactory(normalizeKernelVariant(options.variant)))();\r\n    return new OcctKernel(mod);\r\n}"],
  "mappings": ";AAgBO,IAAM,cAAN,cAA0B,MAAM;AAAA,EAInC,YAAY,MAAuB,QAAgB;AAC/C,UAAM,IAAI,IAAI,KAAK,MAAM,EAAE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