import { Either as E, Schema } from "effect";
declare const CBORError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
    readonly _tag: "CBORError";
} & Readonly<A>;
/**
 * Error class for CBOR value operations
 *
 * @since 1.0.0
 * @category errors
 */
export declare class CBORError extends CBORError_base<{
    message?: string;
    cause?: unknown;
}> {
}
/**
 * CBOR major types as constants
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CBOR_MAJOR_TYPE: {
    readonly UNSIGNED_INTEGER: 0;
    readonly NEGATIVE_INTEGER: 1;
    readonly BYTE_STRING: 2;
    readonly TEXT_STRING: 3;
    readonly ARRAY: 4;
    readonly MAP: 5;
    readonly TAG: 6;
    readonly SIMPLE_FLOAT: 7;
};
/**
 * CBOR additional information constants
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CBOR_ADDITIONAL_INFO: {
    readonly DIRECT: 24;
    readonly UINT16: 25;
    readonly UINT32: 26;
    readonly UINT64: 27;
    readonly INDEFINITE: 31;
};
/**
 * Simple value constants for CBOR
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CBOR_SIMPLE: {
    readonly FALSE: 20;
    readonly TRUE: 21;
    readonly NULL: 22;
    readonly UNDEFINED: 23;
};
/**
 * Width of a CBOR integer argument: inline (0), 1-byte, 2-byte, 4-byte, or 8-byte.
 *
 * @since 2.0.0
 * @category model
 */
export type ByteSize = 0 | 1 | 2 | 4 | 8;
/**
 * Container length encoding style captured during decode.
 *
 * @since 2.0.0
 * @category model
 */
export type LengthEncoding = {
    readonly tag: "indefinite";
} | {
    readonly tag: "definite";
    readonly byteSize: ByteSize;
};
/**
 * Byte/text string encoding style captured during decode.
 *
 * @since 2.0.0
 * @category model
 */
export type StringEncoding = {
    readonly tag: "definite";
    readonly byteSize: ByteSize;
} | {
    readonly tag: "indefinite";
    readonly chunks: ReadonlyArray<{
        readonly length: number;
        readonly byteSize: ByteSize;
    }>;
};
/**
 * Tagged discriminated union capturing how each CBOR node was originally
 * serialized.  Every variant carries a `_tag` discriminant.  Encoding-detail
 * fields are optional — absent means "use canonical / minimal default".
 *
 * @since 2.0.0
 * @category model
 */
export type CBORFormat = CBORFormat.UInt | CBORFormat.NInt | CBORFormat.Bytes | CBORFormat.Text | CBORFormat.Array | CBORFormat.Map | CBORFormat.Tag | CBORFormat.Simple;
/**
 * @since 2.0.0
 * @category model
 */
export declare namespace CBORFormat {
    /** Unsigned integer (major 0). `byteSize` absent → minimal encoding. */
    type UInt = {
        readonly _tag: "uint";
        readonly byteSize?: ByteSize;
    };
    /** Negative integer (major 1). `byteSize` absent → minimal encoding. */
    type NInt = {
        readonly _tag: "nint";
        readonly byteSize?: ByteSize;
    };
    /** Byte string (major 2). `encoding` absent → definite, minimal length. */
    type Bytes = {
        readonly _tag: "bytes";
        readonly encoding?: StringEncoding;
    };
    /** Text string (major 3). `encoding` absent → definite, minimal length. */
    type Text = {
        readonly _tag: "text";
        readonly encoding?: StringEncoding;
    };
    /** Array (major 4). `length` absent → definite, minimal length header. */
    type Array = {
        readonly _tag: "array";
        readonly length?: LengthEncoding;
        readonly children: ReadonlyArray<CBORFormat>;
    };
    /** Map (major 5). `keyOrder` stores CBOR-encoded key bytes for serializable ordering. */
    type Map = {
        readonly _tag: "map";
        readonly length?: LengthEncoding;
        readonly keyOrder?: ReadonlyArray<Uint8Array>;
        readonly entries: ReadonlyArray<readonly [CBORFormat, CBORFormat]>;
    };
    /** Tag (major 6). `width` absent → minimal tag header. */
    type Tag = {
        readonly _tag: "tag";
        readonly width?: ByteSize;
        readonly child: CBORFormat;
    };
    /** Simple value or float (major 7). No encoding choices to preserve. */
    type Simple = {
        readonly _tag: "simple";
    };
}
/**
 * Decoded value paired with its captured root format tree.
 *
 * @since 2.0.0
 * @category model
 */
