// Examples alternate between physical assets and intellectual/participation assets.
// The classification is only used to arrange the sequence, never shown as copy.
const examples = {
  property: ['املاک و مستغلات', 'Real estate', '#65d8ed', '#14788d'],
  startup: ['استارتاپ', 'Startups', '#bb9bff', '#7951b8'],
  solar: ['نیروگاه خورشیدی', 'Solar power plants', '#f2be73', '#916014'],
  intellectual: ['مالکیت فکری', 'Intellectual property', '#e9a3dd', '#a04490'],
  renewable: ['انرژی‌های تجدیدپذیر', 'Renewable energy', '#6fe0b5', '#247b5b'],
  knowledge: ['شرکت دانش‌بنیان', 'Knowledge-based companies', '#8faeff', '#456ac1'],
  art: ['آثار هنری', 'Works of art', '#f4a489', '#a95032'],
  research: ['پروژه‌های تحقیقاتی', 'Research projects', '#c2a3f4', '#7951b8'],
  gold: ['طلا', 'Gold', '#e8ce77', '#826519'],
  development: ['مشارکت در توسعه', 'Development participation', '#8cd6e2', '#1a7889'],
  agriculture: ['کشاورزی', 'Agriculture', '#b3d889', '#50792a'],
  network: ['مشارکت در توسعه شبکه پلانک', 'Planck network development', '#6fddd0', '#187d73'],
  oil: ['نفت', 'Oil', '#eca48f', '#a9553d'],
  metals: ['فلزات گران‌بها', 'Precious metals', '#b7c8eb', '#586e9b'],
} as const;

// Repeat two intellectual/participation examples to keep the alternation at the loop seam.
export const HERO_ASSETS = [
  'property', 'startup', 'solar', 'intellectual', 'renewable', 'knowledge', 'art', 'research',
  'gold', 'development', 'agriculture', 'network', 'oil', 'intellectual', 'metals', 'network',
].map((key, index) => {
  const [fa, en, color, lightColor] = examples[key as keyof typeof examples];
  return {key, fa, en, color, lightColor, kind: index % 2 ? 'intellectual' : 'physical'};
});

export const HERO_ASSET_DURATION = 4400;
export const HERO_ASSET_FADE = 700;
const smooth = (value: number) => {const t = Math.max(0, Math.min(1, value));return t * t * (3 - 2 * t)};

// Both the map highlight and its caption use Orbit's pausable clock.
export function heroAssetFrame(elapsedMs: number, reducedMotion = false) {
  const elapsed = Math.max(0, elapsedMs);
  const index = reducedMotion ? 0 : Math.floor(elapsed / HERO_ASSET_DURATION) % HERO_ASSETS.length;
  const time = elapsed % HERO_ASSET_DURATION;
  const opacity = reducedMotion ? 1 : smooth(Math.min(time, HERO_ASSET_DURATION - time) / HERO_ASSET_FADE);
  return {index, item: HERO_ASSETS[index], opacity};
}
