{"version":3,"file":"src_stimulus_controllers_dynamic_job-status-polling_controller_ts.230745037eaf5e91.js","mappings":"+OAGc,MAAOA,mCAAmCC,EAAAA,GAAxDC,WAAAA,G,oBASE,KAAAC,iBAA0B,CA6C5B,QArDS,KAAAC,QAAU,CAAC,WAAY,WAAY,WAAY,YAAa,QAAS,QACrE,KAAAC,OAAS,CAAEC,YAAa,CAAEC,KAAMC,QAASC,SAAS,GAAU,CASnEC,OAAAA,GACEC,KAAKC,SAAWC,aAAY,IAAMF,KAAKG,YAAYC,UAAU,IAC/D,CAEAC,UAAAA,GACEL,KAAKM,cACDN,KAAKO,mBAAqBP,KAAKR,iBACjCgB,OAAOC,QAAQC,MAEnB,CAEAC,uBAAAA,GACEX,KAAKM,cACLN,KAAKY,uBACP,CAEAN,WAAAA,GACEO,cAAcb,KAAKC,SACrB,CAEAW,qBAAAA,GACEZ,KAAKc,gBAAgBC,QACvB,CAEAC,uBAAAA,CAAwBC,GACtBC,YAAW,IAAMD,EAAQE,SAAS,GACpC,CAEAC,aAAAA,CAAcC,GACZA,EAAMC,iBACNtB,KAAKuB,WAAWF,EAAMG,OACxB,CAEAC,uBAAAA,CAAwBR,GACtBC,YAAW,KACTlB,KAAKuB,WAAWN,EAAQ,GACvB,IACL,CAEAM,UAAAA,CAAWN,GACTjB,KAAKR,iBAAkB,EACvBgB,OAAOkB,SAASC,KAAOV,EAAQU,IACjC,E","sources":["./src/stimulus/controllers/dynamic/job-status-polling.controller.ts"],"sourcesContent":["import { Controller } from '@hotwired/stimulus';\nimport { FrameElement } from '@hotwired/turbo';\n\nexport default class JobStatusPollingController extends Controller {\n static targets = ['finished', 'download', 'redirect', 'indicator', 'frame'];\n static values = { backOnClose: { type: Boolean, default: false } };\n\n declare readonly backOnCloseValue:boolean;\n declare readonly indicatorTarget:HTMLElement;\n declare readonly frameTarget:FrameElement;\n\n interval:ReturnType;\n userInteraction:boolean = false;\n\n connect() {\n this.interval = setInterval(() => this.frameTarget.reload(), 2000);\n }\n\n disconnect() {\n this.stopPolling();\n if (this.backOnCloseValue && !this.userInteraction) {\n window.history.back();\n }\n }\n\n finishedTargetConnected() {\n this.stopPolling();\n this.hideProgressIndicator();\n }\n\n stopPolling() {\n clearInterval(this.interval);\n }\n\n hideProgressIndicator() {\n this.indicatorTarget.remove();\n }\n\n downloadTargetConnected(element:HTMLLinkElement) {\n setTimeout(() => element.click(), 50);\n }\n\n redirectClick(event:PointerEvent) {\n event.preventDefault();\n this.followLink(event.target as HTMLLinkElement);\n }\n\n redirectTargetConnected(element:HTMLLinkElement) {\n setTimeout(() => {\n this.followLink(element);\n }, 2000);\n }\n\n followLink(element:HTMLLinkElement) {\n this.userInteraction = true;\n window.location.href = element.href;\n }\n}\n"],"names":["JobStatusPollingController","Controller","constructor","userInteraction","targets","values","backOnClose","type","Boolean","default","connect","this","interval","setInterval","frameTarget","reload","disconnect","stopPolling","backOnCloseValue","window","history","back","finishedTargetConnected","hideProgressIndicator","clearInterval","indicatorTarget","remove","downloadTargetConnected","element","setTimeout","click","redirectClick","event","preventDefault","followLink","target","redirectTargetConnected","location","href"],"sourceRoot":"webpack:///","x_google_ignoreList":[]}