import { createLink, parseLink } from "./../../ricos-content/lib/node-utils.js";
import linkDefaults from "./../../ricos-schema/legacy/statics/link.defaults.json.js";
import {
  convertRelObjectToString,
  convertRelStringToObject
} from "./../../wix-rich-content-common/index.js";
const defaultLinkRel = {
  nofollow: false,
  sponsored: false,
  ugc: false,
  noreferrer: false
};
class RicosLink {
  constructor(link) {
    this.link = link;
  }
  toLink() {
    return this.link;
  }
  toHtmlAttributes() {
    const { url = "", rel = "", target = "_self" } = parseLink(this.link);
    return { url, rel, target };
  }
  static getLinkDefaults() {
    return linkDefaults;
  }
  static of(url, target = "_self", rel, linkRel = defaultLinkRel) {
    const relValue = convertRelObjectToString(rel ? convertRelStringToObject(rel) : linkRel);
    const link = createLink({ url, rel: relValue, target });
    return new RicosLink(link);
  }
  static fromLink(link) {
    return new RicosLink(link);
  }
  setUrl(url) {
    const link = createLink({ ...this.toHtmlAttributes(), url });
    return new RicosLink(link);
  }
}
export {
  RicosLink
};
//# sourceMappingURL=models.js.map
