<template>
	<!--底部操作按钮-->
	<div class="flex-between">
		<div>
			<span class="el-text el-text--info">
				<span class="ml-4">{{ props.item?.answer?.createdTime }} 以上内容为 AI 生成，不代表开发者立场</span>
			</span>
		</div>
		<div>
			<!--重新回答-->
			<el-tooltip effect="dark" content="重新回答" placement="top">
				<el-button text @click="regeneration">
					<el-icon>
						<RefreshRight />
					</el-icon>
				</el-button>
			</el-tooltip>
			<!--复制-->
			<el-divider direction="vertical" />
			<el-tooltip effect="dark" content="复制" placement="top">
				<el-button text @click="handleCopyClick">
					<AppIcon iconName="app-copy"></AppIcon>
				</el-button>
			</el-tooltip>
			<!--初始化状态-->
			<span v-if="!item?.praise || item?.praise === 'DEFAULT'">
				<el-tooltip effect="dark" content="喜欢" placement="top">
					<el-button text @click="handlePraiseClick('LIKE')">
						<img src="@/assets/agent/chat/xihuan.svg" alt="">
					</el-button>
				</el-tooltip>
				<el-tooltip effect="dark" content="不喜欢" placement="top">
					<el-button text @click="handlePraiseClick('UNLIKE')">
						<img src="@/assets/agent/chat/buxihuan.svg" alt="">
					</el-button>
				</el-tooltip>
			</span>
			<!--喜欢-->
			<el-tooltip effect="dark" content="喜欢" placement="top" v-else-if="item?.praise === 'LIKE'">
				<el-button text @click="handlePraiseClick('DEFAULT')">
					<img src="@/assets/agent/chat/xihuan_h.svg" alt="">
				</el-button>
			</el-tooltip>
			<!--不喜欢-->
			<el-tooltip effect="dark" content="不喜欢" placement="top" v-else-if="item?.praise === 'UNLIKE'">
				<el-button text @click="handlePraiseClick('DEFAULT')">
					<img src="@/assets/agent/chat/buxihuan_h.svg" alt="">
				</el-button>
			</el-tooltip>
		</div>
	</div>
</template>

<script setup lang="ts">

const emit = defineEmits(['on-copy', 'on-regeneration', 'on-praise'])


const props = defineProps({
	item: {
		type: Object,
		required: false
	},
})

/**
 * @description: 复制
 * @param {string} info
 * @return {*}
 */
const handleCopyClick = () => {
	emit('on-copy')
}

/**
 * @description: 重新回答	
 * @param {string} info
 * @return {*}
 */
const regeneration = () => {
	emit('on-regeneration')
}

/**
 * @description: 喜欢或不喜欢
 * @param {string} type 喜欢：L 不喜欢：D  初始化：''
 * @return {*}
 */
const handlePraiseClick = (type?: string) => {
	emit('on-praise', type)
}


</script>

<style lang="scss" scoped></style>