class TooltipElement extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; } show(x, y, text) { this.style.display = 'block'; this.style.left = `${x}px`; this.style.top = `${y}px`; this.textContent = text; } hide() { this.style.display = 'none'; } } customElements.define('tool-tip', TooltipElement);