<script setup lang="ts">
import type { GlobalThemeOverrides } from 'naive-ui'
import { darkTheme, zhCN, dateZhCN } from 'naive-ui'
import { CloseCircle } from '@vicons/ionicons5'

const themeOverrides: GlobalThemeOverrides = {
  common: {
    primaryColor: '#48a8f5',
    primaryColorPressed: '#3771e1',
    fontSize: '16px',
  },
  DataTable: {
    thColor: '#257bb5',
    tdColor: '#0000',
    tdColorStriped: 'rgba(37,123,181,0.3)',
    tdColorHover: 'rgba(37,123,181,0.6)',
  },
}
const props = defineProps({
  title: {
    type: String,
    default: '信息',
  },
  content: {
    type: String,
  },
  closeEvent: Function,
})
const closeClick = () => {
  props?.closeEvent()
}

// `style` will be a helper computed for `left: ?px; top: ?px;`
</script>
<template>
  <div class="popup-container">
    <n-config-provider
      :theme-overrides="themeOverrides"
      :theme="darkTheme"
      :locale="zhCN"
      :date-locale="dateZhCN"
    >
      <div class="pine"></div>
      <div class="box-wrap flex flex-col">
        <div class="area">
          <div class="area-title fontColor">
            <template v-if="props.title">{{ props.title }}</template>
            <slot v-else name="title"></slot>
          </div>
          <div class="close" @click="closeClick">
            <n-icon><close-circle /></n-icon>
          </div>
        </div>
        <div class="content h-0 flex-1">
          <n-scrollbar>
            <div v-if="props.content" class="data-li">
              <div class="data-label textColor">地址：</div>
              <div class="data-value">
                <span class="label-num yellowColor">
                  {{ props.content }}
                </span>
              </div>
            </div>
            <slot v-else name="content"></slot>
          </n-scrollbar>
        </div>
        <div class="footer px-2 pb-2">
          <slot name="footer"></slot>
        </div>
      </div>
    </n-config-provider>
  </div>
</template>
<style lang="scss" scoped>
.popup-container {
  width: 200px;
  position: relative;
  bottom: 0;
  left: 0;
}

.close {
  color: #fff;
  text-shadow: 2px 2px 2px #022122;
  cursor: pointer;
  animation: fontColor 1s;
}

.box-wrap {
  position: absolute;
  left: 20.5%;
  top: 0;
  width: 100%;
  height: 163px;
  border-radius: 20px 0px 20px 0px;
  border: 1px solid #38e1ff;
  background-color: #38e1ff4a;
  box-shadow: 0 0 5px 1px #29baf1;
  animation: slide 0.5s;
}

.box-wrap .area {
  // position: absolute;
  // top: 20px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  right: 0;
  width: 100%;
  height: 30px;
  background-image: linear-gradient(to left, #4cdef9, #4cdef96b);
  border-radius: 20px 0px 0px 0px;
  animation: area 1s;
}

.pine {
  position: absolute;
  width: 100px;
  height: 100px;
  box-sizing: border-box;
  line-height: 120px;
  text-indent: 5px;
}

.pine::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -83px;
  width: 40%;
  height: 1px;
  box-sizing: border-box;
  border-bottom: 1px solid #38e1ff;
  transform-origin: bottom center;
  transform: rotateZ(135deg) scale(1.5);
  animation: slash 0.5s;
  filter: drop-shadow(1px 0px 2px #03abb4);
}

.area .area-title {
  text-align: center;
  line-height: 30px;
}

.textColor {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 1px 1px 5px #002520d2;
  animation: fontColor 1s;
}

.yellowColor {
  font-size: 14px;
  font-weight: 600;
  color: #f09e28;
  text-shadow: 1px 1px 5px #002520d2;
  animation: fontColor 1s;
}

.fontColor {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 1px 1px 5px #002520d2;
  animation: fontColor 1s;
}

.content {
  padding: 10px;
}

.content .data-li {
  display: flex;
  align-items: center;
}

@keyframes fontColor {
  0% {
    color: #ffffff00;
    text-shadow: 1px 1px 5px #00252000;
  }

  40% {
    color: #ffffff00;
    text-shadow: 1px 1px 5px #00252000;
  }

  100% {
    color: #ffffff;
    text-shadow: 1px 1px 5px #002520d2;
  }
}

@keyframes slide {
  0% {
    border: 1px solid #38e1ff00;
    background-color: #38e1ff00;
    box-shadow: 0 0 5px 1px #29baf100;
  }

  100% {
    border: 1px solid #38e1ff;
    background-color: #38e1ff4a;
    box-shadow: 0 0 5px 1px #29baf1;
  }
}

@keyframes area {
  0% {
    width: 0%;
  }

  100% {
    width: 100%;
  }
}

@keyframes slash {
  0% {
    transform: rotateZ(135deg) scale(0);
  }

  100% {
    transform: rotateZ(135deg) scale(1.5);
  }
}
</style>