export type DecodedWithFormat<A> = {
    value: A;
    format: CBORFormat;
};
/**
 * CBOR codec configuration options
 *
 * @since 1.0.0
 * @category model
 */
export type CodecOptions = {
    readonly mode: "canonical";
    readonly mapsAsObjects?: boolean;
    readonly encodeMapAsPairs?: boolean;
} | {
    readonly mode: "custom";
    readonly useIndefiniteArrays: boolean;
    readonly useIndefiniteMaps: boolean;
    readonly useDefiniteForEmpty: boolean;
    readonly sortMapKeys: boolean;
    readonly useMinimalEncoding: boolean;
    readonly mapsAsObjects?: boolean;
    readonly encodeMapAsPairs?: boolean;
};
/**
 * Canonical CBOR encoding options (RFC 8949 Section 4.2.1)
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CANONICAL_OPTIONS: CodecOptions;
/**
 * Default CBOR encoding options
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CML_DEFAULT_OPTIONS: CodecOptions;
/**
 * Default CBOR encoding options for PlutusData.
 *
 * Uses indefinite-length arrays and maps. The `bounded_bytes` constraint
 * (Conway CDDL: byte strings ≤ 64 bytes) is enforced at the data-type layer
 * via the `BoundedBytes` CBOR node, independent of these codec options.
 *
 * @since 1.0.0
 * @category constants
 */
export declare const CML_DATA_DEFAULT_OPTIONS: CodecOptions;
/**
 * Aiken-compatible CBOR encoding options.
 *
 * Matches the encoding produced by `cbor.serialise()` in Aiken:
 * - Indefinite-length arrays (`9f...ff`)
 * - Maps encoded as arrays of pairs (not CBOR maps)
 * - Strings as byte arrays (major type 2, not 3)
 * - Constructor tags: 121–127 for indices 0–6, then 1280+ for 7+
 *
 * PlutusData byte strings are chunked per the Conway `bounded_bytes` rule
 * via the `BoundedBytes` CBOR node, independent of these codec options.
 *
 * @since 2.0.0
 * @category constants
 */
export declare const AIKEN_DEFAULT_OPTIONS: CodecOptions;
/**
 * CBOR encoding options that return objects instead of Maps for Schema.Struct compatibility
 *
 * @since 2.0.0
 * @category constants
 */
export declare const STRUCT_FRIENDLY_OPTIONS: CodecOptions;
/**
 * Cardano Node compatible CBOR encoding options for PlutusData
 *
 * Uses definite-length encoding for arrays and maps, matching the format
 * produced by CML's `to_cardano_node_format().to_cbor_hex()`.
 *
 * Note: The on-chain format uses indefinite-length (AIKEN_DEFAULT_OPTIONS),
 * but this option is useful for testing compatibility with tools that
 * expect definite-length encoding.
 *
 * @since 2.0.0
 * @category constants
 */
export declare const CARDANO_NODE_DATA_OPTIONS: CodecOptions;
/**
 * Encode a CBOR definite-length array from already-encoded item bytes.
 * This is a low-level function that constructs: definite_array_header + items.
 *
 */
export declare const encodeArrayAsDefinite: (items: ReadonlyArray<Uint8Array>) => Uint8Array;
/**
 * Encode a CBOR indefinite-length array from already-encoded item bytes.
 * This is a low-level function that constructs: 0x9f + items + 0xff.
 *
 */
export declare const encodeArrayAsIndefinite: (items: ReadonlyArray<Uint8Array>) => Uint8Array;
/**
 * Encode a CBOR tagged value from already-encoded value bytes.
 * This is a low-level function that constructs: tag_header + value_bytes.
 *
 */
export declare const encodeTaggedValue: (tag: number, valueBytes: Uint8Array) => Uint8Array;
/**
 * Type representing a CBOR value with simplified, non-tagged structure
 *
 * @since 1.0.0
 * @category model
 */
