/**
 * @license
 * Copyright 2025 Steven Roussey <sroussey@gmail.com>
 * SPDX-License-Identifier: Apache-2.0
 */
import { CreateWorkflow, IExecuteContext, Task, TaskConfig } from "@workglow/task-graph";
import { DataPortSchema, FromSchema } from "@workglow/util/schema";
import { FetchUrlTaskOutput } from "./FetchUrlTask";
declare const inputSchema: {
    readonly type: "object";
    readonly properties: {
        readonly url: {
            readonly type: "string";
            readonly title: "URL";
            readonly description: "URL to load document from (http://, https://)";
            readonly format: "uri";
        };
        readonly format: {
            readonly type: "string";
            readonly enum: readonly ["text", "markdown", "json", "csv", "pdf", "image", "html", "auto"];
            readonly title: "Format";
            readonly description: "File format (auto-detected from URL if 'auto')";
            readonly default: "auto";
        };
    };
    readonly required: readonly ["url"];
    readonly additionalProperties: false;
};
declare const outputSchema: {
    readonly type: "object";
    readonly properties: {
        readonly text: {
            readonly type: "string";
            readonly title: "Text";
            readonly description: "Text content (for text, markdown, html formats)";
        };
        readonly json: {
            readonly title: "JSON";
            readonly description: "Parsed JSON object or array";
        };
        readonly csv: {
            readonly type: "array";
            readonly title: "CSV";
            readonly description: "Parsed CSV data as array of objects";
        };
        readonly image: {
            readonly type: "string";
            readonly title: "Image";
            readonly description: "Base64 data URL for image files";
            readonly format: "image:data-uri";
        };
        readonly pdf: {
            readonly type: "string";
            readonly title: "PDF";
            readonly description: "Base64 data URL for PDF files";
        };
        readonly frontmatter: {
            readonly type: "object";
            readonly title: "Frontmatter";
            readonly description: "Parsed YAML frontmatter from markdown/MDX files";
        };
        readonly metadata: {
            readonly type: "object";
            readonly properties: {
                readonly url: {
                    readonly type: "string";
                };
                readonly format: {
                    readonly type: "string";
                };
                readonly size: {
                    readonly type: "number";
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly mimeType: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: false;
            readonly title: "Metadata";
            readonly description: "File metadata";
        };
    };
    readonly required: readonly ["metadata"];
    readonly additionalProperties: false;
};
export type FileLoaderTaskInput = FromSchema<typeof inputSchema>;
export type FileLoaderTaskOutput = FromSchema<typeof outputSchema>;
/**
 * Task for loading documents from URLs (including file:// URLs).
 * Works in all environments (browser, Node.js, Bun) by using fetch API.
 * For server-only filesystem path access, see FileLoaderServerTask.
 */
export declare class FileLoaderTask extends Task<FileLoaderTaskInput, FileLoaderTaskOutput, TaskConfig> {
    static type: string;
    static category: string;
    static title: string;
    static description: string;
    static cacheable: boolean;
    static inputSchema(): DataPortSchema;
    static outputSchema(): DataPortSchema;
    execute(input: FileLoaderTaskInput, context: IExecuteContext): Promise<FileLoaderTaskOutput>;
    /**
     * Parse JSON content
     */
    protected parseJsonContent(content: string): unknown;
    /**
     * Parse CSV content into array of objects
     */
    protected parseCsvContent(content: string): Promise<Array<Record<string, string>>>;
    /**
     * Parse YAML frontmatter from markdown/MDX content.
     * Supports common frontmatter patterns: strings, numbers, booleans, arrays, and nested objects.
     */
    protected parseFrontmatter(content: string): {
        readonly frontmatter: Record<string, unknown> | undefined;
        readonly body: string;
    };
    /**
     * Lightweight line-based YAML parser for frontmatter key-value pairs.
     */
    private parseSimpleYaml;
    private parseYamlLine;
    private parseYamlValue;
    /**
     * Parse the fetch response into typed outputs
     */
    protected parseResponse(response: FetchUrlTaskOutput, url: string, detectedFormat: "text" | "markdown" | "json" | "csv" | "pdf" | "image" | "html"): Promise<{
        readonly text: string | undefined;
        readonly json: unknown | undefined;
        readonly csv: Array<Record<string, string>> | undefined;
        readonly image: string | undefined;
        readonly pdf: string | undefined;
        readonly frontmatter: Record<string, unknown> | undefined;
        readonly size: number;
        readonly mimeType: string;
    }>;
    /**
     * Detect the appropriate response type for fetching based on the detected format
     * @param detectedFormat - The detected format
     * @returns The appropriate response type
     */
    protected detectResponseType(detectedFormat: string): "text" | "json" | "blob" | "arraybuffer";
    /**
     *
     * @param url - The URL to detect the format from
     * @param format - The format (assuming "auto" if not provided)
     * @returns
     */
    protected detectFormat(url: string, format: "text" | "markdown" | "json" | "csv" | "pdf" | "image" | "html" | "auto"): "text" | "markdown" | "json" | "csv" | "pdf" | "image" | "html";
    /**
     * Get image MIME type based on URL extension
     */
    protected getImageMimeType(url: string): string;
    /**
     * Convert Blob to base64 data URL
     */
    protected blobToBase64DataURL(blob: Blob, mimeType: string): Promise<string>;
}
export declare const fileLoader: (input: FileLoaderTaskInput, config?: TaskConfig) => Promise<{
    csv?: unknown[] | undefined;
    frontmatter?: {
        [x: string]: unknown;
    } | undefined;
    image?: string | undefined;
    json?: unknown;
    metadata: {
        format?: string | undefined;
        mimeType?: string | undefined;
        size?: number | undefined;
        title?: string | undefined;
        url?: string | undefined;
    };
    pdf?: string | undefined;
    text?: string | undefined;
}>;
declare module "@workglow/task-graph" {
    interface Workflow {
        fileLoader: CreateWorkflow<FileLoaderTaskInput, FileLoaderTaskOutput, TaskConfig>;
    }
}
export {};
//# sourceMappingURL=FileLoaderTask.d.ts.map