"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _slugid = _interopRequireDefault(require("slugid"));
var _constants = require("../constants");
const linkRule = (element, parseChild) => {
  const {
    nodeName
  } = element;
  const content = element.textContent || element.getAttribute('title') || element.getAttribute('href');
  if (nodeName === 'A') {
    return {
      id: _slugid.default.nice(),
      type: _constants.LINK,
      url: element.getAttribute('href') || content,
      title: element.getAttribute('title'),
      children: [{
        id: _slugid.default.nice(),
        text: content
      }]
    };
  }
  return;
};
var _default = exports.default = linkRule;