import*as Platform from"../../../core/platform/platform.js";import*as SDK from"../../../core/sdk/sdk.js";import*as LitHtml from"../../lit-html/lit-html.js";import*as ComponentHelpers from"../helpers/helpers.js";import chromeLinkStyles from"./chromeLink.css.js";export class ChromeLink extends HTMLElement{static litTagName=LitHtml.literal`devtools-chrome-link`;#e=this.attachShadow({mode:"open"});#t=this.#r.bind(this);#o="";connectedCallback(){this.#e.adoptedStyleSheets=[chromeLinkStyles],ComponentHelpers.ScheduledRender.scheduleRender(this,this.#t)}set href(e){if(!e.startsWith("chrome://"))throw new Error("ChromeLink href needs to start with 'chrome://'");this.#o=e,ComponentHelpers.ScheduledRender.scheduleRender(this,this.#t)}openSettingsTab(e){if("click"===e.type||"keydown"===e.type&&Platform.KeyboardUtilities.isEnterOrSpaceKey(e)){const t=SDK.TargetManager.TargetManager.instance().rootTarget();t&&t.targetAgent().invoke_createTarget({url:this.#o}),e.consume(!0)}}#r(){LitHtml.render(LitHtml.html`
        <a href=${this.#o} class="link" target="_blank"
          @click=${this.openSettingsTab}
          @keydown=${this.openSettingsTab}><slot></slot></a>
      `,this.#e,{host:this})}}ComponentHelpers.CustomElements.defineComponent("devtools-chrome-link",ChromeLink);