pub mod base36;
pub mod context;
pub mod events;
pub mod facade;
pub mod lsp;
pub mod parsers;
pub mod tools;

mod consumers;
pub mod emitters;
pub mod plugins;
#[cfg(feature = "python")]
pub mod python;
#[cfg(test)]
mod tests;
pub mod transformers;
mod util;

// Re-export the main facade for simple usage
pub use parsers::wasot::WasotParser;

// Re-export commonly used types from parser module
pub use parsers::wasot::{
    detect_links, extract_line_type, is_meta_line, parse_link, split_into_parts,
    split_into_parts_and_trim, Block, DocumentParser, Element, ElementParser, Id, MetaLine,
    ParsedArguments, Text,
};

// Re-export selector parsing and AST types
pub use parsers::selectors::{
    ast::{SimpleSelector, SimpleSelectorGroup, StackFrame},
    parser::parse_selector,
    specificity::{calculate_simple_selector_group, Specificity},
};

// Re-export event system types
pub use events::{BusReaderIterator, Consumer, Emitter, Event};

// Re-export emitter types
#[cfg(feature = "html")]
pub use emitters::html_emitter::{HtmlEmitter, HtmlEmitterConfig};
#[cfg(feature = "binary")]
pub use emitters::protobuf_binary_emitter::ProtobufBinaryEmitter;
#[cfg(feature = "sqlite")]
pub use emitters::sql_file_emitter::SqlFileEmitter;
#[cfg(feature = "sqlite")]
pub use emitters::sqlite_emitter::SqliteEmitter;
pub use emitters::{
    fast_random_emitter::FastRandomEmitter, jsonl_emitter::JsonlEmitter,
    random_emitter::RandomEmitter, selector_emitter::SelectorEmitter,
    wasot_file_emitter::WasotFileEmitter, xml_emitter::XmlEmitter,
};

// Re-export plugin types
pub use plugins::MarkdownEmitter;

// Re-export consumer types (previously listeners)
#[cfg(feature = "sqlite")]
pub use consumers::SqliteConsumer;
#[cfg(feature = "binary")]
pub use consumers::{binary_format, BinaryProtobufConsumer, ProtobufConsumer};
pub use consumers::{
    get_sample_actions, Action, ActionConsumer, ActionHandler, HtmlListener, LinksPrinter,
    SelectorConsumer, SqlFileConsumer, StreamingJsonExporter, ToJsonlConsumer, ToXmlConsumer,
    ToYamlTestConsumer, WasotReconstructor, XmlListener,
};
#[cfg(feature = "sexp")]
pub use consumers::{validate_sexp, ToSexpConsumer};

// Re-export XML validation utilities
pub use util::{validate_xml_file, validate_xml_string, XmlValidationError, XmlValidationResult};

// Re-export LSP types
pub use lsp::{
    start_lsp_server, DocumentIndex, IndexedId, IndexedLink, LinkTargetType, Position, Range,
    ResolvedTarget, WasotLanguageServer,
};

// Python module entry point
#[cfg(feature = "python")]
use pyo3::prelude::*;

#[cfg(feature = "python")]
#[pymodule]
fn _pywasot(m: &Bound<'_, PyModule>) -> PyResult<()> {
    python::pywasot(m)
}
