<template>
  <div class="map-navigation-card bg-white rounded-[24px] overflow-hidden w-full">
    <div class="map-navigation-card__media">
      <img class="map-navigation-card__image block w-full" :src="data.image" mode="aspectFill" />
      <div class="map-navigation-card__badge flex items-center text-white text-[12px] font-bold">
        <span class="map-navigation-card__badge-icon">{{ badge.icon }}</span>
        <span>{{ badge.text }}</span>
      </div>
    </div>

    <div class="map-navigation-card__content flex items-center">
      <div class="map-navigation-card__info flex-1">
        <div class="map-navigation-card__title text-[#1e293b] text-[18px] font-bold truncate">
          {{ data.title }}
        </div>
        <div class="map-navigation-card__distance text-[#94A3B8] text-[14px] font-bold truncate">
          {{ data.distance }}
        </div>
      </div>
      <div
        class="map-navigation-card__button flex items-center justify-center bg-0F172A text-white text-[18px] font-bold"
        :class="{ 'is-disabled': disabled }" @click="handleAction">
        <span class="map-navigation-card__button-icon">{{ action.icon }}</span>
        <span>{{ action.text }}</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
  data: {
    type: Object,
    default: () => ({}),
  },
  disabled: {
    type: Boolean,
    default: false,
  },
});

const emit = defineEmits(["select", "action"]);

const badge = computed(() => props.data.badge || {});
const action = computed(() => props.data.action || {});

const handleAction = () => {
  if (props.disabled) return;
  emit("select", props.data);
  emit("action", props.data);
};
</script>

<style scoped lang="scss">
@import "./styles/index.scss";
</style>
