// VYB LIFE — Social Privacy Foundation
// ─────────────────────────────────────────────────────────────────
// Step 1 scaffolding only. No Supabase calls, no public exposure.
// All flags here default to OFF. Future "Friends / Public Profile"
// features must read from these constants, not from inline guesses.
//
// DEVELOPER NOTES — Future public profile rules:
//  • Nothing is shared publicly unless the user explicitly opts in.
//  • Even when public profile is enabled, ONLY events listed in
//    SAFE_SOCIAL_EVENT_TYPES may ever be exposed. Habit content,
//    task content, idea text, reading entries, notes, page numbers,
//    book titles (if private), and any free-form text are NEVER
//    exposed by default.
//  • Path/Artifact unlocks are the canonical "safe" social signal:
//    they reveal effort/consistency without revealing personal text.
//  • Friend graph (when added) must be mutual-consent. No follower-
//    style asymmetric exposure in v1.
//  • All exposure must be revocable. Toggling Public Profile OFF
//    must hide previously-shared signals immediately on next read.
//  • Server-side enforcement is required — never rely on client
//    filtering alone. RLS policies must mirror these constants.
// ─────────────────────────────────────────────────────────────────

const SOCIAL_PRIVACY_DEFAULTS = {
  publicProfile: false,        // master switch — default OFF
  showActiveArtifact: false,   // show currently-equipped artifact
  showRarestArtifact: false,   // show highest-rarity unlocked artifact
  showPathProgress: false,     // show path stage counts (no content)
  showStreakBadges: false,     // show streak milestones (e.g. 7d/30d)
  allowFriendRequests: false,  // mutual-consent friend graph
  shareToFriendsFeed: false,   // push artifact unlocks to friends
};

// Whitelist of event types that MAY be exposed when publicProfile=true.
// Anything not in this list is private by default and forever.
const SAFE_SOCIAL_EVENT_TYPES = [
  'artifact_unlocked',     // {artifactId, rarity, timestamp}
  'path_stage_reached',    // {pathId, stageIndex, timestamp}
  'streak_milestone',      // {kind:'habit-week'|'habit-month', length}
  'rarity_tier_reached',   // {rarity:'Rare Signal'|'Prime Signal'|...}
];

// Helper: returns true if a given event type is allowed for public exposure.
// Use this on the client AND mirror with RLS on the server.
const isSafeSocialEvent = (eventType) =>
  SAFE_SOCIAL_EVENT_TYPES.indexOf(eventType) !== -1;

Object.assign(window, {
  SOCIAL_PRIVACY_DEFAULTS,
  SAFE_SOCIAL_EVENT_TYPES,
  isSafeSocialEvent,
});
