// This file is auto-generated by alef. DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
#nullable enable

using System;
using System.Runtime.InteropServices;

namespace Kreuzberg;

internal static partial class NativeMethods
{
    private const string LibName = "kreuzberg_ffi";

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_extractor_free")]
    internal static extern void DocumentExtractorFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_backend_free")]
    internal static extern void EmbeddingBackendFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_backend_free")]
    internal static extern void OcrBackendFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_plugin_free")]
    internal static extern void PluginFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_post_processor_free")]
    internal static extern void PostProcessorFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_renderer_free")]
    internal static extern void RendererFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_validator_free")]
    internal static extern void ValidatorFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_diff_options_from_json")]
    internal static extern IntPtr DiffOptionsFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_diff_options_free")]
    internal static extern void DiffOptionsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_from_json")]
    internal static extern IntPtr DocumentStructureFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_free")]
    internal static extern void DocumentStructureFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_config_from_json")]
    internal static extern IntPtr EmbeddingConfigFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_config_free")]
    internal static extern void EmbeddingConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_config_from_json")]
    internal static extern IntPtr ExtractionConfigFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_config_free")]
    internal static extern void ExtractionConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_result_from_json")]
    internal static extern IntPtr ExtractionResultFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_result_free")]
    internal static extern void ExtractionResultFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_metadata_from_json")]
    internal static extern IntPtr MetadataFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_metadata_free")]
    internal static extern void MetadataFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_extraction_result_from_json")]
    internal static extern IntPtr OcrExtractionResultFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_extraction_result_free")]
    internal static extern void OcrExtractionResultFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_from_json")]
    internal static extern IntPtr PaddleOcrConfigFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_free")]
    internal static extern void PaddleOcrConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_from_json")]
    internal static extern IntPtr ServerConfigFromJson([MarshalAs(UnmanagedType.LPUTF8Str)] string json);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_free")]
    internal static extern void ServerConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_chunking_config_to_json")]
    internal static extern IntPtr ChunkingConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_chunking_config_free")]
    internal static extern void ChunkingConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_content_filter_config_to_json")]
    internal static extern IntPtr ContentFilterConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_content_filter_config_free")]
    internal static extern void ContentFilterConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_diff_options_to_json")]
    internal static extern IntPtr DiffOptionsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_to_json")]
    internal static extern IntPtr DocumentStructureToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_config_to_json")]
    internal static extern IntPtr EmbeddingConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_preset_to_json")]
    internal static extern IntPtr EmbeddingPresetToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_preset_free")]
    internal static extern void EmbeddingPresetFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_config_to_json")]
    internal static extern IntPtr ExtractionConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_diff_to_json")]
    internal static extern IntPtr ExtractionDiffToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_diff_free")]
    internal static extern void ExtractionDiffFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_result_to_json")]
    internal static extern IntPtr ExtractionResultToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_hierarchy_config_to_json")]
    internal static extern IntPtr HierarchyConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_hierarchy_config_free")]
    internal static extern void HierarchyConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_html_output_config_to_json")]
    internal static extern IntPtr HtmlOutputConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_html_output_config_free")]
    internal static extern void HtmlOutputConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_extraction_config_to_json")]
    internal static extern IntPtr ImageExtractionConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_extraction_config_free")]
    internal static extern void ImageExtractionConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_preprocessing_config_to_json")]
    internal static extern IntPtr ImagePreprocessingConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_preprocessing_config_free")]
    internal static extern void ImagePreprocessingConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_keyword_config_to_json")]
    internal static extern IntPtr KeywordConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_keyword_config_free")]
    internal static extern void KeywordConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_language_detection_config_to_json")]
    internal static extern IntPtr LanguageDetectionConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_language_detection_config_free")]
    internal static extern void LanguageDetectionConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_layout_detection_config_to_json")]
    internal static extern IntPtr LayoutDetectionConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_layout_detection_config_free")]
    internal static extern void LayoutDetectionConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_metadata_to_json")]
    internal static extern IntPtr MetadataToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_config_to_json")]
    internal static extern IntPtr OcrConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_config_free")]
    internal static extern void OcrConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_quality_thresholds_to_json")]
    internal static extern IntPtr OcrQualityThresholdsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_quality_thresholds_free")]
    internal static extern void OcrQualityThresholdsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_to_json")]
    internal static extern IntPtr PaddleOcrConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_page_config_to_json")]
    internal static extern IntPtr PageConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_page_config_free")]
    internal static extern void PageConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_pdf_config_to_json")]
    internal static extern IntPtr PdfConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_pdf_config_free")]
    internal static extern void PdfConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_post_processor_config_to_json")]
    internal static extern IntPtr PostProcessorConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_post_processor_config_free")]
    internal static extern void PostProcessorConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_rake_params_to_json")]
    internal static extern IntPtr RakeParamsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_rake_params_free")]
    internal static extern void RakeParamsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_security_limits_to_json")]
    internal static extern IntPtr SecurityLimitsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_security_limits_free")]
    internal static extern void SecurityLimitsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_to_json")]
    internal static extern IntPtr ServerConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tesseract_config_to_json")]
    internal static extern IntPtr TesseractConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tesseract_config_free")]
    internal static extern void TesseractConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_config_to_json")]
    internal static extern IntPtr TokenReductionConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_config_free")]
    internal static extern void TokenReductionConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_options_to_json")]
    internal static extern IntPtr TokenReductionOptionsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_options_free")]
    internal static extern void TokenReductionOptionsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_config_to_json")]
    internal static extern IntPtr TreeSitterConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_config_free")]
    internal static extern void TreeSitterConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_process_config_to_json")]
    internal static extern IntPtr TreeSitterProcessConfigToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_process_config_free")]
    internal static extern void TreeSitterProcessConfigFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_yake_params_to_json")]
    internal static extern IntPtr YakeParamsToJson(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_yake_params_free")]
    internal static extern void YakeParamsFree(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extract_bytes")]
    internal static extern IntPtr ExtractBytes(
        IntPtr content,
        UIntPtr contentLen,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string mimeType,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extract_file")]
    internal static extern IntPtr ExtractFile(
        [MarshalAs(UnmanagedType.LPUTF8Str)] string path,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string mimeType,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extract_file_sync")]
    internal static extern IntPtr ExtractFileSync(
        [MarshalAs(UnmanagedType.LPUTF8Str)] string path,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string mimeType,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extract_bytes_sync")]
    internal static extern IntPtr ExtractBytesSync(
        IntPtr content,
        UIntPtr contentLen,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string mimeType,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_batch_extract_files_sync")]
    internal static extern IntPtr BatchExtractFilesSync(
        IntPtr items,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_batch_extract_bytes_sync")]
    internal static extern IntPtr BatchExtractBytesSync(
        IntPtr items,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_batch_extract_files")]
    internal static extern IntPtr BatchExtractFiles(
        IntPtr items,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_batch_extract_bytes")]
    internal static extern IntPtr BatchExtractBytes(
        IntPtr items,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_detect_mime_type_from_bytes")]
    internal static extern IntPtr DetectMimeTypeFromBytes(
        IntPtr content,
        UIntPtr contentLen
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_get_extensions_for_mime")]
    internal static extern IntPtr GetExtensionsForMime(
        [MarshalAs(UnmanagedType.LPUTF8Str)] string mimeType
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_embedding_backends")]
    internal static extern IntPtr ListEmbeddingBackends();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_document_extractors")]
    internal static extern IntPtr ListDocumentExtractors();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_ocr_backends")]
    internal static extern IntPtr ListOcrBackends();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_post_processors")]
    internal static extern IntPtr ListPostProcessors();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_renderers")]
    internal static extern IntPtr ListRenderers();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_validators")]
    internal static extern IntPtr ListValidators();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_compare")]
    internal static extern IntPtr Compare(
        IntPtr a,
        IntPtr b,
        IntPtr opts
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embed_texts_async")]
    internal static extern IntPtr EmbedTextsAsync(
        IntPtr texts,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_render_pdf_page_to_png")]
    internal static extern int RenderPdfPageToPng(
        IntPtr pdfBytes,
        UIntPtr pdfBytesLen,
        ulong pageIndex,
        int dpi,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string password,
        out IntPtr outPtr,
        out UIntPtr outLen,
        out UIntPtr outCap
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_detect_mime_type")]
    internal static extern IntPtr DetectMimeType(
        [MarshalAs(UnmanagedType.LPUTF8Str)] string path,
        [MarshalAs(UnmanagedType.U1)] bool checkExists
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embed_texts")]
    internal static extern IntPtr EmbedTexts(
        IntPtr texts,
        IntPtr config
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_get_embedding_preset")]
    internal static extern IntPtr GetEmbeddingPreset(
        [MarshalAs(UnmanagedType.LPUTF8Str)] string name
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_list_embedding_presets")]
    internal static extern IntPtr ListEmbeddingPresets();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_content_filter_config_default")]
    internal static extern IntPtr ContentFilterConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_config_default")]
    internal static extern IntPtr ExtractionConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_config_needs_image_processing")]
    internal static extern int ExtractionConfigNeedsImageProcessing(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_extraction_config_default")]
    internal static extern IntPtr ImageExtractionConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_options_default")]
    internal static extern IntPtr TokenReductionOptionsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_language_detection_config_default")]
    internal static extern IntPtr LanguageDetectionConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_html_output_config_default")]
    internal static extern IntPtr HtmlOutputConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_layout_detection_config_default")]
    internal static extern IntPtr LayoutDetectionConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_quality_thresholds_default")]
    internal static extern IntPtr OcrQualityThresholdsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_ocr_config_default")]
    internal static extern IntPtr OcrConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_page_config_default")]
    internal static extern IntPtr PageConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_pdf_config_default")]
    internal static extern IntPtr PdfConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_hierarchy_config_default")]
    internal static extern IntPtr HierarchyConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_post_processor_config_default")]
    internal static extern IntPtr PostProcessorConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_chunking_config_default")]
    internal static extern IntPtr ChunkingConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_embedding_config_default")]
    internal static extern IntPtr EmbeddingConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_config_default")]
    internal static extern IntPtr TreeSitterConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tree_sitter_process_config_default")]
    internal static extern IntPtr TreeSitterProcessConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_default")]
    internal static extern IntPtr ServerConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_listen_addr")]
    internal static extern IntPtr ServerConfigListenAddr(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_cors_allows_all")]
    internal static extern int ServerConfigCorsAllowsAll(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_is_origin_allowed")]
    internal static extern int ServerConfigIsOriginAllowed(
        IntPtr handle,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string origin
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_max_request_body_mb")]
    internal static extern ulong ServerConfigMaxRequestBodyMb(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_server_config_max_multipart_field_mb")]
    internal static extern ulong ServerConfigMaxMultipartFieldMb(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_security_limits_default")]
    internal static extern IntPtr SecurityLimitsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_token_reduction_config_default")]
    internal static extern IntPtr TokenReductionConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_finalize_node_types")]
    internal static extern void DocumentStructureFinalizeNodeTypes(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_is_empty")]
    internal static extern int DocumentStructureIsEmpty(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_document_structure_default")]
    internal static extern IntPtr DocumentStructureDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_extraction_result_from_ocr")]
    internal static extern IntPtr ExtractionResultFromOcr(
        IntPtr ocr
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_image_preprocessing_config_default")]
    internal static extern IntPtr ImagePreprocessingConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_tesseract_config_default")]
    internal static extern IntPtr TesseractConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_metadata_is_empty")]
    internal static extern int MetadataIsEmpty(
        IntPtr handle
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_diff_options_default")]
    internal static extern IntPtr DiffOptionsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_yake_params_default")]
    internal static extern IntPtr YakeParamsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_rake_params_default")]
    internal static extern IntPtr RakeParamsDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_keyword_config_default")]
    internal static extern IntPtr KeywordConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_cache_dir")]
    internal static extern IntPtr PaddleOcrConfigWithCacheDir(
        IntPtr handle,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string path
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_table_detection")]
    internal static extern IntPtr PaddleOcrConfigWithTableDetection(
        IntPtr handle,
        [MarshalAs(UnmanagedType.U1)] bool enable
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_angle_cls")]
    internal static extern IntPtr PaddleOcrConfigWithAngleCls(
        IntPtr handle,
        [MarshalAs(UnmanagedType.U1)] bool enable
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_det_db_thresh")]
    internal static extern IntPtr PaddleOcrConfigWithDetDbThresh(
        IntPtr handle,
        float threshold
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_det_db_box_thresh")]
    internal static extern IntPtr PaddleOcrConfigWithDetDbBoxThresh(
        IntPtr handle,
        float threshold
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_det_db_unclip_ratio")]
    internal static extern IntPtr PaddleOcrConfigWithDetDbUnclipRatio(
        IntPtr handle,
        float ratio
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_det_limit_side_len")]
    internal static extern IntPtr PaddleOcrConfigWithDetLimitSideLen(
        IntPtr handle,
        uint length
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_rec_batch_num")]
    internal static extern IntPtr PaddleOcrConfigWithRecBatchNum(
        IntPtr handle,
        uint batchSize
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_drop_score")]
    internal static extern IntPtr PaddleOcrConfigWithDropScore(
        IntPtr handle,
        float score
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_padding")]
    internal static extern IntPtr PaddleOcrConfigWithPadding(
        IntPtr handle,
        uint padding
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_with_model_tier")]
    internal static extern IntPtr PaddleOcrConfigWithModelTier(
        IntPtr handle,
        [MarshalAs(UnmanagedType.LPUTF8Str)] string tier
    );

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_paddle_ocr_config_default")]
    internal static extern IntPtr PaddleOcrConfigDefault();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_last_error_code")]
    internal static extern int LastErrorCode();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_last_error_context")]
    internal static extern IntPtr LastErrorContext();

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_free_string")]
    internal static extern void FreeString(IntPtr ptr);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_free_bytes")]
    internal static extern void FreeBytes(IntPtr ptr, UIntPtr len, UIntPtr cap);

    // Trait Bridge FFI

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_ocr_backend")]
    internal static extern int RegisterOcrBackend([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_ocr_backend")]
    internal static extern int UnregisterOcrBackend([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_ocr_backend")]
    internal static extern int ClearOcrBackend(out IntPtr outError);


    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_post_processor")]
    internal static extern int RegisterPostProcessor([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_post_processor")]
    internal static extern int UnregisterPostProcessor([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_post_processor")]
    internal static extern int ClearPostProcessor(out IntPtr outError);


    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_validator")]
    internal static extern int RegisterValidator([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_validator")]
    internal static extern int UnregisterValidator([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_validator")]
    internal static extern int ClearValidator(out IntPtr outError);


    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_embedding_backend")]
    internal static extern int RegisterEmbeddingBackend([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_embedding_backend")]
    internal static extern int UnregisterEmbeddingBackend([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_embedding_backend")]
    internal static extern int ClearEmbeddingBackend(out IntPtr outError);


    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_document_extractor")]
    internal static extern int RegisterDocumentExtractor([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_document_extractor")]
    internal static extern int UnregisterDocumentExtractor([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_document_extractor")]
    internal static extern int ClearDocumentExtractor(out IntPtr outError);


    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_register_renderer")]
    internal static extern int RegisterRenderer([MarshalAs(UnmanagedType.LPUTF8Str)] string name, IntPtr vtable, IntPtr userData, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_unregister_renderer")]
    internal static extern int UnregisterRenderer([MarshalAs(UnmanagedType.LPUTF8Str)] string name, out IntPtr outError);

    [DllImport(LibName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "kreuzberg_clear_renderer")]
    internal static extern int ClearRenderer(out IntPtr outError);

}
