import*as e from"../../../core/platform/platform.js";import*as t from"../../lit/lit.js";import*as i from"../render_coordinator/render_coordinator.js";import*as r from"../../../models/bindings/bindings.js";var n={cssText:`.link:link,\n.link:visited{color:var(--sys-color-primary);text-decoration:underline;cursor:pointer;outline-offset:2px}\n/*# sourceURL=${import.meta.resolve("./linkifierImpl.css")} */\n`};const o=new CSSStyleSheet;o.replaceSync(n.cssText);const{html:s}=t;class l extends Event{data;static eventName="linkifieractivated";constructor(e){super(l.eventName,{bubbles:!0,composed:!0}),this.data=e,this.data=e}}class a extends HTMLElement{#e=this.attachShadow({mode:"open"});#t=e.DevToolsPath.EmptyUrlString;#i;#r;#n;#o;set data(e){if(this.#t=e.url,this.#i=e.lineNumber,this.#r=e.columnNumber,this.#n=e.linkText,this.#o=e.title,!this.#t)throw new Error("Cannot construct a Linkifier without providing a valid string URL.");this.#s()}cloneNode(e){const t=super.cloneNode(e);return t.data={url:this.#t,lineNumber:this.#i,columnNumber:this.#r,linkText:this.#n,title:this.#o},t}connectedCallback(){this.#e.adoptedStyleSheets=[o]}#l(e){e.preventDefault();const t=new l({url:this.#t,lineNumber:this.#i,columnNumber:this.#r});this.dispatchEvent(t)}async#s(){const e=this.#n??function(e,t){if(e){let i=`${r.ResourceUtils.displayNameForURL(e)}`;return void 0!==t&&(i+=`:${t+1}`),i}throw new Error("New linkifier component error: don't know how to generate link text for given arguments")}(this.#t,this.#i);await i.write((()=>{t.render(s`<a class="link" href=${this.#t} @click=${this.#l} title=${t.Directives.ifDefined(this.#o)}><slot>${e}</slot></a>`,this.#e,{host:this})}))}}customElements.define("devtools-linkifier",a);var c=Object.freeze({__proto__:null,Linkifier:a,LinkifierClick:l});export{c as Linkifier};