export type CBOR = bigint | Uint8Array | string | ReadonlyArray<CBOR> | ReadonlyMap<CBOR, CBOR> | {
    readonly [key: string | number]: CBOR;
} | {
    _tag: "Tag";
    tag: number;
    value: CBOR;
} | boolean | null | undefined | number | {
    _tag: "BoundedBytes";
    bytes: Uint8Array;
};
/**
 * **Record vs Map Key Ordering**
 *
 * Records `{ readonly [key: string | number]: CBOR }` follow JavaScript object property enumeration rules:
 * 1. **Integer-like strings in ascending numeric order** (e.g., "0", "1", "42", "999")
 * 2. **Other strings in insertion order** (e.g., "text", "key1", "key2")
 *
 * Maps `ReadonlyMap<CBOR, CBOR>` preserve insertion order for all key types.
 *
 * **Example:**
 * ```typescript
 * // Map preserves insertion order: ["text", 42n, 999n]
 * const map = new Map([["text", "a"], [42n, "b"], [999n, "c"]])
 *
 * // Record follows JS enumeration: [42, 999, "text"]
 * const record = { text: "a", 42: "b", 999: "c" }
 * ```
 *
 * **Recommendation:** Use Maps for consistent insertion order with mixed key types,
 * or use canonical encoding to eliminate ordering differences.
 *
 * @since 1.0.0
 * @category model
 */
/**
 * CBOR Value schema definitions for each major type
 *
 * @since 1.0.0
 * @category schemas
 */
export declare const Integer: typeof Schema.BigIntFromSelf;
export declare const isInteger: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is bigint;
export declare const ByteArray: typeof Schema.Uint8ArrayFromSelf;
export declare const isByteArray: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is Uint8Array<ArrayBufferLike>;
export declare const Text: typeof Schema.String;
export declare const ArraySchema: Schema.Array$<Schema.suspend<CBOR, CBOR, never>>;
export declare const isArray: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is readonly CBOR[];
export declare const MapSchema: Schema.ReadonlyMapFromSelf<Schema.suspend<CBOR, CBOR, never>, Schema.suspend<CBOR, CBOR, never>>;
export declare const isMap: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is ReadonlyMap<CBOR, CBOR>;
export declare const RecordSchema: Schema.Record$<typeof Schema.String, Schema.suspend<CBOR, CBOR, never>>;
export declare const isRecord: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is {
    readonly [x: string]: CBOR;
};
export declare const Tag: Schema.TaggedStruct<"Tag", {
    tag: typeof Schema.Number;
    value: Schema.suspend<CBOR, CBOR, never>;
}>;
export declare const tag: <T extends number, C extends Schema.Schema<any, any>>(tag: T, value: C) => Schema.TaggedStruct<"Tag", {
    tag: Schema.Literal<[T]>;
    value: C;
}>;
export declare const map: <K extends CBOR, V extends CBOR>(key: Schema.Schema<K>, value: Schema.Schema<V>) => Schema.ReadonlyMapFromSelf<Schema.Schema<K, K, never>, Schema.Schema<V, V, never>>;
export declare const isTag: (u: unknown, overrideOptions?: import("effect/SchemaAST").ParseOptions | number) => u is {
    readonly tag: number;
    readonly value: CBOR;
    readonly _tag: "Tag";
};
export declare const Simple: Schema.Union<[typeof Schema.Boolean, typeof Schema.Null, typeof Schema.Undefined]>;
export declare const Float: typeof Schema.Number;
/**
 * CBOR Value discriminated union schema representing all possible CBOR data types
 * Inspired by OCaml and Rust CBOR implementations
 *
 * @since 1.0.0
 * @category schemas
 */
export declare const CBORSchema: Schema.Schema<CBOR>;
/**
 * Pattern matching utility for CBOR values
 *
 * @since 1.0.0
 * @category transformation
 */
export declare const match: <R>(value: CBOR, patterns: {
    integer: (value: bigint) => R;
    bytes: (value: Uint8Array) => R;
    text: (value: string) => R;
    array: (value: ReadonlyArray<CBOR>) => R;
    map: (value: ReadonlyMap<CBOR, CBOR>) => R;
    record: (value: {
        readonly [key: string]: CBOR;
    }) => R;
    tag: (tag: number, value: CBOR) => R;
    boolean: (value: boolean) => R;
    null: () => R;
    undefined: () => R;
    float: (value: number) => R;
    boundedBytes: (value: Uint8Array) => R;
}) => R;
/**
 * Create a CBOR bytes schema with custom codec options
 *
 * @since 1.0.0
 * @category schemas
 */
