{ "version": 3, "sources": ["event_now_banner_controller-562eb441.js"], "sourcesContent": ["import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n static targets = [ \"text\" ]\n\n static values = {\n eventStartDate: String,\n nowText: String,\n transitionedBeforeLoad: { type: Boolean, default: false }\n }\n\n initialize() {\n this.transitionCompleted = false\n }\n\n eventStartDateValueChanged() {\n this.eventStartsAt = new Date(this.eventStartDateValue)\n }\n\n connect() {\n this.transitionCompleted = this.transitionedBeforeLoadValue\n\n if (!this.transitionCompleted) {\n this.activateRefresher()\n this.refresh()\n }\n }\n\n disconnect() {\n this.deactivateRefresher()\n }\n\n activateRefresher() {\n const refreshFrequencyInMs = 1000\n\n this.refresher = setInterval(() => {\n this.refresh()\n }, refreshFrequencyInMs)\n }\n\n deactivateRefresher() {\n if (this.refresher) {\n clearInterval(this.refresher)\n }\n }\n\n refresh() {\n const passedStartDate = this.checkStartDatePassed()\n\n if (passedStartDate && !this.transitionCompleted) {\n this.transition()\n this.deactivateRefresher()\n }\n }\n\n checkStartDatePassed() {\n const now = new Date()\n return (now >= this.eventStartsAt)\n }\n\n transition() {\n this.textTarget.textContent = this.nowTextValue\n this.transitionCompleted = true\n }\n}"], "mappings": "wKAAA,gDAEA,qBAAO,SAAsB,EAAW,CAStC,YAAa,CACX,KAAK,oBAAsB,EAC7B,CAEA,4BAA6B,CAC3B,KAAK,cAAgB,GAAI,MAAK,KAAK,mBAAmB,CACxD,CAEA,SAAU,CACR,KAAK,oBAAsB,KAAK,4BAE3B,KAAK,qBACR,MAAK,kBAAkB,EACvB,KAAK,QAAQ,EAEjB,CAEA,YAAa,CACX,KAAK,oBAAoB,CAC3B,CAEA,mBAAoB,CAGlB,KAAK,UAAY,YAAY,IAAM,CACjC,KAAK,QAAQ,CACf,EAAG,GAAoB,CACzB,CAEA,qBAAsB,CACpB,AAAI,KAAK,WACP,cAAc,KAAK,SAAS,CAEhC,CAEA,SAAU,CAGR,AAAI,AAFoB,KAAK,qBAAqB,GAE3B,CAAC,KAAK,qBAC3B,MAAK,WAAW,EAChB,KAAK,oBAAoB,EAE7B,CAEA,sBAAuB,CAErB,MAAQ,AADI,IAAI,OACD,KAAK,aACtB,CAEA,YAAa,CACX,KAAK,WAAW,YAAc,KAAK,aACnC,KAAK,oBAAsB,EAC7B,CACF,CA7DS,EADT,EACS,UAAU,CAAE,MAAO,GAEnB,EAHT,EAGS,SAAS,CACd,eAAgB,OAChB,QAAS,OACT,uBAAwB,CAAE,KAAM,QAAS,QAAS,EAAM,CAC1D", "names": [] }