import { Component,CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent } from '@ionic/angular/standalone';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
import { IonButton, IonCard, IonCardContent, IonCardHeader, IonCardTitle, IonItem, IonLabel,
   IonList,IonSelect, IonSelectOption } from '@ionic/angular/standalone';
import { CommonModule } from '@angular/common';
import { Router } from '@angular/router';
import { ChatPanelOptions, FmodeChat, openChatPanelModal } from 'fmode-ng';
import { ModalController } from '@ionic/angular/standalone';

@Component({
  selector: 'app-tab2',
  templateUrl: 'tab2.page.html',
  styleUrls: ['tab2.page.scss'],
  standalone: true,
  imports: [IonHeader, IonToolbar, IonTitle, IonContent, ExploreContainerComponent,
    IonCard,IonCardHeader,IonCardTitle,IonCardContent,
    IonItem,IonLabel,
    IonSelect,IonSelectOption,
    IonButton,IonList,
    CommonModule
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class Tab2Page {

  private modalCtrl: ModalController;
  constructor(private router: Router,modalCtrl: ModalController) {
    this.modalCtrl = modalCtrl;
    // 其他构造函数代码
  }
  consultants = [
    {
      name: '张衡',
      desc:"是温柔学长，国家中级心理咨询师",
      title: '中级心理咨询师',
      avatar: '/assets/img/2.png',
      tags: ['专业领域：焦虑']
    },
    {
      name: '王雅',
      desc:"是热心学姐，国家中级心理咨询师",
      title: '中级心理咨询师',
      avatar: '/assets/img/4.png',
      tags: ['专业领域：抑郁']
    },
    {
      name: '孙晴',
      desc:"是活泼学妹，国家初级心理咨询师",
      title: '初级心理咨询师',
      avatar: '/assets/img/5.png',
      tags: ['专业领域：压力']
    }
  ];
  clickToConsult(consultant:any) {
    // 弹窗形式聊天：开始咨询
    let options:ChatPanelOptions = {
      roleId:"2DXJkRsjXK",
      onChatInit: (chat: FmodeChat) => {
        console.log("onChatInit");
        console.log("预设角色", chat.role);
        chat.role.set("name", consultant.name);
        chat.role.set("title", consultant.title);
        chat.role.set("desc",consultant.desc);
        chat.role.set("tags", consultant.tags);
        chat.role.set("avatar", consultant.avatar)
        chat.role.set("prompt", `
        # 角色设定
        您是${consultant.name}，一位${consultant.title}，${consultant.desc}，需要为学生提供陪伴和支持等积极情绪。
`);
      },
      onChatSaved:(chat:FmodeChat)=>{
        // chat?.chatSession?.id 本次会话的 chatId
        console.log("onChatSaved",chat,chat?.chatSession,chat?.chatSession?.id)
      },
    }
    openChatPanelModal(this.modalCtrl,options)
    // 页面形式聊天：开始咨询
    // this.router.navigateByUrl("/chat/session/role/2DXJkRsjXK")
  }
  //selectedIssue:string='';
  matchedCounselor: { name: string; specialty: string } | null = null;

  questions = [
    {
      title: '如何应对焦虑？',
      advice: '尝试深呼吸和正念冥想，保持规律的作息，健康饮食，设定小目标，培养兴趣爱好，适当锻炼。',
      expanded: false,
    },
    {
      title: '如何提高自信心？',
      advice: '设定小目标并逐步实现，进行积极自我对话，培养技能，保持健康的生活方式，多与他人社交。',
      expanded: false,
    },
    {
      title: '如何改善人际关系？',
      advice: '积极多与他人沟通，倾听对方的感受，理解他人的感受，多参加社交活动，保持积极的态度，尊重他人。',
      expanded: false,
    },
  ];

  matchCounselor() {
  }
  goChat(){
      this.router.navigateByUrl("/chat/session/role/2DXJkRsjXK")
  }
}