import { R as Result } from './types-Cgumy1N4.js';
import { D as DicomJsonElement, T as TagModification } from './dcmodify-B-_uUIKB.js';

/**
 * Branded types for domain primitives.
 *
 * Branded types use TypeScript's structural type system to prevent accidental
 * mixing of semantically different values that share the same underlying type.
 * A `DicomTag` cannot be used where an `AETitle` is expected, even though both
 * are strings at runtime.
 *
 * @module brands
 */

declare const __brand: unique symbol;
/** Intersects a base type with a phantom brand property for nominal typing. */
type Brand<T, TBrand extends string> = T & {
    readonly [__brand]: TBrand;
};
/**
 * A validated DICOM tag string, e.g. `"(0010,0010)"`.
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createDicomTag} to obtain a branded value from a raw string.
 */
type DicomTag = Brand<string, 'DicomTag'>;
/**
 * A validated AE Title (1-16 chars: uppercase letters, digits, spaces, hyphens).
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createAETitle} to obtain a branded value from a raw string.
 */
type AETitle = Brand<string, 'AETitle'>;
/**
 * A validated DICOM tag path, e.g. `"(0040,A730)[0].(0010,0010)"`.
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createDicomTagPath} to obtain a branded value from a raw string.
 */
type DicomTagPath = Brand<string, 'DicomTagPath'>;
/**
 * A validated SOP Class UID (dotted numeric OID, 1-64 chars).
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createSOPClassUID} to obtain a branded value from a raw string.
 */
type SOPClassUID = Brand<string, 'SOPClassUID'>;
/**
 * A validated Transfer Syntax UID (dotted numeric OID, 1-64 chars).
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createTransferSyntaxUID} to obtain a branded value from a raw string.
 */
type TransferSyntaxUID = Brand<string, 'TransferSyntaxUID'>;
/**
 * A validated filesystem path to a DICOM file.
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createDicomFilePath} to obtain a branded value from a raw string.
 */
type DicomFilePath = Brand<string, 'DicomFilePath'>;
/**
 * A validated network port number (1-65535).
 *
 * @remarks
 * Branded types enforce type safety when passing values between functions.
 * They are not required for direct API calls (which validate internally via Zod).
 * Use {@link createPort} to obtain a branded value from a raw number.
 */
type Port = Brand<number, 'Port'>;
/**
 * Creates a validated DicomTag from a raw string.
 *
 * @param input - A string expected to be in format `(XXXX,XXXX)` where X is a hex digit
 * @returns A Result containing the branded DicomTag or an error
 */
declare function createDicomTag(input: string): Result<DicomTag>;
/**
 * Creates a validated AETitle from a raw string.
 *
 * @param input - A string expected to be 1-16 chars of letters, digits, spaces, or hyphens
 * @returns A Result containing the branded AETitle or an error
 */
declare function createAETitle(input: string): Result<AETitle>;
/**
 * Creates a validated DicomTagPath from a raw string.
 *
 * @param input - A dot-separated path of DICOM tags with optional array indices
 * @returns A Result containing the branded DicomTagPath or an error
 */
declare function createDicomTagPath(input: string): Result<DicomTagPath>;
/**
 * Creates a validated SOPClassUID from a raw string.
 *
 * @param input - A dotted numeric OID string, 1-64 characters
 * @returns A Result containing the branded SOPClassUID or an error
 */
declare function createSOPClassUID(input: string): Result<SOPClassUID>;
/**
 * Creates a validated TransferSyntaxUID from a raw string.
 *
 * @param input - A dotted numeric OID string, 1-64 characters
 * @returns A Result containing the branded TransferSyntaxUID or an error
 */
declare function createTransferSyntaxUID(input: string): Result<TransferSyntaxUID>;
/**
 * Creates a branded DicomFilePath from a raw string.
 * Validates that the path is non-empty and does not contain path traversal sequences.
 *
 * @param input - A filesystem path string
 * @returns A Result containing the branded DicomFilePath or an error
 */
declare function createDicomFilePath(input: string): Result<DicomFilePath>;
/**
 * Creates a validated Port from a raw number.
 *
 * @param input - A number expected to be an integer between 1 and 65535
 * @returns A Result containing the branded Port or an error
 */
declare function createPort(input: number): Result<Port>;
/**
 * Shorthand for creating a DicomTagPath, throwing on invalid input.
 *
 * Use this when you know the tag path is valid (e.g. hardcoded constants).
 * For user-supplied input, use {@link createDicomTagPath} which returns a Result.
 *
 * @param input - A DICOM tag path string, e.g. `'(0010,0010)'`
 * @returns The branded DicomTagPath
 * @throws Error if the input is not a valid DICOM tag path
 */
