{"version":3,"file":"tunnel.js","sources":["../../node_modules/mdn-polyfills/Array.from.js","../../sources/javascripts/utils/extend.js","../../node_modules/mdn-polyfills/Element.prototype.closest.js","../../sources/javascripts/tunnel/StepForm/StepForm.js","../../sources/javascripts/tunnel/StepForm/lifecycle.js","../../sources/javascripts/tunnel/StepForm/contactFormApplicationMessage.js","../../sources/javascripts/tunnel/AgencySelect/lifecycle.js"],"sourcesContent":["!function(){var t,u,e,c;Array.from||(Array.from=(t=Object.prototype.toString,u=function(r){return\"function\"==typeof r||\"[object Function]\"===t.call(r)},e=Math.pow(2,53)-1,c=function(r){var t,n=(t=Number(r),isNaN(t)?0:0!==t&&isFinite(t)?(0 {},\n onSectionHide: () => {},\n },\n },\n settings || {}\n );\n\n _.$sections = _.$form.querySelectorAll(_.settings.stepsSectionSelector);\n _.$nexts = _.$form.querySelectorAll(_.settings.navNextSelector);\n _.$submits = _.$form.querySelectorAll('[type=\"submit\"]');\n\n _.currentSectionIndex = null;\n\n _.handleNextClick = _.handleNextClick.bind(_);\n _.handleSubmitClick = _.handleSubmitClick.bind(_);\n\n if (\n _.settings.startIndex !== 0 &&\n _.settings.startIndex > _.$sections.length + 1\n ) {\n _.settings.startIndex = 0;\n }\n }\n\n mount() {\n const _ = this;\n\n for (let i = 0; i < _.$sections.length; i++) {\n _.$sections[i].style.display = \"none\";\n }\n\n for (let i = 0; i < _.$nexts.length; i++) {\n _.$nexts[i].addEventListener(\"click\", _.handleNextClick);\n }\n for (let i = 0; i < _.$submits.length; i++) {\n _.$submits[i].addEventListener(\"click\", _.handleSubmitClick);\n }\n\n _.displaySection(_.currentSectionIndex || _.settings.startIndex);\n }\n\n dismount() {\n const _ = this;\n\n for (let i = 0; i < _.$sections.length; i++) {\n _.$sections[i].style.display = \"\";\n }\n\n for (let i = 0; i < _.$nexts.length; i++) {\n _.$nexts[i].removeEventListener(\"click\", _.handleNextClick);\n }\n for (let i = 0; i < _.$submits.length; i++) {\n _.$submits[i].removeEventListener(\"click\", _.handleSubmitClick);\n }\n }\n\n displaySection(index, withScroll = false) {\n const _ = this;\n\n if (_.currentSectionIndex !== null) {\n _.hideSection(_.currentSectionIndex);\n }\n\n _.currentSectionIndex = index;\n _.$sections[_.currentSectionIndex].style.display = \"\";\n\n _.settings.callbacks.onSectionDisplay(_, index);\n\n if (withScroll) {\n _.$sections[_.currentSectionIndex].scrollIntoView();\n }\n }\n\n hideSection(index) {\n const _ = this;\n\n _.$sections[index].style.display = \"none\";\n _.currentSectionIndex = null;\n\n _.settings.callbacks.onSectionHide(_, index);\n }\n\n handleNextClick(e) {\n const _ = this;\n\n e.preventDefault();\n\n if (_.checkSectionValidity(_.currentSectionIndex)) {\n _.displaySection(_.currentSectionIndex + 1, true);\n } else {\n _.$form.reportValidity();\n }\n }\n\n handleSubmitClick(e) {\n /* global grecaptcha */\n const _ = this;\n const useRecaptcha =\n e.currentTarget.getAttribute(\"data-recaptcha\") !== null;\n\n e.preventDefault();\n\n if (_.checkSectionValidity(_.currentSectionIndex)) {\n if (useRecaptcha) {\n grecaptcha.execute();\n } else {\n _.$form.submit();\n }\n } else {\n _.$form.reportValidity();\n }\n }\n\n checkSectionValidity(index) {\n const _ = this;\n\n const $inputs = _.$sections[index].querySelectorAll(\n \"input, textarea, select\"\n );\n for (let i = 0; i < $inputs.length; i++) {\n if (!$inputs[i].checkValidity()) {\n return false;\n }\n }\n\n return true;\n }\n}\n","import 'mdn-polyfills/Element.prototype.closest';\nimport StepForm from './StepForm';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n const $form = document.querySelector('.js-stepform');\n\n if ($form) {\n const $progressTrack = document.querySelector('.js-tunnel-progress-track');\n const $errors = $form.querySelectorAll('.c-form__field.has-error');\n let startIndex = 0;\n\n if ($errors.length) {\n startIndex = Array.from($form.querySelectorAll('.js-stepform-section')).indexOf($errors[0].closest('.js-stepform-section'));\n }\n\n const form = new StepForm($form, {\n stepsSectionSelector: '.js-stepform-section',\n navNextSelector: '.js-stepform-next',\n startIndex,\n callbacks: {\n onSectionDisplay: (instance, index) => {\n if ($progressTrack) {\n $progressTrack.style.width = `${((index + 1) / (instance.$sections.length + 1)) * 100}%`;\n }\n },\n },\n });\n\n form.mount();\n }\n});\n","let selectStatus = document.querySelector(\"#form_602fb877c15ab #position\");\nlet selectSuject = document.querySelector(\"#form_602fb877c15ab #subject\");\nconst applicationMessage = document.querySelector(\n \"#form_602fb877c15ab .application_message\"\n);\n\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n if (selectStatus) {\n selectStatus.addEventListener(\"change\", (e) => {\n if (\n selectStatus.value == \"Étudiant\" ||\n selectStatus.value == \"En recherche d'emploi\"\n ) {\n applicationMessage.classList.remove(\"hide\");\n } else {\n applicationMessage.classList.add(\"hide\");\n }\n });\n }\n\n if (selectSuject) {\n selectSuject.addEventListener(\"change\", (e) => {\n if (\n selectSuject.value == \"Candidature spontanée\" ||\n selectSuject.value == \"Recherche de stage/alternance\"\n ) {\n applicationMessage.classList.remove(\"hide\");\n } else {\n applicationMessage.classList.add(\"hide\");\n }\n });\n }\n});\n","document.addEventListener('DOMContentLoaded', () => {\n const $zipInput = document.querySelector('.js-agencyselect-zip input');\n const $select = document.querySelector('.js-agencyselect-select select');\n const list = window.agenciesByDepartment || {};\n const originalOptionsHTML = $select?.innerHTML;\n const $placeholderOption = $select?.querySelector('option[value=\"\"]');\n let previousSet = 'original';\n\n function updateSelect() {\n // Extracts department from user input\n const department = $zipInput.value.substr(0, 2);\n\n if (department in list) {\n // Updates options if we have entries for the matching department\n if (previousSet !== department) {\n $select.innerHTML = '';\n\n // Creates an array of