<script setup="setup">

import * as cryptoServer from 'crypto'
const getRandomUUID = () => (typeof window === 'undefined')
      ? cryptoServer.randomBytes(16).toString('hex')
      : crypto.randomUUID()

const { etherpadApiUrl } = useEtherpadApi()
const route = useRoute()

const revisionId = ref(null)

revisionId.value = route.params.guid ? route.params.guid : getRandomUUID()

// Ustvari nov, prazen pad
// @TODO parameter za seranje linka?
const padId = revisionId.value
const resp = await $fetch(`${etherpadApiUrl}/createPad?padID=${padId}`)

</script>

<template>
  <section class="pojem">
    <PojemForm :pojem="{ nov: true }" :revisionId="revisionId" />
  </section>
</template>

<style scoped>
section.pojem {
  max-width: 608px;
}
form.pojem {
  width: 100%;
}
</style>