export declare const FromBytes: (options: CodecOptions) => Schema.transformOrFail<typeof Schema.Uint8ArrayFromSelf, Schema.declare<CBOR, CBOR, readonly [], never>, never>;
export declare const FromHex: (options: CodecOptions) => Schema.transform<Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>, Schema.transformOrFail<typeof Schema.Uint8ArrayFromSelf, Schema.declare<CBOR, CBOR, readonly [], never>, never>>;
export declare namespace Either {
    /** Decode CBOR bytes to a CBOR value, returning Either */
    const fromCBORBytes: (bytes: Uint8Array, options?: CodecOptions) => E.Either<CBOR, CBORError>;
    /** Decode CBOR hex string to a CBOR value, returning Either */
    const fromCBORHex: (hex: string, options?: CodecOptions) => E.Either<CBOR, CBORError>;
    /** Encode a CBOR value to bytes, returning Either */
    const toCBORBytes: (value: CBOR, options?: CodecOptions) => E.Either<Uint8Array, CBORError>;
    /** Encode a CBOR value to hex string, returning Either */
    const toCBORHex: (value: CBOR, options?: CodecOptions) => E.Either<string, CBORError>;
}
/**
 * Parse a CBOR value from CBOR bytes.
 *
 * @since 1.0.0
 * @category parsing
 */
export declare const fromCBORBytes: (bytes: Uint8Array, options?: CodecOptions) => CBOR;
/**
 * Parse a CBOR value from CBOR bytes and return the root format tree.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromCBORBytesWithFormat: (bytes: Uint8Array) => DecodedWithFormat<CBOR>;
/**
 * Parse a CBOR value from CBOR hex string.
 *
 * @since 1.0.0
 * @category parsing
 */
export declare const fromCBORHex: (hex: string, options?: CodecOptions) => CBOR;
/**
 * Parse a CBOR value from CBOR hex string and return the root format tree.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromCBORHexWithFormat: (hex: string) => DecodedWithFormat<CBOR>;
/**
 * Convert a CBOR value to CBOR bytes.
 *
 * @since 1.0.0
 * @category encoding
 */
export declare const toCBORBytes: (value: CBOR, options?: CodecOptions) => Uint8Array;
/**
 * Convert a CBOR value to CBOR bytes using an explicit root format tree.
 *
 * @since 2.0.0
 * @category encoding
 */
export declare const toCBORBytesWithFormat: (value: CBOR, format: CBORFormat) => Uint8Array;
/**
 * Convert a CBOR value to CBOR hex string.
 *
 * @since 1.0.0
 * @category encoding
 */
export declare const toCBORHex: (value: CBOR, options?: CodecOptions) => string;
/**
 * Convert a CBOR value to CBOR hex string using an explicit root format tree.
 *
 * @since 2.0.0
 * @category encoding
 */
export declare const toCBORHexWithFormat: (value: CBOR, format: CBORFormat) => string;
export declare const internalEncodeSync: (value: CBOR, options?: CodecOptions, fmt?: CBORFormat) => Uint8Array;
/**
 * `BoundedBytes` CBOR node — represents a PlutusData byte string that must comply
 * with the Conway CDDL constraint `bounded_bytes = bytes .size (0..64)`.
 *
 * The encoding rule is unconditional and options-independent:
 * - ≤ 64 bytes → definite-length CBOR bytes
 * - > 64 bytes → indefinite-length 64-byte chunked byte string (`0x5f` + chunks + `0xff`)
 *
 * Use `BoundedBytes.make` to construct the node; the encoder handles the rest.
 *
 * @since 2.0.0
 * @category model
 */
export declare const BoundedBytes: {
    /** Construct a BoundedBytes CBOR node from a raw byte array. */
    readonly make: (bytes: Uint8Array) => CBOR;
    /** Type guard for BoundedBytes CBOR nodes. */
    readonly is: (value: CBOR) => value is {
        _tag: "BoundedBytes";
        bytes: Uint8Array;
    };
};
/**
 * Schema-derived structural equivalence for CBOR values.
 * Handles Uint8Array, Array, Map, Tag and all primitives via the
 * recursive CBORSchema definition — no hand-rolled comparison needed.
 *
 * Derived once at module init; at call time it's a plain function.
 *
 * @since 2.0.0
 * @category equality
 */
export declare const equals: (a: CBOR, b: CBOR) => boolean;
/**
 * Decode a single CBOR item at a given byte offset, returning the decoded value and the new offset.
 * Useful for extracting raw byte slices from CBOR-encoded data without re-encoding.
 *
 * @since 2.0.0
 * @category decoding
 */
export declare const decodeItemWithOffset: (data: Uint8Array, offset: number, options?: CodecOptions) => {
    item: CBOR;
    newOffset: number;
};
export declare const internalDecodeSync: (data: Uint8Array, options?: CodecOptions) => CBOR;
/**
 * Decode CBOR bytes and return both the decoded value and the root format tree.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const internalDecodeWithFormatSync: (data: Uint8Array) => DecodedWithFormat<CBOR>;
export {};
//# sourceMappingURL=CBOR.d.ts.map