import { error } from "@sveltejs/kit";
import type { PullState } from "$lib/components/repo/pulls/PullStatePill.svelte";
import type { PageLoad } from "./$types";

export const load: PageLoad = async (event) => {
	const uri = decodeURIComponent(event.params.aturi);

	if (!uri.startsWith("at://")) error(404, "Pull request not found");

	return {
		pull: {
			// $type: "patchView#pullViewDetailed",
			uri: "at://did:plc:bob/sh.tangled.pull/123",
			cid: "thisiscid",
			rkey: "123",
			repo: {
				did: "did:plc:gitrepo",
				owner: {
					// $type: "sh.tangled.actor.defs#profileViewBasic"
					did: "did:plc:alice",
					handle: "alice.pds.tngl.boltless.dev"
				},
				slug: "core",
				createdAt: ""
			},
			author: {
				did: "did:plc:bob",
				handle: "bob.pds.tngl.boltless.dev"
			},
			title: "ref based PR",
			state: "open" as PullState,
			targetBranch: "master",
			versions: [
				{
					// $type: "#patchView",
					base: "01117fddd3502c57bc20a65a75a66a4900d5d67d",
					head: "9a925efef6a0e6dfcd2d4317b4a1eee8752928b8",
					comments: []
				},
				{
					// $type: "#patchView",
					base: "4ce2be789de9ba1b9a39de3c310ae9fa35fef5f7",
					head: "9f7d5e39d69b030454e520f28f83afc28189ed23",
					comments: []
				}
			]
		}
	};
};
