import {
  readVersionedPreference,
  writeVersionedPreference,
  clearVersionedPreference
} from "@open-mercato/shared/lib/browser/versionedPreference";
const LEGACY_HIDDEN_WIDGETS_KEY = "om:portal:dashboard:hidden";
const HIDDEN_WIDGETS_KEY_PREFIX = "om:portal:dashboard:hidden:v1:";
const HIDDEN_WIDGETS_VERSION = 1;
function buildHiddenWidgetsKey(orgSlug, userId) {
  return `${HIDDEN_WIDGETS_KEY_PREFIX}${orgSlug}:${userId}`;
}
function isStringArray(value) {
  return Array.isArray(value) && value.every((id) => typeof id === "string");
}
function loadHiddenWidgets(orgSlug, userId) {
  const hidden = readVersionedPreference(
    buildHiddenWidgetsKey(orgSlug, userId),
    HIDDEN_WIDGETS_VERSION,
    isStringArray,
    []
  );
  return new Set(hidden);
}
function saveHiddenWidgets(orgSlug, userId, hidden) {
  writeVersionedPreference(buildHiddenWidgetsKey(orgSlug, userId), HIDDEN_WIDGETS_VERSION, Array.from(hidden));
}
function clearLegacyHiddenWidgetsKey() {
  clearVersionedPreference(LEGACY_HIDDEN_WIDGETS_KEY);
}
export {
  clearLegacyHiddenWidgetsKey,
  loadHiddenWidgets,
  saveHiddenWidgets
};
//# sourceMappingURL=hiddenWidgetsStorage.js.map
