<script setup lang="ts">
interface internalProps {
  type?:
    | 'Confirmed'
    | 'Cancelled'
    | 'Created'
    | 'Booked'
    | 'Cargo Received'
    | 'Departure'
    | 'Arrived'
    | 'Completed'
    | 'Departed'
  large?: boolean
}

const mappingTable = new Map([
  ['Confirmed', 'confirmed'],
  ['Cancelled', 'cancelled'],
  ['Created', 'created'],
  ['Booked', 'booked'],
  ['Cargo Received', 'cargo-received'],
  ['Departure', 'departure'],
  ['Arrived', 'arrived'],
  ['Completed', 'completed'],
  ['Departed', 'Departed']
])
defineProps<internalProps>()
</script>

<template>
  <div :class="['v-tag', type && 'v-tag__' + mappingTable.get(type), large && 'large']">
    <div class="dot"></div>
    <slot />
  </div>
</template>

<style lang="scss" scoped>
.v-tag {
  display: inline-flex;
  justify-content: center;
  cursor: default;
  align-items: center;
  padding: 5px 8px;
  height: 22px;
  line-height: 28px;
  font-size: 12px;
  border-radius: 12px;
  background-color: #f7faff;
  color: #4290ff;
  &.large {
    padding: 12px 12px;
    height: 28px;
    font-size: 14px;
  }
  .dot {
    height: 5px;
    width: 5px;
    margin-right: 4px;
    border-radius: 50%;
    background-color: var(--color-tag-confirmed);
  }
  &.v-tag__confirmed {
    background-color: var(--color-tag-confirmed-bg);
    color: var(--color-tag-confirmed);
    .dot {
      background-color: var(--color-tag-confirmed);
    }
  }
  &.v-tag__cancelled {
    background-color: var(--color-tag-cancelled-bg);
    color: var(--color-tag-cancelled);
    .dot {
      background-color: var(--color-tag-cancelled);
    }
  }
  &.v-tag__created {
    background-color: var(--color-tag-created-bg);
    color: var(--color-tag-created);
    .dot {
      background-color: var(--color-tag-created);
    }
  }
  &.v-tag__booked {
    background-color: var(--color-tag-booked-bg);
    color: var(--color-tag-booked);
    .dot {
      background-color: var(--color-tag-booked);
    }
  }
  &.v-tag__cargo-received {
    background-color: var(--color-tag-cargo-received-bg);
    color: var(--color-tag-cargo-received);
    .dot {
      background-color: var(--color-tag-cargo-received);
    }
  }
  &.v-tag__departure {
    background-color: var(--color-tag-departure-bg);
    color: var(--color-tag-departure);
    .dot {
      background-color: var(--color-tag-departure);
    }
  }
  &.v-tag__arrived {
    background-color: var(--color-tag-arrived-bg);
    color: var(--color-tag-arrived);
    .dot {
      background-color: var(--color-tag-arrived);
    }
  }
  &.v-tag__completed {
    background-color: var(--color-tag-completed-bg);
    color: var(--color-tag-completed);
    .dot {
      background-color: var(--color-tag-completed);
    }
  }
  &.v-tag__Departed {
    background-color: var(--color-tag-Departed-bg);
    color: var(--color-tag-Departed);
    .dot {
      background-color: var(--color-tag-Departed);
    }
  }
  & + .v-tag {
    margin-left: 8px;
  }
}
</style>
