/* TransformJS C Bindings - Generated by cbindgen */

#ifndef TRANSFORMJS_H
#define TRANSFORMJS_H

/* Generated with cbindgen:0.29.2 */

/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */

#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>

/**
 * Helper loader mode
 */
typedef enum TransformHelperLoaderMode {
  /**
   * Runtime mode - helpers are inlined
   */
  TransformHelperLoaderMode_Runtime = 0,
  /**
   * External mode - helpers are imported
   */
  TransformHelperLoaderMode_External = 1,
} TransformHelperLoaderMode;

/**
 * Transform options structure (C-compatible)
 */
typedef struct CTransformOptions {
  /**
   * Enable JSX transformation (0 = disabled, 1 = enabled)
   */
  int jsx_enabled;
  /**
   * JSX development mode (0 = production, 1 = development)
   */
  int jsx_development;
  /**
   * Enable TypeScript transformation (0 = disabled, 1 = enabled)
   */
  int typescript_enabled;
  /**
   * Helper loader mode
   */
  TransformHelperLoaderMode helper_loader_mode;
  /**
   * Target environment string (e.g., "es2020", "chrome58", null for default)
   * This is a comma-separated list of targets
   */
  const char *target;
} CTransformOptions;

/**
 * Result structure for transformation operations
 */
typedef struct TransformResult {
  /**
   * Pointer to the transformed code (null-terminated C string)
   * Caller is responsible for freeing this using `transformjs_free_string`
   */
  char *output;
  /**
   * Length of the output string (excluding null terminator)
   */
  size_t output_len;
  /**
   * Error message if transformation failed (null-terminated C string)
   * Caller is responsible for freeing this using `transformjs_free_string`
   */
  char *error;
  /**
   * Success flag: 0 = success, non-zero = error
   */
  int success;
} TransformResult;

/**
 * Transform JavaScript/TypeScript source code
 *
 * # Safety
 * - `source` must be a valid null-terminated C string
 * - `file_path` must be a valid null-terminated C string (can be null for default)
 * - `options` can be null to use default options, or a pointer to a valid CTransformOptions struct
 * - The caller is responsible for freeing the returned `TransformResult` using `transformjs_free_result`
 */
struct TransformResult *transformjs_transform(const char *source,
                                              const char *file_path,
                                              const struct CTransformOptions *options);

/**
 * Free a string allocated by the library
 *
 * # Safety
 * - `ptr` must be a pointer returned by the library, or null
 */
void transformjs_free_string(char *ptr);

/**
 * Free a TransformResult structure
 *
 * # Safety
 * - `result` must be a pointer returned by `transformjs_transform`, or null
 */
void transformjs_free_result(struct TransformResult *result);

#endif  /* TRANSFORMJS_H */
