<script lang="ts">
	import {
		PUBLIC_DISABLE_INTRO_TILES,
		PUBLIC_MODEL_ID,
		PUBLIC_MODEL_NAME,
		PUBLIC_VERSION,
	} from "$env/static/public";

	import Logo from "$lib/components/icons/Logo.svelte";
	import CarbonArrowUpRight from "~icons/carbon/arrow-up-right";
	import CarbonEarth from "~icons/carbon/earth";
	import { createEventDispatcher } from "svelte";
	const dispatch = createEventDispatcher<{ message: string }>();
</script>

<div class="my-auto grid gap-8 lg:grid-cols-3">
	<div class="lg:col-span-1">
		<div>
			<div class="mb-3 flex items-center text-2xl font-semibold">
                <svg width="52px" height="52px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                  <g id="SVGRepo_bgCarrier" stroke-width="0"/>
                  <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
                  <g id="SVGRepo_iconCarrier">
                    <path fill="#004cff" fill-rule="evenodd" clip-rule="evenodd" d="M20.5433 6.7039C21 7.80653 21 9.20435 21 12C21 14.7956 21 16.1935 20.5433 17.2961C19.9343 18.7663 18.7663 19.9343 17.2961 20.5433C16.1935 21 14.7956 21 12 21H9C6.17157 21 4.75736 21 3.87868 20.1213C3 19.2426 3 17.8284 3 15V12C3 9.20435 3 7.80653 3.45672 6.7039C4.06569 5.23373 5.23373 4.06569 6.7039 3.45672C7.80653 3 9.20435 3 12 3C14.7956 3 16.1935 3 17.2961 3.45672C18.7663 4.06569 19.9343 5.23373 20.5433 6.7039ZM8 9.99966C8 9.44738 8.44772 8.99966 9 8.99966H15C15.5523 8.99966 16 9.44738 16 9.99966C16 10.5519 15.5523 10.9997 15 10.9997H9C8.44772 10.9997 8 10.5519 8 9.99966ZM8 13.9997C8 13.4474 8.44772 12.9997 9 12.9997H12C12.5523 12.9997 13 13.4474 13 13.9997C13 14.5519 12.5523 14.9997 12 14.9997H9C8.44772 14.9997 8 14.5519 8 13.9997Z" />
                  </g>
                </svg>
				BetterChat
				{#if typeof PUBLIC_VERSION !== "undefined"}
					<div
						class="ml-3 flex h-6 items-center rounded-lg border border-gray-100 bg-gray-50 px-2 text-base text-gray-400 dark:border-gray-700/60 dark:bg-gray-800"
					>
						v{PUBLIC_VERSION}
					</div>
				{/if}
			</div>
			<p class="text-base text-gray-600 dark:text-gray-400">
				Making the community's best AI chat models with internet access available to everyone. (🌍)
			</p>
		</div>
	</div>
	<div class="lg:col-span-2 lg:pl-24">
		<div class="overflow-hidden rounded-xl border dark:border-gray-800">
			<div class="p-3">
				<div class="text-sm text-gray-600 dark:text-gray-400">Current Model</div>
				<div class="font-semibold">{PUBLIC_MODEL_NAME}</div>
			</div>
			<div
				class="flex items-center gap-5 rounded-xl bg-gray-100 px-3 py-2 text-sm text-gray-600 dark:bg-gray-800 dark:text-gray-300"
			>
				<a
					href="https://huggingface.co/{PUBLIC_MODEL_ID}"
					target="_blank"
					rel="noreferrer"
					class="flex items-center hover:underline"
				>
					<CarbonArrowUpRight class="mr-1.5 text-xs text-gray-400" />
					Model
					<div class="max-sm:hidden">&nbsp;page</div>
				</a>
				<a
					href="https://huggingface.co/datasets/OpenAssistant/oasst1"
					target="_blank"
					rel="noreferrer"
					class="flex items-center hover:underline"
				>
					<CarbonArrowUpRight class="mr-1.5 text-xs text-gray-400" />
					Dataset
					<div class="max-sm:hidden">&nbsp;page</div>
				</a>
				<a
					href="https://open-assistant.io/"
					target="_blank"
					class="ml-auto flex items-center hover:underline"
					rel="noreferrer"
				>
					<CarbonEarth class="mr-1.5 text-xs text-gray-400" />
					Open Assistant Website
				</a>
			</div>
		</div>
	</div>
	{#if PUBLIC_DISABLE_INTRO_TILES !== "true"}
		<div class="lg:col-span-3 lg:mt-12">
			<p class="mb-3 text-gray-600 dark:text-gray-300">Examples</p>
			<div class="grid gap-3 lg:grid-cols-3 lg:gap-5">
				<button
					type="button"
					class="rounded-xl border bg-gray-50 p-2.5 text-gray-600 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:p-4"
					on:click={() =>
						dispatch(
							"message",
							"As a restaurant owner, write a professional email to the supplier to get these products every week: \n\n- Wine (x10)\n- Eggs (x24)\n- Bread (x12)"
						)}
				>
					"Write an email from bullet list"
				</button>
				<button
					type="button"
					class="rounded-xl border bg-gray-50 p-2.5 text-gray-600 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:p-4"
					on:click={() =>
						dispatch(
							"message",
							"Code a basic snake game in python, give explanations for each step."
						)}
				>
					"Code a snake game"
				</button>
				<button
					type="button"
					class="rounded-xl border bg-gray-50 p-2.5 text-gray-600 hover:bg-gray-100 dark:border-gray-800 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 sm:p-4"
					on:click={() => dispatch("message", "How do I make a delicious lemon cheesecake?")}
				>
					"Assist in a task"
				</button>
			</div>
		</div>
	{/if}
</div>
