"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("../micromark-util-sanitize-uri/index.cjs");
const revert = require("./lib-revert.cjs");
function linkReference(state, node) {
  const id = String(node.identifier).toUpperCase();
  const definition = state.definitionById.get(id);
  if (!definition) {
    return revert.revert(state, node);
  }
  const properties = { href: index.normalizeUri(definition.url || "") };
  if (definition.title !== null && definition.title !== void 0) {
    properties.title = definition.title;
  }
  const result = {
    type: "element",
    tagName: "a",
    properties,
    children: state.all(node)
  };
  state.patch(node, result);
  return state.applyData(node, result);
}
exports.linkReference = linkReference;
//# sourceMappingURL=lib-handlers-link-reference.cjs.map
