{"version":3,"sources":["webpack:///./app/javascript/src/date_select_wrapper.jsx"],"names":["initialSelectedDates","campForm","document","querySelector","campEventType","initialHiddenFieldValues","_initialHiddenFieldVa","dataset","selected","JSON","parse","Date","addEventListener","event","value","render","React","createElement","InfiniteCalendar","Component","withMultipleDates","Calendar","_toConsumableArray","interpolateSelection","defaultMultipleDateInterpolation","ref","pageComponent","window","onSelect","dateSelection","startDateField","getElementById","endDateField","sessionDatesField","selectedDatesArr","state","includes","filter","item","push","startDate","sort","a","b","Number","endDate","at","allSessionDates","Set","length","calValidation","innerHTML","classList","remove","add","calendar","displayOptions","showTodayHelper","showOverlay","withRange","height","minDate","start","end","eventType"],"mappings":"s2BAIA,IAGIA,EAHAC,EAAWC,SAASC,cAAc,cAClCC,EAAgBF,SAASC,cAAc,oBACvCE,EAA2BH,SAASC,cAAc,oBAIpDH,EAD0B,OAAxBK,QAAwB,IAAxBA,GAAiC,QAATC,EAAxBD,EAA0BE,eAAO,IAAAD,GAAjCA,EAAmCE,SACdC,KAAKC,MAAML,EAAyBE,QAAQC,UAE5C,CAAC,IAAIG,MAG1BP,IACFA,EAAcQ,iBAAiB,UAAU,SAACC,GACpCZ,GAAmC,YAAvBG,EAAcU,MAC5BC,iBACEC,IAAAC,cAACC,IAAgB,CACfC,UAAWC,YAAkBC,KAC7Bb,SAAQc,EACHtB,GAELuB,qBAAsBC,IACtBC,IAAK,SAACC,GAAmBC,OAAOD,cAAgBA,CAAa,EAC7DE,SAAU,SAASC,GAEjB,IAAIC,EAAiB5B,SAAS6B,eAAe,mBACzCC,EAAe9B,SAAS6B,eAAe,iBACvCE,EAAoB/B,SAAS6B,eAAe,mBAC5CG,EAAgBZ,EAAOK,OAAOD,cAAcS,MAAM3B,UAClD0B,EAAiBE,SAASP,GAC5BK,EAAmBA,EAAiBG,QAAO,SAAAC,GAAI,OAAIA,GAAQT,CAAa,IAExEK,EAAiBK,KAAK,IAAI5B,KAAKkB,IAGjC,IAAIW,GADJN,EAAmBA,EAA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\nimport { render } from \"react-dom\";\nimport InfiniteCalendar, { Calendar, withRange, withMultipleDates, defaultMultipleDateInterpolation } from \"react-infinite-calendar\";\n\nlet campForm = document.querySelector(\".camp-form\");\nlet campEventType = document.querySelector(\"#camp_event_type\");\nlet initialHiddenFieldValues = document.querySelector(\"#session_dates__\");\nlet initialSelectedDates;\n\nif (initialHiddenFieldValues?.dataset?.selected){ \n initialSelectedDates = JSON.parse(initialHiddenFieldValues.dataset.selected);\n} else {\n initialSelectedDates = [new Date()];\n} \n\nif (campEventType) {\n campEventType.addEventListener('change', (event) => {\n if (campForm && campEventType.value == 'sessions') {\n render(\n {window.pageComponent = pageComponent}}\n onSelect={function(dateSelection) {\n\n let startDateField = document.getElementById(\"camp_start_date\");\n let endDateField = document.getElementById(\"camp_end_date\");\n let sessionDatesField = document.getElementById(\"session_dates__\");\n let selectedDatesArr = [...window.pageComponent.state.selected];\n if (selectedDatesArr.includes(dateSelection)){\n selectedDatesArr = selectedDatesArr.filter(item => item != dateSelection)\n } else {\n selectedDatesArr.push(new Date(dateSelection));\n }\n selectedDatesArr = selectedDatesArr.sort((a,b)=> Number(a)-Number(b))\n let startDate = selectedDatesArr[0];\n let endDate = selectedDatesArr.at(-1);\n let allSessionDates = [...new Set(selectedDatesArr)]\n\n if (allSessionDates.length < 1) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set an end date below - for a one day camp, double click your desired date.';\n }\n\n if (allSessionDates.length > 1) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n sessionDatesField.value = allSessionDates;\n\n if (startDate <= endDate) {\n startDateField.value = startDate;\n endDateField.value = endDate;\n sessionDatesField.value = allSessionDates;\n calValidation.classList.add(\"valid\");\n calValidation.innerHTML =\n ' Success!';\n } else {\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set a date below.';\n }\n }\n }}\n />,\n calendar\n );\n } else {\n render(\n To save your event successfully set an end date below - for a one day camp, double click your desired date.';\n }\n if (dateSelection.eventType == 3) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n if (dateSelection.start <= dateSelection.end) {\n startDateField.value = dateSelection.start;\n endDateField.value = dateSelection.end;\n calValidation.classList.add(\"valid\");\n calValidation.innerHTML =\n ' Success!';\n } else {\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set a date below.';\n }\n }\n }}\n />,\n calendar\n );\n }\n });\n\n if (campForm && campEventType.value == 'sessions') {\n render(\n {window.pageComponent = pageComponent}}\n onSelect={function(dateSelection) {\n let startDateField = document.getElementById(\"camp_start_date\");\n let endDateField = document.getElementById(\"camp_end_date\");\n let sessionDatesField = document.getElementById(\"session_dates__\");\n let selectedDatesArr = [...window.pageComponent.state.selected];\n if (selectedDatesArr.includes(dateSelection)){\n selectedDatesArr = selectedDatesArr.filter(item => item != dateSelection)\n } else {\n selectedDatesArr.push(new Date(dateSelection));\n }\n selectedDatesArr = selectedDatesArr.sort((a,b)=> Number(a)-Number(b))\n let startDate = selectedDatesArr[0];\n let endDate = selectedDatesArr.at(-1);\n let allSessionDates = [...new Set(selectedDatesArr)]\n if (allSessionDates.length < 1) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set an end date below - for a one day camp, double click your desired date.';\n }\n\n if (allSessionDates.length > 1) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n sessionDatesField.value = allSessionDates;\n if (startDate <= endDate) {\n startDateField.value = startDate;\n endDateField.value = endDate;\n sessionDatesField.value = allSessionDates;\n calValidation.classList.add(\"valid\");\n calValidation.innerHTML =\n ' Success!';\n } else {\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set a date below.';\n }\n }\n }}\n />,\n calendar\n );\n } else {\n render(\n To save your event successfully set an end date below - for a one day camp, double click your desired date.';\n }\n if (dateSelection.eventType == 3) {\n let calValidation = document.getElementById(\n \"calendar-validation-message\"\n );\n calValidation.innerHTML = \"\";\n calValidation.classList.remove(\"valid\");\n if (dateSelection.start <= dateSelection.end) {\n startDateField.value = dateSelection.start;\n endDateField.value = dateSelection.end;\n calValidation.classList.add(\"valid\");\n calValidation.innerHTML =\n ' Success!';\n } else {\n calValidation.classList.add(\"invalid\");\n calValidation.innerHTML =\n ' To save your event successfully set a date below.';\n }\n }\n }}\n />,\n calendar\n );\n }\n}\n\n"],"sourceRoot":""}