{{ define "page" }}
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/notes2.css">
<link rel="stylesheet" type="text/css" href="/css/{{ .VERSION }}/page_history.css">


<!-- Drag and drop elements -->

<!-- page-node -->
<div id="notes2" class="page-node">
	<div id="tree-expander" onclick="globalThis._mbus.dispatch('TREE_EXPANSION', { expand: true })">&gt;</div>
	<div id="tree" tabindex=0></div>

	<div id="main-page">
		<!-- Storage stats -->
		<div id="page-storage">
			<n2-pagestorage></n2-pagestorage>
		</div>

		<div id="page-root">
			<div>
				<img src="/images/{{ .VERSION }}/logo.svg">
				<div> {{ .VERSION }}</div>

				<div class="create">Create note</div>
			</div>
		</div>

		<!-- Node editing -->
		<div id="page-node">
			<div id="crumbs"></div>
			<n2-nodeui id="note"></n2-nodeui>
		</div>

		<!-- History -->
		<n2-pagehistory id="page-history"></n2-pagehistory>

		<!-- Preferences -->
		<n2-pagepreferences id="page-preferences"></n2-pagepreferences>
	</div>

	<n2-syncprogress></n2-syncprogress>
</div>

<script type="module">
	import {NodeStore} from '/js/{{ .VERSION }}/node_store.mjs'

	import {App} from "/js/{{ .VERSION }}/app.mjs"
	import {API} from 'api'
	import {Sync} from 'sync'
	import { } from '/js/{{ .VERSION }}/page_node.mjs'
	import { } from '/js/{{ .VERSION }}/page_preferences.mjs'
	import { } from '/js/{{ .VERSION }}/page_storage.mjs'
	import { } from '/js/{{ .VERSION }}/page_history.mjs'
	import { } from '/js/{{ .VERSION }}/file.mjs'

	globalThis.Sync = Sync

	if (!API.hasAuthenticationToken()) {
		location.href = '/login'
	} else {
		try {
			globalThis.nodeStore = new NodeStore()
			globalThis.nodeStore.initializeDB().then(() => {
				globalThis._app = new App()
			})
		} catch (e) {
			alert(e)
		}
	}
</script>

{{ end }}
