// AUTO-GENERATED by stele — do not edit.
// Source of truth: locales/*.json

export type Locale = "en" | "es" | "pl";

export interface Stele {
  home: {
    greeting: (a: { name: string | number }) => string;
    nearby: (a: { count: number; radius: string | number }) => string;
    title: string;
  };
  inbox: {
    unread: (a: { count: number }) => string;
  };
  walk: {
    cta: {
      confirm: (a: { dogName: string | number }) => string;
      start: string;
    };
  };
}

const PCAT_SMALL: Record<Locale, string> = {
  "en": "o1oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "es": "o1oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "pl": "m1fffmmmmmmmmmmmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmm",
};
const PCAT_MOD: Record<Locale, string> = {
  "en": "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "es": "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "pl": "mmfffmmmmmmmmmmmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmm",
};

type Forms = Partial<Record<"zero" | "one" | "two" | "few" | "many" | "other", string>>;

// Baked from CLDR via ICU4X at generate time. Pure table lookup — never calls
// Intl.PluralRules (which Hermes / React Native does not implement).
const PCODE: Record<string, keyof Forms> = {
  z: "zero", "1": "one", "2": "two", f: "few", m: "many", o: "other",
};

function pluralCategory(locale: Locale, n: number): keyof Forms {
  const i = Math.abs(Math.trunc(n));
  const table = i < 100 ? PCAT_SMALL[locale] : PCAT_MOD[locale];
  return PCODE[table[i < 100 ? i : i % 100]];
}

function interp(t: string, a: Record<string, string | number>): string {
  return t.replace(/\{\{(\w+)\}\}/g, (_, k) => String(a[k]));
}

function plural(locale: Locale, forms: Forms, n: number, a: Record<string, string | number>): string {
  return interp(forms[pluralCategory(locale, n)] ?? forms.other ?? "", a);
}

const DATA: Record<Locale, Record<string, string | Forms>> = {
  "en": {
    "home.greeting": "Hey {{name}}, there are dogs nearby",
    "home.nearby": {
      "one": "{{count}} dog within {{radius}} of you",
      "other": "{{count}} dogs within {{radius}} of you"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "one": "{{count}} unread message",
      "other": "{{count}} unread messages"
    },
    "walk.cta.confirm": "Hold to confirm walking {{dogName}}",
    "walk.cta.start": "Start walk"
  },
  "es": {
    "home.greeting": "Hola {{name}}, hay perros cerca",
    "home.nearby": {
      "one": "{{count}} perro a {{radius}} de ti",
      "other": "{{count}} perros a {{radius}} de ti"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "one": "{{count}} mensaje sin leer",
      "other": "{{count}} mensajes sin leer"
    },
    "walk.cta.confirm": "Mantén pulsado para pasear a {{dogName}}",
    "walk.cta.start": "Empezar paseo"
  },
  "pl": {
    "home.greeting": "Cześć {{name}}, w pobliżu są psy",
    "home.nearby": {
      "few": "{{count}} psy w odległości {{radius}} od Ciebie",
      "many": "{{count}} psów w odległości {{radius}} od Ciebie",
      "one": "{{count}} pies w odległości {{radius}} od Ciebie",
      "other": "{{count}} psa w odległości {{radius}} od Ciebie"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "few": "{{count}} nieprzeczytane wiadomości",
      "many": "{{count}} nieprzeczytanych wiadomości",
      "one": "{{count}} nieprzeczytana wiadomość",
      "other": "{{count}} nieprzeczytanej wiadomości"
    },
    "walk.cta.confirm": "Przytrzymaj, aby potwierdzić spacer z {{dogName}}",
    "walk.cta.start": "Rozpocznij spacer"
  }
};

export function createStele(locale: Locale): Stele {
  const D = DATA[locale];
  return {
    home: {
      greeting: (a: { name: string | number }) => interp(D["home.greeting"] as string, a),
      nearby: (a: { count: number; radius: string | number }) => plural(locale, D["home.nearby"] as Forms, a.count, a),
      title: D["home.title"] as string,
    },
    inbox: {
      unread: (a: { count: number }) => plural(locale, D["inbox.unread"] as Forms, a.count, a),
    },
    walk: {
      cta: {
        confirm: (a: { dogName: string | number }) => interp(D["walk.cta.confirm"] as string, a),
        start: D["walk.cta.start"] as string,
      },
    },
  };
}
