<template>
  <div v-if="contentEditorVisible || docEditorVisible" class="edit-dialog">
    <div class="edit">
      <div class="close"><Close @click="handleClose" /></div>
      <div class="warning"><Warning /></div>
      <div class="title">{{ $t('prevent.title') }}</div>
      <div class="des">{{ contentEditorVisible ? $t('prevent.description') : $t('prevent.description1') }}</div>
      <div class="button" @click="handleClose">{{ $t('ok') }}</div>
    </div>
  </div>
</template>

<script setup>
  import { computed } from "vue"
  import { useViewerStore } from '@/stores/modules/viewer'

  const useViewer = useViewerStore()

  const contentEditorVisible = computed(() => useViewer.isElementOpen('contentEditorPreventDialog'))
  const docEditorVisible = computed(() => useViewer.isElementOpen('docEditorPreventDialog'))

  const handleClose = () => useViewer.closeElement(contentEditorVisible.value ? 'contentEditorPreventDialog' : 'docEditorPreventDialog')
</script>

<style lang="scss">
  .edit-dialog {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    .edit {
      width: 100%;
      max-width: 284px;
      background-color: var(--c-side-bg);
      padding: 16px 16px 40px;
      box-shadow: 0px 4px 32px 0px #8195C852;
      .close {
        text-align: right;
        font-size: 0;
        svg {
          width: 12px;
          height: 12px;
          cursor: pointer;
        }
      }
      .warning {
        margin-top: 12px;
        text-align: center;
        font-size: 0;
      }
      .title {
        margin-top: 16px;
        font-size: 16px;
        font-weight: 700;
        line-height: 24px;
        color: var(--c-right-side-header-text);
        text-align: center;
      }
      .des {
        margin-top: 8px;
        font-size: 14px;
        line-height: 16px;
        color: var(--c-edit-text);
        text-align: center;
      }
      .button {
        width: 220px;
        margin: 0 auto;
        margin-top: 24px;
        line-height: 40px;
        border-radius: 4px;
        background: var(--c-header-text-theme-active);
        font-size: 14px;
        font-weight: 700;
        color: #FFFFFF;
        cursor: pointer;
        &:hover {
          background-color: rgba(20, 96, 243, 0.8);
        }
      }
    }
  }
</style>
