// Generated by alef. Do not edit by hand.

#![allow(unused_variables, unreachable_code)]
#![allow(
    clippy::collapsible_if,
    clippy::collapsible_match,
    clippy::needless_borrows_for_generic_args,
    clippy::field_reassign_with_default,
    clippy::too_many_arguments,
    clippy::clone_on_copy,
    clippy::unnecessary_cast,
    clippy::manual_flatten,
    clippy::match_single_binding,
    clippy::redundant_closure,
    clippy::useless_conversion,
    clippy::inherent_to_string
)]

/// Process-wide tokio runtime shared across every swift-bridge async wrapper.
///
/// alef-emitted; see shims.rs for the rationale (orphaned reqwest connection
/// pools when each call creates and drops its own current-thread runtime).
fn __alef_tokio_runtime() -> &'static ::tokio::runtime::Runtime {
    use std::sync::OnceLock;
    static RT: OnceLock<::tokio::runtime::Runtime> = OnceLock::new();
    RT.get_or_init(|| {
        ::tokio::runtime::Builder::new_multi_thread()
            .enable_all()
            .build()
            .expect("build process-wide alef tokio runtime")
    })
}

#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        type CacheStats;
        #[swift_bridge(init)]
        fn new(
            total_files: usize,
            total_size_mb: f64,
            available_space_mb: f64,
            oldest_file_age_days: f64,
            newest_file_age_days: f64,
        ) -> CacheStats;
        #[swift_bridge(swift_name = "totalFiles")]
        fn total_files(&self) -> usize;
        #[swift_bridge(swift_name = "totalSizeMb")]
        fn total_size_mb(&self) -> f64;
        #[swift_bridge(swift_name = "availableSpaceMb")]
        fn available_space_mb(&self) -> f64;
        #[swift_bridge(swift_name = "oldestFileAgeDays")]
        fn oldest_file_age_days(&self) -> f64;
        #[swift_bridge(swift_name = "newestFileAgeDays")]
        fn newest_file_age_days(&self) -> f64;
    }

    extern "Rust" {
        type AccelerationConfig;
        #[swift_bridge(init)]
        fn new(provider: ExecutionProviderType, device_id: u32) -> AccelerationConfig;
        fn provider(&self) -> String;
        #[swift_bridge(swift_name = "deviceId")]
        fn device_id(&self) -> u32;
    }

    extern "Rust" {
        type ContentFilterConfig;
        #[swift_bridge(init)]
        fn new(
            include_headers: bool,
            include_footers: bool,
            strip_repeating_text: bool,
            include_watermarks: bool,
        ) -> ContentFilterConfig;
        #[swift_bridge(swift_name = "includeHeaders")]
        fn include_headers(&self) -> bool;
        #[swift_bridge(swift_name = "includeFooters")]
        fn include_footers(&self) -> bool;
        #[swift_bridge(swift_name = "stripRepeatingText")]
        fn strip_repeating_text(&self) -> bool;
        #[swift_bridge(swift_name = "includeWatermarks")]
        fn include_watermarks(&self) -> bool;
    }

    extern "Rust" {
        type EmailConfig;
        #[swift_bridge(init)]
        fn new(msg_fallback_codepage: Option<u32>) -> EmailConfig;
        #[swift_bridge(swift_name = "msgFallbackCodepage")]
        fn msg_fallback_codepage(&self) -> Option<u32>;
    }

    extern "Rust" {
        type ExtractionConfig;
        #[swift_bridge(init)]
        fn new(
            use_cache: bool,
            enable_quality_processing: bool,
            ocr: Option<OcrConfig>,
            force_ocr: bool,
            force_ocr_pages: Option<Vec<u32>>,
            disable_ocr: bool,
            chunking: Option<ChunkingConfig>,
            content_filter: Option<ContentFilterConfig>,
            images: Option<ImageExtractionConfig>,
            pdf_options: Option<PdfConfig>,
            token_reduction: Option<TokenReductionOptions>,
            language_detection: Option<LanguageDetectionConfig>,
            pages: Option<PageConfig>,
            keywords: Option<KeywordConfig>,
            postprocessor: Option<PostProcessorConfig>,
            html_options: Option<String>,
            html_output: Option<HtmlOutputConfig>,
            extraction_timeout_secs: Option<u64>,
            max_concurrent_extractions: Option<usize>,
            result_format: ResultFormat,
            security_limits: Option<SecurityLimits>,
            max_embedded_file_bytes: Option<u64>,
            output_format: OutputFormat,
            layout: Option<LayoutDetectionConfig>,
            use_layout_for_markdown: bool,
            include_document_structure: bool,
            acceleration: Option<AccelerationConfig>,
            cache_namespace: Option<String>,
            cache_ttl_secs: Option<u64>,
            email: Option<EmailConfig>,
            concurrency: Option<String>,
            max_archive_depth: usize,
            tree_sitter: Option<TreeSitterConfig>,
            structured_extraction: Option<StructuredExtractionConfig>,
            cancel_token: Option<String>,
        ) -> ExtractionConfig;
        #[swift_bridge(swift_name = "useCache")]
        fn use_cache(&self) -> bool;
        #[swift_bridge(swift_name = "enableQualityProcessing")]
        fn enable_quality_processing(&self) -> bool;
        fn ocr(&self) -> Option<OcrConfig>;
        #[swift_bridge(swift_name = "forceOcr")]
        fn force_ocr(&self) -> bool;
        #[swift_bridge(swift_name = "forceOcrPages")]
        fn force_ocr_pages(&self) -> Option<Vec<u32>>;
        #[swift_bridge(swift_name = "disableOcr")]
        fn disable_ocr(&self) -> bool;
        fn chunking(&self) -> Option<ChunkingConfig>;
        #[swift_bridge(swift_name = "contentFilter")]
        fn content_filter(&self) -> Option<ContentFilterConfig>;
        fn images(&self) -> Option<ImageExtractionConfig>;
        #[swift_bridge(swift_name = "pdfOptions")]
        fn pdf_options(&self) -> Option<PdfConfig>;
        #[swift_bridge(swift_name = "tokenReduction")]
        fn token_reduction(&self) -> Option<TokenReductionOptions>;
        #[swift_bridge(swift_name = "languageDetection")]
        fn language_detection(&self) -> Option<LanguageDetectionConfig>;
        fn pages(&self) -> Option<PageConfig>;
        fn keywords(&self) -> Option<KeywordConfig>;
        fn postprocessor(&self) -> Option<PostProcessorConfig>;
        #[swift_bridge(swift_name = "htmlOptions")]
        fn html_options(&self) -> Option<String>;
        #[swift_bridge(swift_name = "htmlOutput")]
        fn html_output(&self) -> Option<HtmlOutputConfig>;
        #[swift_bridge(swift_name = "extractionTimeoutSecs")]
        fn extraction_timeout_secs(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "maxConcurrentExtractions")]
        fn max_concurrent_extractions(&self) -> Option<usize>;
        #[swift_bridge(swift_name = "resultFormat")]
        fn result_format(&self) -> String;
        #[swift_bridge(swift_name = "securityLimits")]
        fn security_limits(&self) -> Option<SecurityLimits>;
        #[swift_bridge(swift_name = "maxEmbeddedFileBytes")]
        fn max_embedded_file_bytes(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> String;
        fn layout(&self) -> Option<LayoutDetectionConfig>;
        #[swift_bridge(swift_name = "useLayoutForMarkdown")]
        fn use_layout_for_markdown(&self) -> bool;
        #[swift_bridge(swift_name = "includeDocumentStructure")]
        fn include_document_structure(&self) -> bool;
        fn acceleration(&self) -> Option<AccelerationConfig>;
        #[swift_bridge(swift_name = "cacheNamespace")]
        fn cache_namespace(&self) -> Option<String>;
        #[swift_bridge(swift_name = "cacheTtlSecs")]
        fn cache_ttl_secs(&self) -> Option<u64>;
        fn email(&self) -> Option<EmailConfig>;
        fn concurrency(&self) -> Option<String>;
        #[swift_bridge(swift_name = "maxArchiveDepth")]
        fn max_archive_depth(&self) -> usize;
        #[swift_bridge(swift_name = "treeSitter")]
        fn tree_sitter(&self) -> Option<TreeSitterConfig>;
        #[swift_bridge(swift_name = "structuredExtraction")]
        fn structured_extraction(&self) -> Option<StructuredExtractionConfig>;
        #[swift_bridge(swift_name = "cancelToken")]
        fn cancel_token(&self) -> Option<String>;
    }

    extern "Rust" {
        type FileExtractionConfig;
        #[swift_bridge(init)]
        fn new(
            enable_quality_processing: Option<bool>,
            ocr: Option<OcrConfig>,
            force_ocr: Option<bool>,
            force_ocr_pages: Option<Vec<u32>>,
            disable_ocr: Option<bool>,
            chunking: Option<ChunkingConfig>,
            content_filter: Option<ContentFilterConfig>,
            images: Option<ImageExtractionConfig>,
            pdf_options: Option<PdfConfig>,
            token_reduction: Option<TokenReductionOptions>,
            language_detection: Option<LanguageDetectionConfig>,
            pages: Option<PageConfig>,
            keywords: Option<KeywordConfig>,
            postprocessor: Option<PostProcessorConfig>,
            html_options: Option<String>,
            result_format: Option<ResultFormat>,
            output_format: Option<OutputFormat>,
            include_document_structure: Option<bool>,
            layout: Option<LayoutDetectionConfig>,
            timeout_secs: Option<u64>,
            tree_sitter: Option<TreeSitterConfig>,
            structured_extraction: Option<StructuredExtractionConfig>,
        ) -> FileExtractionConfig;
        #[swift_bridge(swift_name = "enableQualityProcessing")]
        fn enable_quality_processing(&self) -> Option<bool>;
        fn ocr(&self) -> Option<OcrConfig>;
        #[swift_bridge(swift_name = "forceOcr")]
        fn force_ocr(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "forceOcrPages")]
        fn force_ocr_pages(&self) -> Option<Vec<u32>>;
        #[swift_bridge(swift_name = "disableOcr")]
        fn disable_ocr(&self) -> Option<bool>;
        fn chunking(&self) -> Option<ChunkingConfig>;
        #[swift_bridge(swift_name = "contentFilter")]
        fn content_filter(&self) -> Option<ContentFilterConfig>;
        fn images(&self) -> Option<ImageExtractionConfig>;
        #[swift_bridge(swift_name = "pdfOptions")]
        fn pdf_options(&self) -> Option<PdfConfig>;
        #[swift_bridge(swift_name = "tokenReduction")]
        fn token_reduction(&self) -> Option<TokenReductionOptions>;
        #[swift_bridge(swift_name = "languageDetection")]
        fn language_detection(&self) -> Option<LanguageDetectionConfig>;
        fn pages(&self) -> Option<PageConfig>;
        fn keywords(&self) -> Option<KeywordConfig>;
        fn postprocessor(&self) -> Option<PostProcessorConfig>;
        #[swift_bridge(swift_name = "htmlOptions")]
        fn html_options(&self) -> Option<String>;
        #[swift_bridge(swift_name = "resultFormat")]
        fn result_format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "includeDocumentStructure")]
        fn include_document_structure(&self) -> Option<bool>;
        fn layout(&self) -> Option<LayoutDetectionConfig>;
        #[swift_bridge(swift_name = "timeoutSecs")]
        fn timeout_secs(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "treeSitter")]
        fn tree_sitter(&self) -> Option<TreeSitterConfig>;
        #[swift_bridge(swift_name = "structuredExtraction")]
        fn structured_extraction(&self) -> Option<StructuredExtractionConfig>;
    }

    extern "Rust" {
        type BatchBytesItem;
        fn content(&self) -> Vec<u8>;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
        fn config(&self) -> Option<FileExtractionConfig>;
    }

    extern "Rust" {
        type BatchFileItem;
        fn path(&self) -> String;
        fn config(&self) -> Option<FileExtractionConfig>;
    }

    extern "Rust" {
        type ImageExtractionConfig;
        #[swift_bridge(init)]
        fn new(
            extract_images: bool,
            target_dpi: i32,
            max_image_dimension: i32,
            inject_placeholders: bool,
            auto_adjust_dpi: bool,
            min_dpi: i32,
            max_dpi: i32,
            max_images_per_page: Option<u32>,
            classify: bool,
            include_page_rasters: bool,
            run_ocr_on_images: bool,
            ocr_text_only: bool,
            append_ocr_text: bool,
        ) -> ImageExtractionConfig;
        #[swift_bridge(swift_name = "extractImages")]
        fn extract_images(&self) -> bool;
        #[swift_bridge(swift_name = "targetDpi")]
        fn target_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "maxImageDimension")]
        fn max_image_dimension(&self) -> i32;
        #[swift_bridge(swift_name = "injectPlaceholders")]
        fn inject_placeholders(&self) -> bool;
        #[swift_bridge(swift_name = "autoAdjustDpi")]
        fn auto_adjust_dpi(&self) -> bool;
        #[swift_bridge(swift_name = "minDpi")]
        fn min_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "maxDpi")]
        fn max_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "maxImagesPerPage")]
        fn max_images_per_page(&self) -> Option<u32>;
        fn classify(&self) -> bool;
        #[swift_bridge(swift_name = "includePageRasters")]
        fn include_page_rasters(&self) -> bool;
        #[swift_bridge(swift_name = "runOcrOnImages")]
        fn run_ocr_on_images(&self) -> bool;
        #[swift_bridge(swift_name = "ocrTextOnly")]
        fn ocr_text_only(&self) -> bool;
        #[swift_bridge(swift_name = "appendOcrText")]
        fn append_ocr_text(&self) -> bool;
    }

    extern "Rust" {
        type TokenReductionOptions;
        #[swift_bridge(init)]
        fn new(mode: String, preserve_important_words: bool) -> TokenReductionOptions;
        fn mode(&self) -> String;
        #[swift_bridge(swift_name = "preserveImportantWords")]
        fn preserve_important_words(&self) -> bool;
    }

    extern "Rust" {
        type LanguageDetectionConfig;
        #[swift_bridge(init)]
        fn new(enabled: bool, min_confidence: f64, detect_multiple: bool) -> LanguageDetectionConfig;
        fn enabled(&self) -> bool;
        #[swift_bridge(swift_name = "minConfidence")]
        fn min_confidence(&self) -> f64;
        #[swift_bridge(swift_name = "detectMultiple")]
        fn detect_multiple(&self) -> bool;
    }

    extern "Rust" {
        type HtmlOutputConfig;
        #[swift_bridge(init)]
        fn new(
            css: Option<String>,
            css_file: Option<String>,
            theme: HtmlTheme,
            class_prefix: String,
            embed_css: bool,
        ) -> HtmlOutputConfig;
        fn css(&self) -> Option<String>;
        #[swift_bridge(swift_name = "cssFile")]
        fn css_file(&self) -> Option<String>;
        fn theme(&self) -> String;
        #[swift_bridge(swift_name = "classPrefix")]
        fn class_prefix(&self) -> String;
        #[swift_bridge(swift_name = "embedCss")]
        fn embed_css(&self) -> bool;
    }

    extern "Rust" {
        type LayoutDetectionConfig;
        #[swift_bridge(init)]
        fn new(
            confidence_threshold: Option<f32>,
            apply_heuristics: bool,
            table_model: TableModel,
            acceleration: Option<AccelerationConfig>,
        ) -> LayoutDetectionConfig;
        #[swift_bridge(swift_name = "confidenceThreshold")]
        fn confidence_threshold(&self) -> Option<f32>;
        #[swift_bridge(swift_name = "applyHeuristics")]
        fn apply_heuristics(&self) -> bool;
        #[swift_bridge(swift_name = "tableModel")]
        fn table_model(&self) -> String;
        fn acceleration(&self) -> Option<AccelerationConfig>;
    }

    extern "Rust" {
        type LlmConfig;
        #[swift_bridge(init)]
        fn new(
            model: String,
            api_key: Option<String>,
            base_url: Option<String>,
            timeout_secs: Option<u64>,
            max_retries: Option<u32>,
            temperature: Option<f64>,
            max_tokens: Option<u64>,
        ) -> LlmConfig;
        fn model(&self) -> String;
        #[swift_bridge(swift_name = "apiKey")]
        fn api_key(&self) -> Option<String>;
        #[swift_bridge(swift_name = "baseUrl")]
        fn base_url(&self) -> Option<String>;
        #[swift_bridge(swift_name = "timeoutSecs")]
        fn timeout_secs(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "maxRetries")]
        fn max_retries(&self) -> Option<u32>;
        fn temperature(&self) -> Option<f64>;
        #[swift_bridge(swift_name = "maxTokens")]
        fn max_tokens(&self) -> Option<u64>;
    }

    extern "Rust" {
        type StructuredExtractionConfig;
        fn schema(&self) -> String;
        #[swift_bridge(swift_name = "schemaName")]
        fn schema_name(&self) -> String;
        #[swift_bridge(swift_name = "schemaDescription")]
        fn schema_description(&self) -> Option<String>;
        fn strict(&self) -> bool;
        fn prompt(&self) -> Option<String>;
        fn llm(&self) -> LlmConfig;
    }

    extern "Rust" {
        type OcrQualityThresholds;
        #[swift_bridge(init)]
        fn new(
            min_total_non_whitespace: usize,
            min_non_whitespace_per_page: f64,
            min_meaningful_word_len: usize,
            min_meaningful_words: usize,
            min_alnum_ratio: f64,
            min_garbage_chars: usize,
            max_fragmented_word_ratio: f64,
            critical_fragmented_word_ratio: f64,
            min_avg_word_length: f64,
            min_words_for_avg_length_check: usize,
            min_consecutive_repeat_ratio: f64,
            min_words_for_repeat_check: usize,
            substantive_min_chars: usize,
            non_text_min_chars: usize,
            alnum_ws_ratio_threshold: f64,
            pipeline_min_quality: f64,
        ) -> OcrQualityThresholds;
        #[swift_bridge(swift_name = "minTotalNonWhitespace")]
        fn min_total_non_whitespace(&self) -> usize;
        #[swift_bridge(swift_name = "minNonWhitespacePerPage")]
        fn min_non_whitespace_per_page(&self) -> f64;
        #[swift_bridge(swift_name = "minMeaningfulWordLen")]
        fn min_meaningful_word_len(&self) -> usize;
        #[swift_bridge(swift_name = "minMeaningfulWords")]
        fn min_meaningful_words(&self) -> usize;
        #[swift_bridge(swift_name = "minAlnumRatio")]
        fn min_alnum_ratio(&self) -> f64;
        #[swift_bridge(swift_name = "minGarbageChars")]
        fn min_garbage_chars(&self) -> usize;
        #[swift_bridge(swift_name = "maxFragmentedWordRatio")]
        fn max_fragmented_word_ratio(&self) -> f64;
        #[swift_bridge(swift_name = "criticalFragmentedWordRatio")]
        fn critical_fragmented_word_ratio(&self) -> f64;
        #[swift_bridge(swift_name = "minAvgWordLength")]
        fn min_avg_word_length(&self) -> f64;
        #[swift_bridge(swift_name = "minWordsForAvgLengthCheck")]
        fn min_words_for_avg_length_check(&self) -> usize;
        #[swift_bridge(swift_name = "minConsecutiveRepeatRatio")]
        fn min_consecutive_repeat_ratio(&self) -> f64;
        #[swift_bridge(swift_name = "minWordsForRepeatCheck")]
        fn min_words_for_repeat_check(&self) -> usize;
        #[swift_bridge(swift_name = "substantiveMinChars")]
        fn substantive_min_chars(&self) -> usize;
        #[swift_bridge(swift_name = "nonTextMinChars")]
        fn non_text_min_chars(&self) -> usize;
        #[swift_bridge(swift_name = "alnumWsRatioThreshold")]
        fn alnum_ws_ratio_threshold(&self) -> f64;
        #[swift_bridge(swift_name = "pipelineMinQuality")]
        fn pipeline_min_quality(&self) -> f64;
    }

    extern "Rust" {
        type OcrPipelineStage;
        fn backend(&self) -> String;
        fn priority(&self) -> u32;
        fn language(&self) -> Option<String>;
        #[swift_bridge(swift_name = "tesseractConfig")]
        fn tesseract_config(&self) -> Option<TesseractConfig>;
        #[swift_bridge(swift_name = "paddleOcrConfig")]
        fn paddle_ocr_config(&self) -> Option<String>;
        #[swift_bridge(swift_name = "vlmConfig")]
        fn vlm_config(&self) -> Option<LlmConfig>;
        #[swift_bridge(swift_name = "backendOptions")]
        fn backend_options(&self) -> Option<String>;
    }

    extern "Rust" {
        type OcrPipelineConfig;
        fn stages(&self) -> Vec<OcrPipelineStage>;
        #[swift_bridge(swift_name = "qualityThresholds")]
        fn quality_thresholds(&self) -> OcrQualityThresholds;
    }

    extern "Rust" {
        type OcrConfig;
        #[swift_bridge(init)]
        fn new(
            enabled: bool,
            backend: String,
            language: String,
            tesseract_config: Option<TesseractConfig>,
            output_format: Option<OutputFormat>,
            paddle_ocr_config: Option<String>,
            backend_options: Option<String>,
            element_config: Option<OcrElementConfig>,
            quality_thresholds: Option<OcrQualityThresholds>,
            pipeline: Option<OcrPipelineConfig>,
            auto_rotate: bool,
            vlm_config: Option<LlmConfig>,
            vlm_prompt: Option<String>,
            acceleration: Option<AccelerationConfig>,
            tessdata_bytes: String,
        ) -> OcrConfig;
        fn enabled(&self) -> bool;
        fn backend(&self) -> String;
        fn language(&self) -> String;
        #[swift_bridge(swift_name = "tesseractConfig")]
        fn tesseract_config(&self) -> Option<TesseractConfig>;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "paddleOcrConfig")]
        fn paddle_ocr_config(&self) -> Option<String>;
        #[swift_bridge(swift_name = "backendOptions")]
        fn backend_options(&self) -> Option<String>;
        #[swift_bridge(swift_name = "elementConfig")]
        fn element_config(&self) -> Option<OcrElementConfig>;
        #[swift_bridge(swift_name = "qualityThresholds")]
        fn quality_thresholds(&self) -> Option<OcrQualityThresholds>;
        fn pipeline(&self) -> Option<OcrPipelineConfig>;
        #[swift_bridge(swift_name = "autoRotate")]
        fn auto_rotate(&self) -> bool;
        #[swift_bridge(swift_name = "vlmConfig")]
        fn vlm_config(&self) -> Option<LlmConfig>;
        #[swift_bridge(swift_name = "vlmPrompt")]
        fn vlm_prompt(&self) -> Option<String>;
        fn acceleration(&self) -> Option<AccelerationConfig>;
        #[swift_bridge(swift_name = "tessdataBytes")]
        fn tessdata_bytes(&self) -> String;
    }

    extern "Rust" {
        type PageConfig;
        #[swift_bridge(init)]
        fn new(extract_pages: bool, insert_page_markers: bool, marker_format: String) -> PageConfig;
        #[swift_bridge(swift_name = "extractPages")]
        fn extract_pages(&self) -> bool;
        #[swift_bridge(swift_name = "insertPageMarkers")]
        fn insert_page_markers(&self) -> bool;
        #[swift_bridge(swift_name = "markerFormat")]
        fn marker_format(&self) -> String;
    }

    extern "Rust" {
        type PdfConfig;
        #[swift_bridge(init)]
        fn new(
            extract_images: bool,
            extract_tables: bool,
            passwords: Option<Vec<String>>,
            extract_metadata: bool,
            hierarchy: Option<HierarchyConfig>,
            extract_annotations: bool,
            top_margin_fraction: Option<f32>,
            bottom_margin_fraction: Option<f32>,
            allow_single_column_tables: bool,
            ocr_inline_images: bool,
        ) -> PdfConfig;
        #[swift_bridge(swift_name = "extractImages")]
        fn extract_images(&self) -> bool;
        #[swift_bridge(swift_name = "extractTables")]
        fn extract_tables(&self) -> bool;
        fn passwords(&self) -> Option<Vec<String>>;
        #[swift_bridge(swift_name = "extractMetadata")]
        fn extract_metadata(&self) -> bool;
        fn hierarchy(&self) -> Option<HierarchyConfig>;
        #[swift_bridge(swift_name = "extractAnnotations")]
        fn extract_annotations(&self) -> bool;
        #[swift_bridge(swift_name = "topMarginFraction")]
        fn top_margin_fraction(&self) -> Option<f32>;
        #[swift_bridge(swift_name = "bottomMarginFraction")]
        fn bottom_margin_fraction(&self) -> Option<f32>;
        #[swift_bridge(swift_name = "allowSingleColumnTables")]
        fn allow_single_column_tables(&self) -> bool;
        #[swift_bridge(swift_name = "ocrInlineImages")]
        fn ocr_inline_images(&self) -> bool;
    }

    extern "Rust" {
        type HierarchyConfig;
        #[swift_bridge(init)]
        fn new(
            enabled: bool,
            k_clusters: usize,
            include_bbox: bool,
            ocr_coverage_threshold: Option<f32>,
        ) -> HierarchyConfig;
        fn enabled(&self) -> bool;
        #[swift_bridge(swift_name = "kClusters")]
        fn k_clusters(&self) -> usize;
        #[swift_bridge(swift_name = "includeBbox")]
        fn include_bbox(&self) -> bool;
        #[swift_bridge(swift_name = "ocrCoverageThreshold")]
        fn ocr_coverage_threshold(&self) -> Option<f32>;
    }

    extern "Rust" {
        type PostProcessorConfig;
        #[swift_bridge(init)]
        fn new(
            enabled: bool,
            enabled_processors: Option<Vec<String>>,
            disabled_processors: Option<Vec<String>>,
            enabled_set: Option<Vec<String>>,
            disabled_set: Option<Vec<String>>,
        ) -> PostProcessorConfig;
        fn enabled(&self) -> bool;
        #[swift_bridge(swift_name = "enabledProcessors")]
        fn enabled_processors(&self) -> Option<Vec<String>>;
        #[swift_bridge(swift_name = "disabledProcessors")]
        fn disabled_processors(&self) -> Option<Vec<String>>;
        #[swift_bridge(swift_name = "enabledSet")]
        fn enabled_set(&self) -> Option<Vec<String>>;
        #[swift_bridge(swift_name = "disabledSet")]
        fn disabled_set(&self) -> Option<Vec<String>>;
    }

    extern "Rust" {
        type ChunkingConfig;
        #[swift_bridge(init)]
        fn new(
            max_characters: usize,
            overlap: usize,
            trim: bool,
            chunker_type: ChunkerType,
            embedding: Option<EmbeddingConfig>,
            preset: Option<String>,
            sizing: ChunkSizing,
            prepend_heading_context: bool,
            topic_threshold: Option<f32>,
        ) -> ChunkingConfig;
        #[swift_bridge(swift_name = "maxCharacters")]
        fn max_characters(&self) -> usize;
        fn overlap(&self) -> usize;
        fn trim(&self) -> bool;
        #[swift_bridge(swift_name = "chunkerType")]
        fn chunker_type(&self) -> String;
        fn embedding(&self) -> Option<EmbeddingConfig>;
        fn preset(&self) -> Option<String>;
        fn sizing(&self) -> String;
        #[swift_bridge(swift_name = "prependHeadingContext")]
        fn prepend_heading_context(&self) -> bool;
        #[swift_bridge(swift_name = "topicThreshold")]
        fn topic_threshold(&self) -> Option<f32>;
    }

    extern "Rust" {
        type EmbeddingConfig;
        #[swift_bridge(init)]
        fn new(
            model: EmbeddingModelType,
            normalize: bool,
            batch_size: usize,
            show_download_progress: bool,
            cache_dir: Option<String>,
            acceleration: Option<AccelerationConfig>,
            max_embed_duration_secs: Option<u64>,
        ) -> EmbeddingConfig;
        fn model(&self) -> String;
        fn normalize(&self) -> bool;
        #[swift_bridge(swift_name = "batchSize")]
        fn batch_size(&self) -> usize;
        #[swift_bridge(swift_name = "showDownloadProgress")]
        fn show_download_progress(&self) -> bool;
        #[swift_bridge(swift_name = "cacheDir")]
        fn cache_dir(&self) -> Option<String>;
        fn acceleration(&self) -> Option<AccelerationConfig>;
        #[swift_bridge(swift_name = "maxEmbedDurationSecs")]
        fn max_embed_duration_secs(&self) -> Option<u64>;
    }

    extern "Rust" {
        type TreeSitterConfig;
        #[swift_bridge(init)]
        fn new(
            enabled: bool,
            cache_dir: Option<String>,
            languages: Option<Vec<String>>,
            groups: Option<Vec<String>>,
            process: TreeSitterProcessConfig,
        ) -> TreeSitterConfig;
        fn enabled(&self) -> bool;
        #[swift_bridge(swift_name = "cacheDir")]
        fn cache_dir(&self) -> Option<String>;
        fn languages(&self) -> Option<Vec<String>>;
        fn groups(&self) -> Option<Vec<String>>;
        fn process(&self) -> TreeSitterProcessConfig;
    }

    extern "Rust" {
        type TreeSitterProcessConfig;
        #[swift_bridge(init)]
        fn new(
            structure: bool,
            imports: bool,
            exports: bool,
            comments: bool,
            docstrings: bool,
            symbols: bool,
            diagnostics: bool,
            chunk_max_size: Option<usize>,
            content_mode: CodeContentMode,
        ) -> TreeSitterProcessConfig;
        fn structure(&self) -> bool;
        fn imports(&self) -> bool;
        fn exports(&self) -> bool;
        fn comments(&self) -> bool;
        fn docstrings(&self) -> bool;
        fn symbols(&self) -> bool;
        fn diagnostics(&self) -> bool;
        #[swift_bridge(swift_name = "chunkMaxSize")]
        fn chunk_max_size(&self) -> Option<usize>;
        #[swift_bridge(swift_name = "contentMode")]
        fn content_mode(&self) -> String;
    }

    extern "Rust" {
        type SupportedFormat;
        fn extension_(&self) -> String;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
    }

    extern "Rust" {
        type ServerConfig;
        #[swift_bridge(init)]
        fn new(
            host: String,
            port: u16,
            cors_origins: Vec<String>,
            max_request_body_bytes: usize,
            max_multipart_field_bytes: usize,
        ) -> ServerConfig;
        fn host(&self) -> String;
        fn port(&self) -> u16;
        #[swift_bridge(swift_name = "corsOrigins")]
        fn cors_origins(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "maxRequestBodyBytes")]
        fn max_request_body_bytes(&self) -> usize;
        #[swift_bridge(swift_name = "maxMultipartFieldBytes")]
        fn max_multipart_field_bytes(&self) -> usize;
    }

    extern "Rust" {
        type StructuredDataResult;
        fn content(&self) -> String;
        fn format(&self) -> String;
        fn metadata(&self) -> String;
        #[swift_bridge(swift_name = "textFields")]
        fn text_fields(&self) -> Vec<String>;
    }

    extern "Rust" {
        type DocxAppProperties;
        #[swift_bridge(init)]
        fn new(
            application: Option<String>,
            app_version: Option<String>,
            template: Option<String>,
            total_time: Option<i32>,
            pages: Option<i32>,
            words: Option<i32>,
            characters: Option<i32>,
            characters_with_spaces: Option<i32>,
            lines: Option<i32>,
            paragraphs: Option<i32>,
            company: Option<String>,
            doc_security: Option<i32>,
            scale_crop: Option<bool>,
            links_up_to_date: Option<bool>,
            shared_doc: Option<bool>,
            hyperlinks_changed: Option<bool>,
        ) -> DocxAppProperties;
        fn application(&self) -> Option<String>;
        #[swift_bridge(swift_name = "appVersion")]
        fn app_version(&self) -> Option<String>;
        fn template(&self) -> Option<String>;
        #[swift_bridge(swift_name = "totalTime")]
        fn total_time(&self) -> Option<i32>;
        fn pages(&self) -> Option<i32>;
        fn words(&self) -> Option<i32>;
        fn characters(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "charactersWithSpaces")]
        fn characters_with_spaces(&self) -> Option<i32>;
        fn lines(&self) -> Option<i32>;
        fn paragraphs(&self) -> Option<i32>;
        fn company(&self) -> Option<String>;
        #[swift_bridge(swift_name = "docSecurity")]
        fn doc_security(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "scaleCrop")]
        fn scale_crop(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "linksUpToDate")]
        fn links_up_to_date(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "sharedDoc")]
        fn shared_doc(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "hyperlinksChanged")]
        fn hyperlinks_changed(&self) -> Option<bool>;
    }

    extern "Rust" {
        type XlsxAppProperties;
        #[swift_bridge(init)]
        fn new(
            application: Option<String>,
            app_version: Option<String>,
            doc_security: Option<i32>,
            scale_crop: Option<bool>,
            links_up_to_date: Option<bool>,
            shared_doc: Option<bool>,
            hyperlinks_changed: Option<bool>,
            company: Option<String>,
            worksheet_names: Vec<String>,
        ) -> XlsxAppProperties;
        fn application(&self) -> Option<String>;
        #[swift_bridge(swift_name = "appVersion")]
        fn app_version(&self) -> Option<String>;
        #[swift_bridge(swift_name = "docSecurity")]
        fn doc_security(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "scaleCrop")]
        fn scale_crop(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "linksUpToDate")]
        fn links_up_to_date(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "sharedDoc")]
        fn shared_doc(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "hyperlinksChanged")]
        fn hyperlinks_changed(&self) -> Option<bool>;
        fn company(&self) -> Option<String>;
        #[swift_bridge(swift_name = "worksheetNames")]
        fn worksheet_names(&self) -> Vec<String>;
    }

    extern "Rust" {
        type PptxAppProperties;
        #[swift_bridge(init)]
        fn new(
            application: Option<String>,
            app_version: Option<String>,
            total_time: Option<i32>,
            company: Option<String>,
            doc_security: Option<i32>,
            scale_crop: Option<bool>,
            links_up_to_date: Option<bool>,
            shared_doc: Option<bool>,
            hyperlinks_changed: Option<bool>,
            slides: Option<i32>,
            notes: Option<i32>,
            hidden_slides: Option<i32>,
            multimedia_clips: Option<i32>,
            presentation_format: Option<String>,
            slide_titles: Vec<String>,
        ) -> PptxAppProperties;
        fn application(&self) -> Option<String>;
        #[swift_bridge(swift_name = "appVersion")]
        fn app_version(&self) -> Option<String>;
        #[swift_bridge(swift_name = "totalTime")]
        fn total_time(&self) -> Option<i32>;
        fn company(&self) -> Option<String>;
        #[swift_bridge(swift_name = "docSecurity")]
        fn doc_security(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "scaleCrop")]
        fn scale_crop(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "linksUpToDate")]
        fn links_up_to_date(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "sharedDoc")]
        fn shared_doc(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "hyperlinksChanged")]
        fn hyperlinks_changed(&self) -> Option<bool>;
        fn slides(&self) -> Option<i32>;
        fn notes(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "hiddenSlides")]
        fn hidden_slides(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "multimediaClips")]
        fn multimedia_clips(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "presentationFormat")]
        fn presentation_format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "slideTitles")]
        fn slide_titles(&self) -> Vec<String>;
    }

    extern "Rust" {
        type CoreProperties;
        #[swift_bridge(init)]
        fn new(
            title: Option<String>,
            subject: Option<String>,
            creator: Option<String>,
            keywords: Option<String>,
            description: Option<String>,
            last_modified_by: Option<String>,
            revision: Option<String>,
            created: Option<String>,
            modified: Option<String>,
            category: Option<String>,
            content_status: Option<String>,
            language: Option<String>,
            identifier: Option<String>,
            version: Option<String>,
            last_printed: Option<String>,
        ) -> CoreProperties;
        fn title(&self) -> Option<String>;
        fn subject(&self) -> Option<String>;
        fn creator(&self) -> Option<String>;
        fn keywords(&self) -> Option<String>;
        fn description(&self) -> Option<String>;
        #[swift_bridge(swift_name = "lastModifiedBy")]
        fn last_modified_by(&self) -> Option<String>;
        fn revision(&self) -> Option<String>;
        fn created(&self) -> Option<String>;
        fn modified(&self) -> Option<String>;
        fn category(&self) -> Option<String>;
        #[swift_bridge(swift_name = "contentStatus")]
        fn content_status(&self) -> Option<String>;
        fn language(&self) -> Option<String>;
        fn identifier(&self) -> Option<String>;
        fn version(&self) -> Option<String>;
        #[swift_bridge(swift_name = "lastPrinted")]
        fn last_printed(&self) -> Option<String>;
    }

    extern "Rust" {
        type SecurityLimits;
        #[swift_bridge(init)]
        fn new(
            max_archive_size: usize,
            max_compression_ratio: usize,
            max_files_in_archive: usize,
            max_nesting_depth: usize,
            max_entity_length: usize,
            max_content_size: usize,
            max_iterations: usize,
            max_xml_depth: usize,
            max_table_cells: usize,
        ) -> SecurityLimits;
        #[swift_bridge(swift_name = "maxArchiveSize")]
        fn max_archive_size(&self) -> usize;
        #[swift_bridge(swift_name = "maxCompressionRatio")]
        fn max_compression_ratio(&self) -> usize;
        #[swift_bridge(swift_name = "maxFilesInArchive")]
        fn max_files_in_archive(&self) -> usize;
        #[swift_bridge(swift_name = "maxNestingDepth")]
        fn max_nesting_depth(&self) -> usize;
        #[swift_bridge(swift_name = "maxEntityLength")]
        fn max_entity_length(&self) -> usize;
        #[swift_bridge(swift_name = "maxContentSize")]
        fn max_content_size(&self) -> usize;
        #[swift_bridge(swift_name = "maxIterations")]
        fn max_iterations(&self) -> usize;
        #[swift_bridge(swift_name = "maxXmlDepth")]
        fn max_xml_depth(&self) -> usize;
        #[swift_bridge(swift_name = "maxTableCells")]
        fn max_table_cells(&self) -> usize;
    }

    extern "Rust" {
        type TokenReductionConfig;
        #[swift_bridge(init)]
        fn new(
            level: ReductionLevel,
            language_hint: Option<String>,
            preserve_markdown: bool,
            preserve_code: bool,
            semantic_threshold: f32,
            enable_parallel: bool,
            use_simd: bool,
            custom_stopwords: String,
            preserve_patterns: Vec<String>,
            target_reduction: Option<f32>,
            enable_semantic_clustering: bool,
        ) -> TokenReductionConfig;
        fn level(&self) -> String;
        #[swift_bridge(swift_name = "languageHint")]
        fn language_hint(&self) -> Option<String>;
        #[swift_bridge(swift_name = "preserveMarkdown")]
        fn preserve_markdown(&self) -> bool;
        #[swift_bridge(swift_name = "preserveCode")]
        fn preserve_code(&self) -> bool;
        #[swift_bridge(swift_name = "semanticThreshold")]
        fn semantic_threshold(&self) -> f32;
        #[swift_bridge(swift_name = "enableParallel")]
        fn enable_parallel(&self) -> bool;
        #[swift_bridge(swift_name = "useSimd")]
        fn use_simd(&self) -> bool;
        #[swift_bridge(swift_name = "customStopwords")]
        fn custom_stopwords(&self) -> String;
        #[swift_bridge(swift_name = "preservePatterns")]
        fn preserve_patterns(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "targetReduction")]
        fn target_reduction(&self) -> Option<f32>;
        #[swift_bridge(swift_name = "enableSemanticClustering")]
        fn enable_semantic_clustering(&self) -> bool;
    }

    extern "Rust" {
        type PdfAnnotation;
        #[swift_bridge(swift_name = "annotationType")]
        fn annotation_type(&self) -> String;
        fn content(&self) -> Option<String>;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
        #[swift_bridge(swift_name = "boundingBox")]
        fn bounding_box(&self) -> Option<BoundingBox>;
    }

    extern "Rust" {
        type DjotContent;
        #[swift_bridge(swift_name = "plainText")]
        fn plain_text(&self) -> String;
        fn blocks(&self) -> Vec<FormattedBlock>;
        fn metadata(&self) -> Metadata;
        fn tables(&self) -> Vec<Table>;
        fn images(&self) -> Vec<DjotImage>;
        fn links(&self) -> Vec<DjotLink>;
        fn footnotes(&self) -> Vec<Footnote>;
    }

    extern "Rust" {
        type FormattedBlock;
        #[swift_bridge(swift_name = "blockType")]
        fn block_type(&self) -> String;
        fn level(&self) -> Option<usize>;
        #[swift_bridge(swift_name = "inlineContent")]
        fn inline_content(&self) -> Vec<InlineElement>;
        fn attributes(&self) -> Option<String>;
        fn language(&self) -> Option<String>;
        fn code(&self) -> Option<String>;
        fn children(&self) -> Vec<FormattedBlock>;
    }

    extern "Rust" {
        type InlineElement;
        #[swift_bridge(swift_name = "elementType")]
        fn element_type(&self) -> String;
        fn content(&self) -> String;
        fn attributes(&self) -> Option<String>;
        fn metadata(&self) -> String;
    }

    extern "Rust" {
        type DjotImage;
        fn src(&self) -> String;
        fn alt(&self) -> String;
        fn title(&self) -> Option<String>;
        fn attributes(&self) -> Option<String>;
    }

    extern "Rust" {
        type DjotLink;
        fn url(&self) -> String;
        fn text(&self) -> String;
        fn title(&self) -> Option<String>;
        fn attributes(&self) -> Option<String>;
    }

    extern "Rust" {
        type Footnote;
        fn label(&self) -> String;
        fn content(&self) -> Vec<FormattedBlock>;
    }

    extern "Rust" {
        type DocumentStructure;
        #[swift_bridge(init)]
        fn new(
            nodes: Vec<DocumentNode>,
            source_format: Option<String>,
            relationships: Vec<DocumentRelationship>,
            node_types: Vec<String>,
        ) -> DocumentStructure;
        fn nodes(&self) -> Vec<DocumentNode>;
        #[swift_bridge(swift_name = "sourceFormat")]
        fn source_format(&self) -> Option<String>;
        fn relationships(&self) -> Vec<DocumentRelationship>;
        #[swift_bridge(swift_name = "nodeTypes")]
        fn node_types(&self) -> Vec<String>;
    }

    extern "Rust" {
        type DocumentRelationship;
        fn source(&self) -> u32;
        fn target(&self) -> u32;
        fn kind(&self) -> String;
    }

    extern "Rust" {
        type DocumentNode;
        fn id(&self) -> String;
        fn content(&self) -> String;
        fn parent(&self) -> Option<u32>;
        fn children(&self) -> Vec<u32>;
        #[swift_bridge(swift_name = "contentLayer")]
        fn content_layer(&self) -> String;
        fn page(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "pageEnd")]
        fn page_end(&self) -> Option<u32>;
        fn bbox(&self) -> Option<BoundingBox>;
        fn annotations(&self) -> Vec<TextAnnotation>;
        fn attributes(&self) -> String;
    }

    extern "Rust" {
        type TableGrid;
        #[swift_bridge(init)]
        fn new(rows: u32, cols: u32, cells: Vec<GridCell>) -> TableGrid;
        fn rows(&self) -> u32;
        fn cols(&self) -> u32;
        fn cells(&self) -> Vec<GridCell>;
    }

    extern "Rust" {
        type GridCell;
        fn content(&self) -> String;
        fn row(&self) -> u32;
        fn col(&self) -> u32;
        #[swift_bridge(swift_name = "rowSpan")]
        fn row_span(&self) -> u32;
        #[swift_bridge(swift_name = "colSpan")]
        fn col_span(&self) -> u32;
        #[swift_bridge(swift_name = "isHeader")]
        fn is_header(&self) -> bool;
        fn bbox(&self) -> Option<BoundingBox>;
    }

    extern "Rust" {
        type TextAnnotation;
        fn start(&self) -> u32;
        fn end(&self) -> u32;
        fn kind(&self) -> String;
    }

    extern "Rust" {
        type ExtractionResult;
        #[swift_bridge(init)]
        fn new(
            content: String,
            mime_type: String,
            metadata: Metadata,
            extraction_method: Option<ExtractionMethod>,
            tables: Vec<Table>,
            detected_languages: Option<Vec<String>>,
            chunks: Option<Vec<Chunk>>,
            images: Option<Vec<ExtractedImage>>,
            pages: Option<Vec<PageContent>>,
            elements: Option<Vec<Element>>,
            djot_content: Option<DjotContent>,
            ocr_elements: Option<Vec<OcrElement>>,
            document: Option<DocumentStructure>,
            extracted_keywords: Option<Vec<Keyword>>,
            quality_score: Option<f64>,
            processing_warnings: Vec<ProcessingWarning>,
            annotations: Option<Vec<PdfAnnotation>>,
            children: Option<Vec<ArchiveEntry>>,
            uris: Option<Vec<ExtractedUri>>,
            revisions: Option<Vec<DocumentRevision>>,
            structured_output: Option<String>,
            code_intelligence: Option<String>,
            llm_usage: Option<Vec<LlmUsage>>,
            formatted_content: Option<String>,
        ) -> ExtractionResult;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
        fn metadata(&self) -> Metadata;
        #[swift_bridge(swift_name = "extractionMethod")]
        fn extraction_method(&self) -> Option<String>;
        fn tables(&self) -> Vec<Table>;
        #[swift_bridge(swift_name = "detectedLanguages")]
        fn detected_languages(&self) -> Option<Vec<String>>;
        fn chunks(&self) -> Option<Vec<Chunk>>;
        fn images(&self) -> Option<Vec<ExtractedImage>>;
        fn pages(&self) -> Option<Vec<PageContent>>;
        fn elements(&self) -> Option<Vec<Element>>;
        #[swift_bridge(swift_name = "djotContent")]
        fn djot_content(&self) -> Option<DjotContent>;
        #[swift_bridge(swift_name = "ocrElements")]
        fn ocr_elements(&self) -> Option<Vec<OcrElement>>;
        fn document(&self) -> Option<DocumentStructure>;
        #[swift_bridge(swift_name = "extractedKeywords")]
        fn extracted_keywords(&self) -> Option<Vec<Keyword>>;
        #[swift_bridge(swift_name = "qualityScore")]
        fn quality_score(&self) -> Option<f64>;
        #[swift_bridge(swift_name = "processingWarnings")]
        fn processing_warnings(&self) -> Vec<ProcessingWarning>;
        fn annotations(&self) -> Option<Vec<PdfAnnotation>>;
        fn children(&self) -> Option<Vec<ArchiveEntry>>;
        fn uris(&self) -> Option<Vec<ExtractedUri>>;
        fn revisions(&self) -> Option<Vec<DocumentRevision>>;
        #[swift_bridge(swift_name = "structuredOutput")]
        fn structured_output(&self) -> Option<String>;
        #[swift_bridge(swift_name = "codeIntelligence")]
        fn code_intelligence(&self) -> Option<String>;
        #[swift_bridge(swift_name = "llmUsage")]
        fn llm_usage(&self) -> Option<Vec<LlmUsage>>;
        #[swift_bridge(swift_name = "formattedContent")]
        fn formatted_content(&self) -> Option<String>;
    }

    extern "Rust" {
        type ArchiveEntry;
        fn path(&self) -> String;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
        fn result(&self) -> ExtractionResult;
    }

    extern "Rust" {
        type ProcessingWarning;
        fn source(&self) -> String;
        fn message(&self) -> String;
    }

    extern "Rust" {
        type LlmUsage;
        #[swift_bridge(init)]
        fn new(
            model: String,
            source: String,
            input_tokens: Option<u64>,
            output_tokens: Option<u64>,
            total_tokens: Option<u64>,
            estimated_cost: Option<f64>,
            finish_reason: Option<String>,
        ) -> LlmUsage;
        fn model(&self) -> String;
        fn source(&self) -> String;
        #[swift_bridge(swift_name = "inputTokens")]
        fn input_tokens(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "outputTokens")]
        fn output_tokens(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "totalTokens")]
        fn total_tokens(&self) -> Option<u64>;
        #[swift_bridge(swift_name = "estimatedCost")]
        fn estimated_cost(&self) -> Option<f64>;
        #[swift_bridge(swift_name = "finishReason")]
        fn finish_reason(&self) -> Option<String>;
    }

    extern "Rust" {
        type Chunk;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "chunkType")]
        fn chunk_type(&self) -> String;
        fn embedding(&self) -> Option<Vec<f32>>;
        fn metadata(&self) -> ChunkMetadata;
    }

    extern "Rust" {
        type HeadingContext;
        fn headings(&self) -> Vec<HeadingLevel>;
    }

    extern "Rust" {
        type HeadingLevel;
        fn level(&self) -> u8;
        fn text(&self) -> String;
    }

    extern "Rust" {
        type ChunkMetadata;
        #[swift_bridge(swift_name = "byteStart")]
        fn byte_start(&self) -> usize;
        #[swift_bridge(swift_name = "byteEnd")]
        fn byte_end(&self) -> usize;
        #[swift_bridge(swift_name = "tokenCount")]
        fn token_count(&self) -> Option<usize>;
        #[swift_bridge(swift_name = "chunkIndex")]
        fn chunk_index(&self) -> usize;
        #[swift_bridge(swift_name = "totalChunks")]
        fn total_chunks(&self) -> usize;
        #[swift_bridge(swift_name = "firstPage")]
        fn first_page(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "lastPage")]
        fn last_page(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "headingContext")]
        fn heading_context(&self) -> Option<HeadingContext>;
        #[swift_bridge(swift_name = "imageIndices")]
        fn image_indices(&self) -> Vec<u32>;
    }

    extern "Rust" {
        type ExtractedImage;
        fn data(&self) -> Vec<u8>;
        fn format(&self) -> String;
        #[swift_bridge(swift_name = "imageIndex")]
        fn image_index(&self) -> u32;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> Option<u32>;
        fn width(&self) -> Option<u32>;
        fn height(&self) -> Option<u32>;
        fn colorspace(&self) -> Option<String>;
        #[swift_bridge(swift_name = "bitsPerComponent")]
        fn bits_per_component(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "isMask")]
        fn is_mask(&self) -> bool;
        fn description(&self) -> Option<String>;
        #[swift_bridge(swift_name = "ocrResult")]
        fn ocr_result(&self) -> Option<ExtractionResult>;
        #[swift_bridge(swift_name = "boundingBox")]
        fn bounding_box(&self) -> Option<BoundingBox>;
        #[swift_bridge(swift_name = "sourcePath")]
        fn source_path(&self) -> Option<String>;
        #[swift_bridge(swift_name = "imageKind")]
        fn image_kind(&self) -> Option<String>;
        #[swift_bridge(swift_name = "kindConfidence")]
        fn kind_confidence(&self) -> Option<f32>;
        #[swift_bridge(swift_name = "clusterId")]
        fn cluster_id(&self) -> Option<u32>;
    }

    extern "Rust" {
        type BoundingBox;
        #[swift_bridge(init)]
        fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> BoundingBox;
        fn x0(&self) -> f64;
        fn y0(&self) -> f64;
        fn x1(&self) -> f64;
        fn y1(&self) -> f64;
    }

    extern "Rust" {
        type ElementMetadata;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> Option<u32>;
        fn filename(&self) -> Option<String>;
        fn coordinates(&self) -> Option<BoundingBox>;
        #[swift_bridge(swift_name = "elementIndex")]
        fn element_index(&self) -> Option<usize>;
        fn additional(&self) -> String;
    }

    extern "Rust" {
        type Element;
        #[swift_bridge(swift_name = "elementId")]
        fn element_id(&self) -> String;
        #[swift_bridge(swift_name = "elementType")]
        fn element_type(&self) -> String;
        fn text(&self) -> String;
        fn metadata(&self) -> ElementMetadata;
    }

    extern "Rust" {
        type ExcelWorkbook;
        fn sheets(&self) -> Vec<ExcelSheet>;
        fn metadata(&self) -> String;
        fn revisions(&self) -> Option<Vec<DocumentRevision>>;
    }

    extern "Rust" {
        type ExcelSheet;
        fn name(&self) -> String;
        fn markdown(&self) -> String;
        #[swift_bridge(swift_name = "rowCount")]
        fn row_count(&self) -> usize;
        #[swift_bridge(swift_name = "colCount")]
        fn col_count(&self) -> usize;
        #[swift_bridge(swift_name = "cellCount")]
        fn cell_count(&self) -> usize;
        #[swift_bridge(swift_name = "tableCells")]
        fn table_cells(&self) -> String;
    }

    extern "Rust" {
        type XmlExtractionResult;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "elementCount")]
        fn element_count(&self) -> usize;
        #[swift_bridge(swift_name = "uniqueElements")]
        fn unique_elements(&self) -> Vec<String>;
    }

    extern "Rust" {
        type TextExtractionResult;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "lineCount")]
        fn line_count(&self) -> usize;
        #[swift_bridge(swift_name = "wordCount")]
        fn word_count(&self) -> usize;
        #[swift_bridge(swift_name = "characterCount")]
        fn character_count(&self) -> usize;
        fn headers(&self) -> Option<Vec<String>>;
    }

    extern "Rust" {
        type PptxExtractionResult;
        fn content(&self) -> String;
        fn metadata(&self) -> PptxMetadata;
        #[swift_bridge(swift_name = "slideCount")]
        fn slide_count(&self) -> usize;
        #[swift_bridge(swift_name = "imageCount")]
        fn image_count(&self) -> usize;
        #[swift_bridge(swift_name = "tableCount")]
        fn table_count(&self) -> usize;
        fn images(&self) -> Vec<ExtractedImage>;
        #[swift_bridge(swift_name = "pageStructure")]
        fn page_structure(&self) -> Option<PageStructure>;
        #[swift_bridge(swift_name = "pageContents")]
        fn page_contents(&self) -> Option<Vec<PageContent>>;
        fn document(&self) -> Option<DocumentStructure>;
        #[swift_bridge(swift_name = "officeMetadata")]
        fn office_metadata(&self) -> String;
        fn revisions(&self) -> Option<Vec<DocumentRevision>>;
    }

    extern "Rust" {
        type EmailExtractionResult;
        fn subject(&self) -> Option<String>;
        #[swift_bridge(swift_name = "fromEmail")]
        fn from_email(&self) -> Option<String>;
        #[swift_bridge(swift_name = "toEmails")]
        fn to_emails(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "ccEmails")]
        fn cc_emails(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "bccEmails")]
        fn bcc_emails(&self) -> Vec<String>;
        fn date(&self) -> Option<String>;
        #[swift_bridge(swift_name = "messageId")]
        fn message_id(&self) -> Option<String>;
        #[swift_bridge(swift_name = "plainText")]
        fn plain_text(&self) -> Option<String>;
        #[swift_bridge(swift_name = "htmlContent")]
        fn html_content(&self) -> Option<String>;
        fn content(&self) -> String;
        fn attachments(&self) -> Vec<EmailAttachment>;
        fn metadata(&self) -> String;
    }

    extern "Rust" {
        type EmailAttachment;
        fn name(&self) -> Option<String>;
        fn filename(&self) -> Option<String>;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> Option<String>;
        fn size(&self) -> Option<usize>;
        #[swift_bridge(swift_name = "isImage")]
        fn is_image(&self) -> bool;
        fn data(&self) -> Option<Vec<u8>>;
    }

    extern "Rust" {
        type OcrExtractionResult;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
        fn metadata(&self) -> String;
        fn tables(&self) -> Vec<OcrTable>;
        #[swift_bridge(swift_name = "ocrElements")]
        fn ocr_elements(&self) -> Option<Vec<OcrElement>>;
    }

    extern "Rust" {
        type OcrTable;
        fn cells(&self) -> String;
        fn markdown(&self) -> String;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
        #[swift_bridge(swift_name = "boundingBox")]
        fn bounding_box(&self) -> Option<OcrTableBoundingBox>;
    }

    extern "Rust" {
        type OcrTableBoundingBox;
        #[swift_bridge(init)]
        fn new(left: u32, top: u32, right: u32, bottom: u32) -> OcrTableBoundingBox;
        fn left(&self) -> u32;
        fn top(&self) -> u32;
        fn right(&self) -> u32;
        fn bottom(&self) -> u32;
    }

    extern "Rust" {
        type ImagePreprocessingConfig;
        #[swift_bridge(init)]
        fn new(
            target_dpi: i32,
            auto_rotate: bool,
            deskew: bool,
            denoise: bool,
            contrast_enhance: bool,
            binarization_method: String,
            invert_colors: bool,
        ) -> ImagePreprocessingConfig;
        #[swift_bridge(swift_name = "targetDpi")]
        fn target_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "autoRotate")]
        fn auto_rotate(&self) -> bool;
        fn deskew(&self) -> bool;
        fn denoise(&self) -> bool;
        #[swift_bridge(swift_name = "contrastEnhance")]
        fn contrast_enhance(&self) -> bool;
        #[swift_bridge(swift_name = "binarizationMethod")]
        fn binarization_method(&self) -> String;
        #[swift_bridge(swift_name = "invertColors")]
        fn invert_colors(&self) -> bool;
    }

    extern "Rust" {
        type TesseractConfig;
        #[swift_bridge(init)]
        fn new(
            language: String,
            psm: i32,
            output_format: String,
            oem: i32,
            min_confidence: f64,
            preprocessing: Option<ImagePreprocessingConfig>,
            enable_table_detection: bool,
            table_min_confidence: f64,
            table_column_threshold: i32,
            table_row_threshold_ratio: f64,
            use_cache: bool,
            classify_use_pre_adapted_templates: bool,
            language_model_ngram_on: bool,
            tessedit_dont_blkrej_good_wds: bool,
            tessedit_dont_rowrej_good_wds: bool,
            tessedit_enable_dict_correction: bool,
            tessedit_char_whitelist: String,
            tessedit_char_blacklist: String,
            tessedit_use_primary_params_model: bool,
            textord_space_size_is_variable: bool,
            thresholding_method: bool,
        ) -> TesseractConfig;
        fn language(&self) -> String;
        fn psm(&self) -> i32;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> String;
        fn oem(&self) -> i32;
        #[swift_bridge(swift_name = "minConfidence")]
        fn min_confidence(&self) -> f64;
        fn preprocessing(&self) -> Option<ImagePreprocessingConfig>;
        #[swift_bridge(swift_name = "enableTableDetection")]
        fn enable_table_detection(&self) -> bool;
        #[swift_bridge(swift_name = "tableMinConfidence")]
        fn table_min_confidence(&self) -> f64;
        #[swift_bridge(swift_name = "tableColumnThreshold")]
        fn table_column_threshold(&self) -> i32;
        #[swift_bridge(swift_name = "tableRowThresholdRatio")]
        fn table_row_threshold_ratio(&self) -> f64;
        #[swift_bridge(swift_name = "useCache")]
        fn use_cache(&self) -> bool;
        #[swift_bridge(swift_name = "classifyUsePreAdaptedTemplates")]
        fn classify_use_pre_adapted_templates(&self) -> bool;
        #[swift_bridge(swift_name = "languageModelNgramOn")]
        fn language_model_ngram_on(&self) -> bool;
        #[swift_bridge(swift_name = "tesseditDontBlkrejGoodWds")]
        fn tessedit_dont_blkrej_good_wds(&self) -> bool;
        #[swift_bridge(swift_name = "tesseditDontRowrejGoodWds")]
        fn tessedit_dont_rowrej_good_wds(&self) -> bool;
        #[swift_bridge(swift_name = "tesseditEnableDictCorrection")]
        fn tessedit_enable_dict_correction(&self) -> bool;
        #[swift_bridge(swift_name = "tesseditCharWhitelist")]
        fn tessedit_char_whitelist(&self) -> String;
        #[swift_bridge(swift_name = "tesseditCharBlacklist")]
        fn tessedit_char_blacklist(&self) -> String;
        #[swift_bridge(swift_name = "tesseditUsePrimaryParamsModel")]
        fn tessedit_use_primary_params_model(&self) -> bool;
        #[swift_bridge(swift_name = "textordSpaceSizeIsVariable")]
        fn textord_space_size_is_variable(&self) -> bool;
        #[swift_bridge(swift_name = "thresholdingMethod")]
        fn thresholding_method(&self) -> bool;
    }

    extern "Rust" {
        type ImagePreprocessingMetadata;
        #[swift_bridge(swift_name = "originalDimensions")]
        fn original_dimensions(&self) -> Vec<usize>;
        #[swift_bridge(swift_name = "originalDpi")]
        fn original_dpi(&self) -> Vec<f64>;
        #[swift_bridge(swift_name = "targetDpi")]
        fn target_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "scaleFactor")]
        fn scale_factor(&self) -> f64;
        #[swift_bridge(swift_name = "autoAdjusted")]
        fn auto_adjusted(&self) -> bool;
        #[swift_bridge(swift_name = "finalDpi")]
        fn final_dpi(&self) -> i32;
        #[swift_bridge(swift_name = "newDimensions")]
        fn new_dimensions(&self) -> Option<Vec<usize>>;
        #[swift_bridge(swift_name = "resampleMethod")]
        fn resample_method(&self) -> String;
        #[swift_bridge(swift_name = "dimensionClamped")]
        fn dimension_clamped(&self) -> bool;
        #[swift_bridge(swift_name = "calculatedDpi")]
        fn calculated_dpi(&self) -> Option<i32>;
        #[swift_bridge(swift_name = "skippedResize")]
        fn skipped_resize(&self) -> bool;
        #[swift_bridge(swift_name = "resizeError")]
        fn resize_error(&self) -> Option<String>;
    }

    extern "Rust" {
        type Metadata;
        #[swift_bridge(init)]
        fn new(
            title: Option<String>,
            subject: Option<String>,
            authors: Option<Vec<String>>,
            keywords: Option<Vec<String>>,
            language: Option<String>,
            created_at: Option<String>,
            modified_at: Option<String>,
            created_by: Option<String>,
            modified_by: Option<String>,
            pages: Option<PageStructure>,
            format: Option<FormatMetadata>,
            image_preprocessing: Option<ImagePreprocessingMetadata>,
            json_schema: Option<String>,
            error: Option<ErrorMetadata>,
            extraction_duration_ms: Option<u64>,
            category: Option<String>,
            tags: Option<Vec<String>>,
            document_version: Option<String>,
            abstract_text: Option<String>,
            output_format: Option<String>,
            ocr_used: bool,
            additional: String,
        ) -> Metadata;
        fn title(&self) -> Option<String>;
        fn subject(&self) -> Option<String>;
        fn authors(&self) -> Option<Vec<String>>;
        fn keywords(&self) -> Option<Vec<String>>;
        fn language(&self) -> Option<String>;
        #[swift_bridge(swift_name = "createdAt")]
        fn created_at(&self) -> Option<String>;
        #[swift_bridge(swift_name = "modifiedAt")]
        fn modified_at(&self) -> Option<String>;
        #[swift_bridge(swift_name = "createdBy")]
        fn created_by(&self) -> Option<String>;
        #[swift_bridge(swift_name = "modifiedBy")]
        fn modified_by(&self) -> Option<String>;
        fn pages(&self) -> Option<PageStructure>;
        fn format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "imagePreprocessing")]
        fn image_preprocessing(&self) -> Option<ImagePreprocessingMetadata>;
        #[swift_bridge(swift_name = "jsonSchema")]
        fn json_schema(&self) -> Option<String>;
        fn error(&self) -> Option<ErrorMetadata>;
        #[swift_bridge(swift_name = "extractionDurationMs")]
        fn extraction_duration_ms(&self) -> Option<u64>;
        fn category(&self) -> Option<String>;
        fn tags(&self) -> Option<Vec<String>>;
        #[swift_bridge(swift_name = "documentVersion")]
        fn document_version(&self) -> Option<String>;
        #[swift_bridge(swift_name = "abstractText")]
        fn abstract_text(&self) -> Option<String>;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> Option<String>;
        #[swift_bridge(swift_name = "ocrUsed")]
        fn ocr_used(&self) -> bool;
        fn additional(&self) -> String;
    }

    extern "Rust" {
        type ExcelMetadata;
        #[swift_bridge(init)]
        fn new(sheet_count: Option<u32>, sheet_names: Option<Vec<String>>) -> ExcelMetadata;
        #[swift_bridge(swift_name = "sheetCount")]
        fn sheet_count(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "sheetNames")]
        fn sheet_names(&self) -> Option<Vec<String>>;
    }

    extern "Rust" {
        type EmailMetadata;
        #[swift_bridge(init)]
        fn new(
            from_email: Option<String>,
            from_name: Option<String>,
            to_emails: Vec<String>,
            cc_emails: Vec<String>,
            bcc_emails: Vec<String>,
            message_id: Option<String>,
            attachments: Vec<String>,
        ) -> EmailMetadata;
        #[swift_bridge(swift_name = "fromEmail")]
        fn from_email(&self) -> Option<String>;
        #[swift_bridge(swift_name = "fromName")]
        fn from_name(&self) -> Option<String>;
        #[swift_bridge(swift_name = "toEmails")]
        fn to_emails(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "ccEmails")]
        fn cc_emails(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "bccEmails")]
        fn bcc_emails(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "messageId")]
        fn message_id(&self) -> Option<String>;
        fn attachments(&self) -> Vec<String>;
    }

    extern "Rust" {
        type ArchiveMetadata;
        #[swift_bridge(init)]
        fn new(
            format: String,
            file_count: u32,
            file_list: Vec<String>,
            total_size: u64,
            compressed_size: Option<u64>,
        ) -> ArchiveMetadata;
        fn format(&self) -> String;
        #[swift_bridge(swift_name = "fileCount")]
        fn file_count(&self) -> u32;
        #[swift_bridge(swift_name = "fileList")]
        fn file_list(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "totalSize")]
        fn total_size(&self) -> u64;
        #[swift_bridge(swift_name = "compressedSize")]
        fn compressed_size(&self) -> Option<u64>;
    }

    extern "Rust" {
        type ImageMetadata;
        #[swift_bridge(init)]
        fn new(width: u32, height: u32, format: String, exif: String) -> ImageMetadata;
        fn width(&self) -> u32;
        fn height(&self) -> u32;
        fn format(&self) -> String;
        fn exif(&self) -> String;
    }

    extern "Rust" {
        type XmlMetadata;
        #[swift_bridge(init)]
        fn new(element_count: u32, unique_elements: Vec<String>) -> XmlMetadata;
        #[swift_bridge(swift_name = "elementCount")]
        fn element_count(&self) -> u32;
        #[swift_bridge(swift_name = "uniqueElements")]
        fn unique_elements(&self) -> Vec<String>;
    }

    extern "Rust" {
        type TextMetadata;
        #[swift_bridge(init)]
        fn new(
            line_count: u32,
            word_count: u32,
            character_count: u32,
            headers: Option<Vec<String>>,
            links: String,
            code_blocks: String,
        ) -> TextMetadata;
        #[swift_bridge(swift_name = "lineCount")]
        fn line_count(&self) -> u32;
        #[swift_bridge(swift_name = "wordCount")]
        fn word_count(&self) -> u32;
        #[swift_bridge(swift_name = "characterCount")]
        fn character_count(&self) -> u32;
        fn headers(&self) -> Option<Vec<String>>;
    }

    extern "Rust" {
        type HeaderMetadata;
        fn level(&self) -> u8;
        fn text(&self) -> String;
        fn id(&self) -> Option<String>;
        fn depth(&self) -> u32;
        #[swift_bridge(swift_name = "htmlOffset")]
        fn html_offset(&self) -> u32;
    }

    extern "Rust" {
        type LinkMetadata;
        fn href(&self) -> String;
        fn text(&self) -> String;
        fn title(&self) -> Option<String>;
        #[swift_bridge(swift_name = "linkType")]
        fn link_type(&self) -> String;
        fn rel(&self) -> Vec<String>;
    }

    extern "Rust" {
        type ImageMetadataType;
        fn src(&self) -> String;
        fn alt(&self) -> Option<String>;
        fn title(&self) -> Option<String>;
        fn dimensions(&self) -> Option<Vec<u32>>;
        #[swift_bridge(swift_name = "imageType")]
        fn image_type(&self) -> String;
    }

    extern "Rust" {
        type StructuredData;
        #[swift_bridge(swift_name = "dataType")]
        fn data_type(&self) -> String;
        #[swift_bridge(swift_name = "rawJson")]
        fn raw_json(&self) -> String;
        #[swift_bridge(swift_name = "schemaType")]
        fn schema_type(&self) -> Option<String>;
    }

    extern "Rust" {
        type HtmlMetadata;
        #[swift_bridge(init)]
        fn new(
            title: Option<String>,
            description: Option<String>,
            keywords: Vec<String>,
            author: Option<String>,
            canonical_url: Option<String>,
            base_href: Option<String>,
            language: Option<String>,
            text_direction: Option<TextDirection>,
            open_graph: String,
            twitter_card: String,
            meta_tags: String,
            headers: Vec<HeaderMetadata>,
            links: Vec<LinkMetadata>,
            images: Vec<ImageMetadataType>,
            structured_data: Vec<StructuredData>,
        ) -> HtmlMetadata;
        fn title(&self) -> Option<String>;
        fn description(&self) -> Option<String>;
        fn keywords(&self) -> Vec<String>;
        fn author(&self) -> Option<String>;
        #[swift_bridge(swift_name = "canonicalUrl")]
        fn canonical_url(&self) -> Option<String>;
        #[swift_bridge(swift_name = "baseHref")]
        fn base_href(&self) -> Option<String>;
        fn language(&self) -> Option<String>;
        #[swift_bridge(swift_name = "textDirection")]
        fn text_direction(&self) -> Option<String>;
        #[swift_bridge(swift_name = "openGraph")]
        fn open_graph(&self) -> String;
        #[swift_bridge(swift_name = "twitterCard")]
        fn twitter_card(&self) -> String;
        #[swift_bridge(swift_name = "metaTags")]
        fn meta_tags(&self) -> String;
        fn headers(&self) -> Vec<HeaderMetadata>;
        fn links(&self) -> Vec<LinkMetadata>;
        fn images(&self) -> Vec<ImageMetadataType>;
        #[swift_bridge(swift_name = "structuredData")]
        fn structured_data(&self) -> Vec<StructuredData>;
    }

    extern "Rust" {
        type OcrMetadata;
        #[swift_bridge(init)]
        fn new(
            language: String,
            psm: i32,
            output_format: String,
            table_count: u32,
            table_rows: Option<u32>,
            table_cols: Option<u32>,
        ) -> OcrMetadata;
        fn language(&self) -> String;
        fn psm(&self) -> i32;
        #[swift_bridge(swift_name = "outputFormat")]
        fn output_format(&self) -> String;
        #[swift_bridge(swift_name = "tableCount")]
        fn table_count(&self) -> u32;
        #[swift_bridge(swift_name = "tableRows")]
        fn table_rows(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "tableCols")]
        fn table_cols(&self) -> Option<u32>;
    }

    extern "Rust" {
        type ErrorMetadata;
        #[swift_bridge(swift_name = "errorType")]
        fn error_type(&self) -> String;
        fn message(&self) -> String;
    }

    extern "Rust" {
        type PptxMetadata;
        #[swift_bridge(init)]
        fn new(
            slide_count: u32,
            slide_names: Vec<String>,
            image_count: Option<u32>,
            table_count: Option<u32>,
        ) -> PptxMetadata;
        #[swift_bridge(swift_name = "slideCount")]
        fn slide_count(&self) -> u32;
        #[swift_bridge(swift_name = "slideNames")]
        fn slide_names(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "imageCount")]
        fn image_count(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "tableCount")]
        fn table_count(&self) -> Option<u32>;
    }

    extern "Rust" {
        type DocxMetadata;
        #[swift_bridge(init)]
        fn new(
            core_properties: Option<CoreProperties>,
            app_properties: Option<DocxAppProperties>,
            custom_properties: String,
        ) -> DocxMetadata;
        #[swift_bridge(swift_name = "coreProperties")]
        fn core_properties(&self) -> Option<CoreProperties>;
        #[swift_bridge(swift_name = "appProperties")]
        fn app_properties(&self) -> Option<DocxAppProperties>;
        #[swift_bridge(swift_name = "customProperties")]
        fn custom_properties(&self) -> String;
    }

    extern "Rust" {
        type CsvMetadata;
        #[swift_bridge(init)]
        fn new(
            row_count: u32,
            column_count: u32,
            delimiter: Option<String>,
            has_header: bool,
            column_types: Option<Vec<String>>,
        ) -> CsvMetadata;
        #[swift_bridge(swift_name = "rowCount")]
        fn row_count(&self) -> u32;
        #[swift_bridge(swift_name = "columnCount")]
        fn column_count(&self) -> u32;
        fn delimiter(&self) -> Option<String>;
        #[swift_bridge(swift_name = "hasHeader")]
        fn has_header(&self) -> bool;
        #[swift_bridge(swift_name = "columnTypes")]
        fn column_types(&self) -> Option<Vec<String>>;
    }

    extern "Rust" {
        type BibtexMetadata;
        #[swift_bridge(init)]
        fn new(
            entry_count: usize,
            citation_keys: Vec<String>,
            authors: Vec<String>,
            year_range: Option<YearRange>,
            entry_types: String,
        ) -> BibtexMetadata;
        #[swift_bridge(swift_name = "entryCount")]
        fn entry_count(&self) -> usize;
        #[swift_bridge(swift_name = "citationKeys")]
        fn citation_keys(&self) -> Vec<String>;
        fn authors(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "yearRange")]
        fn year_range(&self) -> Option<YearRange>;
        #[swift_bridge(swift_name = "entryTypes")]
        fn entry_types(&self) -> String;
    }

    extern "Rust" {
        type CitationMetadata;
        #[swift_bridge(init)]
        fn new(
            citation_count: usize,
            format: Option<String>,
            authors: Vec<String>,
            year_range: Option<YearRange>,
            dois: Vec<String>,
            keywords: Vec<String>,
        ) -> CitationMetadata;
        #[swift_bridge(swift_name = "citationCount")]
        fn citation_count(&self) -> usize;
        fn format(&self) -> Option<String>;
        fn authors(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "yearRange")]
        fn year_range(&self) -> Option<YearRange>;
        fn dois(&self) -> Vec<String>;
        fn keywords(&self) -> Vec<String>;
    }

    extern "Rust" {
        type YearRange;
        fn min(&self) -> Option<u32>;
        fn max(&self) -> Option<u32>;
        fn years(&self) -> Vec<u32>;
    }

    extern "Rust" {
        type FictionBookMetadata;
        #[swift_bridge(init)]
        fn new(genres: Vec<String>, sequences: Vec<String>, annotation: Option<String>) -> FictionBookMetadata;
        fn genres(&self) -> Vec<String>;
        fn sequences(&self) -> Vec<String>;
        fn annotation(&self) -> Option<String>;
    }

    extern "Rust" {
        type DbfMetadata;
        #[swift_bridge(init)]
        fn new(record_count: usize, field_count: usize, fields: Vec<DbfFieldInfo>) -> DbfMetadata;
        #[swift_bridge(swift_name = "recordCount")]
        fn record_count(&self) -> usize;
        #[swift_bridge(swift_name = "fieldCount")]
        fn field_count(&self) -> usize;
        fn fields(&self) -> Vec<DbfFieldInfo>;
    }

    extern "Rust" {
        type DbfFieldInfo;
        fn name(&self) -> String;
        #[swift_bridge(swift_name = "fieldType")]
        fn field_type(&self) -> String;
    }

    extern "Rust" {
        type JatsMetadata;
        #[swift_bridge(init)]
        fn new(
            copyright: Option<String>,
            license: Option<String>,
            history_dates: String,
            contributor_roles: Vec<ContributorRole>,
        ) -> JatsMetadata;
        fn copyright(&self) -> Option<String>;
        fn license(&self) -> Option<String>;
        #[swift_bridge(swift_name = "historyDates")]
        fn history_dates(&self) -> String;
        #[swift_bridge(swift_name = "contributorRoles")]
        fn contributor_roles(&self) -> Vec<ContributorRole>;
    }

    extern "Rust" {
        type ContributorRole;
        fn name(&self) -> String;
        fn role(&self) -> Option<String>;
    }

    extern "Rust" {
        type EpubMetadata;
        #[swift_bridge(init)]
        fn new(
            coverage: Option<String>,
            dc_format: Option<String>,
            relation: Option<String>,
            source: Option<String>,
            dc_type: Option<String>,
            cover_image: Option<String>,
        ) -> EpubMetadata;
        fn coverage(&self) -> Option<String>;
        #[swift_bridge(swift_name = "dcFormat")]
        fn dc_format(&self) -> Option<String>;
        fn relation(&self) -> Option<String>;
        fn source(&self) -> Option<String>;
        #[swift_bridge(swift_name = "dcType")]
        fn dc_type(&self) -> Option<String>;
        #[swift_bridge(swift_name = "coverImage")]
        fn cover_image(&self) -> Option<String>;
    }

    extern "Rust" {
        type PstMetadata;
        #[swift_bridge(init)]
        fn new(message_count: usize) -> PstMetadata;
        #[swift_bridge(swift_name = "messageCount")]
        fn message_count(&self) -> usize;
    }

    extern "Rust" {
        type OcrConfidence;
        #[swift_bridge(init)]
        fn new(detection: Option<f64>, recognition: f64) -> OcrConfidence;
        fn detection(&self) -> Option<f64>;
        fn recognition(&self) -> f64;
    }

    extern "Rust" {
        type OcrRotation;
        #[swift_bridge(init)]
        fn new(angle_degrees: f64, confidence: Option<f64>) -> OcrRotation;
        #[swift_bridge(swift_name = "angleDegrees")]
        fn angle_degrees(&self) -> f64;
        fn confidence(&self) -> Option<f64>;
    }

    extern "Rust" {
        type OcrElement;
        #[swift_bridge(init)]
        fn new(
            text: String,
            geometry: OcrBoundingGeometry,
            confidence: OcrConfidence,
            level: OcrElementLevel,
            rotation: Option<OcrRotation>,
            page_number: u32,
            parent_id: Option<String>,
            backend_metadata: String,
        ) -> OcrElement;
        fn text(&self) -> String;
        fn geometry(&self) -> String;
        fn confidence(&self) -> OcrConfidence;
        fn level(&self) -> String;
        fn rotation(&self) -> Option<OcrRotation>;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
        #[swift_bridge(swift_name = "parentId")]
        fn parent_id(&self) -> Option<String>;
        #[swift_bridge(swift_name = "backendMetadata")]
        fn backend_metadata(&self) -> String;
    }

    extern "Rust" {
        type OcrElementConfig;
        #[swift_bridge(init)]
        fn new(
            include_elements: bool,
            min_level: OcrElementLevel,
            min_confidence: f64,
            build_hierarchy: bool,
        ) -> OcrElementConfig;
        #[swift_bridge(swift_name = "includeElements")]
        fn include_elements(&self) -> bool;
        #[swift_bridge(swift_name = "minLevel")]
        fn min_level(&self) -> String;
        #[swift_bridge(swift_name = "minConfidence")]
        fn min_confidence(&self) -> f64;
        #[swift_bridge(swift_name = "buildHierarchy")]
        fn build_hierarchy(&self) -> bool;
    }

    extern "Rust" {
        type PageStructure;
        #[swift_bridge(swift_name = "totalCount")]
        fn total_count(&self) -> u32;
        #[swift_bridge(swift_name = "unitType")]
        fn unit_type(&self) -> String;
        fn boundaries(&self) -> Option<Vec<PageBoundary>>;
        fn pages(&self) -> Option<Vec<PageInfo>>;
    }

    extern "Rust" {
        type PageBoundary;
        #[swift_bridge(init)]
        fn new(byte_start: usize, byte_end: usize, page_number: u32) -> PageBoundary;
        #[swift_bridge(swift_name = "byteStart")]
        fn byte_start(&self) -> usize;
        #[swift_bridge(swift_name = "byteEnd")]
        fn byte_end(&self) -> usize;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
    }

    extern "Rust" {
        type PageInfo;
        fn number(&self) -> u32;
        fn title(&self) -> Option<String>;
        fn dimensions(&self) -> Option<Vec<f64>>;
        #[swift_bridge(swift_name = "imageCount")]
        fn image_count(&self) -> Option<u32>;
        #[swift_bridge(swift_name = "tableCount")]
        fn table_count(&self) -> Option<u32>;
        fn hidden(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "isBlank")]
        fn is_blank(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "hasVectorGraphics")]
        fn has_vector_graphics(&self) -> bool;
    }

    extern "Rust" {
        type PageContent;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
        fn content(&self) -> String;
        fn tables(&self) -> Vec<Table>;
        #[swift_bridge(swift_name = "imageIndices")]
        fn image_indices(&self) -> Vec<u32>;
        fn hierarchy(&self) -> Option<PageHierarchy>;
        #[swift_bridge(swift_name = "isBlank")]
        fn is_blank(&self) -> Option<bool>;
        #[swift_bridge(swift_name = "layoutRegions")]
        fn layout_regions(&self) -> Option<Vec<LayoutRegion>>;
        #[swift_bridge(swift_name = "speakerNotes")]
        fn speaker_notes(&self) -> Option<String>;
        #[swift_bridge(swift_name = "sectionName")]
        fn section_name(&self) -> Option<String>;
        #[swift_bridge(swift_name = "sheetName")]
        fn sheet_name(&self) -> Option<String>;
    }

    extern "Rust" {
        type LayoutRegion;
        #[swift_bridge(init)]
        fn new(class_name: String, confidence: f64, bounding_box: BoundingBox, area_fraction: f64) -> LayoutRegion;
        #[swift_bridge(swift_name = "className")]
        fn class_name(&self) -> String;
        fn confidence(&self) -> f64;
        #[swift_bridge(swift_name = "boundingBox")]
        fn bounding_box(&self) -> BoundingBox;
        #[swift_bridge(swift_name = "areaFraction")]
        fn area_fraction(&self) -> f64;
    }

    extern "Rust" {
        type PageHierarchy;
        #[swift_bridge(swift_name = "blockCount")]
        fn block_count(&self) -> u32;
        fn blocks(&self) -> Vec<HierarchicalBlock>;
    }

    extern "Rust" {
        type HierarchicalBlock;
        fn text(&self) -> String;
        #[swift_bridge(swift_name = "fontSize")]
        fn font_size(&self) -> f32;
        fn level(&self) -> String;
        fn bbox(&self) -> Option<Vec<f32>>;
    }

    extern "Rust" {
        type CellChange;
        fn row(&self) -> usize;
        fn col(&self) -> usize;
        fn from(&self) -> String;
        fn to(&self) -> String;
    }

    extern "Rust" {
        type DocumentRevision;
        #[swift_bridge(swift_name = "revisionId")]
        fn revision_id(&self) -> String;
        fn author(&self) -> Option<String>;
        fn timestamp(&self) -> Option<String>;
        fn kind(&self) -> String;
        fn anchor(&self) -> Option<String>;
        fn delta(&self) -> RevisionDelta;
    }

    extern "Rust" {
        type RevisionDelta;
        #[swift_bridge(init)]
        fn new(content: Vec<DiffLine>, table_changes: Vec<CellChange>) -> RevisionDelta;
        fn content(&self) -> Vec<String>;
        #[swift_bridge(swift_name = "tableChanges")]
        fn table_changes(&self) -> Vec<CellChange>;
    }

    extern "Rust" {
        type Table;
        #[swift_bridge(init)]
        fn new(cells: String, markdown: String, page_number: u32, bounding_box: Option<BoundingBox>) -> Table;
        fn cells(&self) -> String;
        fn markdown(&self) -> String;
        #[swift_bridge(swift_name = "pageNumber")]
        fn page_number(&self) -> u32;
        #[swift_bridge(swift_name = "boundingBox")]
        fn bounding_box(&self) -> Option<BoundingBox>;
    }

    extern "Rust" {
        type TableCell;
        #[swift_bridge(init)]
        fn new(content: String, row_span: u32, col_span: u32, is_header: bool) -> TableCell;
        fn content(&self) -> String;
        #[swift_bridge(swift_name = "rowSpan")]
        fn row_span(&self) -> u32;
        #[swift_bridge(swift_name = "colSpan")]
        fn col_span(&self) -> u32;
        #[swift_bridge(swift_name = "isHeader")]
        fn is_header(&self) -> bool;
    }

    extern "Rust" {
        type ExtractedUri;
        fn url(&self) -> String;
        fn label(&self) -> Option<String>;
        fn page(&self) -> Option<u32>;
        fn kind(&self) -> String;
    }

    extern "Rust" {
        type DetectResponse;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> String;
        fn filename(&self) -> Option<String>;
    }

    extern "Rust" {
        type DiffOptions;
        #[swift_bridge(init)]
        fn new(include_metadata: bool, include_embedded: bool, max_content_chars: Option<usize>) -> DiffOptions;
        #[swift_bridge(swift_name = "includeMetadata")]
        fn include_metadata(&self) -> bool;
        #[swift_bridge(swift_name = "includeEmbedded")]
        fn include_embedded(&self) -> bool;
        #[swift_bridge(swift_name = "maxContentChars")]
        fn max_content_chars(&self) -> Option<usize>;
    }

    extern "Rust" {
        type ExtractionDiff;
        #[swift_bridge(swift_name = "contentDiff")]
        fn content_diff(&self) -> Vec<DiffHunk>;
        #[swift_bridge(swift_name = "tablesAdded")]
        fn tables_added(&self) -> Vec<Table>;
        #[swift_bridge(swift_name = "tablesRemoved")]
        fn tables_removed(&self) -> Vec<Table>;
        #[swift_bridge(swift_name = "tablesChanged")]
        fn tables_changed(&self) -> Vec<TableDiff>;
        #[swift_bridge(swift_name = "metadataChanged")]
        fn metadata_changed(&self) -> String;
        #[swift_bridge(swift_name = "embeddedChanges")]
        fn embedded_changes(&self) -> EmbeddedChanges;
    }

    extern "Rust" {
        type DiffHunk;
        #[swift_bridge(swift_name = "fromLine")]
        fn from_line(&self) -> usize;
        #[swift_bridge(swift_name = "fromCount")]
        fn from_count(&self) -> usize;
        #[swift_bridge(swift_name = "toLine")]
        fn to_line(&self) -> usize;
        #[swift_bridge(swift_name = "toCount")]
        fn to_count(&self) -> usize;
        fn lines(&self) -> Vec<String>;
    }

    extern "Rust" {
        type TableDiff;
        #[swift_bridge(swift_name = "fromIndex")]
        fn from_index(&self) -> usize;
        #[swift_bridge(swift_name = "toIndex")]
        fn to_index(&self) -> usize;
        #[swift_bridge(swift_name = "cellChanges")]
        fn cell_changes(&self) -> Vec<CellChange>;
    }

    extern "Rust" {
        type EmbeddedChanges;
        fn added(&self) -> Vec<ArchiveEntry>;
        fn removed(&self) -> Vec<ArchiveEntry>;
        fn changed(&self) -> Vec<EmbeddedDiff>;
    }

    extern "Rust" {
        type EmbeddedDiff;
        fn path(&self) -> String;
        fn diff(&self) -> ExtractionDiff;
    }

    extern "Rust" {
        type EmbeddingPreset;
        fn name(&self) -> String;
        #[swift_bridge(swift_name = "chunkSize")]
        fn chunk_size(&self) -> usize;
        fn overlap(&self) -> usize;
        #[swift_bridge(swift_name = "modelRepo")]
        fn model_repo(&self) -> String;
        fn pooling(&self) -> String;
        #[swift_bridge(swift_name = "modelFile")]
        fn model_file(&self) -> String;
        fn dimensions(&self) -> usize;
        fn description(&self) -> String;
    }

    extern "Rust" {
        type YakeParams;
        #[swift_bridge(init)]
        fn new(window_size: usize) -> YakeParams;
        #[swift_bridge(swift_name = "windowSize")]
        fn window_size(&self) -> usize;
    }

    extern "Rust" {
        type RakeParams;
        #[swift_bridge(init)]
        fn new(min_word_length: usize, max_words_per_phrase: usize) -> RakeParams;
        #[swift_bridge(swift_name = "minWordLength")]
        fn min_word_length(&self) -> usize;
        #[swift_bridge(swift_name = "maxWordsPerPhrase")]
        fn max_words_per_phrase(&self) -> usize;
    }

    extern "Rust" {
        type KeywordConfig;
        #[swift_bridge(init)]
        fn new(
            algorithm: KeywordAlgorithm,
            max_keywords: usize,
            min_score: f32,
            ngram_range: Vec<usize>,
            language: Option<String>,
            yake_params: Option<YakeParams>,
            rake_params: Option<RakeParams>,
        ) -> KeywordConfig;
        fn algorithm(&self) -> String;
        #[swift_bridge(swift_name = "maxKeywords")]
        fn max_keywords(&self) -> usize;
        #[swift_bridge(swift_name = "minScore")]
        fn min_score(&self) -> f32;
        #[swift_bridge(swift_name = "ngramRange")]
        fn ngram_range(&self) -> Vec<usize>;
        fn language(&self) -> Option<String>;
        #[swift_bridge(swift_name = "yakeParams")]
        fn yake_params(&self) -> Option<YakeParams>;
        #[swift_bridge(swift_name = "rakeParams")]
        fn rake_params(&self) -> Option<RakeParams>;
    }

    extern "Rust" {
        type Keyword;
        fn text(&self) -> String;
        fn score(&self) -> f32;
        fn algorithm(&self) -> String;
        fn positions(&self) -> Option<Vec<usize>>;
    }

    extern "Rust" {
        type PaddleOcrConfig;
        #[swift_bridge(init)]
        fn new(
            language: String,
            cache_dir: Option<String>,
            use_angle_cls: bool,
            enable_table_detection: bool,
            det_db_thresh: f32,
            det_db_box_thresh: f32,
            det_db_unclip_ratio: f32,
            det_limit_side_len: u32,
            rec_batch_num: u32,
            padding: u32,
            drop_score: f32,
            model_tier: String,
        ) -> PaddleOcrConfig;
        fn language(&self) -> String;
        #[swift_bridge(swift_name = "cacheDir")]
        fn cache_dir(&self) -> Option<String>;
        #[swift_bridge(swift_name = "useAngleCls")]
        fn use_angle_cls(&self) -> bool;
        #[swift_bridge(swift_name = "enableTableDetection")]
        fn enable_table_detection(&self) -> bool;
        #[swift_bridge(swift_name = "detDbThresh")]
        fn det_db_thresh(&self) -> f32;
        #[swift_bridge(swift_name = "detDbBoxThresh")]
        fn det_db_box_thresh(&self) -> f32;
        #[swift_bridge(swift_name = "detDbUnclipRatio")]
        fn det_db_unclip_ratio(&self) -> f32;
        #[swift_bridge(swift_name = "detLimitSideLen")]
        fn det_limit_side_len(&self) -> u32;
        #[swift_bridge(swift_name = "recBatchNum")]
        fn rec_batch_num(&self) -> u32;
        fn padding(&self) -> u32;
        #[swift_bridge(swift_name = "dropScore")]
        fn drop_score(&self) -> f32;
        #[swift_bridge(swift_name = "modelTier")]
        fn model_tier(&self) -> String;
    }

    extern "Rust" {
        type ModelPaths;
        #[swift_bridge(swift_name = "detModel")]
        fn det_model(&self) -> String;
        #[swift_bridge(swift_name = "clsModel")]
        fn cls_model(&self) -> String;
        #[swift_bridge(swift_name = "recModel")]
        fn rec_model(&self) -> String;
        #[swift_bridge(swift_name = "dictFile")]
        fn dict_file(&self) -> String;
    }

    extern "Rust" {
        type OrientationResult;
        #[swift_bridge(init)]
        fn new(degrees: u32, confidence: f32) -> OrientationResult;
        fn degrees(&self) -> u32;
        fn confidence(&self) -> f32;
    }

    extern "Rust" {
        type BBox;
        #[swift_bridge(init)]
        fn new(x1: f32, y1: f32, x2: f32, y2: f32) -> BBox;
        fn x1(&self) -> f32;
        fn y1(&self) -> f32;
        fn x2(&self) -> f32;
        fn y2(&self) -> f32;
    }

    extern "Rust" {
        type LayoutDetection;
        #[swift_bridge(swift_name = "className")]
        fn class_name(&self) -> String;
        fn confidence(&self) -> f32;
        fn bbox(&self) -> BBox;
    }

    extern "Rust" {
        type RecognizedTable;
        #[swift_bridge(swift_name = "detectionBbox")]
        fn detection_bbox(&self) -> BBox;
        fn cells(&self) -> String;
        fn markdown(&self) -> String;
    }

    extern "Rust" {
        type DetectionResult;
        #[swift_bridge(swift_name = "pageWidth")]
        fn page_width(&self) -> u32;
        #[swift_bridge(swift_name = "pageHeight")]
        fn page_height(&self) -> u32;
        fn detections(&self) -> Vec<LayoutDetection>;
    }

    extern "Rust" {
        type EmbeddedFile;
        fn name(&self) -> String;
        fn data(&self) -> Vec<u8>;
        #[swift_bridge(swift_name = "compressedSize")]
        fn compressed_size(&self) -> usize;
        #[swift_bridge(swift_name = "mimeType")]
        fn mime_type(&self) -> Option<String>;
    }

    extern "Rust" {
        type PdfMetadata;
        #[swift_bridge(init)]
        fn new(
            pdf_version: Option<String>,
            producer: Option<String>,
            is_encrypted: Option<bool>,
            width: Option<i64>,
            height: Option<i64>,
            page_count: Option<u32>,
        ) -> PdfMetadata;
        #[swift_bridge(swift_name = "pdfVersion")]
        fn pdf_version(&self) -> Option<String>;
        fn producer(&self) -> Option<String>;
        #[swift_bridge(swift_name = "isEncrypted")]
        fn is_encrypted(&self) -> Option<bool>;
        fn width(&self) -> Option<i64>;
        fn height(&self) -> Option<i64>;
        #[swift_bridge(swift_name = "pageCount")]
        fn page_count(&self) -> Option<u32>;
    }

    extern "Rust" {
        type ExecutionProviderType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type OutputFormat;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type HtmlTheme;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type TableModel;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ChunkerType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ChunkSizing;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type EmbeddingModelType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type CodeContentMode;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ListType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type OcrBackendType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ProcessingStage;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ReductionLevel;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type PdfAnnotationType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type BlockType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type InlineType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type RelationshipKind;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ContentLayer;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type NodeContent;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type AnnotationKind;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ExtractionMethod;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ChunkType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ImageKind;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ResultFormat;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ElementType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type FormatMetadata;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type TextDirection;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type LinkType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type ImageType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type StructuredDataType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type OcrBoundingGeometry;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type OcrElementLevel;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type PageUnitType;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type DiffLine;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type RevisionKind;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type RevisionAnchor;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type UriKind;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type KeywordAlgorithm;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type PSMMode;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type PaddleLanguage;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        type LayoutClass;
        fn to_string(&self) -> String;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "extractBytes")]
        fn extract_bytes(
            content: Vec<u8>,
            mime_type: String,
            config: ExtractionConfig,
        ) -> Result<ExtractionResult, String>;
        #[swift_bridge(swift_name = "extractFile")]
        fn extract_file(
            path: String,
            mime_type: Option<String>,
            config: ExtractionConfig,
        ) -> Result<ExtractionResult, String>;
        #[swift_bridge(swift_name = "extractFileSync")]
        fn extract_file_sync(
            path: String,
            mime_type: Option<String>,
            config: ExtractionConfig,
        ) -> Result<ExtractionResult, String>;
        #[swift_bridge(swift_name = "extractBytesSync")]
        fn extract_bytes_sync(
            content: Vec<u8>,
            mime_type: String,
            config: ExtractionConfig,
        ) -> Result<ExtractionResult, String>;
        #[swift_bridge(swift_name = "batchExtractFilesSync")]
        fn batch_extract_files_sync(
            items: Vec<BatchFileItem>,
            config: ExtractionConfig,
        ) -> Result<Vec<ExtractionResult>, String>;
        #[swift_bridge(swift_name = "batchExtractBytesSync")]
        fn batch_extract_bytes_sync(
            items: Vec<BatchBytesItem>,
            config: ExtractionConfig,
        ) -> Result<Vec<ExtractionResult>, String>;
        #[swift_bridge(swift_name = "batchExtractFiles")]
        fn batch_extract_files(
            items: Vec<BatchFileItem>,
            config: ExtractionConfig,
        ) -> Result<Vec<ExtractionResult>, String>;
        #[swift_bridge(swift_name = "batchExtractBytes")]
        fn batch_extract_bytes(
            items: Vec<BatchBytesItem>,
            config: ExtractionConfig,
        ) -> Result<Vec<ExtractionResult>, String>;
        #[swift_bridge(swift_name = "detectMimeTypeFromBytes")]
        fn detect_mime_type_from_bytes(content: Vec<u8>) -> Result<String, String>;
        #[swift_bridge(swift_name = "getExtensionsForMime")]
        fn get_extensions_for_mime(mime_type: String) -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listEmbeddingBackends")]
        fn list_embedding_backends() -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listDocumentExtractors")]
        fn list_document_extractors() -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listOcrBackends")]
        fn list_ocr_backends() -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listPostProcessors")]
        fn list_post_processors() -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listRenderers")]
        fn list_renderers() -> Result<Vec<String>, String>;
        #[swift_bridge(swift_name = "listValidators")]
        fn list_validators() -> Result<Vec<String>, String>;
        fn compare(a: ExtractionResult, b: ExtractionResult, opts: DiffOptions) -> ExtractionDiff;
        #[swift_bridge(swift_name = "embedTextsAsync")]
        fn embed_texts_async(texts: Vec<String>, config: EmbeddingConfig) -> Result<String, String>;
        #[swift_bridge(swift_name = "renderPdfPageToPng")]
        fn render_pdf_page_to_png(
            pdf_bytes: Vec<u8>,
            page_index: usize,
            dpi: Option<i32>,
            password: Option<String>,
        ) -> Result<Vec<u8>, String>;
        #[swift_bridge(swift_name = "detectMimeType")]
        fn detect_mime_type(path: String, check_exists: bool) -> Result<String, String>;
        #[swift_bridge(swift_name = "embedTexts")]
        fn embed_texts(texts: Vec<String>, config: EmbeddingConfig) -> Result<String, String>;
        #[swift_bridge(swift_name = "getEmbeddingPreset")]
        fn get_embedding_preset(name: String) -> Option<EmbeddingPreset>;
        #[swift_bridge(swift_name = "listEmbeddingPresets")]
        fn list_embedding_presets() -> Vec<String>;
    }

    extern "Rust" {
        type OcrBackendBox;
        fn alef_phantom_vec_ocr_backend() -> Vec<OcrBackendBox>;
        fn ocr_backend_call_process_image(this: &OcrBackendBox, image_bytes: Vec<u8>, config: OcrConfig) -> String;
        fn ocr_backend_call_supports_language(this: &OcrBackendBox, lang: String) -> bool;
        fn ocr_backend_call_backend_type(this: &OcrBackendBox) -> OcrBackendType;
    }

    extern "Rust" {
        type PostProcessorBox;
        fn alef_phantom_vec_post_processor() -> Vec<PostProcessorBox>;
        fn post_processor_call_process(
            this: &PostProcessorBox,
            result: ExtractionResult,
            config: ExtractionConfig,
        ) -> String;
        fn post_processor_call_processing_stage(this: &PostProcessorBox) -> ProcessingStage;
    }

    extern "Rust" {
        type ValidatorBox;
        fn alef_phantom_vec_validator() -> Vec<ValidatorBox>;
        fn validator_call_validate(this: &ValidatorBox, result: ExtractionResult, config: ExtractionConfig) -> String;
    }

    extern "Rust" {
        type EmbeddingBackendBox;
        fn alef_phantom_vec_embedding_backend() -> Vec<EmbeddingBackendBox>;
        fn embedding_backend_call_dimensions(this: &EmbeddingBackendBox) -> usize;
        fn embedding_backend_call_embed(this: &EmbeddingBackendBox, texts: Vec<String>) -> String;
    }

    extern "Rust" {
        type DocumentExtractorBox;
        fn alef_phantom_vec_document_extractor() -> Vec<DocumentExtractorBox>;
        fn document_extractor_call_extract_bytes(
            this: &DocumentExtractorBox,
            content: Vec<u8>,
            mime_type: String,
            config: ExtractionConfig,
        ) -> String;
        fn document_extractor_call_supported_mime_types(this: &DocumentExtractorBox) -> Vec<String>;
    }

    extern "Rust" {
        type RendererBox;
        fn alef_phantom_vec_renderer() -> Vec<RendererBox>;
        fn renderer_call_render(this: &RendererBox, doc: String) -> String;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerOcrBackend")]
        fn register_ocr_backend(swift_box: SwiftOcrBackendBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterOcrBackend")]
        fn unregister_ocr_backend(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearOcrBackends")]
        fn clear_ocr_backends() -> Result<(), String>;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerPostProcessor")]
        fn register_post_processor(swift_box: SwiftPostProcessorBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterPostProcessor")]
        fn unregister_post_processor(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearPostProcessors")]
        fn clear_post_processors() -> Result<(), String>;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerValidator")]
        fn register_validator(swift_box: SwiftValidatorBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterValidator")]
        fn unregister_validator(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearValidators")]
        fn clear_validators() -> Result<(), String>;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerEmbeddingBackend")]
        fn register_embedding_backend(swift_box: SwiftEmbeddingBackendBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterEmbeddingBackend")]
        fn unregister_embedding_backend(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearEmbeddingBackends")]
        fn clear_embedding_backends() -> Result<(), String>;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerDocumentExtractor")]
        fn register_document_extractor(swift_box: SwiftDocumentExtractorBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterDocumentExtractor")]
        fn unregister_document_extractor(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearDocumentExtractors")]
        fn clear_document_extractors() -> Result<(), String>;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "registerRenderer")]
        fn register_renderer(swift_box: SwiftRendererBox) -> Result<(), String>;
        #[swift_bridge(swift_name = "unregisterRenderer")]
        fn unregister_renderer(name: String) -> Result<(), String>;
        #[swift_bridge(swift_name = "clearRenderers")]
        fn clear_renderers() -> Result<(), String>;
    }

    extern "Swift" {
        type SwiftOcrBackendBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_process_image(&self, image_bytes: Vec<u8>, config: String) -> String;
        fn alef_process_image_file(&self, path: String, config: String) -> String;
        fn alef_supports_language(&self, lang: String) -> bool;
        fn alef_backend_type(&self) -> String;
        fn alef_supported_languages(&self) -> Vec<String>;
        fn alef_supports_table_detection(&self) -> bool;
        fn alef_supports_document_processing(&self) -> bool;
        fn alef_process_document(&self, path: String, config: String) -> String;
    }

    extern "Swift" {
        type SwiftPostProcessorBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_process(&self, result: String, config: String) -> String;
        fn alef_processing_stage(&self) -> String;
        fn alef_should_process(&self, result: String, config: String) -> bool;
        fn alef_estimated_duration_ms(&self, result: String) -> u64;
        fn alef_priority(&self) -> i32;
    }

    extern "Swift" {
        type SwiftValidatorBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_validate(&self, result: String, config: String) -> String;
        fn alef_should_validate(&self, result: String, config: String) -> bool;
        fn alef_priority(&self) -> i32;
    }

    extern "Swift" {
        type SwiftEmbeddingBackendBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_dimensions(&self) -> usize;
        fn alef_embed(&self, texts: Vec<String>) -> String;
    }

    extern "Swift" {
        type SwiftDocumentExtractorBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_extract_bytes(&self, content: Vec<u8>, mime_type: String, config: String) -> String;
        fn alef_extract_file(&self, path: String, mime_type: String, config: String) -> String;
        fn alef_supported_mime_types(&self) -> Vec<String>;
        fn alef_priority(&self) -> i32;
        fn alef_can_handle(&self, path: String, mime_type: String) -> bool;
    }

    extern "Swift" {
        type SwiftRendererBox;
        fn alef_name(&self) -> String;
        fn alef_version(&self) -> String;
        fn alef_initialize(&self) -> String;
        fn alef_shutdown(&self) -> String;
        fn alef_render(&self, doc: String) -> String;
    }

    extern "Rust" {
        #[swift_bridge(swift_name = "extractionConfigFromJson")]
        fn extraction_config_from_json(json: String) -> Result<ExtractionConfig, String>;
        #[swift_bridge(swift_name = "batchBytesItemFromJson")]
        fn batch_bytes_item_from_json(json: String) -> Result<BatchBytesItem, String>;
        #[swift_bridge(swift_name = "batchFileItemFromJson")]
        fn batch_file_item_from_json(json: String) -> Result<BatchFileItem, String>;
        #[swift_bridge(swift_name = "ocrConfigFromJson")]
        fn ocr_config_from_json(json: String) -> Result<OcrConfig, String>;
        #[swift_bridge(swift_name = "embeddingConfigFromJson")]
        fn embedding_config_from_json(json: String) -> Result<EmbeddingConfig, String>;
        #[swift_bridge(swift_name = "extractionResultFromJson")]
        fn extraction_result_from_json(json: String) -> Result<ExtractionResult, String>;
        #[swift_bridge(swift_name = "ocrExtractionResultFromJson")]
        fn ocr_extraction_result_from_json(json: String) -> Result<OcrExtractionResult, String>;
        #[swift_bridge(swift_name = "diffOptionsFromJson")]
        fn diff_options_from_json(json: String) -> Result<DiffOptions, String>;
    }
    extern "Rust" {
        #[swift_bridge(swift_name = "cacheStatsFromJson")]
        fn cache_stats_from_json(json: String) -> Result<CacheStats, String>;
        #[swift_bridge(swift_name = "accelerationConfigFromJson")]
        fn acceleration_config_from_json(json: String) -> Result<AccelerationConfig, String>;
        #[swift_bridge(swift_name = "contentFilterConfigFromJson")]
        fn content_filter_config_from_json(json: String) -> Result<ContentFilterConfig, String>;
        #[swift_bridge(swift_name = "emailConfigFromJson")]
        fn email_config_from_json(json: String) -> Result<EmailConfig, String>;
        #[swift_bridge(swift_name = "fileExtractionConfigFromJson")]
        fn file_extraction_config_from_json(json: String) -> Result<FileExtractionConfig, String>;
        #[swift_bridge(swift_name = "imageExtractionConfigFromJson")]
        fn image_extraction_config_from_json(json: String) -> Result<ImageExtractionConfig, String>;
        #[swift_bridge(swift_name = "tokenReductionOptionsFromJson")]
        fn token_reduction_options_from_json(json: String) -> Result<TokenReductionOptions, String>;
        #[swift_bridge(swift_name = "languageDetectionConfigFromJson")]
        fn language_detection_config_from_json(json: String) -> Result<LanguageDetectionConfig, String>;
        #[swift_bridge(swift_name = "htmlOutputConfigFromJson")]
        fn html_output_config_from_json(json: String) -> Result<HtmlOutputConfig, String>;
        #[swift_bridge(swift_name = "layoutDetectionConfigFromJson")]
        fn layout_detection_config_from_json(json: String) -> Result<LayoutDetectionConfig, String>;
        #[swift_bridge(swift_name = "llmConfigFromJson")]
        fn llm_config_from_json(json: String) -> Result<LlmConfig, String>;
        #[swift_bridge(swift_name = "structuredExtractionConfigFromJson")]
        fn structured_extraction_config_from_json(json: String) -> Result<StructuredExtractionConfig, String>;
        #[swift_bridge(swift_name = "ocrQualityThresholdsFromJson")]
        fn ocr_quality_thresholds_from_json(json: String) -> Result<OcrQualityThresholds, String>;
        #[swift_bridge(swift_name = "ocrPipelineStageFromJson")]
        fn ocr_pipeline_stage_from_json(json: String) -> Result<OcrPipelineStage, String>;
        #[swift_bridge(swift_name = "ocrPipelineConfigFromJson")]
        fn ocr_pipeline_config_from_json(json: String) -> Result<OcrPipelineConfig, String>;
        #[swift_bridge(swift_name = "pageConfigFromJson")]
        fn page_config_from_json(json: String) -> Result<PageConfig, String>;
        #[swift_bridge(swift_name = "pdfConfigFromJson")]
        fn pdf_config_from_json(json: String) -> Result<PdfConfig, String>;
        #[swift_bridge(swift_name = "hierarchyConfigFromJson")]
        fn hierarchy_config_from_json(json: String) -> Result<HierarchyConfig, String>;
        #[swift_bridge(swift_name = "postProcessorConfigFromJson")]
        fn post_processor_config_from_json(json: String) -> Result<PostProcessorConfig, String>;
        #[swift_bridge(swift_name = "chunkingConfigFromJson")]
        fn chunking_config_from_json(json: String) -> Result<ChunkingConfig, String>;
        #[swift_bridge(swift_name = "treeSitterConfigFromJson")]
        fn tree_sitter_config_from_json(json: String) -> Result<TreeSitterConfig, String>;
        #[swift_bridge(swift_name = "treeSitterProcessConfigFromJson")]
        fn tree_sitter_process_config_from_json(json: String) -> Result<TreeSitterProcessConfig, String>;
        #[swift_bridge(swift_name = "supportedFormatFromJson")]
        fn supported_format_from_json(json: String) -> Result<SupportedFormat, String>;
        #[swift_bridge(swift_name = "serverConfigFromJson")]
        fn server_config_from_json(json: String) -> Result<ServerConfig, String>;
        #[swift_bridge(swift_name = "structuredDataResultFromJson")]
        fn structured_data_result_from_json(json: String) -> Result<StructuredDataResult, String>;
        #[swift_bridge(swift_name = "docxAppPropertiesFromJson")]
        fn docx_app_properties_from_json(json: String) -> Result<DocxAppProperties, String>;
        #[swift_bridge(swift_name = "xlsxAppPropertiesFromJson")]
        fn xlsx_app_properties_from_json(json: String) -> Result<XlsxAppProperties, String>;
        #[swift_bridge(swift_name = "pptxAppPropertiesFromJson")]
        fn pptx_app_properties_from_json(json: String) -> Result<PptxAppProperties, String>;
        #[swift_bridge(swift_name = "corePropertiesFromJson")]
        fn core_properties_from_json(json: String) -> Result<CoreProperties, String>;
        #[swift_bridge(swift_name = "securityLimitsFromJson")]
        fn security_limits_from_json(json: String) -> Result<SecurityLimits, String>;
        #[swift_bridge(swift_name = "tokenReductionConfigFromJson")]
        fn token_reduction_config_from_json(json: String) -> Result<TokenReductionConfig, String>;
        #[swift_bridge(swift_name = "pdfAnnotationFromJson")]
        fn pdf_annotation_from_json(json: String) -> Result<PdfAnnotation, String>;
        #[swift_bridge(swift_name = "djotContentFromJson")]
        fn djot_content_from_json(json: String) -> Result<DjotContent, String>;
        #[swift_bridge(swift_name = "formattedBlockFromJson")]
        fn formatted_block_from_json(json: String) -> Result<FormattedBlock, String>;
        #[swift_bridge(swift_name = "inlineElementFromJson")]
        fn inline_element_from_json(json: String) -> Result<InlineElement, String>;
        #[swift_bridge(swift_name = "djotImageFromJson")]
        fn djot_image_from_json(json: String) -> Result<DjotImage, String>;
        #[swift_bridge(swift_name = "djotLinkFromJson")]
        fn djot_link_from_json(json: String) -> Result<DjotLink, String>;
        #[swift_bridge(swift_name = "footnoteFromJson")]
        fn footnote_from_json(json: String) -> Result<Footnote, String>;
        #[swift_bridge(swift_name = "documentStructureFromJson")]
        fn document_structure_from_json(json: String) -> Result<DocumentStructure, String>;
        #[swift_bridge(swift_name = "documentRelationshipFromJson")]
        fn document_relationship_from_json(json: String) -> Result<DocumentRelationship, String>;
        #[swift_bridge(swift_name = "documentNodeFromJson")]
        fn document_node_from_json(json: String) -> Result<DocumentNode, String>;
        #[swift_bridge(swift_name = "tableGridFromJson")]
        fn table_grid_from_json(json: String) -> Result<TableGrid, String>;
        #[swift_bridge(swift_name = "gridCellFromJson")]
        fn grid_cell_from_json(json: String) -> Result<GridCell, String>;
        #[swift_bridge(swift_name = "textAnnotationFromJson")]
        fn text_annotation_from_json(json: String) -> Result<TextAnnotation, String>;
        #[swift_bridge(swift_name = "archiveEntryFromJson")]
        fn archive_entry_from_json(json: String) -> Result<ArchiveEntry, String>;
        #[swift_bridge(swift_name = "processingWarningFromJson")]
        fn processing_warning_from_json(json: String) -> Result<ProcessingWarning, String>;
        #[swift_bridge(swift_name = "llmUsageFromJson")]
        fn llm_usage_from_json(json: String) -> Result<LlmUsage, String>;
        #[swift_bridge(swift_name = "chunkFromJson")]
        fn chunk_from_json(json: String) -> Result<Chunk, String>;
        #[swift_bridge(swift_name = "headingContextFromJson")]
        fn heading_context_from_json(json: String) -> Result<HeadingContext, String>;
        #[swift_bridge(swift_name = "headingLevelFromJson")]
        fn heading_level_from_json(json: String) -> Result<HeadingLevel, String>;
        #[swift_bridge(swift_name = "chunkMetadataFromJson")]
        fn chunk_metadata_from_json(json: String) -> Result<ChunkMetadata, String>;
        #[swift_bridge(swift_name = "extractedImageFromJson")]
        fn extracted_image_from_json(json: String) -> Result<ExtractedImage, String>;
        #[swift_bridge(swift_name = "boundingBoxFromJson")]
        fn bounding_box_from_json(json: String) -> Result<BoundingBox, String>;
        #[swift_bridge(swift_name = "elementMetadataFromJson")]
        fn element_metadata_from_json(json: String) -> Result<ElementMetadata, String>;
        #[swift_bridge(swift_name = "elementFromJson")]
        fn element_from_json(json: String) -> Result<Element, String>;
        #[swift_bridge(swift_name = "excelWorkbookFromJson")]
        fn excel_workbook_from_json(json: String) -> Result<ExcelWorkbook, String>;
        #[swift_bridge(swift_name = "excelSheetFromJson")]
        fn excel_sheet_from_json(json: String) -> Result<ExcelSheet, String>;
        #[swift_bridge(swift_name = "xmlExtractionResultFromJson")]
        fn xml_extraction_result_from_json(json: String) -> Result<XmlExtractionResult, String>;
        #[swift_bridge(swift_name = "textExtractionResultFromJson")]
        fn text_extraction_result_from_json(json: String) -> Result<TextExtractionResult, String>;
        #[swift_bridge(swift_name = "pptxExtractionResultFromJson")]
        fn pptx_extraction_result_from_json(json: String) -> Result<PptxExtractionResult, String>;
        #[swift_bridge(swift_name = "emailExtractionResultFromJson")]
        fn email_extraction_result_from_json(json: String) -> Result<EmailExtractionResult, String>;
        #[swift_bridge(swift_name = "emailAttachmentFromJson")]
        fn email_attachment_from_json(json: String) -> Result<EmailAttachment, String>;
        #[swift_bridge(swift_name = "ocrTableFromJson")]
        fn ocr_table_from_json(json: String) -> Result<OcrTable, String>;
        #[swift_bridge(swift_name = "ocrTableBoundingBoxFromJson")]
        fn ocr_table_bounding_box_from_json(json: String) -> Result<OcrTableBoundingBox, String>;
        #[swift_bridge(swift_name = "imagePreprocessingConfigFromJson")]
        fn image_preprocessing_config_from_json(json: String) -> Result<ImagePreprocessingConfig, String>;
        #[swift_bridge(swift_name = "tesseractConfigFromJson")]
        fn tesseract_config_from_json(json: String) -> Result<TesseractConfig, String>;
        #[swift_bridge(swift_name = "imagePreprocessingMetadataFromJson")]
        fn image_preprocessing_metadata_from_json(json: String) -> Result<ImagePreprocessingMetadata, String>;
        #[swift_bridge(swift_name = "metadataFromJson")]
        fn metadata_from_json(json: String) -> Result<Metadata, String>;
        #[swift_bridge(swift_name = "excelMetadataFromJson")]
        fn excel_metadata_from_json(json: String) -> Result<ExcelMetadata, String>;
        #[swift_bridge(swift_name = "emailMetadataFromJson")]
        fn email_metadata_from_json(json: String) -> Result<EmailMetadata, String>;
        #[swift_bridge(swift_name = "archiveMetadataFromJson")]
        fn archive_metadata_from_json(json: String) -> Result<ArchiveMetadata, String>;
        #[swift_bridge(swift_name = "imageMetadataFromJson")]
        fn image_metadata_from_json(json: String) -> Result<ImageMetadata, String>;
        #[swift_bridge(swift_name = "xmlMetadataFromJson")]
        fn xml_metadata_from_json(json: String) -> Result<XmlMetadata, String>;
        #[swift_bridge(swift_name = "textMetadataFromJson")]
        fn text_metadata_from_json(json: String) -> Result<TextMetadata, String>;
        #[swift_bridge(swift_name = "headerMetadataFromJson")]
        fn header_metadata_from_json(json: String) -> Result<HeaderMetadata, String>;
        #[swift_bridge(swift_name = "linkMetadataFromJson")]
        fn link_metadata_from_json(json: String) -> Result<LinkMetadata, String>;
        #[swift_bridge(swift_name = "imageMetadataTypeFromJson")]
        fn image_metadata_type_from_json(json: String) -> Result<ImageMetadataType, String>;
        #[swift_bridge(swift_name = "structuredDataFromJson")]
        fn structured_data_from_json(json: String) -> Result<StructuredData, String>;
        #[swift_bridge(swift_name = "htmlMetadataFromJson")]
        fn html_metadata_from_json(json: String) -> Result<HtmlMetadata, String>;
        #[swift_bridge(swift_name = "ocrMetadataFromJson")]
        fn ocr_metadata_from_json(json: String) -> Result<OcrMetadata, String>;
        #[swift_bridge(swift_name = "errorMetadataFromJson")]
        fn error_metadata_from_json(json: String) -> Result<ErrorMetadata, String>;
        #[swift_bridge(swift_name = "pptxMetadataFromJson")]
        fn pptx_metadata_from_json(json: String) -> Result<PptxMetadata, String>;
        #[swift_bridge(swift_name = "docxMetadataFromJson")]
        fn docx_metadata_from_json(json: String) -> Result<DocxMetadata, String>;
        #[swift_bridge(swift_name = "csvMetadataFromJson")]
        fn csv_metadata_from_json(json: String) -> Result<CsvMetadata, String>;
        #[swift_bridge(swift_name = "bibtexMetadataFromJson")]
        fn bibtex_metadata_from_json(json: String) -> Result<BibtexMetadata, String>;
        #[swift_bridge(swift_name = "citationMetadataFromJson")]
        fn citation_metadata_from_json(json: String) -> Result<CitationMetadata, String>;
        #[swift_bridge(swift_name = "yearRangeFromJson")]
        fn year_range_from_json(json: String) -> Result<YearRange, String>;
        #[swift_bridge(swift_name = "fictionBookMetadataFromJson")]
        fn fiction_book_metadata_from_json(json: String) -> Result<FictionBookMetadata, String>;
        #[swift_bridge(swift_name = "dbfMetadataFromJson")]
        fn dbf_metadata_from_json(json: String) -> Result<DbfMetadata, String>;
        #[swift_bridge(swift_name = "dbfFieldInfoFromJson")]
        fn dbf_field_info_from_json(json: String) -> Result<DbfFieldInfo, String>;
        #[swift_bridge(swift_name = "jatsMetadataFromJson")]
        fn jats_metadata_from_json(json: String) -> Result<JatsMetadata, String>;
        #[swift_bridge(swift_name = "contributorRoleFromJson")]
        fn contributor_role_from_json(json: String) -> Result<ContributorRole, String>;
        #[swift_bridge(swift_name = "epubMetadataFromJson")]
        fn epub_metadata_from_json(json: String) -> Result<EpubMetadata, String>;
        #[swift_bridge(swift_name = "pstMetadataFromJson")]
        fn pst_metadata_from_json(json: String) -> Result<PstMetadata, String>;
        #[swift_bridge(swift_name = "ocrConfidenceFromJson")]
        fn ocr_confidence_from_json(json: String) -> Result<OcrConfidence, String>;
        #[swift_bridge(swift_name = "ocrRotationFromJson")]
        fn ocr_rotation_from_json(json: String) -> Result<OcrRotation, String>;
        #[swift_bridge(swift_name = "ocrElementFromJson")]
        fn ocr_element_from_json(json: String) -> Result<OcrElement, String>;
        #[swift_bridge(swift_name = "ocrElementConfigFromJson")]
        fn ocr_element_config_from_json(json: String) -> Result<OcrElementConfig, String>;
        #[swift_bridge(swift_name = "pageStructureFromJson")]
        fn page_structure_from_json(json: String) -> Result<PageStructure, String>;
        #[swift_bridge(swift_name = "pageBoundaryFromJson")]
        fn page_boundary_from_json(json: String) -> Result<PageBoundary, String>;
        #[swift_bridge(swift_name = "pageInfoFromJson")]
        fn page_info_from_json(json: String) -> Result<PageInfo, String>;
        #[swift_bridge(swift_name = "pageContentFromJson")]
        fn page_content_from_json(json: String) -> Result<PageContent, String>;
        #[swift_bridge(swift_name = "layoutRegionFromJson")]
        fn layout_region_from_json(json: String) -> Result<LayoutRegion, String>;
        #[swift_bridge(swift_name = "pageHierarchyFromJson")]
        fn page_hierarchy_from_json(json: String) -> Result<PageHierarchy, String>;
        #[swift_bridge(swift_name = "hierarchicalBlockFromJson")]
        fn hierarchical_block_from_json(json: String) -> Result<HierarchicalBlock, String>;
        #[swift_bridge(swift_name = "cellChangeFromJson")]
        fn cell_change_from_json(json: String) -> Result<CellChange, String>;
        #[swift_bridge(swift_name = "documentRevisionFromJson")]
        fn document_revision_from_json(json: String) -> Result<DocumentRevision, String>;
        #[swift_bridge(swift_name = "revisionDeltaFromJson")]
        fn revision_delta_from_json(json: String) -> Result<RevisionDelta, String>;
        #[swift_bridge(swift_name = "tableFromJson")]
        fn table_from_json(json: String) -> Result<Table, String>;
        #[swift_bridge(swift_name = "tableCellFromJson")]
        fn table_cell_from_json(json: String) -> Result<TableCell, String>;
        #[swift_bridge(swift_name = "extractedUriFromJson")]
        fn extracted_uri_from_json(json: String) -> Result<ExtractedUri, String>;
        #[swift_bridge(swift_name = "detectResponseFromJson")]
        fn detect_response_from_json(json: String) -> Result<DetectResponse, String>;
        #[swift_bridge(swift_name = "extractionDiffFromJson")]
        fn extraction_diff_from_json(json: String) -> Result<ExtractionDiff, String>;
        #[swift_bridge(swift_name = "diffHunkFromJson")]
        fn diff_hunk_from_json(json: String) -> Result<DiffHunk, String>;
        #[swift_bridge(swift_name = "tableDiffFromJson")]
        fn table_diff_from_json(json: String) -> Result<TableDiff, String>;
        #[swift_bridge(swift_name = "embeddedChangesFromJson")]
        fn embedded_changes_from_json(json: String) -> Result<EmbeddedChanges, String>;
        #[swift_bridge(swift_name = "embeddedDiffFromJson")]
        fn embedded_diff_from_json(json: String) -> Result<EmbeddedDiff, String>;
        #[swift_bridge(swift_name = "embeddingPresetFromJson")]
        fn embedding_preset_from_json(json: String) -> Result<EmbeddingPreset, String>;
        #[swift_bridge(swift_name = "yakeParamsFromJson")]
        fn yake_params_from_json(json: String) -> Result<YakeParams, String>;
        #[swift_bridge(swift_name = "rakeParamsFromJson")]
        fn rake_params_from_json(json: String) -> Result<RakeParams, String>;
        #[swift_bridge(swift_name = "keywordConfigFromJson")]
        fn keyword_config_from_json(json: String) -> Result<KeywordConfig, String>;
        #[swift_bridge(swift_name = "keywordFromJson")]
        fn keyword_from_json(json: String) -> Result<Keyword, String>;
        #[swift_bridge(swift_name = "paddleOcrConfigFromJson")]
        fn paddle_ocr_config_from_json(json: String) -> Result<PaddleOcrConfig, String>;
        #[swift_bridge(swift_name = "modelPathsFromJson")]
        fn model_paths_from_json(json: String) -> Result<ModelPaths, String>;
        #[swift_bridge(swift_name = "orientationResultFromJson")]
        fn orientation_result_from_json(json: String) -> Result<OrientationResult, String>;
        #[swift_bridge(swift_name = "bBoxFromJson")]
        fn b_box_from_json(json: String) -> Result<BBox, String>;
        #[swift_bridge(swift_name = "layoutDetectionFromJson")]
        fn layout_detection_from_json(json: String) -> Result<LayoutDetection, String>;
        #[swift_bridge(swift_name = "recognizedTableFromJson")]
        fn recognized_table_from_json(json: String) -> Result<RecognizedTable, String>;
        #[swift_bridge(swift_name = "detectionResultFromJson")]
        fn detection_result_from_json(json: String) -> Result<DetectionResult, String>;
        #[swift_bridge(swift_name = "embeddedFileFromJson")]
        fn embedded_file_from_json(json: String) -> Result<EmbeddedFile, String>;
        #[swift_bridge(swift_name = "pdfMetadataFromJson")]
        fn pdf_metadata_from_json(json: String) -> Result<PdfMetadata, String>;
    }
    extern "Rust" {
        #[swift_bridge(swift_name = "executionProviderTypeFromJson")]
        fn execution_provider_type_from_json(json: String) -> Result<ExecutionProviderType, String>;
        #[swift_bridge(swift_name = "outputFormatFromJson")]
        fn output_format_from_json(json: String) -> Result<OutputFormat, String>;
        #[swift_bridge(swift_name = "htmlThemeFromJson")]
        fn html_theme_from_json(json: String) -> Result<HtmlTheme, String>;
        #[swift_bridge(swift_name = "tableModelFromJson")]
        fn table_model_from_json(json: String) -> Result<TableModel, String>;
        #[swift_bridge(swift_name = "chunkerTypeFromJson")]
        fn chunker_type_from_json(json: String) -> Result<ChunkerType, String>;
        #[swift_bridge(swift_name = "chunkSizingFromJson")]
        fn chunk_sizing_from_json(json: String) -> Result<ChunkSizing, String>;
        #[swift_bridge(swift_name = "embeddingModelTypeFromJson")]
        fn embedding_model_type_from_json(json: String) -> Result<EmbeddingModelType, String>;
        #[swift_bridge(swift_name = "codeContentModeFromJson")]
        fn code_content_mode_from_json(json: String) -> Result<CodeContentMode, String>;
        #[swift_bridge(swift_name = "ocrBackendTypeFromJson")]
        fn ocr_backend_type_from_json(json: String) -> Result<OcrBackendType, String>;
        #[swift_bridge(swift_name = "processingStageFromJson")]
        fn processing_stage_from_json(json: String) -> Result<ProcessingStage, String>;
        #[swift_bridge(swift_name = "reductionLevelFromJson")]
        fn reduction_level_from_json(json: String) -> Result<ReductionLevel, String>;
        #[swift_bridge(swift_name = "pdfAnnotationTypeFromJson")]
        fn pdf_annotation_type_from_json(json: String) -> Result<PdfAnnotationType, String>;
        #[swift_bridge(swift_name = "blockTypeFromJson")]
        fn block_type_from_json(json: String) -> Result<BlockType, String>;
        #[swift_bridge(swift_name = "inlineTypeFromJson")]
        fn inline_type_from_json(json: String) -> Result<InlineType, String>;
        #[swift_bridge(swift_name = "relationshipKindFromJson")]
        fn relationship_kind_from_json(json: String) -> Result<RelationshipKind, String>;
        #[swift_bridge(swift_name = "contentLayerFromJson")]
        fn content_layer_from_json(json: String) -> Result<ContentLayer, String>;
        #[swift_bridge(swift_name = "nodeContentFromJson")]
        fn node_content_from_json(json: String) -> Result<NodeContent, String>;
        #[swift_bridge(swift_name = "annotationKindFromJson")]
        fn annotation_kind_from_json(json: String) -> Result<AnnotationKind, String>;
        #[swift_bridge(swift_name = "extractionMethodFromJson")]
        fn extraction_method_from_json(json: String) -> Result<ExtractionMethod, String>;
        #[swift_bridge(swift_name = "chunkTypeFromJson")]
        fn chunk_type_from_json(json: String) -> Result<ChunkType, String>;
        #[swift_bridge(swift_name = "imageKindFromJson")]
        fn image_kind_from_json(json: String) -> Result<ImageKind, String>;
        #[swift_bridge(swift_name = "resultFormatFromJson")]
        fn result_format_from_json(json: String) -> Result<ResultFormat, String>;
        #[swift_bridge(swift_name = "elementTypeFromJson")]
        fn element_type_from_json(json: String) -> Result<ElementType, String>;
        #[swift_bridge(swift_name = "formatMetadataFromJson")]
        fn format_metadata_from_json(json: String) -> Result<FormatMetadata, String>;
        #[swift_bridge(swift_name = "textDirectionFromJson")]
        fn text_direction_from_json(json: String) -> Result<TextDirection, String>;
        #[swift_bridge(swift_name = "linkTypeFromJson")]
        fn link_type_from_json(json: String) -> Result<LinkType, String>;
        #[swift_bridge(swift_name = "imageTypeFromJson")]
        fn image_type_from_json(json: String) -> Result<ImageType, String>;
        #[swift_bridge(swift_name = "structuredDataTypeFromJson")]
        fn structured_data_type_from_json(json: String) -> Result<StructuredDataType, String>;
        #[swift_bridge(swift_name = "ocrBoundingGeometryFromJson")]
        fn ocr_bounding_geometry_from_json(json: String) -> Result<OcrBoundingGeometry, String>;
        #[swift_bridge(swift_name = "ocrElementLevelFromJson")]
        fn ocr_element_level_from_json(json: String) -> Result<OcrElementLevel, String>;
        #[swift_bridge(swift_name = "pageUnitTypeFromJson")]
        fn page_unit_type_from_json(json: String) -> Result<PageUnitType, String>;
        #[swift_bridge(swift_name = "diffLineFromJson")]
        fn diff_line_from_json(json: String) -> Result<DiffLine, String>;
        #[swift_bridge(swift_name = "revisionKindFromJson")]
        fn revision_kind_from_json(json: String) -> Result<RevisionKind, String>;
        #[swift_bridge(swift_name = "revisionAnchorFromJson")]
        fn revision_anchor_from_json(json: String) -> Result<RevisionAnchor, String>;
        #[swift_bridge(swift_name = "uriKindFromJson")]
        fn uri_kind_from_json(json: String) -> Result<UriKind, String>;
        #[swift_bridge(swift_name = "keywordAlgorithmFromJson")]
        fn keyword_algorithm_from_json(json: String) -> Result<KeywordAlgorithm, String>;
        #[swift_bridge(swift_name = "psmModeFromJson")]
        fn psm_mode_from_json(json: String) -> Result<PSMMode, String>;
        #[swift_bridge(swift_name = "paddleLanguageFromJson")]
        fn paddle_language_from_json(json: String) -> Result<PaddleLanguage, String>;
        #[swift_bridge(swift_name = "layoutClassFromJson")]
        fn layout_class_from_json(json: String) -> Result<LayoutClass, String>;
    }
}

pub struct CacheStats(pub kreuzberg::CacheStats);
impl CacheStats {
    pub fn new(
        total_files: usize,
        total_size_mb: f64,
        available_space_mb: f64,
        oldest_file_age_days: f64,
        newest_file_age_days: f64,
    ) -> CacheStats {
        CacheStats(kreuzberg::CacheStats {
            total_files,
            total_size_mb,
            available_space_mb,
            oldest_file_age_days,
            newest_file_age_days,
        })
    }
    pub fn total_files(&self) -> usize {
        ::serde_json::to_value(&self.0.total_files)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn total_size_mb(&self) -> f64 {
        ::serde_json::to_value(&self.0.total_size_mb)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn available_space_mb(&self) -> f64 {
        ::serde_json::to_value(&self.0.available_space_mb)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn oldest_file_age_days(&self) -> f64 {
        ::serde_json::to_value(&self.0.oldest_file_age_days)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn newest_file_age_days(&self) -> f64 {
        ::serde_json::to_value(&self.0.newest_file_age_days)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct AccelerationConfig(pub kreuzberg::AccelerationConfig);
impl AccelerationConfig {
    pub fn new(provider: ExecutionProviderType, device_id: u32) -> AccelerationConfig {
        let mut __target: kreuzberg::AccelerationConfig = ::std::default::Default::default();
        // alef: provider (ExecutionProviderType) is an enum; reverse From not generated — left at default
        __target.device_id = device_id;
        AccelerationConfig(__target)
    }
    pub fn provider(&self) -> String {
        ExecutionProviderType::from(self.0.provider.clone()).to_string()
    }
    pub fn device_id(&self) -> u32 {
        ::serde_json::to_value(&self.0.device_id)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ContentFilterConfig(pub kreuzberg::ContentFilterConfig);
impl ContentFilterConfig {
    pub fn new(
        include_headers: bool,
        include_footers: bool,
        strip_repeating_text: bool,
        include_watermarks: bool,
    ) -> ContentFilterConfig {
        ContentFilterConfig(kreuzberg::ContentFilterConfig {
            include_headers,
            include_footers,
            strip_repeating_text,
            include_watermarks,
        })
    }
    pub fn include_headers(&self) -> bool {
        ::serde_json::to_value(&self.0.include_headers)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_footers(&self) -> bool {
        ::serde_json::to_value(&self.0.include_footers)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn strip_repeating_text(&self) -> bool {
        ::serde_json::to_value(&self.0.strip_repeating_text)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_watermarks(&self) -> bool {
        ::serde_json::to_value(&self.0.include_watermarks)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct EmailConfig(pub kreuzberg::EmailConfig);
impl EmailConfig {
    pub fn new(msg_fallback_codepage: Option<u32>) -> EmailConfig {
        EmailConfig(kreuzberg::EmailConfig { msg_fallback_codepage })
    }
    pub fn msg_fallback_codepage(&self) -> Option<u32> {
        self.0.msg_fallback_codepage.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct ExtractionConfig(pub kreuzberg::ExtractionConfig);
impl ExtractionConfig {
    pub fn new(
        use_cache: bool,
        enable_quality_processing: bool,
        ocr: Option<OcrConfig>,
        force_ocr: bool,
        force_ocr_pages: Option<Vec<u32>>,
        disable_ocr: bool,
        chunking: Option<ChunkingConfig>,
        content_filter: Option<ContentFilterConfig>,
        images: Option<ImageExtractionConfig>,
        pdf_options: Option<PdfConfig>,
        token_reduction: Option<TokenReductionOptions>,
        language_detection: Option<LanguageDetectionConfig>,
        pages: Option<PageConfig>,
        keywords: Option<KeywordConfig>,
        postprocessor: Option<PostProcessorConfig>,
        html_options: Option<String>,
        html_output: Option<HtmlOutputConfig>,
        extraction_timeout_secs: Option<u64>,
        max_concurrent_extractions: Option<usize>,
        result_format: ResultFormat,
        security_limits: Option<SecurityLimits>,
        max_embedded_file_bytes: Option<u64>,
        output_format: OutputFormat,
        layout: Option<LayoutDetectionConfig>,
        use_layout_for_markdown: bool,
        include_document_structure: bool,
        acceleration: Option<AccelerationConfig>,
        cache_namespace: Option<String>,
        cache_ttl_secs: Option<u64>,
        email: Option<EmailConfig>,
        concurrency: Option<String>,
        max_archive_depth: usize,
        tree_sitter: Option<TreeSitterConfig>,
        structured_extraction: Option<StructuredExtractionConfig>,
        cancel_token: Option<String>,
    ) -> ExtractionConfig {
        let mut __target: kreuzberg::ExtractionConfig = ::std::default::Default::default();
        __target.use_cache = use_cache;
        __target.enable_quality_processing = enable_quality_processing;
        if let Some(w) = ocr {
            __target.ocr = Some(w.0);
        }
        __target.force_ocr = force_ocr;
        if let Ok(__v) = ::serde_json::to_value(force_ocr_pages) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.force_ocr_pages = t;
            }
        }
        __target.disable_ocr = disable_ocr;
        if let Some(w) = chunking {
            __target.chunking = Some(w.0);
        }
        if let Some(w) = content_filter {
            __target.content_filter = Some(w.0);
        }
        if let Some(w) = images {
            __target.images = Some(w.0);
        }
        if let Some(w) = pdf_options {
            __target.pdf_options = Some(w.0);
        }
        if let Some(w) = token_reduction {
            __target.token_reduction = Some(w.0);
        }
        if let Some(w) = language_detection {
            __target.language_detection = Some(w.0);
        }
        if let Some(w) = pages {
            __target.pages = Some(w.0);
        }
        if let Some(w) = keywords {
            __target.keywords = Some(w.0);
        }
        if let Some(w) = postprocessor {
            __target.postprocessor = Some(w.0);
        }
        if let Some(s) = html_options {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.html_options = Some(t);
            }
        }
        if let Some(w) = html_output {
            __target.html_output = Some(w.0);
        }
        __target.extraction_timeout_secs = extraction_timeout_secs;
        __target.max_concurrent_extractions = max_concurrent_extractions;
        // alef: result_format (ResultFormat) is an enum; reverse From not generated — left at default
        if let Some(w) = security_limits {
            __target.security_limits = Some(w.0);
        }
        __target.max_embedded_file_bytes = max_embedded_file_bytes;
        // alef: output_format (OutputFormat) is an enum; reverse From not generated — left at default
        if let Some(w) = layout {
            __target.layout = Some(w.0);
        }
        __target.use_layout_for_markdown = use_layout_for_markdown;
        __target.include_document_structure = include_document_structure;
        if let Some(w) = acceleration {
            __target.acceleration = Some(w.0);
        }
        if let Some(s) = cache_namespace {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cache_namespace = Some(t);
            }
        }
        __target.cache_ttl_secs = cache_ttl_secs;
        if let Some(w) = email {
            __target.email = Some(w.0);
        }
        if let Some(s) = concurrency {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.concurrency = Some(t);
            }
        }
        __target.max_archive_depth = max_archive_depth;
        if let Some(w) = tree_sitter {
            __target.tree_sitter = Some(w.0);
        }
        if let Some(w) = structured_extraction {
            __target.structured_extraction = Some(w.0);
        }
        if let Some(s) = cancel_token {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cancel_token = Some(t);
            }
        }
        ExtractionConfig(__target)
    }
    pub fn use_cache(&self) -> bool {
        ::serde_json::to_value(&self.0.use_cache)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn enable_quality_processing(&self) -> bool {
        ::serde_json::to_value(&self.0.enable_quality_processing)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn ocr(&self) -> Option<OcrConfig> {
        self.0.ocr.clone().map(OcrConfig)
    }
    pub fn force_ocr(&self) -> bool {
        ::serde_json::to_value(&self.0.force_ocr)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn force_ocr_pages(&self) -> Option<Vec<u32>> {
        self.0.force_ocr_pages.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn disable_ocr(&self) -> bool {
        ::serde_json::to_value(&self.0.disable_ocr)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn chunking(&self) -> Option<ChunkingConfig> {
        self.0.chunking.clone().map(ChunkingConfig)
    }
    pub fn content_filter(&self) -> Option<ContentFilterConfig> {
        self.0.content_filter.clone().map(ContentFilterConfig)
    }
    pub fn images(&self) -> Option<ImageExtractionConfig> {
        self.0.images.clone().map(ImageExtractionConfig)
    }
    pub fn pdf_options(&self) -> Option<PdfConfig> {
        self.0.pdf_options.clone().map(PdfConfig)
    }
    pub fn token_reduction(&self) -> Option<TokenReductionOptions> {
        self.0.token_reduction.clone().map(TokenReductionOptions)
    }
    pub fn language_detection(&self) -> Option<LanguageDetectionConfig> {
        self.0.language_detection.clone().map(LanguageDetectionConfig)
    }
    pub fn pages(&self) -> Option<PageConfig> {
        self.0.pages.clone().map(PageConfig)
    }
    pub fn keywords(&self) -> Option<KeywordConfig> {
        self.0.keywords.clone().map(KeywordConfig)
    }
    pub fn postprocessor(&self) -> Option<PostProcessorConfig> {
        self.0.postprocessor.clone().map(PostProcessorConfig)
    }
    pub fn html_options(&self) -> Option<String> {
        self.0.html_options.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn html_output(&self) -> Option<HtmlOutputConfig> {
        self.0.html_output.clone().map(HtmlOutputConfig)
    }
    pub fn extraction_timeout_secs(&self) -> Option<u64> {
        self.0.extraction_timeout_secs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn max_concurrent_extractions(&self) -> Option<usize> {
        self.0.max_concurrent_extractions.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn result_format(&self) -> String {
        ResultFormat::from(self.0.result_format.clone()).to_string()
    }
    pub fn security_limits(&self) -> Option<SecurityLimits> {
        self.0.security_limits.clone().map(SecurityLimits)
    }
    pub fn max_embedded_file_bytes(&self) -> Option<u64> {
        self.0.max_embedded_file_bytes.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn output_format(&self) -> String {
        OutputFormat::from(self.0.output_format.clone()).to_string()
    }
    pub fn layout(&self) -> Option<LayoutDetectionConfig> {
        self.0.layout.clone().map(LayoutDetectionConfig)
    }
    pub fn use_layout_for_markdown(&self) -> bool {
        ::serde_json::to_value(&self.0.use_layout_for_markdown)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_document_structure(&self) -> bool {
        ::serde_json::to_value(&self.0.include_document_structure)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn acceleration(&self) -> Option<AccelerationConfig> {
        self.0.acceleration.clone().map(AccelerationConfig)
    }
    pub fn cache_namespace(&self) -> Option<String> {
        self.0.cache_namespace.clone()
    }
    pub fn cache_ttl_secs(&self) -> Option<u64> {
        self.0.cache_ttl_secs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn email(&self) -> Option<EmailConfig> {
        self.0.email.clone().map(EmailConfig)
    }
    pub fn concurrency(&self) -> Option<String> {
        self.0.concurrency.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn max_archive_depth(&self) -> usize {
        ::serde_json::to_value(&self.0.max_archive_depth)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn tree_sitter(&self) -> Option<TreeSitterConfig> {
        self.0.tree_sitter.clone().map(TreeSitterConfig)
    }
    pub fn structured_extraction(&self) -> Option<StructuredExtractionConfig> {
        self.0.structured_extraction.clone().map(StructuredExtractionConfig)
    }
    pub fn cancel_token(&self) -> Option<String> {
        self.0.cancel_token.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
}

pub struct FileExtractionConfig(pub kreuzberg::FileExtractionConfig);
impl FileExtractionConfig {
    pub fn new(
        enable_quality_processing: Option<bool>,
        ocr: Option<OcrConfig>,
        force_ocr: Option<bool>,
        force_ocr_pages: Option<Vec<u32>>,
        disable_ocr: Option<bool>,
        chunking: Option<ChunkingConfig>,
        content_filter: Option<ContentFilterConfig>,
        images: Option<ImageExtractionConfig>,
        pdf_options: Option<PdfConfig>,
        token_reduction: Option<TokenReductionOptions>,
        language_detection: Option<LanguageDetectionConfig>,
        pages: Option<PageConfig>,
        keywords: Option<KeywordConfig>,
        postprocessor: Option<PostProcessorConfig>,
        html_options: Option<String>,
        result_format: Option<ResultFormat>,
        output_format: Option<OutputFormat>,
        include_document_structure: Option<bool>,
        layout: Option<LayoutDetectionConfig>,
        timeout_secs: Option<u64>,
        tree_sitter: Option<TreeSitterConfig>,
        structured_extraction: Option<StructuredExtractionConfig>,
    ) -> FileExtractionConfig {
        let mut __target: kreuzberg::FileExtractionConfig = ::std::default::Default::default();
        __target.enable_quality_processing = enable_quality_processing;
        if let Some(w) = ocr {
            __target.ocr = Some(w.0);
        }
        __target.force_ocr = force_ocr;
        if let Ok(__v) = ::serde_json::to_value(force_ocr_pages) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.force_ocr_pages = t;
            }
        }
        __target.disable_ocr = disable_ocr;
        if let Some(w) = chunking {
            __target.chunking = Some(w.0);
        }
        if let Some(w) = content_filter {
            __target.content_filter = Some(w.0);
        }
        if let Some(w) = images {
            __target.images = Some(w.0);
        }
        if let Some(w) = pdf_options {
            __target.pdf_options = Some(w.0);
        }
        if let Some(w) = token_reduction {
            __target.token_reduction = Some(w.0);
        }
        if let Some(w) = language_detection {
            __target.language_detection = Some(w.0);
        }
        if let Some(w) = pages {
            __target.pages = Some(w.0);
        }
        if let Some(w) = keywords {
            __target.keywords = Some(w.0);
        }
        if let Some(w) = postprocessor {
            __target.postprocessor = Some(w.0);
        }
        if let Some(s) = html_options {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.html_options = Some(t);
            }
        }
        // alef: result_format (ResultFormat) is an enum; reverse From not generated — left at default
        // alef: output_format (OutputFormat) is an enum; reverse From not generated — left at default
        __target.include_document_structure = include_document_structure;
        if let Some(w) = layout {
            __target.layout = Some(w.0);
        }
        __target.timeout_secs = timeout_secs;
        if let Some(w) = tree_sitter {
            __target.tree_sitter = Some(w.0);
        }
        if let Some(w) = structured_extraction {
            __target.structured_extraction = Some(w.0);
        }
        FileExtractionConfig(__target)
    }
    pub fn enable_quality_processing(&self) -> Option<bool> {
        self.0.enable_quality_processing.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn ocr(&self) -> Option<OcrConfig> {
        self.0.ocr.clone().map(OcrConfig)
    }
    pub fn force_ocr(&self) -> Option<bool> {
        self.0.force_ocr.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn force_ocr_pages(&self) -> Option<Vec<u32>> {
        self.0.force_ocr_pages.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn disable_ocr(&self) -> Option<bool> {
        self.0.disable_ocr.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn chunking(&self) -> Option<ChunkingConfig> {
        self.0.chunking.clone().map(ChunkingConfig)
    }
    pub fn content_filter(&self) -> Option<ContentFilterConfig> {
        self.0.content_filter.clone().map(ContentFilterConfig)
    }
    pub fn images(&self) -> Option<ImageExtractionConfig> {
        self.0.images.clone().map(ImageExtractionConfig)
    }
    pub fn pdf_options(&self) -> Option<PdfConfig> {
        self.0.pdf_options.clone().map(PdfConfig)
    }
    pub fn token_reduction(&self) -> Option<TokenReductionOptions> {
        self.0.token_reduction.clone().map(TokenReductionOptions)
    }
    pub fn language_detection(&self) -> Option<LanguageDetectionConfig> {
        self.0.language_detection.clone().map(LanguageDetectionConfig)
    }
    pub fn pages(&self) -> Option<PageConfig> {
        self.0.pages.clone().map(PageConfig)
    }
    pub fn keywords(&self) -> Option<KeywordConfig> {
        self.0.keywords.clone().map(KeywordConfig)
    }
    pub fn postprocessor(&self) -> Option<PostProcessorConfig> {
        self.0.postprocessor.clone().map(PostProcessorConfig)
    }
    pub fn html_options(&self) -> Option<String> {
        self.0.html_options.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn result_format(&self) -> Option<String> {
        self.0.result_format.clone().map(|w| ResultFormat::from(w).to_string())
    }
    pub fn output_format(&self) -> Option<String> {
        self.0.output_format.clone().map(|w| OutputFormat::from(w).to_string())
    }
    pub fn include_document_structure(&self) -> Option<bool> {
        self.0.include_document_structure.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn layout(&self) -> Option<LayoutDetectionConfig> {
        self.0.layout.clone().map(LayoutDetectionConfig)
    }
    pub fn timeout_secs(&self) -> Option<u64> {
        self.0.timeout_secs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn tree_sitter(&self) -> Option<TreeSitterConfig> {
        self.0.tree_sitter.clone().map(TreeSitterConfig)
    }
    pub fn structured_extraction(&self) -> Option<StructuredExtractionConfig> {
        self.0.structured_extraction.clone().map(StructuredExtractionConfig)
    }
}

pub struct BatchBytesItem(pub kreuzberg::BatchBytesItem);
impl BatchBytesItem {
    pub fn content(&self) -> Vec<u8> {
        self.0.content.to_vec()
    }
    pub fn mime_type(&self) -> String {
        self.0.mime_type.clone()
    }
    pub fn config(&self) -> Option<FileExtractionConfig> {
        self.0.config.clone().map(FileExtractionConfig)
    }
}

pub struct BatchFileItem(pub kreuzberg::BatchFileItem);
impl BatchFileItem {
    pub fn path(&self) -> String {
        serde_json::to_string(&self.0.path).unwrap_or_default()
    }
    pub fn config(&self) -> Option<FileExtractionConfig> {
        self.0.config.clone().map(FileExtractionConfig)
    }
}

pub struct ImageExtractionConfig(pub kreuzberg::ImageExtractionConfig);
impl ImageExtractionConfig {
    pub fn new(
        extract_images: bool,
        target_dpi: i32,
        max_image_dimension: i32,
        inject_placeholders: bool,
        auto_adjust_dpi: bool,
        min_dpi: i32,
        max_dpi: i32,
        max_images_per_page: Option<u32>,
        classify: bool,
        include_page_rasters: bool,
        run_ocr_on_images: bool,
        ocr_text_only: bool,
        append_ocr_text: bool,
    ) -> ImageExtractionConfig {
        ImageExtractionConfig(kreuzberg::ImageExtractionConfig {
            extract_images,
            target_dpi,
            max_image_dimension,
            inject_placeholders,
            auto_adjust_dpi,
            min_dpi,
            max_dpi,
            max_images_per_page,
            classify,
            include_page_rasters,
            run_ocr_on_images,
            ocr_text_only,
            append_ocr_text,
        })
    }
    pub fn extract_images(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_images)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn target_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.target_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_image_dimension(&self) -> i32 {
        ::serde_json::to_value(&self.0.max_image_dimension)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn inject_placeholders(&self) -> bool {
        ::serde_json::to_value(&self.0.inject_placeholders)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn auto_adjust_dpi(&self) -> bool {
        ::serde_json::to_value(&self.0.auto_adjust_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.min_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.max_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_images_per_page(&self) -> Option<u32> {
        self.0.max_images_per_page.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn classify(&self) -> bool {
        ::serde_json::to_value(&self.0.classify)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_page_rasters(&self) -> bool {
        ::serde_json::to_value(&self.0.include_page_rasters)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn run_ocr_on_images(&self) -> bool {
        ::serde_json::to_value(&self.0.run_ocr_on_images)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn ocr_text_only(&self) -> bool {
        ::serde_json::to_value(&self.0.ocr_text_only)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn append_ocr_text(&self) -> bool {
        ::serde_json::to_value(&self.0.append_ocr_text)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct TokenReductionOptions(pub kreuzberg::TokenReductionOptions);
impl TokenReductionOptions {
    pub fn new(mode: String, preserve_important_words: bool) -> TokenReductionOptions {
        let mut __target: kreuzberg::TokenReductionOptions = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&mode)
                .unwrap_or(::serde_json::Value::String(mode.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.mode = t;
            }
        }
        __target.preserve_important_words = preserve_important_words;
        TokenReductionOptions(__target)
    }
    pub fn mode(&self) -> String {
        self.0.mode.clone()
    }
    pub fn preserve_important_words(&self) -> bool {
        ::serde_json::to_value(&self.0.preserve_important_words)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct LanguageDetectionConfig(pub kreuzberg::LanguageDetectionConfig);
impl LanguageDetectionConfig {
    pub fn new(enabled: bool, min_confidence: f64, detect_multiple: bool) -> LanguageDetectionConfig {
        LanguageDetectionConfig(kreuzberg::LanguageDetectionConfig {
            enabled,
            min_confidence,
            detect_multiple,
        })
    }
    pub fn enabled(&self) -> bool {
        ::serde_json::to_value(&self.0.enabled)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_confidence(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn detect_multiple(&self) -> bool {
        ::serde_json::to_value(&self.0.detect_multiple)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct HtmlOutputConfig(pub kreuzberg::HtmlOutputConfig);
impl HtmlOutputConfig {
    pub fn new(
        css: Option<String>,
        css_file: Option<String>,
        theme: HtmlTheme,
        class_prefix: String,
        embed_css: bool,
    ) -> HtmlOutputConfig {
        let mut __target: kreuzberg::HtmlOutputConfig = ::std::default::Default::default();
        if let Some(s) = css {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.css = Some(t);
            }
        }
        if let Some(s) = css_file {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.css_file = Some(t);
            }
        }
        // alef: theme (HtmlTheme) is an enum; reverse From not generated — left at default
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&class_prefix)
                .unwrap_or(::serde_json::Value::String(class_prefix.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.class_prefix = t;
            }
        }
        __target.embed_css = embed_css;
        HtmlOutputConfig(__target)
    }
    pub fn css(&self) -> Option<String> {
        self.0.css.clone()
    }
    pub fn css_file(&self) -> Option<String> {
        self.0.css_file.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn theme(&self) -> String {
        HtmlTheme::from(self.0.theme.clone()).to_string()
    }
    pub fn class_prefix(&self) -> String {
        self.0.class_prefix.clone()
    }
    pub fn embed_css(&self) -> bool {
        ::serde_json::to_value(&self.0.embed_css)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct LayoutDetectionConfig(pub kreuzberg::LayoutDetectionConfig);
impl LayoutDetectionConfig {
    pub fn new(
        confidence_threshold: Option<f32>,
        apply_heuristics: bool,
        table_model: TableModel,
        acceleration: Option<AccelerationConfig>,
    ) -> LayoutDetectionConfig {
        let mut __target: kreuzberg::LayoutDetectionConfig = ::std::default::Default::default();
        __target.confidence_threshold = confidence_threshold;
        __target.apply_heuristics = apply_heuristics;
        // alef: table_model (TableModel) is an enum; reverse From not generated — left at default
        if let Some(w) = acceleration {
            __target.acceleration = Some(w.0);
        }
        LayoutDetectionConfig(__target)
    }
    pub fn confidence_threshold(&self) -> Option<f32> {
        self.0.confidence_threshold.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn apply_heuristics(&self) -> bool {
        ::serde_json::to_value(&self.0.apply_heuristics)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_model(&self) -> String {
        TableModel::from(self.0.table_model.clone()).to_string()
    }
    pub fn acceleration(&self) -> Option<AccelerationConfig> {
        self.0.acceleration.clone().map(AccelerationConfig)
    }
}

pub struct LlmConfig(pub kreuzberg::LlmConfig);
impl LlmConfig {
    pub fn new(
        model: String,
        api_key: Option<String>,
        base_url: Option<String>,
        timeout_secs: Option<u64>,
        max_retries: Option<u32>,
        temperature: Option<f64>,
        max_tokens: Option<u64>,
    ) -> LlmConfig {
        let mut __target: kreuzberg::LlmConfig = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&model)
                .unwrap_or(::serde_json::Value::String(model.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.model = t;
            }
        }
        if let Some(s) = api_key {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.api_key = Some(t);
            }
        }
        if let Some(s) = base_url {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.base_url = Some(t);
            }
        }
        __target.timeout_secs = timeout_secs;
        __target.max_retries = max_retries;
        __target.temperature = temperature;
        __target.max_tokens = max_tokens;
        LlmConfig(__target)
    }
    pub fn model(&self) -> String {
        self.0.model.clone()
    }
    pub fn api_key(&self) -> Option<String> {
        self.0.api_key.clone()
    }
    pub fn base_url(&self) -> Option<String> {
        self.0.base_url.clone()
    }
    pub fn timeout_secs(&self) -> Option<u64> {
        self.0.timeout_secs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn max_retries(&self) -> Option<u32> {
        self.0.max_retries.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn temperature(&self) -> Option<f64> {
        self.0.temperature.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn max_tokens(&self) -> Option<u64> {
        self.0.max_tokens.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct StructuredExtractionConfig(pub kreuzberg::StructuredExtractionConfig);
impl StructuredExtractionConfig {
    pub fn schema(&self) -> String {
        serde_json::to_string(&self.0.schema).unwrap_or_default()
    }
    pub fn schema_name(&self) -> String {
        self.0.schema_name.clone()
    }
    pub fn schema_description(&self) -> Option<String> {
        self.0.schema_description.clone()
    }
    pub fn strict(&self) -> bool {
        ::serde_json::to_value(&self.0.strict)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn prompt(&self) -> Option<String> {
        self.0.prompt.clone()
    }
    pub fn llm(&self) -> LlmConfig {
        LlmConfig(self.0.llm.clone())
    }
}

pub struct OcrQualityThresholds(pub kreuzberg::OcrQualityThresholds);
impl OcrQualityThresholds {
    pub fn new(
        min_total_non_whitespace: usize,
        min_non_whitespace_per_page: f64,
        min_meaningful_word_len: usize,
        min_meaningful_words: usize,
        min_alnum_ratio: f64,
        min_garbage_chars: usize,
        max_fragmented_word_ratio: f64,
        critical_fragmented_word_ratio: f64,
        min_avg_word_length: f64,
        min_words_for_avg_length_check: usize,
        min_consecutive_repeat_ratio: f64,
        min_words_for_repeat_check: usize,
        substantive_min_chars: usize,
        non_text_min_chars: usize,
        alnum_ws_ratio_threshold: f64,
        pipeline_min_quality: f64,
    ) -> OcrQualityThresholds {
        OcrQualityThresholds(kreuzberg::OcrQualityThresholds {
            min_total_non_whitespace,
            min_non_whitespace_per_page,
            min_meaningful_word_len,
            min_meaningful_words,
            min_alnum_ratio,
            min_garbage_chars,
            max_fragmented_word_ratio,
            critical_fragmented_word_ratio,
            min_avg_word_length,
            min_words_for_avg_length_check,
            min_consecutive_repeat_ratio,
            min_words_for_repeat_check,
            substantive_min_chars,
            non_text_min_chars,
            alnum_ws_ratio_threshold,
            pipeline_min_quality,
        })
    }
    pub fn min_total_non_whitespace(&self) -> usize {
        ::serde_json::to_value(&self.0.min_total_non_whitespace)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_non_whitespace_per_page(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_non_whitespace_per_page)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_meaningful_word_len(&self) -> usize {
        ::serde_json::to_value(&self.0.min_meaningful_word_len)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_meaningful_words(&self) -> usize {
        ::serde_json::to_value(&self.0.min_meaningful_words)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_alnum_ratio(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_alnum_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_garbage_chars(&self) -> usize {
        ::serde_json::to_value(&self.0.min_garbage_chars)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_fragmented_word_ratio(&self) -> f64 {
        ::serde_json::to_value(&self.0.max_fragmented_word_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn critical_fragmented_word_ratio(&self) -> f64 {
        ::serde_json::to_value(&self.0.critical_fragmented_word_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_avg_word_length(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_avg_word_length)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_words_for_avg_length_check(&self) -> usize {
        ::serde_json::to_value(&self.0.min_words_for_avg_length_check)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_consecutive_repeat_ratio(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_consecutive_repeat_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_words_for_repeat_check(&self) -> usize {
        ::serde_json::to_value(&self.0.min_words_for_repeat_check)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn substantive_min_chars(&self) -> usize {
        ::serde_json::to_value(&self.0.substantive_min_chars)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn non_text_min_chars(&self) -> usize {
        ::serde_json::to_value(&self.0.non_text_min_chars)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn alnum_ws_ratio_threshold(&self) -> f64 {
        ::serde_json::to_value(&self.0.alnum_ws_ratio_threshold)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn pipeline_min_quality(&self) -> f64 {
        ::serde_json::to_value(&self.0.pipeline_min_quality)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct OcrPipelineStage(pub kreuzberg::OcrPipelineStage);
impl OcrPipelineStage {
    pub fn backend(&self) -> String {
        self.0.backend.clone()
    }
    pub fn priority(&self) -> u32 {
        ::serde_json::to_value(&self.0.priority)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn tesseract_config(&self) -> Option<TesseractConfig> {
        self.0.tesseract_config.clone().map(TesseractConfig)
    }
    pub fn paddle_ocr_config(&self) -> Option<String> {
        self.0
            .paddle_ocr_config
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn vlm_config(&self) -> Option<LlmConfig> {
        self.0.vlm_config.clone().map(LlmConfig)
    }
    pub fn backend_options(&self) -> Option<String> {
        self.0
            .backend_options
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
}

pub struct OcrPipelineConfig(pub kreuzberg::OcrPipelineConfig);
impl OcrPipelineConfig {
    pub fn stages(&self) -> Vec<OcrPipelineStage> {
        self.0
            .stages
            .iter()
            .map(|elem| OcrPipelineStage(elem.clone()))
            .collect()
    }
    pub fn quality_thresholds(&self) -> OcrQualityThresholds {
        OcrQualityThresholds(self.0.quality_thresholds.clone())
    }
}

pub struct OcrConfig(pub kreuzberg::OcrConfig);
impl OcrConfig {
    pub fn new(
        enabled: bool,
        backend: String,
        language: String,
        tesseract_config: Option<TesseractConfig>,
        output_format: Option<OutputFormat>,
        paddle_ocr_config: Option<String>,
        backend_options: Option<String>,
        element_config: Option<OcrElementConfig>,
        quality_thresholds: Option<OcrQualityThresholds>,
        pipeline: Option<OcrPipelineConfig>,
        auto_rotate: bool,
        vlm_config: Option<LlmConfig>,
        vlm_prompt: Option<String>,
        acceleration: Option<AccelerationConfig>,
        tessdata_bytes: String,
    ) -> OcrConfig {
        let mut __target: kreuzberg::OcrConfig = ::std::default::Default::default();
        __target.enabled = enabled;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&backend)
                .unwrap_or(::serde_json::Value::String(backend.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.backend = t;
            }
        }
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&language)
                .unwrap_or(::serde_json::Value::String(language.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = t;
            }
        }
        if let Some(w) = tesseract_config {
            __target.tesseract_config = Some(w.0);
        }
        // alef: output_format (OutputFormat) is an enum; reverse From not generated — left at default
        if let Some(s) = paddle_ocr_config {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.paddle_ocr_config = Some(t);
            }
        }
        if let Some(s) = backend_options {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.backend_options = Some(t);
            }
        }
        if let Some(w) = element_config {
            __target.element_config = Some(w.0);
        }
        if let Some(w) = quality_thresholds {
            __target.quality_thresholds = Some(w.0);
        }
        if let Some(w) = pipeline {
            __target.pipeline = Some(w.0);
        }
        __target.auto_rotate = auto_rotate;
        if let Some(w) = vlm_config {
            __target.vlm_config = Some(w.0);
        }
        if let Some(s) = vlm_prompt {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.vlm_prompt = Some(t);
            }
        }
        if let Some(w) = acceleration {
            __target.acceleration = Some(w.0);
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&tessdata_bytes) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.tessdata_bytes = t;
            }
        }
        OcrConfig(__target)
    }
    pub fn enabled(&self) -> bool {
        ::serde_json::to_value(&self.0.enabled)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn backend(&self) -> String {
        self.0.backend.clone()
    }
    pub fn language(&self) -> String {
        self.0.language.clone()
    }
    pub fn tesseract_config(&self) -> Option<TesseractConfig> {
        self.0.tesseract_config.clone().map(TesseractConfig)
    }
    pub fn output_format(&self) -> Option<String> {
        self.0.output_format.clone().map(|w| OutputFormat::from(w).to_string())
    }
    pub fn paddle_ocr_config(&self) -> Option<String> {
        self.0
            .paddle_ocr_config
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn backend_options(&self) -> Option<String> {
        self.0
            .backend_options
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn element_config(&self) -> Option<OcrElementConfig> {
        self.0.element_config.clone().map(OcrElementConfig)
    }
    pub fn quality_thresholds(&self) -> Option<OcrQualityThresholds> {
        self.0.quality_thresholds.clone().map(OcrQualityThresholds)
    }
    pub fn pipeline(&self) -> Option<OcrPipelineConfig> {
        self.0.pipeline.clone().map(OcrPipelineConfig)
    }
    pub fn auto_rotate(&self) -> bool {
        ::serde_json::to_value(&self.0.auto_rotate)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn vlm_config(&self) -> Option<LlmConfig> {
        self.0.vlm_config.clone().map(LlmConfig)
    }
    pub fn vlm_prompt(&self) -> Option<String> {
        self.0.vlm_prompt.clone()
    }
    pub fn acceleration(&self) -> Option<AccelerationConfig> {
        self.0.acceleration.clone().map(AccelerationConfig)
    }
    pub fn tessdata_bytes(&self) -> String {
        serde_json::to_string(&self.0.tessdata_bytes).expect("serializable tessdata_bytes")
    }
}

pub struct PageConfig(pub kreuzberg::PageConfig);
impl PageConfig {
    pub fn new(extract_pages: bool, insert_page_markers: bool, marker_format: String) -> PageConfig {
        let mut __target: kreuzberg::PageConfig = ::std::default::Default::default();
        __target.extract_pages = extract_pages;
        __target.insert_page_markers = insert_page_markers;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&marker_format)
                .unwrap_or(::serde_json::Value::String(marker_format.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.marker_format = t;
            }
        }
        PageConfig(__target)
    }
    pub fn extract_pages(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_pages)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn insert_page_markers(&self) -> bool {
        ::serde_json::to_value(&self.0.insert_page_markers)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn marker_format(&self) -> String {
        self.0.marker_format.clone()
    }
}

pub struct PdfConfig(pub kreuzberg::PdfConfig);
impl PdfConfig {
    pub fn new(
        extract_images: bool,
        extract_tables: bool,
        passwords: Option<Vec<String>>,
        extract_metadata: bool,
        hierarchy: Option<HierarchyConfig>,
        extract_annotations: bool,
        top_margin_fraction: Option<f32>,
        bottom_margin_fraction: Option<f32>,
        allow_single_column_tables: bool,
        ocr_inline_images: bool,
    ) -> PdfConfig {
        let mut __target: kreuzberg::PdfConfig = ::std::default::Default::default();
        __target.extract_images = extract_images;
        __target.extract_tables = extract_tables;
        if let Ok(__v) = ::serde_json::to_value(passwords) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.passwords = t;
            }
        }
        __target.extract_metadata = extract_metadata;
        if let Some(w) = hierarchy {
            __target.hierarchy = Some(w.0);
        }
        __target.extract_annotations = extract_annotations;
        __target.top_margin_fraction = top_margin_fraction;
        __target.bottom_margin_fraction = bottom_margin_fraction;
        __target.allow_single_column_tables = allow_single_column_tables;
        __target.ocr_inline_images = ocr_inline_images;
        PdfConfig(__target)
    }
    pub fn extract_images(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_images)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn extract_tables(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_tables)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn passwords(&self) -> Option<Vec<String>> {
        self.0.passwords.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn extract_metadata(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_metadata)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn hierarchy(&self) -> Option<HierarchyConfig> {
        self.0.hierarchy.clone().map(HierarchyConfig)
    }
    pub fn extract_annotations(&self) -> bool {
        ::serde_json::to_value(&self.0.extract_annotations)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn top_margin_fraction(&self) -> Option<f32> {
        self.0.top_margin_fraction.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn bottom_margin_fraction(&self) -> Option<f32> {
        self.0.bottom_margin_fraction.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn allow_single_column_tables(&self) -> bool {
        ::serde_json::to_value(&self.0.allow_single_column_tables)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn ocr_inline_images(&self) -> bool {
        ::serde_json::to_value(&self.0.ocr_inline_images)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct HierarchyConfig(pub kreuzberg::HierarchyConfig);
impl HierarchyConfig {
    pub fn new(
        enabled: bool,
        k_clusters: usize,
        include_bbox: bool,
        ocr_coverage_threshold: Option<f32>,
    ) -> HierarchyConfig {
        HierarchyConfig(kreuzberg::HierarchyConfig {
            enabled,
            k_clusters,
            include_bbox,
            ocr_coverage_threshold,
        })
    }
    pub fn enabled(&self) -> bool {
        ::serde_json::to_value(&self.0.enabled)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn k_clusters(&self) -> usize {
        ::serde_json::to_value(&self.0.k_clusters)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_bbox(&self) -> bool {
        ::serde_json::to_value(&self.0.include_bbox)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn ocr_coverage_threshold(&self) -> Option<f32> {
        self.0.ocr_coverage_threshold.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct PostProcessorConfig(pub kreuzberg::PostProcessorConfig);
impl PostProcessorConfig {
    pub fn new(
        enabled: bool,
        enabled_processors: Option<Vec<String>>,
        disabled_processors: Option<Vec<String>>,
        enabled_set: Option<Vec<String>>,
        disabled_set: Option<Vec<String>>,
    ) -> PostProcessorConfig {
        let mut __target: kreuzberg::PostProcessorConfig = ::std::default::Default::default();
        __target.enabled = enabled;
        if let Ok(__v) = ::serde_json::to_value(enabled_processors) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.enabled_processors = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(disabled_processors) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.disabled_processors = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(enabled_set) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.enabled_set = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(disabled_set) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.disabled_set = t;
            }
        }
        PostProcessorConfig(__target)
    }
    pub fn enabled(&self) -> bool {
        ::serde_json::to_value(&self.0.enabled)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn enabled_processors(&self) -> Option<Vec<String>> {
        self.0.enabled_processors.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn disabled_processors(&self) -> Option<Vec<String>> {
        self.0.disabled_processors.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn enabled_set(&self) -> Option<Vec<String>> {
        self.0.enabled_set.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn disabled_set(&self) -> Option<Vec<String>> {
        self.0.disabled_set.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct ChunkingConfig(pub kreuzberg::ChunkingConfig);
impl ChunkingConfig {
    pub fn new(
        max_characters: usize,
        overlap: usize,
        trim: bool,
        chunker_type: ChunkerType,
        embedding: Option<EmbeddingConfig>,
        preset: Option<String>,
        sizing: ChunkSizing,
        prepend_heading_context: bool,
        topic_threshold: Option<f32>,
    ) -> ChunkingConfig {
        let mut __target: kreuzberg::ChunkingConfig = ::std::default::Default::default();
        __target.max_characters = max_characters;
        __target.overlap = overlap;
        __target.trim = trim;
        // alef: chunker_type (ChunkerType) is an enum; reverse From not generated — left at default
        if let Some(w) = embedding {
            __target.embedding = Some(w.0);
        }
        if let Some(s) = preset {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.preset = Some(t);
            }
        }
        // alef: sizing (ChunkSizing) is an enum; reverse From not generated — left at default
        __target.prepend_heading_context = prepend_heading_context;
        __target.topic_threshold = topic_threshold;
        ChunkingConfig(__target)
    }
    pub fn max_characters(&self) -> usize {
        ::serde_json::to_value(&self.0.max_characters)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn overlap(&self) -> usize {
        ::serde_json::to_value(&self.0.overlap)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn trim(&self) -> bool {
        ::serde_json::to_value(&self.0.trim)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn chunker_type(&self) -> String {
        ChunkerType::from(self.0.chunker_type.clone()).to_string()
    }
    pub fn embedding(&self) -> Option<EmbeddingConfig> {
        self.0.embedding.clone().map(EmbeddingConfig)
    }
    pub fn preset(&self) -> Option<String> {
        self.0.preset.clone()
    }
    pub fn sizing(&self) -> String {
        ChunkSizing::from(self.0.sizing.clone()).to_string()
    }
    pub fn prepend_heading_context(&self) -> bool {
        ::serde_json::to_value(&self.0.prepend_heading_context)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn topic_threshold(&self) -> Option<f32> {
        self.0.topic_threshold.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct EmbeddingConfig(pub kreuzberg::EmbeddingConfig);
impl EmbeddingConfig {
    pub fn new(
        model: EmbeddingModelType,
        normalize: bool,
        batch_size: usize,
        show_download_progress: bool,
        cache_dir: Option<String>,
        acceleration: Option<AccelerationConfig>,
        max_embed_duration_secs: Option<u64>,
    ) -> EmbeddingConfig {
        let mut __target: kreuzberg::EmbeddingConfig = ::std::default::Default::default();
        // alef: model (EmbeddingModelType) is an enum; reverse From not generated — left at default
        __target.normalize = normalize;
        __target.batch_size = batch_size;
        __target.show_download_progress = show_download_progress;
        if let Some(s) = cache_dir {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cache_dir = Some(t);
            }
        }
        if let Some(w) = acceleration {
            __target.acceleration = Some(w.0);
        }
        __target.max_embed_duration_secs = max_embed_duration_secs;
        EmbeddingConfig(__target)
    }
    pub fn model(&self) -> String {
        EmbeddingModelType::from(self.0.model.clone()).to_string()
    }
    pub fn normalize(&self) -> bool {
        ::serde_json::to_value(&self.0.normalize)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn batch_size(&self) -> usize {
        ::serde_json::to_value(&self.0.batch_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn show_download_progress(&self) -> bool {
        ::serde_json::to_value(&self.0.show_download_progress)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cache_dir(&self) -> Option<String> {
        self.0.cache_dir.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn acceleration(&self) -> Option<AccelerationConfig> {
        self.0.acceleration.clone().map(AccelerationConfig)
    }
    pub fn max_embed_duration_secs(&self) -> Option<u64> {
        self.0.max_embed_duration_secs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct TreeSitterConfig(pub kreuzberg::TreeSitterConfig);
impl TreeSitterConfig {
    pub fn new(
        enabled: bool,
        cache_dir: Option<String>,
        languages: Option<Vec<String>>,
        groups: Option<Vec<String>>,
        process: TreeSitterProcessConfig,
    ) -> TreeSitterConfig {
        let mut __target: kreuzberg::TreeSitterConfig = ::std::default::Default::default();
        __target.enabled = enabled;
        if let Some(s) = cache_dir {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cache_dir = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(languages) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.languages = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(groups) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.groups = t;
            }
        }
        __target.process = process.0;
        TreeSitterConfig(__target)
    }
    pub fn enabled(&self) -> bool {
        ::serde_json::to_value(&self.0.enabled)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cache_dir(&self) -> Option<String> {
        self.0.cache_dir.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn languages(&self) -> Option<Vec<String>> {
        self.0.languages.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn groups(&self) -> Option<Vec<String>> {
        self.0.groups.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn process(&self) -> TreeSitterProcessConfig {
        TreeSitterProcessConfig(self.0.process.clone())
    }
}

pub struct TreeSitterProcessConfig(pub kreuzberg::TreeSitterProcessConfig);
impl TreeSitterProcessConfig {
    pub fn new(
        structure: bool,
        imports: bool,
        exports: bool,
        comments: bool,
        docstrings: bool,
        symbols: bool,
        diagnostics: bool,
        chunk_max_size: Option<usize>,
        content_mode: CodeContentMode,
    ) -> TreeSitterProcessConfig {
        let mut __target: kreuzberg::TreeSitterProcessConfig = ::std::default::Default::default();
        __target.structure = structure;
        __target.imports = imports;
        __target.exports = exports;
        __target.comments = comments;
        __target.docstrings = docstrings;
        __target.symbols = symbols;
        __target.diagnostics = diagnostics;
        __target.chunk_max_size = chunk_max_size;
        // alef: content_mode (CodeContentMode) is an enum; reverse From not generated — left at default
        TreeSitterProcessConfig(__target)
    }
    pub fn structure(&self) -> bool {
        ::serde_json::to_value(&self.0.structure)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn imports(&self) -> bool {
        ::serde_json::to_value(&self.0.imports)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn exports(&self) -> bool {
        ::serde_json::to_value(&self.0.exports)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn comments(&self) -> bool {
        ::serde_json::to_value(&self.0.comments)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn docstrings(&self) -> bool {
        ::serde_json::to_value(&self.0.docstrings)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn symbols(&self) -> bool {
        ::serde_json::to_value(&self.0.symbols)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn diagnostics(&self) -> bool {
        ::serde_json::to_value(&self.0.diagnostics)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn chunk_max_size(&self) -> Option<usize> {
        self.0.chunk_max_size.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn content_mode(&self) -> String {
        CodeContentMode::from(self.0.content_mode.clone()).to_string()
    }
}

pub struct SupportedFormat(pub kreuzberg::SupportedFormat);
impl SupportedFormat {
    pub fn extension_(&self) -> String {
        self.0.extension.clone()
    }
    pub fn mime_type(&self) -> String {
        self.0.mime_type.clone()
    }
}

pub struct ServerConfig(pub kreuzberg::ServerConfig);
impl ServerConfig {
    pub fn new(
        host: String,
        port: u16,
        cors_origins: Vec<String>,
        max_request_body_bytes: usize,
        max_multipart_field_bytes: usize,
    ) -> ServerConfig {
        let mut __target: kreuzberg::ServerConfig = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&host)
                .unwrap_or(::serde_json::Value::String(host.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.host = t;
            }
        }
        __target.port = port;
        if let Ok(__v) = ::serde_json::to_value(cors_origins) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cors_origins = t;
            }
        }
        __target.max_request_body_bytes = max_request_body_bytes;
        __target.max_multipart_field_bytes = max_multipart_field_bytes;
        ServerConfig(__target)
    }
    pub fn host(&self) -> String {
        self.0.host.clone()
    }
    pub fn port(&self) -> u16 {
        ::serde_json::to_value(&self.0.port)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cors_origins(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.cors_origins)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_request_body_bytes(&self) -> usize {
        ::serde_json::to_value(&self.0.max_request_body_bytes)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_multipart_field_bytes(&self) -> usize {
        ::serde_json::to_value(&self.0.max_multipart_field_bytes)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct StructuredDataResult(pub kreuzberg::extraction::structured::StructuredDataResult);
impl StructuredDataResult {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn format(&self) -> String {
        self.0.format.to_string()
    }
    pub fn metadata(&self) -> String {
        serde_json::to_string(&self.0.metadata).expect("serializable metadata")
    }
    pub fn text_fields(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.text_fields)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct DocxAppProperties(pub kreuzberg::DocxAppProperties);
impl DocxAppProperties {
    pub fn new(
        application: Option<String>,
        app_version: Option<String>,
        template: Option<String>,
        total_time: Option<i32>,
        pages: Option<i32>,
        words: Option<i32>,
        characters: Option<i32>,
        characters_with_spaces: Option<i32>,
        lines: Option<i32>,
        paragraphs: Option<i32>,
        company: Option<String>,
        doc_security: Option<i32>,
        scale_crop: Option<bool>,
        links_up_to_date: Option<bool>,
        shared_doc: Option<bool>,
        hyperlinks_changed: Option<bool>,
    ) -> DocxAppProperties {
        let mut __target: kreuzberg::DocxAppProperties = ::std::default::Default::default();
        if let Some(s) = application {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.application = Some(t);
            }
        }
        if let Some(s) = app_version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.app_version = Some(t);
            }
        }
        if let Some(s) = template {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.template = Some(t);
            }
        }
        __target.total_time = total_time;
        __target.pages = pages;
        __target.words = words;
        __target.characters = characters;
        __target.characters_with_spaces = characters_with_spaces;
        __target.lines = lines;
        __target.paragraphs = paragraphs;
        if let Some(s) = company {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.company = Some(t);
            }
        }
        __target.doc_security = doc_security;
        __target.scale_crop = scale_crop;
        __target.links_up_to_date = links_up_to_date;
        __target.shared_doc = shared_doc;
        __target.hyperlinks_changed = hyperlinks_changed;
        DocxAppProperties(__target)
    }
    pub fn application(&self) -> Option<String> {
        self.0.application.clone()
    }
    pub fn app_version(&self) -> Option<String> {
        self.0.app_version.clone()
    }
    pub fn template(&self) -> Option<String> {
        self.0.template.clone()
    }
    pub fn total_time(&self) -> Option<i32> {
        self.0.total_time.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn pages(&self) -> Option<i32> {
        self.0.pages.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn words(&self) -> Option<i32> {
        self.0.words.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn characters(&self) -> Option<i32> {
        self.0.characters.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn characters_with_spaces(&self) -> Option<i32> {
        self.0.characters_with_spaces.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn lines(&self) -> Option<i32> {
        self.0.lines.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn paragraphs(&self) -> Option<i32> {
        self.0.paragraphs.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn company(&self) -> Option<String> {
        self.0.company.clone()
    }
    pub fn doc_security(&self) -> Option<i32> {
        self.0.doc_security.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn scale_crop(&self) -> Option<bool> {
        self.0.scale_crop.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn links_up_to_date(&self) -> Option<bool> {
        self.0.links_up_to_date.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn shared_doc(&self) -> Option<bool> {
        self.0.shared_doc.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn hyperlinks_changed(&self) -> Option<bool> {
        self.0.hyperlinks_changed.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct XlsxAppProperties(pub kreuzberg::extraction::office_metadata::app_properties::XlsxAppProperties);
impl XlsxAppProperties {
    pub fn new(
        application: Option<String>,
        app_version: Option<String>,
        doc_security: Option<i32>,
        scale_crop: Option<bool>,
        links_up_to_date: Option<bool>,
        shared_doc: Option<bool>,
        hyperlinks_changed: Option<bool>,
        company: Option<String>,
        worksheet_names: Vec<String>,
    ) -> XlsxAppProperties {
        let mut __target: kreuzberg::extraction::office_metadata::app_properties::XlsxAppProperties =
            ::std::default::Default::default();
        if let Some(s) = application {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.application = Some(t);
            }
        }
        if let Some(s) = app_version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.app_version = Some(t);
            }
        }
        __target.doc_security = doc_security;
        __target.scale_crop = scale_crop;
        __target.links_up_to_date = links_up_to_date;
        __target.shared_doc = shared_doc;
        __target.hyperlinks_changed = hyperlinks_changed;
        if let Some(s) = company {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.company = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(worksheet_names) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.worksheet_names = t;
            }
        }
        XlsxAppProperties(__target)
    }
    pub fn application(&self) -> Option<String> {
        self.0.application.clone()
    }
    pub fn app_version(&self) -> Option<String> {
        self.0.app_version.clone()
    }
    pub fn doc_security(&self) -> Option<i32> {
        self.0.doc_security.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn scale_crop(&self) -> Option<bool> {
        self.0.scale_crop.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn links_up_to_date(&self) -> Option<bool> {
        self.0.links_up_to_date.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn shared_doc(&self) -> Option<bool> {
        self.0.shared_doc.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn hyperlinks_changed(&self) -> Option<bool> {
        self.0.hyperlinks_changed.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn company(&self) -> Option<String> {
        self.0.company.clone()
    }
    pub fn worksheet_names(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.worksheet_names)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PptxAppProperties(pub kreuzberg::extraction::office_metadata::app_properties::PptxAppProperties);
impl PptxAppProperties {
    pub fn new(
        application: Option<String>,
        app_version: Option<String>,
        total_time: Option<i32>,
        company: Option<String>,
        doc_security: Option<i32>,
        scale_crop: Option<bool>,
        links_up_to_date: Option<bool>,
        shared_doc: Option<bool>,
        hyperlinks_changed: Option<bool>,
        slides: Option<i32>,
        notes: Option<i32>,
        hidden_slides: Option<i32>,
        multimedia_clips: Option<i32>,
        presentation_format: Option<String>,
        slide_titles: Vec<String>,
    ) -> PptxAppProperties {
        let mut __target: kreuzberg::extraction::office_metadata::app_properties::PptxAppProperties =
            ::std::default::Default::default();
        if let Some(s) = application {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.application = Some(t);
            }
        }
        if let Some(s) = app_version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.app_version = Some(t);
            }
        }
        __target.total_time = total_time;
        if let Some(s) = company {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.company = Some(t);
            }
        }
        __target.doc_security = doc_security;
        __target.scale_crop = scale_crop;
        __target.links_up_to_date = links_up_to_date;
        __target.shared_doc = shared_doc;
        __target.hyperlinks_changed = hyperlinks_changed;
        __target.slides = slides;
        __target.notes = notes;
        __target.hidden_slides = hidden_slides;
        __target.multimedia_clips = multimedia_clips;
        if let Some(s) = presentation_format {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.presentation_format = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(slide_titles) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.slide_titles = t;
            }
        }
        PptxAppProperties(__target)
    }
    pub fn application(&self) -> Option<String> {
        self.0.application.clone()
    }
    pub fn app_version(&self) -> Option<String> {
        self.0.app_version.clone()
    }
    pub fn total_time(&self) -> Option<i32> {
        self.0.total_time.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn company(&self) -> Option<String> {
        self.0.company.clone()
    }
    pub fn doc_security(&self) -> Option<i32> {
        self.0.doc_security.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn scale_crop(&self) -> Option<bool> {
        self.0.scale_crop.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn links_up_to_date(&self) -> Option<bool> {
        self.0.links_up_to_date.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn shared_doc(&self) -> Option<bool> {
        self.0.shared_doc.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn hyperlinks_changed(&self) -> Option<bool> {
        self.0.hyperlinks_changed.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn slides(&self) -> Option<i32> {
        self.0.slides.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn notes(&self) -> Option<i32> {
        self.0.notes.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn hidden_slides(&self) -> Option<i32> {
        self.0.hidden_slides.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn multimedia_clips(&self) -> Option<i32> {
        self.0.multimedia_clips.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn presentation_format(&self) -> Option<String> {
        self.0.presentation_format.clone()
    }
    pub fn slide_titles(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.slide_titles)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct CoreProperties(pub kreuzberg::CoreProperties);
impl CoreProperties {
    pub fn new(
        title: Option<String>,
        subject: Option<String>,
        creator: Option<String>,
        keywords: Option<String>,
        description: Option<String>,
        last_modified_by: Option<String>,
        revision: Option<String>,
        created: Option<String>,
        modified: Option<String>,
        category: Option<String>,
        content_status: Option<String>,
        language: Option<String>,
        identifier: Option<String>,
        version: Option<String>,
        last_printed: Option<String>,
    ) -> CoreProperties {
        let mut __target: kreuzberg::CoreProperties = ::std::default::Default::default();
        if let Some(s) = title {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.title = Some(t);
            }
        }
        if let Some(s) = subject {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.subject = Some(t);
            }
        }
        if let Some(s) = creator {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.creator = Some(t);
            }
        }
        if let Some(s) = keywords {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.keywords = Some(t);
            }
        }
        if let Some(s) = description {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.description = Some(t);
            }
        }
        if let Some(s) = last_modified_by {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.last_modified_by = Some(t);
            }
        }
        if let Some(s) = revision {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.revision = Some(t);
            }
        }
        if let Some(s) = created {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.created = Some(t);
            }
        }
        if let Some(s) = modified {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.modified = Some(t);
            }
        }
        if let Some(s) = category {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.category = Some(t);
            }
        }
        if let Some(s) = content_status {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.content_status = Some(t);
            }
        }
        if let Some(s) = language {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = Some(t);
            }
        }
        if let Some(s) = identifier {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.identifier = Some(t);
            }
        }
        if let Some(s) = version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.version = Some(t);
            }
        }
        if let Some(s) = last_printed {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.last_printed = Some(t);
            }
        }
        CoreProperties(__target)
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn subject(&self) -> Option<String> {
        self.0.subject.clone()
    }
    pub fn creator(&self) -> Option<String> {
        self.0.creator.clone()
    }
    pub fn keywords(&self) -> Option<String> {
        self.0.keywords.clone()
    }
    pub fn description(&self) -> Option<String> {
        self.0.description.clone()
    }
    pub fn last_modified_by(&self) -> Option<String> {
        self.0.last_modified_by.clone()
    }
    pub fn revision(&self) -> Option<String> {
        self.0.revision.clone()
    }
    pub fn created(&self) -> Option<String> {
        self.0.created.clone()
    }
    pub fn modified(&self) -> Option<String> {
        self.0.modified.clone()
    }
    pub fn category(&self) -> Option<String> {
        self.0.category.clone()
    }
    pub fn content_status(&self) -> Option<String> {
        self.0.content_status.clone()
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn identifier(&self) -> Option<String> {
        self.0.identifier.clone()
    }
    pub fn version(&self) -> Option<String> {
        self.0.version.clone()
    }
    pub fn last_printed(&self) -> Option<String> {
        self.0.last_printed.clone()
    }
}

pub struct SecurityLimits(pub kreuzberg::SecurityLimits);
impl SecurityLimits {
    pub fn new(
        max_archive_size: usize,
        max_compression_ratio: usize,
        max_files_in_archive: usize,
        max_nesting_depth: usize,
        max_entity_length: usize,
        max_content_size: usize,
        max_iterations: usize,
        max_xml_depth: usize,
        max_table_cells: usize,
    ) -> SecurityLimits {
        SecurityLimits(kreuzberg::SecurityLimits {
            max_archive_size,
            max_compression_ratio,
            max_files_in_archive,
            max_nesting_depth,
            max_entity_length,
            max_content_size,
            max_iterations,
            max_xml_depth,
            max_table_cells,
        })
    }
    pub fn max_archive_size(&self) -> usize {
        ::serde_json::to_value(&self.0.max_archive_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_compression_ratio(&self) -> usize {
        ::serde_json::to_value(&self.0.max_compression_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_files_in_archive(&self) -> usize {
        ::serde_json::to_value(&self.0.max_files_in_archive)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_nesting_depth(&self) -> usize {
        ::serde_json::to_value(&self.0.max_nesting_depth)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_entity_length(&self) -> usize {
        ::serde_json::to_value(&self.0.max_entity_length)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_content_size(&self) -> usize {
        ::serde_json::to_value(&self.0.max_content_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_iterations(&self) -> usize {
        ::serde_json::to_value(&self.0.max_iterations)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_xml_depth(&self) -> usize {
        ::serde_json::to_value(&self.0.max_xml_depth)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_table_cells(&self) -> usize {
        ::serde_json::to_value(&self.0.max_table_cells)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct TokenReductionConfig(pub kreuzberg::TokenReductionConfig);
impl TokenReductionConfig {
    pub fn new(
        level: ReductionLevel,
        language_hint: Option<String>,
        preserve_markdown: bool,
        preserve_code: bool,
        semantic_threshold: f32,
        enable_parallel: bool,
        use_simd: bool,
        custom_stopwords: String,
        preserve_patterns: Vec<String>,
        target_reduction: Option<f32>,
        enable_semantic_clustering: bool,
    ) -> TokenReductionConfig {
        let mut __target: kreuzberg::TokenReductionConfig = ::std::default::Default::default();
        // alef: level (ReductionLevel) is an enum; reverse From not generated — left at default
        if let Some(s) = language_hint {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language_hint = Some(t);
            }
        }
        __target.preserve_markdown = preserve_markdown;
        __target.preserve_code = preserve_code;
        __target.semantic_threshold = semantic_threshold;
        __target.enable_parallel = enable_parallel;
        __target.use_simd = use_simd;
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&custom_stopwords) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.custom_stopwords = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(preserve_patterns) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.preserve_patterns = t;
            }
        }
        __target.target_reduction = target_reduction;
        __target.enable_semantic_clustering = enable_semantic_clustering;
        TokenReductionConfig(__target)
    }
    pub fn level(&self) -> String {
        ReductionLevel::from(self.0.level.clone()).to_string()
    }
    pub fn language_hint(&self) -> Option<String> {
        self.0.language_hint.clone()
    }
    pub fn preserve_markdown(&self) -> bool {
        ::serde_json::to_value(&self.0.preserve_markdown)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn preserve_code(&self) -> bool {
        ::serde_json::to_value(&self.0.preserve_code)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn semantic_threshold(&self) -> f32 {
        ::serde_json::to_value(&self.0.semantic_threshold)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn enable_parallel(&self) -> bool {
        ::serde_json::to_value(&self.0.enable_parallel)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn use_simd(&self) -> bool {
        ::serde_json::to_value(&self.0.use_simd)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn custom_stopwords(&self) -> String {
        serde_json::to_string(&self.0.custom_stopwords).expect("serializable custom_stopwords")
    }
    pub fn preserve_patterns(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.preserve_patterns)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn target_reduction(&self) -> Option<f32> {
        self.0.target_reduction.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn enable_semantic_clustering(&self) -> bool {
        ::serde_json::to_value(&self.0.enable_semantic_clustering)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PdfAnnotation(pub kreuzberg::PdfAnnotation);
impl PdfAnnotation {
    pub fn annotation_type(&self) -> String {
        PdfAnnotationType::from(self.0.annotation_type.clone()).to_string()
    }
    pub fn content(&self) -> Option<String> {
        self.0.content.clone()
    }
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bounding_box(&self) -> Option<BoundingBox> {
        self.0.bounding_box.clone().map(BoundingBox)
    }
}

pub struct DjotContent(pub kreuzberg::DjotContent);
impl DjotContent {
    pub fn plain_text(&self) -> String {
        self.0.plain_text.clone()
    }
    pub fn blocks(&self) -> Vec<FormattedBlock> {
        self.0.blocks.iter().map(|elem| FormattedBlock(elem.clone())).collect()
    }
    pub fn metadata(&self) -> Metadata {
        Metadata(self.0.metadata.clone())
    }
    pub fn tables(&self) -> Vec<Table> {
        self.0.tables.iter().map(|elem| Table(elem.clone())).collect()
    }
    pub fn images(&self) -> Vec<DjotImage> {
        self.0.images.iter().map(|elem| DjotImage(elem.clone())).collect()
    }
    pub fn links(&self) -> Vec<DjotLink> {
        self.0.links.iter().map(|elem| DjotLink(elem.clone())).collect()
    }
    pub fn footnotes(&self) -> Vec<Footnote> {
        self.0.footnotes.iter().map(|elem| Footnote(elem.clone())).collect()
    }
    // alef: skipped getter `attributes` — type cannot be bridged through swift-bridge
}

pub struct FormattedBlock(pub kreuzberg::FormattedBlock);
impl FormattedBlock {
    pub fn block_type(&self) -> String {
        BlockType::from(self.0.block_type.clone()).to_string()
    }
    pub fn level(&self) -> Option<usize> {
        self.0.level.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn inline_content(&self) -> Vec<InlineElement> {
        self.0
            .inline_content
            .iter()
            .map(|elem| InlineElement(elem.clone()))
            .collect()
    }
    pub fn attributes(&self) -> Option<String> {
        self.0.attributes.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn code(&self) -> Option<String> {
        self.0.code.clone()
    }
    pub fn children(&self) -> Vec<FormattedBlock> {
        self.0
            .children
            .iter()
            .map(|elem| FormattedBlock(elem.clone()))
            .collect()
    }
}

pub struct InlineElement(pub kreuzberg::InlineElement);
impl InlineElement {
    pub fn element_type(&self) -> String {
        InlineType::from(self.0.element_type.clone()).to_string()
    }
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn attributes(&self) -> Option<String> {
        self.0.attributes.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn metadata(&self) -> String {
        serde_json::to_string(&self.0.metadata).expect("serializable metadata")
    }
}

pub struct DjotImage(pub kreuzberg::DjotImage);
impl DjotImage {
    pub fn src(&self) -> String {
        self.0.src.clone()
    }
    pub fn alt(&self) -> String {
        self.0.alt.clone()
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn attributes(&self) -> Option<String> {
        self.0.attributes.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
}

pub struct DjotLink(pub kreuzberg::DjotLink);
impl DjotLink {
    pub fn url(&self) -> String {
        self.0.url.clone()
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn attributes(&self) -> Option<String> {
        self.0.attributes.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
}

pub struct Footnote(pub kreuzberg::Footnote);
impl Footnote {
    pub fn label(&self) -> String {
        self.0.label.clone()
    }
    pub fn content(&self) -> Vec<FormattedBlock> {
        self.0.content.iter().map(|elem| FormattedBlock(elem.clone())).collect()
    }
}

pub struct DocumentStructure(pub kreuzberg::DocumentStructure);
impl DocumentStructure {
    pub fn new(
        nodes: Vec<DocumentNode>,
        source_format: Option<String>,
        relationships: Vec<DocumentRelationship>,
        node_types: Vec<String>,
    ) -> DocumentStructure {
        let mut __target: kreuzberg::DocumentStructure = ::std::default::Default::default();
        __target.nodes = nodes.into_iter().map(|w| w.0).collect();
        if let Some(s) = source_format {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.source_format = Some(t);
            }
        }
        __target.relationships = relationships.into_iter().map(|w| w.0).collect();
        if let Ok(__v) = ::serde_json::to_value(node_types) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.node_types = t;
            }
        }
        DocumentStructure(__target)
    }
    pub fn nodes(&self) -> Vec<DocumentNode> {
        self.0.nodes.iter().map(|elem| DocumentNode(elem.clone())).collect()
    }
    pub fn source_format(&self) -> Option<String> {
        self.0.source_format.clone()
    }
    pub fn relationships(&self) -> Vec<DocumentRelationship> {
        self.0
            .relationships
            .iter()
            .map(|elem| DocumentRelationship(elem.clone()))
            .collect()
    }
    pub fn node_types(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.node_types)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct DocumentRelationship(pub kreuzberg::DocumentRelationship);
impl DocumentRelationship {
    pub fn source(&self) -> u32 {
        ::serde_json::to_value(&self.0.source)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn target(&self) -> u32 {
        ::serde_json::to_value(&self.0.target)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn kind(&self) -> String {
        RelationshipKind::from(self.0.kind.clone()).to_string()
    }
}

pub struct DocumentNode(pub kreuzberg::DocumentNode);
impl DocumentNode {
    pub fn id(&self) -> String {
        serde_json::to_string(&self.0.id).unwrap_or_default()
    }
    pub fn content(&self) -> String {
        NodeContent::from(self.0.content.clone()).to_string()
    }
    pub fn parent(&self) -> Option<u32> {
        self.0.parent.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn children(&self) -> Vec<u32> {
        ::serde_json::to_value(&self.0.children)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn content_layer(&self) -> String {
        ContentLayer::from(self.0.content_layer.clone()).to_string()
    }
    pub fn page(&self) -> Option<u32> {
        self.0.page.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn page_end(&self) -> Option<u32> {
        self.0.page_end.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn bbox(&self) -> Option<BoundingBox> {
        self.0.bbox.clone().map(BoundingBox)
    }
    pub fn annotations(&self) -> Vec<TextAnnotation> {
        self.0
            .annotations
            .iter()
            .map(|elem| TextAnnotation(elem.clone()))
            .collect()
    }
    pub fn attributes(&self) -> String {
        serde_json::to_string(&self.0.attributes).expect("serializable attributes")
    }
}

pub struct TableGrid(pub kreuzberg::TableGrid);
impl TableGrid {
    pub fn new(rows: u32, cols: u32, cells: Vec<GridCell>) -> TableGrid {
        let mut __target: kreuzberg::TableGrid = ::std::default::Default::default();
        __target.rows = rows;
        __target.cols = cols;
        __target.cells = cells.into_iter().map(|w| w.0).collect();
        TableGrid(__target)
    }
    pub fn rows(&self) -> u32 {
        ::serde_json::to_value(&self.0.rows)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cols(&self) -> u32 {
        ::serde_json::to_value(&self.0.cols)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cells(&self) -> Vec<GridCell> {
        self.0.cells.iter().map(|elem| GridCell(elem.clone())).collect()
    }
}

pub struct GridCell(pub kreuzberg::GridCell);
impl GridCell {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn row(&self) -> u32 {
        ::serde_json::to_value(&self.0.row)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn col(&self) -> u32 {
        ::serde_json::to_value(&self.0.col)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn row_span(&self) -> u32 {
        ::serde_json::to_value(&self.0.row_span)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn col_span(&self) -> u32 {
        ::serde_json::to_value(&self.0.col_span)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn is_header(&self) -> bool {
        ::serde_json::to_value(&self.0.is_header)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bbox(&self) -> Option<BoundingBox> {
        self.0.bbox.clone().map(BoundingBox)
    }
}

pub struct TextAnnotation(pub kreuzberg::TextAnnotation);
impl TextAnnotation {
    pub fn start(&self) -> u32 {
        ::serde_json::to_value(&self.0.start)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn end(&self) -> u32 {
        ::serde_json::to_value(&self.0.end)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn kind(&self) -> String {
        AnnotationKind::from(self.0.kind.clone()).to_string()
    }
}

pub struct ExtractionResult(pub kreuzberg::ExtractionResult);
impl ExtractionResult {
    pub fn new(
        content: String,
        mime_type: String,
        metadata: Metadata,
        extraction_method: Option<ExtractionMethod>,
        tables: Vec<Table>,
        detected_languages: Option<Vec<String>>,
        chunks: Option<Vec<Chunk>>,
        images: Option<Vec<ExtractedImage>>,
        pages: Option<Vec<PageContent>>,
        elements: Option<Vec<Element>>,
        djot_content: Option<DjotContent>,
        ocr_elements: Option<Vec<OcrElement>>,
        document: Option<DocumentStructure>,
        extracted_keywords: Option<Vec<Keyword>>,
        quality_score: Option<f64>,
        processing_warnings: Vec<ProcessingWarning>,
        annotations: Option<Vec<PdfAnnotation>>,
        children: Option<Vec<ArchiveEntry>>,
        uris: Option<Vec<ExtractedUri>>,
        revisions: Option<Vec<DocumentRevision>>,
        structured_output: Option<String>,
        code_intelligence: Option<String>,
        llm_usage: Option<Vec<LlmUsage>>,
        formatted_content: Option<String>,
    ) -> ExtractionResult {
        let mut __target: kreuzberg::ExtractionResult = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&content)
                .unwrap_or(::serde_json::Value::String(content.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.content = t;
            }
        }
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&mime_type)
                .unwrap_or(::serde_json::Value::String(mime_type.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.mime_type = t;
            }
        }
        __target.metadata = metadata.0;
        // alef: extraction_method (ExtractionMethod) is an enum; reverse From not generated — left at default
        __target.tables = tables.into_iter().map(|w| w.0).collect();
        if let Ok(__v) = ::serde_json::to_value(detected_languages) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.detected_languages = t;
            }
        }
        if let Some(v) = chunks {
            __target.chunks = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = images {
            __target.images = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = pages {
            __target.pages = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = elements {
            __target.elements = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(w) = djot_content {
            __target.djot_content = Some(w.0);
        }
        if let Some(v) = ocr_elements {
            __target.ocr_elements = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(w) = document {
            __target.document = Some(w.0);
        }
        if let Some(v) = extracted_keywords {
            __target.extracted_keywords = Some(v.into_iter().map(|w| w.0).collect());
        }
        __target.quality_score = quality_score;
        __target.processing_warnings = processing_warnings.into_iter().map(|w| w.0).collect();
        if let Some(v) = annotations {
            __target.annotations = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = children {
            __target.children = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = uris {
            __target.uris = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(v) = revisions {
            __target.revisions = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(s) = structured_output {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.structured_output = Some(t);
            }
        }
        if let Some(s) = code_intelligence {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.code_intelligence = Some(t);
            }
        }
        if let Some(v) = llm_usage {
            __target.llm_usage = Some(v.into_iter().map(|w| w.0).collect());
        }
        if let Some(s) = formatted_content {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.formatted_content = Some(t);
            }
        }
        // alef: excluded field `ocr_internal_document` — actual type is not serializable, left at default
        ExtractionResult(__target)
    }
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn mime_type(&self) -> String {
        self.0.mime_type.to_string()
    }
    pub fn metadata(&self) -> Metadata {
        Metadata(self.0.metadata.clone())
    }
    pub fn extraction_method(&self) -> Option<String> {
        self.0
            .extraction_method
            .clone()
            .map(|w| ExtractionMethod::from(w).to_string())
    }
    pub fn tables(&self) -> Vec<Table> {
        self.0.tables.iter().map(|elem| Table(elem.clone())).collect()
    }
    pub fn detected_languages(&self) -> Option<Vec<String>> {
        self.0.detected_languages.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn chunks(&self) -> Option<Vec<Chunk>> {
        self.0
            .chunks
            .as_ref()
            .map(|v| v.iter().map(|elem| Chunk(elem.clone())).collect())
    }
    pub fn images(&self) -> Option<Vec<ExtractedImage>> {
        self.0
            .images
            .as_ref()
            .map(|v| v.iter().map(|elem| ExtractedImage(elem.clone())).collect())
    }
    pub fn pages(&self) -> Option<Vec<PageContent>> {
        self.0
            .pages
            .as_ref()
            .map(|v| v.iter().map(|elem| PageContent(elem.clone())).collect())
    }
    pub fn elements(&self) -> Option<Vec<Element>> {
        self.0
            .elements
            .as_ref()
            .map(|v| v.iter().map(|elem| Element(elem.clone())).collect())
    }
    pub fn djot_content(&self) -> Option<DjotContent> {
        self.0.djot_content.clone().map(DjotContent)
    }
    pub fn ocr_elements(&self) -> Option<Vec<OcrElement>> {
        self.0
            .ocr_elements
            .as_ref()
            .map(|v| v.iter().map(|elem| OcrElement(elem.clone())).collect())
    }
    pub fn document(&self) -> Option<DocumentStructure> {
        self.0.document.clone().map(DocumentStructure)
    }
    pub fn extracted_keywords(&self) -> Option<Vec<Keyword>> {
        self.0
            .extracted_keywords
            .as_ref()
            .map(|v| v.iter().map(|elem| Keyword(elem.clone())).collect())
    }
    pub fn quality_score(&self) -> Option<f64> {
        self.0.quality_score.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn processing_warnings(&self) -> Vec<ProcessingWarning> {
        self.0
            .processing_warnings
            .iter()
            .map(|elem| ProcessingWarning(elem.clone()))
            .collect()
    }
    pub fn annotations(&self) -> Option<Vec<PdfAnnotation>> {
        self.0
            .annotations
            .as_ref()
            .map(|v| v.iter().map(|elem| PdfAnnotation(elem.clone())).collect())
    }
    pub fn children(&self) -> Option<Vec<ArchiveEntry>> {
        self.0
            .children
            .as_ref()
            .map(|v| v.iter().map(|elem| ArchiveEntry(elem.clone())).collect())
    }
    pub fn uris(&self) -> Option<Vec<ExtractedUri>> {
        self.0
            .uris
            .as_ref()
            .map(|v| v.iter().map(|elem| ExtractedUri(elem.clone())).collect())
    }
    pub fn revisions(&self) -> Option<Vec<DocumentRevision>> {
        self.0
            .revisions
            .as_ref()
            .map(|v| v.iter().map(|elem| DocumentRevision(elem.clone())).collect())
    }
    pub fn structured_output(&self) -> Option<String> {
        self.0
            .structured_output
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn code_intelligence(&self) -> Option<String> {
        self.0
            .code_intelligence
            .as_ref()
            .and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn llm_usage(&self) -> Option<Vec<LlmUsage>> {
        self.0
            .llm_usage
            .as_ref()
            .map(|v| v.iter().map(|elem| LlmUsage(elem.clone())).collect())
    }
    pub fn formatted_content(&self) -> Option<String> {
        self.0.formatted_content.clone()
    }
    // alef: skipped getter `ocr_internal_document` — type cannot be bridged through swift-bridge
}

pub struct ArchiveEntry(pub kreuzberg::ArchiveEntry);
impl ArchiveEntry {
    pub fn path(&self) -> String {
        self.0.path.clone()
    }
    pub fn mime_type(&self) -> String {
        self.0.mime_type.clone()
    }
    pub fn result(&self) -> ExtractionResult {
        ExtractionResult(*self.0.result.clone())
    }
}

pub struct ProcessingWarning(pub kreuzberg::ProcessingWarning);
impl ProcessingWarning {
    pub fn source(&self) -> String {
        self.0.source.to_string()
    }
    pub fn message(&self) -> String {
        self.0.message.to_string()
    }
}

pub struct LlmUsage(pub kreuzberg::LlmUsage);
impl LlmUsage {
    pub fn new(
        model: String,
        source: String,
        input_tokens: Option<u64>,
        output_tokens: Option<u64>,
        total_tokens: Option<u64>,
        estimated_cost: Option<f64>,
        finish_reason: Option<String>,
    ) -> LlmUsage {
        let mut __target: kreuzberg::LlmUsage = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&model)
                .unwrap_or(::serde_json::Value::String(model.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.model = t;
            }
        }
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&source)
                .unwrap_or(::serde_json::Value::String(source.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.source = t;
            }
        }
        __target.input_tokens = input_tokens;
        __target.output_tokens = output_tokens;
        __target.total_tokens = total_tokens;
        __target.estimated_cost = estimated_cost;
        if let Some(s) = finish_reason {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.finish_reason = Some(t);
            }
        }
        LlmUsage(__target)
    }
    pub fn model(&self) -> String {
        self.0.model.clone()
    }
    pub fn source(&self) -> String {
        self.0.source.clone()
    }
    pub fn input_tokens(&self) -> Option<u64> {
        self.0.input_tokens.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn output_tokens(&self) -> Option<u64> {
        self.0.output_tokens.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn total_tokens(&self) -> Option<u64> {
        self.0.total_tokens.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn estimated_cost(&self) -> Option<f64> {
        self.0.estimated_cost.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn finish_reason(&self) -> Option<String> {
        self.0.finish_reason.clone()
    }
}

pub struct Chunk(pub kreuzberg::Chunk);
impl Chunk {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn chunk_type(&self) -> String {
        ChunkType::from(self.0.chunk_type.clone()).to_string()
    }
    pub fn embedding(&self) -> Option<Vec<f32>> {
        self.0.embedding.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn metadata(&self) -> ChunkMetadata {
        ChunkMetadata(self.0.metadata.clone())
    }
}

pub struct HeadingContext(pub kreuzberg::HeadingContext);
impl HeadingContext {
    pub fn headings(&self) -> Vec<HeadingLevel> {
        self.0.headings.iter().map(|elem| HeadingLevel(elem.clone())).collect()
    }
}

pub struct HeadingLevel(pub kreuzberg::HeadingLevel);
impl HeadingLevel {
    pub fn level(&self) -> u8 {
        ::serde_json::to_value(&self.0.level)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
}

pub struct ChunkMetadata(pub kreuzberg::ChunkMetadata);
impl ChunkMetadata {
    pub fn byte_start(&self) -> usize {
        ::serde_json::to_value(&self.0.byte_start)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn byte_end(&self) -> usize {
        ::serde_json::to_value(&self.0.byte_end)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn token_count(&self) -> Option<usize> {
        self.0.token_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn chunk_index(&self) -> usize {
        ::serde_json::to_value(&self.0.chunk_index)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn total_chunks(&self) -> usize {
        ::serde_json::to_value(&self.0.total_chunks)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn first_page(&self) -> Option<u32> {
        self.0.first_page.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn last_page(&self) -> Option<u32> {
        self.0.last_page.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn heading_context(&self) -> Option<HeadingContext> {
        self.0.heading_context.clone().map(HeadingContext)
    }
    pub fn image_indices(&self) -> Vec<u32> {
        ::serde_json::to_value(&self.0.image_indices)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ExtractedImage(pub kreuzberg::ExtractedImage);
impl ExtractedImage {
    pub fn data(&self) -> Vec<u8> {
        self.0.data.to_vec()
    }
    pub fn format(&self) -> String {
        self.0.format.to_string()
    }
    pub fn image_index(&self) -> u32 {
        ::serde_json::to_value(&self.0.image_index)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn page_number(&self) -> Option<u32> {
        self.0.page_number.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn width(&self) -> Option<u32> {
        self.0.width.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn height(&self) -> Option<u32> {
        self.0.height.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn colorspace(&self) -> Option<String> {
        self.0.colorspace.clone()
    }
    pub fn bits_per_component(&self) -> Option<u32> {
        self.0.bits_per_component.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn is_mask(&self) -> bool {
        ::serde_json::to_value(&self.0.is_mask)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn description(&self) -> Option<String> {
        self.0.description.clone()
    }
    pub fn ocr_result(&self) -> Option<ExtractionResult> {
        self.0.ocr_result.clone().map(|w| ExtractionResult(*w))
    }
    pub fn bounding_box(&self) -> Option<BoundingBox> {
        self.0.bounding_box.clone().map(BoundingBox)
    }
    pub fn source_path(&self) -> Option<String> {
        self.0.source_path.clone()
    }
    pub fn image_kind(&self) -> Option<String> {
        self.0.image_kind.clone().map(|w| ImageKind::from(w).to_string())
    }
    pub fn kind_confidence(&self) -> Option<f32> {
        self.0.kind_confidence.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn cluster_id(&self) -> Option<u32> {
        self.0.cluster_id.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct BoundingBox(pub kreuzberg::BoundingBox);
impl BoundingBox {
    pub fn new(x0: f64, y0: f64, x1: f64, y1: f64) -> BoundingBox {
        BoundingBox(kreuzberg::BoundingBox { x0, y0, x1, y1 })
    }
    pub fn x0(&self) -> f64 {
        ::serde_json::to_value(&self.0.x0)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn y0(&self) -> f64 {
        ::serde_json::to_value(&self.0.y0)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn x1(&self) -> f64 {
        ::serde_json::to_value(&self.0.x1)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn y1(&self) -> f64 {
        ::serde_json::to_value(&self.0.y1)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ElementMetadata(pub kreuzberg::ElementMetadata);
impl ElementMetadata {
    pub fn page_number(&self) -> Option<u32> {
        self.0.page_number.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn filename(&self) -> Option<String> {
        self.0.filename.clone()
    }
    pub fn coordinates(&self) -> Option<BoundingBox> {
        self.0.coordinates.clone().map(BoundingBox)
    }
    pub fn element_index(&self) -> Option<usize> {
        self.0.element_index.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn additional(&self) -> String {
        serde_json::to_string(&self.0.additional).expect("serializable additional")
    }
}

pub struct Element(pub kreuzberg::Element);
impl Element {
    pub fn element_id(&self) -> String {
        serde_json::to_string(&self.0.element_id).unwrap_or_default()
    }
    pub fn element_type(&self) -> String {
        ElementType::from(self.0.element_type.clone()).to_string()
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn metadata(&self) -> ElementMetadata {
        ElementMetadata(self.0.metadata.clone())
    }
}

pub struct ExcelWorkbook(pub kreuzberg::ExcelWorkbook);
impl ExcelWorkbook {
    pub fn sheets(&self) -> Vec<ExcelSheet> {
        self.0.sheets.iter().map(|elem| ExcelSheet(elem.clone())).collect()
    }
    pub fn metadata(&self) -> String {
        serde_json::to_string(&self.0.metadata).expect("serializable metadata")
    }
    pub fn revisions(&self) -> Option<Vec<DocumentRevision>> {
        self.0
            .revisions
            .as_ref()
            .map(|v| v.iter().map(|elem| DocumentRevision(elem.clone())).collect())
    }
}

pub struct ExcelSheet(pub kreuzberg::ExcelSheet);
impl ExcelSheet {
    pub fn name(&self) -> String {
        self.0.name.clone()
    }
    pub fn markdown(&self) -> String {
        self.0.markdown.clone()
    }
    pub fn row_count(&self) -> usize {
        ::serde_json::to_value(&self.0.row_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn col_count(&self) -> usize {
        ::serde_json::to_value(&self.0.col_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cell_count(&self) -> usize {
        ::serde_json::to_value(&self.0.cell_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_cells(&self) -> String {
        serde_json::to_string(&self.0.table_cells).expect("serializable table_cells")
    }
}

pub struct XmlExtractionResult(pub kreuzberg::XmlExtractionResult);
impl XmlExtractionResult {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn element_count(&self) -> usize {
        ::serde_json::to_value(&self.0.element_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn unique_elements(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.unique_elements)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct TextExtractionResult(pub kreuzberg::TextExtractionResult);
impl TextExtractionResult {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn line_count(&self) -> usize {
        ::serde_json::to_value(&self.0.line_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn word_count(&self) -> usize {
        ::serde_json::to_value(&self.0.word_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn character_count(&self) -> usize {
        ::serde_json::to_value(&self.0.character_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn headers(&self) -> Option<Vec<String>> {
        self.0.headers.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    // alef: skipped getter `links` — type cannot be bridged through swift-bridge
    // alef: skipped getter `code_blocks` — type cannot be bridged through swift-bridge
}

pub struct PptxExtractionResult(pub kreuzberg::PptxExtractionResult);
impl PptxExtractionResult {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn metadata(&self) -> PptxMetadata {
        PptxMetadata(self.0.metadata.clone())
    }
    pub fn slide_count(&self) -> usize {
        ::serde_json::to_value(&self.0.slide_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn image_count(&self) -> usize {
        ::serde_json::to_value(&self.0.image_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_count(&self) -> usize {
        ::serde_json::to_value(&self.0.table_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn images(&self) -> Vec<ExtractedImage> {
        self.0.images.iter().map(|elem| ExtractedImage(elem.clone())).collect()
    }
    pub fn page_structure(&self) -> Option<PageStructure> {
        self.0.page_structure.clone().map(PageStructure)
    }
    pub fn page_contents(&self) -> Option<Vec<PageContent>> {
        self.0
            .page_contents
            .as_ref()
            .map(|v| v.iter().map(|elem| PageContent(elem.clone())).collect())
    }
    pub fn document(&self) -> Option<DocumentStructure> {
        self.0.document.clone().map(DocumentStructure)
    }
    // alef: skipped getter `hyperlinks` — type cannot be bridged through swift-bridge
    pub fn office_metadata(&self) -> String {
        serde_json::to_string(&self.0.office_metadata).expect("serializable office_metadata")
    }
    pub fn revisions(&self) -> Option<Vec<DocumentRevision>> {
        self.0
            .revisions
            .as_ref()
            .map(|v| v.iter().map(|elem| DocumentRevision(elem.clone())).collect())
    }
}

pub struct EmailExtractionResult(pub kreuzberg::EmailExtractionResult);
impl EmailExtractionResult {
    pub fn subject(&self) -> Option<String> {
        self.0.subject.clone()
    }
    pub fn from_email(&self) -> Option<String> {
        self.0.from_email.clone()
    }
    pub fn to_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.to_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cc_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.cc_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bcc_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.bcc_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn date(&self) -> Option<String> {
        self.0.date.clone()
    }
    pub fn message_id(&self) -> Option<String> {
        self.0.message_id.clone()
    }
    pub fn plain_text(&self) -> Option<String> {
        self.0.plain_text.clone()
    }
    pub fn html_content(&self) -> Option<String> {
        self.0.html_content.clone()
    }
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn attachments(&self) -> Vec<EmailAttachment> {
        self.0
            .attachments
            .iter()
            .map(|elem| EmailAttachment(elem.clone()))
            .collect()
    }
    pub fn metadata(&self) -> String {
        serde_json::to_string(&self.0.metadata).expect("serializable metadata")
    }
}

pub struct EmailAttachment(pub kreuzberg::EmailAttachment);
impl EmailAttachment {
    pub fn name(&self) -> Option<String> {
        self.0.name.clone()
    }
    pub fn filename(&self) -> Option<String> {
        self.0.filename.clone()
    }
    pub fn mime_type(&self) -> Option<String> {
        self.0.mime_type.clone()
    }
    pub fn size(&self) -> Option<usize> {
        self.0.size.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn is_image(&self) -> bool {
        ::serde_json::to_value(&self.0.is_image)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn data(&self) -> Option<Vec<u8>> {
        self.0.data.as_ref().map(|b| b.to_vec())
    }
}

pub struct OcrExtractionResult(pub kreuzberg::OcrExtractionResult);
impl OcrExtractionResult {
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn mime_type(&self) -> String {
        self.0.mime_type.clone()
    }
    pub fn metadata(&self) -> String {
        serde_json::to_string(&self.0.metadata).expect("serializable metadata")
    }
    pub fn tables(&self) -> Vec<OcrTable> {
        self.0.tables.iter().map(|elem| OcrTable(elem.clone())).collect()
    }
    pub fn ocr_elements(&self) -> Option<Vec<OcrElement>> {
        self.0
            .ocr_elements
            .as_ref()
            .map(|v| v.iter().map(|elem| OcrElement(elem.clone())).collect())
    }
    // alef: skipped getter `internal_document` — type cannot be bridged through swift-bridge
}

pub struct OcrTable(pub kreuzberg::OcrTable);
impl OcrTable {
    pub fn cells(&self) -> String {
        serde_json::to_string(&self.0.cells).expect("serializable cells")
    }
    pub fn markdown(&self) -> String {
        self.0.markdown.clone()
    }
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bounding_box(&self) -> Option<OcrTableBoundingBox> {
        self.0.bounding_box.clone().map(OcrTableBoundingBox)
    }
}

pub struct OcrTableBoundingBox(pub kreuzberg::OcrTableBoundingBox);
impl OcrTableBoundingBox {
    pub fn new(left: u32, top: u32, right: u32, bottom: u32) -> OcrTableBoundingBox {
        OcrTableBoundingBox(kreuzberg::OcrTableBoundingBox {
            left,
            top,
            right,
            bottom,
        })
    }
    pub fn left(&self) -> u32 {
        ::serde_json::to_value(&self.0.left)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn top(&self) -> u32 {
        ::serde_json::to_value(&self.0.top)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn right(&self) -> u32 {
        ::serde_json::to_value(&self.0.right)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bottom(&self) -> u32 {
        ::serde_json::to_value(&self.0.bottom)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ImagePreprocessingConfig(pub kreuzberg::ImagePreprocessingConfig);
impl ImagePreprocessingConfig {
    pub fn new(
        target_dpi: i32,
        auto_rotate: bool,
        deskew: bool,
        denoise: bool,
        contrast_enhance: bool,
        binarization_method: String,
        invert_colors: bool,
    ) -> ImagePreprocessingConfig {
        let mut __target: kreuzberg::ImagePreprocessingConfig = ::std::default::Default::default();
        __target.target_dpi = target_dpi;
        __target.auto_rotate = auto_rotate;
        __target.deskew = deskew;
        __target.denoise = denoise;
        __target.contrast_enhance = contrast_enhance;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&binarization_method)
                .unwrap_or(::serde_json::Value::String(binarization_method.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.binarization_method = t;
            }
        }
        __target.invert_colors = invert_colors;
        ImagePreprocessingConfig(__target)
    }
    pub fn target_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.target_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn auto_rotate(&self) -> bool {
        ::serde_json::to_value(&self.0.auto_rotate)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn deskew(&self) -> bool {
        ::serde_json::to_value(&self.0.deskew)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn denoise(&self) -> bool {
        ::serde_json::to_value(&self.0.denoise)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn contrast_enhance(&self) -> bool {
        ::serde_json::to_value(&self.0.contrast_enhance)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn binarization_method(&self) -> String {
        self.0.binarization_method.clone()
    }
    pub fn invert_colors(&self) -> bool {
        ::serde_json::to_value(&self.0.invert_colors)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct TesseractConfig(pub kreuzberg::TesseractConfig);
impl TesseractConfig {
    pub fn new(
        language: String,
        psm: i32,
        output_format: String,
        oem: i32,
        min_confidence: f64,
        preprocessing: Option<ImagePreprocessingConfig>,
        enable_table_detection: bool,
        table_min_confidence: f64,
        table_column_threshold: i32,
        table_row_threshold_ratio: f64,
        use_cache: bool,
        classify_use_pre_adapted_templates: bool,
        language_model_ngram_on: bool,
        tessedit_dont_blkrej_good_wds: bool,
        tessedit_dont_rowrej_good_wds: bool,
        tessedit_enable_dict_correction: bool,
        tessedit_char_whitelist: String,
        tessedit_char_blacklist: String,
        tessedit_use_primary_params_model: bool,
        textord_space_size_is_variable: bool,
        thresholding_method: bool,
    ) -> TesseractConfig {
        let mut __target: kreuzberg::TesseractConfig = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&language)
                .unwrap_or(::serde_json::Value::String(language.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = t;
            }
        }
        __target.psm = psm;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&output_format)
                .unwrap_or(::serde_json::Value::String(output_format.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.output_format = t;
            }
        }
        __target.oem = oem;
        __target.min_confidence = min_confidence;
        if let Some(w) = preprocessing {
            __target.preprocessing = Some(w.0);
        }
        __target.enable_table_detection = enable_table_detection;
        __target.table_min_confidence = table_min_confidence;
        __target.table_column_threshold = table_column_threshold;
        __target.table_row_threshold_ratio = table_row_threshold_ratio;
        __target.use_cache = use_cache;
        __target.classify_use_pre_adapted_templates = classify_use_pre_adapted_templates;
        __target.language_model_ngram_on = language_model_ngram_on;
        __target.tessedit_dont_blkrej_good_wds = tessedit_dont_blkrej_good_wds;
        __target.tessedit_dont_rowrej_good_wds = tessedit_dont_rowrej_good_wds;
        __target.tessedit_enable_dict_correction = tessedit_enable_dict_correction;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&tessedit_char_whitelist)
                .unwrap_or(::serde_json::Value::String(tessedit_char_whitelist.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.tessedit_char_whitelist = t;
            }
        }
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&tessedit_char_blacklist)
                .unwrap_or(::serde_json::Value::String(tessedit_char_blacklist.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.tessedit_char_blacklist = t;
            }
        }
        __target.tessedit_use_primary_params_model = tessedit_use_primary_params_model;
        __target.textord_space_size_is_variable = textord_space_size_is_variable;
        __target.thresholding_method = thresholding_method;
        TesseractConfig(__target)
    }
    pub fn language(&self) -> String {
        self.0.language.clone()
    }
    pub fn psm(&self) -> i32 {
        ::serde_json::to_value(&self.0.psm)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn output_format(&self) -> String {
        self.0.output_format.clone()
    }
    pub fn oem(&self) -> i32 {
        ::serde_json::to_value(&self.0.oem)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_confidence(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn preprocessing(&self) -> Option<ImagePreprocessingConfig> {
        self.0.preprocessing.clone().map(ImagePreprocessingConfig)
    }
    pub fn enable_table_detection(&self) -> bool {
        ::serde_json::to_value(&self.0.enable_table_detection)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_min_confidence(&self) -> f64 {
        ::serde_json::to_value(&self.0.table_min_confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_column_threshold(&self) -> i32 {
        ::serde_json::to_value(&self.0.table_column_threshold)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_row_threshold_ratio(&self) -> f64 {
        ::serde_json::to_value(&self.0.table_row_threshold_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn use_cache(&self) -> bool {
        ::serde_json::to_value(&self.0.use_cache)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn classify_use_pre_adapted_templates(&self) -> bool {
        ::serde_json::to_value(&self.0.classify_use_pre_adapted_templates)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn language_model_ngram_on(&self) -> bool {
        ::serde_json::to_value(&self.0.language_model_ngram_on)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn tessedit_dont_blkrej_good_wds(&self) -> bool {
        ::serde_json::to_value(&self.0.tessedit_dont_blkrej_good_wds)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn tessedit_dont_rowrej_good_wds(&self) -> bool {
        ::serde_json::to_value(&self.0.tessedit_dont_rowrej_good_wds)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn tessedit_enable_dict_correction(&self) -> bool {
        ::serde_json::to_value(&self.0.tessedit_enable_dict_correction)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn tessedit_char_whitelist(&self) -> String {
        self.0.tessedit_char_whitelist.clone()
    }
    pub fn tessedit_char_blacklist(&self) -> String {
        self.0.tessedit_char_blacklist.clone()
    }
    pub fn tessedit_use_primary_params_model(&self) -> bool {
        ::serde_json::to_value(&self.0.tessedit_use_primary_params_model)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn textord_space_size_is_variable(&self) -> bool {
        ::serde_json::to_value(&self.0.textord_space_size_is_variable)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn thresholding_method(&self) -> bool {
        ::serde_json::to_value(&self.0.thresholding_method)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ImagePreprocessingMetadata(pub kreuzberg::ImagePreprocessingMetadata);
impl ImagePreprocessingMetadata {
    pub fn original_dimensions(&self) -> Vec<usize> {
        ::serde_json::to_value(&self.0.original_dimensions)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn original_dpi(&self) -> Vec<f64> {
        ::serde_json::to_value(&self.0.original_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn target_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.target_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn scale_factor(&self) -> f64 {
        ::serde_json::to_value(&self.0.scale_factor)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn auto_adjusted(&self) -> bool {
        ::serde_json::to_value(&self.0.auto_adjusted)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn final_dpi(&self) -> i32 {
        ::serde_json::to_value(&self.0.final_dpi)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn new_dimensions(&self) -> Option<Vec<usize>> {
        self.0.new_dimensions.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn resample_method(&self) -> String {
        self.0.resample_method.clone()
    }
    pub fn dimension_clamped(&self) -> bool {
        ::serde_json::to_value(&self.0.dimension_clamped)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn calculated_dpi(&self) -> Option<i32> {
        self.0.calculated_dpi.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn skipped_resize(&self) -> bool {
        ::serde_json::to_value(&self.0.skipped_resize)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn resize_error(&self) -> Option<String> {
        self.0.resize_error.clone()
    }
}

pub struct Metadata(pub kreuzberg::Metadata);
impl Metadata {
    pub fn new(
        title: Option<String>,
        subject: Option<String>,
        authors: Option<Vec<String>>,
        keywords: Option<Vec<String>>,
        language: Option<String>,
        created_at: Option<String>,
        modified_at: Option<String>,
        created_by: Option<String>,
        modified_by: Option<String>,
        pages: Option<PageStructure>,
        format: Option<FormatMetadata>,
        image_preprocessing: Option<ImagePreprocessingMetadata>,
        json_schema: Option<String>,
        error: Option<ErrorMetadata>,
        extraction_duration_ms: Option<u64>,
        category: Option<String>,
        tags: Option<Vec<String>>,
        document_version: Option<String>,
        abstract_text: Option<String>,
        output_format: Option<String>,
        ocr_used: bool,
        additional: String,
    ) -> Metadata {
        let mut __target: kreuzberg::Metadata = ::std::default::Default::default();
        if let Some(s) = title {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.title = Some(t);
            }
        }
        if let Some(s) = subject {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.subject = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(authors) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.authors = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(keywords) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.keywords = t;
            }
        }
        if let Some(s) = language {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = Some(t);
            }
        }
        if let Some(s) = created_at {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.created_at = Some(t);
            }
        }
        if let Some(s) = modified_at {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.modified_at = Some(t);
            }
        }
        if let Some(s) = created_by {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.created_by = Some(t);
            }
        }
        if let Some(s) = modified_by {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.modified_by = Some(t);
            }
        }
        if let Some(w) = pages {
            __target.pages = Some(w.0);
        }
        // alef: format (FormatMetadata) is an enum; reverse From not generated — left at default
        if let Some(w) = image_preprocessing {
            __target.image_preprocessing = Some(w.0);
        }
        if let Some(s) = json_schema {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.json_schema = Some(t);
            }
        }
        if let Some(w) = error {
            __target.error = Some(w.0);
        }
        __target.extraction_duration_ms = extraction_duration_ms;
        if let Some(s) = category {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.category = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(tags) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.tags = t;
            }
        }
        if let Some(s) = document_version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.document_version = Some(t);
            }
        }
        if let Some(s) = abstract_text {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.abstract_text = Some(t);
            }
        }
        if let Some(s) = output_format {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.output_format = Some(t);
            }
        }
        __target.ocr_used = ocr_used;
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&additional) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.additional = t;
            }
        }
        Metadata(__target)
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn subject(&self) -> Option<String> {
        self.0.subject.clone()
    }
    pub fn authors(&self) -> Option<Vec<String>> {
        self.0.authors.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn keywords(&self) -> Option<Vec<String>> {
        self.0.keywords.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn created_at(&self) -> Option<String> {
        self.0.created_at.clone()
    }
    pub fn modified_at(&self) -> Option<String> {
        self.0.modified_at.clone()
    }
    pub fn created_by(&self) -> Option<String> {
        self.0.created_by.clone()
    }
    pub fn modified_by(&self) -> Option<String> {
        self.0.modified_by.clone()
    }
    pub fn pages(&self) -> Option<PageStructure> {
        self.0.pages.clone().map(PageStructure)
    }
    pub fn format(&self) -> Option<String> {
        self.0.format.clone().map(|w| FormatMetadata::from(w).to_string())
    }
    pub fn image_preprocessing(&self) -> Option<ImagePreprocessingMetadata> {
        self.0.image_preprocessing.clone().map(ImagePreprocessingMetadata)
    }
    pub fn json_schema(&self) -> Option<String> {
        self.0.json_schema.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn error(&self) -> Option<ErrorMetadata> {
        self.0.error.clone().map(ErrorMetadata)
    }
    pub fn extraction_duration_ms(&self) -> Option<u64> {
        self.0.extraction_duration_ms.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn category(&self) -> Option<String> {
        self.0.category.clone()
    }
    pub fn tags(&self) -> Option<Vec<String>> {
        self.0.tags.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn document_version(&self) -> Option<String> {
        self.0.document_version.clone()
    }
    pub fn abstract_text(&self) -> Option<String> {
        self.0.abstract_text.clone()
    }
    pub fn output_format(&self) -> Option<String> {
        self.0.output_format.clone()
    }
    pub fn ocr_used(&self) -> bool {
        ::serde_json::to_value(&self.0.ocr_used)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn additional(&self) -> String {
        serde_json::to_string(&self.0.additional).expect("serializable additional")
    }
}

pub struct ExcelMetadata(pub kreuzberg::ExcelMetadata);
impl ExcelMetadata {
    pub fn new(sheet_count: Option<u32>, sheet_names: Option<Vec<String>>) -> ExcelMetadata {
        let mut __target: kreuzberg::ExcelMetadata = ::std::default::Default::default();
        __target.sheet_count = sheet_count;
        if let Ok(__v) = ::serde_json::to_value(sheet_names) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.sheet_names = t;
            }
        }
        ExcelMetadata(__target)
    }
    pub fn sheet_count(&self) -> Option<u32> {
        self.0.sheet_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn sheet_names(&self) -> Option<Vec<String>> {
        self.0.sheet_names.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct EmailMetadata(pub kreuzberg::EmailMetadata);
impl EmailMetadata {
    pub fn new(
        from_email: Option<String>,
        from_name: Option<String>,
        to_emails: Vec<String>,
        cc_emails: Vec<String>,
        bcc_emails: Vec<String>,
        message_id: Option<String>,
        attachments: Vec<String>,
    ) -> EmailMetadata {
        let mut __target: kreuzberg::EmailMetadata = ::std::default::Default::default();
        if let Some(s) = from_email {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.from_email = Some(t);
            }
        }
        if let Some(s) = from_name {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.from_name = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(to_emails) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.to_emails = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(cc_emails) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cc_emails = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(bcc_emails) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.bcc_emails = t;
            }
        }
        if let Some(s) = message_id {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.message_id = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(attachments) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.attachments = t;
            }
        }
        EmailMetadata(__target)
    }
    pub fn from_email(&self) -> Option<String> {
        self.0.from_email.clone()
    }
    pub fn from_name(&self) -> Option<String> {
        self.0.from_name.clone()
    }
    pub fn to_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.to_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cc_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.cc_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bcc_emails(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.bcc_emails)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn message_id(&self) -> Option<String> {
        self.0.message_id.clone()
    }
    pub fn attachments(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.attachments)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ArchiveMetadata(pub kreuzberg::ArchiveMetadata);
impl ArchiveMetadata {
    pub fn new(
        format: String,
        file_count: u32,
        file_list: Vec<String>,
        total_size: u64,
        compressed_size: Option<u64>,
    ) -> ArchiveMetadata {
        let mut __target: kreuzberg::ArchiveMetadata = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&format)
                .unwrap_or(::serde_json::Value::String(format.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.format = t;
            }
        }
        __target.file_count = file_count;
        if let Ok(__v) = ::serde_json::to_value(file_list) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.file_list = t;
            }
        }
        __target.total_size = total_size;
        __target.compressed_size = compressed_size;
        ArchiveMetadata(__target)
    }
    pub fn format(&self) -> String {
        self.0.format.to_string()
    }
    pub fn file_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.file_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn file_list(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.file_list)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn total_size(&self) -> u64 {
        ::serde_json::to_value(&self.0.total_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn compressed_size(&self) -> Option<u64> {
        self.0.compressed_size.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct ImageMetadata(pub kreuzberg::ImageMetadata);
impl ImageMetadata {
    pub fn new(width: u32, height: u32, format: String, exif: String) -> ImageMetadata {
        let mut __target: kreuzberg::ImageMetadata = ::std::default::Default::default();
        __target.width = width;
        __target.height = height;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&format)
                .unwrap_or(::serde_json::Value::String(format.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.format = t;
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&exif) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.exif = t;
            }
        }
        ImageMetadata(__target)
    }
    pub fn width(&self) -> u32 {
        ::serde_json::to_value(&self.0.width)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn height(&self) -> u32 {
        ::serde_json::to_value(&self.0.height)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn format(&self) -> String {
        self.0.format.clone()
    }
    pub fn exif(&self) -> String {
        serde_json::to_string(&self.0.exif).expect("serializable exif")
    }
}

pub struct XmlMetadata(pub kreuzberg::XmlMetadata);
impl XmlMetadata {
    pub fn new(element_count: u32, unique_elements: Vec<String>) -> XmlMetadata {
        let mut __target: kreuzberg::XmlMetadata = ::std::default::Default::default();
        __target.element_count = element_count;
        if let Ok(__v) = ::serde_json::to_value(unique_elements) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.unique_elements = t;
            }
        }
        XmlMetadata(__target)
    }
    pub fn element_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.element_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn unique_elements(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.unique_elements)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct TextMetadata(pub kreuzberg::TextMetadata);
impl TextMetadata {
    pub fn new(
        line_count: u32,
        word_count: u32,
        character_count: u32,
        headers: Option<Vec<String>>,
        links: String,
        code_blocks: String,
    ) -> TextMetadata {
        let mut __target: kreuzberg::TextMetadata = ::std::default::Default::default();
        __target.line_count = line_count;
        __target.word_count = word_count;
        __target.character_count = character_count;
        if let Ok(__v) = ::serde_json::to_value(headers) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.headers = t;
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&links) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.links = t;
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&code_blocks) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.code_blocks = t;
            }
        }
        TextMetadata(__target)
    }
    pub fn line_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.line_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn word_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.word_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn character_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.character_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn headers(&self) -> Option<Vec<String>> {
        self.0.headers.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    // alef: skipped getter `links` — type cannot be bridged through swift-bridge
    // alef: skipped getter `code_blocks` — type cannot be bridged through swift-bridge
}

pub struct HeaderMetadata(pub kreuzberg::HeaderMetadata);
impl HeaderMetadata {
    pub fn level(&self) -> u8 {
        ::serde_json::to_value(&self.0.level)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn id(&self) -> Option<String> {
        self.0.id.clone()
    }
    pub fn depth(&self) -> u32 {
        ::serde_json::to_value(&self.0.depth)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn html_offset(&self) -> u32 {
        ::serde_json::to_value(&self.0.html_offset)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct LinkMetadata(pub kreuzberg::LinkMetadata);
impl LinkMetadata {
    pub fn href(&self) -> String {
        self.0.href.clone()
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn link_type(&self) -> String {
        LinkType::from(self.0.link_type.clone()).to_string()
    }
    pub fn rel(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.rel)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    // alef: skipped getter `attributes` — type cannot be bridged through swift-bridge
}

pub struct ImageMetadataType(pub kreuzberg::ImageMetadataType);
impl ImageMetadataType {
    pub fn src(&self) -> String {
        self.0.src.clone()
    }
    pub fn alt(&self) -> Option<String> {
        self.0.alt.clone()
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn dimensions(&self) -> Option<Vec<u32>> {
        self.0.dimensions.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn image_type(&self) -> String {
        ImageType::from(self.0.image_type.clone()).to_string()
    }
    // alef: skipped getter `attributes` — type cannot be bridged through swift-bridge
}

pub struct StructuredData(pub kreuzberg::StructuredData);
impl StructuredData {
    pub fn data_type(&self) -> String {
        StructuredDataType::from(self.0.data_type.clone()).to_string()
    }
    pub fn raw_json(&self) -> String {
        self.0.raw_json.clone()
    }
    pub fn schema_type(&self) -> Option<String> {
        self.0.schema_type.clone()
    }
}

pub struct HtmlMetadata(pub kreuzberg::HtmlMetadata);
impl HtmlMetadata {
    pub fn new(
        title: Option<String>,
        description: Option<String>,
        keywords: Vec<String>,
        author: Option<String>,
        canonical_url: Option<String>,
        base_href: Option<String>,
        language: Option<String>,
        text_direction: Option<TextDirection>,
        open_graph: String,
        twitter_card: String,
        meta_tags: String,
        headers: Vec<HeaderMetadata>,
        links: Vec<LinkMetadata>,
        images: Vec<ImageMetadataType>,
        structured_data: Vec<StructuredData>,
    ) -> HtmlMetadata {
        let mut __target: kreuzberg::HtmlMetadata = ::std::default::Default::default();
        if let Some(s) = title {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.title = Some(t);
            }
        }
        if let Some(s) = description {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.description = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(keywords) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.keywords = t;
            }
        }
        if let Some(s) = author {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.author = Some(t);
            }
        }
        if let Some(s) = canonical_url {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.canonical_url = Some(t);
            }
        }
        if let Some(s) = base_href {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.base_href = Some(t);
            }
        }
        if let Some(s) = language {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = Some(t);
            }
        }
        // alef: text_direction (TextDirection) is an enum; reverse From not generated — left at default
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&open_graph) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.open_graph = t;
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&twitter_card) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.twitter_card = t;
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&meta_tags) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.meta_tags = t;
            }
        }
        __target.headers = headers.into_iter().map(|w| w.0).collect();
        __target.links = links.into_iter().map(|w| w.0).collect();
        __target.images = images.into_iter().map(|w| w.0).collect();
        __target.structured_data = structured_data.into_iter().map(|w| w.0).collect();
        HtmlMetadata(__target)
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn description(&self) -> Option<String> {
        self.0.description.clone()
    }
    pub fn keywords(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.keywords)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn author(&self) -> Option<String> {
        self.0.author.clone()
    }
    pub fn canonical_url(&self) -> Option<String> {
        self.0.canonical_url.clone()
    }
    pub fn base_href(&self) -> Option<String> {
        self.0.base_href.clone()
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn text_direction(&self) -> Option<String> {
        self.0
            .text_direction
            .clone()
            .map(|w| TextDirection::from(w).to_string())
    }
    pub fn open_graph(&self) -> String {
        serde_json::to_string(&self.0.open_graph).expect("serializable open_graph")
    }
    pub fn twitter_card(&self) -> String {
        serde_json::to_string(&self.0.twitter_card).expect("serializable twitter_card")
    }
    pub fn meta_tags(&self) -> String {
        serde_json::to_string(&self.0.meta_tags).expect("serializable meta_tags")
    }
    pub fn headers(&self) -> Vec<HeaderMetadata> {
        self.0.headers.iter().map(|elem| HeaderMetadata(elem.clone())).collect()
    }
    pub fn links(&self) -> Vec<LinkMetadata> {
        self.0.links.iter().map(|elem| LinkMetadata(elem.clone())).collect()
    }
    pub fn images(&self) -> Vec<ImageMetadataType> {
        self.0
            .images
            .iter()
            .map(|elem| ImageMetadataType(elem.clone()))
            .collect()
    }
    pub fn structured_data(&self) -> Vec<StructuredData> {
        self.0
            .structured_data
            .iter()
            .map(|elem| StructuredData(elem.clone()))
            .collect()
    }
}

pub struct OcrMetadata(pub kreuzberg::OcrMetadata);
impl OcrMetadata {
    pub fn new(
        language: String,
        psm: i32,
        output_format: String,
        table_count: u32,
        table_rows: Option<u32>,
        table_cols: Option<u32>,
    ) -> OcrMetadata {
        let mut __target: kreuzberg::OcrMetadata = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&language)
                .unwrap_or(::serde_json::Value::String(language.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = t;
            }
        }
        __target.psm = psm;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&output_format)
                .unwrap_or(::serde_json::Value::String(output_format.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.output_format = t;
            }
        }
        __target.table_count = table_count;
        __target.table_rows = table_rows;
        __target.table_cols = table_cols;
        OcrMetadata(__target)
    }
    pub fn language(&self) -> String {
        self.0.language.clone()
    }
    pub fn psm(&self) -> i32 {
        ::serde_json::to_value(&self.0.psm)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn output_format(&self) -> String {
        self.0.output_format.clone()
    }
    pub fn table_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.table_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn table_rows(&self) -> Option<u32> {
        self.0.table_rows.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn table_cols(&self) -> Option<u32> {
        self.0.table_cols.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct ErrorMetadata(pub kreuzberg::ErrorMetadata);
impl ErrorMetadata {
    pub fn error_type(&self) -> String {
        self.0.error_type.clone()
    }
    pub fn message(&self) -> String {
        self.0.message.clone()
    }
}

pub struct PptxMetadata(pub kreuzberg::PptxMetadata);
impl PptxMetadata {
    pub fn new(
        slide_count: u32,
        slide_names: Vec<String>,
        image_count: Option<u32>,
        table_count: Option<u32>,
    ) -> PptxMetadata {
        let mut __target: kreuzberg::PptxMetadata = ::std::default::Default::default();
        __target.slide_count = slide_count;
        if let Ok(__v) = ::serde_json::to_value(slide_names) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.slide_names = t;
            }
        }
        __target.image_count = image_count;
        __target.table_count = table_count;
        PptxMetadata(__target)
    }
    pub fn slide_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.slide_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn slide_names(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.slide_names)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn image_count(&self) -> Option<u32> {
        self.0.image_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn table_count(&self) -> Option<u32> {
        self.0.table_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct DocxMetadata(pub kreuzberg::DocxMetadata);
impl DocxMetadata {
    pub fn new(
        core_properties: Option<CoreProperties>,
        app_properties: Option<DocxAppProperties>,
        custom_properties: String,
    ) -> DocxMetadata {
        let mut __target: kreuzberg::DocxMetadata = ::std::default::Default::default();
        if let Some(w) = core_properties {
            __target.core_properties = Some(w.0);
        }
        if let Some(w) = app_properties {
            __target.app_properties = Some(w.0);
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&custom_properties) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.custom_properties = t;
            }
        }
        DocxMetadata(__target)
    }
    pub fn core_properties(&self) -> Option<CoreProperties> {
        self.0.core_properties.clone().map(CoreProperties)
    }
    pub fn app_properties(&self) -> Option<DocxAppProperties> {
        self.0.app_properties.clone().map(DocxAppProperties)
    }
    pub fn custom_properties(&self) -> String {
        serde_json::to_string(&self.0.custom_properties).expect("serializable custom_properties")
    }
}

pub struct CsvMetadata(pub kreuzberg::CsvMetadata);
impl CsvMetadata {
    pub fn new(
        row_count: u32,
        column_count: u32,
        delimiter: Option<String>,
        has_header: bool,
        column_types: Option<Vec<String>>,
    ) -> CsvMetadata {
        let mut __target: kreuzberg::CsvMetadata = ::std::default::Default::default();
        __target.row_count = row_count;
        __target.column_count = column_count;
        if let Some(s) = delimiter {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.delimiter = Some(t);
            }
        }
        __target.has_header = has_header;
        if let Ok(__v) = ::serde_json::to_value(column_types) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.column_types = t;
            }
        }
        CsvMetadata(__target)
    }
    pub fn row_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.row_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn column_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.column_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn delimiter(&self) -> Option<String> {
        self.0.delimiter.clone()
    }
    pub fn has_header(&self) -> bool {
        ::serde_json::to_value(&self.0.has_header)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn column_types(&self) -> Option<Vec<String>> {
        self.0.column_types.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct BibtexMetadata(pub kreuzberg::BibtexMetadata);
impl BibtexMetadata {
    pub fn new(
        entry_count: usize,
        citation_keys: Vec<String>,
        authors: Vec<String>,
        year_range: Option<YearRange>,
        entry_types: String,
    ) -> BibtexMetadata {
        let mut __target: kreuzberg::BibtexMetadata = ::std::default::Default::default();
        __target.entry_count = entry_count;
        if let Ok(__v) = ::serde_json::to_value(citation_keys) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.citation_keys = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(authors) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.authors = t;
            }
        }
        if let Some(w) = year_range {
            __target.year_range = Some(w.0);
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&entry_types) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.entry_types = t;
            }
        }
        BibtexMetadata(__target)
    }
    pub fn entry_count(&self) -> usize {
        ::serde_json::to_value(&self.0.entry_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn citation_keys(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.citation_keys)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn authors(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.authors)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn year_range(&self) -> Option<YearRange> {
        self.0.year_range.clone().map(YearRange)
    }
    pub fn entry_types(&self) -> String {
        serde_json::to_string(&self.0.entry_types).expect("serializable entry_types")
    }
}

pub struct CitationMetadata(pub kreuzberg::CitationMetadata);
impl CitationMetadata {
    pub fn new(
        citation_count: usize,
        format: Option<String>,
        authors: Vec<String>,
        year_range: Option<YearRange>,
        dois: Vec<String>,
        keywords: Vec<String>,
    ) -> CitationMetadata {
        let mut __target: kreuzberg::CitationMetadata = ::std::default::Default::default();
        __target.citation_count = citation_count;
        if let Some(s) = format {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.format = Some(t);
            }
        }
        if let Ok(__v) = ::serde_json::to_value(authors) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.authors = t;
            }
        }
        if let Some(w) = year_range {
            __target.year_range = Some(w.0);
        }
        if let Ok(__v) = ::serde_json::to_value(dois) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.dois = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(keywords) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.keywords = t;
            }
        }
        CitationMetadata(__target)
    }
    pub fn citation_count(&self) -> usize {
        ::serde_json::to_value(&self.0.citation_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn format(&self) -> Option<String> {
        self.0.format.clone()
    }
    pub fn authors(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.authors)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn year_range(&self) -> Option<YearRange> {
        self.0.year_range.clone().map(YearRange)
    }
    pub fn dois(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.dois)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn keywords(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.keywords)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct YearRange(pub kreuzberg::YearRange);
impl YearRange {
    pub fn min(&self) -> Option<u32> {
        self.0.min.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn max(&self) -> Option<u32> {
        self.0.max.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn years(&self) -> Vec<u32> {
        ::serde_json::to_value(&self.0.years)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct FictionBookMetadata(pub kreuzberg::FictionBookMetadata);
impl FictionBookMetadata {
    pub fn new(genres: Vec<String>, sequences: Vec<String>, annotation: Option<String>) -> FictionBookMetadata {
        let mut __target: kreuzberg::FictionBookMetadata = ::std::default::Default::default();
        if let Ok(__v) = ::serde_json::to_value(genres) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.genres = t;
            }
        }
        if let Ok(__v) = ::serde_json::to_value(sequences) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.sequences = t;
            }
        }
        if let Some(s) = annotation {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.annotation = Some(t);
            }
        }
        FictionBookMetadata(__target)
    }
    pub fn genres(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.genres)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn sequences(&self) -> Vec<String> {
        ::serde_json::to_value(&self.0.sequences)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn annotation(&self) -> Option<String> {
        self.0.annotation.clone()
    }
}

pub struct DbfMetadata(pub kreuzberg::DbfMetadata);
impl DbfMetadata {
    pub fn new(record_count: usize, field_count: usize, fields: Vec<DbfFieldInfo>) -> DbfMetadata {
        let mut __target: kreuzberg::DbfMetadata = ::std::default::Default::default();
        __target.record_count = record_count;
        __target.field_count = field_count;
        __target.fields = fields.into_iter().map(|w| w.0).collect();
        DbfMetadata(__target)
    }
    pub fn record_count(&self) -> usize {
        ::serde_json::to_value(&self.0.record_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn field_count(&self) -> usize {
        ::serde_json::to_value(&self.0.field_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn fields(&self) -> Vec<DbfFieldInfo> {
        self.0.fields.iter().map(|elem| DbfFieldInfo(elem.clone())).collect()
    }
}

pub struct DbfFieldInfo(pub kreuzberg::DbfFieldInfo);
impl DbfFieldInfo {
    pub fn name(&self) -> String {
        self.0.name.clone()
    }
    pub fn field_type(&self) -> String {
        self.0.field_type.clone()
    }
}

pub struct JatsMetadata(pub kreuzberg::JatsMetadata);
impl JatsMetadata {
    pub fn new(
        copyright: Option<String>,
        license: Option<String>,
        history_dates: String,
        contributor_roles: Vec<ContributorRole>,
    ) -> JatsMetadata {
        let mut __target: kreuzberg::JatsMetadata = ::std::default::Default::default();
        if let Some(s) = copyright {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.copyright = Some(t);
            }
        }
        if let Some(s) = license {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.license = Some(t);
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&history_dates) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.history_dates = t;
            }
        }
        __target.contributor_roles = contributor_roles.into_iter().map(|w| w.0).collect();
        JatsMetadata(__target)
    }
    pub fn copyright(&self) -> Option<String> {
        self.0.copyright.clone()
    }
    pub fn license(&self) -> Option<String> {
        self.0.license.clone()
    }
    pub fn history_dates(&self) -> String {
        serde_json::to_string(&self.0.history_dates).expect("serializable history_dates")
    }
    pub fn contributor_roles(&self) -> Vec<ContributorRole> {
        self.0
            .contributor_roles
            .iter()
            .map(|elem| ContributorRole(elem.clone()))
            .collect()
    }
}

pub struct ContributorRole(pub kreuzberg::ContributorRole);
impl ContributorRole {
    pub fn name(&self) -> String {
        self.0.name.clone()
    }
    pub fn role(&self) -> Option<String> {
        self.0.role.clone()
    }
}

pub struct EpubMetadata(pub kreuzberg::EpubMetadata);
impl EpubMetadata {
    pub fn new(
        coverage: Option<String>,
        dc_format: Option<String>,
        relation: Option<String>,
        source: Option<String>,
        dc_type: Option<String>,
        cover_image: Option<String>,
    ) -> EpubMetadata {
        let mut __target: kreuzberg::EpubMetadata = ::std::default::Default::default();
        if let Some(s) = coverage {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.coverage = Some(t);
            }
        }
        if let Some(s) = dc_format {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.dc_format = Some(t);
            }
        }
        if let Some(s) = relation {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.relation = Some(t);
            }
        }
        if let Some(s) = source {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.source = Some(t);
            }
        }
        if let Some(s) = dc_type {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.dc_type = Some(t);
            }
        }
        if let Some(s) = cover_image {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cover_image = Some(t);
            }
        }
        EpubMetadata(__target)
    }
    pub fn coverage(&self) -> Option<String> {
        self.0.coverage.clone()
    }
    pub fn dc_format(&self) -> Option<String> {
        self.0.dc_format.clone()
    }
    pub fn relation(&self) -> Option<String> {
        self.0.relation.clone()
    }
    pub fn source(&self) -> Option<String> {
        self.0.source.clone()
    }
    pub fn dc_type(&self) -> Option<String> {
        self.0.dc_type.clone()
    }
    pub fn cover_image(&self) -> Option<String> {
        self.0.cover_image.clone()
    }
}

pub struct PstMetadata(pub kreuzberg::PstMetadata);
impl PstMetadata {
    pub fn new(message_count: usize) -> PstMetadata {
        PstMetadata(kreuzberg::PstMetadata { message_count })
    }
    pub fn message_count(&self) -> usize {
        ::serde_json::to_value(&self.0.message_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct OcrConfidence(pub kreuzberg::OcrConfidence);
impl OcrConfidence {
    pub fn new(detection: Option<f64>, recognition: f64) -> OcrConfidence {
        OcrConfidence(kreuzberg::OcrConfidence { detection, recognition })
    }
    pub fn detection(&self) -> Option<f64> {
        self.0.detection.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn recognition(&self) -> f64 {
        ::serde_json::to_value(&self.0.recognition)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct OcrRotation(pub kreuzberg::OcrRotation);
impl OcrRotation {
    pub fn new(angle_degrees: f64, confidence: Option<f64>) -> OcrRotation {
        OcrRotation(kreuzberg::OcrRotation {
            angle_degrees,
            confidence,
        })
    }
    pub fn angle_degrees(&self) -> f64 {
        ::serde_json::to_value(&self.0.angle_degrees)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn confidence(&self) -> Option<f64> {
        self.0.confidence.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct OcrElement(pub kreuzberg::OcrElement);
impl OcrElement {
    pub fn new(
        text: String,
        geometry: OcrBoundingGeometry,
        confidence: OcrConfidence,
        level: OcrElementLevel,
        rotation: Option<OcrRotation>,
        page_number: u32,
        parent_id: Option<String>,
        backend_metadata: String,
    ) -> OcrElement {
        let mut __target: kreuzberg::OcrElement = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&text)
                .unwrap_or(::serde_json::Value::String(text.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.text = t;
            }
        }
        // alef: geometry (OcrBoundingGeometry) is an enum; reverse From not generated — left at default
        __target.confidence = confidence.0;
        // alef: level (OcrElementLevel) is an enum; reverse From not generated — left at default
        if let Some(w) = rotation {
            __target.rotation = Some(w.0);
        }
        __target.page_number = page_number;
        if let Some(s) = parent_id {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.parent_id = Some(t);
            }
        }
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&backend_metadata) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.backend_metadata = t;
            }
        }
        OcrElement(__target)
    }
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn geometry(&self) -> String {
        OcrBoundingGeometry::from(self.0.geometry.clone()).to_string()
    }
    pub fn confidence(&self) -> OcrConfidence {
        OcrConfidence(self.0.confidence.clone())
    }
    pub fn level(&self) -> String {
        OcrElementLevel::from(self.0.level.clone()).to_string()
    }
    pub fn rotation(&self) -> Option<OcrRotation> {
        self.0.rotation.clone().map(OcrRotation)
    }
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn parent_id(&self) -> Option<String> {
        self.0.parent_id.clone()
    }
    pub fn backend_metadata(&self) -> String {
        serde_json::to_string(&self.0.backend_metadata).expect("serializable backend_metadata")
    }
}

pub struct OcrElementConfig(pub kreuzberg::OcrElementConfig);
impl OcrElementConfig {
    pub fn new(
        include_elements: bool,
        min_level: OcrElementLevel,
        min_confidence: f64,
        build_hierarchy: bool,
    ) -> OcrElementConfig {
        let mut __target: kreuzberg::OcrElementConfig = ::std::default::Default::default();
        __target.include_elements = include_elements;
        // alef: min_level (OcrElementLevel) is an enum; reverse From not generated — left at default
        __target.min_confidence = min_confidence;
        __target.build_hierarchy = build_hierarchy;
        OcrElementConfig(__target)
    }
    pub fn include_elements(&self) -> bool {
        ::serde_json::to_value(&self.0.include_elements)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_level(&self) -> String {
        OcrElementLevel::from(self.0.min_level.clone()).to_string()
    }
    pub fn min_confidence(&self) -> f64 {
        ::serde_json::to_value(&self.0.min_confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn build_hierarchy(&self) -> bool {
        ::serde_json::to_value(&self.0.build_hierarchy)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PageStructure(pub kreuzberg::PageStructure);
impl PageStructure {
    pub fn total_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.total_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn unit_type(&self) -> String {
        PageUnitType::from(self.0.unit_type.clone()).to_string()
    }
    pub fn boundaries(&self) -> Option<Vec<PageBoundary>> {
        self.0
            .boundaries
            .as_ref()
            .map(|v| v.iter().map(|elem| PageBoundary(elem.clone())).collect())
    }
    pub fn pages(&self) -> Option<Vec<PageInfo>> {
        self.0
            .pages
            .as_ref()
            .map(|v| v.iter().map(|elem| PageInfo(elem.clone())).collect())
    }
}

pub struct PageBoundary(pub kreuzberg::PageBoundary);
impl PageBoundary {
    pub fn new(byte_start: usize, byte_end: usize, page_number: u32) -> PageBoundary {
        PageBoundary(kreuzberg::PageBoundary {
            byte_start,
            byte_end,
            page_number,
        })
    }
    pub fn byte_start(&self) -> usize {
        ::serde_json::to_value(&self.0.byte_start)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn byte_end(&self) -> usize {
        ::serde_json::to_value(&self.0.byte_end)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PageInfo(pub kreuzberg::PageInfo);
impl PageInfo {
    pub fn number(&self) -> u32 {
        ::serde_json::to_value(&self.0.number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn title(&self) -> Option<String> {
        self.0.title.clone()
    }
    pub fn dimensions(&self) -> Option<Vec<f64>> {
        self.0.dimensions.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn image_count(&self) -> Option<u32> {
        self.0.image_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn table_count(&self) -> Option<u32> {
        self.0.table_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn hidden(&self) -> Option<bool> {
        self.0.hidden.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn is_blank(&self) -> Option<bool> {
        self.0.is_blank.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn has_vector_graphics(&self) -> bool {
        ::serde_json::to_value(&self.0.has_vector_graphics)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PageContent(pub kreuzberg::PageContent);
impl PageContent {
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn tables(&self) -> Vec<Table> {
        self.0.tables.iter().map(|elem| Table((**elem).clone())).collect()
    }
    pub fn image_indices(&self) -> Vec<u32> {
        ::serde_json::to_value(&self.0.image_indices)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn hierarchy(&self) -> Option<PageHierarchy> {
        self.0.hierarchy.clone().map(PageHierarchy)
    }
    pub fn is_blank(&self) -> Option<bool> {
        self.0.is_blank.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn layout_regions(&self) -> Option<Vec<LayoutRegion>> {
        self.0
            .layout_regions
            .as_ref()
            .map(|v| v.iter().map(|elem| LayoutRegion(elem.clone())).collect())
    }
    pub fn speaker_notes(&self) -> Option<String> {
        self.0.speaker_notes.clone()
    }
    pub fn section_name(&self) -> Option<String> {
        self.0.section_name.clone()
    }
    pub fn sheet_name(&self) -> Option<String> {
        self.0.sheet_name.clone()
    }
}

pub struct LayoutRegion(pub kreuzberg::LayoutRegion);
impl LayoutRegion {
    pub fn new(class_name: String, confidence: f64, bounding_box: BoundingBox, area_fraction: f64) -> LayoutRegion {
        let mut __target: kreuzberg::LayoutRegion = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&class_name)
                .unwrap_or(::serde_json::Value::String(class_name.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.class_name = t;
            }
        }
        __target.confidence = confidence;
        __target.bounding_box = bounding_box.0;
        __target.area_fraction = area_fraction;
        LayoutRegion(__target)
    }
    pub fn class_name(&self) -> String {
        self.0.class_name.clone()
    }
    pub fn confidence(&self) -> f64 {
        ::serde_json::to_value(&self.0.confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bounding_box(&self) -> BoundingBox {
        BoundingBox(self.0.bounding_box.clone())
    }
    pub fn area_fraction(&self) -> f64 {
        ::serde_json::to_value(&self.0.area_fraction)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct PageHierarchy(pub kreuzberg::PageHierarchy);
impl PageHierarchy {
    pub fn block_count(&self) -> u32 {
        ::serde_json::to_value(&self.0.block_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn blocks(&self) -> Vec<HierarchicalBlock> {
        self.0
            .blocks
            .iter()
            .map(|elem| HierarchicalBlock(elem.clone()))
            .collect()
    }
}

pub struct HierarchicalBlock(pub kreuzberg::HierarchicalBlock);
impl HierarchicalBlock {
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn font_size(&self) -> f32 {
        ::serde_json::to_value(&self.0.font_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn level(&self) -> String {
        self.0.level.clone()
    }
    pub fn bbox(&self) -> Option<Vec<f32>> {
        self.0.bbox.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct CellChange(pub kreuzberg::CellChange);
impl CellChange {
    pub fn row(&self) -> usize {
        ::serde_json::to_value(&self.0.row)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn col(&self) -> usize {
        ::serde_json::to_value(&self.0.col)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn from(&self) -> String {
        self.0.from.clone()
    }
    pub fn to(&self) -> String {
        self.0.to.clone()
    }
}

pub struct DocumentRevision(pub kreuzberg::DocumentRevision);
impl DocumentRevision {
    pub fn revision_id(&self) -> String {
        self.0.revision_id.clone()
    }
    pub fn author(&self) -> Option<String> {
        self.0.author.clone()
    }
    pub fn timestamp(&self) -> Option<String> {
        self.0.timestamp.clone()
    }
    pub fn kind(&self) -> String {
        RevisionKind::from(self.0.kind.clone()).to_string()
    }
    pub fn anchor(&self) -> Option<String> {
        self.0.anchor.clone().map(|w| RevisionAnchor::from(w).to_string())
    }
    pub fn delta(&self) -> RevisionDelta {
        RevisionDelta(self.0.delta.clone())
    }
}

pub struct RevisionDelta(pub kreuzberg::RevisionDelta);
impl RevisionDelta {
    pub fn new(content: Vec<DiffLine>, table_changes: Vec<CellChange>) -> RevisionDelta {
        let mut __target: kreuzberg::RevisionDelta = ::std::default::Default::default();
        // alef: content (Vec<>) contains enum elements — left at default
        __target.table_changes = table_changes.into_iter().map(|w| w.0).collect();
        RevisionDelta(__target)
    }
    pub fn content(&self) -> Vec<String> {
        self.0
            .content
            .iter()
            .map(|elem| DiffLine::from(elem.clone()).to_string())
            .collect()
    }
    pub fn table_changes(&self) -> Vec<CellChange> {
        self.0
            .table_changes
            .iter()
            .map(|elem| CellChange(elem.clone()))
            .collect()
    }
}

pub struct Table(pub kreuzberg::Table);
impl Table {
    pub fn new(cells: String, markdown: String, page_number: u32, bounding_box: Option<BoundingBox>) -> Table {
        let mut __target: kreuzberg::Table = ::std::default::Default::default();
        if let Ok(v) = ::serde_json::from_str::<::serde_json::Value>(&cells) {
            if let Ok(t) = ::serde_json::from_value(v) {
                __target.cells = t;
            }
        }
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&markdown)
                .unwrap_or(::serde_json::Value::String(markdown.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.markdown = t;
            }
        }
        __target.page_number = page_number;
        if let Some(w) = bounding_box {
            __target.bounding_box = Some(w.0);
        }
        Table(__target)
    }
    pub fn cells(&self) -> String {
        serde_json::to_string(&self.0.cells).expect("serializable cells")
    }
    pub fn markdown(&self) -> String {
        self.0.markdown.clone()
    }
    pub fn page_number(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_number)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bounding_box(&self) -> Option<BoundingBox> {
        self.0.bounding_box.clone().map(BoundingBox)
    }
}

pub struct TableCell(pub kreuzberg::TableCell);
impl TableCell {
    pub fn new(content: String, row_span: u32, col_span: u32, is_header: bool) -> TableCell {
        let mut __target: kreuzberg::TableCell = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&content)
                .unwrap_or(::serde_json::Value::String(content.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.content = t;
            }
        }
        __target.row_span = row_span;
        __target.col_span = col_span;
        __target.is_header = is_header;
        TableCell(__target)
    }
    pub fn content(&self) -> String {
        self.0.content.clone()
    }
    pub fn row_span(&self) -> u32 {
        ::serde_json::to_value(&self.0.row_span)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn col_span(&self) -> u32 {
        ::serde_json::to_value(&self.0.col_span)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn is_header(&self) -> bool {
        ::serde_json::to_value(&self.0.is_header)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct ExtractedUri(pub kreuzberg::ExtractedUri);
impl ExtractedUri {
    pub fn url(&self) -> String {
        self.0.url.clone()
    }
    pub fn label(&self) -> Option<String> {
        self.0.label.clone()
    }
    pub fn page(&self) -> Option<u32> {
        self.0.page.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn kind(&self) -> String {
        UriKind::from(self.0.kind.clone()).to_string()
    }
}

pub struct DetectResponse(pub kreuzberg::api::DetectResponse);
impl DetectResponse {
    pub fn mime_type(&self) -> String {
        self.0.mime_type.clone()
    }
    pub fn filename(&self) -> Option<String> {
        self.0.filename.clone()
    }
}

pub struct DiffOptions(pub kreuzberg::DiffOptions);
impl DiffOptions {
    pub fn new(include_metadata: bool, include_embedded: bool, max_content_chars: Option<usize>) -> DiffOptions {
        DiffOptions(kreuzberg::DiffOptions {
            include_metadata,
            include_embedded,
            max_content_chars,
        })
    }
    pub fn include_metadata(&self) -> bool {
        ::serde_json::to_value(&self.0.include_metadata)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn include_embedded(&self) -> bool {
        ::serde_json::to_value(&self.0.include_embedded)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_content_chars(&self) -> Option<usize> {
        self.0.max_content_chars.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct ExtractionDiff(pub kreuzberg::ExtractionDiff);
impl ExtractionDiff {
    pub fn content_diff(&self) -> Vec<DiffHunk> {
        self.0.content_diff.iter().map(|elem| DiffHunk(elem.clone())).collect()
    }
    pub fn tables_added(&self) -> Vec<Table> {
        self.0.tables_added.iter().map(|elem| Table(elem.clone())).collect()
    }
    pub fn tables_removed(&self) -> Vec<Table> {
        self.0.tables_removed.iter().map(|elem| Table(elem.clone())).collect()
    }
    pub fn tables_changed(&self) -> Vec<TableDiff> {
        self.0
            .tables_changed
            .iter()
            .map(|elem| TableDiff(elem.clone()))
            .collect()
    }
    pub fn metadata_changed(&self) -> String {
        serde_json::to_string(&self.0.metadata_changed).unwrap_or_default()
    }
    pub fn embedded_changes(&self) -> EmbeddedChanges {
        EmbeddedChanges(self.0.embedded_changes.clone())
    }
}

pub struct DiffHunk(pub kreuzberg::DiffHunk);
impl DiffHunk {
    pub fn from_line(&self) -> usize {
        ::serde_json::to_value(&self.0.from_line)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn from_count(&self) -> usize {
        ::serde_json::to_value(&self.0.from_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn to_line(&self) -> usize {
        ::serde_json::to_value(&self.0.to_line)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn to_count(&self) -> usize {
        ::serde_json::to_value(&self.0.to_count)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn lines(&self) -> Vec<String> {
        self.0
            .lines
            .iter()
            .map(|elem| DiffLine::from(elem.clone()).to_string())
            .collect()
    }
}

pub struct TableDiff(pub kreuzberg::TableDiff);
impl TableDiff {
    pub fn from_index(&self) -> usize {
        ::serde_json::to_value(&self.0.from_index)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn to_index(&self) -> usize {
        ::serde_json::to_value(&self.0.to_index)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn cell_changes(&self) -> Vec<CellChange> {
        self.0
            .cell_changes
            .iter()
            .map(|elem| CellChange(elem.clone()))
            .collect()
    }
}

pub struct EmbeddedChanges(pub kreuzberg::EmbeddedChanges);
impl EmbeddedChanges {
    pub fn added(&self) -> Vec<ArchiveEntry> {
        self.0.added.iter().map(|elem| ArchiveEntry(elem.clone())).collect()
    }
    pub fn removed(&self) -> Vec<ArchiveEntry> {
        self.0.removed.iter().map(|elem| ArchiveEntry(elem.clone())).collect()
    }
    pub fn changed(&self) -> Vec<EmbeddedDiff> {
        self.0.changed.iter().map(|elem| EmbeddedDiff(elem.clone())).collect()
    }
}

pub struct EmbeddedDiff(pub kreuzberg::EmbeddedDiff);
impl EmbeddedDiff {
    pub fn path(&self) -> String {
        self.0.path.clone()
    }
    pub fn diff(&self) -> ExtractionDiff {
        ExtractionDiff(*self.0.diff.clone())
    }
}

pub struct EmbeddingPreset(pub kreuzberg::EmbeddingPreset);
impl EmbeddingPreset {
    pub fn name(&self) -> String {
        self.0.name.clone()
    }
    pub fn chunk_size(&self) -> usize {
        ::serde_json::to_value(&self.0.chunk_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn overlap(&self) -> usize {
        ::serde_json::to_value(&self.0.overlap)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn model_repo(&self) -> String {
        self.0.model_repo.clone()
    }
    pub fn pooling(&self) -> String {
        self.0.pooling.clone()
    }
    pub fn model_file(&self) -> String {
        self.0.model_file.clone()
    }
    pub fn dimensions(&self) -> usize {
        ::serde_json::to_value(&self.0.dimensions)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn description(&self) -> String {
        self.0.description.clone()
    }
}

pub struct YakeParams(pub kreuzberg::YakeParams);
impl YakeParams {
    pub fn new(window_size: usize) -> YakeParams {
        YakeParams(kreuzberg::YakeParams { window_size })
    }
    pub fn window_size(&self) -> usize {
        ::serde_json::to_value(&self.0.window_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct RakeParams(pub kreuzberg::RakeParams);
impl RakeParams {
    pub fn new(min_word_length: usize, max_words_per_phrase: usize) -> RakeParams {
        RakeParams(kreuzberg::RakeParams {
            min_word_length,
            max_words_per_phrase,
        })
    }
    pub fn min_word_length(&self) -> usize {
        ::serde_json::to_value(&self.0.min_word_length)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn max_words_per_phrase(&self) -> usize {
        ::serde_json::to_value(&self.0.max_words_per_phrase)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct KeywordConfig(pub kreuzberg::KeywordConfig);
impl KeywordConfig {
    pub fn new(
        algorithm: KeywordAlgorithm,
        max_keywords: usize,
        min_score: f32,
        ngram_range: Vec<usize>,
        language: Option<String>,
        yake_params: Option<YakeParams>,
        rake_params: Option<RakeParams>,
    ) -> KeywordConfig {
        let mut __target: kreuzberg::KeywordConfig = ::std::default::Default::default();
        // alef: algorithm (KeywordAlgorithm) is an enum; reverse From not generated — left at default
        __target.max_keywords = max_keywords;
        __target.min_score = min_score;
        if let Ok(__v) = ::serde_json::to_value(ngram_range) {
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.ngram_range = t;
            }
        }
        if let Some(s) = language {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = Some(t);
            }
        }
        if let Some(w) = yake_params {
            __target.yake_params = Some(w.0);
        }
        if let Some(w) = rake_params {
            __target.rake_params = Some(w.0);
        }
        KeywordConfig(__target)
    }
    pub fn algorithm(&self) -> String {
        KeywordAlgorithm::from(self.0.algorithm.clone()).to_string()
    }
    pub fn max_keywords(&self) -> usize {
        ::serde_json::to_value(&self.0.max_keywords)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn min_score(&self) -> f32 {
        ::serde_json::to_value(&self.0.min_score)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn ngram_range(&self) -> Vec<usize> {
        ::serde_json::to_value(&self.0.ngram_range)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn language(&self) -> Option<String> {
        self.0.language.clone()
    }
    pub fn yake_params(&self) -> Option<YakeParams> {
        self.0.yake_params.clone().map(YakeParams)
    }
    pub fn rake_params(&self) -> Option<RakeParams> {
        self.0.rake_params.clone().map(RakeParams)
    }
}

pub struct Keyword(pub kreuzberg::Keyword);
impl Keyword {
    pub fn text(&self) -> String {
        self.0.text.clone()
    }
    pub fn score(&self) -> f32 {
        ::serde_json::to_value(&self.0.score)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn algorithm(&self) -> String {
        KeywordAlgorithm::from(self.0.algorithm.clone()).to_string()
    }
    pub fn positions(&self) -> Option<Vec<usize>> {
        self.0.positions.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub struct PaddleOcrConfig(pub kreuzberg::PaddleOcrConfig);
impl PaddleOcrConfig {
    pub fn new(
        language: String,
        cache_dir: Option<String>,
        use_angle_cls: bool,
        enable_table_detection: bool,
        det_db_thresh: f32,
        det_db_box_thresh: f32,
        det_db_unclip_ratio: f32,
        det_limit_side_len: u32,
        rec_batch_num: u32,
        padding: u32,
        drop_score: f32,
        model_tier: String,
    ) -> PaddleOcrConfig {
        let mut __target: kreuzberg::PaddleOcrConfig = ::std::default::Default::default();
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&language)
                .unwrap_or(::serde_json::Value::String(language.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.language = t;
            }
        }
        if let Some(s) = cache_dir {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.cache_dir = Some(t);
            }
        }
        __target.use_angle_cls = use_angle_cls;
        __target.enable_table_detection = enable_table_detection;
        __target.det_db_thresh = det_db_thresh;
        __target.det_db_box_thresh = det_db_box_thresh;
        __target.det_db_unclip_ratio = det_db_unclip_ratio;
        __target.det_limit_side_len = det_limit_side_len;
        __target.rec_batch_num = rec_batch_num;
        __target.padding = padding;
        __target.drop_score = drop_score;
        {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&model_tier)
                .unwrap_or(::serde_json::Value::String(model_tier.clone()));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.model_tier = t;
            }
        }
        PaddleOcrConfig(__target)
    }
    pub fn language(&self) -> String {
        self.0.language.clone()
    }
    pub fn cache_dir(&self) -> Option<String> {
        self.0.cache_dir.as_ref().and_then(|v| serde_json::to_string(v).ok())
    }
    pub fn use_angle_cls(&self) -> bool {
        ::serde_json::to_value(&self.0.use_angle_cls)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn enable_table_detection(&self) -> bool {
        ::serde_json::to_value(&self.0.enable_table_detection)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn det_db_thresh(&self) -> f32 {
        ::serde_json::to_value(&self.0.det_db_thresh)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn det_db_box_thresh(&self) -> f32 {
        ::serde_json::to_value(&self.0.det_db_box_thresh)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn det_db_unclip_ratio(&self) -> f32 {
        ::serde_json::to_value(&self.0.det_db_unclip_ratio)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn det_limit_side_len(&self) -> u32 {
        ::serde_json::to_value(&self.0.det_limit_side_len)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn rec_batch_num(&self) -> u32 {
        ::serde_json::to_value(&self.0.rec_batch_num)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn padding(&self) -> u32 {
        ::serde_json::to_value(&self.0.padding)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn drop_score(&self) -> f32 {
        ::serde_json::to_value(&self.0.drop_score)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn model_tier(&self) -> String {
        self.0.model_tier.clone()
    }
}

pub struct ModelPaths(pub kreuzberg::ModelPaths);
impl ModelPaths {
    pub fn det_model(&self) -> String {
        serde_json::to_string(&self.0.det_model).unwrap_or_default()
    }
    pub fn cls_model(&self) -> String {
        serde_json::to_string(&self.0.cls_model).unwrap_or_default()
    }
    pub fn rec_model(&self) -> String {
        serde_json::to_string(&self.0.rec_model).unwrap_or_default()
    }
    pub fn dict_file(&self) -> String {
        serde_json::to_string(&self.0.dict_file).unwrap_or_default()
    }
}

pub struct OrientationResult(pub kreuzberg::OrientationResult);
impl OrientationResult {
    pub fn new(degrees: u32, confidence: f32) -> OrientationResult {
        OrientationResult(kreuzberg::OrientationResult { degrees, confidence })
    }
    pub fn degrees(&self) -> u32 {
        ::serde_json::to_value(&self.0.degrees)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn confidence(&self) -> f32 {
        ::serde_json::to_value(&self.0.confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct BBox(pub kreuzberg::BBox);
impl BBox {
    pub fn new(x1: f32, y1: f32, x2: f32, y2: f32) -> BBox {
        BBox(kreuzberg::BBox { x1, y1, x2, y2 })
    }
    pub fn x1(&self) -> f32 {
        ::serde_json::to_value(&self.0.x1)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn y1(&self) -> f32 {
        ::serde_json::to_value(&self.0.y1)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn x2(&self) -> f32 {
        ::serde_json::to_value(&self.0.x2)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn y2(&self) -> f32 {
        ::serde_json::to_value(&self.0.y2)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
}

pub struct LayoutDetection(pub kreuzberg::LayoutDetection);
impl LayoutDetection {
    pub fn class_name(&self) -> String {
        LayoutClass::from(self.0.class_name.clone()).to_string()
    }
    pub fn confidence(&self) -> f32 {
        ::serde_json::to_value(&self.0.confidence)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn bbox(&self) -> BBox {
        BBox(self.0.bbox.clone())
    }
}

pub struct RecognizedTable(pub kreuzberg::RecognizedTable);
impl RecognizedTable {
    pub fn detection_bbox(&self) -> BBox {
        BBox(self.0.detection_bbox.clone())
    }
    pub fn cells(&self) -> String {
        serde_json::to_string(&self.0.cells).expect("serializable cells")
    }
    pub fn markdown(&self) -> String {
        self.0.markdown.clone()
    }
}

pub struct DetectionResult(pub kreuzberg::DetectionResult);
impl DetectionResult {
    pub fn page_width(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_width)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn page_height(&self) -> u32 {
        ::serde_json::to_value(&self.0.page_height)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn detections(&self) -> Vec<LayoutDetection> {
        self.0
            .detections
            .iter()
            .map(|elem| LayoutDetection(elem.clone()))
            .collect()
    }
}

pub struct EmbeddedFile(pub kreuzberg::pdf::embedded_files::EmbeddedFile);
impl EmbeddedFile {
    pub fn name(&self) -> String {
        self.0.name.clone()
    }
    pub fn data(&self) -> Vec<u8> {
        self.0.data.to_vec()
    }
    pub fn compressed_size(&self) -> usize {
        ::serde_json::to_value(&self.0.compressed_size)
            .ok()
            .and_then(|j| ::serde_json::from_value(j).ok())
            .unwrap_or_default()
    }
    pub fn mime_type(&self) -> Option<String> {
        self.0.mime_type.clone()
    }
}

pub struct PdfMetadata(pub kreuzberg::pdf::metadata::PdfMetadata);
impl PdfMetadata {
    pub fn new(
        pdf_version: Option<String>,
        producer: Option<String>,
        is_encrypted: Option<bool>,
        width: Option<i64>,
        height: Option<i64>,
        page_count: Option<u32>,
    ) -> PdfMetadata {
        let mut __target: kreuzberg::pdf::metadata::PdfMetadata = ::std::default::Default::default();
        if let Some(s) = pdf_version {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.pdf_version = Some(t);
            }
        }
        if let Some(s) = producer {
            // Try JSON parse first (handles enum/object values); on parse failure
            // treat the raw input as a JSON string scalar so plain `String` /
            // string-like enum fields don't end up empty for inputs that aren't
            // valid JSON tokens (e.g. `tts-1`).
            let __v = ::serde_json::from_str::<::serde_json::Value>(&s).unwrap_or(::serde_json::Value::String(s));
            if let Ok(t) = ::serde_json::from_value(__v) {
                __target.producer = Some(t);
            }
        }
        __target.is_encrypted = is_encrypted;
        __target.width = width;
        __target.height = height;
        __target.page_count = page_count;
        PdfMetadata(__target)
    }
    pub fn pdf_version(&self) -> Option<String> {
        self.0.pdf_version.clone()
    }
    pub fn producer(&self) -> Option<String> {
        self.0.producer.clone()
    }
    pub fn is_encrypted(&self) -> Option<bool> {
        self.0.is_encrypted.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn width(&self) -> Option<i64> {
        self.0.width.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn height(&self) -> Option<i64> {
        self.0.height.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
    pub fn page_count(&self) -> Option<u32> {
        self.0.page_count.as_ref().and_then(|v| {
            ::serde_json::to_value(v)
                .ok()
                .and_then(|j| ::serde_json::from_value(j).ok())
        })
    }
}

pub enum ExecutionProviderType {
    Auto,
    Cpu,
    CoreMl,
    Cuda,
    TensorRt,
}

impl From<kreuzberg::ExecutionProviderType> for ExecutionProviderType {
    fn from(val: kreuzberg::ExecutionProviderType) -> Self {
        match val {
            kreuzberg::ExecutionProviderType::Auto => Self::Auto,
            kreuzberg::ExecutionProviderType::Cpu => Self::Cpu,
            kreuzberg::ExecutionProviderType::CoreMl => Self::CoreMl,
            kreuzberg::ExecutionProviderType::Cuda => Self::Cuda,
            kreuzberg::ExecutionProviderType::TensorRt => Self::TensorRt,
        }
    }
}

impl ExecutionProviderType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Auto => "auto".to_string(),
            Self::Cpu => "cpu".to_string(),
            Self::CoreMl => "coreml".to_string(),
            Self::Cuda => "cuda".to_string(),
            Self::TensorRt => "tensorrt".to_string(),
        }
    }
}

pub enum OutputFormat {
    Plain,
    Markdown,
    Djot,
    Html,
    Json,
    Structured,
    Custom,
}

impl From<kreuzberg::OutputFormat> for OutputFormat {
    fn from(val: kreuzberg::OutputFormat) -> Self {
        match val {
            kreuzberg::OutputFormat::Plain => Self::Plain,
            kreuzberg::OutputFormat::Markdown => Self::Markdown,
            kreuzberg::OutputFormat::Djot => Self::Djot,
            kreuzberg::OutputFormat::Html => Self::Html,
            kreuzberg::OutputFormat::Json => Self::Json,
            kreuzberg::OutputFormat::Structured => Self::Structured,
            kreuzberg::OutputFormat::Custom(..) => Self::Custom,
        }
    }
}

impl OutputFormat {
    pub fn to_string(&self) -> String {
        match self {
            Self::Plain => "plain".to_string(),
            Self::Markdown => "markdown".to_string(),
            Self::Djot => "djot".to_string(),
            Self::Html => "html".to_string(),
            Self::Json => "json".to_string(),
            Self::Structured => "structured".to_string(),
            Self::Custom => "custom".to_string(),
        }
    }
}

pub enum HtmlTheme {
    Default,
    GitHub,
    Dark,
    Light,
    Unstyled,
}

impl From<kreuzberg::HtmlTheme> for HtmlTheme {
    fn from(val: kreuzberg::HtmlTheme) -> Self {
        match val {
            kreuzberg::HtmlTheme::Default => Self::Default,
            kreuzberg::HtmlTheme::GitHub => Self::GitHub,
            kreuzberg::HtmlTheme::Dark => Self::Dark,
            kreuzberg::HtmlTheme::Light => Self::Light,
            kreuzberg::HtmlTheme::Unstyled => Self::Unstyled,
        }
    }
}

impl HtmlTheme {
    pub fn to_string(&self) -> String {
        match self {
            Self::Default => "default".to_string(),
            Self::GitHub => "github".to_string(),
            Self::Dark => "dark".to_string(),
            Self::Light => "light".to_string(),
            Self::Unstyled => "unstyled".to_string(),
        }
    }
}

pub enum TableModel {
    Tatr,
    SlanetWired,
    SlanetWireless,
    SlanetPlus,
    SlanetAuto,
    Disabled,
}

impl From<kreuzberg::TableModel> for TableModel {
    fn from(val: kreuzberg::TableModel) -> Self {
        match val {
            kreuzberg::TableModel::Tatr => Self::Tatr,
            kreuzberg::TableModel::SlanetWired => Self::SlanetWired,
            kreuzberg::TableModel::SlanetWireless => Self::SlanetWireless,
            kreuzberg::TableModel::SlanetPlus => Self::SlanetPlus,
            kreuzberg::TableModel::SlanetAuto => Self::SlanetAuto,
            kreuzberg::TableModel::Disabled => Self::Disabled,
        }
    }
}

impl TableModel {
    pub fn to_string(&self) -> String {
        match self {
            Self::Tatr => "tatr".to_string(),
            Self::SlanetWired => "slanet_wired".to_string(),
            Self::SlanetWireless => "slanet_wireless".to_string(),
            Self::SlanetPlus => "slanet_plus".to_string(),
            Self::SlanetAuto => "slanet_auto".to_string(),
            Self::Disabled => "disabled".to_string(),
        }
    }
}

pub enum ChunkerType {
    Text,
    Markdown,
    Yaml,
    Semantic,
}

impl From<kreuzberg::ChunkerType> for ChunkerType {
    fn from(val: kreuzberg::ChunkerType) -> Self {
        match val {
            kreuzberg::ChunkerType::Text => Self::Text,
            kreuzberg::ChunkerType::Markdown => Self::Markdown,
            kreuzberg::ChunkerType::Yaml => Self::Yaml,
            kreuzberg::ChunkerType::Semantic => Self::Semantic,
        }
    }
}

impl ChunkerType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Text => "text".to_string(),
            Self::Markdown => "markdown".to_string(),
            Self::Yaml => "yaml".to_string(),
            Self::Semantic => "semantic".to_string(),
        }
    }
}

pub enum ChunkSizing {
    Characters,
    Tokenizer,
}

impl From<kreuzberg::ChunkSizing> for ChunkSizing {
    fn from(val: kreuzberg::ChunkSizing) -> Self {
        match val {
            kreuzberg::ChunkSizing::Characters => Self::Characters,
            kreuzberg::ChunkSizing::Tokenizer { .. } => Self::Tokenizer,
        }
    }
}

impl ChunkSizing {
    pub fn to_string(&self) -> String {
        match self {
            Self::Characters => "characters".to_string(),
            Self::Tokenizer => "tokenizer".to_string(),
        }
    }
}

pub enum EmbeddingModelType {
    Preset,
    Custom,
    Llm,
    Plugin,
}

impl From<kreuzberg::EmbeddingModelType> for EmbeddingModelType {
    fn from(val: kreuzberg::EmbeddingModelType) -> Self {
        match val {
            kreuzberg::EmbeddingModelType::Preset { .. } => Self::Preset,
            kreuzberg::EmbeddingModelType::Custom { .. } => Self::Custom,
            kreuzberg::EmbeddingModelType::Llm { .. } => Self::Llm,
            kreuzberg::EmbeddingModelType::Plugin { .. } => Self::Plugin,
        }
    }
}

impl EmbeddingModelType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Preset => "preset".to_string(),
            Self::Custom => "custom".to_string(),
            Self::Llm => "llm".to_string(),
            Self::Plugin => "plugin".to_string(),
        }
    }
}

pub enum CodeContentMode {
    Chunks,
    Raw,
    Structure,
}

impl From<kreuzberg::CodeContentMode> for CodeContentMode {
    fn from(val: kreuzberg::CodeContentMode) -> Self {
        match val {
            kreuzberg::CodeContentMode::Chunks => Self::Chunks,
            kreuzberg::CodeContentMode::Raw => Self::Raw,
            kreuzberg::CodeContentMode::Structure => Self::Structure,
        }
    }
}

impl CodeContentMode {
    pub fn to_string(&self) -> String {
        match self {
            Self::Chunks => "chunks".to_string(),
            Self::Raw => "raw".to_string(),
            Self::Structure => "structure".to_string(),
        }
    }
}

pub enum ListType {
    Bullet,
    Numbered,
    Lettered,
    Indented,
}

impl From<kreuzberg::extraction::transform::ListType> for ListType {
    fn from(val: kreuzberg::extraction::transform::ListType) -> Self {
        match val {
            kreuzberg::extraction::transform::ListType::Bullet => Self::Bullet,
            kreuzberg::extraction::transform::ListType::Numbered => Self::Numbered,
            kreuzberg::extraction::transform::ListType::Lettered => Self::Lettered,
            kreuzberg::extraction::transform::ListType::Indented => Self::Indented,
        }
    }
}

impl ListType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Bullet => "Bullet".to_string(),
            Self::Numbered => "Numbered".to_string(),
            Self::Lettered => "Lettered".to_string(),
            Self::Indented => "Indented".to_string(),
        }
    }
}

pub enum OcrBackendType {
    Tesseract,
    EasyOCR,
    PaddleOCR,
    Custom,
}

impl From<kreuzberg::OcrBackendType> for OcrBackendType {
    fn from(val: kreuzberg::OcrBackendType) -> Self {
        match val {
            kreuzberg::OcrBackendType::Tesseract => Self::Tesseract,
            kreuzberg::OcrBackendType::EasyOCR => Self::EasyOCR,
            kreuzberg::OcrBackendType::PaddleOCR => Self::PaddleOCR,
            kreuzberg::OcrBackendType::Custom => Self::Custom,
        }
    }
}

impl OcrBackendType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Tesseract => "Tesseract".to_string(),
            Self::EasyOCR => "EasyOCR".to_string(),
            Self::PaddleOCR => "PaddleOCR".to_string(),
            Self::Custom => "Custom".to_string(),
        }
    }
}

pub enum ProcessingStage {
    Early,
    Middle,
    Late,
}

impl From<kreuzberg::ProcessingStage> for ProcessingStage {
    fn from(val: kreuzberg::ProcessingStage) -> Self {
        match val {
            kreuzberg::ProcessingStage::Early => Self::Early,
            kreuzberg::ProcessingStage::Middle => Self::Middle,
            kreuzberg::ProcessingStage::Late => Self::Late,
        }
    }
}

impl ProcessingStage {
    pub fn to_string(&self) -> String {
        match self {
            Self::Early => "Early".to_string(),
            Self::Middle => "Middle".to_string(),
            Self::Late => "Late".to_string(),
        }
    }
}

pub enum ReductionLevel {
    Off,
    Light,
    Moderate,
    Aggressive,
    Maximum,
}

impl From<kreuzberg::ReductionLevel> for ReductionLevel {
    fn from(val: kreuzberg::ReductionLevel) -> Self {
        match val {
            kreuzberg::ReductionLevel::Off => Self::Off,
            kreuzberg::ReductionLevel::Light => Self::Light,
            kreuzberg::ReductionLevel::Moderate => Self::Moderate,
            kreuzberg::ReductionLevel::Aggressive => Self::Aggressive,
            kreuzberg::ReductionLevel::Maximum => Self::Maximum,
        }
    }
}

impl ReductionLevel {
    pub fn to_string(&self) -> String {
        match self {
            Self::Off => "Off".to_string(),
            Self::Light => "Light".to_string(),
            Self::Moderate => "Moderate".to_string(),
            Self::Aggressive => "Aggressive".to_string(),
            Self::Maximum => "Maximum".to_string(),
        }
    }
}

pub enum PdfAnnotationType {
    Text,
    Highlight,
    Link,
    Stamp,
    Underline,
    StrikeOut,
    Other,
}

impl From<kreuzberg::PdfAnnotationType> for PdfAnnotationType {
    fn from(val: kreuzberg::PdfAnnotationType) -> Self {
        match val {
            kreuzberg::PdfAnnotationType::Text => Self::Text,
            kreuzberg::PdfAnnotationType::Highlight => Self::Highlight,
            kreuzberg::PdfAnnotationType::Link => Self::Link,
            kreuzberg::PdfAnnotationType::Stamp => Self::Stamp,
            kreuzberg::PdfAnnotationType::Underline => Self::Underline,
            kreuzberg::PdfAnnotationType::StrikeOut => Self::StrikeOut,
            kreuzberg::PdfAnnotationType::Other => Self::Other,
        }
    }
}

impl PdfAnnotationType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Text => "text".to_string(),
            Self::Highlight => "highlight".to_string(),
            Self::Link => "link".to_string(),
            Self::Stamp => "stamp".to_string(),
            Self::Underline => "underline".to_string(),
            Self::StrikeOut => "strike_out".to_string(),
            Self::Other => "other".to_string(),
        }
    }
}

pub enum BlockType {
    Paragraph,
    Heading,
    Blockquote,
    CodeBlock,
    ListItem,
    OrderedList,
    BulletList,
    TaskList,
    DefinitionList,
    DefinitionTerm,
    DefinitionDescription,
    Div,
    Section,
    ThematicBreak,
    RawBlock,
    MathDisplay,
}

impl From<kreuzberg::BlockType> for BlockType {
    fn from(val: kreuzberg::BlockType) -> Self {
        match val {
            kreuzberg::BlockType::Paragraph => Self::Paragraph,
            kreuzberg::BlockType::Heading => Self::Heading,
            kreuzberg::BlockType::Blockquote => Self::Blockquote,
            kreuzberg::BlockType::CodeBlock => Self::CodeBlock,
            kreuzberg::BlockType::ListItem => Self::ListItem,
            kreuzberg::BlockType::OrderedList => Self::OrderedList,
            kreuzberg::BlockType::BulletList => Self::BulletList,
            kreuzberg::BlockType::TaskList => Self::TaskList,
            kreuzberg::BlockType::DefinitionList => Self::DefinitionList,
            kreuzberg::BlockType::DefinitionTerm => Self::DefinitionTerm,
            kreuzberg::BlockType::DefinitionDescription => Self::DefinitionDescription,
            kreuzberg::BlockType::Div => Self::Div,
            kreuzberg::BlockType::Section => Self::Section,
            kreuzberg::BlockType::ThematicBreak => Self::ThematicBreak,
            kreuzberg::BlockType::RawBlock => Self::RawBlock,
            kreuzberg::BlockType::MathDisplay => Self::MathDisplay,
        }
    }
}

impl BlockType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Paragraph => "paragraph".to_string(),
            Self::Heading => "heading".to_string(),
            Self::Blockquote => "blockquote".to_string(),
            Self::CodeBlock => "code_block".to_string(),
            Self::ListItem => "list_item".to_string(),
            Self::OrderedList => "ordered_list".to_string(),
            Self::BulletList => "bullet_list".to_string(),
            Self::TaskList => "task_list".to_string(),
            Self::DefinitionList => "definition_list".to_string(),
            Self::DefinitionTerm => "definition_term".to_string(),
            Self::DefinitionDescription => "definition_description".to_string(),
            Self::Div => "div".to_string(),
            Self::Section => "section".to_string(),
            Self::ThematicBreak => "thematic_break".to_string(),
            Self::RawBlock => "raw_block".to_string(),
            Self::MathDisplay => "math_display".to_string(),
        }
    }
}

pub enum InlineType {
    Text,
    Strong,
    Emphasis,
    Highlight,
    Subscript,
    Superscript,
    Insert,
    Delete,
    Code,
    Link,
    Image,
    Span,
    Math,
    RawInline,
    FootnoteRef,
    Symbol,
}

impl From<kreuzberg::InlineType> for InlineType {
    fn from(val: kreuzberg::InlineType) -> Self {
        match val {
            kreuzberg::InlineType::Text => Self::Text,
            kreuzberg::InlineType::Strong => Self::Strong,
            kreuzberg::InlineType::Emphasis => Self::Emphasis,
            kreuzberg::InlineType::Highlight => Self::Highlight,
            kreuzberg::InlineType::Subscript => Self::Subscript,
            kreuzberg::InlineType::Superscript => Self::Superscript,
            kreuzberg::InlineType::Insert => Self::Insert,
            kreuzberg::InlineType::Delete => Self::Delete,
            kreuzberg::InlineType::Code => Self::Code,
            kreuzberg::InlineType::Link => Self::Link,
            kreuzberg::InlineType::Image => Self::Image,
            kreuzberg::InlineType::Span => Self::Span,
            kreuzberg::InlineType::Math => Self::Math,
            kreuzberg::InlineType::RawInline => Self::RawInline,
            kreuzberg::InlineType::FootnoteRef => Self::FootnoteRef,
            kreuzberg::InlineType::Symbol => Self::Symbol,
        }
    }
}

impl InlineType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Text => "text".to_string(),
            Self::Strong => "strong".to_string(),
            Self::Emphasis => "emphasis".to_string(),
            Self::Highlight => "highlight".to_string(),
            Self::Subscript => "subscript".to_string(),
            Self::Superscript => "superscript".to_string(),
            Self::Insert => "insert".to_string(),
            Self::Delete => "delete".to_string(),
            Self::Code => "code".to_string(),
            Self::Link => "link".to_string(),
            Self::Image => "image".to_string(),
            Self::Span => "span".to_string(),
            Self::Math => "math".to_string(),
            Self::RawInline => "raw_inline".to_string(),
            Self::FootnoteRef => "footnote_ref".to_string(),
            Self::Symbol => "symbol".to_string(),
        }
    }
}

pub enum RelationshipKind {
    FootnoteReference,
    CitationReference,
    InternalLink,
    Caption,
    Label,
    TocEntry,
    CrossReference,
}

impl From<kreuzberg::RelationshipKind> for RelationshipKind {
    fn from(val: kreuzberg::RelationshipKind) -> Self {
        match val {
            kreuzberg::RelationshipKind::FootnoteReference => Self::FootnoteReference,
            kreuzberg::RelationshipKind::CitationReference => Self::CitationReference,
            kreuzberg::RelationshipKind::InternalLink => Self::InternalLink,
            kreuzberg::RelationshipKind::Caption => Self::Caption,
            kreuzberg::RelationshipKind::Label => Self::Label,
            kreuzberg::RelationshipKind::TocEntry => Self::TocEntry,
            kreuzberg::RelationshipKind::CrossReference => Self::CrossReference,
        }
    }
}

impl RelationshipKind {
    pub fn to_string(&self) -> String {
        match self {
            Self::FootnoteReference => "footnote_reference".to_string(),
            Self::CitationReference => "citation_reference".to_string(),
            Self::InternalLink => "internal_link".to_string(),
            Self::Caption => "caption".to_string(),
            Self::Label => "label".to_string(),
            Self::TocEntry => "toc_entry".to_string(),
            Self::CrossReference => "cross_reference".to_string(),
        }
    }
}

pub enum ContentLayer {
    Body,
    Header,
    Footer,
    Footnote,
}

impl From<kreuzberg::ContentLayer> for ContentLayer {
    fn from(val: kreuzberg::ContentLayer) -> Self {
        match val {
            kreuzberg::ContentLayer::Body => Self::Body,
            kreuzberg::ContentLayer::Header => Self::Header,
            kreuzberg::ContentLayer::Footer => Self::Footer,
            kreuzberg::ContentLayer::Footnote => Self::Footnote,
        }
    }
}

impl ContentLayer {
    pub fn to_string(&self) -> String {
        match self {
            Self::Body => "body".to_string(),
            Self::Header => "header".to_string(),
            Self::Footer => "footer".to_string(),
            Self::Footnote => "footnote".to_string(),
        }
    }
}

pub enum NodeContent {
    Title,
    Heading,
    Paragraph,
    List,
    ListItem,
    Table,
    Image,
    Code,
    Quote,
    Formula,
    Footnote,
    Group,
    PageBreak,
    Slide,
    DefinitionList,
    DefinitionItem,
    Citation,
    Admonition,
    RawBlock,
    MetadataBlock,
}

impl From<kreuzberg::NodeContent> for NodeContent {
    fn from(val: kreuzberg::NodeContent) -> Self {
        match val {
            kreuzberg::NodeContent::Title { .. } => Self::Title,
            kreuzberg::NodeContent::Heading { .. } => Self::Heading,
            kreuzberg::NodeContent::Paragraph { .. } => Self::Paragraph,
            kreuzberg::NodeContent::List { .. } => Self::List,
            kreuzberg::NodeContent::ListItem { .. } => Self::ListItem,
            kreuzberg::NodeContent::Table { .. } => Self::Table,
            kreuzberg::NodeContent::Image { .. } => Self::Image,
            kreuzberg::NodeContent::Code { .. } => Self::Code,
            kreuzberg::NodeContent::Quote => Self::Quote,
            kreuzberg::NodeContent::Formula { .. } => Self::Formula,
            kreuzberg::NodeContent::Footnote { .. } => Self::Footnote,
            kreuzberg::NodeContent::Group { .. } => Self::Group,
            kreuzberg::NodeContent::PageBreak => Self::PageBreak,
            kreuzberg::NodeContent::Slide { .. } => Self::Slide,
            kreuzberg::NodeContent::DefinitionList => Self::DefinitionList,
            kreuzberg::NodeContent::DefinitionItem { .. } => Self::DefinitionItem,
            kreuzberg::NodeContent::Citation { .. } => Self::Citation,
            kreuzberg::NodeContent::Admonition { .. } => Self::Admonition,
            kreuzberg::NodeContent::RawBlock { .. } => Self::RawBlock,
            kreuzberg::NodeContent::MetadataBlock { .. } => Self::MetadataBlock,
        }
    }
}

impl NodeContent {
    pub fn to_string(&self) -> String {
        match self {
            Self::Title => "title".to_string(),
            Self::Heading => "heading".to_string(),
            Self::Paragraph => "paragraph".to_string(),
            Self::List => "list".to_string(),
            Self::ListItem => "list_item".to_string(),
            Self::Table => "table".to_string(),
            Self::Image => "image".to_string(),
            Self::Code => "code".to_string(),
            Self::Quote => "quote".to_string(),
            Self::Formula => "formula".to_string(),
            Self::Footnote => "footnote".to_string(),
            Self::Group => "group".to_string(),
            Self::PageBreak => "page_break".to_string(),
            Self::Slide => "slide".to_string(),
            Self::DefinitionList => "definition_list".to_string(),
            Self::DefinitionItem => "definition_item".to_string(),
            Self::Citation => "citation".to_string(),
            Self::Admonition => "admonition".to_string(),
            Self::RawBlock => "raw_block".to_string(),
            Self::MetadataBlock => "metadata_block".to_string(),
        }
    }
}

pub enum AnnotationKind {
    Bold,
    Italic,
    Underline,
    Strikethrough,
    Code,
    Subscript,
    Superscript,
    Link,
    Highlight,
    Color,
    FontSize,
    Custom,
}

impl From<kreuzberg::AnnotationKind> for AnnotationKind {
    fn from(val: kreuzberg::AnnotationKind) -> Self {
        match val {
            kreuzberg::AnnotationKind::Bold => Self::Bold,
            kreuzberg::AnnotationKind::Italic => Self::Italic,
            kreuzberg::AnnotationKind::Underline => Self::Underline,
            kreuzberg::AnnotationKind::Strikethrough => Self::Strikethrough,
            kreuzberg::AnnotationKind::Code => Self::Code,
            kreuzberg::AnnotationKind::Subscript => Self::Subscript,
            kreuzberg::AnnotationKind::Superscript => Self::Superscript,
            kreuzberg::AnnotationKind::Link { .. } => Self::Link,
            kreuzberg::AnnotationKind::Highlight => Self::Highlight,
            kreuzberg::AnnotationKind::Color { .. } => Self::Color,
            kreuzberg::AnnotationKind::FontSize { .. } => Self::FontSize,
            kreuzberg::AnnotationKind::Custom { .. } => Self::Custom,
        }
    }
}

impl AnnotationKind {
    pub fn to_string(&self) -> String {
        match self {
            Self::Bold => "bold".to_string(),
            Self::Italic => "italic".to_string(),
            Self::Underline => "underline".to_string(),
            Self::Strikethrough => "strikethrough".to_string(),
            Self::Code => "code".to_string(),
            Self::Subscript => "subscript".to_string(),
            Self::Superscript => "superscript".to_string(),
            Self::Link => "link".to_string(),
            Self::Highlight => "highlight".to_string(),
            Self::Color => "color".to_string(),
            Self::FontSize => "font_size".to_string(),
            Self::Custom => "custom".to_string(),
        }
    }
}

pub enum ExtractionMethod {
    Native,
    Ocr,
    Mixed,
}

impl From<kreuzberg::ExtractionMethod> for ExtractionMethod {
    fn from(val: kreuzberg::ExtractionMethod) -> Self {
        match val {
            kreuzberg::ExtractionMethod::Native => Self::Native,
            kreuzberg::ExtractionMethod::Ocr => Self::Ocr,
            kreuzberg::ExtractionMethod::Mixed => Self::Mixed,
        }
    }
}

impl ExtractionMethod {
    pub fn to_string(&self) -> String {
        match self {
            Self::Native => "native".to_string(),
            Self::Ocr => "ocr".to_string(),
            Self::Mixed => "mixed".to_string(),
        }
    }
}

pub enum ChunkType {
    Heading,
    PartyList,
    Definitions,
    OperativeClause,
    SignatureBlock,
    Schedule,
    TableLike,
    Formula,
    CodeBlock,
    Image,
    OrgChart,
    Diagram,
    Unknown,
}

impl From<kreuzberg::ChunkType> for ChunkType {
    fn from(val: kreuzberg::ChunkType) -> Self {
        match val {
            kreuzberg::ChunkType::Heading => Self::Heading,
            kreuzberg::ChunkType::PartyList => Self::PartyList,
            kreuzberg::ChunkType::Definitions => Self::Definitions,
            kreuzberg::ChunkType::OperativeClause => Self::OperativeClause,
            kreuzberg::ChunkType::SignatureBlock => Self::SignatureBlock,
            kreuzberg::ChunkType::Schedule => Self::Schedule,
            kreuzberg::ChunkType::TableLike => Self::TableLike,
            kreuzberg::ChunkType::Formula => Self::Formula,
            kreuzberg::ChunkType::CodeBlock => Self::CodeBlock,
            kreuzberg::ChunkType::Image => Self::Image,
            kreuzberg::ChunkType::OrgChart => Self::OrgChart,
            kreuzberg::ChunkType::Diagram => Self::Diagram,
            kreuzberg::ChunkType::Unknown => Self::Unknown,
        }
    }
}

impl ChunkType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Heading => "heading".to_string(),
            Self::PartyList => "party_list".to_string(),
            Self::Definitions => "definitions".to_string(),
            Self::OperativeClause => "operative_clause".to_string(),
            Self::SignatureBlock => "signature_block".to_string(),
            Self::Schedule => "schedule".to_string(),
            Self::TableLike => "table_like".to_string(),
            Self::Formula => "formula".to_string(),
            Self::CodeBlock => "code_block".to_string(),
            Self::Image => "image".to_string(),
            Self::OrgChart => "org_chart".to_string(),
            Self::Diagram => "diagram".to_string(),
            Self::Unknown => "unknown".to_string(),
        }
    }
}

pub enum ImageKind {
    Photograph,
    Diagram,
    Chart,
    Drawing,
    TextBlock,
    Decoration,
    Logo,
    Icon,
    TileFragment,
    Mask,
    PageRaster,
    Unknown,
}

impl From<kreuzberg::ImageKind> for ImageKind {
    fn from(val: kreuzberg::ImageKind) -> Self {
        match val {
            kreuzberg::ImageKind::Photograph => Self::Photograph,
            kreuzberg::ImageKind::Diagram => Self::Diagram,
            kreuzberg::ImageKind::Chart => Self::Chart,
            kreuzberg::ImageKind::Drawing => Self::Drawing,
            kreuzberg::ImageKind::TextBlock => Self::TextBlock,
            kreuzberg::ImageKind::Decoration => Self::Decoration,
            kreuzberg::ImageKind::Logo => Self::Logo,
            kreuzberg::ImageKind::Icon => Self::Icon,
            kreuzberg::ImageKind::TileFragment => Self::TileFragment,
            kreuzberg::ImageKind::Mask => Self::Mask,
            kreuzberg::ImageKind::PageRaster => Self::PageRaster,
            kreuzberg::ImageKind::Unknown => Self::Unknown,
        }
    }
}

impl ImageKind {
    pub fn to_string(&self) -> String {
        match self {
            Self::Photograph => "photograph".to_string(),
            Self::Diagram => "diagram".to_string(),
            Self::Chart => "chart".to_string(),
            Self::Drawing => "drawing".to_string(),
            Self::TextBlock => "text_block".to_string(),
            Self::Decoration => "decoration".to_string(),
            Self::Logo => "logo".to_string(),
            Self::Icon => "icon".to_string(),
            Self::TileFragment => "tile_fragment".to_string(),
            Self::Mask => "mask".to_string(),
            Self::PageRaster => "page_raster".to_string(),
            Self::Unknown => "unknown".to_string(),
        }
    }
}

pub enum ResultFormat {
    Unified,
    ElementBased,
}

impl From<kreuzberg::ResultFormat> for ResultFormat {
    fn from(val: kreuzberg::ResultFormat) -> Self {
        match val {
            kreuzberg::ResultFormat::Unified => Self::Unified,
            kreuzberg::ResultFormat::ElementBased => Self::ElementBased,
        }
    }
}

impl ResultFormat {
    pub fn to_string(&self) -> String {
        match self {
            Self::Unified => "unified".to_string(),
            Self::ElementBased => "element_based".to_string(),
        }
    }
}

pub enum ElementType {
    Title,
    NarrativeText,
    Heading,
    ListItem,
    Table,
    Image,
    PageBreak,
    CodeBlock,
    BlockQuote,
    Footer,
    Header,
}

impl From<kreuzberg::ElementType> for ElementType {
    fn from(val: kreuzberg::ElementType) -> Self {
        match val {
            kreuzberg::ElementType::Title => Self::Title,
            kreuzberg::ElementType::NarrativeText => Self::NarrativeText,
            kreuzberg::ElementType::Heading => Self::Heading,
            kreuzberg::ElementType::ListItem => Self::ListItem,
            kreuzberg::ElementType::Table => Self::Table,
            kreuzberg::ElementType::Image => Self::Image,
            kreuzberg::ElementType::PageBreak => Self::PageBreak,
            kreuzberg::ElementType::CodeBlock => Self::CodeBlock,
            kreuzberg::ElementType::BlockQuote => Self::BlockQuote,
            kreuzberg::ElementType::Footer => Self::Footer,
            kreuzberg::ElementType::Header => Self::Header,
        }
    }
}

impl ElementType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Title => "title".to_string(),
            Self::NarrativeText => "narrative_text".to_string(),
            Self::Heading => "heading".to_string(),
            Self::ListItem => "list_item".to_string(),
            Self::Table => "table".to_string(),
            Self::Image => "image".to_string(),
            Self::PageBreak => "page_break".to_string(),
            Self::CodeBlock => "code_block".to_string(),
            Self::BlockQuote => "block_quote".to_string(),
            Self::Footer => "footer".to_string(),
            Self::Header => "header".to_string(),
        }
    }
}

pub enum FormatMetadata {
    Pdf,
    Docx,
    Excel,
    Email,
    Pptx,
    Archive,
    Image,
    Xml,
    Text,
    Html,
    Ocr,
    Csv,
    Bibtex,
    Citation,
    FictionBook,
    Dbf,
    Jats,
    Epub,
    Pst,
    Code,
}

impl From<kreuzberg::FormatMetadata> for FormatMetadata {
    fn from(val: kreuzberg::FormatMetadata) -> Self {
        match val {
            kreuzberg::FormatMetadata::Pdf(..) => Self::Pdf,
            kreuzberg::FormatMetadata::Docx(..) => Self::Docx,
            kreuzberg::FormatMetadata::Excel(..) => Self::Excel,
            kreuzberg::FormatMetadata::Email(..) => Self::Email,
            kreuzberg::FormatMetadata::Pptx(..) => Self::Pptx,
            kreuzberg::FormatMetadata::Archive(..) => Self::Archive,
            kreuzberg::FormatMetadata::Image(..) => Self::Image,
            kreuzberg::FormatMetadata::Xml(..) => Self::Xml,
            kreuzberg::FormatMetadata::Text(..) => Self::Text,
            kreuzberg::FormatMetadata::Html(..) => Self::Html,
            kreuzberg::FormatMetadata::Ocr(..) => Self::Ocr,
            kreuzberg::FormatMetadata::Csv(..) => Self::Csv,
            kreuzberg::FormatMetadata::Bibtex(..) => Self::Bibtex,
            kreuzberg::FormatMetadata::Citation(..) => Self::Citation,
            kreuzberg::FormatMetadata::FictionBook(..) => Self::FictionBook,
            kreuzberg::FormatMetadata::Dbf(..) => Self::Dbf,
            kreuzberg::FormatMetadata::Jats(..) => Self::Jats,
            kreuzberg::FormatMetadata::Epub(..) => Self::Epub,
            kreuzberg::FormatMetadata::Pst(..) => Self::Pst,
            kreuzberg::FormatMetadata::Code(..) => Self::Code,
        }
    }
}

impl FormatMetadata {
    pub fn to_string(&self) -> String {
        match self {
            Self::Pdf => "pdf".to_string(),
            Self::Docx => "docx".to_string(),
            Self::Excel => "excel".to_string(),
            Self::Email => "email".to_string(),
            Self::Pptx => "pptx".to_string(),
            Self::Archive => "archive".to_string(),
            Self::Image => "image".to_string(),
            Self::Xml => "xml".to_string(),
            Self::Text => "text".to_string(),
            Self::Html => "html".to_string(),
            Self::Ocr => "ocr".to_string(),
            Self::Csv => "csv".to_string(),
            Self::Bibtex => "bibtex".to_string(),
            Self::Citation => "citation".to_string(),
            Self::FictionBook => "fiction_book".to_string(),
            Self::Dbf => "dbf".to_string(),
            Self::Jats => "jats".to_string(),
            Self::Epub => "epub".to_string(),
            Self::Pst => "pst".to_string(),
            Self::Code => "code".to_string(),
        }
    }
}

pub enum TextDirection {
    LeftToRight,
    RightToLeft,
    Auto,
}

impl From<kreuzberg::TextDirection> for TextDirection {
    fn from(val: kreuzberg::TextDirection) -> Self {
        match val {
            kreuzberg::TextDirection::LeftToRight => Self::LeftToRight,
            kreuzberg::TextDirection::RightToLeft => Self::RightToLeft,
            kreuzberg::TextDirection::Auto => Self::Auto,
        }
    }
}

impl TextDirection {
    pub fn to_string(&self) -> String {
        match self {
            Self::LeftToRight => "ltr".to_string(),
            Self::RightToLeft => "rtl".to_string(),
            Self::Auto => "auto".to_string(),
        }
    }
}

pub enum LinkType {
    Anchor,
    Internal,
    External,
    Email,
    Phone,
    Other,
}

impl From<kreuzberg::LinkType> for LinkType {
    fn from(val: kreuzberg::LinkType) -> Self {
        match val {
            kreuzberg::LinkType::Anchor => Self::Anchor,
            kreuzberg::LinkType::Internal => Self::Internal,
            kreuzberg::LinkType::External => Self::External,
            kreuzberg::LinkType::Email => Self::Email,
            kreuzberg::LinkType::Phone => Self::Phone,
            kreuzberg::LinkType::Other => Self::Other,
        }
    }
}

impl LinkType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Anchor => "anchor".to_string(),
            Self::Internal => "internal".to_string(),
            Self::External => "external".to_string(),
            Self::Email => "email".to_string(),
            Self::Phone => "phone".to_string(),
            Self::Other => "other".to_string(),
        }
    }
}

pub enum ImageType {
    DataUri,
    InlineSvg,
    External,
    Relative,
}

impl From<kreuzberg::ImageType> for ImageType {
    fn from(val: kreuzberg::ImageType) -> Self {
        match val {
            kreuzberg::ImageType::DataUri => Self::DataUri,
            kreuzberg::ImageType::InlineSvg => Self::InlineSvg,
            kreuzberg::ImageType::External => Self::External,
            kreuzberg::ImageType::Relative => Self::Relative,
        }
    }
}

impl ImageType {
    pub fn to_string(&self) -> String {
        match self {
            Self::DataUri => "data-uri".to_string(),
            Self::InlineSvg => "inline-svg".to_string(),
            Self::External => "external".to_string(),
            Self::Relative => "relative".to_string(),
        }
    }
}

pub enum StructuredDataType {
    JsonLd,
    Microdata,
    RDFa,
}

impl From<kreuzberg::StructuredDataType> for StructuredDataType {
    fn from(val: kreuzberg::StructuredDataType) -> Self {
        match val {
            kreuzberg::StructuredDataType::JsonLd => Self::JsonLd,
            kreuzberg::StructuredDataType::Microdata => Self::Microdata,
            kreuzberg::StructuredDataType::RDFa => Self::RDFa,
        }
    }
}

impl StructuredDataType {
    pub fn to_string(&self) -> String {
        match self {
            Self::JsonLd => "json-ld".to_string(),
            Self::Microdata => "microdata".to_string(),
            Self::RDFa => "rdfa".to_string(),
        }
    }
}

pub enum OcrBoundingGeometry {
    Rectangle,
    Quadrilateral,
}

impl From<kreuzberg::OcrBoundingGeometry> for OcrBoundingGeometry {
    fn from(val: kreuzberg::OcrBoundingGeometry) -> Self {
        match val {
            kreuzberg::OcrBoundingGeometry::Rectangle { .. } => Self::Rectangle,
            kreuzberg::OcrBoundingGeometry::Quadrilateral { .. } => Self::Quadrilateral,
        }
    }
}

impl OcrBoundingGeometry {
    pub fn to_string(&self) -> String {
        match self {
            Self::Rectangle => "rectangle".to_string(),
            Self::Quadrilateral => "quadrilateral".to_string(),
        }
    }
}

pub enum OcrElementLevel {
    Word,
    Line,
    Block,
    Page,
}

impl From<kreuzberg::OcrElementLevel> for OcrElementLevel {
    fn from(val: kreuzberg::OcrElementLevel) -> Self {
        match val {
            kreuzberg::OcrElementLevel::Word => Self::Word,
            kreuzberg::OcrElementLevel::Line => Self::Line,
            kreuzberg::OcrElementLevel::Block => Self::Block,
            kreuzberg::OcrElementLevel::Page => Self::Page,
        }
    }
}

impl OcrElementLevel {
    pub fn to_string(&self) -> String {
        match self {
            Self::Word => "word".to_string(),
            Self::Line => "line".to_string(),
            Self::Block => "block".to_string(),
            Self::Page => "page".to_string(),
        }
    }
}

pub enum PageUnitType {
    Page,
    Slide,
    Sheet,
}

impl From<kreuzberg::PageUnitType> for PageUnitType {
    fn from(val: kreuzberg::PageUnitType) -> Self {
        match val {
            kreuzberg::PageUnitType::Page => Self::Page,
            kreuzberg::PageUnitType::Slide => Self::Slide,
            kreuzberg::PageUnitType::Sheet => Self::Sheet,
        }
    }
}

impl PageUnitType {
    pub fn to_string(&self) -> String {
        match self {
            Self::Page => "page".to_string(),
            Self::Slide => "slide".to_string(),
            Self::Sheet => "sheet".to_string(),
        }
    }
}

pub enum DiffLine {
    Context,
    Added,
    Removed,
}

impl From<kreuzberg::DiffLine> for DiffLine {
    fn from(val: kreuzberg::DiffLine) -> Self {
        match val {
            kreuzberg::DiffLine::Context(..) => Self::Context,
            kreuzberg::DiffLine::Added(..) => Self::Added,
            kreuzberg::DiffLine::Removed(..) => Self::Removed,
        }
    }
}

impl DiffLine {
    pub fn to_string(&self) -> String {
        match self {
            Self::Context => "context".to_string(),
            Self::Added => "added".to_string(),
            Self::Removed => "removed".to_string(),
        }
    }
}

pub enum RevisionKind {
    Insertion,
    Deletion,
    FormatChange,
    Comment,
}

impl From<kreuzberg::RevisionKind> for RevisionKind {
    fn from(val: kreuzberg::RevisionKind) -> Self {
        match val {
            kreuzberg::RevisionKind::Insertion => Self::Insertion,
            kreuzberg::RevisionKind::Deletion => Self::Deletion,
            kreuzberg::RevisionKind::FormatChange => Self::FormatChange,
            kreuzberg::RevisionKind::Comment => Self::Comment,
        }
    }
}

impl RevisionKind {
    pub fn to_string(&self) -> String {
        match self {
            Self::Insertion => "insertion".to_string(),
            Self::Deletion => "deletion".to_string(),
            Self::FormatChange => "format_change".to_string(),
            Self::Comment => "comment".to_string(),
        }
    }
}

pub enum RevisionAnchor {
    Paragraph,
    TableCell,
    Page,
    Slide,
    Sheet,
}

impl From<kreuzberg::RevisionAnchor> for RevisionAnchor {
    fn from(val: kreuzberg::RevisionAnchor) -> Self {
        match val {
            kreuzberg::RevisionAnchor::Paragraph { .. } => Self::Paragraph,
            kreuzberg::RevisionAnchor::TableCell { .. } => Self::TableCell,
            kreuzberg::RevisionAnchor::Page { .. } => Self::Page,
            kreuzberg::RevisionAnchor::Slide { .. } => Self::Slide,
            kreuzberg::RevisionAnchor::Sheet { .. } => Self::Sheet,
        }
    }
}

impl RevisionAnchor {
    pub fn to_string(&self) -> String {
        match self {
            Self::Paragraph => "paragraph".to_string(),
            Self::TableCell => "table_cell".to_string(),
            Self::Page => "page".to_string(),
            Self::Slide => "slide".to_string(),
            Self::Sheet => "sheet".to_string(),
        }
    }
}

pub enum UriKind {
    Hyperlink,
    Image,
    Anchor,
    Citation,
    Reference,
    Email,
}

impl From<kreuzberg::UriKind> for UriKind {
    fn from(val: kreuzberg::UriKind) -> Self {
        match val {
            kreuzberg::UriKind::Hyperlink => Self::Hyperlink,
            kreuzberg::UriKind::Image => Self::Image,
            kreuzberg::UriKind::Anchor => Self::Anchor,
            kreuzberg::UriKind::Citation => Self::Citation,
            kreuzberg::UriKind::Reference => Self::Reference,
            kreuzberg::UriKind::Email => Self::Email,
        }
    }
}

impl UriKind {
    pub fn to_string(&self) -> String {
        match self {
            Self::Hyperlink => "hyperlink".to_string(),
            Self::Image => "image".to_string(),
            Self::Anchor => "anchor".to_string(),
            Self::Citation => "citation".to_string(),
            Self::Reference => "reference".to_string(),
            Self::Email => "email".to_string(),
        }
    }
}

pub enum KeywordAlgorithm {
    Yake,
    Rake,
}

impl From<kreuzberg::KeywordAlgorithm> for KeywordAlgorithm {
    fn from(val: kreuzberg::KeywordAlgorithm) -> Self {
        match val {
            kreuzberg::KeywordAlgorithm::Yake => Self::Yake,
            kreuzberg::KeywordAlgorithm::Rake => Self::Rake,
        }
    }
}

impl KeywordAlgorithm {
    pub fn to_string(&self) -> String {
        match self {
            Self::Yake => "yake".to_string(),
            Self::Rake => "rake".to_string(),
        }
    }
}

pub enum PSMMode {
    OsdOnly,
    AutoOsd,
    AutoOnly,
    Auto,
    SingleColumn,
    SingleBlockVertical,
    SingleBlock,
    SingleLine,
    SingleWord,
    CircleWord,
    SingleChar,
}

impl From<kreuzberg::PSMMode> for PSMMode {
    fn from(val: kreuzberg::PSMMode) -> Self {
        match val {
            kreuzberg::PSMMode::OsdOnly => Self::OsdOnly,
            kreuzberg::PSMMode::AutoOsd => Self::AutoOsd,
            kreuzberg::PSMMode::AutoOnly => Self::AutoOnly,
            kreuzberg::PSMMode::Auto => Self::Auto,
            kreuzberg::PSMMode::SingleColumn => Self::SingleColumn,
            kreuzberg::PSMMode::SingleBlockVertical => Self::SingleBlockVertical,
            kreuzberg::PSMMode::SingleBlock => Self::SingleBlock,
            kreuzberg::PSMMode::SingleLine => Self::SingleLine,
            kreuzberg::PSMMode::SingleWord => Self::SingleWord,
            kreuzberg::PSMMode::CircleWord => Self::CircleWord,
            kreuzberg::PSMMode::SingleChar => Self::SingleChar,
        }
    }
}

impl PSMMode {
    pub fn to_string(&self) -> String {
        match self {
            Self::OsdOnly => "OsdOnly".to_string(),
            Self::AutoOsd => "AutoOsd".to_string(),
            Self::AutoOnly => "AutoOnly".to_string(),
            Self::Auto => "Auto".to_string(),
            Self::SingleColumn => "SingleColumn".to_string(),
            Self::SingleBlockVertical => "SingleBlockVertical".to_string(),
            Self::SingleBlock => "SingleBlock".to_string(),
            Self::SingleLine => "SingleLine".to_string(),
            Self::SingleWord => "SingleWord".to_string(),
            Self::CircleWord => "CircleWord".to_string(),
            Self::SingleChar => "SingleChar".to_string(),
        }
    }
}

pub enum PaddleLanguage {
    English,
    Chinese,
    Japanese,
    Korean,
    German,
    French,
    Latin,
    Cyrillic,
    TraditionalChinese,
    Thai,
    Greek,
    EastSlavic,
    Arabic,
    Devanagari,
    Tamil,
    Telugu,
}

impl From<kreuzberg::PaddleLanguage> for PaddleLanguage {
    fn from(val: kreuzberg::PaddleLanguage) -> Self {
        match val {
            kreuzberg::PaddleLanguage::English => Self::English,
            kreuzberg::PaddleLanguage::Chinese => Self::Chinese,
            kreuzberg::PaddleLanguage::Japanese => Self::Japanese,
            kreuzberg::PaddleLanguage::Korean => Self::Korean,
            kreuzberg::PaddleLanguage::German => Self::German,
            kreuzberg::PaddleLanguage::French => Self::French,
            kreuzberg::PaddleLanguage::Latin => Self::Latin,
            kreuzberg::PaddleLanguage::Cyrillic => Self::Cyrillic,
            kreuzberg::PaddleLanguage::TraditionalChinese => Self::TraditionalChinese,
            kreuzberg::PaddleLanguage::Thai => Self::Thai,
            kreuzberg::PaddleLanguage::Greek => Self::Greek,
            kreuzberg::PaddleLanguage::EastSlavic => Self::EastSlavic,
            kreuzberg::PaddleLanguage::Arabic => Self::Arabic,
            kreuzberg::PaddleLanguage::Devanagari => Self::Devanagari,
            kreuzberg::PaddleLanguage::Tamil => Self::Tamil,
            kreuzberg::PaddleLanguage::Telugu => Self::Telugu,
        }
    }
}

impl PaddleLanguage {
    pub fn to_string(&self) -> String {
        match self {
            Self::English => "English".to_string(),
            Self::Chinese => "Chinese".to_string(),
            Self::Japanese => "Japanese".to_string(),
            Self::Korean => "Korean".to_string(),
            Self::German => "German".to_string(),
            Self::French => "French".to_string(),
            Self::Latin => "Latin".to_string(),
            Self::Cyrillic => "Cyrillic".to_string(),
            Self::TraditionalChinese => "TraditionalChinese".to_string(),
            Self::Thai => "Thai".to_string(),
            Self::Greek => "Greek".to_string(),
            Self::EastSlavic => "EastSlavic".to_string(),
            Self::Arabic => "Arabic".to_string(),
            Self::Devanagari => "Devanagari".to_string(),
            Self::Tamil => "Tamil".to_string(),
            Self::Telugu => "Telugu".to_string(),
        }
    }
}

pub enum LayoutClass {
    Caption,
    Footnote,
    Formula,
    ListItem,
    PageFooter,
    PageHeader,
    Picture,
    SectionHeader,
    Table,
    Text,
    Title,
    DocumentIndex,
    Code,
    CheckboxSelected,
    CheckboxUnselected,
    Form,
    KeyValueRegion,
}

impl From<kreuzberg::LayoutClass> for LayoutClass {
    fn from(val: kreuzberg::LayoutClass) -> Self {
        match val {
            kreuzberg::LayoutClass::Caption => Self::Caption,
            kreuzberg::LayoutClass::Footnote => Self::Footnote,
            kreuzberg::LayoutClass::Formula => Self::Formula,
            kreuzberg::LayoutClass::ListItem => Self::ListItem,
            kreuzberg::LayoutClass::PageFooter => Self::PageFooter,
            kreuzberg::LayoutClass::PageHeader => Self::PageHeader,
            kreuzberg::LayoutClass::Picture => Self::Picture,
            kreuzberg::LayoutClass::SectionHeader => Self::SectionHeader,
            kreuzberg::LayoutClass::Table => Self::Table,
            kreuzberg::LayoutClass::Text => Self::Text,
            kreuzberg::LayoutClass::Title => Self::Title,
            kreuzberg::LayoutClass::DocumentIndex => Self::DocumentIndex,
            kreuzberg::LayoutClass::Code => Self::Code,
            kreuzberg::LayoutClass::CheckboxSelected => Self::CheckboxSelected,
            kreuzberg::LayoutClass::CheckboxUnselected => Self::CheckboxUnselected,
            kreuzberg::LayoutClass::Form => Self::Form,
            kreuzberg::LayoutClass::KeyValueRegion => Self::KeyValueRegion,
        }
    }
}

impl LayoutClass {
    pub fn to_string(&self) -> String {
        match self {
            Self::Caption => "caption".to_string(),
            Self::Footnote => "footnote".to_string(),
            Self::Formula => "formula".to_string(),
            Self::ListItem => "list_item".to_string(),
            Self::PageFooter => "page_footer".to_string(),
            Self::PageHeader => "page_header".to_string(),
            Self::Picture => "picture".to_string(),
            Self::SectionHeader => "section_header".to_string(),
            Self::Table => "table".to_string(),
            Self::Text => "text".to_string(),
            Self::Title => "title".to_string(),
            Self::DocumentIndex => "document_index".to_string(),
            Self::Code => "code".to_string(),
            Self::CheckboxSelected => "checkbox_selected".to_string(),
            Self::CheckboxUnselected => "checkbox_unselected".to_string(),
            Self::Form => "form".to_string(),
            Self::KeyValueRegion => "key_value_region".to_string(),
        }
    }
}

pub fn extract_bytes(
    content: Vec<u8>,
    mime_type: String,
    config: ExtractionConfig,
) -> Result<ExtractionResult, String> {
    crate::__alef_tokio_runtime().block_on(async {
        kreuzberg::extract_bytes(&content, &mime_type, &config.0)
            .await
            .map_err(|e| e.to_string())
            .map(ExtractionResult)
    })
}

pub fn extract_file(
    path: String,
    mime_type: Option<String>,
    config: ExtractionConfig,
) -> Result<ExtractionResult, String> {
    crate::__alef_tokio_runtime().block_on(async {
        kreuzberg::extract_file(std::path::PathBuf::from(path), mime_type.as_deref(), &config.0)
            .await
            .map_err(|e| e.to_string())
            .map(ExtractionResult)
    })
}

pub fn extract_file_sync(
    path: String,
    mime_type: Option<String>,
    config: ExtractionConfig,
) -> Result<ExtractionResult, String> {
    kreuzberg::extract_file_sync(std::path::PathBuf::from(path), mime_type.as_deref(), &config.0)
        .map_err(|e| e.to_string())
        .map(ExtractionResult)
}

pub fn extract_bytes_sync(
    content: Vec<u8>,
    mime_type: String,
    config: ExtractionConfig,
) -> Result<ExtractionResult, String> {
    kreuzberg::extract_bytes_sync(&content, &mime_type, &config.0)
        .map_err(|e| e.to_string())
        .map(ExtractionResult)
}

pub fn batch_extract_files_sync(
    items: Vec<BatchFileItem>,
    config: ExtractionConfig,
) -> Result<Vec<ExtractionResult>, String> {
    kreuzberg::batch_extract_files_sync(items.into_iter().map(|w| w.0).collect::<Vec<_>>(), &config.0)
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(ExtractionResult).collect::<Vec<_>>())
}

pub fn batch_extract_bytes_sync(
    items: Vec<BatchBytesItem>,
    config: ExtractionConfig,
) -> Result<Vec<ExtractionResult>, String> {
    kreuzberg::batch_extract_bytes_sync(items.into_iter().map(|w| w.0).collect::<Vec<_>>(), &config.0)
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(ExtractionResult).collect::<Vec<_>>())
}

pub fn batch_extract_files(
    items: Vec<BatchFileItem>,
    config: ExtractionConfig,
) -> Result<Vec<ExtractionResult>, String> {
    crate::__alef_tokio_runtime().block_on(async {
        kreuzberg::batch_extract_files(items.into_iter().map(|w| w.0).collect::<Vec<_>>(), &config.0)
            .await
            .map_err(|e| e.to_string())
            .map(|v| v.into_iter().map(ExtractionResult).collect::<Vec<_>>())
    })
}

pub fn batch_extract_bytes(
    items: Vec<BatchBytesItem>,
    config: ExtractionConfig,
) -> Result<Vec<ExtractionResult>, String> {
    crate::__alef_tokio_runtime().block_on(async {
        kreuzberg::batch_extract_bytes(items.into_iter().map(|w| w.0).collect::<Vec<_>>(), &config.0)
            .await
            .map_err(|e| e.to_string())
            .map(|v| v.into_iter().map(ExtractionResult).collect::<Vec<_>>())
    })
}

pub fn detect_mime_type_from_bytes(content: Vec<u8>) -> Result<String, String> {
    kreuzberg::detect_mime_type_from_bytes(&content)
        .map_err(|e| e.to_string())
        .map(|s| s.to_string())
}

pub fn get_extensions_for_mime(mime_type: String) -> Result<Vec<String>, String> {
    kreuzberg::get_extensions_for_mime(&mime_type)
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_embedding_backends() -> Result<Vec<String>, String> {
    kreuzberg::list_embedding_backends()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_document_extractors() -> Result<Vec<String>, String> {
    kreuzberg::list_document_extractors()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_ocr_backends() -> Result<Vec<String>, String> {
    kreuzberg::list_ocr_backends()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_post_processors() -> Result<Vec<String>, String> {
    kreuzberg::list_post_processors()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_renderers() -> Result<Vec<String>, String> {
    kreuzberg::list_renderers()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn list_validators() -> Result<Vec<String>, String> {
    kreuzberg::list_validators()
        .map_err(|e| e.to_string())
        .map(|v| v.into_iter().map(|s| s.to_string()).collect::<Vec<_>>())
}

pub fn compare(a: ExtractionResult, b: ExtractionResult, opts: DiffOptions) -> ExtractionDiff {
    ExtractionDiff(kreuzberg::compare(&a.0, &b.0, &opts.0))
}

pub fn embed_texts_async(texts: Vec<String>, config: EmbeddingConfig) -> Result<String, String> {
    crate::__alef_tokio_runtime().block_on(async {
        kreuzberg::embed_texts_async(texts, &config.0)
            .await
            .map_err(|e| e.to_string())
            .map(|v| serde_json::to_string(&v).expect("serializable return"))
    })
}

pub fn render_pdf_page_to_png(
    pdf_bytes: Vec<u8>,
    page_index: usize,
    dpi: Option<i32>,
    password: Option<String>,
) -> Result<Vec<u8>, String> {
    kreuzberg::render_pdf_page_to_png(&pdf_bytes, page_index, dpi, password.as_deref()).map_err(|e| e.to_string())
}

pub fn detect_mime_type(path: String, check_exists: bool) -> Result<String, String> {
    kreuzberg::detect_mime_type(path, check_exists)
        .map_err(|e| e.to_string())
        .map(|s| s.to_string())
}

pub fn embed_texts(texts: Vec<String>, config: EmbeddingConfig) -> Result<String, String> {
    kreuzberg::embed_texts(texts, &config.0)
        .map_err(|e| e.to_string())
        .map(|v| serde_json::to_string(&v).expect("serializable return"))
}

pub fn get_embedding_preset(name: String) -> Option<EmbeddingPreset> {
    (kreuzberg::get_embedding_preset(&name)).map(EmbeddingPreset)
}

pub fn list_embedding_presets() -> Vec<String> {
    kreuzberg::list_embedding_presets()
        .into_iter()
        .map(|s| s.to_string())
        .collect::<Vec<_>>()
}

pub struct OcrBackendBox(pub Box<dyn kreuzberg::OcrBackend + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_ocr_backend() -> Vec<OcrBackendBox> {
    Vec::new()
}
pub fn ocr_backend_call_process_image(this: &OcrBackendBox, image_bytes: Vec<u8>, config: OcrConfig) -> String {
    crate::__alef_tokio_runtime().block_on(async {
        match this.0.process_image(&image_bytes, &config.0).await {
            Ok(v) => format!(
                "{{\"ok\": {}}}",
                serde_json::to_string(&v).expect("serializable return")
            ),
            Err(e) => format!(
                "{{\"err\": {}}}",
                serde_json::to_string(&e.to_string()).expect("serializable error")
            ),
        }
    })
}
pub fn ocr_backend_call_supports_language(this: &OcrBackendBox, lang: String) -> bool {
    this.0.supports_language(&lang)
}
pub fn ocr_backend_call_backend_type(this: &OcrBackendBox) -> OcrBackendType {
    OcrBackendType::from(this.0.backend_type())
}

pub struct PostProcessorBox(pub Box<dyn kreuzberg::PostProcessor + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_post_processor() -> Vec<PostProcessorBox> {
    Vec::new()
}
pub fn post_processor_call_process(
    this: &PostProcessorBox,
    mut result: ExtractionResult,
    config: ExtractionConfig,
) -> String {
    crate::__alef_tokio_runtime().block_on(async {
        match this.0.process(&mut result.0, &config.0).await {
            Ok(v) => format!("{{\"ok\": {}}}", "null"),
            Err(e) => format!(
                "{{\"err\": {}}}",
                serde_json::to_string(&e.to_string()).expect("serializable error")
            ),
        }
    })
}
pub fn post_processor_call_processing_stage(this: &PostProcessorBox) -> ProcessingStage {
    ProcessingStage::from(this.0.processing_stage())
}

pub struct ValidatorBox(pub Box<dyn kreuzberg::Validator + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_validator() -> Vec<ValidatorBox> {
    Vec::new()
}
pub fn validator_call_validate(this: &ValidatorBox, result: ExtractionResult, config: ExtractionConfig) -> String {
    crate::__alef_tokio_runtime().block_on(async {
        match this.0.validate(&result.0, &config.0).await {
            Ok(v) => format!("{{\"ok\": {}}}", "null"),
            Err(e) => format!(
                "{{\"err\": {}}}",
                serde_json::to_string(&e.to_string()).expect("serializable error")
            ),
        }
    })
}

pub struct EmbeddingBackendBox(pub Box<dyn kreuzberg::EmbeddingBackend + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_embedding_backend() -> Vec<EmbeddingBackendBox> {
    Vec::new()
}
pub fn embedding_backend_call_dimensions(this: &EmbeddingBackendBox) -> usize {
    this.0.dimensions()
}
pub fn embedding_backend_call_embed(this: &EmbeddingBackendBox, texts: Vec<String>) -> String {
    crate::__alef_tokio_runtime().block_on(async {
        match this.0.embed(texts).await {
            Ok(v) => format!(
                "{{\"ok\": {}}}",
                serde_json::to_string(&v).expect("serializable return")
            ),
            Err(e) => format!(
                "{{\"err\": {}}}",
                serde_json::to_string(&e.to_string()).expect("serializable error")
            ),
        }
    })
}

pub struct DocumentExtractorBox(pub Box<dyn kreuzberg::DocumentExtractor + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_document_extractor() -> Vec<DocumentExtractorBox> {
    Vec::new()
}
pub fn document_extractor_call_extract_bytes(
    this: &DocumentExtractorBox,
    content: Vec<u8>,
    mime_type: String,
    config: ExtractionConfig,
) -> String {
    crate::__alef_tokio_runtime().block_on(async {
        match this.0.extract_bytes(&content, &mime_type, &config.0).await {
            Ok(v) => format!(
                "{{\"ok\": {}}}",
                serde_json::to_string(&v).expect("serializable return")
            ),
            Err(e) => format!(
                "{{\"err\": {}}}",
                serde_json::to_string(&e.to_string()).expect("serializable error")
            ),
        }
    })
}
pub fn document_extractor_call_supported_mime_types(this: &DocumentExtractorBox) -> Vec<String> {
    this.0.supported_mime_types().iter().map(|s| s.to_string()).collect()
}

pub struct RendererBox(pub Box<dyn kreuzberg::Renderer + Send + Sync>);
#[doc(hidden)]
pub fn alef_phantom_vec_renderer() -> Vec<RendererBox> {
    Vec::new()
}
pub fn renderer_call_render(this: &RendererBox, doc: String) -> String {
    match this
        .0
        .render(&serde_json::from_str::<kreuzberg::InternalDocument>(&doc).expect("valid JSON for doc"))
    {
        Ok(v) => format!(
            "{{\"ok\": {}}}",
            serde_json::to_string(&v).expect("serializable return")
        ),
        Err(e) => format!(
            "{{\"err\": {}}}",
            serde_json::to_string(&e.to_string()).expect("serializable error")
        ),
    }
}

/// Convert a stringified Swift error into the configured source-crate error type.
#[allow(dead_code)]
fn plugin_error_from_string(message: String) -> kreuzberg::KreuzbergError {
    kreuzberg::KreuzbergError::Other(message)
}

/// JSON envelope returned by every fallible Swift trait method. Carries `Ok(T)`
/// as `{"ok": <serialised T>}` and `Err(String)` as `{"err": "<message>"}`.
/// Avoids swift-bridge 0.1.59's broken `Result<RustString, RustString>` codegen.
#[allow(dead_code)]
#[derive(::serde::Deserialize)]
#[serde(rename_all = "snake_case")]
enum InboundEnvelope<T> {
    Ok(T),
    Err(String),
}

/// Deserialise a JSON envelope returned from a Swift FFI shim into a typed Result.
#[allow(dead_code)]
fn decode_inbound_envelope<T>(json: &str) -> std::result::Result<T, kreuzberg::KreuzbergError>
where
    T: ::serde::de::DeserializeOwned,
{
    match ::serde_json::from_str::<InboundEnvelope<T>>(json) {
        Ok(InboundEnvelope::Ok(value)) => Ok(value),
        Ok(InboundEnvelope::Err(message)) => Err(plugin_error_from_string(message)),
        Err(e) => Err(plugin_error_from_string(format!(
            "swift returned malformed envelope: {e}"
        ))),
    }
}
/// Rust-side wrapper around a Swift class implementing the `OcrBackend` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftOcrBackendWrapper {
    inner: ffi::SwiftOcrBackendBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftOcrBackendWrapper {}
unsafe impl Sync for SwiftOcrBackendWrapper {}

impl SwiftOcrBackendWrapper {
    /// Construct a new wrapper from a Swift `SwiftOcrBackendBox` handle.
    pub fn new(inner: ffi::SwiftOcrBackendBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftOcrBackendWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
#[async_trait::async_trait]
impl kreuzberg::OcrBackend for SwiftOcrBackendWrapper {
    async fn process_image(
        &self,
        image_bytes: &[u8],
        config: &kreuzberg::OcrConfig,
    ) -> std::result::Result<kreuzberg::ExtractionResult, kreuzberg::KreuzbergError> {
        let image_bytes = image_bytes.to_vec();
        let config = ::serde_json::to_string(&config).expect("serializable param config");
        let envelope = self.inner.alef_process_image(image_bytes, config);
        decode_inbound_envelope::<kreuzberg::ExtractionResult>(&envelope)
    }

    fn supports_language(&self, lang: &str) -> bool {
        let lang = lang.to_string();
        self.inner.alef_supports_language(lang)
    }

    fn backend_type(&self) -> kreuzberg::OcrBackendType {
        let json = self.inner.alef_backend_type();
        ::serde_json::from_str::<kreuzberg::OcrBackendType>(&json)
            .expect("swift ocr_backend.backend_type returned invalid JSON")
    }
}

/// Register a Swift class implementation as a `OcrBackend` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_ocr_backend(swift_box: ffi::SwiftOcrBackendBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::OcrBackend> =
        ::std::sync::Arc::new(SwiftOcrBackendWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_ocr_backend_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `OcrBackend` plugin by name.
pub fn unregister_ocr_backend(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_ocr_backend_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `OcrBackend` plugins.
pub fn clear_ocr_backends() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_ocr_backend_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

/// Rust-side wrapper around a Swift class implementing the `PostProcessor` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftPostProcessorWrapper {
    inner: ffi::SwiftPostProcessorBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftPostProcessorWrapper {}
unsafe impl Sync for SwiftPostProcessorWrapper {}

impl SwiftPostProcessorWrapper {
    /// Construct a new wrapper from a Swift `SwiftPostProcessorBox` handle.
    pub fn new(inner: ffi::SwiftPostProcessorBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftPostProcessorWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
#[async_trait::async_trait]
impl kreuzberg::PostProcessor for SwiftPostProcessorWrapper {
    async fn process(
        &self,
        result: &mut kreuzberg::ExtractionResult,
        config: &kreuzberg::ExtractionConfig,
    ) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        let result = ::serde_json::to_string(&result).expect("serializable param result");
        let config = ::serde_json::to_string(&config).expect("serializable param config");
        let envelope = self.inner.alef_process(result, config);
        decode_inbound_envelope::<()>(&envelope).map(|_| ())
    }

    fn processing_stage(&self) -> kreuzberg::ProcessingStage {
        let json = self.inner.alef_processing_stage();
        ::serde_json::from_str::<kreuzberg::ProcessingStage>(&json)
            .expect("swift post_processor.processing_stage returned invalid JSON")
    }
}

/// Register a Swift class implementation as a `PostProcessor` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_post_processor(swift_box: ffi::SwiftPostProcessorBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::PostProcessor> =
        ::std::sync::Arc::new(SwiftPostProcessorWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_post_processor_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `PostProcessor` plugin by name.
pub fn unregister_post_processor(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_post_processor_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `PostProcessor` plugins.
pub fn clear_post_processors() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_post_processor_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

/// Rust-side wrapper around a Swift class implementing the `Validator` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftValidatorWrapper {
    inner: ffi::SwiftValidatorBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftValidatorWrapper {}
unsafe impl Sync for SwiftValidatorWrapper {}

impl SwiftValidatorWrapper {
    /// Construct a new wrapper from a Swift `SwiftValidatorBox` handle.
    pub fn new(inner: ffi::SwiftValidatorBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftValidatorWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
#[async_trait::async_trait]
impl kreuzberg::Validator for SwiftValidatorWrapper {
    async fn validate(
        &self,
        result: &kreuzberg::ExtractionResult,
        config: &kreuzberg::ExtractionConfig,
    ) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        let result = ::serde_json::to_string(&result).expect("serializable param result");
        let config = ::serde_json::to_string(&config).expect("serializable param config");
        let envelope = self.inner.alef_validate(result, config);
        decode_inbound_envelope::<()>(&envelope).map(|_| ())
    }
}

/// Register a Swift class implementation as a `Validator` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_validator(swift_box: ffi::SwiftValidatorBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::Validator> = ::std::sync::Arc::new(SwiftValidatorWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_validator_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `Validator` plugin by name.
pub fn unregister_validator(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_validator_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `Validator` plugins.
pub fn clear_validators() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_validator_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

/// Rust-side wrapper around a Swift class implementing the `EmbeddingBackend` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftEmbeddingBackendWrapper {
    inner: ffi::SwiftEmbeddingBackendBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftEmbeddingBackendWrapper {}
unsafe impl Sync for SwiftEmbeddingBackendWrapper {}

impl SwiftEmbeddingBackendWrapper {
    /// Construct a new wrapper from a Swift `SwiftEmbeddingBackendBox` handle.
    pub fn new(inner: ffi::SwiftEmbeddingBackendBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftEmbeddingBackendWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
#[async_trait::async_trait]
impl kreuzberg::EmbeddingBackend for SwiftEmbeddingBackendWrapper {
    fn dimensions(&self) -> usize {
        self.inner.alef_dimensions()
    }

    async fn embed(&self, texts: Vec<String>) -> std::result::Result<Vec<Vec<f32>>, kreuzberg::KreuzbergError> {
        let envelope = self.inner.alef_embed(texts);
        decode_inbound_envelope::<Vec<Vec<f32>>>(&envelope)
    }
}

/// Register a Swift class implementation as a `EmbeddingBackend` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_embedding_backend(swift_box: ffi::SwiftEmbeddingBackendBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::EmbeddingBackend> =
        ::std::sync::Arc::new(SwiftEmbeddingBackendWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_embedding_backend_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `EmbeddingBackend` plugin by name.
pub fn unregister_embedding_backend(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_embedding_backend_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `EmbeddingBackend` plugins.
pub fn clear_embedding_backends() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_embedding_backend_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

/// Rust-side wrapper around a Swift class implementing the `DocumentExtractor` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftDocumentExtractorWrapper {
    inner: ffi::SwiftDocumentExtractorBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftDocumentExtractorWrapper {}
unsafe impl Sync for SwiftDocumentExtractorWrapper {}

impl SwiftDocumentExtractorWrapper {
    /// Construct a new wrapper from a Swift `SwiftDocumentExtractorBox` handle.
    pub fn new(inner: ffi::SwiftDocumentExtractorBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftDocumentExtractorWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
#[async_trait::async_trait]
impl kreuzberg::DocumentExtractor for SwiftDocumentExtractorWrapper {
    async fn extract_bytes(
        &self,
        content: &[u8],
        mime_type: &str,
        config: &kreuzberg::ExtractionConfig,
    ) -> std::result::Result<kreuzberg::InternalDocument, kreuzberg::KreuzbergError> {
        let content = content.to_vec();
        let mime_type = mime_type.to_string();
        let config = ::serde_json::to_string(&config).expect("serializable param config");
        let envelope = self.inner.alef_extract_bytes(content, mime_type, config);
        decode_inbound_envelope::<kreuzberg::InternalDocument>(&envelope)
    }

    fn supported_mime_types(&self) -> &'static [&'static str] {
        let __types: Vec<String> = self.inner.alef_supported_mime_types();
        let __strs: Vec<&'static str> = __types
            .into_iter()
            .map(|s| -> &'static str { Box::leak(s.into_boxed_str()) })
            .collect();
        Box::leak(__strs.into_boxed_slice())
    }
}

/// Register a Swift class implementation as a `DocumentExtractor` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_document_extractor(swift_box: ffi::SwiftDocumentExtractorBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::DocumentExtractor> =
        ::std::sync::Arc::new(SwiftDocumentExtractorWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_document_extractor_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `DocumentExtractor` plugin by name.
pub fn unregister_document_extractor(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_document_extractor_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `DocumentExtractor` plugins.
pub fn clear_document_extractors() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_document_extractor_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

/// Rust-side wrapper around a Swift class implementing the `Renderer` plugin protocol.
///
/// The Swift instance is held via a `swift-bridge` opaque handle that retains
/// the underlying ARC reference for the lifetime of this struct. Send + Sync are
/// asserted unsafely: Swift classes used as generated plugins must be thread-safe
/// (the `Plugin` super-trait requires it), and ARC handles themselves are safe to share.
pub struct SwiftRendererWrapper {
    inner: ffi::SwiftRendererBox,
    /// Cached `Plugin::name()` — required because the trait returns `&str` but
    /// the Swift FFI shim returns an owned `String`. Populated lazily on first access.
    name_cache: ::std::sync::OnceLock<String>,
}
unsafe impl Send for SwiftRendererWrapper {}
unsafe impl Sync for SwiftRendererWrapper {}

impl SwiftRendererWrapper {
    /// Construct a new wrapper from a Swift `SwiftRendererBox` handle.
    pub fn new(inner: ffi::SwiftRendererBox) -> Self {
        Self {
            inner,
            name_cache: ::std::sync::OnceLock::new(),
        }
    }
}
impl kreuzberg::plugins::Plugin for SwiftRendererWrapper {
    fn name(&self) -> &str {
        self.name_cache.get_or_init(|| self.inner.alef_name()).as_str()
    }

    fn version(&self) -> String {
        self.inner.alef_version()
    }

    fn initialize(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_initialize()).map(|_| ())
    }

    fn shutdown(&self) -> std::result::Result<(), kreuzberg::KreuzbergError> {
        decode_inbound_envelope::<()>(&self.inner.alef_shutdown()).map(|_| ())
    }
}
impl kreuzberg::Renderer for SwiftRendererWrapper {
    fn render(&self, doc: &kreuzberg::InternalDocument) -> std::result::Result<String, kreuzberg::KreuzbergError> {
        let doc = ::serde_json::to_string(&doc).expect("serializable param doc");
        let envelope = self.inner.alef_render(doc);
        decode_inbound_envelope::<String>(&envelope)
    }
}

/// Register a Swift class implementation as a `Renderer` plugin.
///
/// Wraps the Swift handle in `Arc<SwiftXxxWrapper>` and inserts it into the host registry.
/// Errors from the registry are stringified for swift-bridge transport.
pub fn register_renderer(swift_box: ffi::SwiftRendererBox) -> Result<(), String> {
    let arc: ::std::sync::Arc<dyn kreuzberg::Renderer> = ::std::sync::Arc::new(SwiftRendererWrapper::new(swift_box));
    let registry = kreuzberg::plugins::registry::get_renderer_registry();
    let mut guard = registry.write();
    guard.register(arc).map_err(|e| e.to_string())
}
/// Unregister a previously-registered `Renderer` plugin by name.
pub fn unregister_renderer(name: String) -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_renderer_registry();
    let mut guard = registry.write();
    guard.remove(&name).map_err(|e| e.to_string())
}

/// Clear all registered `Renderer` plugins.
pub fn clear_renderers() -> Result<(), String> {
    let registry = kreuzberg::plugins::registry::get_renderer_registry();
    let mut guard = registry.write();
    guard.clear().map_err(|e| e.to_string())
}

pub fn extraction_config_from_json(json: String) -> Result<ExtractionConfig, String> {
    serde_json::from_str::<kreuzberg::ExtractionConfig>(&json)
        .map(ExtractionConfig)
        .map_err(|e| e.to_string())
}
pub fn batch_bytes_item_from_json(json: String) -> Result<BatchBytesItem, String> {
    serde_json::from_str::<kreuzberg::BatchBytesItem>(&json)
        .map(BatchBytesItem)
        .map_err(|e| e.to_string())
}
pub fn batch_file_item_from_json(json: String) -> Result<BatchFileItem, String> {
    serde_json::from_str::<kreuzberg::BatchFileItem>(&json)
        .map(BatchFileItem)
        .map_err(|e| e.to_string())
}
pub fn ocr_config_from_json(json: String) -> Result<OcrConfig, String> {
    serde_json::from_str::<kreuzberg::OcrConfig>(&json)
        .map(OcrConfig)
        .map_err(|e| e.to_string())
}
pub fn embedding_config_from_json(json: String) -> Result<EmbeddingConfig, String> {
    serde_json::from_str::<kreuzberg::EmbeddingConfig>(&json)
        .map(EmbeddingConfig)
        .map_err(|e| e.to_string())
}
pub fn extraction_result_from_json(json: String) -> Result<ExtractionResult, String> {
    serde_json::from_str::<kreuzberg::ExtractionResult>(&json)
        .map(ExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn ocr_extraction_result_from_json(json: String) -> Result<OcrExtractionResult, String> {
    serde_json::from_str::<kreuzberg::OcrExtractionResult>(&json)
        .map(OcrExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn diff_options_from_json(json: String) -> Result<DiffOptions, String> {
    serde_json::from_str::<kreuzberg::DiffOptions>(&json)
        .map(DiffOptions)
        .map_err(|e| e.to_string())
}
pub fn cache_stats_from_json(json: String) -> Result<CacheStats, String> {
    serde_json::from_str::<kreuzberg::CacheStats>(&json)
        .map(CacheStats)
        .map_err(|e| e.to_string())
}
pub fn acceleration_config_from_json(json: String) -> Result<AccelerationConfig, String> {
    serde_json::from_str::<kreuzberg::AccelerationConfig>(&json)
        .map(AccelerationConfig)
        .map_err(|e| e.to_string())
}
pub fn content_filter_config_from_json(json: String) -> Result<ContentFilterConfig, String> {
    serde_json::from_str::<kreuzberg::ContentFilterConfig>(&json)
        .map(ContentFilterConfig)
        .map_err(|e| e.to_string())
}
pub fn email_config_from_json(json: String) -> Result<EmailConfig, String> {
    serde_json::from_str::<kreuzberg::EmailConfig>(&json)
        .map(EmailConfig)
        .map_err(|e| e.to_string())
}
pub fn file_extraction_config_from_json(json: String) -> Result<FileExtractionConfig, String> {
    serde_json::from_str::<kreuzberg::FileExtractionConfig>(&json)
        .map(FileExtractionConfig)
        .map_err(|e| e.to_string())
}
pub fn image_extraction_config_from_json(json: String) -> Result<ImageExtractionConfig, String> {
    serde_json::from_str::<kreuzberg::ImageExtractionConfig>(&json)
        .map(ImageExtractionConfig)
        .map_err(|e| e.to_string())
}
pub fn token_reduction_options_from_json(json: String) -> Result<TokenReductionOptions, String> {
    serde_json::from_str::<kreuzberg::TokenReductionOptions>(&json)
        .map(TokenReductionOptions)
        .map_err(|e| e.to_string())
}
pub fn language_detection_config_from_json(json: String) -> Result<LanguageDetectionConfig, String> {
    serde_json::from_str::<kreuzberg::LanguageDetectionConfig>(&json)
        .map(LanguageDetectionConfig)
        .map_err(|e| e.to_string())
}
pub fn html_output_config_from_json(json: String) -> Result<HtmlOutputConfig, String> {
    serde_json::from_str::<kreuzberg::HtmlOutputConfig>(&json)
        .map(HtmlOutputConfig)
        .map_err(|e| e.to_string())
}
pub fn layout_detection_config_from_json(json: String) -> Result<LayoutDetectionConfig, String> {
    serde_json::from_str::<kreuzberg::LayoutDetectionConfig>(&json)
        .map(LayoutDetectionConfig)
        .map_err(|e| e.to_string())
}
pub fn llm_config_from_json(json: String) -> Result<LlmConfig, String> {
    serde_json::from_str::<kreuzberg::LlmConfig>(&json)
        .map(LlmConfig)
        .map_err(|e| e.to_string())
}
pub fn structured_extraction_config_from_json(json: String) -> Result<StructuredExtractionConfig, String> {
    serde_json::from_str::<kreuzberg::StructuredExtractionConfig>(&json)
        .map(StructuredExtractionConfig)
        .map_err(|e| e.to_string())
}
pub fn ocr_quality_thresholds_from_json(json: String) -> Result<OcrQualityThresholds, String> {
    serde_json::from_str::<kreuzberg::OcrQualityThresholds>(&json)
        .map(OcrQualityThresholds)
        .map_err(|e| e.to_string())
}
pub fn ocr_pipeline_stage_from_json(json: String) -> Result<OcrPipelineStage, String> {
    serde_json::from_str::<kreuzberg::OcrPipelineStage>(&json)
        .map(OcrPipelineStage)
        .map_err(|e| e.to_string())
}
pub fn ocr_pipeline_config_from_json(json: String) -> Result<OcrPipelineConfig, String> {
    serde_json::from_str::<kreuzberg::OcrPipelineConfig>(&json)
        .map(OcrPipelineConfig)
        .map_err(|e| e.to_string())
}
pub fn page_config_from_json(json: String) -> Result<PageConfig, String> {
    serde_json::from_str::<kreuzberg::PageConfig>(&json)
        .map(PageConfig)
        .map_err(|e| e.to_string())
}
pub fn pdf_config_from_json(json: String) -> Result<PdfConfig, String> {
    serde_json::from_str::<kreuzberg::PdfConfig>(&json)
        .map(PdfConfig)
        .map_err(|e| e.to_string())
}
pub fn hierarchy_config_from_json(json: String) -> Result<HierarchyConfig, String> {
    serde_json::from_str::<kreuzberg::HierarchyConfig>(&json)
        .map(HierarchyConfig)
        .map_err(|e| e.to_string())
}
pub fn post_processor_config_from_json(json: String) -> Result<PostProcessorConfig, String> {
    serde_json::from_str::<kreuzberg::PostProcessorConfig>(&json)
        .map(PostProcessorConfig)
        .map_err(|e| e.to_string())
}
pub fn chunking_config_from_json(json: String) -> Result<ChunkingConfig, String> {
    serde_json::from_str::<kreuzberg::ChunkingConfig>(&json)
        .map(ChunkingConfig)
        .map_err(|e| e.to_string())
}
pub fn tree_sitter_config_from_json(json: String) -> Result<TreeSitterConfig, String> {
    serde_json::from_str::<kreuzberg::TreeSitterConfig>(&json)
        .map(TreeSitterConfig)
        .map_err(|e| e.to_string())
}
pub fn tree_sitter_process_config_from_json(json: String) -> Result<TreeSitterProcessConfig, String> {
    serde_json::from_str::<kreuzberg::TreeSitterProcessConfig>(&json)
        .map(TreeSitterProcessConfig)
        .map_err(|e| e.to_string())
}
pub fn supported_format_from_json(json: String) -> Result<SupportedFormat, String> {
    serde_json::from_str::<kreuzberg::SupportedFormat>(&json)
        .map(SupportedFormat)
        .map_err(|e| e.to_string())
}
pub fn server_config_from_json(json: String) -> Result<ServerConfig, String> {
    serde_json::from_str::<kreuzberg::ServerConfig>(&json)
        .map(ServerConfig)
        .map_err(|e| e.to_string())
}
pub fn structured_data_result_from_json(json: String) -> Result<StructuredDataResult, String> {
    serde_json::from_str::<kreuzberg::extraction::structured::StructuredDataResult>(&json)
        .map(StructuredDataResult)
        .map_err(|e| e.to_string())
}
pub fn docx_app_properties_from_json(json: String) -> Result<DocxAppProperties, String> {
    serde_json::from_str::<kreuzberg::DocxAppProperties>(&json)
        .map(DocxAppProperties)
        .map_err(|e| e.to_string())
}
pub fn xlsx_app_properties_from_json(json: String) -> Result<XlsxAppProperties, String> {
    serde_json::from_str::<kreuzberg::extraction::office_metadata::app_properties::XlsxAppProperties>(&json)
        .map(XlsxAppProperties)
        .map_err(|e| e.to_string())
}
pub fn pptx_app_properties_from_json(json: String) -> Result<PptxAppProperties, String> {
    serde_json::from_str::<kreuzberg::extraction::office_metadata::app_properties::PptxAppProperties>(&json)
        .map(PptxAppProperties)
        .map_err(|e| e.to_string())
}
pub fn core_properties_from_json(json: String) -> Result<CoreProperties, String> {
    serde_json::from_str::<kreuzberg::CoreProperties>(&json)
        .map(CoreProperties)
        .map_err(|e| e.to_string())
}
pub fn security_limits_from_json(json: String) -> Result<SecurityLimits, String> {
    serde_json::from_str::<kreuzberg::SecurityLimits>(&json)
        .map(SecurityLimits)
        .map_err(|e| e.to_string())
}
pub fn token_reduction_config_from_json(json: String) -> Result<TokenReductionConfig, String> {
    serde_json::from_str::<kreuzberg::TokenReductionConfig>(&json)
        .map(TokenReductionConfig)
        .map_err(|e| e.to_string())
}
pub fn pdf_annotation_from_json(json: String) -> Result<PdfAnnotation, String> {
    serde_json::from_str::<kreuzberg::PdfAnnotation>(&json)
        .map(PdfAnnotation)
        .map_err(|e| e.to_string())
}
pub fn djot_content_from_json(json: String) -> Result<DjotContent, String> {
    serde_json::from_str::<kreuzberg::DjotContent>(&json)
        .map(DjotContent)
        .map_err(|e| e.to_string())
}
pub fn formatted_block_from_json(json: String) -> Result<FormattedBlock, String> {
    serde_json::from_str::<kreuzberg::FormattedBlock>(&json)
        .map(FormattedBlock)
        .map_err(|e| e.to_string())
}
pub fn inline_element_from_json(json: String) -> Result<InlineElement, String> {
    serde_json::from_str::<kreuzberg::InlineElement>(&json)
        .map(InlineElement)
        .map_err(|e| e.to_string())
}
pub fn djot_image_from_json(json: String) -> Result<DjotImage, String> {
    serde_json::from_str::<kreuzberg::DjotImage>(&json)
        .map(DjotImage)
        .map_err(|e| e.to_string())
}
pub fn djot_link_from_json(json: String) -> Result<DjotLink, String> {
    serde_json::from_str::<kreuzberg::DjotLink>(&json)
        .map(DjotLink)
        .map_err(|e| e.to_string())
}
pub fn footnote_from_json(json: String) -> Result<Footnote, String> {
    serde_json::from_str::<kreuzberg::Footnote>(&json)
        .map(Footnote)
        .map_err(|e| e.to_string())
}
pub fn document_structure_from_json(json: String) -> Result<DocumentStructure, String> {
    serde_json::from_str::<kreuzberg::DocumentStructure>(&json)
        .map(DocumentStructure)
        .map_err(|e| e.to_string())
}
pub fn document_relationship_from_json(json: String) -> Result<DocumentRelationship, String> {
    serde_json::from_str::<kreuzberg::DocumentRelationship>(&json)
        .map(DocumentRelationship)
        .map_err(|e| e.to_string())
}
pub fn document_node_from_json(json: String) -> Result<DocumentNode, String> {
    serde_json::from_str::<kreuzberg::DocumentNode>(&json)
        .map(DocumentNode)
        .map_err(|e| e.to_string())
}
pub fn table_grid_from_json(json: String) -> Result<TableGrid, String> {
    serde_json::from_str::<kreuzberg::TableGrid>(&json)
        .map(TableGrid)
        .map_err(|e| e.to_string())
}
pub fn grid_cell_from_json(json: String) -> Result<GridCell, String> {
    serde_json::from_str::<kreuzberg::GridCell>(&json)
        .map(GridCell)
        .map_err(|e| e.to_string())
}
pub fn text_annotation_from_json(json: String) -> Result<TextAnnotation, String> {
    serde_json::from_str::<kreuzberg::TextAnnotation>(&json)
        .map(TextAnnotation)
        .map_err(|e| e.to_string())
}
pub fn archive_entry_from_json(json: String) -> Result<ArchiveEntry, String> {
    serde_json::from_str::<kreuzberg::ArchiveEntry>(&json)
        .map(ArchiveEntry)
        .map_err(|e| e.to_string())
}
pub fn processing_warning_from_json(json: String) -> Result<ProcessingWarning, String> {
    serde_json::from_str::<kreuzberg::ProcessingWarning>(&json)
        .map(ProcessingWarning)
        .map_err(|e| e.to_string())
}
pub fn llm_usage_from_json(json: String) -> Result<LlmUsage, String> {
    serde_json::from_str::<kreuzberg::LlmUsage>(&json)
        .map(LlmUsage)
        .map_err(|e| e.to_string())
}
pub fn chunk_from_json(json: String) -> Result<Chunk, String> {
    serde_json::from_str::<kreuzberg::Chunk>(&json)
        .map(Chunk)
        .map_err(|e| e.to_string())
}
pub fn heading_context_from_json(json: String) -> Result<HeadingContext, String> {
    serde_json::from_str::<kreuzberg::HeadingContext>(&json)
        .map(HeadingContext)
        .map_err(|e| e.to_string())
}
pub fn heading_level_from_json(json: String) -> Result<HeadingLevel, String> {
    serde_json::from_str::<kreuzberg::HeadingLevel>(&json)
        .map(HeadingLevel)
        .map_err(|e| e.to_string())
}
pub fn chunk_metadata_from_json(json: String) -> Result<ChunkMetadata, String> {
    serde_json::from_str::<kreuzberg::ChunkMetadata>(&json)
        .map(ChunkMetadata)
        .map_err(|e| e.to_string())
}
pub fn extracted_image_from_json(json: String) -> Result<ExtractedImage, String> {
    serde_json::from_str::<kreuzberg::ExtractedImage>(&json)
        .map(ExtractedImage)
        .map_err(|e| e.to_string())
}
pub fn bounding_box_from_json(json: String) -> Result<BoundingBox, String> {
    serde_json::from_str::<kreuzberg::BoundingBox>(&json)
        .map(BoundingBox)
        .map_err(|e| e.to_string())
}
pub fn element_metadata_from_json(json: String) -> Result<ElementMetadata, String> {
    serde_json::from_str::<kreuzberg::ElementMetadata>(&json)
        .map(ElementMetadata)
        .map_err(|e| e.to_string())
}
pub fn element_from_json(json: String) -> Result<Element, String> {
    serde_json::from_str::<kreuzberg::Element>(&json)
        .map(Element)
        .map_err(|e| e.to_string())
}
pub fn excel_workbook_from_json(json: String) -> Result<ExcelWorkbook, String> {
    serde_json::from_str::<kreuzberg::ExcelWorkbook>(&json)
        .map(ExcelWorkbook)
        .map_err(|e| e.to_string())
}
pub fn excel_sheet_from_json(json: String) -> Result<ExcelSheet, String> {
    serde_json::from_str::<kreuzberg::ExcelSheet>(&json)
        .map(ExcelSheet)
        .map_err(|e| e.to_string())
}
pub fn xml_extraction_result_from_json(json: String) -> Result<XmlExtractionResult, String> {
    serde_json::from_str::<kreuzberg::XmlExtractionResult>(&json)
        .map(XmlExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn text_extraction_result_from_json(json: String) -> Result<TextExtractionResult, String> {
    serde_json::from_str::<kreuzberg::TextExtractionResult>(&json)
        .map(TextExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn pptx_extraction_result_from_json(json: String) -> Result<PptxExtractionResult, String> {
    serde_json::from_str::<kreuzberg::PptxExtractionResult>(&json)
        .map(PptxExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn email_extraction_result_from_json(json: String) -> Result<EmailExtractionResult, String> {
    serde_json::from_str::<kreuzberg::EmailExtractionResult>(&json)
        .map(EmailExtractionResult)
        .map_err(|e| e.to_string())
}
pub fn email_attachment_from_json(json: String) -> Result<EmailAttachment, String> {
    serde_json::from_str::<kreuzberg::EmailAttachment>(&json)
        .map(EmailAttachment)
        .map_err(|e| e.to_string())
}
pub fn ocr_table_from_json(json: String) -> Result<OcrTable, String> {
    serde_json::from_str::<kreuzberg::OcrTable>(&json)
        .map(OcrTable)
        .map_err(|e| e.to_string())
}
pub fn ocr_table_bounding_box_from_json(json: String) -> Result<OcrTableBoundingBox, String> {
    serde_json::from_str::<kreuzberg::OcrTableBoundingBox>(&json)
        .map(OcrTableBoundingBox)
        .map_err(|e| e.to_string())
}
pub fn image_preprocessing_config_from_json(json: String) -> Result<ImagePreprocessingConfig, String> {
    serde_json::from_str::<kreuzberg::ImagePreprocessingConfig>(&json)
        .map(ImagePreprocessingConfig)
        .map_err(|e| e.to_string())
}
pub fn tesseract_config_from_json(json: String) -> Result<TesseractConfig, String> {
    serde_json::from_str::<kreuzberg::TesseractConfig>(&json)
        .map(TesseractConfig)
        .map_err(|e| e.to_string())
}
pub fn image_preprocessing_metadata_from_json(json: String) -> Result<ImagePreprocessingMetadata, String> {
    serde_json::from_str::<kreuzberg::ImagePreprocessingMetadata>(&json)
        .map(ImagePreprocessingMetadata)
        .map_err(|e| e.to_string())
}
pub fn metadata_from_json(json: String) -> Result<Metadata, String> {
    serde_json::from_str::<kreuzberg::Metadata>(&json)
        .map(Metadata)
        .map_err(|e| e.to_string())
}
pub fn excel_metadata_from_json(json: String) -> Result<ExcelMetadata, String> {
    serde_json::from_str::<kreuzberg::ExcelMetadata>(&json)
        .map(ExcelMetadata)
        .map_err(|e| e.to_string())
}
pub fn email_metadata_from_json(json: String) -> Result<EmailMetadata, String> {
    serde_json::from_str::<kreuzberg::EmailMetadata>(&json)
        .map(EmailMetadata)
        .map_err(|e| e.to_string())
}
pub fn archive_metadata_from_json(json: String) -> Result<ArchiveMetadata, String> {
    serde_json::from_str::<kreuzberg::ArchiveMetadata>(&json)
        .map(ArchiveMetadata)
        .map_err(|e| e.to_string())
}
pub fn image_metadata_from_json(json: String) -> Result<ImageMetadata, String> {
    serde_json::from_str::<kreuzberg::ImageMetadata>(&json)
        .map(ImageMetadata)
        .map_err(|e| e.to_string())
}
pub fn xml_metadata_from_json(json: String) -> Result<XmlMetadata, String> {
    serde_json::from_str::<kreuzberg::XmlMetadata>(&json)
        .map(XmlMetadata)
        .map_err(|e| e.to_string())
}
pub fn text_metadata_from_json(json: String) -> Result<TextMetadata, String> {
    serde_json::from_str::<kreuzberg::TextMetadata>(&json)
        .map(TextMetadata)
        .map_err(|e| e.to_string())
}
pub fn header_metadata_from_json(json: String) -> Result<HeaderMetadata, String> {
    serde_json::from_str::<kreuzberg::HeaderMetadata>(&json)
        .map(HeaderMetadata)
        .map_err(|e| e.to_string())
}
pub fn link_metadata_from_json(json: String) -> Result<LinkMetadata, String> {
    serde_json::from_str::<kreuzberg::LinkMetadata>(&json)
        .map(LinkMetadata)
        .map_err(|e| e.to_string())
}
pub fn image_metadata_type_from_json(json: String) -> Result<ImageMetadataType, String> {
    serde_json::from_str::<kreuzberg::ImageMetadataType>(&json)
        .map(ImageMetadataType)
        .map_err(|e| e.to_string())
}
pub fn structured_data_from_json(json: String) -> Result<StructuredData, String> {
    serde_json::from_str::<kreuzberg::StructuredData>(&json)
        .map(StructuredData)
        .map_err(|e| e.to_string())
}
pub fn html_metadata_from_json(json: String) -> Result<HtmlMetadata, String> {
    serde_json::from_str::<kreuzberg::HtmlMetadata>(&json)
        .map(HtmlMetadata)
        .map_err(|e| e.to_string())
}
pub fn ocr_metadata_from_json(json: String) -> Result<OcrMetadata, String> {
    serde_json::from_str::<kreuzberg::OcrMetadata>(&json)
        .map(OcrMetadata)
        .map_err(|e| e.to_string())
}
pub fn error_metadata_from_json(json: String) -> Result<ErrorMetadata, String> {
    serde_json::from_str::<kreuzberg::ErrorMetadata>(&json)
        .map(ErrorMetadata)
        .map_err(|e| e.to_string())
}
pub fn pptx_metadata_from_json(json: String) -> Result<PptxMetadata, String> {
    serde_json::from_str::<kreuzberg::PptxMetadata>(&json)
        .map(PptxMetadata)
        .map_err(|e| e.to_string())
}
pub fn docx_metadata_from_json(json: String) -> Result<DocxMetadata, String> {
    serde_json::from_str::<kreuzberg::DocxMetadata>(&json)
        .map(DocxMetadata)
        .map_err(|e| e.to_string())
}
pub fn csv_metadata_from_json(json: String) -> Result<CsvMetadata, String> {
    serde_json::from_str::<kreuzberg::CsvMetadata>(&json)
        .map(CsvMetadata)
        .map_err(|e| e.to_string())
}
pub fn bibtex_metadata_from_json(json: String) -> Result<BibtexMetadata, String> {
    serde_json::from_str::<kreuzberg::BibtexMetadata>(&json)
        .map(BibtexMetadata)
        .map_err(|e| e.to_string())
}
pub fn citation_metadata_from_json(json: String) -> Result<CitationMetadata, String> {
    serde_json::from_str::<kreuzberg::CitationMetadata>(&json)
        .map(CitationMetadata)
        .map_err(|e| e.to_string())
}
pub fn year_range_from_json(json: String) -> Result<YearRange, String> {
    serde_json::from_str::<kreuzberg::YearRange>(&json)
        .map(YearRange)
        .map_err(|e| e.to_string())
}
pub fn fiction_book_metadata_from_json(json: String) -> Result<FictionBookMetadata, String> {
    serde_json::from_str::<kreuzberg::FictionBookMetadata>(&json)
        .map(FictionBookMetadata)
        .map_err(|e| e.to_string())
}
pub fn dbf_metadata_from_json(json: String) -> Result<DbfMetadata, String> {
    serde_json::from_str::<kreuzberg::DbfMetadata>(&json)
        .map(DbfMetadata)
        .map_err(|e| e.to_string())
}
pub fn dbf_field_info_from_json(json: String) -> Result<DbfFieldInfo, String> {
    serde_json::from_str::<kreuzberg::DbfFieldInfo>(&json)
        .map(DbfFieldInfo)
        .map_err(|e| e.to_string())
}
pub fn jats_metadata_from_json(json: String) -> Result<JatsMetadata, String> {
    serde_json::from_str::<kreuzberg::JatsMetadata>(&json)
        .map(JatsMetadata)
        .map_err(|e| e.to_string())
}
pub fn contributor_role_from_json(json: String) -> Result<ContributorRole, String> {
    serde_json::from_str::<kreuzberg::ContributorRole>(&json)
        .map(ContributorRole)
        .map_err(|e| e.to_string())
}
pub fn epub_metadata_from_json(json: String) -> Result<EpubMetadata, String> {
    serde_json::from_str::<kreuzberg::EpubMetadata>(&json)
        .map(EpubMetadata)
        .map_err(|e| e.to_string())
}
pub fn pst_metadata_from_json(json: String) -> Result<PstMetadata, String> {
    serde_json::from_str::<kreuzberg::PstMetadata>(&json)
        .map(PstMetadata)
        .map_err(|e| e.to_string())
}
pub fn ocr_confidence_from_json(json: String) -> Result<OcrConfidence, String> {
    serde_json::from_str::<kreuzberg::OcrConfidence>(&json)
        .map(OcrConfidence)
        .map_err(|e| e.to_string())
}
pub fn ocr_rotation_from_json(json: String) -> Result<OcrRotation, String> {
    serde_json::from_str::<kreuzberg::OcrRotation>(&json)
        .map(OcrRotation)
        .map_err(|e| e.to_string())
}
pub fn ocr_element_from_json(json: String) -> Result<OcrElement, String> {
    serde_json::from_str::<kreuzberg::OcrElement>(&json)
        .map(OcrElement)
        .map_err(|e| e.to_string())
}
pub fn ocr_element_config_from_json(json: String) -> Result<OcrElementConfig, String> {
    serde_json::from_str::<kreuzberg::OcrElementConfig>(&json)
        .map(OcrElementConfig)
        .map_err(|e| e.to_string())
}
pub fn page_structure_from_json(json: String) -> Result<PageStructure, String> {
    serde_json::from_str::<kreuzberg::PageStructure>(&json)
        .map(PageStructure)
        .map_err(|e| e.to_string())
}
pub fn page_boundary_from_json(json: String) -> Result<PageBoundary, String> {
    serde_json::from_str::<kreuzberg::PageBoundary>(&json)
        .map(PageBoundary)
        .map_err(|e| e.to_string())
}
pub fn page_info_from_json(json: String) -> Result<PageInfo, String> {
    serde_json::from_str::<kreuzberg::PageInfo>(&json)
        .map(PageInfo)
        .map_err(|e| e.to_string())
}
pub fn page_content_from_json(json: String) -> Result<PageContent, String> {
    serde_json::from_str::<kreuzberg::PageContent>(&json)
        .map(PageContent)
        .map_err(|e| e.to_string())
}
pub fn layout_region_from_json(json: String) -> Result<LayoutRegion, String> {
    serde_json::from_str::<kreuzberg::LayoutRegion>(&json)
        .map(LayoutRegion)
        .map_err(|e| e.to_string())
}
pub fn page_hierarchy_from_json(json: String) -> Result<PageHierarchy, String> {
    serde_json::from_str::<kreuzberg::PageHierarchy>(&json)
        .map(PageHierarchy)
        .map_err(|e| e.to_string())
}
pub fn hierarchical_block_from_json(json: String) -> Result<HierarchicalBlock, String> {
    serde_json::from_str::<kreuzberg::HierarchicalBlock>(&json)
        .map(HierarchicalBlock)
        .map_err(|e| e.to_string())
}
pub fn cell_change_from_json(json: String) -> Result<CellChange, String> {
    serde_json::from_str::<kreuzberg::CellChange>(&json)
        .map(CellChange)
        .map_err(|e| e.to_string())
}
pub fn document_revision_from_json(json: String) -> Result<DocumentRevision, String> {
    serde_json::from_str::<kreuzberg::DocumentRevision>(&json)
        .map(DocumentRevision)
        .map_err(|e| e.to_string())
}
pub fn revision_delta_from_json(json: String) -> Result<RevisionDelta, String> {
    serde_json::from_str::<kreuzberg::RevisionDelta>(&json)
        .map(RevisionDelta)
        .map_err(|e| e.to_string())
}
pub fn table_from_json(json: String) -> Result<Table, String> {
    serde_json::from_str::<kreuzberg::Table>(&json)
        .map(Table)
        .map_err(|e| e.to_string())
}
pub fn table_cell_from_json(json: String) -> Result<TableCell, String> {
    serde_json::from_str::<kreuzberg::TableCell>(&json)
        .map(TableCell)
        .map_err(|e| e.to_string())
}
pub fn extracted_uri_from_json(json: String) -> Result<ExtractedUri, String> {
    serde_json::from_str::<kreuzberg::ExtractedUri>(&json)
        .map(ExtractedUri)
        .map_err(|e| e.to_string())
}
pub fn detect_response_from_json(json: String) -> Result<DetectResponse, String> {
    serde_json::from_str::<kreuzberg::api::DetectResponse>(&json)
        .map(DetectResponse)
        .map_err(|e| e.to_string())
}
pub fn extraction_diff_from_json(json: String) -> Result<ExtractionDiff, String> {
    serde_json::from_str::<kreuzberg::ExtractionDiff>(&json)
        .map(ExtractionDiff)
        .map_err(|e| e.to_string())
}
pub fn diff_hunk_from_json(json: String) -> Result<DiffHunk, String> {
    serde_json::from_str::<kreuzberg::DiffHunk>(&json)
        .map(DiffHunk)
        .map_err(|e| e.to_string())
}
pub fn table_diff_from_json(json: String) -> Result<TableDiff, String> {
    serde_json::from_str::<kreuzberg::TableDiff>(&json)
        .map(TableDiff)
        .map_err(|e| e.to_string())
}
pub fn embedded_changes_from_json(json: String) -> Result<EmbeddedChanges, String> {
    serde_json::from_str::<kreuzberg::EmbeddedChanges>(&json)
        .map(EmbeddedChanges)
        .map_err(|e| e.to_string())
}
pub fn embedded_diff_from_json(json: String) -> Result<EmbeddedDiff, String> {
    serde_json::from_str::<kreuzberg::EmbeddedDiff>(&json)
        .map(EmbeddedDiff)
        .map_err(|e| e.to_string())
}
pub fn embedding_preset_from_json(json: String) -> Result<EmbeddingPreset, String> {
    serde_json::from_str::<kreuzberg::EmbeddingPreset>(&json)
        .map(EmbeddingPreset)
        .map_err(|e| e.to_string())
}
pub fn yake_params_from_json(json: String) -> Result<YakeParams, String> {
    serde_json::from_str::<kreuzberg::YakeParams>(&json)
        .map(YakeParams)
        .map_err(|e| e.to_string())
}
pub fn rake_params_from_json(json: String) -> Result<RakeParams, String> {
    serde_json::from_str::<kreuzberg::RakeParams>(&json)
        .map(RakeParams)
        .map_err(|e| e.to_string())
}
pub fn keyword_config_from_json(json: String) -> Result<KeywordConfig, String> {
    serde_json::from_str::<kreuzberg::KeywordConfig>(&json)
        .map(KeywordConfig)
        .map_err(|e| e.to_string())
}
pub fn keyword_from_json(json: String) -> Result<Keyword, String> {
    serde_json::from_str::<kreuzberg::Keyword>(&json)
        .map(Keyword)
        .map_err(|e| e.to_string())
}
pub fn paddle_ocr_config_from_json(json: String) -> Result<PaddleOcrConfig, String> {
    serde_json::from_str::<kreuzberg::PaddleOcrConfig>(&json)
        .map(PaddleOcrConfig)
        .map_err(|e| e.to_string())
}
pub fn model_paths_from_json(json: String) -> Result<ModelPaths, String> {
    serde_json::from_str::<kreuzberg::ModelPaths>(&json)
        .map(ModelPaths)
        .map_err(|e| e.to_string())
}
pub fn orientation_result_from_json(json: String) -> Result<OrientationResult, String> {
    serde_json::from_str::<kreuzberg::OrientationResult>(&json)
        .map(OrientationResult)
        .map_err(|e| e.to_string())
}
pub fn b_box_from_json(json: String) -> Result<BBox, String> {
    serde_json::from_str::<kreuzberg::BBox>(&json)
        .map(BBox)
        .map_err(|e| e.to_string())
}
pub fn layout_detection_from_json(json: String) -> Result<LayoutDetection, String> {
    serde_json::from_str::<kreuzberg::LayoutDetection>(&json)
        .map(LayoutDetection)
        .map_err(|e| e.to_string())
}
pub fn recognized_table_from_json(json: String) -> Result<RecognizedTable, String> {
    serde_json::from_str::<kreuzberg::RecognizedTable>(&json)
        .map(RecognizedTable)
        .map_err(|e| e.to_string())
}
pub fn detection_result_from_json(json: String) -> Result<DetectionResult, String> {
    serde_json::from_str::<kreuzberg::DetectionResult>(&json)
        .map(DetectionResult)
        .map_err(|e| e.to_string())
}
pub fn embedded_file_from_json(json: String) -> Result<EmbeddedFile, String> {
    serde_json::from_str::<kreuzberg::pdf::embedded_files::EmbeddedFile>(&json)
        .map(EmbeddedFile)
        .map_err(|e| e.to_string())
}
pub fn pdf_metadata_from_json(json: String) -> Result<PdfMetadata, String> {
    serde_json::from_str::<kreuzberg::pdf::metadata::PdfMetadata>(&json)
        .map(PdfMetadata)
        .map_err(|e| e.to_string())
}
pub fn execution_provider_type_from_json(json: String) -> Result<ExecutionProviderType, String> {
    serde_json::from_str::<kreuzberg::ExecutionProviderType>(&json)
        .map(ExecutionProviderType::from)
        .map_err(|e| e.to_string())
}
pub fn output_format_from_json(json: String) -> Result<OutputFormat, String> {
    serde_json::from_str::<kreuzberg::OutputFormat>(&json)
        .map(OutputFormat::from)
        .map_err(|e| e.to_string())
}
pub fn html_theme_from_json(json: String) -> Result<HtmlTheme, String> {
    serde_json::from_str::<kreuzberg::HtmlTheme>(&json)
        .map(HtmlTheme::from)
        .map_err(|e| e.to_string())
}
pub fn table_model_from_json(json: String) -> Result<TableModel, String> {
    serde_json::from_str::<kreuzberg::TableModel>(&json)
        .map(TableModel::from)
        .map_err(|e| e.to_string())
}
pub fn chunker_type_from_json(json: String) -> Result<ChunkerType, String> {
    serde_json::from_str::<kreuzberg::ChunkerType>(&json)
        .map(ChunkerType::from)
        .map_err(|e| e.to_string())
}
pub fn chunk_sizing_from_json(json: String) -> Result<ChunkSizing, String> {
    serde_json::from_str::<kreuzberg::ChunkSizing>(&json)
        .map(ChunkSizing::from)
        .map_err(|e| e.to_string())
}
pub fn embedding_model_type_from_json(json: String) -> Result<EmbeddingModelType, String> {
    serde_json::from_str::<kreuzberg::EmbeddingModelType>(&json)
        .map(EmbeddingModelType::from)
        .map_err(|e| e.to_string())
}
pub fn code_content_mode_from_json(json: String) -> Result<CodeContentMode, String> {
    serde_json::from_str::<kreuzberg::CodeContentMode>(&json)
        .map(CodeContentMode::from)
        .map_err(|e| e.to_string())
}
pub fn ocr_backend_type_from_json(json: String) -> Result<OcrBackendType, String> {
    serde_json::from_str::<kreuzberg::OcrBackendType>(&json)
        .map(OcrBackendType::from)
        .map_err(|e| e.to_string())
}
pub fn processing_stage_from_json(json: String) -> Result<ProcessingStage, String> {
    serde_json::from_str::<kreuzberg::ProcessingStage>(&json)
        .map(ProcessingStage::from)
        .map_err(|e| e.to_string())
}
pub fn reduction_level_from_json(json: String) -> Result<ReductionLevel, String> {
    serde_json::from_str::<kreuzberg::ReductionLevel>(&json)
        .map(ReductionLevel::from)
        .map_err(|e| e.to_string())
}
pub fn pdf_annotation_type_from_json(json: String) -> Result<PdfAnnotationType, String> {
    serde_json::from_str::<kreuzberg::PdfAnnotationType>(&json)
        .map(PdfAnnotationType::from)
        .map_err(|e| e.to_string())
}
pub fn block_type_from_json(json: String) -> Result<BlockType, String> {
    serde_json::from_str::<kreuzberg::BlockType>(&json)
        .map(BlockType::from)
        .map_err(|e| e.to_string())
}
pub fn inline_type_from_json(json: String) -> Result<InlineType, String> {
    serde_json::from_str::<kreuzberg::InlineType>(&json)
        .map(InlineType::from)
        .map_err(|e| e.to_string())
}
pub fn relationship_kind_from_json(json: String) -> Result<RelationshipKind, String> {
    serde_json::from_str::<kreuzberg::RelationshipKind>(&json)
        .map(RelationshipKind::from)
        .map_err(|e| e.to_string())
}
pub fn content_layer_from_json(json: String) -> Result<ContentLayer, String> {
    serde_json::from_str::<kreuzberg::ContentLayer>(&json)
        .map(ContentLayer::from)
        .map_err(|e| e.to_string())
}
pub fn node_content_from_json(json: String) -> Result<NodeContent, String> {
    serde_json::from_str::<kreuzberg::NodeContent>(&json)
        .map(NodeContent::from)
        .map_err(|e| e.to_string())
}
pub fn annotation_kind_from_json(json: String) -> Result<AnnotationKind, String> {
    serde_json::from_str::<kreuzberg::AnnotationKind>(&json)
        .map(AnnotationKind::from)
        .map_err(|e| e.to_string())
}
pub fn extraction_method_from_json(json: String) -> Result<ExtractionMethod, String> {
    serde_json::from_str::<kreuzberg::ExtractionMethod>(&json)
        .map(ExtractionMethod::from)
        .map_err(|e| e.to_string())
}
pub fn chunk_type_from_json(json: String) -> Result<ChunkType, String> {
    serde_json::from_str::<kreuzberg::ChunkType>(&json)
        .map(ChunkType::from)
        .map_err(|e| e.to_string())
}
pub fn image_kind_from_json(json: String) -> Result<ImageKind, String> {
    serde_json::from_str::<kreuzberg::ImageKind>(&json)
        .map(ImageKind::from)
        .map_err(|e| e.to_string())
}
pub fn result_format_from_json(json: String) -> Result<ResultFormat, String> {
    serde_json::from_str::<kreuzberg::ResultFormat>(&json)
        .map(ResultFormat::from)
        .map_err(|e| e.to_string())
}
pub fn element_type_from_json(json: String) -> Result<ElementType, String> {
    serde_json::from_str::<kreuzberg::ElementType>(&json)
        .map(ElementType::from)
        .map_err(|e| e.to_string())
}
pub fn format_metadata_from_json(json: String) -> Result<FormatMetadata, String> {
    serde_json::from_str::<kreuzberg::FormatMetadata>(&json)
        .map(FormatMetadata::from)
        .map_err(|e| e.to_string())
}
pub fn text_direction_from_json(json: String) -> Result<TextDirection, String> {
    serde_json::from_str::<kreuzberg::TextDirection>(&json)
        .map(TextDirection::from)
        .map_err(|e| e.to_string())
}
pub fn link_type_from_json(json: String) -> Result<LinkType, String> {
    serde_json::from_str::<kreuzberg::LinkType>(&json)
        .map(LinkType::from)
        .map_err(|e| e.to_string())
}
pub fn image_type_from_json(json: String) -> Result<ImageType, String> {
    serde_json::from_str::<kreuzberg::ImageType>(&json)
        .map(ImageType::from)
        .map_err(|e| e.to_string())
}
pub fn structured_data_type_from_json(json: String) -> Result<StructuredDataType, String> {
    serde_json::from_str::<kreuzberg::StructuredDataType>(&json)
        .map(StructuredDataType::from)
        .map_err(|e| e.to_string())
}
pub fn ocr_bounding_geometry_from_json(json: String) -> Result<OcrBoundingGeometry, String> {
    serde_json::from_str::<kreuzberg::OcrBoundingGeometry>(&json)
        .map(OcrBoundingGeometry::from)
        .map_err(|e| e.to_string())
}
pub fn ocr_element_level_from_json(json: String) -> Result<OcrElementLevel, String> {
    serde_json::from_str::<kreuzberg::OcrElementLevel>(&json)
        .map(OcrElementLevel::from)
        .map_err(|e| e.to_string())
}
pub fn page_unit_type_from_json(json: String) -> Result<PageUnitType, String> {
    serde_json::from_str::<kreuzberg::PageUnitType>(&json)
        .map(PageUnitType::from)
        .map_err(|e| e.to_string())
}
pub fn diff_line_from_json(json: String) -> Result<DiffLine, String> {
    serde_json::from_str::<kreuzberg::DiffLine>(&json)
        .map(DiffLine::from)
        .map_err(|e| e.to_string())
}
pub fn revision_kind_from_json(json: String) -> Result<RevisionKind, String> {
    serde_json::from_str::<kreuzberg::RevisionKind>(&json)
        .map(RevisionKind::from)
        .map_err(|e| e.to_string())
}
pub fn revision_anchor_from_json(json: String) -> Result<RevisionAnchor, String> {
    serde_json::from_str::<kreuzberg::RevisionAnchor>(&json)
        .map(RevisionAnchor::from)
        .map_err(|e| e.to_string())
}
pub fn uri_kind_from_json(json: String) -> Result<UriKind, String> {
    serde_json::from_str::<kreuzberg::UriKind>(&json)
        .map(UriKind::from)
        .map_err(|e| e.to_string())
}
pub fn keyword_algorithm_from_json(json: String) -> Result<KeywordAlgorithm, String> {
    serde_json::from_str::<kreuzberg::KeywordAlgorithm>(&json)
        .map(KeywordAlgorithm::from)
        .map_err(|e| e.to_string())
}
pub fn psm_mode_from_json(json: String) -> Result<PSMMode, String> {
    serde_json::from_str::<kreuzberg::PSMMode>(&json)
        .map(PSMMode::from)
        .map_err(|e| e.to_string())
}
pub fn paddle_language_from_json(json: String) -> Result<PaddleLanguage, String> {
    serde_json::from_str::<kreuzberg::PaddleLanguage>(&json)
        .map(PaddleLanguage::from)
        .map_err(|e| e.to_string())
}
pub fn layout_class_from_json(json: String) -> Result<LayoutClass, String> {
    serde_json::from_str::<kreuzberg::LayoutClass>(&json)
        .map(LayoutClass::from)
        .map_err(|e| e.to_string())
}
