{% if page %}
<div id="content-main" class="content-main d-flex"
  data-path="{{ encodeURI(page.path) }}"
  data-current-user="{% if user %}{{ user._id.toString() }}{% endif %}"
  data-page-id="{% if page %}{{ page._id.toString() }}{% endif %}"
  data-page-revision-id="{% if revision %}{{ revision._id.toString() }}{% endif %}"
  data-page-revision-created="{% if revision %}{{ revision.createdAt|datetz('U') }}{% endif %}"
  data-page-revision-author="{% if revision && revision.author %}{{ revision.author|json }}{% endif %}"
  data-page-revision-id-hackmd-synced="{% if revisionHackmdSynced %}{{ revisionHackmdSynced.toString() }}{% endif %}"
  data-page-id-on-hackmd="{% if pageIdOnHackmd %}{{ pageIdOnHackmd.toString() }}{% endif %}"
  data-page-has-draft-on-hackmd="{% if hasDraftOnHackmd %}{{ hasDraftOnHackmd.toString() }}{% endif %}"
  data-page-grant="{{ grant }}"
  data-page-grant-group="{{ grantedGroupId }}"
  data-page-grant-group-name="{{ grantedGroupName }}"
  data-page-is-liked="{% if user %}{{ page.isLiked(user) }}{% else %}false{% endif %}"
  data-page-is-seen="{% if page and page.isSeenUser(user) %}1{% else %}0{% endif %}"
  data-page-is-deleted="{% if page.isDeleted() %}true{% else %}false{% endif %}"
  data-page-is-deletable="{% if isDeletablePage() %}true{% else %}false{% endif %}"
  data-page-is-not-creatable="false"
  data-page-is-able-to-delete-completely="{% if user.canDeleteCompletely(page.creator._id) %}true{% else %}false{% endif %}"
  data-slack-channels="{% if page %}{{ page.slackChannels }}{% endif %}"
  data-page-created-at="{% if page %}{{ page.createdAt|datetz('Y/m/d H:i:s') }}{% endif %}"
  data-page-creator="{% if page && page.creator %}{{ page.creator|json }}{% endif %}"
  data-page-last-update-username="{% if page && page.lastUpdateUser %}{{ page.lastUpdateUser.name }}{% endif %}"
  data-page-updated-at="{% if page %}{{ page.updatedAt|datetz('Y/m/d H:i:s') }}{% endif %}"
  data-page-delete-username="{% if page && page.deleteUser %}{{ page.deleteUser.name }}{% endif %}"
  data-page-deleted-at="{% if page && page.deletedAt %}{{ page.deletedAt|datetz('Y/m/d H:i:s') }}{% endif %}"
  data-page-has-children="{% if pages.length > 0 %}true{% else %}false{% endif %}"
  data-page-user="{% if pageUser %}{{ pageUser|json }}{% else %}null{% endif %}"
  data-page-ids-of-seen-users="{{ page.seenUsers|slice(-15)|default([])|reverse|join(',') }}"
  data-page-count-of-seen-users="{{ page.seenUsers.length|default(0) }}"
  data-share-links-number="{% if page %}{{ sharelinksNumber }}{% endif %}"
  data-share-link-id="{% if sharelink %}{{ sharelink._id|json }}{% endif %}"
  >
{% else %}
<div id="content-main" class="content-main d-flex"
  data-path="{{ encodeURI(path) }}"
  data-current-user="{% if user %}{{ user._id.toString() }}{% endif %}"
  data-slack-channels="{% if page %}{{ page.slackChannels }}{% endif %}"
  data-page-is-deleted="{% if page.isDeleted() %}true{% else %}false{% endif %}"
  data-page-has-children="{% if pages.length > 0 %}true{% else %}false{% endif %}"
  >
{% endif %}

<div class="flex-grow-1 flex-basis-0 mw-0">
  {% include 'page_alerts.html' %}

  <div id="display-switcher">
    <script type="text/template" id="raw-text-original">{{ revision.body.toString() | encodeHTML }}</script>
  </div>
  <div id="page-editor-navbar-bottom-container" class="d-none d-edit-block"></div>
</div>

<div id="grw-page-status-alert-container"></div>

</div>

