import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = ["container", "count", "content"] static values = { interval: { type: Number, default: 60000 }, // 60 seconds countUrl: String, fullUrl: String } connect() { this.isExpanded = false this.isLoading = false this.isVisible = false this.startCountPolling() this.boundClickHandler = this.handleClick.bind(this) this.containerTarget.addEventListener('click', this.boundClickHandler) } disconnect() { this.stopCountPolling() this.containerTarget.removeEventListener('click', this.boundClickHandler) } handleClick(event) { const header = event.target.closest('.currently-hacking') if (header) { this.toggle() } } async toggle() { this.isExpanded = !this.isExpanded if (this.isExpanded) { this.showLoading() this.contentTarget.style.display = 'block' await this.gimmeAll() } else { this.contentTarget.style.display = 'none' } } showLoading() { this.contentTarget.innerHTML = `