class AnomalyVisualizer extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.anomalies = [];
}
connectedCallback() {
this.render();
document.addEventListener('quantumAnomaly', (e) => {
this.addAnomaly(e.detail);
});
}
addAnomaly(anomaly) {
this.anomalies.push(anomaly);
this.renderAnomaly(anomaly);
// Remove after animation
setTimeout(() => {
this.anomalies = this.anomalies.filter(a => a !== anomaly);
}, 3000);
}
render() {
this.shadowRoot.innerHTML = `
`;
}
renderAnomaly(anomaly) {
const element = document.createElement('div');
element.className = 'anomaly';
element.style.left = `${Math.random() * 100}%`;
element.style.top = `${Math.random() * 100}%`;
element.style.animationDelay = `${Math.random() * 0.5}s`;
this.shadowRoot.appendChild(element);
}
}
customElements.define('anomaly-visualizer', AnomalyVisualizer);