declare function tag(input: string): DicomTagPath;

/**
 * Immutable DICOM dataset wrapper with type-safe accessors.
 *
 * Wraps DICOM JSON Model data (PS3.18 F.2) from dcm2json/dcm2xml with
 * convenient read-only accessors. No setters — mutations go through ChangeSet.
 *
 * @module dicom/DicomDataset
 */

/**
 * Immutable wrapper around DICOM JSON Model data.
 *
 * Provides type-safe read-only accessors for DICOM tag values.
 * Construct via the static {@link DicomDataset.fromJson} factory.
 *
 * @example
 * ```ts
 * const result = DicomDataset.fromJson(jsonData);
 * if (result.ok) {
 *     const ds = result.value;
 *     console.log(ds.patientName);
 *     console.log(ds.modality);
 * }
 * ```
 */
declare class DicomDataset {
    private readonly data;
    private constructor();
    /**
     * Creates a DicomDataset from a DICOM JSON Model object.
     *
     * Performs structural validation only — verifies the input is a non-null object.
     *
     * @param json - A DICOM JSON Model object (typically from dcm2json)
     * @returns A Result containing the DicomDataset or an error
     */
    static fromJson(json: unknown): Result<DicomDataset>;
    /**
     * Gets the full DICOM JSON element for a tag.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns Result containing the element or an error if not found
     */
    getElement(tag: DicomTag | string): Result<DicomJsonElement>;
    /**
     * Gets the Value array for a tag.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns Result containing the readonly Value array or an error
     */
    getValue(tag: DicomTag | string): Result<ReadonlyArray<unknown>>;
    /**
     * Gets the first element of the Value array for a tag.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns Result containing the first value or an error
     */
    getFirstValue(tag: DicomTag | string): Result<unknown>;
    /**
     * Gets a tag value as a string with optional fallback.
     *
     * Returns the fallback (default empty string) if the tag is missing or has no value.
     * Handles PN (PersonName) values by extracting the Alphabetic component.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @param fallback - Value to return if tag is missing (default: `''`)
     * @returns The string value or the fallback
     */
    getString(tag: DicomTag | string, fallback?: string): string;
    /**
     * Gets a tag value as a validated number.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns Result containing the number or an error
     */
    getNumber(tag: DicomTag | string): Result<number>;
    /**
     * Gets all values of a tag as strings.
     *
     * Useful for multi-valued tags like CS (Code String).
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns Result containing the readonly string array or an error
     */
    getStrings(tag: DicomTag | string): Result<ReadonlyArray<string>>;
    /**
     * Checks whether a tag exists in the dataset.
     *
     * @param tag - A DicomTag `(0010,0010)` or hex string `00100010`
     * @returns `true` if the tag is present
     */
    hasTag(tag: DicomTag | string): boolean;
    /**
     * Gets an element by traversing a dotted tag path through sequences.
     *
     * @param path - A branded DicomTagPath, e.g. `(0040,A730)[0].(0040,A160)`
     * @returns Result containing the element at the path or an error
     */
    getElementAtPath(path: DicomTagPath): Result<DicomJsonElement>;
    /**
     * Finds all values matching a path with wildcard `[*]` indices.
     *
     * Traverses all items in wildcard sequence positions using an iterative BFS queue.
     * The traversal is bounded to {@link MAX_TRAVERSAL_DEPTH} * 100 iterations (5 000).
     * For extremely large datasets this may truncate results silently; callers
     * needing completeness guarantees should verify dataset size independently.
     *
     * @param path - A branded DicomTagPath, e.g. `(0040,A730)[*].(0040,A160)`
     * @returns A readonly array of all matching values (may be empty)
     */
    findValues(path: DicomTagPath): ReadonlyArray<unknown>;
    /** Accession Number (0008,0050). */
    get accession(): string;
    /** Patient's Name (0010,0010). */
    get patientName(): string;
    /** Patient ID (0010,0020). */
    get patientID(): string;
    /** Study Date (0008,0020). */
    get studyDate(): string;
    /** Modality (0008,0060). */
    get modality(): string;
    /** SOP Class UID (0008,0016) as a branded SOPClassUID, or undefined if missing/invalid. */
    get sopClassUID(): SOPClassUID | undefined;
    /** Study Instance UID (0020,000D). */
    get studyInstanceUID(): string;
    /** Series Instance UID (0020,000E). */
    get seriesInstanceUID(): string;
    /** SOP Instance UID (0008,0018). */
    get sopInstanceUID(): string;
    /** Transfer Syntax UID (0002,0010). */
    get transferSyntaxUID(): string;
}

