// ../aot-compiler/dist/chunk-QKE5BEQY.js
var SemanticParserAdapter = class {
  constructor(analyzer, ASTBuilderClass, parseWithConfidenceFn, converter) {
    this.analyzer = analyzer;
    this.ASTBuilderClass = ASTBuilderClass;
    this.parseWithConfidenceFn = parseWithConfidenceFn;
    this.converter = converter;
  }
  /**
   * Analyze code in the given language.
   * Uses the full semantic parser (parseWithConfidence) which correctly
   * returns event-handler nodes with body commands.
   */
  analyze(code, language) {
    try {
      const result = this.parseWithConfidenceFn(code, language);
      return {
        node: result.node ?? void 0,
        confidence: result.confidence,
        errors: result.error ? [result.error] : void 0
      };
    } catch (error) {
      return {
        confidence: 0,
        errors: [error instanceof Error ? error.message : String(error)]
      };
    }
  }
  /**
   * Build an AOT-compatible AST from the SemanticNode.
   * Converts the semantic package's AST format to AOT types via interchange.
   */
  buildAST(node) {
    const semanticNode = node;
    const builder = new this.ASTBuilderClass();
    const semanticAST = builder.build(semanticNode);
    const aotAST = this.converter(semanticAST);
    return { ast: aotAST, warnings: builder.warnings };
  }
  /**
   * Check if the given language is supported.
   */
  supportsLanguage(language) {
    return this.analyzer.supportsLanguage(language);
  }
};
var _converter = null;
function convertSemanticASTToAOT(node) {
  if (_converter) return _converter(node);
  return node;
}
async function createSemanticAdapter() {
  const semantic = await import("@lokascript/semantic");
  const analyzer = semantic.createSemanticAnalyzer();
  const ASTBuilderClass = semantic.ASTBuilder;
  const parseWithConfidence = semantic.parseWithConfidence;
  const converter = semantic.fromSemanticAST;
  if (!converter) {
    throw new Error(
      "@lokascript/semantic does not export fromSemanticAST. Ensure @lokascript/semantic >= 1.3.0 is installed."
    );
  }
  _converter = converter;
  return new SemanticParserAdapter(
    analyzer,
    ASTBuilderClass,
    parseWithConfidence,
    converter
  );
}

export {
  SemanticParserAdapter,
  convertSemanticASTToAOT,
  createSemanticAdapter
};
//# sourceMappingURL=chunk-CY26COTT.js.map