// real comment data pulled from tangled.org/tangled.org/core/issues/245, used across
// the comment stories so the fixtures live in one place.
import type { MarkupContext } from "$lib/markup";
import type { CommentThread, CommentView } from "./comments";

export const sampleMarkup: MarkupContext = {
	repo: "tangled.org/core",
	ref: "main",
	host: "tangled.org"
};

export const sampleSubjectUri = "at://did:plc:xan/sh.tangled.repo.issue/245";
export const sampleSubjectCid = "bafyreib2rxk3rh6kzwq6yhkp6bd4vjxj3xj2xj2xj2xj2xj2xj2xj2xj4";

const cid = "bafyreib2rxk3rh6kzwq6yhkp6bd4vjxj3xj2xj2xj2xj2xj2xj2xj2xj2";

const c = (
	rkey: string,
	authorDid: string,
	authorHandle: string,
	createdAt: string,
	body: string,
	bodyHtml: string
): CommentView => ({
	uri: `at://${authorDid}/sh.tangled.feed.comment/${rkey}`,
	cid,
	rkey,
	authorDid,
	authorHandle,
	createdAt,
	body,
	bodyHtml
});

export const sampleComments = {
	byjp: c(
		"byjp",
		"did:plc:byjp",
		"byjp.me",
		"2024-10-02T09:15:00Z",
		`I'm on the cusp, but I reacted "👎", as:

- I quite like the "@"!
- it clearly differentiates between user stuff, and site stuff; \`tangled.org/settings\` vs. \`tangled.org/@settings.in\`
- it feels quite "ATProto" to have an AT☺️

Plus I think I'd keep the @s in the UI anyway (eg. in the header of a repo page "[@tangled.org](/tangled.org)/core") — so then the URLs would match what's displayed.`,
		`<p>I'm on the cusp, but I reacted "👎", as:</p>
<ul>
<li>I quite like the "@"!</li>
<li>it clearly differentiates between user stuff, and site stuff; <code>tangled.org/settings</code> vs. <code>tangled.org/@settings.in</code></li>
<li>it feels quite "ATProto" to have an AT☺️</li>
</ul>
<p>Plus I think I'd keep the @s in the UI anyway (eg. in the header of a repo page "<a href="/tangled.org">@tangled.org</a>/core") — so then the URLs would match what's displayed.</p>`
	),
	cam: c(
		"cam",
		"did:plc:cam",
		"camsmith.dev",
		"2024-10-02T11:00:00Z",
		`I also found these two reasons convincing enough to vote in favor of removal.

One small, silly side effect of this will be that the address for tangled itself will be tangled.org/tangled.org`,
		`<p>I also found these two reasons convincing enough to vote in favor of removal.</p>
<p>One small, silly side effect of this will be that the address for tangled itself will be tangled.org/tangled.org</p>`
	),
	samuel: c(
		"samuel",
		"did:plc:samuel",
		"samuel.fm",
		"2024-10-03T08:20:00Z",
		"I vote removing them. You can tell if it's a handle by the presence of the `.`s",
		"<p>I vote removing them. You can tell if it's a handle by the presence of the <code>.</code>s</p>"
	),
	moth: c(
		"moth",
		"did:plc:moth",
		"moth11.net",
		"2024-10-03T14:05:00Z",
		"i vote yes, i'm probably stupid but i dont think go modules like there being @s in the url so i just use github, i'm sure theres a way around it, but its best to minimize friction",
		"<p>i vote yes, i'm probably stupid but i dont think go modules like there being @s in the url so i just use github, i'm sure theres a way around it, but its best to minimize friction</p>"
	),
	anirudh: c(
		"anirudh",
		"did:plc:anirudh",
		"anirudh.fi",
		"2024-10-04T10:00:00Z",
		"For what it's worth, we've always supported the non-@ URL as well. We just redirect it to the @'d version—which Go seems to be content with.",
		"<p>For what it's worth, we've always supported the non-@ URL as well. We just redirect it to the @'d version—which Go seems to be content with.</p>"
	),
	knowtheory: c(
		"knowtheory",
		"did:plc:knowtheory",
		"knowtheory.net",
		"2024-10-05T16:30:00Z",
		`So i'm a 👍 I dig the poetry of having an @ in the URI, but mostly i think it's confusing. This isn't a practice the other Apps & AppServers use. It's also confusing because an AT:// URI is something distinct and different.

And just personally, it's a URL eyesore for me.`,
		`<p>So i'm a 👍 I dig the poetry of having an @ in the URI, but mostly i think it's confusing. This isn't a practice the other Apps &amp; AppServers use. It's also confusing because an AT:// URI is something distinct and different.</p>
<p>And just personally, it's a URL eyesore for me.</p>`
	),
	anil: c(
		"anil",
		"did:plc:anil",
		"anil.recoil.org",
		"2024-11-10T12:00:00Z",
		"This has tripped me up quite a few times on the SSH URLs with extraneous @s, so thank you for making this change!",
		"<p>This has tripped me up quite a few times on the SSH URLs with extraneous @s, so thank you for making this change!</p>"
	),
	// authored by the story's logged-in user (MockAuthProvider = did:plc:alice), for edit cases
	mine: c(
		"mine",
		"did:plc:alice",
		"alice.pds.tngl.boltless.dev",
		"2024-10-06T09:00:00Z",
		"I vote removing them. You can tell if it's a handle by the presence of the `.`s",
		"<p>I vote removing them. You can tell if it's a handle by the presence of the <code>.</code>s</p>"
	)
};

// a top-level comment on its own
export const soloThread: CommentThread = { self: sampleComments.byjp, replies: [] };

// a thread with a couple of replies
export const sampleThread: CommentThread = {
	self: sampleComments.byjp,
	replies: [sampleComments.cam, sampleComments.samuel]
};

export const sampleThreads: CommentThread[] = [
	sampleThread,
	{ self: sampleComments.knowtheory, replies: [] }
];

// more than one reply, to show the connector line running down the replies
export const multiReplyThread: CommentThread = {
	self: sampleComments.byjp,
	replies: [sampleComments.cam, sampleComments.samuel, sampleComments.moth]
};

// a long thread whose middle reply belongs to the logged-in user (for edit-in-place)
export const longThread: CommentThread = {
	self: sampleComments.byjp,
	replies: [
		sampleComments.cam,
		sampleComments.moth,
		sampleComments.mine,
		sampleComments.anirudh,
		sampleComments.anil
	]
};
