import{k as G,_ as K,l as P,s as S,c as l,m as k,n as D,u as a,a as e,t,i as r,F as T,q as L,j as g,A as w,e as _,w as R,v as $,b as q,h as H,r as d,C as J,x as O,o as n}from"./index-Dv9XjhnS.js";import{T as U}from"./target-Do-370k4.js";import{A as Q}from"./arrow-left-haz-8IhO.js";/** * @license lucide-vue-next v1.0.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const W=G("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),X={key:0,class:"card"},Y={style:{"margin-top":"0"}},Z=["onClick"],ee={class:"row",style:{"align-items":"center"}},se={key:0,class:"badge line"},te={key:1,class:"badge facebook"},ae={class:"muted",style:{"margin-top":"6px"}},le=["disabled"],ne={key:1},oe={class:"card guide"},ie={style:{margin:"6px 0 0","line-height":"1.7"}},re={class:"row",style:{"align-items":"center","margin-bottom":"12px"}},ce={style:{margin:"0"}},ue={key:0,class:"muted"},de={key:0,class:"bubble msg-customer muted"},ve={key:0,class:"composer"},pe=["disabled","placeholder"],me=["disabled"],_e={key:1,class:"card debrief"},he={key:0},ge={key:0,class:"reveal-grid"},ye={class:"rk"},fe={class:"rv"},be={class:"primary",style:{"margin-top":"12px"}},ke={__name:"Chat",setup(we){const N=H(),y=N.params.gid,x=N.params.pid,c=d(null),u=d("pick"),v=d([]),h=d(""),f=d(!1),o=d(null),V=d(null),b=d("social"),z=[{id:"social",emoji:"💬",init:"customer",label:"Social Media (แชท)",desc:"ลูกค้าทักมาหาคุณก่อน — โทนสั้น ทักๆ ตามสไตล์แชท"},{id:"f2f_call",emoji:"📞",init:"seller",label:"พบหน้า / โทรศัพท์",desc:"คุณต้องเป็นฝ่ายเปิดการสนทนาเชิงรุกกับลีด (ผู้ฝึกทักก่อน)"},{id:"recontact",emoji:"⏳",init:"customer",label:"ลูกค้ากลับมาติดต่อ (1-3 เดือน)",desc:"เคยได้รับข้อมูลไปแล้ว ตอนนี้กลับมาติดต่อ พร้อมตัดสินใจมากขึ้น"}];function A(){J(()=>{C.value&&(C.value.scrollTop=C.value.scrollHeight)})}const C=d(null);async function I(){u.value="chat";const s=await S.chatStart(y,x,{scenario:b.value});V.value=s.session.id,v.value=s.session.messages||[],v.value.length&&A()}P(async()=>{c.value=(await S.getPersona(y,x)).persona;try{const s=await S.chatResume(y,x);V.value=s.session.id,v.value=s.session.messages||[],v.value.length&&!s.session.debrief?(u.value="chat",z.find(j=>j.id===s.scenario)&&(b.value=s.scenario)):s.session.debrief&&(o.value=s.session.debrief,v.value=s.session.messages||[],u.value="done"),v.value.length&&A()}catch{u.value="pick"}});async function B(){if(h.value.trim()){f.value=!0;try{const s=await S.chatSend(y,x,h.value.trim());v.value=s.messages,h.value="",s.finished&&(o.value=s.debrief||null,u.value="done"),A()}catch(s){alert(s.message)}finally{f.value=!1}}}const E={name:"ชื่อ",tier:"ระดับ",difficulty:"ความยาก",profession:"อาชีพ",age_group:"ช่วงอายุ",location:"พื้นที่",income:"รายได้",budget:"งบประมาณ",lifestyle:"ไลฟ์สไตล์",background:"ภูมิหลัง",personality:"บุคลิก",communication_style:"สไตล์การสื่อสาร",goal:"เป้าหมาย",decision_timeline:"กรอบตัดสินใจ",pains:"ปัญหา (Pain)",objections:"ข้อโต้แย้ง",negotiation_levers:"สิ่งที่ใช้ต่อรอง",opener:"บทเปิดบทสนทนา",channel:"ช่องทาง",initiation_mode:"ใครเริ่มก่อน",product_context:"บริบทสินค้า"};function F(s){return E[s]||s}function M(s){return Array.isArray(s)?s.join(", "):s&&typeof s=="object"?JSON.stringify(s):String(s??"—")}return(s,p)=>{const j=O("router-link");return n(),l("div",null,[k(j,{to:`/groups/${a(y)}/personas`,class:"btn-back"},{default:D(()=>[k(a(Q),{size:16,"stroke-width":2}),g(" "+t(a(r).t("personas")),1)]),_:1},8,["to"]),u.value==="pick"?(n(),l("div",X,[e("h3",Y,"🎬 "+t(a(r).t("chooseScenario")),1),p[1]||(p[1]=e("p",{class:"muted",style:{"margin-top":"0"}},"เลือกสถานการณ์ที่อยากฝึกการขาย — แต่ละแบบกำหนดว่าใครทักก่อน และโทนการสนทนา",-1)),(n(),l(T,null,L(z,i=>e("div",{key:i.id,class:w(["scenario",{sel:b.value===i.id}]),onClick:m=>b.value=i.id},[e("div",ee,[e("strong",null,t(i.emoji)+" "+t(i.label),1),i.init==="customer"?(n(),l("span",se,"ลูกค้าทักก่อน")):(n(),l("span",te,"คุณต้องทักก่อน (เชิงรุก)"))]),e("div",ae,t(i.desc),1)],10,Z)),64)),e("button",{class:"primary",style:{"margin-top":"16px",width:"100%"},disabled:!b.value,onClick:I}," ▶ "+t(a(r).t("start")),9,le)])):(n(),l("div",ne,[e("div",oe,[e("strong",null,[k(a(U),{size:17,"stroke-width":1.8,style:{"vertical-align":"-3px"}}),g(" "+t(a(r).t("chatGuideTitle")),1)]),e("p",ie,t(a(r).t("chatGuideText")),1)]),e("div",re,[e("h2",ce,t(c.value?c.value.name:"..."),1),e("span",{class:w(["badge",c.value&&c.value.channel])},t(c.value?c.value.channel:""),3),c.value?(n(),l("span",ue,t(c.value.profession)+" · "+t(c.value.age_group),1)):_("",!0),u.value==="done"?(n(),l("span",{key:1,class:w(["badge",o.value&&o.value.outcome])},t(o.value&&o.value.outcome==="won"?a(r).t("won"):a(r).t("lost")),3)):_("",!0)]),e("div",{class:"thread",ref_key:"thread",ref:C},[(n(!0),l(T,null,L(v.value,(i,m)=>(n(),l("div",{key:m,class:w(["bubble",i.role==="seller"?"msg-seller":i.role==="system"?"msg-system":"msg-customer"])},t(i.text),3))),128)),f.value?(n(),l("div",de,"...")):_("",!0)],512),u.value==="chat"?(n(),l("div",ve,[R(e("input",{"onUpdate:modelValue":p[0]||(p[0]=i=>h.value=i),onKeyup:q(B,["enter"]),disabled:f.value,placeholder:a(r).t("send")},null,40,pe),[[$,h.value]]),e("button",{class:"primary",onClick:B,disabled:f.value||!h.value.trim()},t(a(r).t("send")),9,me)])):_("",!0),u.value==="done"&&o.value?(n(),l("div",_e,[e("h3",null,t(a(r).t("debrief")),1),e("p",null,[e("span",{class:w(["badge",o.value.outcome])},t(o.value.outcome==="won"?a(r).t("won"):a(r).t("lost")),3),g(" — "+t(a(r).t("score"))+": ",1),e("strong",null,t(o.value.score),1)]),e("p",null,[e("strong",null,t(a(r).t("pain"))+":",1),g(" "+t(o.value.pain||"—"),1)]),e("p",null,[e("strong",null,t(a(r).t("why"))+":",1),g(" "+t(o.value.why),1)]),o.value.coaching&&o.value.coaching.length?(n(),l("div",he,[p[2]||(p[2]=e("strong",null,"Coaching:",-1)),e("ul",null,[(n(!0),l(T,null,L(o.value.coaching,(i,m)=>(n(),l("li",{key:m},t(i),1))),128))])])):_("",!0),e("details",null,[e("summary",null,[k(a(W),{size:15,"stroke-width":1.8,style:{"vertical-align":"-2px"}}),g(" "+t(a(r).t("reveal")),1)]),o.value.revealed_persona?(n(),l("div",ge,[(n(!0),l(T,null,L(o.value.revealed_persona,(i,m)=>(n(),l("div",{key:m,class:"rev"},[e("span",ye,t(F(m)),1),e("span",fe,t(M(i)),1)]))),128))])):_("",!0)]),k(j,{to:"/"},{default:D(()=>[e("button",be,t(a(r).t("dashboard")),1)]),_:1})])):_("",!0)]))])}}},Se=K(ke,[["__scopeId","data-v-4da228fb"]]);export{Se as default};