<template>
  <div
    :class="prefixCls"
    class="relative w-full h-full px-4"
    :style="{ backgroundImage: 'url(' + backgroundImageUrl + ')' }"
  >
    <AppLocalePicker
      class="absolute text-white top-4 right-4 enter-x xl:text-gray-600"
      :showText="false"
      v-if="!sessionTimeout && showLocale"
    />
    <!--<AppDarkModeToggle class="absolute top-3 right-7 enter-x" v-if="!sessionTimeout" />-->
    <span class="-enter-x">
      <HomePageLogo :alwaysShowTitle="true" />
    </span>

    <div class="container relative h-full py-2 mx-auto">
      <div class="flex-new h-full">
        <!--<div class="hidden min-h-full pl-4 mr-4 xl:flex xl:flex-col xl:w-6/12">-->
        <!--<div class="my-auto -enter-x">-->
        <!--<div class="kinetic-effect"></div>-->
        <!--</div>-->
        <!--</div>-->
        <div class="flex w-full h-full py-5 xl:h-auto xl:py-0 xl:my-0 xl:w-2/5">
          <div
            :class="`${prefixCls}-form`"
            class="relative w-full px-5 py-8 mx-auto my-auto rounded-md shadow-md xl:bg-transparent sm:px-8 xl:p-4 sm:w-3/4 lg:w-2/4 xl:w-auto enter-x"
          >
            <LoginForm :baseSetting="baseSetting" />
            <ForgetPasswordForm />
            <RegisterForm />
            <MobileForm />
            <QrCodeForm />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import { HomePageLogo } from '@jdlinker/ui';
  import { AppLocalePicker } from '../../../../components/Application';
  import LoginForm from './LoginForm.vue';
  import ForgetPasswordForm from './ForgetPasswordForm.vue';
  import RegisterForm from './RegisterForm.vue';
  import MobileForm from './MobileForm.vue';
  import QrCodeForm from './QrCodeForm.vue';
  import { useDesign, useLocaleStore, useLoginState, useBaseSettingsStore } from '@jdlinker/func';

  defineProps({
    sessionTimeout: {
      type: Boolean
    }
  });

  const { prefixCls } = useDesign('login');
  // const { t } = useI18n();
  const localeStore = useLocaleStore();
  const showLocale = localeStore.getShowPicker;
  const { handleBackLogin } = useLoginState();
  handleBackLogin();

  const baseSettingsStore = useBaseSettingsStore();
  const baseSetting = ref(baseSettingsStore.model);
  const backgroundImageUrl = ref(
    '' === baseSettingsStore.model?.logoText || 'JD-Linker' === baseSettingsStore.model?.logoText
      ? new URL('/home/JD-Linker-bg.png', import.meta.url).href
      : baseSettingsStore.model?.bgUrl
  );
</script>
<style lang="less">
  @prefix-cls: ~'@{namespace}-login';
  @logo-prefix-cls: ~'@{namespace}-app-logo';
  @countdown-prefix-cls: ~'@{namespace}-countdown-input';
  @dark-bg: #293146;

  html[data-theme='dark'] {
    .@{prefix-cls} {
      background-color: @dark-bg;
      background-image: none;

      &::before {
        /*background-image: url(/@/assets/svg/login-bg-dark.svg);*/
      }

      .ant-input,
      .ant-input-password {
        background-color: #232a3b;
      }

      .ant-btn:not(.ant-btn-link):not(.ant-btn-primary) {
        border: 1px solid #4a5569;
      }

      &-form {
        background: transparent !important;
      }

      .app-iconify {
        color: #fff;
      }
    }

    input.fix-auto-fill,
    .fix-auto-fill input {
      -webkit-text-fill-color: #c9d1d9 !important;
      box-shadow: inherit !important;
    }

    .ant-checkbox-inner {
      border: 1px solid #4a5569;
    }
  }

  .@{prefix-cls} {
    min-height: 100%;
    overflow: hidden;
    width: 100%;
    height: 100%;
    /*background-image: url(/@/assets/images/JD-Linker-bg.png);*/
    background-repeat: no-repeat;
    background-size: 100% 100%;

    @media (max-width: @screen-xl) {
      /*background-color: #293146;*/
      //background-color: #ffffff;
      background-image: none;

      .@{prefix-cls}-form {
        background-color: #fff;
      }
    }

    &::before {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      margin-left: -48%;
      //background-image: url(/@/assets/svg/login-bg.svg);
      background-position: 100%;
      background-repeat: no-repeat;
      background-size: auto 100%;
      content: '';
      @media (max-width: @screen-xl) {
        display: none;
      }
    }

    .@{logo-prefix-cls} {
      position: absolute;
      top: 12px;
      height: 30px;

      &__title {
        font-size: 16px;
        color: #fff;
      }

      img {
        width: 32px;
      }
    }

    .container {
      .@{logo-prefix-cls} {
        display: flex;
        width: 60%;
        height: 80px;

        &__title {
          font-size: 24px;
          color: #fff;
        }

        img {
          width: 48px;
        }
      }
    }

    &-sign-in-way {
      .anticon {
        font-size: 22px;
        color: #888;
        cursor: pointer;

        &:hover {
          color: @primary-color;
        }
      }
    }

    input:not([type='checkbox']) {
      min-width: 360px;

      @media (max-width: @screen-xl) {
        min-width: 320px;
      }

      @media (max-width: @screen-lg) {
        min-width: 260px;
      }

      @media (max-width: @screen-md) {
        min-width: 240px;
      }

      @media (max-width: @screen-sm) {
        min-width: 160px;
      }
    }

    .@{countdown-prefix-cls} input {
      min-width: unset;
    }

    .ant-divider-horizontal.ant-divider-with-text {
      margin: 0 0 10px 0;
    }

    .ant-divider-inner-text {
      font-size: 14px;
      color: @text-color-secondary;
    }
  }
  .flex-new {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .kinetic-effect {
    width: 481px;
    height: 478px;
    /*background: url(/@/assets/loginIcons/kineticEffect.png) no-repeat 0 0;*/
    -webkit-animation: kinetic 1s infinite steps(40, end);
    -moz-animation: kinetic 1s infinite steps(40, end);
    -ms-animation: kinetic 1s infinite steps(40, end);
    animation: kinetic 1s infinite steps(40, end);
  }
  @-webkit-keyframes kinetic {
    0% {
      background-position-y: 0;
    }
    100% {
      background-position-y: -19120px;
    }
  }
  @-moz-keyframes kinetic {
    0% {
      background-position-y: 0;
    }
    100% {
      background-position-y: -19120px;
    }
  }
  @-ms-keyframes kinetic {
    0% {
      background-position-y: 0;
    }
    100% {
      background-position-y: -19120px;
    }
  }
  @keyframes kinetic {
    0% {
      background-position-y: 0;
    }
    100% {
      background-position-y: -19120px;
    }
  }

  .shadow-md {
    --tw-shadow: 0 4px 20px -1px rgb(0 0 0/0.1), 0 2px 4px -2px rgb(0 0 0/0.1);
    --tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px var(--tw-shadow-color);
    box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
  }

  .px-5 {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .py-8 {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
  .rounded-md {
    border-radius: 1px;
  }
</style>
