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KAAKgC,MAAQC,YAAW,KACtBC,MAAMP,EAAK,CACTQ,KAAML,EACND,OAAQA,IACPO,MAAMC,IAEPrC,KAAKC,QAAQgB,SAEToB,EAASC,EAIZ,IACCC,OAZJ,GAeyB,IAAxBvC,KAAKwC,iBACT,CAEDC,aACEC,aAAa1C,KAAKgC,MACnB,GC1BHrC,EAAYgD,SAAS,kBAAmBC,GAGxCjD,EAAYgD,SAAS,cAAeE,GAGpClD,EAAYgD,SAAS,oBAAqBG,GAG1CnD,EAAYgD,SAAS,sBAAuBI,E","sources":["webpack://app/./app/javascript/utils/rails_ujs.ts","webpack://app/./app/javascript/controllers/application.js","webpack://app/./app/javascript/controllers/change_duration_controller.js","webpack://app/./app/javascript/controllers/change_plan_controller.js","webpack://app/./app/javascript/controllers/change_plan_modal_controller.js","webpack://app/./app/javascript/controllers/record_reading_form_controller.ts","webpack://app/./app/javascript/controllers/index.js"],"sourcesContent":["import Rails from '@rails/ujs';\n\ntype CustomRails = typeof Rails & {\n replaceElement: (currentEl: HTMLElement, newEl: HTMLElement) => HTMLElement;\n nodeFromString: (str: string) => DocumentFragment;\n}\n\ndeclare global {\n interface Window {\n Rails: CustomRails;\n }\n}\n\nRails.start();\n\nif (window) {\n window.Rails = Rails as CustomRails;\n}\n\n// extra functions are from https://github.com/nefe/You-Dont-Need-jQuery/blob/master/README.md\n\n(Rails as CustomRails).replaceElement = function replaceElement (currentEl, newEl) {\n const parentNode = currentEl.parentNode;\n return parentNode.replaceChild(newEl, currentEl);\n};\n\n(Rails as CustomRails).nodeFromString = function (str) {\n const range = document.createRange();\n const parse = range.createContextualFragment.bind(range) as (fragment: string) => DocumentFragment;\n\n return parse(str);\n};\n","import { Application } from \"@hotwired/stimulus\"\n\nconst application = Application.start()\n\n// Configure Stimulus development experience\napplication.debug = false\nwindow.Stimulus = application\n\nexport { application }\n","import { Controller } from \"@hotwired/stimulus\"\n\n// Connects to data-controller=\"change-duration\"\nexport default class extends Controller {\n static targets = [\"durationSelect\"];\n\n form = this.element;\n\n submit(e) {\n if (!confirm(\"Are you sure you want to change your reading duration?\")) {\n e.preventDefault();\n e.stopPropagation();\n\n this.form.reset();\n }\n }\n\n changeSelection() {\n this.form.requestSubmit();\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\n// Connects to data-controller=\"change-plan\"\nexport default class extends Controller {\n modal = document.querySelector('.change-plan-modal');\n\n click() {\n if (!this.modal) return;\n\n this.modal.classList.add('show');\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\n// Connects to data-controller=\"change-plan-modal\"\nexport default class extends Controller {\n static targets = ['newPlanName', 'form'];\n\n modal = document.querySelector('.change-plan-modal');\n\n close() {\n this.modal.classList.remove('show');\n }\n\n selectPlan(event) {\n const confirmed = confirm(`Are you sure you want to change to plan ${event.target.dataset.planName}?`);\n\n if (confirmed) {\n this.newPlanNameTarget.value = event.target.dataset.planName;\n this.formTarget.submit();\n }\n }\n}\n","import { Controller } from \"@hotwired/stimulus\"\n\nexport default class extends Controller {\n private timer: NodeJS.Timer = null\n\n timeoutInSeconds = 10\n\n connect() {\n const url = this.element.action;\n const method = this.element.method;\n const data = new FormData(this.element);\n\n this.timer = setTimeout(() => {\n fetch(url, {\n body: data,\n method: method,\n }).then((response) => {\n // if the form is recorded before the request is made, the request will never be made\n this.element.remove();\n\n if (response.ok) {\n // recorded successfully\n } else {\n // failed to record\n }\n }, (_error) => {\n // failed to record\n });\n }, this.timeoutInSeconds * 1000);\n }\n\n disconnect() {\n clearTimeout(this.timer);\n }\n}\n","// This file is auto-generated by ./bin/rails stimulus:manifest:update\n// Run that command whenever you add a new controller or create them with\n// ./bin/rails generate stimulus controllerName\n\nimport { application } from \"./application\"\n\nimport ChangeDurationController from \"./change_duration_controller\"\napplication.register(\"change-duration\", ChangeDurationController)\n\nimport ChangePlanController from \"./change_plan_controller\"\napplication.register(\"change-plan\", ChangePlanController)\n\nimport ChangePlanModalController from \"./change_plan_modal_controller\"\napplication.register(\"change-plan-modal\", ChangePlanModalController)\n\nimport RecordReadingFormController from \"./record_reading_form_controller\"\napplication.register(\"record-reading-form\", RecordReadingFormController)\n"],"names":["Rails","window","currentEl","newEl","parentNode","replaceChild","str","range","document","createRange","createContextualFragment","bind","parse","application","Application","debug","Stimulus","Controller","this","element","submit","e","confirm","preventDefault","stopPropagation","form","reset","changeSelection","requestSubmit","querySelector","click","modal","classList","add","close","remove","selectPlan","event","target","dataset","planName","newPlanNameTarget","value","formTarget","connect","url","action","method","data","FormData","timer","setTimeout","fetch","body","then","response","ok","_error","timeoutInSeconds","disconnect","clearTimeout","register","ChangeDurationController","ChangePlanController","ChangePlanModalController","RecordReadingFormController"],"sourceRoot":""}