<template>
  <div class="map-navigation-card bg-white rounded-24 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 flex-items-center color-white font-size-12 font-900">
        <span class="map-navigation-card__badge-icon">{{ badge.icon }}</span>
        <span>{{ badge.text }}</span>
      </div>
    </div>

    <div class="map-navigation-card__content flex flex-items-center">
      <div class="map-navigation-card__info flex-full">
        <div class="map-navigation-card__title color-1E293B font-size-18 font-900 ellipsis-1">
          {{ data.title }}
        </div>
        <div class="map-navigation-card__distance color-94A3B8 font-size-14 font-900 ellipsis-1">
          {{ data.distance }}
        </div>
      </div>
      <div
        class="map-navigation-card__button flex flex-items-center flex-justify-center bg-0F172A color-white font-size-18 font-900"
        :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>
