import { RotateCcw } from "lucide-react"; import type { AllSetting, ModuleSetting } from "@/lib/api"; import { cn } from "@/lib/utils"; import { useT, type Key } from "@/i18n"; /** The collection and convenience switches of the client compatibility part (the same file holds them under either name). */ const SWITCHES: { name: string; label: Key; text: Key }[] = [ { name: "UnlockLocalAppearanceCatalog", label: "col.appearances", text: "col.appearances.text" }, { name: "UnlockAllVanity", label: "col.vanity", text: "col.vanity.text" }, { name: "AutoCollectAppearances", label: "col.auto", text: "col.auto.text" }, { name: "LearnOwnedCompanions", label: "col.companions", text: "col.companions.text" }, { name: "MaxRidingFromStart", label: "col.riding", text: "col.riding.text" }, ]; export interface Collection { item: ModuleSetting; label: Key; text: Key; } /** The switches the compatibility file actually has; an older build without the file offers none. */ export function collectionsOf(items: ModuleSetting[]): Collection[] { return SWITCHES.flatMap((s) => { const item = items.find((i) => i.key.endsWith("." + s.name)); return item ? [{ item, label: s.label, text: s.text }] : []; }); } const ROW = "grid grid-cols-[1fr_auto] items-start gap-x-6 gap-y-1 py-3.5"; /** Appearances (transmog), vanity and a few solo conveniences, in the look of every other setting row. */ export function CollectionRows(props: { items: Collection[]; edits: Record; onChange: (key: string, value: string | null) => void }) { const t = useT(); return (
{props.items.map(({ item, label, text }) => { const value = props.edits[item.key] ?? item.value; const on = value.trim() === "1"; return (

{t(text)}

); })}
); } /** Documented world server settings that have no friendlier control: the name, its explanation, a text box. */ export function RawRows(props: { items: AllSetting[]; edits: Record; onChange: (key: string, value: string | null) => void }) { const t = useT(); return (
{props.items.map((s) => { const value = props.edits[s.key] ?? s.value; const set = (v: string) => props.onChange(s.key, v === s.value ? null : v); return (

{s.doc}

{t("set.default", { v: s.default })}

set(e.target.value)} className="selectable w-56 rounded-md border border-line bg-bg px-3 py-2 text-sm outline-none focus:border-gold" />
); })}
); }