<script setup lang="ts">
import {ref} from 'vue';

import {ArrowDown, ArrowRight} from '@element-plus/icons-vue';
import {ElButton, ElIcon} from 'element-plus';

const props = defineProps<{
  collapsed?: boolean;
  text: string;
}>();

const open = ref(!props.collapsed);
</script>

<template>
  <div class="ai-reasoning-card">
    <ElButton class="ai-reasoning-card__toggle" link @click="open = !open">
      <ElIcon>
        <ArrowDown v-if="open" />
        <ArrowRight v-else />
      </ElIcon>
      <span>思考</span>
    </ElButton>
    <div v-if="open" class="ai-reasoning-card__body">{{ text }}</div>
  </div>
</template>

<style scoped>
.ai-reasoning-card {
  padding: 10px 12px;
  color: var(--el-text-color-regular);
  background: var(--el-fill-color-light);
  border-radius: 8px;
}

.ai-reasoning-card__toggle {
  height: 24px;
  padding: 0;
  color: var(--el-text-color-secondary);
}

.ai-reasoning-card__body {
  margin-top: 8px;
  font-size: 13px;
  line-height: 20px;
  white-space: pre-wrap;
}
</style>
