<script lang="ts">
	import Download from './icons/Download.svelte';
	import Terminal from './icons/Terminal.svelte';
	import Check from './icons/Check.svelte';
	import PhotoSwipeLightbox from 'photoswipe/lightbox';
	import 'photoswipe';
	import 'photoswipe/style.css';
	import { onMount } from 'svelte';

	let downloadIsPressed = false;
	let checksumSwayIsPressed = false;
	let checksumRiverIsPressed = false;

	onMount(() => {
		let lightbox = new PhotoSwipeLightbox({
			gallery: '#sway-screenshots',
			children: 'a',
			pswpModule: () => import('photoswipe')
		});
		lightbox.init();
	});
</script>

<div class="flex justify-center items-center flex-col text-center bg-[#24273a]">
	<img alt="" height="216px" src="tileos.svg" width="216px" />
	<h1 class="text-3xl font-bold">Tile OS</h1>
	<p>Debian-based distribution with tiling window managers.</p>
	<div class="flex flex-row flex-wrap m-7 justify-center">
		<div class="relative inline-block text-left">
			<div>
				<button
					class="border-2 p-2.5 mx-5 my-3 rounded-md bg-[#6993e9]"
					on:click={() => {
						downloadIsPressed = !downloadIsPressed;
					}}
				>
					<Download className="mr-1.5"></Download>
					Download
				</button>
			</div>
			<div
				class="absolute left-0 mx-5 my-3 w-56 rounded-md bg-[#6993e9] {downloadIsPressed
					? 'transition ease-in duration-75 opacity-100 scale-100'
					: 'opacity-0 transition ease-out duration-100 scale-95'}"
			>
				<div class="py-1">
					<!-- Sway/River Download Links Under Logo -->
					<p class="block px-4 py-2 text-sm">
						<a href="https://downloads.tile-os.com/beta/sway/tileos-sway-1.0-desktop-beta-amd64.iso"
							>Download (1.0-beta Sway)</a
						>
						<a
							class="underline"
							href="https://downloads.tile-os.com/beta/sway/tileos-sway-1.0-desktop-beta-amd64.sha256.txt"
							>(sha256)</a
						>
						<a
							class="underline"
							href="https://downloads.tile-os.com/beta/sway/tileos-sway-1.0-desktop-beta-amd64.md5.txt"
							>(md5)</a
						>
					</p>
					<p class="block px-4 py-2 text-sm">
						<a
							href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.iso"
							>Download (1.0-beta River)</a
						>
						<a
							class="underline"
							href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.sha256.txt"
							>(sha256)</a
						>
						<a
							class="underline"
							href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.md5.txt"
							>(md5)</a
						>
					</p>
				</div>
			</div>
		</div>
		<!-- Source Code Link -->
		<a class="border-2 p-2.5 mx-5 my-3 rounded-md bg-[#73b4d1]" href="https://gitlab.com/tile-os">
			<Terminal className="mr-1.5"></Terminal>
			Source Code</a
		>
	</div>
</div>

<div>
	<div class="flex flex-col xl:flex-row p-8">
		<div class="flex-1 m-5">
			<h1 class="font-bold text-3xl mb-3">TileOS 1.0 "T-Rex" Sway Edition</h1>
			<p>
				TileOS Sway is a flagship edition featuring Sway - a lightweight and highly customizable
				Wayland compositor. It is designed to be compatible with the i3 window manager but is built
				using the Wayland display server protocol instead of X11. Sway is a full feature complete
				Wayland compositor, combined with awesome Catppuccin color scheme, Waybar panel and apps
				from NWG project (such as nwg-drawer, nwg-look, etc) it provides powerful, easy to use and
				very flexible desktop.
			</p>
			<div class="flex flex-row flex-wrap m-7 ml-0">
				<!-- Sway Download Link -->
				<a
					class="border-2 p-2.5 mx-5 my-3 rounded-md bg-[#6993e9] ml-0"
					href="https://downloads.tile-os.com/beta/sway/tileos-sway-1.0-desktop-beta-amd64.iso"
				>
					<Download className="mr-1.5"></Download>
					Download (1.0-beta Sway)</a
				>
				<div class="relative inline-block text-left">
					<div>
						<button
							class="border-2 p-2.5 mx-5 my-3 ml-0 rounded-md bg-[#8bd5ca]"
							on:click={() => {
								checksumSwayIsPressed = !checksumSwayIsPressed;
							}}
						>
							<Check className="mr-1.5"></Check>
							Checksums
						</button>
					</div>
					<div
						class="absolute left-0 mx-5 my-3 ml-0 w-56 rounded-md bg-[#8bd5ca] {checksumSwayIsPressed
							? 'transition ease-in duration-75 opacity-100 scale-100'
							: 'opacity-0 transition ease-out duration-100 scale-95'}"
					>
						<div class="py-1">
							<!-- Checksum Download Links -->
							<p class="block px-4 py-2 text-sm">
								<a
									class=""
									href="https://downloads.tile-os.com/beta/sway/tileos-sway-1.0-desktop-beta-amd64.sha256.txt"
									>SHA256</a
								>
							</p>
							<p class="block px-4 py-2 text-sm">
								<a
									class=""
									href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.md5.txt"
									>MD5</a
								>
							</p>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="flex-1 m-5">
			<!-- Screenshots -->
			<div class="flex justify-center flex-wrap" id="sway-screenshots">
				<a
					href="screenshots/sway/screen1.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/sway/screen1.png"
						alt=""
					/>
				</a>
				<a
					href="screenshots/sway/screen2.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/sway/screen2.png"
						alt=""
					/>
				</a>
				<a
					href="screenshots/sway/screen3.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/sway/screen3.png"
						alt=""
					/>
				</a>
			</div>
		</div>
	</div>
