<template>
	<component :message="message" :is-self-msg="isSelfMsg" :disabled="disabled" :is="getRenderComp"></component>
</template>

<script lang="ts" setup>
	import RtcMessageRenderer from './RtcMessageRenderer.vue'
	import CatchMsgRenderer from './CatchMsgRenderer.vue'
	import { ExedMessageItem } from './data'
	import { CustomMessageType } from '@/constants/enum'

	type CustomMessageSwitcherProps = {
		message : ExedMessageItem
		disabled : boolean
		isSelfMsg : boolean
	}
	const props = defineProps<CustomMessageSwitcherProps>()

	const customData = JSON.parse(props.message.customElem.data)

	const getRenderComp = computed(() => {
		switch (customData.customType) {
			case CustomMessageType.Call:
				return RtcMessageRenderer
			default:
				return CatchMsgRenderer
		}
	})
</script>