import*as LitHtml from"../../third_party/lit-html/lit-html.js";import*as LinkifierUtils from"./LinkifierUtils.js";export class LinkifierClick extends Event{constructor(i){super("linkifier-activated",{bubbles:!0,composed:!0}),this.data=i}}export class Linkifier extends HTMLElement{constructor(){super(...arguments),this.shadow=this.attachShadow({mode:"open"}),this.url=""}set data(i){this.url=i.url,this.lineNumber=i.lineNumber,this.columnNumber=i.columnNumber,this.render()}onLinkActivation(i){i.preventDefault();const t=new LinkifierClick({url:this.url,lineNumber:this.lineNumber,columnNumber:this.columnNumber});this.dispatchEvent(t)}render(){if(!this.url)throw new Error("Cannot construct a Linkifier without providing a valid string URL.");return LitHtml.render(LitHtml.html`
      <style>
          .link:link,
          .link:visited {
            color: var(--color-link);
            text-decoration: underline;
            cursor: pointer;
          }
      </style>
      <a class="link" href=${this.url} @click=${this.onLinkActivation}>${LinkifierUtils.linkText(this.url,this.lineNumber)}</a>
    `,this.shadow,{eventContext:this})}}customElements.define("devtools-linkifier",Linkifier);