/**
 * Small, deterministic runtime facts for the shipped office environments.
 *
 * Activity robots are authored here rather than inferred from storey count. A
 * floor is geometry, not a staffing instruction: the SF studio should have one
 * useful machine, LA has two distinct work areas, and a building environment
 * still under construction should not wake a synthetic workforce merely
 * because it has levels. The extra job metadata is ignored by today's wander
 * controller but is deliberately carried beside `RobotSpec`, ready for the
 * robot-jobs runtime without changing stable robot ids.
 */

import type { Office } from "../interiors/types.ts";
import type { ShippedOfficeId } from "./sites.ts";

export type OfficeRobotJobSet = "studio-support" | "office-operations" | "model-review";

export interface OfficeActivityRobotSpec {
  id: string;
  levelId: string;
  /** Stable per-robot seed for a future job scheduler or replay harness. */
  seed: number;
  jobSet: OfficeRobotJobSet;
}

const OFFICE_ACTIVITY_ROBOTS: Readonly<Record<ShippedOfficeId, readonly OfficeActivityRobotSpec[]>> = {
  "lumbridge-hq": [
    { id: "sf-studio-activity-01", levelId: "level-1", seed: 0x53464851, jobSet: "studio-support" },
  ],
  "frontier-valley": [],
  "mateo-court": [
    { id: "la-office-activity-01", levelId: "level-1", seed: 0x4c414851, jobSet: "office-operations" },
    { id: "la-office-activity-02", levelId: "level-2", seed: 0x4c414852, jobSet: "model-review" },
  ],
};

/**
 * Resolve fresh specs and discard any whose authored level is absent.
 *
 * The level check keeps downloaded or locally modified packs safe, while fresh
 * objects stop one consumer's scheduler state from mutating the next scene or
 * determinism test.
 */
export function activityRobotsForOffice(
  office: Pick<Office, "id" | "levels">,
): OfficeActivityRobotSpec[] {
  const specs = OFFICE_ACTIVITY_ROBOTS[office.id as ShippedOfficeId] ?? [];
  const levels = new Set(office.levels.map((level) => level.id));
  return specs
    .filter((spec) => levels.has(spec.levelId))
    .map((spec) => ({ ...spec }));
}
