declare module "llrt:xml" {
  type XmlInput =
    | string
    | ArrayBuffer
    | QuickJS.ArrayBufferView
    | ArrayLike<number>;

  type AttributeValueProcessor = (
    attrName: string,
    attrValue: string,
    jpath: string
  ) => string | null | undefined | void;

  type TagValueProcessor = (
    tagName: string,
    tagValue: string,
    jpath: string,
    hasAttributes: boolean
  ) => string | null | undefined | void;

  interface XmlParserOptions {
    ignoreAttributes?: boolean;
    attributeNamePrefix?: string;
    textNodeName?: string;
    attributeValueProcessor?: AttributeValueProcessor;
    tagValueProcessor?: TagValueProcessor;
  }

  export class XmlText {
    constructor(text: string);
    toString(): string;
  }

  export class XmlNode {
    constructor(name: string, children?: unknown[]);
    static of(name: string, childText?: string, withName?: string): XmlNode;
    withName(name: string): this;
    addAttribute(name: string, value: string): this;
    addChildNode(node: unknown): this;
    removeAttribute(name: string): this;
    toString(): string;
  }

  export class XMLParser {
    constructor(options?: XmlParserOptions);
    addEntity(key: string, value: string): void;
    parse(xml: XmlInput): Record<string, unknown>;
  }

  const _default: {
    XMLParser: typeof XMLParser;
    XmlText: typeof XmlText;
    XmlNode: typeof XmlNode;
  };

  export type { XmlParserOptions };
  export default _default;
}