/**
 * Immutable mutation tracking for DICOM datasets.
 *
 * Every mutation method returns a new ChangeSet instance, preserving immutability.
 * Bridge methods produce dcmodify-compatible arguments for applying changes to files.
 *
 * @module dicom/ChangeSet
 */

/**
 * Immutable mutation tracker for DICOM datasets.
 *
 * Every mutation method returns a **new** ChangeSet — the original is never modified.
 * Use {@link ChangeSet.toModifications} and {@link ChangeSet.toErasureArgs} to bridge
 * to the dcmodify tool wrapper.
 *
 * @example
 * ```ts
 * const cs = ChangeSet.empty()
 *     .setTag('(0010,0010)' as DicomTagPath, 'Anonymous')
 *     .eraseTag('(0010,0020)' as DicomTagPath)
 *     .erasePrivateTags();
 * ```
 */
declare class ChangeSet {
    private readonly mods;
    private readonly erased;
    private constructor();
    /** Creates an empty ChangeSet with no modifications or erasures. */
    static empty(): ChangeSet;
    /**
     * Sets a tag value, returning a new ChangeSet.
     *
     * Control characters (except LF/CR) are stripped from the value.
     * If the tag was previously erased, it is removed from the erasure set.
     *
     * @param path - The DICOM tag path to set (e.g. `'(0010,0010)'`)
     * @param value - The new value for the tag
     * @returns A new ChangeSet with the modification applied
     * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
     */
    setTag(path: string, value: string): ChangeSet;
    /**
     * Marks a tag for erasure, returning a new ChangeSet.
     *
     * If the tag was previously set, the modification is removed.
     *
     * @param path - The DICOM tag path to erase (e.g. `'(0010,0010)'`)
     * @returns A new ChangeSet with the erasure applied
     * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
     */
    eraseTag(path: string): ChangeSet;
    /**
     * Marks all private tags for erasure, returning a new ChangeSet.
     *
     * @returns A new ChangeSet with the erase-private flag set
     * @throws Error if operation count would exceed MAX_CHANGESET_OPERATIONS
     */
    erasePrivateTags(): ChangeSet;
    /** Sets Patient's Name (0010,0010). */
    setPatientName(value: string): ChangeSet;
    /** Sets Patient ID (0010,0020). */
    setPatientID(value: string): ChangeSet;
    /** Sets Study Date (0008,0020). */
    setStudyDate(value: string): ChangeSet;
    /** Sets Modality (0008,0060). */
    setModality(value: string): ChangeSet;
    /** Sets Accession Number (0008,0050). */
    setAccessionNumber(value: string): ChangeSet;
    /** Sets Study Description (0008,1030). */
    setStudyDescription(value: string): ChangeSet;
    /** Sets Series Description (0008,103E). */
    setSeriesDescription(value: string): ChangeSet;
    /** Sets Institution Name (0008,0080). */
    setInstitutionName(value: string): ChangeSet;
    /**
     * Sets multiple tags at once, returning a new ChangeSet.
     *
     * @param entries - A record of tag path → value pairs
     * @returns A new ChangeSet with all modifications applied
     */
    setBatch(entries: Readonly<Record<string, string>>): ChangeSet;
    /** All pending tag modifications as a readonly map of path → value. */
    get modifications(): ReadonlyMap<string, string>;
    /** All pending tag erasures as a readonly set of paths. */
    get erasures(): ReadonlySet<string>;
    /** Total number of operations (modifications + erasures) in this ChangeSet. */
    get operationCount(): number;
    /** Whether the ChangeSet has no modifications and no erasures. */
    get isEmpty(): boolean;
    /** Whether the erase-all-private-tags flag is set. */
    get erasePrivate(): boolean;
    /**
     * Merges another ChangeSet into this one, returning a new ChangeSet.
     *
     * The `other` ChangeSet wins on conflicts: if the same tag is modified in both,
     * `other`'s value is used. Erasures from both sets are unioned. An erasure in
     * `other` removes a modification from `base`.
     *
     * @param other - The ChangeSet to merge in
     * @returns A new ChangeSet with merged modifications and erasures
     */
    merge(other: ChangeSet): ChangeSet;
    /**
     * Converts modifications to dcmodify-compatible TagModification array.
     *
     * @returns A readonly array of TagModification objects
     */
    toModifications(): ReadonlyArray<TagModification>;
    /**
     * Converts erasures to dcmodify-compatible argument strings.
     *
     * The erase-private sentinel is excluded — use {@link erasePrivate} to check
     * whether `-ep` should be passed.
     *
     * @returns A readonly array of tag path strings for `-e` arguments
     */
    toErasureArgs(): ReadonlyArray<string>;
}

