import { createDefaultSharedCoreModule, createDefaultCoreModule } from "./lib-default-module.js";
import { inject } from "./lib-dependency-injection.js";
import { LangiumGrammarAstReflection } from "./lib-languages-generated-ast.js";
import { EmptyFileSystem } from "./lib-workspace-file-system-provider.js";
import "./lib-utils-uri-utils.js";
import { URI } from "../vscode-uri/lib-esm-index.js";
const minimalGrammarModule = {
  Grammar: () => void 0,
  LanguageMetaData: () => ({
    caseInsensitive: false,
    fileExtensions: [".langium"],
    languageId: "langium"
  })
};
const minimalSharedGrammarModule = {
  AstReflection: () => new LangiumGrammarAstReflection()
};
function createMinimalGrammarServices() {
  const shared = inject(createDefaultSharedCoreModule(EmptyFileSystem), minimalSharedGrammarModule);
  const grammar = inject(createDefaultCoreModule({ shared }), minimalGrammarModule);
  shared.ServiceRegistry.register(grammar);
  return grammar;
}
function loadGrammarFromJson(json) {
  var _a;
  const services = createMinimalGrammarServices();
  const astNode = services.serializer.JsonSerializer.deserialize(json);
  services.shared.workspace.LangiumDocumentFactory.fromModel(astNode, URI.parse(`memory://${(_a = astNode.name) !== null && _a !== void 0 ? _a : "grammar"}.langium`));
  return astNode;
}
export {
  loadGrammarFromJson
};
//# sourceMappingURL=lib-utils-grammar-loader.js.map
