import { ContentReference } from './references';
import { UploadState } from './uploads';

/**
 * Platform-agnostic image asset type (compatible with expo-image-picker's ImagePickerAsset)
 * This allows the package to work in Node.js, web, and React Native environments.
 */
export interface ImagePickerAsset {
    uri: string;
    width: number;
    height: number;
    fileSize?: number;
    mimeType?: string;
    fileName?: string;
    type?: 'image' | 'video';
    duration?: number;
    base64?: string;
    exif?: Record<string, unknown>;
}
export type LinkMetadata = PageMetadata | FileMetadata;
export type LinkMetadataError = {
    type: 'redirect';
} | {
    type: 'error';
    reason: 'bad response' | 'unknown error' | string;
};
export type DefaultPageMetadata = {
    siteIconUrl?: string;
    siteName?: string;
    title?: string;
    author?: string;
    description?: string;
    previewImageUrl?: string;
    previewImageHeight?: string;
    previewImageWidth?: string;
};
export interface PageMetadata extends DefaultPageMetadata {
    url: string;
    type: 'page';
}
export type FileMetadata = {
    url: string;
    type: 'file';
    mime: string;
    isImage?: boolean;
};
export interface LinkAttachment extends DefaultPageMetadata {
    type: 'link';
    url: string;
    resourceType?: 'page' | 'file';
}
export type ReferenceAttachment = {
    type: 'reference';
    reference: ContentReference;
    path: string;
};
export type ImageAttachment = {
    type: 'image';
    file: ImagePickerAsset;
    uploadState?: UploadState;
};
export type UploadedImageAttachment = {
    type: 'image';
    file: ImagePickerAsset;
    uploadState: Extract<UploadState, {
        status: 'success' | 'uploading';
    }>;
};
export declare namespace UploadedImageAttachment {
    function uri(attachment: UploadedImageAttachment): string;
}
export type FileAttachment = {
    type: 'file';
    localFile: File | string;
    name?: string;
    /** in bytes */
    size: number;
    mimeType?: string;
};
export type UploadedFileAttachment = {
    type: 'file';
    localFile: File | string;
    name?: string;
    /** in bytes */
    size: number;
    mimeType?: string;
    uploadState: Extract<UploadState, {
        status: 'success' | 'uploading';
    }>;
};
export declare namespace UploadedFileAttachment {
    function uri(attachment: UploadedFileAttachment): string;
}
export type TextAttachment = {
    type: 'text';
    text: string;
};
export type Attachment = ReferenceAttachment | ImageAttachment | FileAttachment | TextAttachment | LinkAttachment;
export type FinalizedAttachment = ReferenceAttachment | UploadedImageAttachment | UploadedFileAttachment | TextAttachment | LinkAttachment;
export declare namespace Attachment {
    type ImageUploadIntent = {
        type: 'image';
        asset: Pick<ImagePickerAsset, 'uri' | 'width' | 'height' | 'fileSize' | 'mimeType'>;
    };
    export type UploadIntent = ImageUploadIntent | {
        type: 'fileUri';
        localUri: string;
        name?: string;
        /** in bytes */
        size: number;
        mimeType?: string;
    } | {
        type: 'file';
        file: File;
    };
    export namespace UploadIntent {
        /** Branded type to avoid using wrong keys downstream */
        type Key = string & {
            __brand: 'Attachment.UploadIntent.Key';
        };
        function fromImagePickerAsset(asset: ImagePickerAsset): UploadIntent;
        function fromFile(file: File): UploadIntent;
        function createLocalUri(uploadIntent: UploadIntent): string;
        function extractImagePickerAssets(xs: UploadIntent[]): ImagePickerAsset[];
        function extractKey(uploadIntent: UploadIntent): UploadIntent.Key;
        function equivalent(a: UploadIntent, b: UploadIntent): boolean;
        function toFinalizedAttachment(uploadIntent: UploadIntent, uploadState: UploadState): FinalizedAttachment | null;
        /** Builds a FinalizedAttachment using local data - used in optimistic UI update. */
        function toLocalFinalizedAttachment(uploadIntent: UploadIntent): FinalizedAttachment | null;
    }
    export function toUploadIntent(attachment: Attachment): {
        needsUpload: false;
        finalized: FinalizedAttachment;
    } | ({
        needsUpload: true;
    } & UploadIntent);
    export function fromUploadIntent(uploadIntent: UploadIntent): Attachment;
    export function toSuccessfulFinalizedAttachment(attachment: Attachment, uploadState: UploadState | null): FinalizedAttachment | null;
    /**
     * Make an attachment safe for JSON serialization.
     * Converts web File objects to blob URLs.
     * On non-web platforms (React Native), localFile is already a string path.
     */
    export function makeSerializable(att: Attachment): Attachment;
    export {};
}
//# sourceMappingURL=attachment.d.ts.map