updateModalToggles = (service, category) => {
    const state = globalObj._state;
    const {
        _allDefinedServices,
        _enabledServices,
        _preferencesModalExists
    } = state;

    const servicesInputs = globalObj._dom._serviceCheckboxInputs[category] || {};
    const categoryInput = globalObj._dom._categoryCheckboxInputs[category] || {};
    const allServiceNames = getKeys(_allDefinedServices[category]);

    // Clear previously enabled services
    _enabledServices[category] = [];

    if (isString(service)) {
        if (service === 'all') {

            // Enable all services
            _enabledServices[category].push(...allServiceNames);

            if (_preferencesModalExists) {
                for (let serviceName in servicesInputs) {
                    servicesInputs[serviceName].checked = true;
                    dispatchInputChangeEvent(servicesInputs[serviceName]);
                }
            }

        } else {

            // Enable only one service (if valid) and disable all the others
            if (elContains(allServiceNames, service))
                _enabledServices[category].push(service);

            if (_preferencesModalExists) {
                for (let serviceName in servicesInputs) {
                    servicesInputs[serviceName].checked = service === serviceName;
                    dispatchInputChangeEvent(servicesInputs[serviceName]);
                }
            }
        }
    } else if (isArray(service)) {
        for (let serviceName of allServiceNames) {
            const validService = elContains(service, serviceName);
            validService && _enabledServices[category].push(serviceName);

            if (_preferencesModalExists) {
                servicesInputs[serviceName].checked = validService;
                dispatchInputChangeEvent(servicesInputs[serviceName]);
            }
        }
    }

    const uncheckCategory = _enabledServices[category].length === 0;

    /**
     * Remove/add the category from acceptedCategories
     */
    state._acceptedCategories = uncheckCategory
        ? state._acceptedCategories.filter(cat => cat !== category)
        : unique([...state._acceptedCategories, category]);

    /**
     * If there are no services enabled in the
     * current category, uncheck the category
     */
    if (_preferencesModalExists) {
        categoryInput.checked = !uncheckCategory;
        dispatchInputChangeEvent(categoryInput);
    }
}
Update services state internally and tick/untick checkboxes
@param {string|string[]} service
@param {string} category