import { normalizeUri } from "../../../../../micromark-util-sanitize-uri@2.0.1/node_modules/micromark-util-sanitize-uri/index.js";
import { revert } from "../revert.js";
function linkReference(state, node) {
  const id = String(node.identifier).toUpperCase();
  const definition = state.definitionById.get(id);
  if (!definition) {
    return revert(state, node);
  }
  const properties = { href: 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);
}
export {
  linkReference
};
//# sourceMappingURL=link-reference.js.map
