function saveSettings(settings) {
  const storage = {
    /** @type {Record<string, boolean>} */
    [STORAGE_KEYS.Categories]: {},
    /** @type {Record<string, string>} */
    [STORAGE_KEYS.Settings]: {},
  };

  // Stash selected categories.
  DEFAULT_CATEGORIES.forEach(category => {
    const enabled = settings.selectedCategories.includes(category.id);
    storage[STORAGE_KEYS.Categories][category.id] = enabled;
  });

  // Stash device setting.
  storage[STORAGE_KEYS.Settings].device = settings.device;

  // Stash backend setting.
  storage[STORAGE_KEYS.Settings].backend = settings.backend;

  storage[STORAGE_KEYS.Settings].locale = settings.locale;

  // Save object to chrome local storage.
  chrome.storage.local.set(storage);
}
Save currently selected set of category categories to local storage.
@param {Settings} settings