public function setCalendarEventData(array $data = [], ?EntityInterface $calendar = null): array
    {
        $result = [
            'CalendarEvents' => [],
        ];

        $result['CalendarEvents'] = $data;
        if (!empty($data['recurrence'])) {
            $recurrence = $this->setRRuleConfiguration($data['recurrence']);
            $result['CalendarEvents']['is_recurring'] = true;
            $result['CalendarEvents']['recurrence'] = $recurrence;
        }

        if (!empty($data['attendees_ids'])) {
            $result['calendar_attendees']['_ids'] = $data['attendees_ids'];
            unset($result['CalendarEvents']['attendees_ids']);
        }

        if (empty($data['title']) && $calendar instanceof EntityInterface) {
            $result['CalendarEvents']['title'] = $this->setEventTitle($data, $calendar);
        }

        return $result;
    }