import { Behavior, BundleBuilder } from "./builders";
import { DBSchema } from "idb";
export type Bytes = Uint8Array;
export type BundleBytes = Bytes;
export type Medallion = number;
export type Timestamp = number;
export type ChainStart = Timestamp;
export type SeenThrough = Timestamp;
export type PriorTime = Timestamp;
export type Offset = number;
export type DirPath = string;
export type FilePath = string;
export type NumberStr = string;
export type ScalarKey = number | string | Bytes;
export type Value = number | string | boolean | null | Bytes | Map<ScalarKey, Value> | Array<Value> | Date | BigInt;
export type BundleInfoTuple = [
    Timestamp,
    Medallion,
    ChainStart,
    PriorTime,
    string
];
export type ChangeSetOffset = number;
export type AsOf = Timestamp | Date | ChangeSetOffset;
export type MuidTuple = [Timestamp, Medallion, Offset];
export type Cookies = Map<string, string>;
export type Indexable = MuidTuple;
export type ActorId = number;
export type StorageKey = ScalarKey | MuidTuple | [MuidTuple, MuidTuple] | [];
export type Placement = {
    container: MuidTuple;
    key: StorageKey;
    placement: MuidTuple;
};
export interface BundleListener {
    (bundle: BundleView): Promise<void>;
}
export interface ClaimedChain {
    medallion: Medallion;
    chainStart: ChainStart;
    actorId: ActorId;
    claimTime: Timestamp;
}
export interface CallBack {
    (value?: any): void;
}
export interface Indexer {
    (value: Muid): Indexable;
}
export interface AuthFunction {
    (token: string): boolean;
}
export interface BroadcastFunc {
    (bundle: BundleView): Promise<void>;
}
export interface Muid {
    medallion: Medallion;
    timestamp: Timestamp;
    offset: number;
}
export interface BundleInfo {
    timestamp: Timestamp;
    medallion: Medallion;
    chainStart: ChainStart;
    priorTime?: PriorTime;
    hashCode?: Bytes;
    comment?: string;
}
export interface BundleView {
    bytes: BundleBytes;
    info: BundleInfo;
    builder: BundleBuilder;
}
export interface Entry {
    behavior: Behavior;
    containerId: MuidTuple;
    /**
     * storageKey is a KeyType if the entry is for a Directory, a Timestamp if it's for a sequence,
     * MuidTuple if it's for a property, and empty list for a box.
     */
    storageKey: StorageKey;
    entryId: MuidTuple;
    pointeeList: Indexable[];
    value?: Value;
    expiry?: Timestamp;
    deletion?: boolean;
    placementId: MuidTuple;
    sourceList: Indexable[];
    targetList: Indexable[];
    purging?: boolean;
}
export interface Removal {
    removing: MuidTuple;
    removalId: MuidTuple;
    containerId: MuidTuple;
    dest: number;
    entryId: MuidTuple;
}
export interface Movement {
    entryId: MuidTuple;
    movementId: MuidTuple;
    containerId: MuidTuple;
    dest: number;
    purge: boolean;
}
export interface Clearance {
    containerId: MuidTuple;
    clearanceId: MuidTuple;
    purging: boolean;
}
export interface EdgeData {
    source: Muid;
    target: Muid;
    action: Muid;
    value?: Value;
    effective?: number;
}
export interface KeyPair {
    publicKey: Bytes;
    secretKey: Bytes;
}
export interface IndexedDbStoreSchema extends DBSchema {
    trxns: {
        key: BundleInfoTuple;
        value: BundleBytes;
    };
    chainInfos: {
        value: BundleInfo;
        key: [number, number];
    };
    activeChains: {
        value: ClaimedChain;
        key: [number];
    };
    containers: {
        key: MuidTuple;
        value: Bytes;
    };
    removals: {
        value: Removal;
        key: MuidTuple;
        indexes: {
            "by-container-movement": [MuidTuple, MuidTuple];
            "by-removing": [MuidTuple, MuidTuple];
        };
    };
    clearances: {
        value: Clearance;
        key: [MuidTuple, MuidTuple];
    };
    entries: {
        value: Entry;
        key: MuidTuple;
        indexes: {
            "by-container-key-placement": [
                MuidTuple,
                ScalarKey | Timestamp | MuidTuple | [],
                MuidTuple
            ];
            "by-container-name": [MuidTuple, string];
            "by-key-placement": [StorageKey, MuidTuple];
            pointees: Indexable;
            locations: [MuidTuple, MuidTuple];
            sources: Indexable;
            targets: Indexable;
        };
    };
    identities: {
        value: string;
        key: [Medallion, ChainStart];
    };
    verifyKeys: {
        value: Bytes;
        key: [Medallion, ChainStart];
    };
    secretKeys: {
        value: Bytes;
        key: Bytes;
    };
    symmetricKeys: {
        value: Bytes;
        key: number;
    };
}
