function handlePurposes($content){var activePurposes=[],$checkedBookingType=$("#reservation-bookingtype input:checked",$content),$selectedUser=$("#reservation-user option:selected",$content);if($checkedBookingType.length){var bookingTypePurposesStr=$checkedBookingType.data("purposes")+"";if(bookingTypePurposesStr)for(var bookingTypePurposes=bookingTypePurposesStr.split(","),i=0;i<bookingTypePurposes.length;i++)!activePurposes.includes(bookingTypePurposes[i])&&bookingTypePurposes[i]!=""&&activePurposes.push(bookingTypePurposes[i])}if($selectedUser.length){var userPurposesStr=$selectedUser.data("purposes")+"";if(userPurposesStr)for(var userPurposes=userPurposesStr.split(","),i=0;i<userPurposes.length;i++)!activePurposes.includes(userPurposes[i])&&userPurposes[i]!=""&&activePurposes.push(userPurposes[i])}var $allOptions=$("#reservation-purpose option",$content);$allOptions.each(function(i2){var $option=$($allOptions[i2]),uid=$option.val();$option.show(),uid&&!activePurposes.includes(uid)&&$option.hide()}),$("#reservation-purpose",$content).parents(".fancyInput").show(),activePurposes.length||$("#reservation-purpose",$content).parents(".fancyInput").hide()}handlePurposes($(document));$(document).on("change","#reservation-bookingtype input",function(e){handlePurposes($(document))});$(document).on("change","#reservation-user",function(e){handlePurposes($(document))});function checkReservationType($content){var $checkboxes=$('.ig-radio input[name="tx_igreservations_ajax[reservation][event][reservationTypes][]"], .ig-radio input[name="tx_igreservations_eventtodo[event][reservationTypes][]"]',$content);$checkboxes.is(":checked")?($checkboxes.attr("required",!1),$checkboxes.prop("required",!1)):($checkboxes.attr("required",!0),$checkboxes.prop("required",!0))}checkReservationType();$(document).on("change",'.ig-radio input[name="tx_igreservations_eventtodo[reservation][event][reservationTypes][]"], .ig-radio input[name="tx_igreservations_eventtodo[event][reservationTypes][]"]',function(e){checkReservationType()});export{checkReservationType,handlePurposes};
