import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = ["video", "link"]

  connect() {
    this.videoTarget.addEventListener("ended", this.followLink)
  }

  disconnect() {
    this.videoTarget.removeEventListener("ended", this.followLink)
  }

  followLink = () => {
    this.linkTarget.click()
  }
}
