import AppCustomElementStyleSheet from "file:///Users/dmail/Documents/dev/core/packages/related/cli/template-web-components/src/app/app_custom_element.css?as_css_module" ;
import { initCounter } from "file:///Users/dmail/Documents/dev/core/packages/related/cli/template-web-components/src/app/counter.js";

const jsenvLogoUrl = new URL("file:///Users/dmail/Documents/dev/core/packages/related/cli/template-web-components/src/jsenv_logo.svg", import.meta.url);

class AppCustomElement extends HTMLElement {
  constructor() {
    super();
    const shadow = this.attachShadow({ mode: "open" });
    shadow.adoptedStyleSheets = [
      ...shadow.adoptedStyleSheets,
      AppCustomElementStyleSheet,
    ];
    shadow.innerHTML = `
<h1>Hello world!</h1>
<img class="logo" src=${jsenvLogoUrl} alt="logo" />
<p>
  <button id="counter_button">Click me!</button>
  <p>
    Number of clicks: <span id="counter_output"></span>
  </p>
</p>
<p>
  Edit <a href="javascript:window.fetch('/.internal/open_file/jsenv_logo.svg')">jsenv_logo.svg</a> and save to test HMR updates.
</p>
<a href="https://github.com/jsenv/core" target="_blank">Documentation</a>`;
    initCounter(shadow);
  }
}

customElements.define("my-app", AppCustomElement);