/**
 * File operation helpers for DicomInstance.
 *
 * Extracted to keep DicomInstance methods under line-count limits.
 *
 * @module dicom/_fileHelpers
 */

/** Options for file I/O operations. */
interface FileIOOptions {
    /** Timeout in milliseconds. Defaults to DEFAULT_TIMEOUT_MS. */
    readonly timeoutMs?: number | undefined;
    /** AbortSignal for external cancellation. */
    readonly signal?: AbortSignal | undefined;
}

/**
 * Unified DICOM object composing DicomDataset + ChangeSet + file I/O.
 *
 * Every setter returns a new DicomInstance — the original is never modified.
 * Designed for ergonomic DICOM workflows that combine reading, modifying,
 * and writing DICOM data in a single fluent API.
 *
 * @module dicom/DicomInstance
 */

/**
 * Unified DICOM object composing dataset, change tracking, file path, and metadata.
 *
 * Every setter returns a new immutable instance — the original is never modified.
 * Use the static factories {@link DicomInstance.open} or {@link DicomInstance.fromDataset}
 * to create instances.
 *
 * @example
 * ```ts
 * const result = await DicomInstance.open('/path/to/file.dcm');
 * if (!result.ok) { console.error(result.error.message); return; }
 * const modified = result.value
 *     .setPatientName('DOE^JOHN')
 *     .setPatientID('PAT001')
 *     .erasePrivateTags();
 * await modified.writeAs('/path/to/output.dcm');
 * ```
 */
