<script lang="ts">
  import { bufToImageUrl } from "helpers";
  import { route as currentRoute, images as imageStore } from "stores";
  import Editor from "components/Editor/Editor.svelte";

  const imageId = parseInt($currentRoute.split("/")[1]);

  const imagePromise = imageStore.get(imageId);
</script>

{#await imagePromise}
  Loading image
{:then image}
  <Editor {image} />
{:catch err}
  <p>Error loading image</p>
  {JSON.stringify(err)}
{/await}
