// stand-in data for the welcome flow. the appview fills these from
// OnboardingSocial / OnboardingKeys; nothing here is wired to an api yet, so the
// step components read from this module and a real load later replaces it.

import type { PersonData, RepoCardData } from "$lib/components/profile/types";

export interface MockKey {
	id: number;
	name: string;
	fingerprint: string;
	createdAt: string;
}

const did = (name: string) => `did:plc:${name.replace(/[^a-z0-9]/g, "")}welcome`;

/** OnboardingSocial's People — suggested accounts to follow */
export const people: PersonData[] = [
	{
		did: did("alphaone"),
		handle: "alpha.one",
		description: "Innovative coder at tangled.org, passionate about sustainable tech.",
		followers: 1100,
		following: 99
	},
	{
		did: did("betaspace"),
		handle: "beta.space",
		description: "Rust and Go enthusiast, creating pixel art and exploring plant-based living.",
		followers: 987,
		following: 78
	},
	{
		did: did("gammanetwork"),
		handle: "gamma.network",
		description: "Co-founder of EcoTech Labs, blending software with environmental solutions.",
		followers: 1700,
		following: 25
	}
];

/** OnboardingSocial's TrendingRepos */
export const trendingRepos: RepoCardData[] = [
	{
		rkey: "welcome-1",
		name: "core",
		repoDid: did("tangledorg"),
		ownerHandle: "tangled.org",
		description: "A decentralized network for secure and scalable data storage.",
		createdAt: "2026-05-02T10:00:00Z",
		language: "Go",
		stars: 2200,
		issues: 31,
		pulls: 1
	},
	{
		rkey: "welcome-2",
		name: "batman.vim",
		repoDid: did("072004xyz"),
		ownerHandle: "072004.xyz",
		description: "A Vim colourscheme that only works at night.",
		createdAt: "2026-04-18T10:00:00Z",
		language: "Vim Script",
		stars: 412,
		issues: 3,
		pulls: 2
	},
	{
		rkey: "welcome-3",
		name: "knotserver",
		repoDid: did("coopppage"),
		ownerHandle: "coop.page",
		description: "Self-hostable git remote that speaks the Tangled protocol.",
		createdAt: "2026-03-09T10:00:00Z",
		language: "Rust",
		stars: 856,
		issues: 12,
		pulls: 4
	}
];

/** OnboardingKeys' PubKeys — starts empty, the step adds to it */
export const initialKeys: MockKey[] = [];

/**
 * Builds the row the appview would get back from `PUT /settings/keys`. It lives
 * here rather than in draft.svelte.ts because svelte/prefer-svelte-reactivity
 * rejects a plain `Date` inside a rune module, and this one is a throwaway — the
 * timestamp is read once, never held.
 */
export const newKey = (id: number, name: string, key: string): MockKey => ({
	id,
	name,
	fingerprint: `SHA256:${key.slice(-32)}`,
	createdAt: new Date().toISOString()
});