declare class DicomInstance {
    private readonly dicomDataset;
    private readonly changeSet;
    private readonly filepath;
    private readonly meta;
    private constructor();
    /**
     * Opens a DICOM file and creates a DicomInstance.
     *
     * @param path - Filesystem path to the DICOM file
     * @param options - Timeout and abort options
     * @returns A Result containing the DicomInstance or an error
     */
    static open(path: string, options?: FileIOOptions): Promise<Result<DicomInstance>>;
    /**
     * Creates a DicomInstance from an existing DicomDataset.
     *
     * @param dataset - The DicomDataset to wrap
     * @param filePath - Optional file path (e.g. if the dataset came from a file)
     * @returns A Result containing the DicomInstance
     */
    static fromDataset(dataset: DicomDataset, filePath?: string): Result<DicomInstance>;
    /** The underlying immutable DICOM dataset. */
    get dataset(): DicomDataset;
    /** The pending change set. */
    get changes(): ChangeSet;
    /** Whether there are unsaved changes. */
    get hasUnsavedChanges(): boolean;
    /** The file path, or undefined if this instance has no associated file. */
    get filePath(): string | undefined;
    /** Patient's Name (0010,0010). */
    get patientName(): string;
    /** Patient ID (0010,0020). */
    get patientID(): string;
    /** Study Date (0008,0020). */
    get studyDate(): string;
    /** Modality (0008,0060). */
    get modality(): string;
    /** Accession Number (0008,0050). */
    get accession(): string;
    /** SOP Class UID (0008,0016). */
    get sopClassUID(): SOPClassUID | undefined;
    /** Study Instance UID (0020,000D). */
    get studyInstanceUID(): string;
    /** Series Instance UID (0020,000E). */
    get seriesInstanceUID(): string;
    /** SOP Instance UID (0008,0018). */
    get sopInstanceUID(): string;
    /** Transfer Syntax UID (0002,0010). */
    get transferSyntaxUID(): string;
    /**
     * Gets a tag value as a string with optional fallback.
     *
     * @param tag - A DICOM tag, e.g. `'(0010,0010)'` or `'00100010'`
     * @param fallback - Value to return if tag is missing (default: `''`)
     */
    getString(tag: DicomTag | string, fallback?: string): string;
    /**
     * Gets a tag value as a number.
     *
     * @param tag - A DICOM tag, e.g. `'(0020,0013)'`
     */
    getNumber(tag: DicomTag | string): Result<number>;
    /** Checks whether a tag exists in the dataset. */
    hasTag(tag: DicomTag | string): boolean;
    /**
     * Finds all values matching a wildcard path.
     *
     * @param path - A DicomTagPath with optional wildcard indices
     */
    findValues(path: DicomTagPath): ReadonlyArray<unknown>;
    /**
     * Sets a tag value, returning a new DicomInstance.
     *
     * @param path - The DICOM tag path (e.g. `'(0010,0010)'`)
     * @param value - The new value
     */
    setTag(path: string, value: string): DicomInstance;
    /**
     * Erases a tag, returning a new DicomInstance.
     *
     * @param path - The DICOM tag path to erase
     */
    eraseTag(path: string): DicomInstance;
    /** Erases all private tags, returning a new DicomInstance. */
    erasePrivateTags(): DicomInstance;
    /** Sets Patient's Name (0010,0010). */
    setPatientName(value: string): DicomInstance;
    /** Sets Patient ID (0010,0020). */
    setPatientID(value: string): DicomInstance;
    /** Sets Study Date (0008,0020). */
    setStudyDate(value: string): DicomInstance;
    /** Sets Modality (0008,0060). */
    setModality(value: string): DicomInstance;
    /** Sets Accession Number (0008,0050). */
    setAccessionNumber(value: string): DicomInstance;
    /** Sets Study Description (0008,1030). */
    setStudyDescription(value: string): DicomInstance;
    /** Sets Series Description (0008,103E). */
    setSeriesDescription(value: string): DicomInstance;
    /** Sets Institution Name (0008,0080). */
    setInstitutionName(value: string): DicomInstance;
    /**
     * Transforms a tag value using a function.
     *
     * The function receives the current string value (or undefined if tag is missing)
     * and returns the new value. Returns a new DicomInstance with the modification.
     *
     * @param path - The DICOM tag path
     * @param fn - Transform function receiving the current value
     */
    transformTag(path: string, fn: (current: string | undefined) => string): DicomInstance;
    /**
     * Sets multiple tags at once, returning a new DicomInstance.
     *
     * @param entries - A record of tag path → value pairs
     */
    setBatch(entries: Readonly<Record<string, string>>): DicomInstance;
    /**
     * Returns a new DicomInstance with the given changes merged into pending changes.
     *
     * @param changes - A ChangeSet to merge with existing pending changes
     * @returns A new DicomInstance with accumulated changes
     */
    withChanges(changes: ChangeSet): DicomInstance;
    /**
     * Returns a new DicomInstance pointing to a different file path.
     *
     * Preserves the dataset, pending changes, and metadata.
     *
     * @param newPath - The new filesystem path (validated via createDicomFilePath)
     * @returns A new DicomInstance with the updated path
     * @throws If the path is invalid
     */
    withFilePath(newPath: string): DicomInstance;
    /**
     * Applies pending changes to the file in-place.
     *
     * Requires that the instance has an associated file path.
     *
     * @param options - Timeout and abort options
     */
    applyChanges(options?: FileIOOptions): Promise<Result<void>>;
    /**
     * Copies the file to a new path and applies pending changes to the copy.
     *
     * Returns a new DicomInstance pointing to the output path.
     *
     * @param outputPath - Destination filesystem path
     * @param options - Timeout and abort options
     */
    writeAs(outputPath: string, options?: FileIOOptions): Promise<Result<DicomInstance>>;
    /**
     * Gets the file size in bytes.
     *
     * @returns A Result containing the size or an error
     */
    fileSize(): Promise<Result<number>>;
    /**
     * Deletes the associated file from the filesystem.
     *
     * @returns A Result indicating success or failure
     */
    unlink(): Promise<Result<void>>;
    /**
     * Returns a new DicomInstance with application metadata attached.
     *
     * Metadata is not stored in the DICOM file — it's for application context
     * (e.g. tracking source association, processing status, etc.).
     *
     * @param key - Metadata key
     * @param value - Metadata value
     */
    withMetadata(key: string, value: unknown): DicomInstance;
    /**
     * Gets application metadata by key.
     *
     * @param key - Metadata key
     * @returns The metadata value or undefined
     */
    getMetadata(key: string): unknown;
}

export { type AETitle as A, type Brand as B, ChangeSet as C, type DicomTag as D, type Port as P, type SOPClassUID as S, type TransferSyntaxUID as T, type DicomTagPath as a, DicomDataset as b, type DicomFilePath as c, DicomInstance as d, createAETitle as e, createDicomFilePath as f, createDicomTag as g, createDicomTagPath as h, createPort as i, createSOPClassUID as j, createTransferSyntaxUID as k, tag as t };
