PageSourceSearch

https://www.teneks.ai/assets/TrainPage-D-ZKJsIx.js

js teneks.ai collected 2026-10-05 12:46:41 UTC 34,088 bytes, 36 lines download raw bytes

1var lt=Object.defineProperty;var ct=(t,r,s)=>r in t?lt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var U=(t,r,s)=>ct(t,typeof r!="symbol"?r+"":r,s);import{i as W,t as n,H as dt,x as X,C as ut,q as e}from"./index-D1hWIMSq.js";import{B as mt}from"./button-CMDd-Ga8.js";import{T as xt}from"./textarea-Dsei3wzm.js";import{V as ht}from"./AuthContext-CtNx-rOX.js";import{a as j}from"./utils-DJAlB2fc.js";import{g as pt}from"./teams-CrZIq3FT.js";import{a as le}from"./axios-CEMv0kWU.js";import{ah as ft}from"./fetchers-DPczl4xZ.js";import{m as P}from"./proxy-QSfEx3xg.js";import{C as Ie}from"./check-BoV_gCu8.js";import{A as Ee}from"./index-CJrpovEL.js";import{S as gt}from"./scale-CNuVv7gV.js";import{F as bt}from"./flame-CqjezlTY.js";import{U as yt}from"./user-DjPSfrX2.js";import{U as vt}from"./user-round-BKDB5cX3.js";import{B as wt}from"./building-2-D5ByNTp8.js";import{H as jt}from"./headphones-CPkLaiPC.js";import{L as Nt}from"./loader-circle-BhjIzobU.js";import{M as kt}from"./monitor-BQ3nxCBU.js";import{A as St}from"./arrow-right-C0Tv-K-A.js";import{S as Ct}from"./square-xnxsbC54.js";import"./users-DDsUog1J.js";import"./authReturn-BvqNzQtQ.js";/**
2 * @license lucide-react v0.446.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Tt=W("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/**
7 * @license lucide-react v0.446.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const _t=W("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
12 * @license lucide-react v0.446.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const De=W("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/**
17 * @license lucide-react v0.446.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Pe=W("PhoneOff",[["path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91",key:"z86iuo"}],["line",{x1:"22",x2:"2",y1:"2",y2:"22",key:"11kh81"}]]);/**
22 * @license lucide-react v0.446.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Mt=W("Swords",[["polyline",{points:"14.5 17.5 3 6 3 3 6 3 17.5 14.5",key:"1hfsw2"}],["line",{x1:"13",x2:"19",y1:"19",y2:"13",key:"1vrmhu"}],["line",{x1:"16",x2:"20",y1:"16",y2:"20",key:"1bron3"}],["line",{x1:"19",x2:"21",y1:"21",y2:"19",key:"13pww6"}],["polyline",{points:"14.5 6.5 18 3 21 3 21 6 17.5 9.5",key:"hbey2j"}],["line",{x1:"5",x2:"9",y1:"14",y2:"18",key:"1hf58s"}],["line",{x1:"7",x2:"4",y1:"17",y2:"20",key:"pidxm4"}],["line",{x1:"3",x2:"5",y1:"19",y2:"21",key:"1pehsh"}]]);/**
27 * @license lucide-react v0.446.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const Rt=W("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
32 * @license lucide-react v0.446.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const At=W("Wind",[["path",{d:"M17.7 7.7a2.5 2.5 0 1 1 1.8 4.3H2",key:"1k4u03"}
36],["path",{d:"M9.6 4.6A2 2 0 1 1 11 8H2",key:"b7d0fd"}],["path",{d:"M12.6 19.4A2 2 0 1 0 14 16H2",key:"1p5cb3"}]]);class Bt{constructor(r=24e3){U(this,"audioContext");U(this,"nextStartTime",0);U(this,"sampleRate");U(this,"activeSources",[]);U(this,"gainNode");U(this,"analyser");this.audioContext=new AudioContext({sampleRate:r}),this.sampleRate=r,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=256,this.analyser.smoothingTimeConstant=.7,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.analyser),this.analyser.connect(this.audioContext.destination)}playChunk(r){if(r.byteLength===0)return;const s=new Int16Array(r),l=new Float32Array(s.length);for(let m=0;m<s.length;m++)l[m]=s[m]/32768;const u=this.audioContext.createBuffer(1,l.length,this.sampleRate);u.getChannelData(0).set(l);const c=this.audioContext.createBufferSource();c.buffer=u,c.connect(this.gainNode);const i=this.audioContext.currentTime,d=Math.max(i,this.nextStartTime);c.start(d),this.nextStartTime=d+u.duration,this.activeSources.push(c),c.onended=()=>{this.activeSources=this.activeSources.filter(m=>m!==c)}}interrupt(){for(const r of this.activeSources)try{r.stop()}catch{}this.activeSources=[],this.nextStartTime=0}get isPlaying(){return this.activeSources.length>0}getLevel(){const r=new Uint8Array(this.analyser.frequencyBinCount);this.analyser.getByteFrequencyData(r);let s=0;for(let l=0;l<r.length;l++)s+=r[l];return s/(r.length*255)}async resume(){this.audioContext.state==="suspended"&&await this.audioContext.resume()}destroy(){this.interrupt(),this.audioContext.close()}}function It({onAudioChunk:t,onTranscript:r,onSummary:s,onStatusChange:l,onError:u,onHangup:c,onSessionId:i}){const d=n.useRef(null),m=n.useCallback((N,_,f)=>{const k=localStorage.getItem("authToken");if(!k){u("Not authenticated");return}const M=`${"https://api.teneks.ai".replace(/^http/,"ws")}/api/v1/train/ws?token=${k}`,g=new WebSocket(M);g.binaryType="arraybuffer",g.onopen=()=>{g.send(JSON.stringify({type:"start",scenario:N,language:_,voice:f==null?void 0:f.voice,hangup:f==null?void 0:f.hangup,difficulty:f==null?void 0:f.difficulty})),l(!0)},g.onmessage=x=>{if(x.data instanceof ArrayBuffer)t(x.data);else try{const b=JSON.parse(x.data);switch(b.type){case"transcript":r({role:b.role,text:b.text});break;case"summary":s(b.content,b.conversation_id);break;case"error":u(b.message,b.category);break;case"status":b.conversation_id&&(i==null||i(b.conversation_id));break;case"hangup":c==null||c(b.reason);break;default:break}}catch{}},g.onerror=()=>{u("WebSocket connection error")},g.onclose=x=>{l(!1),x.code!==1e3&&u(`Connection closed unexpectedly (code: ${x.code})`)},d.current=g},[t,r,s,l,u,c,i]),h=n.useCallback(N=>{var _;((_=d.current)==null?void 0:_.readyState)===WebSocket.OPEN&&d.current.send(N)},[]),y=n.useCallback(()=>{var N;((N=d.current)==null?void 0:N.readyState)===WebSocket.OPEN&&d.current.send(JSON.stringify({type:"stop"}))},[]),p=n.useCallback(()=>{d.current&&(d.current.close(1e3),d.current=null)},[]);return{connect:m,sendAudio:h,stop:y,disconnect:p}}async function Et(t){return(await le.get("/api/v1/insights/personas/roleplay/teams",{params:{environment_id:t}})).data}async function Pt(t,r){return(await le.get("/api/v1/insights/personas/roleplay/options",{params:{environment_id:t,team_id:r}})).data}async function Lt(t,r,s,l){return(await le.get("/api/v1/insights/personas/roleplay/scenario",{params:{environment_id:t,team_id:r,persona_key:s,product_key:l||void 0}})).data}const Ot="https://azurepersonalstorage.blob.core.windows.net/voice-assets".replace(/\/$/,""),$t={office:"office-ambience.mp3",cafeteria:"cafeteria-ambience.mp3",street:"street-ambience.mp3"},Ht=t=>t==="off"?null:`${Ot}/${$t[t]}`,Ut=()=>{var t;try{const r=localStorage.getItem("userData");if(r){const s=JSON.parse(r);if((t=s.environment)!=null&&t.language)return s.environment.language}return"en"}catch{return"en"}};function Wt(t,r,s){if(s===r){const m=new Int16Array(t.length);for(let h=0;h<t.length;h++)m[h]=Math.max(-1,Math.min(1,t[h]))*32767;return m.buffer}const l=r/s,u=Math.round(t.length/l),c=new Int16Array(u);let i=0,d=0;for(;i<c.length;){const m=Math.round((i+1)*l);let h=0,y=0;for(let p=d;p<m&&p<t.length;p++)h+=t[p],y++;c[i]=Math.max(-1,Math.min(1,h/y))*32767,i++,d=m}return c.buffer}function Le(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}function Dt({micLevel:t,aiLevel:r,isAiSpeaking:s}){const l=n.useRef(null),u=n.useRef(0);return n.useEffect(()=>{const c=l.current;if(!c)return;const i=c.getContext("2d"),d=280;c.width=d*2,c.height=d*2,i.scale(2,2);let m=0;const h=()=>{m++,i.clearRect(0,0,d,d);const y=d/2,p=d/2,N=s?r:t,_=90+N*40,f=i.createRadialGradient(y,p,40,y,p,_);s?(f.addColorStop(0,`rgba(99, 102, 241, ${.15+r*.25})`),f.addColorStop(.6,`rgba(139, 92, 246, ${.08+r*.12})`),f.addColorStop(1,"rgba(139, 92, 246, 0)")):(f.addColorStop(0,`rgba(16, 185, 129, ${.1+t*.2})`),f.addColorStop(.6,`rgba(52, 211, 153, ${.05+t*.1})`),f.addColorStop(1,"rgba(52, 211, 153, 0)")),i.fillStyle=f,i.fillRect(0,0,d,d);const k=55+N*15,D=64;i.beginPath();for(let x=0;x<=D;x++){const b=x/D*Math.PI*2,R=Math.sin(b*3+m*.04)*.3+Math.sin(b*5+m*.07)*.2+Math.sin(b*7+m*.02)*.15,Q=N*18*(1+R),L=k+Q,Y=y+Math.cos(b)*L,Z=p+Math.sin(b)*L;x===0?i.moveTo(Y,Z):i.lineTo(Y,Z)}if(i.closePath(),s){const x=i.createLinearGradient(y-80,p-80,y+80,p+80);x.addColorStop(0,"rgba(99, 102, 241, 0.6)"),x.addColorStop(.5,"rgba(139, 92, 246, 0.5)"),x.addColorStop(1,"rgba(168, 85, 247, 0.6)"),i.fillStyle=x,i.strokeStyle="rgba(139, 92, 246, 0.8)"}else{const x=i.createLinearGradient(y-80,p-80,y+80,p+80);x.addColorStop(0,"rgba(16, 185, 129, 0.5)"),x.addColorStop(1,"rgba(52, 211, 153, 0.5)"),i.fillStyle=x,i.strokeStyle="rgba(16, 185, 129, 0.7)"}i.lineWidth=2,i.fill(),i.stroke();const M=30+N*5,g=i.createRadialGradient(y,p,0,y,p,M);s?(g.addColorStop(0,"rgba(255, 255, 255, 0.9)"),g.addColorStop(.4,"rgba(199, 182, 255, 0.6)"),g.addColorStop(1,"rgba(139, 92, 246, 0.2)")):(g.addColorStop(0,"rgba(255, 255, 255, 0.8)"),g.addColorStop(.4,"rgba(167, 243, 208, 0.5)"),g.addColorStop(1,"rgba(16, 185, 129, 0.15)")),i.beginPath(),i.arc(y,p,M,0,Math.PI*2),i.fillStyle=g,i.fill(),u.current=requestAnimationFrame(h)};return h(),()=>cancelAnimationFrame(u.current)},[t,r,s]),e.jsx("canvas",{ref:l,className:"w-[280px] h-[280px]",style:{imageRendering:"auto"}})}const Ft={"Easy buyer":{icon:De,chip:"bg-emerald-100 text-emerald-600",flame:"text-emerald-500",rate:"text-emerald-600",selBorder:"border-emerald-300",selBg:"bg-emerald-50/70",glow:"bg-emerald-300",checkBg:"bg-emerald-500"},"Cautious buyer":{icon:gt,chip:"bg-amber-100 text-amber-600",flame:"text-amber-500",rate:"text-amber-600",
36selBorder:"border-amber-300",selBg:"bg-amber-50/70",glow:"bg-amber-300",checkBg:"bg-amber-500"},"Reluctant buyer":{icon:_t,chip:"bg-orange-100 text-orange-600",flame:"text-orange-500",rate:"text-orange-600",selBorder:"border-orange-300",selBg:"bg-orange-50/70",glow:"bg-orange-300",checkBg:"bg-orange-500"},"Tough skeptic":{icon:Mt,chip:"bg-rose-100 text-rose-600",flame:"text-rose-500",rate:"text-rose-600",selBorder:"border-rose-300",selBg:"bg-rose-50/70",glow:"bg-rose-300",checkBg:"bg-rose-500"}},zt={icon:De,chip:"bg-neutral-100 text-neutral-600",flame:"text-neutral-500",rate:"text-neutral-700",selBorder:"border-neutral-400",selBg:"bg-neutral-50",glow:"bg-neutral-300",checkBg:"bg-neutral-800"},Oe=["from-violet-500 to-indigo-500","from-emerald-500 to-teal-500","from-amber-500 to-orange-500","from-rose-500 to-pink-500","from-sky-500 to-blue-500","from-fuchsia-500 to-purple-500","from-lime-500 to-emerald-500","from-orange-500 to-red-500"];function Gt(t){let r=0;for(let s=0;s<t.length;s++)r=r*31+t.charCodeAt(s)>>>0;return Oe[r%Oe.length]}function qt(t){const r=t.trim().split(/\s+/);return(r.length>1?r[0][0]+r[1][0]:t.slice(0,2)).toUpperCase()}const $e={hidden:{},show:{transition:{staggerChildren:.05,delayChildren:.05}}},He={hidden:{opacity:0,y:14},show:{opacity:1,y:0,transition:{type:"spring",stiffness:300,damping:26}}},Ue={hidden:{opacity:0,height:0,y:8},show:{opacity:1,height:"auto",y:0,transition:{duration:.4,ease:[.22,1,.36,1]}},exit:{opacity:0,height:0,y:-8,transition:{duration:.25}}};function ie({index:t,title:r,hint:s}){return e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 items-center justify-center rounded-full bg-neutral-900 text-[11px] font-semibold text-white",children:t}),e.jsx("h2",{className:"text-[12px] font-semibold uppercase tracking-[0.08em] text-neutral-800",children:r}),s&&e.jsxs("span",{className:"text-[11px] font-normal text-neutral-400",children:["· ",s]}),e.jsx("div",{className:"h-px flex-1 bg-neutral-200/70"})]})}function We({active:t,onClick:r,label:s}){return e.jsx("button",{type:"button",onClick:r,className:j("rounded-full border px-3.5 py-1.5 text-[13px] transition-colors",t?"border-neutral-900 bg-neutral-900 font-medium text-white":"border-neutral-200 bg-white text-neutral-600 hover:border-neutral-300 hover:text-neutral-900"),children:s})}function V({active:t,onClick:r,icon:s,label:l}){return e.jsxs("button",{type:"button",onClick:r,className:j("flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11.5px] font-medium transition-colors",t?"border-neutral-900 bg-neutral-900 text-white":"border-neutral-200 bg-white text-neutral-500 hover:border-neutral-300 hover:text-neutral-900"),children:[e.jsx(s,{className:"h-3.5 w-3.5",strokeWidth:2}),l]})}function ga(){const{t}=dt("train"),{user:r}=ht(),s=r==null?void 0:r.environment_id,[l,u]=n.useState("setup"),[c,i]=n.useState(""),[d,m]=n.useState([]),[h,y]=n.useState(""),[p,N]=n.useState([]),[_,f]=n.useState([]),[k,D]=n.useState(""),[M,g]=n.useState(""),[x,b]=n.useState(!1),[R,Q]=n.useState(!1),[L,Y]=n.useState(!1),[Z,Fe]=n.useState(!1),[ce,je]=n.useState("Puck"),[de,ze]=n.useState(!1),[F,ee]=n.useState("off"),[Ge,ue]=n.useState(!1),[Ne,me]=n.useState(null),A=n.useRef(null);n.useEffect(()=>{if(!s)return;let a=!1;return Et(s).then(o=>{a||m(o.teams||[])}).catch(async()=>{try{const o=await pt();a||m((o.data||[]).map(v=>({team_id:v.id,name:v.name,ready:!0,call_count:0,persona_count:0})))}catch{}}).finally(()=>{a||Fe(!0)}),()=>{a=!0}},[s]),n.useEffect(()=>{!h||!s||(b(!0),D(""),g(""),N([]),f([]),i(""),Pt(s,h).then(a=>{N(a.buyer_types||[]),f(a.products||[])}).catch(()=>X.error("Could not load roleplay options for this team")).finally(()=>b(!1)))},[h,s]),n.useEffect(()=>{L||!k||!h||!s||(Q(!0),Lt(s,h,k,M||null).then(a=>i(a.scenario)).catch(()=>X.error("Could not build the scenario")).finally(()=>Q(!1)))},[k,M,L,h,s]);const[ke,xe]=n.useState(0),[Se,Ce]=n.useState(!1),[Te,he]=n.useState([]),[I,pe]=n.useState(null),[J,z]=n.useState("processing"),[qe,te]=n.useState(0),[_e,ae]=n.useState(null),[fe,re]=n.useState(null),[ge,ne]=n.useState(null),be=ut(),[Ve,Me]=n.useState(0),[Je,Re]=n.useState(0),[ye,ve]=n.useState(!1),O=n.useRef(null),G=n.useRef(null),$=n.useRef(null),S=n.useRef(null),H=n.useRef(null),C=n.useRef(null),Ke=Ut(),Xe=n.useCallback(a=>{S.current&&(S.current.playChunk(a),ve(!0))},[]),Qe=n.useCallback(a=>{he(o=>[...o,a])},[]),Ye=n.useCallback((a,o)=>{o&&pe(o),ae(null),re(null),ne(null),te(0),z("processing"),u("summary")}
36,[]),Ze=n.useCallback(a=>{Ce(a),a&&u("active")},[]),et=n.useCallback((a,o)=>{const v={GEMINI_CONNECTION:t("connectionFailed"),AUTH_FAILED:t("connectionFailed"),VALIDATION:a}[o||""]||a;X.error(v),(l==="connecting"||l==="active")&&u("setup")},[l,t]),se=n.useRef(null),tt=n.useCallback(a=>{var o;ue(!0),me(a==="time_limit"?"time_limit":"hangup"),(o=se.current)==null||o.call(se)},[]),{connect:at,sendAudio:rt,stop:nt,disconnect:st}=It({onAudioChunk:Xe,onTranscript:Qe,onSummary:Ye,onStatusChange:Ze,onError:et,onHangup:tt,onSessionId:a=>pe(a)});n.useEffect(()=>{const a=Ht(F);if(l==="active"&&a){const o=A.current??new Audio;o.src!==a&&(o.src=a),o.loop=!0,o.volume=.22,o.play().catch(()=>{}),A.current=o}else A.current&&A.current.pause()},[l,F]),n.useEffect(()=>(l==="active"&&(xe(0),H.current=setInterval(()=>xe(a=>a+1),1e3)),()=>{H.current&&(clearInterval(H.current),H.current=null)}),[l]),n.useEffect(()=>{if(l!=="summary"||!I)return;let a=!1,o=0,v;const T=120,q=async()=>{var B,w,oe;try{const K=await le.get(`/api/v1/conversation/${I}/status`);if(a)return;const Be=(B=K.data)==null?void 0:B.ai_success_rate;ae(typeof Be=="number"?Be:null),re(((w=K.data)==null?void 0:w.good_job)??null),ne(((oe=K.data)==null?void 0:oe.to_be_improved)??null)}catch{}a||z("ready")},E=async()=>{var B;if(!a){o+=1;try{const[w]=await ft([I]);if(a)return;if((w==null?void 0:w.status)==="DONE"){await q();return}if((w==null?void 0:w.status)==="ERROR"){z("error");return}typeof((B=w==null?void 0:w.progress)==null?void 0:B.percent)=="number"&&te(w.progress.percent)}catch{}if(o>=T){a||z("timeout");return}v=setTimeout(E,3e3)}};return E(),()=>{a=!0,clearTimeout(v)}},[l,I]),n.useEffect(()=>(l==="active"&&(C.current=setInterval(()=>{if(G.current){const a=new Uint8Array(G.current.frequencyBinCount);G.current.getByteFrequencyData(a);let o=0;for(let v=0;v<a.length;v++)o+=a[v];Me(o/(a.length*255))}if(S.current){const a=S.current.getLevel();Re(a),ve(a>.02)}},50)),()=>{C.current&&(clearInterval(C.current),C.current=null)}),[l]);const ot=async()=>{var a;if(!c.trim()){X.error(t("scenarioRequired"));return}u("connecting"),he([]),ue(!1),me(null);try{S.current=new Bt(24e3),await S.current.resume();const o=await navigator.mediaDevices.getUserMedia({audio:!0});$.current=o;const v=(a=p.find(w=>w.persona_key===k))==null?void 0:a.difficulty;at(c,Ke,{voice:ce,hangup:de,difficulty:v});const T=new AudioContext;O.current=T;const q=T.createMediaStreamSource(o),E=T.createAnalyser();E.fftSize=256,E.smoothingTimeConstant=.7,G.current=E;const B=T.createScriptProcessor(4096,1,1);B.onaudioprocess=w=>{const oe=w.inputBuffer.getChannelData(0),K=Wt(oe,T.sampleRate,16e3);rt(K)},q.connect(E),E.connect(B),B.connect(T.destination)}catch{X.error(t("connectionFailed")),u("setup"),we()}},Ae=()=>{nt(),$.current&&($.current.getTracks().forEach(a=>a.stop()),$.current=null),O.current&&(O.current.close(),O.current=null),S.current&&S.current.interrupt(),H.current&&(clearInterval(H.current),H.current=null),C.current&&(clearInterval(C.current),C.current=null),G.current=null,A.current&&A.current.pause(),ae(null),re(null),ne(null),te(0),z("processing"),u("summary")};se.current=Ae;const we=()=>{$.current&&($.current.getTracks().forEach(a=>a.stop()),$.current=null),O.current&&(O.current.close(),O.current=null),S.current&&(S.current.destroy(),S.current=null),C.current&&(clearInterval(C.current),C.current=null),G.current=null,A.current&&(A.current.pause(),A.current=null),st()},it=()=>{we(),u("setup"),xe(0),he([]),pe(null),ae(null),re(null),ne(null),te(0),z("processing"),Ce(!1),ve(!1),Me(0),Re(0),ue(!1),me(null)};return n.useEffect(()=>()=>we(),[]),e.jsxs("div",{className:"flex flex-col h-full",children:[l==="setup"&&e.jsxs("div",{className:"relative flex-1 overflow-y-auto",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-72",style:{background:"radial-gradient(55% 100% at 50% 0%, rgba(99,102,241,0.06), transparent 70%)"}}),e.jsxs("div",{className:"relative mx-auto w-full max-w-4xl px-6 py-4 md:py-6",children:[e.jsx(P.header,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.5,ease:[.22,1,.36,1]},className:"mb-5 text-center",children:e.jsx("h1",{className:"text-[2.1rem] leading-[1.05] tracking-tight text-neutral-900 md:text-[2.5rem]",style:{fontFamily:'"DM Serif Display", Georgia, serif'},children:t("title")})}),L?e.jsxs("div",{children:[e.jsx(ie,{index:1,title:t("customScenario")}),e.jsx(xt,{value:c,onChange:a=>i(a.target.value),placeholder:t("scenarioPlaceholder"),className:"min-h-[160px] resize-y rounded-2xl text-sm"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{children:[e.jsx(ie,{index:1,title:t("chooseTeam")}),Z?d.length===0?e.jsx("p",{className:"rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-8 text-center text-sm text-neutral-400",children:t("noTeams")}):e.jsx(P.div,{variants:$e,initial:"hidden",animate:"show",className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:d.map(a=>{const o=h===a.team_id;return e.jsxs(P.button,{variants:He,type:"button",disabled:!a.ready,onClick:()=>a.ready&&y(a.team_id),whileHover:a.ready?{y:-3}:void 0,whileTap:a.ready?{scale:.98}:void 0,className:j("group flex items-center gap-3 rounded-2xl border p-3 text-left transition-all",o?"border-neutral-900 bg-white shadow-[0_12px_30px_-16px_rgba(0,0,0,0.28)] ring-1 ring-neutral-900":a.ready?"border-neutral-200 bg-white hover:border-neutral-300 hover:shadow-[0_12px_28px_-18px_rgba(0,0,0,0.2)]":"cursor-not-allowed border-dashed border-neutral-200 bg-neutral-50/60"),children:[e.jsx("div",{className:j("flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-gradient-to-br text-[13px] font-semibold text-white shadow-sm",a.ready?Gt(a.name):"from-neutral-300 to-neutral-400"),children:qt(a.name)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:j("truncate text-[13.5px] font-semibold",a.ready?"text-neutral-900":"text-neutral-400"),children:a.name}),e.jsx("div",{className:"truncate text-[11px] text-neutral-400",children:a.ready?a.persona_count>0?`${a.persona_count} ${t("buyerTypes")}`:t("ready"):t("soon")})]}),o&&e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-neutral-900 text-white",children:e.jsx(Ie,{className:"h-3 w-3",strokeWidth:3})})]},a.team_id)})}):e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:[0,1,2,3,4,5,6,7].map(a=>e.jsx("div",{className:"h-[70px] animate-pulse rounded-2xl border border-neutral-200 bg-neutral-100/70"},a))})]}),e.jsx(Ee,{initial:!1,children:h&&e.jsxs(P.section,{variants:Ue,initial:"hidden",animate:"show",exit:"exit",className:"overflow-hidden",children:[e.jsx(ie,{index:2,title:t("whoCalling"),hint:t("difficulty")}),x?e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[0,1,2,3].map(a=>e.jsx("div",{className:"h-[118px] animate-pulse rounded-2xl border border-neutral-200 bg-neutral-100/70"},a))}):p.length===0?e.jsx("p",{className:"rounded-2xl border border-neutral-200 bg-neutral-50 px-4 py-6 text-center text-xs text-neutral-400",children:t("noBuyerProfiles")}):e.jsx(P.div,{variants:$e,initial:"hidden",animate:"show",className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:p.map(a=>{const o=Ft[a.label]||zt,v=k===a.persona_key,T=o.icon;return e.jsxs(P.button,{variants:He,type:"button",onClick:()=>D(a.persona_key),whileHover:{y:-3},whileTap:{scale:.98},className:j("group relative overflow-hidden rounded-2xl border p-4 text-left transition-all",v?j(o.selBorder,o.selBg,"shadow-sm"):"border-neutral-200 bg-white hover:border-neutral-300 hover:shadow-[0_12px_28px_-18px_rgba(0,0,0,0.18)]"),children:[v&&e.jsx("div",{className:j("pointer-events-none absolute -right-8 -top-8 h-24 w-24 rounded-full opacity-40 blur-2xl",o.glow)}),e.jsxs("div",{className:"relative flex items-start justify-between",children:[e.jsx("div",{className:j("flex h-10 w-10 items-center justify-center rounded-xl",o.chip),children:e.jsx(T,{className:"h-[18px] w-[18px]",strokeWidth:2})}),v&&e.jsx("div",{className:j("flex h-5 w-5 items-center justify-center rounded-full text-white",o.checkBg),children:e.jsx(Ie,{className:"h-3 w-3",strokeWidth:3})})]}),e.jsx("div",{className:"relative mt-3 text-[14px] font-semibold text-neutral-900",children:t(`buyers.${a.label}`,a.label)}),e.jsxs("div",{className:"relative mt-2.5 flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-0.5",children:[1,2,3,4,5].map(q=>e.jsx(bt,{className:j("h-3 w-3",q<=a.difficulty?o.flame:"text-neutral-200"),fill:"currentColor",strokeWidth:0},q))}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsxs("span",{className:j("text-base font-semibold tabular-nums",o.rate),children:[a.close_rate,"%"]}),e.jsx("span",{className:"text-[10px] text-neutral-400",children:t("closeLabel")})]})]})]},a.persona_key)})})]},"diff")}),e.jsx(Ee,{initial:!1,children:k&&_.length>0&&e.jsxs(P.section,{variants:Ue,initial:"hidden",animate:"show",exit:"exit",className:"overflow-hidden",children:[e.jsx(ie,{index:3,title:t("pitchProduct"),hint:t("optional")}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(We,{active:!M,onClick:()=>g(""),label:t("anyProduct")}),_.map(a=>e.jsx(We,{active:M===a.product_key,onClick:()=>g(a.product_key),label:a.name},a.product_key))]})]},"prod")})]}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-x-5 gap-y-2.5 rounded-2xl border border-neutral-200/70 bg-neutral-50/40 px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.1em] text-neutral-400",children:t("voiceShort","Voice")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(V,{active:ce==="Puck",onClick:()=>je("Puck"),icon:yt,label:t("voiceMale","Male")}),e.jsx(V,{active:ce==="Kore",onClick:()=>je("Kore"),icon:vt,label:t("voiceFemale","Female")})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.1em] text-neutral-400",children:t("ambientShort","Ambience")}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsx(V,{active:F==="off",onClick:()=>ee("off"),icon:Rt,label:t("ambientOff","Quiet")}),e.jsx(V,{active:F==="cafeteria",onClick:()=>ee("cafeteria"),icon:Tt,label:t("ambientCafeteria","Cafeteria")}),e.jsx(V,{active:F==="office",onClick:()=>ee("office"),icon:wt,label:t("ambientOffice","Open office")}),e.jsx(V,{active:F==="street",onClick:()=>ee("street"),icon:At,label:t("ambientStreet","Busy street")})]})]}),e.jsxs("button",{type:"button",role:"switch","aria-checked":de,title:t("hangupHint","They may end the call if you lose them"),onClick:()=>ze(a=>!a),className:j("ml-auto flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11.5px] font-medium transition-colors",de?"border-neutral-900 bg-neutral-900 text-white":"border-neutral-200 bg-white text-neutral-500 hover:border-neutral-300 hover:text-neutral-900"),children:[e.jsx(Pe,{className:"h-3.5 w-3.5",
36strokeWidth:2}),t("hangupShort","Can hang up")]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-center gap-1.5 text-[11.5px] text-neutral-400",children:[e.jsx(jt,{className:"h-3.5 w-3.5",strokeWidth:2}),t("headphonesHint","Best with headphones — otherwise the background noise and the AI’s voice leak into your mic")]}),e.jsxs("div",{className:"mt-6 flex flex-col-reverse items-center justify-between gap-4 sm:flex-row",children:[e.jsx("button",{type:"button",onClick:()=>Y(a=>!a),className:"text-[12px] text-neutral-400 transition-colors hover:text-neutral-700",children:t(L?"pickBuyerType":"writeCustom")}),e.jsxs(P.button,{type:"button",onClick:ot,disabled:!c.trim()||R,whileHover:c.trim()&&!R?{scale:1.02}:void 0,whileTap:c.trim()&&!R?{scale:.98}:void 0,className:j("group relative flex h-12 w-full items-center justify-center gap-2 overflow-hidden rounded-2xl px-8 text-[15px] font-semibold transition-colors sm:w-auto",!c.trim()||R?"cursor-not-allowed bg-neutral-200 text-neutral-400":"bg-neutral-900 text-white hover:bg-neutral-800"),children:[c.trim()&&!R&&e.jsx("span",{className:"pointer-events-none absolute inset-0 -translate-x-full bg-gradient-to-r from-transparent via-white/25 to-transparent transition-transform duration-700 group-hover:translate-x-full"}),e.jsxs("span",{className:"relative flex items-center gap-2",children:[R?e.jsx(Nt,{className:"h-4 w-4 animate-spin"}):e.jsx(kt,{className:"h-4 w-4"}),t("startTraining"),c.trim()&&!R&&e.jsx(St,{className:"h-4 w-4"})]})]})]})]})]}),l==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsxs("div",{className:"relative inline-block",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-gradient-to-br from-violet-500/20 to-indigo-500/20 animate-pulse"}),e.jsx("img",{src:"/teneks_new.svg",alt:"Teneks",className:"absolute inset-0 m-auto h-9 w-9 animate-pulse"})]}),e.jsx("p",{className:"text-sm text-muted-foreground animate-pulse",children:t("connecting")})]})}),l==="active"&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-8 p-6",children:[e.jsx(Dt,{micLevel:Ve,aiLevel:Je,isAiSpeaking:ye}),e.jsxs("div",{className:"text-center space-y-1",children:[e.jsx("p",{className:j("text-sm font-medium transition-colors",ye?"text-violet-600":"text-emerald-600"),children:t(ye?"aiSpeaking":"listening")}),e.jsx("p",{className:"text-xs text-muted-foreground tabular-nums",children:Le(ke)})]}),e.jsxs(mt,{variant:"outline",size:"lg",onClick:Ae,className:"rounded-full px-8 border-red-200 text-red-600 hover:bg-red-50 hover:text-red-700 hover:border-red-300",children:[e.jsx(Ct,{className:"h-4 w-4 mr-2 fill-current"}),t("stopTraining")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:j("h-1.5 w-1.5 rounded-full",Se?"bg-emerald-500":"bg-red-500")}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:t(Se?"connected":"disconnected")})]})]}),l==="summary"&&e.jsx("div",{className:"flex-1 flex items-center justify-center p-6",children:e.jsx("div",{className:"w-full max-w-md",children:e.jsxs("div",{className:"rounded-3xl border border-neutral-200/70 bg-white p-8 shadow-[0_8px_30px_-12px_rgba(16,24,40,0.12)]",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-[17px] font-semibold tracking-tight text-neutral-900",children:t("sessionEnded")}),e.jsxs("p",{className:"mt-1.5 text-[13px] text-neutral-400",children:[Le(ke),Te.length>0?` · ${Te.length} ${t("turns")}`:""]}),Ge&&e.jsxs("div",{className:j("mt-3 inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-[11.5px] font-medium",Ne==="time_limit"?"border-neutral-200 bg-neutral-50 text-neutral-500":"border-rose-200 bg-rose-50 text-rose-600"),children:[e.jsx(Pe,{className:"h-3.5 w-3.5",strokeWidth:2.2}),Ne==="time_limit"?t("timeUp","Time’s up — the call ended at the 8 min limit"):t("prospectHungUp","The prospect hung up on you")]})]}),e.jsxs("div",{className:"mt-7",children:[J==="processing"&&e.jsxs("div",{className:"space-y-4 text-center duration-500 animate-in fade-in-0",children:[e.jsx("p",{className:"text-sm font-medium text-neutral-700",children:t("analyzing")}),e.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-neutral-100",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-violet-500 to-indigo-500 transition-[width] duration-700 ease-out",style:{width:`${Math.max(6,Math.min(100,qe))}%`}})}),e.jsx("p",{className:"mx-auto max-w-xs text-xs leading-relaxed text-neutral-400",children:t("analyzingHint")})]}),J==="ready"&&e.jsxs("div",{className:"duration-500 animate-in fade-in-0 zoom-in-95",children:[_e!==null&&e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"bg-gradient-to-br from-violet-600 to-indigo-600 bg-clip-text text-[52px] font-semibold leading-none tracking-tight text-transparent tabular-nums",children:[Math.round(_e*100),"%"]}),e.jsx("div",{className:"mt-2 text-[10px] font-semibold uppercase tracking-[0.16em] text-neutral-400",children:t("overallPerformance")})]}),(fe||ge)&&e.jsxs("div",{className:"mt-6 space-y-2.5 text-left",children:[fe&&e.jsxs("div",{className:"rounded-2xl border border-emerald-100 bg-emerald-50/40 px-4 py-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-emerald-600",children:t("whatWentWell")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-neutral-700",children:fe})]}),ge&&e.jsxs("div",{className:"rounded-2xl border border-amber-100 bg-amber-50/40 px-4 py-3",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.12em] text-amber-600",children:t("toImprove")}),e.jsx("p",{className:"mt-1 text-[13px] leading-relaxed text-neutral-700",children:ge})]})]}),e.jsx("button",{onClick:()=>I&&be(`/app/dashboard/recording/${I}`),className:"mt-6 w-full rounded-xl bg-neutral-900 py-3 text-sm font-medium text-white transition-colors hover:bg-neutral-800",children:t("viewResults")})]}),(J==="timeout"||J==="error")&&e.jsxs("div",{className:"space-y-4 text-center duration-500 animate-in fade-in-0",children:[e.jsx("p",{className:"mx-auto max-w-xs text-sm leading-relaxed text-neutral-500",children:t(J==="error"?"anal
36ysisFailed":"analysisTakingLonger")}),e.jsx("button",{onClick:()=>I&&be(`/app/dashboard/recording/${I}`),className:"w-full rounded-xl border border-neutral-200 py-3 text-sm font-medium text-neutral-700 transition-colors hover:bg-neutral-50",children:t("viewResults")})]})]}),e.jsxs("div",{className:"mt-7 flex items-center justify-center gap-5 border-t border-neutral-100 pt-5 text-[13px]",children:[e.jsx("button",{onClick:it,className:"font-medium text-neutral-500 transition-colors hover:text-neutral-900",children:t("newSession")}),e.jsx("span",{className:"text-neutral-200",children:"·"}),e.jsx("button",{onClick:()=>be("/app/dashboard"),className:"font-medium text-neutral-500 transition-colors hover:text-neutral-900",children:t("goToDashboard")})]})]})})})]})}export{ga as TrainPage};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.