<template>
  <div class="admin-home-valuation-preview">
    <div class="preview-title">Preview</div>
    <div class="preview-content" :class="['step-'+ stepValue, step3.autoValuation ? 'yes': 'no']">
      <img v-if="imgUrl" :src="imgUrl" alt="">
      <img :src="imgSrc" alt="">

      <div class="title ellipsis">{{step1.title}}</div>
      <div class="desc"><span>{{step1.desc}}</span></div>

      <div v-show="stepValue === '1'" class="step-1-content">
        <div class="placeholder">{{ step1.placeholder }}</div>
        <div class="button-text ellipsis">{{ step1.buttonText }}</div>
        <div v-show="step1.showUnit" class="unit-field">| Unit</div>
      </div>

      <div v-show="stepValue === '2'" class="step-2-content">
        <div class="form-title ellipsis">{{step2.title}}</div>
        <div class="form-desc"><span class="ellipsis">{{step2.desc}}</span></div>
        <div v-show="step2.nameRequired" class="name-required">
          <span>*</span>
          <span style="margin-left: 210px">*</span>
        </div>
      </div>

      <div v-show="stepValue === '3'" class="step-3-content">
        <div class="step3-title ellipsis" v-show="step3.autoValuation">{{step3.title}}</div>
        <div class="thank-you" v-show="!step3.autoValuation">{{step3.thankYou}}</div>
      </div>

    </div>
  </div>
</template>

<script setup>
import Step1Image from "@/static/home-valuation-step1.png";
import Step2Image from "@/static/home-valuation-step2.png";
import Step3ImageYes from "@/static/home-valuation-step3-yes.png";
import Step3ImageNo from "@/static/home-valuation-step3-no.png";
const { stepValue, imgUrl, config } = defineProps({
  stepValue: String,
  imgUrl: String,
  config: Object,
})
const { step1, step2, step3 } = config

const imgSrc = computed(()=>{
  if(stepValue === '1') {
    return LoftyIdxUtils.static_url(Step1Image);
  } else if(stepValue === '2') {
    return LoftyIdxUtils.static_url(Step2Image);
  } else if(step3.autoValuation){
    return LoftyIdxUtils.static_url(Step3ImageYes);
  } else {
    return LoftyIdxUtils.static_url(Step3ImageNo);
  }
})

</script>
<style scoped lang="scss">
.ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-home-valuation-preview {
  border: 1px solid rgba(235, 236, 241, 1);
  border-radius: 4px;
  background: rgba(246, 247, 251, 1);
  padding: 20px;
  position: relative;
  height: 460px;
  .preview-title {
    color: $gray-700;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
  }
  .step-1 {
    height: 278px;
  }
  .step-2 {
    height: 388px;
  }
  .step-3.yes {
    height: 388px;
  }
  .step-3.no {
    height: 350px;
  }
  .preview-content {
    position: absolute;
    width: calc(100% - 40px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    img {
      width: 100%;
      height: 100%;
      position: absolute;
      object-fit: cover;
    }
    .title {
      position: absolute;
      text-align: center;
      width: calc(100% - 40px);
      padding: 0 20px;
      top: 100px;
      font-family: 'font-play-bold';
      font-size: 11px;
      height: 18px;
    }
    .desc {
      display: inline-block;
      position: absolute;
      text-align: center;
      top: 120px;
      overflow: hidden;
      span {
        width: 200%;
        font-size: 16px;
        transform: scale(0.5);
        transform-origin: left center;
        display: inline-block;
      }
    }
  }
}
.step-1-content {
  color: #fff;
  z-index: 10;
  .placeholder {
    color: rgba(168, 168, 168, 1);
    position: absolute;
    top: 153px;
    left: 24px;
    font-size: 16px;
    transform: scale(0.5);
    transform-origin: left center;
  }
  .button-text {
    position: absolute;
    top: 154px;
    right: -6px;
    font-size: 16px;
    transform: scale(0.5);
    width: 120px;
    text-align: center;
  }
  .unit-field {
    color: rgba(168, 168, 168, 1);
    position: absolute;
    top: 154px;
    right: 85px;
    font-size: 16px;
    transform: scale(0.5);
  }
}
.step-2-content {
  z-index: 10;
  .form-title {
    position: absolute;
    width: 200px;
    color: rgba(25, 25, 25, 1);
    left: 260px;
    top: 160px;
    font-weight: 700;
    font-size: 11px;
  }
  .form-desc {
    position: absolute;
    color: rgba(25, 25, 25, 1);
    left: 260px;
    top: 176px;
    overflow: hidden;
    width: 222px;
    span {
      width: 370px;
      font-size: 12px;
      transform: scale(0.6);
      transform-origin: left center;
      display: inline-block;
    }
  }
  .name-required {
    position: absolute;
    left: 242px;
    top: 200px;
    color: #A8A8A8;
    transform: scale(0.5);
  }
}
.step-3-content {
  z-index: 10;
  .step3-title {
    position: absolute;
    width: 220px;
    color: rgba(25, 25, 25, 1);
    left: 260px;
    top: 214px;
    font-size: 7px;
  }
  .thank-you {
    width: 220px;
    height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    position: absolute;
    color: rgba(25, 25, 25, 1);
    left: 260px;
    top: 220px;
    font-size: 7px;
    line-height: 10px;
  }
}
</style>