</div>

<div>
	<div class="flex flex-col xl:flex-row p-8">
		<div class="flex-1 m-5">
			<h1 class="font-bold text-3xl mb-3">TileOS 1.0 "T-Rex" River Edition</h1>
			<p>
				TileOS River Edtion featuring River - a minimalistic and lightweight dynamic Wayland
				compositor. It is designed to be simple, efficient, and easy to use, making it a great
				choice for users looking for a streamlined window management experience. River automatically
				arranges windows in a tiled layout, maximizing screen space and allowing users to easily
				switch between applications. It has a very simple configuration and low resource
				consumption, сombined with awesome Catppuccin color scheme, Waybar panel and apps from NWG
				project (such as nwg-drawer, nwg-look, etc) it provides powerful, easy to use and very
				flexible desktop.
			</p>
			<div class="flex flex-row flex-wrap m-7 ml-0">
				<!-- River Download Link -->
				<a
					class="border-2 p-2.5 mx-5 my-3 rounded-md bg-[#6993e9] ml-0"
					href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.iso"
				>
					<Download className="mr-1.5"></Download>
					Download (1.0-beta River)</a
				>
				<div class="relative inline-block text-left">
					<div>
						<button
							class="border-2 p-2.5 mx-5 my-3 ml-0 rounded-md bg-[#8bd5ca]"
							on:click={() => {
								checksumRiverIsPressed = !checksumRiverIsPressed;
							}}
						>
							<Check className="mr-1.5"></Check>
							Checksums
						</button>
					</div>
					<div
						class="absolute left-0 mx-5 my-3 ml-0 w-56 rounded-md bg-[#8bd5ca] {checksumRiverIsPressed
							? 'transition ease-in duration-75 opacity-100 scale-100'
							: 'opacity-0 transition ease-out duration-100 scale-95'}"
					>
						<div class="py-1">
							<!-- Checksum Download Links -->
							<p class="block px-4 py-2 text-sm">
								<a
									class=""
									href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.sha256.txt"
									>SHA256</a
								>
							</p>
							<p class="block px-4 py-2 text-sm">
								<a
									class=""
									href="https://downloads.tile-os.com/beta/river/tileos-river-1.0-desktop-beta-amd64.md5.txt"
									>MD5</a
								>
							</p>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="flex-1 m-5">
			<!-- Screenshots -->
			<div class="flex justify-center flex-wrap" id="sway-screenshots">
				<a
					href="screenshots/river/screen4.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/river/screen4.png"
						alt=""
					/>
				</a>
				<a
					href="screenshots/river/screen5.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/river/screen5.png"
						alt=""
					/>
				</a>
				<a
					href="screenshots/river/screen6.png"
					data-pswp-width="1920"
					data-pswp-height="980"
					target="_blank"
				>
					<img
						class="m-4 h-[24wh] w-[48vw] lg:h-[16wh] lg:w-[32vw] xl:h-[8wh] xl:w-[16vw]"
						src="screenshots/river/screen6.png"
						alt=""
					/>
				</a>
			</div>
		</div>
	</div>
	<div class="flex flex-row md:flex-col m-7">
		<div class="flex-1 m-5">
			<h2 class="text-2xl font-bold mb-3">System requirements:</h2>
			<ul class="list-disc">
				<li class="ml-[15.3px]">CPU: Dual-core CPU with 1.6 GHz</li>
				<li class="ml-[15.3px]">RAM: 1 GB (Recommended 2GB)</li>
				<li class="ml-[15.3px]">Storage Space: 20 GB</li>
				<li class="ml-[15.3px]">
					GPU: Any Intel or AMD GPU (Nvidia cards require additional settings and are <span
						class="font-bold">NOT</span
					> officially supported.)
				</li>
			</ul>
		</div>
		<div class="flex-1 m-5">
			<h2 class="text-2xl font-bold mb-3">Known Issues:</h2>
			<ul class="list-disc">
				<li class="ml-[15.3px]">
					Secure Boot is not officially supported and may break your system! Use it on your own
					risk!
				</li>
				<li class="ml-[15.3px]">
					The installer currently has problems installing on encrypted partitions.
				</li>
				<li class="ml-[15.3px]">
					The installer currently has installation issues when selecting a non-Latin keyboard layout
					(e.g. Russian). You need to choose English keyboard layout while installing the system
					(system region does not matter and you can choose one that you need).
				</li>
				<li class="ml-[15.3px]">Having boot problems on VMware virtual machines.</li>
			</ul>
		</div>
	</div>
</div>
