import{c as P,_ as G,p as K,y as S,a as l,l as k,q as D,u as a,b as s,t,i as n,F as j,x as T,m as g,g as m,C as L,w as R,v as $,d as q,k as H,r as u,B as J,E as O,z as U,o}from"./index-rfeHzF-F.js";import{T as Y}from"./target-CLzEfHJ7.js";import{A as Q}from"./arrow-left-De8eM538.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=P("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"},Z={style:{"margin-top":"0"}},ee=["onClick"],se={class:"row",style:{"align-items":"center"}},te={key:0,class:"badge line"},ae={key:1,class:"badge facebook"},le={class:"muted",style:{"margin-top":"6px"}},oe=["disabled"],ne={key:1},ie={class:"card guide"},re={style:{margin:"6px 0 0","line-height":"1.7"}},ce={class:"row",style:{"align-items":"center","margin-bottom":"12px"}},ue={style:{margin:"0"}},de={key:0,class:"muted"},ve={key:0,class:"bubble msg-customer muted"},pe={key:0,class:"composer"},me=["disabled","placeholder"],he=["disabled"],_e={key:1,class:"card debrief"},ge={key:0},ye={key:0,class:"reveal-grid"},fe={class:"rk"},be={class:"rv"},ke={class:"primary",style:{"margin-top":"12px"}},we={__name:"Chat",setup(xe){const A=H(),y=A.params.gid,w=A.params.pid,h=u(null),c=u("pick"),d=u([]),_=u(""),f=u(!1),i=u(null),B=u(null),b=u("social"),N=J(()=>{const e=n.locale==="en";return[{id:"social",emoji:"💬",init:"customer",label:e?"Social Media (chat)":"Social Media (แชท)",desc:e?"The customer messages you first — short, chat-style replies":"ลูกค้าทักมาหาคุณก่อน — โทนสั้น ทักๆ ตามสไตล์แชท"},{id:"f2f_call",emoji:"📞",init:"seller",label:e?"Face-to-face / Phone":"พบหน้า / โทรศัพท์",desc:e?"You must proactively open the conversation (seller starts)":"คุณต้องเป็นฝ่ายเปิดการสนทนาเชิงรุกกับลีด (ผู้ฝึกทักก่อน)"}]});function z(){O(()=>{x.value&&(x.value.scrollTop=x.value.scrollHeight)})}const x=u(null);async function E(){c.value="chat";const e=await S.chatStart(y,w,b.value,n.locale);B.value=e.session.id,d.value=e.session.messages||[],d.value.length&&z()}K(async()=>{h.value=(await S.getPersona(y,w)).persona;try{const e=await S.chatResume(y,w);B.value=e.session.id,d.value=e.session.messages||[],d.value.length&&!e.session.debrief?(c.value="chat",N.find(C=>C.id===e.scenario)&&(b.value=e.scenario)):e.session.debrief&&(i.value=e.session.debrief,d.value=e.session.messages||[],c.value="done"),d.value.length&&z()}catch{c.value="pick"}});async function V(){if(_.value.trim()){f.value=!0;try{const e=await S.chatSend(y,w,_.value.trim());d.value=e.messages,_.value="",e.finished&&(i.value=e.debrief||null,c.value="done"),z()}catch(e){alert(e.message)}finally{f.value=!1}}}const F={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 I(e){return F[e]||e}function M(e){return Array.isArray(e)?e.join(", "):e&&typeof e=="object"?JSON.stringify(e):String(e??"—")}return(e,v)=>{const C=U("router-link");return o(),l("div",null,[k(C,{to:`/groups/${a(y)}/personas`,class:"btn-back"},{default:D(()=>[k(a(Q),{size:16,"stroke-width":2}),g(" "+t(a(n).t("personas")),1)]),_:1},8,["to"]),c.value==="pick"?(o(),l("div",X,[s("h3",Z,"🎬 "+t(a(n).t("chooseScenario")),1),v[1]||(v[1]=s("p",{class:"muted",style:{"margin-top":"0"}},"เลือกสถานการณ์ที่อยากฝึกการขาย — แต่ละแบบกำหนดว่าใครทักก่อน และโทนการสนทนา",-1)),(o(!0),l(j,null,T(N.value,r=>(o(),l("div",{key:r.id,class:L(["scenario",{sel:b.value===r.id}]),onClick:p=>b.value=r.id},[s("div",se,[s("strong",null,t(r.emoji)+" "+t(r.label),1),r.init==="customer"?(o(),l("span",te,"ลูกค้าทักก่อน")):(o(),l("span",ae,"คุณต้องทักก่อน (เชิงรุก)"))]),s("div",le,t(r.desc),1)],10,ee))),128)),s("button",{class:"primary",style:{"margin-top":"16px",width:"100%"},disabled:!b.value,onClick:E}," ▶ "+t(a(n).t("start")),9,oe)])):(o(),l("div",ne,[s("div",ie,[s("strong",null,[k(a(Y),{size:17,"stroke-width":1.8,style:{"vertical-align":"-3px"}}),g(" "+t(a(n).t("chatGuideTitle")),1)]),s("p",re,t(a(n).t("chatGuideText")),1)]),s("div",ce,[s("h2",ue,t(h.value?h.value.name:"..."),1),h.value?(o(),l("span",de,t(h.value.profession)+" · "+t(h.value.age_group),1)):m("",!0),c.value==="done"?(o(),l("span",{key:1,class:L(["badge",i.value&&i.value.outcome])},t(i.value&&i.value.outcome==="won"?a(n).t("won"):a(n).t("lost")),3)):m("",!0)]),s("div",{class:"thread",ref_key:"thread",ref:x},[(o(!0),l(j,null,T(d.value,(r,p)=>(o(),l("div",{key:p,class:L(["bubble",r.role==="seller"?"msg-seller":r.role==="system"?"msg-system":"msg-customer"])},t(r.text),3))),128)),f.value?(o(),l("div",ve,"...")):m("",!0)],512),c.value==="chat"?(o(),l("div",pe,[R(s("input",{"onUpdate:modelValue":v[0]||(v[0]=r=>_.value=r),onKeyup:q(V,["enter"]),disabled:f.value,placeholder:a(n).t("send")},null,40,me),[[$,_.value]]),s("button",{class:"primary",onClick:V,disabled:f.value||!_.value.trim()},t(a(n).t("send")),9,he)])):m("",!0),c.value==="done"&&i.value?(o(),l("div",_e,[s("h3",null,t(a(n).t("debrief")),1),s("p",null,[s("span",{class:L(["badge",i.value.outcome])},t(i.value.outcome==="won"?a(n).t("won"):a(n).t("lost")),3),g(" — "+t(a(n).t("score"))+": ",1),s("strong",null,t(i.value.score),1)]),s("p",null,[s("strong",null,t(a(n).t("pain"))+":",1),g(" "+t(i.value.pain||"—"),1)]),s("p",null,[s("strong",null,t(a(n).t("why"))+":",1),g(" "+t(i.value.why),1)]),i.value.coaching&&i.value.coaching.length?(o(),l("div",ge,[v[2]||(v[2]=s("strong",null,"Coaching:",-1)),s("ul",null,[(o(!0),l(j,null,T(i.value.coaching,(r,p)=>(o(),l("li",{key:p},t(r),1))),128))])])):m("",!0),s("details",null,[s("summary",null,[k(a(W),{size:15,"stroke-width":1.8,style:{"vertical-align":"-2px"}}),g(" "+t(a(n).t("reveal")),1)]),i.value.revealed_persona?(o(),l("div",ye,[(o(!0),l(j,null,T(i.value.revealed_persona,(r,p)=>(o(),l("div",{key:p,class:"rev"},[s("span",fe,t(I(p)),1),s("span",be,t(M(r)),1)]))),128))])):m("",!0)]),k(C,{to:"/"},{default:D(()=>[s("button",ke,t(a(n).t("dashboard")),1)]),_:1})])):m("",!0)]))])}}},Te=G(we,[["__scopeId","data-v-dd57873b"]]);export{Te as default};