<script setup>
import { useDescriptorStore } from 'src/stores/useDescriptorStore';
import VnJsonValue from './VnJsonValue.vue';
import { computed } from 'vue';
const descriptorStore = useDescriptorStore();

const $props = defineProps({
    value: { type: Object, default: () => {} },
    name: { type: String, default: undefined },
});

const descriptor = computed(() => descriptorStore.has($props.name));
</script>
<template>
    <VnJsonValue :value="value.val" />
    <span
        v-if="(value.id || typeof value.val == 'number') && descriptor"
        style="margin-left: 2px"
    >
        <QIcon
            name="launch"
            class="link"
            :data-cy="'iconLaunch-' + $props.name"
            style="padding-bottom: 2px"
        />
        <component :is="descriptor" :id="value.id ?? value.val" />
    </span>
</template>
