PageSourceSearch

https://vagle.ai/assets/Assistants-CeBf935b.js

js vagle.ai collected 2026-10-05 13:12:22 UTC 192,251 bytes, 39 lines download raw bytes

1import{c as Ve,b as le,a as w,j as e,e as rs,C as la,d as T,L as ra,f as oa,u as ca}from"./index-CbtKD9GF.js";import{b as c,L as $,d as da}from"./vendor-gmoby7Lc.js";import{n as pa,g as xs,W as oe,$ as ua,a0 as ma,j as ha,a1 as ga,C as os,q as xa,a2 as va}from"./icons-BYq1EogD.js";import{i as fa,W as ja}from"./ToolWorkspace-DC0igncR.js";import{A as vs}from"./audio-lines-BV1zPN1g.js";import{g as cs,s as re}from"./cacheUtils-DOnU_TFH.js";import{B as ba}from"./bot-uO68C_dR.js";import{L as ya}from"./lock-keyhole-yUgNu-lI.js";const Na=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ka=Ve("circle-alert",Na);const Sa=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],wa=Ve("loader-circle",Sa);const Ca=[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]],ds=Ve("plug-zap",Ca);function Ma({assistant:o,onUpdate:p}){const g="Accepted format: standard .pdf only, max 20 MB, unlocked/password-free, and text-readable. Scanned image-only PDFs need OCR first.",[n,f]=c.useState([]),[y,C]=c.useState(!0),[k,v]=c.useState(!1),[x,I]=c.useState(null),[m,N]=c.useState(""),[b,S]=c.useState(""),F={Authorization:`Bearer ${localStorage.getItem("token")}`},V=o?.knowledgeBaseIds||[];c.useEffect(()=>{G()},[]);const Q=n.some(j=>j.status==="processing");c.useEffect(()=>{if(!Q)return;let j=0,M=!1,D=null;const Z=async()=>{if(!M){if(j+=1,!(typeof document<"u"&&document.hidden))try{const ce=await le.get(w.getApiUrl("/api/knowledge-base"));M||f(ce.data.knowledgeBases||[])}catch{}M||j>=80||(D=setTimeout(Z,j<24?2500:1e4))}};return D=setTimeout(Z,2500),()=>{M=!0,D&&clearTimeout(D)}},[Q]);const G=async()=>{C(!0);try{const j=await le.get(w.getApiUrl("/api/knowledge-base"),{headers:F});f(j.data.knowledgeBases||[])}catch(j){console.error("KB fetch error:",j)}finally{C(!1)}},q=async j=>{const M=V||[];if(!M.includes(j))try{await le.post(w.getApiUrl(`/api/knowledge-base/${j}/assign`),{assistantId:o.id},{headers:F}),p("knowledgeBaseIds",[...M,j]),G()}catch(D){rs(D.response?.data?.error||"Failed to attach knowledge base")}},J=async j=>{const M=V||[];try{await le.post(w.getApiUrl(`/api/knowledge-base/${j}/unassign`),{assistantId:o.id},{headers:F}),p("knowledgeBaseIds",M.filter(D=>D!==j)),G()}catch(D){rs(D.response?.data?.error||"Failed to detach knowledge base")}},O=async()=>{if(x){if(!/\.pdf$/i.test(x.name)||x.type&&x.type!=="application/pdf"){S(g);return}if(x.size>20971520){S("PDF is too large. Please upload a file under 20 MB.");return}v(!0),S("");try{const j=new FormData;j.append("file",x),j.append("name",m||x.name.replace(".pdf","")),await le.post(w.getApiUrl("/api/knowledge-base/upload"),j,{headers:{...F,"Content-Type":"multipart/form-data"}}),I(null),N(""),setTimeout(G,2e3),setTimeout(G,6e3),G()}catch(j){const M=j.response?.data?.error||"Upload failed",D=j.response?.data?.acceptedFormat?` Accepted format: ${j.response.data.acceptedFormat}.`:"";S(`${M}${D}`)}finally{v(!1)}}},X=n.filter(j=>V.includes(j.id)),K=n.filter(j=>!V.includes(j.id)&&j.status==="ready");return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:"0.875rem",fontWeight:600,marginBottom:"0.75rem",display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx(pa,{})," Attached Knowledge Bases (",X.length,")"]}),X.length===0?e.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.8125rem",fontStyle:"italic"},children:"No knowledge bases attached. Attach one below to enable RAG."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:X.map(j=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0.625rem 0.875rem",background:"var(--accent-light)",border:"1px solid rgba(108,92,231,0.15)",borderRadius:"8px"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:600,fontSize:"0.8125rem"},children:j.name}),e.jsxs("span",{style:{color:"var(--text-muted)",fontSize:"0.75rem",marginLeft:"0.5rem"},children:[j.totalChunks," chunks • ",j.fileName]})]}),e.jsx("button",{onClick:()=>J(j.id),style:{background:"none",border:"none",color:"var(--danger)",cursor:"pointer",padding:"0.25rem"},children:e.jsx(xs,{size:16})})]},j.id))})]}),K.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:"0.875rem",fontWeight:600,marginBottom:"0.75rem"},children:[e.jsx(oe,{style:{marginRight:"0.375rem"}})," Available to Attach"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.375rem"},children:K.map(j=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0.5rem 0.875rem",background:"var(--bg-tertiary)",border:"1px solid var(--border-color)",borderRadius:"8px"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontSize:"0.8125rem"},children:j.name}),e.jsxs("span",{style:{color:"var(--text-muted)",fontSize:"0.75rem",marginLeft:"0.5rem"},children:[j.totalChunks," chunks"]})]}),e.jsx("button",{onClick:()=>q(j.id),style:{background:"var(--accent-primary)",color:"#fff",border:"none",borderRadius:"6px",padding:"0.25rem 0.75rem",fontSize:"0.75rem",fontWeight:600,cursor:"pointer"},children:"Attach"})]},j.id))})]}),e.jsxs("div",{style:{padding:"1rem",background:"var(--bg-tertiary)",border:"1px solid var(--border-color)",borderRadius:"10px"},children:[e.jsxs("h3",{style:{fontSize:"0.875rem",fontWeight:600,marginBottom:"0.75rem",display:"flex",alignItems:"center",gap:"0.375rem"},children:[e.jsx(ua,{})," Quick Upload PDF"]}),e.jsxs("div",{style:{marginBottom:"0.75rem",padding:"0.75rem 0.875rem",border:"1px solid rgba(249,115,22,0.22)",borderRadius:"12px",background:"linear-gradient(135deg, #FFFFFF, #FFF7ED)",color:"#334155",fontSize:"0.78rem",lineHeight:1.45},children:[e.jsx("strong",{style:{color:"#111111"},children:"Upload format:"})," standard .pdf only, max 20 MB, unlocked, and text-readable. Scanned PDFs must be OCR converted first."]}),b&&e.jsx("div",{style:{marginBottom:"0.75rem",padding:"0.7rem 0.875rem",border:"1px solid rgba(225,112,85,0.24)",borderRadius:"12px",background:"rgba(225,112,85,0.07)",color:"var(--danger)",fontSize:"0.78rem",lineHeight:1.45},children:b}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",alignItems:"center"},children:[e.jsx("input",{type:"text",placeholder:"Name (optional)",value:m,onChange:j=>N(j.target.value),style:{flex:1,minWidth:"150px",padding:"0.5rem 0.625rem",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:"6px",fontSize:"0.8125rem",color:"var(--text-primary)"}}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.375rem",padding:"0.5rem 0.75rem",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:"6px",cursor:"pointer",fontSize:"0.8125rem",color:"var(--text-secondary)"},children:[e.jsx("input",{type:"file",accept:".pdf,application/pdf",onChange:j=>{const M=j.target.files[0];I(M||null),M&&(!/\.pdf$/i.test(M.name)||M.size>20971520)?S(M.size>20971520?"PDF is too large. Please upload a file under 20 MB.":g):S("")},style:{display:"none"}}),e.jsx(ma,{})," ",x?x.name:"Choose PDF"]}),e.jsx("button",{onClick:O,disabled:!x||k,style:{padding:"0.5rem 1rem",background:"var(--accent-primary)",color:"#fff",border:"none",borderRadius:"6px",fontSize:"0.8125rem",fontWeight:600,cursor:x&&!k?"pointer":"not-allowed",opacity:!x||k?.5:1},children:k?"Processing...":"Upload"})]})]}),y&&e.jsx("p",{style:{color:"var(--text-muted)",fontSize:"0.8125rem"},children:"Loading knowledge bases..."})]})}const Ia=["marin","cedar","alloy","ash","ballad","coral","echo","sage","shimmer","verse"];function Aa({assistant:o,onChange:p}){const d={model:"gpt-realtime-1.5",voice:"marin",speed:1,noiseReduction:"near_field",eagerness:"medium",interruptions:!0,...o.realtime},[g,n]=c.useState({state:"unchecked",message:"Connection not checked"}),f=c.useRef(0);c.useEffect(()=>(f.current+=1,n({state:"unchecked",message:"Connection not checked"}),()=>{f.current+=1}),[o.id,JSON.stringify(o.realtime)]);const y=(v,x)=>p("realtime",{...d,[v]:x}),C=async()=>{const v=++f.current;n({state:"checking",message:"Connecting to OpenAI..."});try{const x=await T.authedFetch(w.getApiUrl("/api/realtime-voice/check"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({realtime:d})}),I=await x.json();if(!x.ok||!I.success)throw new Error(I.error||"Connection check failed. Please retry.");v===f.current&&n({state:"connected",message:"OpenAI connection verified"})}catch(x){v===f.current&&n({state:"error",message:x.message})}},k=g.state==="checking"?wa:g.state==="connected"?la:g.state==="error"?ka:ds;return e.jsxs("div",{className:"realtime-settings",children:[e.jsxs("header",{className:"realtime-settings-heading",children:[e.jsx("span",{className:"realtime-settings-mark",children:e.jsx(vs,{size:24})}),e.jsxs("div",{children:[e.jsx("span",{className:"realtime-eyebrow",children:"OPENAI"}),e.jsx("h2",{children:"Realtime Voice"})]}),e.jsx("span",{className:"realtime-mode-tag",children:"Speech to speech"})]}),e.jsxs("div",{className:"realtime-settings-grid",children:[e.jsxs("label",{children:["Live model",e.jsx("select",{value:d.model,onChange:v=>y("model",v.target.value),children:e.jsx("option",{value:"gpt-realtime-1.5",children:"GPT Realtime 1.5"})})]}),e.jsxs("label",{children:["Voice",e.jsx("select",{value:d.voice,onChange:v=>y("voice",v.target.value),children:Ia.map(v=>e.jsx("option",{value:v,children:v[0].toUpperCase()+v.slice(1)},v))})]}),e.jsxs("label",{children:["Turn pacing",e.jsxs("select",{value:d.eagerness,onChange:v=>y("eagerness",v.target.value),children:[e.jsx("option",{value:"low",children:"Patient"}),e.jsx("option",{value:"medium",children:"Balanced"}
1),e.jsx("option",{value:"high",children:"Quick"}),e.jsx("option",{value:"auto",children:"Automatic"})]})]}),e.jsxs("label",{children:["Noise reduction",e.jsxs("select",{value:d.noiseReduction,onChange:v=>y("noiseReduction",v.target.value),children:[e.jsx("option",{value:"near_field",children:"Headset / phone"}),e.jsx("option",{value:"far_field",children:"Speakerphone"}),e.jsx("option",{value:"off",children:"Off"})]})]}),e.jsxs("label",{className:"realtime-speed",children:["Voice speed ",e.jsxs("output",{children:[Number(d.speed).toFixed(2),"x"]}),e.jsx("input",{type:"range",min:"0.7",max:"1.5",step:"0.05",value:d.speed,onChange:v=>y("speed",Number(v.target.value))})]}),e.jsxs("label",{className:"realtime-interruption",children:[e.jsx("span",{children:"Allow interruptions"}),e.jsx("input",{type:"checkbox",role:"switch",checked:d.interruptions,onChange:v=>y("interruptions",v.target.checked)})]})]}),e.jsxs("div",{className:`realtime-connection ${g.state}`,children:[e.jsxs("div",{role:"status",children:[e.jsx(k,{size:18,className:g.state==="checking"?"realtime-spin":""}),e.jsx("span",{children:g.message})]}),e.jsxs("button",{type:"button",onClick:C,disabled:g.state==="checking",children:[e.jsx(ds,{size:15}),g.state==="checking"?"Checking...":"Check connection"]})]}),g.state==="error"&&e.jsx($,{className:"realtime-keys-link",to:"/provider-keys",children:"Manage OpenAI key"}),e.jsxs("div",{className:"realtime-pricing","aria-label":"Realtime provider pricing",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Audio input"}),e.jsx("strong",{children:"$32 / 1M tokens"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Audio output"}),e.jsx("strong",{children:"$64 / 1M tokens"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Billing"}),e.jsx("strong",{children:"Actual usage"})]})]}),e.jsx("p",{className:"realtime-price-note",children:"Text: $4 input / $16 output per 1M tokens. Cached input: $0.40 / 1M. Call transcripts: $0.006 / audio minute. Carrier charges are separate."})]})}const Pa=4e3,_a=300,Ea=500,Ta=3,fs=o=>{const p=Number(o);if(!Number.isFinite(p)||p<=0)return null;let d,g,n,f;p<=150?(d="fastest",g="Fastest",n="#065f46",f="#d1fae5"):p<=300?(d="fast",g="Fast",n="#166534",f="#dcfce7"):p<=600?(d="medium",g="Medium",n="#92400e",f="#fef3c7"):p<=1e3?(d="slower",g="Slower",n="#9a3412",f="#ffedd5"):(d="slow",g="Slow",n="#991b1b",f="#fee2e2");const y=p>=1e3?`${(p/1e3).toFixed(1)}s`:`${Math.round(p)}ms`;return{tier:d,label:g,ms:p,display:y,color:n,bg:f}},ps=(o,p=null)=>{if(p?.runtimeProvider)return String(p.runtimeProvider).toLowerCase();const d=String(o||"").trim().toLowerCase();return d?[/^meta-llama\/llama-3\.3-70b-instruct-turbo$/,/^meta-llama\/meta-llama-3\.1-(8|70)b-instruct(-turbo)?$/,/^meta-llama\/llama-4-scout-17b-16e-instruct$/,/^meta-llama\/llama-4-maverick-17b-128e-instruct-fp8$/,/^qwen\/qwen3-3(2b|0b-a3b)$/,/^qwen\/qwen3\.5-397b-a17b$/,/^deepseek-ai\/deepseek-v4-flash/,/^google\/gemma-(3-27b-it|4-26b-a4b-it|4-31b-it-turbo)$/,/^mistralai\/mistral-small-3\.2-24b-instruct-2506$/,/^minimaxai\/minimax-m2\.7-turbo$/,/^nvidia\/nemotron-3-nano-30b-a3b$/,/^zai-org\/glm-4\.7-flash$/].some(n=>n.test(d))?"deepinfra":d.includes("/")?"groq":d.startsWith("gpt-")?"openai":d.startsWith("minimax-")?"minimax":/^(mistral|ministral|magistral)-/.test(d)?"mistral":/^qwen(?:3)?-/.test(d)?"qwen":d.startsWith("sarvam-")?"sarvam":"groq":""},La={"llama-3.3-70b-versatile":{input:.59,output:.79},"llama-3.1-70b-versatile":{input:.59,output:.79},"llama-3.1-8b-instant":{input:.05,output:.08},"meta-llama/llama-4-scout-17b-16e-instruct":{input:.11,output:.34},"mixtral-8x7b-32768":{input:.24,output:.24},"gemma2-9b-it":{input:.2,output:.2},"qwen/qwen3-32b":{input:.29,output:.59},"qwen3-30b-a3b-instruct-2507":{input:.108,output:.431},"qwen3-next-80b-a3b-instruct":{input:.144,output:.574},"qwen3-235b-a22b-instruct-2507":{input:.287,output:.92},"allam-2-7b":{input:.05,output:.08},"openai/gpt-oss-120b":{input:.3,output:.6},"openai/gpt-oss-20b":{input:.1,output:.4},"openai/gpt-oss-safeguard-20b":{input:.1,output:.4},"gpt-oss-120b-128k":{input:.15,output:.75},"gpt-oss-20b-128k":{input:.1,output:.5},"canopylabs/orpheus-v1-english":{input:.1,output:.2},"canopylabs/orpheus-arabic-saudi":{input:.1,output:.2},"meta-llama/Llama-3.3-70B-Instruct-Turbo":{input:.1,output:.32},"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo":{input:.02,output:.04},"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo":{input:.1,output:.28},"meta-llama/Llama-4-Scout-17B-16E-Instruct":{input:.1,output:.3},"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8":{input:.2,output:.8},"Qwen/Qwen3-32B":{input:.08,output:.28}
1,"Qwen/Qwen3-30B-A3B":{input:.12,output:.5},"Qwen/Qwen3.5-397B-A17B":{input:.45,output:3},"deepseek-ai/DeepSeek-V4-Flash":{input:.09,output:.18},"deepseek-ai/DeepSeek-V4-Flash-0731":{input:.08,output:.18},"google/gemma-3-27b-it":{input:.08,output:.16},"google/gemma-4-26B-A4B-it":{input:.07,output:.34},"google/gemma-4-31B-it-turbo":{input:.09,output:.34},"mistralai/Mistral-Small-3.2-24B-Instruct-2506":{input:.075,output:.2},"MiniMaxAI/MiniMax-M2.7-Turbo":{input:.38,output:1.7},"nvidia/Nemotron-3-Nano-30B-A3B":{input:.05,output:.2},"zai-org/GLM-4.7-Flash":{input:.06,output:.4},"gpt-5.4-nano":{input:.2,output:1.25},"gpt-5.4-mini":{input:.75,output:4.5},"gpt-5.4-nano-instruct":{input:.2,output:1.25},"gpt-5.4-mini-instruct":{input:.75,output:4.5},"gpt-5-nano":{input:.05,output:.4},"gpt-5-mini":{input:.25,output:2},"gpt-5-nano-instruct":{input:.05,output:.4},"gpt-5-mini-instruct":{input:.25,output:2},"MiniMax-M2.7-highspeed":{input:.6,output:2.4},"mistral-small-latest":{input:.1,output:.3},"ministral-14b-latest":{input:.2,output:.2}},Fa={"whisper-large-v3":.111,"whisper-large-v3-turbo":.04,"deepgram-nova-2":.29,"deepgram-nova-2-general":.29,"deepgram-nova-2-phonecall":.29,"deepgram-nova-2-multilingual":.29,"deepgram-nova-3":.29,"qwen3-asr-flash-realtime":.324,"qwen3-asr-flash-realtime-2026-02-10":.324,"mistral-voxtral-mini-realtime":.29},Va={"sonic-3.5":{per1kChars:.015},"sonic-3":{per1kChars:.015},"sonic-turbo":{per1kChars:.015},eleven_flash_v2_5:{per1kChars:.05},eleven_flash_v2:{per1kChars:.05},eleven_turbo_v2_5:{per1kChars:.05},eleven_turbo_v2:{per1kChars:.05},eleven_multilingual_v2:{per1kChars:.1},eleven_v3:{per1kChars:.1},"speech-2.6-turbo":{perMin:.024},"speech-2.8-turbo":{perMin:.024},"bulbul:v3":{perMin:.015},"bulbul-v3":{perMin:.015},"azure-neural":{per1kChars:.016},"gpt-4o-mini-tts":{per1kChars:.016},"tts-1":{per1kChars:.015},"tts-1-hd":{per1kChars:.03},"inworld-tts-1.5-max":{per1kChars:.035},"inworld-tts-1.5-mini":{per1kChars:.02},"inworld-tts-2":{per1kChars:.025},"lightning_v3.1":{per1kChars:.0145},"lightning_v3.1_pro":{per1kChars:.0145},mistv2:{per1kChars:.03},mistv3:{per1kChars:.03},arcana:{per1kChars:.04},coda:{per1kChars:.05},"aura-2-thalia-en":{per1kChars:.05},"aura-2-andromeda-en":{per1kChars:.05},"aura-2-helena-en":{per1kChars:.05},"aura-2-apollo-en":{per1kChars:.05},"aura-2-arcas-en":{per1kChars:.05},"aura-2-aries-en":{per1kChars:.05},"aura-2-amalthea-en":{per1kChars:.05},"aura-2-draco-en":{per1kChars:.05},"aura-2-luna-en":{per1kChars:.05},"aura-2-orpheus-en":{per1kChars:.05}},Da=[["en","English"],["hi","Hindi"],["ta","Tamil"],["te","Telugu"],["bn","Bengali"],["gu","Gujarati"],["kn","Kannada"],["ml","Malayalam"],["mr","Marathi"],["pa","Punjabi"],["es","Spanish"],["fr","French"],["de","German"],["it","Italian"],["pt","Portuguese"],["zh","Chinese"],["ja","Japanese"],["ko","Korean"],["nl","Dutch"],["pl","Polish"],["ru","Russian"],["sv","Swedish"],["tr","Turkish"],["tl","Tagalog"],["bg","Bulgarian"],["ro","Romanian"],["ar","Arabic"],["cs","Czech"],["el","Greek"],["fi","Finnish"],["hr","Croatian"],["ms","Malay"],["sk","Slovak"],["da","Danish"],["uk","Ukrainian"],["hu","Hungarian"],["no","Norwegian"],["vi","Vietnamese"],["th","Thai"],["he","Hebrew"],["ka","Georgian"],["id","Indonesian"]],xe=o=>{const p=String(o||"").trim();return p.toLowerCase().includes("turbo")?p:"speech-2.6-turbo"},P=(o,p,d)=>{const g=Number(o),n=Number(p),f=Number(d);return!Number.isFinite(g)||!Number.isFinite(n)||!Number.isFinite(f)||f===n?{"--rng-fill":"50%"}:{"--rng-fill":`${Math.max(0,Math.min(100,(g-n)/(f-n)*100))}%`}},js={eng:"English",en:"English",spa:"Spanish",es:"Spanish",fra:"French",fr:"French",deu:"German",de:"German",por:"Portuguese",pt:"Portuguese",jpn:"Japanese",ja:"Japanese",hin:"Hindi",hi:"Hindi",tam:"Tamil",ta:"Tamil",tel:"Telugu",te:"Telugu",ben:"Bengali",bn:"Bengali",mar:"Marathi",mr:"Marathi",guj:"Gujarati",gu:"Gujarati",kan:"Kannada",kn:"Kannada",mal:"Malayalam",ml:"Malayalam",pan:"Punjabi",pa:"Punjabi",urd:"Urdu",ur:"Urdu",zho:"Chinese",zh:"Chinese",kor:"Korean",ko:"Korean",nld:"Dutch",nl:"Dutch",pol:"Polish",pl:"Polish",rus:"Russian",ru:"Russian",swe:"Swedish",sv:"Swedish",tur:"Turkish",tr:"Turkish",ara:"Arabic",ar:"Arabic",vie:"Vietnamese",vi:"Vietnamese",tha:"Thai",th:"Thai",ind:"Indonesian",i
1d:"Indonesian",ita:"Italian",it:"Italian",ukr:"Ukrainian",uk:"Ukrainian",ron:"Romanian",ro:"Romanian",ces:"Czech",cs:"Czech",ell:"Greek",el:"Greek",fin:"Finnish",fi:"Finnish",hrv:"Croatian",hr:"Croatian",msa:"Malay",ms:"Malay",slk:"Slovak",sk:"Slovak",dan:"Danish",da:"Danish",hun:"Hungarian",hu:"Hungarian",nor:"Norwegian",no:"Norwegian",bul:"Bulgarian",bg:"Bulgarian",heb:"Hebrew",he:"Hebrew",hinglish:"Hinglish",auto:"Auto / Multilingual"},Ba={sarvam:"Indian Languages",azure:"Indian Languages",minimax:"Indian Languages",cartesia:"Global Multilingual",elevenlabs:"Global Multilingual",inworld:"Global Multilingual",smallest:"Global Multilingual",deepgram:"English (Fastest)",openai:"English (Fastest)",rime:"English (Fastest)",fish:"Global Multilingual"},Ra={sarvam:"Best for Hindi, Tamil, Telugu, Bengali and other Indian languages",azure:"140+ locales, strong Indian-language voice catalog, hosted in India",minimax:"Tuned for Hindi, Hinglish and English on live calls",cartesia:"42+ languages including Hindi, Tamil, Telugu, Bengali and more",elevenlabs:"Large multilingual voice library with fine emotion control",inworld:"Multilingual catalog with expressive, natural-sounding voices",smallest:"Multilingual catalog optimized for low-cost synthesis",deepgram:"Lowest latency, English-only, ideal for fast phone calls",openai:"English-focused, simple voice set, consistent quality",rime:"English-focused, wide voice variety",fish:"Expressive voice cloning, 13+ languages, low-latency streaming"},Oa=["Indian Languages","Global Multilingual","English (Fastest)"];function za(o){return Ba[String(o||"").toLowerCase()]||"Global Multilingual"}const Ua=(o,p="gender")=>{const d=new Map;for(const n of o||[]){let f;if(p==="language"){const y=String(n.language||"other").toLowerCase();f=js[y]||y.toUpperCase()}else{const y=String(n.gender||"").toLowerCase();f=y==="female"?"Female":y==="male"?"Male":"Other"}d.has(f)||d.set(f,[]),d.get(f).push(n)}return(p==="language"?Array.from(d.keys()).sort():["Female","Male","Other"].filter(n=>d.has(n))).map(n=>[n,d.get(n)])},_e=(o,p="gender")=>Ua(o,p).map(([d,g])=>e.jsx("optgroup",{label:`${d} (${g.length})`,children:g.map(n=>e.jsx("option",{value:n.voice_id,children:n.name||n.voice_id},`${n.voice_id}-${n.model||""}`))},d));function Ee(o){return new Set((o||[]).map(d=>String(d.language||"").toLowerCase()).filter(d=>d&&d!=="all")).size>1}function Te(o){const p=new Set((o||[]).map(d=>String(d.language||"").toLowerCase()).filter(d=>d&&d!=="all"));return Array.from(p).sort().map(d=>[d,js[d]||d.toUpperCase()])}function us(o,p){if(!p||p==="all")return o||[];const d=(o||[]).filter(g=>String(g.language||"").toLowerCase()===String(p).toLowerCase());return d.length>0?d:o||[]}const bs=[{id:"sonic-3.5",name:"Sonic 3.5"},{id:"sonic-3",name:"Sonic 3"},{id:"sonic-turbo",name:"Sonic Turbo"}],Le=new Set(bs.map(({id:o})=>o)),ms="a0e99841-438c-4a64-b679-ae501e7d6091",De=[{id:"aura-2-thalia-en",name:"Thalia",detail:"Female, American, clear and energetic"},{id:"aura-2-andromeda-en",name:"Andromeda",detail:"Female, American, expressive customer support"},{id:"aura-2-helena-en",name:"Helena",detail:"Female, American, friendly and natural"},{id:"aura-2-apollo-en",name:"Apollo",detail:"Male, American, confident and casual"},{id:"aura-2-arcas-en",name:"Arcas",detail:"Male, American, smooth and clear"},{id:"aura-2-aries-en",name:"Aries",detail:"Male, American, warm and energetic"},{id:"aura-2-amalthea-en",name:"Amalthea",detail:"Female, Filipino English, cheerful"},{id:"aura-2-draco-en",name:"Draco",detail:"Male, British, professional"},{id:"aura-2-luna-en",name:"Luna",detail:"Female, British, warm and clear"},{id:"aura-2-orpheus-en",name:"Orpheus",detail:"Male, American, polished"}],Ha=new Set(De.map(({id:o})=>o)),fe=De[0].id;function ve(o){return Ha.has(String(o||""))?String(o):fe}function hs(o,p){return(o||[]).find(d=>String(d.voice_id||"")===String(p||""))}function gs(o){const p=String(o?.language||"").trim().toLowerCase();return p&&p!=="all"?p:""}function $a(o,p=null){const g={...La,...p?.llm||{}}[o.model]||{input:.3,output:.6}
1,n=Fa[o.transcriber]??.111,f=Va[o.voiceModel]||{per1kChars:.015},y=o.systemPrompt?Math.ceil(String(o.systemPrompt).length/4):0,k=(Pa+y*Ta)/1e6*g.input+_a/1e6*g.output,v=n/60,x=f.perMin!=null?f.perMin:f.per1kChars/1e3*Ea,I=Number(p?.platformFeePerMin)||0,m=k+v+x+I;return{shape:"canonical",source:"local_static",components:{llm:{model:o.model,totalUSD:k},stt:{model:o.transcriber,totalUSD:v},tts:{model:o.voiceModel,totalUSD:x},platform:{totalUSD:I}},total:{usd:m}}}function fn(){const[o,p]=c.useState([]),[d,g]=c.useState(!1),[n,f]=c.useState(null),[y,C]=c.useState(!1),k=c.useRef(null),[v,x]=c.useState({plan:null,allowed:!1,loading:!0,error:!1});c.useEffect(()=>{let s=!1;return(async()=>{x(t=>({...t,loading:!0,error:!1}));try{const t=await T.authedFetch(w.getApiUrl("/api/auth/me"));if(!t.ok)throw new Error("Could not verify recording access");const i=await t.json();if(s||!i?.user)return;x({plan:i.user.subscriptionPlan||"free",allowed:!!i.user.recordingAllowed,loading:!1,error:!1});try{const r=JSON.parse(localStorage.getItem("user")||"{}");localStorage.setItem("user",JSON.stringify({...r,subscriptionPlan:i.user.subscriptionPlan||"free",subscriptionStatus:i.user.subscriptionStatus||"active",recordingAccess:!!i.user.recordingAccess,recordingAllowed:!!i.user.recordingAllowed}))}catch{}}catch{s||x({plan:null,allowed:!1,loading:!1,error:!0})}})(),()=>{s=!0}},[]);const[I,m]=c.useState([]),[N,b]=c.useState([]),[S,B]=c.useState([]),[F,V]=c.useState([]),[Q,G]=c.useState([]),[q,J]=c.useState([]),[O,X]=c.useState({multilingual:[],english:[],hindi:[],chinese:[]}),[K,j]=c.useState([]),[M,D]=c.useState([]),[Z,ce]=c.useState([]),[Be,ys]=c.useState([]),[Ns,Re]=c.useState(!1),[je,be]=c.useState([]),[Oe,ks]=c.useState(()=>cs("cached_pricing")||null),[ye,Ss]=c.useState(null),[ws,ze]=c.useState(!0),[Ue,Ne]=c.useState(!0),[_,W]=c.useState("model"),[Cs,de]=c.useState(!1),[Qa,Ya]=c.useState(!1),[Ja,Xa]=c.useState(null),[Ms,ee]=c.useState(!1),[A,R]=c.useState({promptQuality:"cost_effective",businessName:"",industry:"",role:"",callType:"both",mainGoal:"",requiredInfo:"",tone:"professional, friendly, calm, and confident",escalationRules:"",tools:"",extraInstructions:""}),[z,He]=c.useState(!1),[$e,pe]=c.useState(null),[Za,en]=c.useState(""),[sn,an]=c.useState(!1),[nn,tn]=c.useState(null),[ln,rn]=c.useState(null),Ge=c.useRef(!1);c.useRef(!1);const[se,ue]=c.useState(!1),[ke,We]=c.useState(!1),[qe,Ke]=c.useState(null),[Se,Qe]=c.useState(null),E=(s,a="success",t=2600)=>{Qe({message:s,kind:a}),window.__toastTimer&&clearTimeout(window.__toastTimer),window.__toastTimer=setTimeout(()=>Qe(null),t)},[me,we]=c.useState({name:"",model:"openai/gpt-oss-20b",transcriber:"whisper-large-v3",voice:"Cartesia Sonic"}),[on,cn]=c.useState({provider:"Groq",model:"openai/gpt-oss-20b",firstMessageMode:"user_speaks_first",firstMessage:"Hello.",systemPrompt:"This is a blank template with minimal defaults, you can change the model, temperature, and messages."});c.useEffect(()=>{Ye(),Ps(),Es(),Ts(),_s()},[]),c.useEffect(()=>{const s=n?.voiceProvider||"cartesia";Q.some(a=>a.id===s&&a.available)&&(s==="elevenlabs"?Ls():s==="minimax"?Is():["inworld","smallest","rime","fish"].includes(s)&&As(s))},[n?.voiceProvider,Q]);const Is=async()=>{try{const a=await(await T.authedFetch(w.getApiUrl("/api/tts/minimax/voices"))).json();a.success&&a.voices&&X(a.voices)}catch(s){console.warn("Failed to fetch MiniMax voices:",s.message)}},As=async s=>{const a=async(r,u)=>{try{const L=await(await T.authedFetch(w.getApiUrl(r))).json();L.success&&Array.isArray(L.voices)&&u(L.voices)}catch(h){console.warn(`Failed to fetch voices from ${r}:`,h.message)}},i={inworld:["/api/tts/inworld/voices",j],smallest:["/api/tts/smallest/voices",D],rime:["/api/tts/rime/voices",ce],fish:["/api/tts/fish/voices",ys]}[s];i&&await a(...i)},ae=()=>{console.log("🔒 Token expired - logging out..."),localStorage.clear(),E("Your session has expired. Please log in again.","error"),window.location.href="/auth"},Ye=async()=>{try{ze(!0),console.log("🔄 Fetching LLM models from API...");const a=await(await T.authedFetch(w.getApiUrl("/api/models"))).json();if(console.log("📊 LLM Models API response:",a),a.success){const t=a.models.llm||{},i=["thinking","prompt-guard","prompt guard","guardrail","safeguard","safety","compound","orpheus","canopylabs","canopy labs","qwen3-235b","qwen3-next"],r=Object.entries(t).filter(([u,h])=>{const L=`${u} ${h?.name||""} ${h?.description||""} ${h?.ownedBy||""}`.toLowerCase(),H=Number(h?.latency||0);return!i.some(Y=>L.includes(Y))&&(!H||H<=1e3)}).map(([u,h])=>({key:u,name:h.name||u,latency:h.latency,speed:h.speed,pricing:h.pricing,description:h.description,contextWindow:h.contextWindow,ownedBy:h.ownedBy,runtimeProvider:h.runtimeProvider,exclusive:!!h.exclusive}));
1m(r),console.log("… LLM Models loaded:",r.length,"models"),console.log("📋 Available LLM models:",r.map(u=>`${u.name} (${u.speed} TPS, $${u.pricing?.input}/${u.pricing?.output})`))}else throw console.error("Error LLM Models API failed:",a.error),new Error(a.error)}catch(s){console.error("Error Error fetching LLM models:",s);const a=[{key:"openai/gpt-oss-120b",name:"GPT OSS 120B",latency:180,speed:500,pricing:{input:.15,output:.75},description:"Advanced reasoning and function calling"},{key:"openai/gpt-oss-20b",name:"GPT OSS 20B",latency:110,speed:1e3,pricing:{input:.1,output:.5},description:"Fast reasoning and function calling"},{key:"gpt-5.4-nano",name:"GPT-5.4 Nano (Instant)",latency:400,speed:null,pricing:{input:.2,output:1.25},description:"Newest low-cost GPT-5.4 model for simple call turns",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5.4-mini",name:"GPT-5.4 Mini (Premium)",latency:450,speed:null,pricing:{input:.75,output:4.5},description:"Stronger GPT-5.4 mini model for important calls",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5.4-nano-instruct",name:"GPT-5.4 Nano Instruct (Instant)",latency:400,speed:null,pricing:{input:.2,output:1.25},description:"Instruction-following GPT-5.4 nano option for strict call scripts",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5.4-mini-instruct",name:"GPT-5.4 Mini Instruct (Premium)",latency:450,speed:null,pricing:{input:.75,output:4.5},description:"Instruction-following GPT-5.4 mini option for premium call handling",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5-nano",name:"GPT-5 Nano (Instant)",latency:350,speed:null,pricing:{input:.05,output:.4},description:"Lowest-cost GPT-5 option for simple call flows",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5-nano-instruct",name:"GPT-5 Nano Instruct (Instant)",latency:350,speed:null,pricing:{input:.05,output:.4},description:"Instruction-following GPT-5 nano option for simple call flows",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5-mini-instruct",name:"GPT-5 Mini Instruct (Instant)",latency:450,speed:null,pricing:{input:.25,output:2},description:"Instruction-following GPT-5 mini option for tool-aware calls",ownedBy:"OpenAI",exclusive:!0},{key:"gpt-5-mini",name:"GPT-5 Mini (Instant)",latency:450,speed:null,pricing:{input:.25,output:2},description:"Cost-efficient GPT-5 model for focused call turns",ownedBy:"OpenAI",exclusive:!0}
1,{key:"MiniMax-M2.7-highspeed",name:"MiniMax M2.7 Highspeed",latency:450,speed:null,pricing:{input:.6,output:2.4},description:"Fast MiniMax model for live voice calls and natural conversation",ownedBy:"MiniMax"},{key:"mistral-small-latest",name:"Mistral Small",latency:450,speed:null,pricing:{input:.1,output:.3},description:"Low-cost Mistral model for talkative voice agents",ownedBy:"Mistral AI"},{key:"ministral-14b-latest",name:"Ministral 14B",latency:420,speed:null,pricing:{input:.2,output:.2},description:"Cheap compact Mistral model for simple call flows",ownedBy:"Mistral AI"},{key:"qwen3-30b-a3b-instruct-2507",name:"Qwen3 30B A3B Instruct",latency:350,speed:null,pricing:{input:.2,output:.8},description:"Low-cost Qwen model for fast live calls, tool use, and follow-up workflows",ownedBy:"Qwen / Alibaba Cloud"},{key:"Qwen/Qwen3-30B-A3B",name:"Qwen 3 30B A3B (DeepInfra)",latency:320,speed:null,pricing:{input:.12,output:.5},description:"Lowest measured latency, multilingual, tool calling verified",ownedBy:"Qwen / DeepInfra",runtimeProvider:"deepinfra"},{key:"mistralai/Mistral-Small-3.2-24B-Instruct-2506",name:"Mistral Small 3.2 24B (DeepInfra)",latency:335,speed:null,pricing:{input:.075,output:.2},description:"Fast and cheap with the most consistent tool calling",ownedBy:"Mistral AI / DeepInfra",runtimeProvider:"deepinfra"},{key:"google/gemma-4-31B-it-turbo",name:"Gemma 4 31B Turbo (DeepInfra)",latency:341,speed:null,pricing:{input:.09,output:.34},description:"Latest Gemma 4, speed-optimised, 262K context",ownedBy:"Google / DeepInfra",runtimeProvider:"deepinfra"},{key:"nvidia/Nemotron-3-Nano-30B-A3B",name:"Nemotron 3 Nano 30B (DeepInfra)",latency:343,speed:null,pricing:{input:.05,output:.2},description:"Very fast, cheap output, 262K context, tool calling verified",ownedBy:"NVIDIA / DeepInfra",runtimeProvider:"deepinfra"},{key:"google/gemma-4-26B-A4B-it",name:"Gemma 4 26B A4B (DeepInfra)",latency:356,speed:null,pricing:{input:.07,output:.34},description:"Sparse Gemma 4 — cheapest input in the Gemma 4 family",ownedBy:"Google / DeepInfra",runtimeProvider:"deepinfra"},{key:"Qwen/Qwen3-32B",name:"Qwen 3 32B (DeepInfra)",latency:355,speed:null,pricing:{input:.08,output:.28},description:"Best multilingual option for Hindi and regional calls",ownedBy:"Qwen / DeepInfra",runtimeProvider:"deepinfra"},{key:"Qwen/Qwen3.5-397B-A17B",name:"Qwen 3.5 397B (DeepInfra)",latency:371,speed:null,pricing:{input:.45,output:3},description:"Frontier Qwen quality for the hardest calls",ownedBy:"Qwen / DeepInfra",runtimeProvider:"deepinfra"},{key:"google/gemma-3-27b-it",name:"Gemma 3 27B (DeepInfra)",latency:429,speed:null,pricing:{input:.08,output:.16},description:"Cheap and fast; best for conversation rather than tools",ownedBy:"Google / DeepInfra",runtimeProvider:"deepinfra"},{key:"zai-org/GLM-4.7-Flash",name:"GLM 4.7 Flash (DeepInfra)",latency:490,speed:null,pricing:{input:.06,output:.4},description:"Long-context tool use, 202K window, cheap input",ownedBy:"Z.ai / DeepInfra",runtimeProvider:"deepinfra"},{key:"meta-llama/Llama-3.3-70B-Instruct-Turbo",name:"Llama 3.3 70B Turbo (DeepInfra)",latency:516,speed:null,pricing:{input:.1,output:.32},description:"Drop-in replacement for the retired Groq Llama 3.3 70B",ownedBy:"Meta / DeepInfra",runtimeProvider:"deepinfra"},{key:"deepseek-ai/DeepSeek-V4-Flash-0731",name:"DeepSeek V4 Flash 0731 (DeepInfra)",latency:564,speed:null,pricing:{input:.08,output:.18},description:"Best value frontier model — 1M context, strong agentic use",ownedBy:"DeepSeek / DeepInfra",runtimeProvider:"deepinfra"},{key:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",name:"Llama 3.1 8B Turbo (DeepInfra)",latency:610,speed:null,pricing:{input:.02,output:.04},description:"Cheapest model on the platform; best for scripted flows",ownedBy:"Meta / DeepInfra",runtimeProvider:"deepinfra"},{key:"meta-llama/Llama-4-Scout-17B-16E-Instruct",name:"Llama 4 Scout (DeepInfra)",latency:718,speed:null,pricing:{input:.1,output:.3},description:"Llama 4 MoE with 327K context",ownedBy:"Meta / DeepInfra",runtimeProvider:"deepinfra"},{key:"openai/gpt-oss-120b",name:"GPT-OSS 120B (DeepInfra)",latency:880,speed:null,pricing:{input:.037,output:.17},description:"Same weights as Groq GPT-OSS 120B at a fraction of the cost",ownedBy:"OpenAI / DeepInfra",runtimeProvider:"deepinfra"},{key:"deepseek-ai/DeepSeek-V4-Flash",name:"DeepSeek V4 Flash (DeepInfra)",latency:929,speed:null,pricing:{input:.09,output:.18},description:"Budget frontier model — 284B total / 13B active, 1M context",ownedBy:"DeepSeek / DeepInfra",runtimeProvider:"deepinfra"},{key:"MiniMaxAI/MiniMax-M2.7-Turbo",name:"MiniMax M2.7 Turbo (DeepInfra)",latency:1489,speed:null,pricing:{input:.38,output:1.7},description:"Conversational specialist, 196K context — premium tier",ownedBy:"MiniMax / DeepInfra",runtimeProvider:"deepinfra"}];m(a),console.log(" Using fallback LLM models:",a.length)}finally{ze(!1)}},Ps=async()=>{try{console.log("🔄 Fetching transcribers from API...");const a=await(await T.authedFetch(w.getApiUrl("/api/transcribers"))).json();if(console.log("🎙️ Transcribers API response:",a),a.success){const t=a.models?.stt||{},i=Object.entries(t).map(([r,u])=>({key:r,name:u.name||r,speedFactor:u.speedFactor,pricePerHour:u.pricing?.inputPerHour,pricePerMinute:u.pricing?.inputPerMinute,latency:u.latency,description:u.description}));b(i),console.log("… Transcribers loaded:",i.length,"models"),console.log("📋 Available transcribers:",i.map(r=>`${r.name} (${r.latency}ms)`))}else throw console.error("Error Transcribers API failed:",a.error),new Error(a.error)}catch(s){console.error("Error Error fetching transcribers:",s);const a=[{key:"deepgram-nova-2",name:"Deepgram Nova-2 (ULTRA-FAST)",speedFactor:"Real-time",pricePerHour:.258,pricePerMinute:.0043,latency:400,description:"3x faster than Whisper"},{key:"deepgram-nova-2-phonecall",name:"Deepgram Nova-2 Phone Call",speedFactor:"Real-time",pricePerHour:.258,pricePerMinute:.0043,latency:400,description:"Optimized for phone calls"},{key:"deepgram-nova-2-multilingual",name:"Deepgram Nova-2 Multilingual",speedFactor:"Real-time",pricePerHour:.258,pricePerMinute:.0043,latency:400,description:"Code-switching English + Hindi/Hinglish in real time"},{key:"deepgram-nova-3",name:"Deepgram Nova-3 (newest)",speedFactor:"Real-time",pricePerHour:.29,pricePerMinute:.0048,latency:400,description:"Latest Deepgram model, best accuracy"},{key:"mistral-voxtral-mini-realtime",name:"Mistral Voxtral Mini Realtime",speedFactor:"Real-time",pricePerHour:null,pricePerMinute:null,latency:900,description:"Realtime streaming speech-to-text for live voice agents"}
1,{key:"qwen3-asr-flash-realtime",name:"Qwen3 ASR Flash Realtime",speedFactor:"Real-time",pricePerHour:.324,pricePerMinute:.0054,latency:700,description:"Realtime Qwen speech-to-text with live audio chunks"},{key:"whisper-large-v3",name:"Whisper V3 Large (FREE, multilingual)",speedFactor:"217x",pricePerHour:0,pricePerMinute:0,latency:1500,description:"High accuracy, supports Hindi/Hinglish, FREE"},{key:"whisper-large-v3-turbo",name:"Whisper Large v3 Turbo (FREE)",speedFactor:"228x",pricePerHour:0,pricePerMinute:0,latency:1e3,description:"Faster Whisper, multilingual, FREE"}];b(a),console.log(" Using fallback transcribers:",a.length)}},_s=async()=>{try{const a=await(await fetch(w.getApiUrl("/api/pricing"))).json();if(a.success){const t={llm:a.llm||{},stt:a.stt||{},tts:a.tts||{},platformFeePerMin:a.platformFeePerMin??0};ks(t),re("cached_pricing",t)}}catch{console.warn("Pricing table fetch failed; using local static pricing.")}},Es=async()=>{try{console.log("🔄 Fetching voices from API...");const a=await(await T.authedFetch(w.getApiUrl("/api/voices"))).json();if(console.log("🎤 Voices API response:",a),a.success){const t=a.models||{},i=Object.entries(t).filter(([u])=>Le.has(u)).map(([u,h])=>({key:u,name:h.name||u,latency:h.latency,description:h.description}));B(i.length>0?i:bs.map(({id:u,name:h})=>({key:u,name:h}))),console.log("… Voice models loaded:",i.length,"models");const r=Object.entries(a.voices).map(([u,h])=>({key:u,id:h.id,name:h.name,language:h.language,gender:h.gender,accent:h.accent,description:h.description}));V(r),console.log("… Voices loaded:",r.length,"voices"),console.log("🎵 Sample voices:",r.slice(0,5).map(u=>`${u.name} (${u.gender}, ${u.accent})`))}else throw console.error("Error Voices API failed:",a.error),new Error(a.error)}catch(s){console.error("Error Error fetching voices:",s);const a=[{key:"sonic-3.5",name:"Sonic 3.5",latency:100,description:"Best quality, 42 languages"},{key:"sonic-3",name:"Sonic 3",latency:110,description:"Speed/volume/emotion controls, 42 languages"},{key:"sonic-turbo",name:"Sonic Turbo",latency:40,description:"Lowest latency (40ms), 10 languages"}];B(a),V([{key:"a0e99841-438c-4a64-b679-ae501e7d6091",id:"a0e99841-438c-4a64-b679-ae501e7d6091",name:"British Lady",language:"en",gender:"female",accent:"british"}]),console.log(" Using fallback voices:",a.length,"models")}},Ts=async()=>{const s=(a=[])=>{const t=[...a],i=[{id:"cartesia",name:"Cartesia"},{id:"elevenlabs",name:"ElevenLabs"},{id:"minimax",name:"MiniMax Voice"},{id:"deepgram",name:"Deepgram Aura"},{id:"sarvam",name:"Sarvam Bulbul v3"},{id:"azure",name:"Azure Neural Voices",available:!1,unavailableReason:"Temporarily unavailable — key needs re-verification"},{id:"openai",name:"OpenAI TTS"},{id:"inworld",name:"Inworld TTS"},{id:"smallest",name:"Smallest.ai Waves"},{id:"rime",name:"Rime AI"}];for(const r of i)t.some(u=>u.id===r.id)||t.push({available:!0,...r});return t};try{const a=await T.authedFetch(w.getApiUrl("/api/tts/providers")),t=a.headers.get("content-type");if(!t||!t.includes("application/json"))throw new Error("Invalid response format");const i=await a.json(),r=s(i.providers);G(r)}catch(a){console.error("Error fetching TTS providers:",a),G(s())}},Ls=async()=>{try{const[s,a]=await Promise.all([T.authedFetch(w.getApiUrl("/api/tts/elevenlabs/voices")),T.authedFetch(w.getApiUrl("/api/tts/elevenlabs/models"))]),t=await s.json(),i=await a.json();t.voices?(J(t.voices),console.log("… ElevenLabs voices loaded:",t.voices.length)):(console.warn(" No voices returned, using fallback"),J([{voice_id:"21m00Tcm4TlvDq8ikWAM",name:"Rachel",category:"premade"},{voice_id:"EXAVITQu4vr4xnSDxMaL",name:"Bella",category:"premade"},{voice_id:"ErXwobaYiN019PkySvjV",name:"Antoni",category:"premade"}])),i.models?(be(i.models.filter(r=>!["eleven_monolingual_v1","eleven_multilingual_v1"].includes(r.model_id))),console.log("… ElevenLabs models loaded:",i.models.length)):(console.warn(" No models returned, using fallback"),be([{model_id:"eleven_v3",name:"Eleven v3",description:"Latest expressive model"},{model_id:"eleven_multilingual_v2",name:"Eleven Multilingual v2",description:"Supports multiple languages"},{model_id:"eleven_flash_v2_5",name:"Eleven Flash v2.5",description:"Fastest model for live calls"},{model_id:"eleven_turbo_v2_5",name:"Eleven Turbo v2.5",description:"Fast model with strong quality"}]))}catch(s){console.error("Error Error fetching ElevenLabs data:",s),console.log("📋 Using fallback ElevenLabs data"),J([{voice_id:"21m00Tcm4TlvDq8ikWAM",name:"Rachel",category:"premade"},{voice_id:"EXAVITQu4vr4xnSDxMaL",name:"Bella",category:"premade"},{voice_id:"ErXwobaYiN019PkySvjV",name:"Antoni",category:"premade"}]),be([{model_id:"eleven_v3",name:"Eleven v3",description:"Latest expressive model"},{model_id:"eleven_multilingual_v2",name:"Eleven Multilingual v2",description:"Supports multiple languages"},{model_id:"eleven_flash_v2_5",name:"Eleven Flash v2.5",description:"Fastest model for live calls"},{model_id:"eleven_turbo_v2_5",name:"Eleven Turbo v2.5",description:"Fast model with strong quality"}])}},Je=c.useCallback(s=>{if(!s)return;let a=s.voiceModel||"sonic-3.5";if(s.voiceProvider==="elevenlabs")a=s.elevenLabsModel||"eleven_flash_v2_5";else if(s.voiceProvider==="minimax")a=xe(s.minimaxModel);else if(s.voiceProvider==="deepgram")a=ve(s.deepgramVoiceModel);else if(s.voiceProvider==="azure")a="azure-neural";else if(s.voiceProvider==="openai")a=s.voiceModel||"gpt-4o-mini-tts";else if(s.voiceProvider==="inworld")a=s.voiceModel||"inworld-tts-1.5-max";else if(s.voiceProvider==="smallest")a=s.voiceModel||"lightning_v3.1";else if(s.voiceProvider==="rime")a=s.voiceModel||"mistv2";else if(s.voiceProvider==="sarvam")a="bulbul-v3";else if((s.voiceProvider||"cartesia")==="cartesia"){const i=String(s.voiceModel||"");a=Le.has(i)?i:"sonic-3.5"}const t={model:s.model||"openai/gpt-oss-20b",transcriber:s.transcriber||"whisper-large-v3",voiceProvider:s.voiceProvider||null,voiceModel:a,systemPrompt:s.systemPrompt||""};Ss($a(t,Oe))},[Oe]),Fs=async()=>
1{if(!n)return;if(![A.businessName,A.industry,A.role,A.mainGoal,A.requiredInfo,A.tools,A.extraInstructions].some(a=>String(a||"").trim().length>0)){pe("Add a short business description, role, goal, or tool details first.");return}He(!0),pe(null);try{const t=await(await T.authedFetch(w.getApiUrl("/api/assistants/generate-system-prompt"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"generate",assistantId:n.id,assistantName:n.name,...A})})).json();t.success&&t.prompt?(l("systemPrompt",t.prompt),ee(!1),E(t.source==="llm"?"Prompt generated":"Prompt generated from template","success")):pe(t.error||"Failed to generate prompt")}catch{pe("Network error. Please try again.")}finally{He(!1)}},Ce=(n?.systemPrompt||"").length,ne=Math.ceil(Ce/4),U=ne>=1e4?{level:"high",text:"Not recommended for realtime calls."}:ne>=5e3?{level:"medium",text:"Very long prompt may increase latency."}:ne>=2e3?{level:"low",text:"Long prompt may increase cost."}:null;c.useEffect(()=>{if(!y)return;const s=document.body.style.overflow;document.body.style.overflow="hidden";const a=i=>{i.key==="Escape"&&C(!1)};document.addEventListener("keydown",a);const t=setTimeout(()=>{k.current&&k.current.focus()},0);return()=>{document.body.style.overflow=s,document.removeEventListener("keydown",a),clearTimeout(t)}},[y]);const Vs={instant:"Best for Quick Calls",standard:"Best for Simple Calls",balanced:"Best for Balanced Calls",pro:"Best for High-Thinking Calls",max:"Best for Complex Reasoning"},Ds={"llama-3.1-8b-instant":"instant","llama3-8b-8192":"instant","gemma2-9b-it":"instant","allam-2-7b":"instant","mixtral-8x7b-32768":"standard","qwen/qwen3-32b":"standard","ministral-14b-latest":"standard","mistral-small-latest":"standard","llama-3.3-70b-versatile":"balanced","llama-3.1-70b-versatile":"balanced","llama3-70b-8192":"balanced","meta-llama/llama-4-scout-17b-16e-instruct":"balanced","qwen3-30b-a3b-instruct-2507":"balanced","qwen3-next-80b-a3b-instruct":"balanced","qwen3-235b-a22b-instruct-2507":"pro","MiniMax-M2.7-
1highspeed":"pro","openai/gpt-oss-20b":"pro","openai/gpt-oss-120b":"max","openai/gpt-oss-safeguard-20b":"pro"};function Bs(s){const a=String(s||"").toLowerCase();return a.includes("nano")||a.includes("instant")||a.includes("8b")||a.includes("9b")||a.includes("7b")?"instant":a.includes("120b")||a.includes("235b")||a.includes("safeguard")?"max":a.includes("70b")||a.includes("80b")||a.includes("versatile")||a.includes("scout")?"balanced":a.includes("20b")||a.includes("30b")||a.includes("32b")?"pro":"standard"}function Rs(s){const a=String(s?.key||"");return String(s?.name||a||"Model").trim().replace(/\s+\((ULTRA-FAST|FREE|Premium|Instant)\)/gi,"").replace(/^gpt-oss-/i,"GPT OSS ").replace(/^gpt-5\.4/i,"GPT-5.4").replace(/^gpt-5/i,"GPT-5").replace(/\binstruct\b/i,"Instruct").replace(/\bnano\b/i,"Nano").replace(/\bmini\b/i,"Mini").replace(/\s+/g," ").trim()}function Os(s){if(Xe(s)==="OpenAI")return Rs(s);const a=String(s?.key||""),t=Ds[a]||Bs(a);return Vs[t]||"Available Model"}function zs(s){const a=String(s?.key||"");return String(s?.name||a||"Model").trim().replace(/^Qwen\s+(Qwen)/i,"$1").replace(/^Llama\s+(Llama)/i,"$1").replace(/^Mistral\s+(Mistral)/i,"$1").replace(/\s+\((ULTRA-FAST|FREE|Premium)\)/gi,"").replace(/\s+/g," ").trim()}function Xe(s){const a=`${s?.provider||""} ${s?.ownedBy||""} ${s?.key||""} ${s?.name||""}`.toLowerCase();return a.includes("gpt")||a.includes("openai")?"OpenAI":a.includes("llama")?"Meta Llama":a.includes("qwen")?"Qwen":a.includes("mistral")||a.includes("mixtral")?"Mistral":a.includes("minimax")?"MiniMax":a.includes("gemini")||a.includes("gemma")?"Google":a.includes("sarvam")?"Sarvam AI":a.includes("allam")?"Allam":a.includes("orpheus")||a.includes("canopy")?"Canopy Labs":a.includes("compound")||a.includes("groq")?"Groq":a.includes("guard")||a.includes("safeguard")?"Safety Models":"Other models"}function Us(s){const a=String(s?.key||"").toLowerCase();return a.startsWith("gpt-5")&&a.includes("instruct")?"Instruction-following option for strict call scripts":a.includes("nano")?"Lowest-cost option for simple call turns":a.includes("gpt-5.4-mini")?"Strong mini model for important calls":s?.exclusive||a.startsWith("gpt-")?"Cost-efficient model for focused calls":a.includes("minimax-m2.7")?"Fast option for live calls":a.includes("mistral-small")?"Very low-cost model for talkative agents":a.includes("ministral")?"Cheap compact model for simple call flows":a.includes("compound")?"Best when tools and multi-step routing matter":a.includes("llama-3.1")||a.includes("instant")?"Fast replies with lower running cost":a.includes("llama-3.3")||a.includes("70b")||a.includes("versatile")?"Balanced quality for production calls":a.includes("qwen")||a.includes("allam")||a.includes("orpheus")?"Good for multilingual or regional use cases":a.includes("guard")||a.includes("safeguard")?"Used for safety checks and guardrails":"Available AI reasoning model"}const Hs=["OpenAI","MiniMax","Mistral","Meta Llama","Qwen","Google","Groq","Allam","Canopy Labs","Safety Models","Other models"],Ze=(()=>{const s=new Map,a=new Map;for(const t of I||[]){const i=Xe(t);s.has(i)||s.set(i,[]),a.has(i)||a.set(i,new Map);const r=a.get(i);let u=Os(t);const h=r.get(u)||0;r.set(u,h+1),h>0&&(u=`${u} ${h+1}`),s.get(i).push({...t,displayName:u,helper:Us(t)})}return Hs.map(t=>({cat:t,label:t,items:s.get(t)||[]})).filter(t=>t.items.length>0)})();function $s(s){const a=`${s?.provider||""} ${s?.key||""} ${s?.name||""}`.toLowerCase();return a.includes("deepgram")?"Deepgram":a.includes("assembly")?"AssemblyAI":a.includes("qwen")||a.includes("dashscope")||a.includes("alibaba")?"Qwen / Alibaba Cloud":a.includes("mistral")||a.includes("voxtral")?"Mistral":a.includes("sarvam")?"Sarvam AI":a.includes("azure")?"Azure":a.includes("whisper")?"Whisper":"Other transcribers"}function Gs(s){const a=String(s?.key||"").toLowerCase();return a.includes("deepgram")&&a.includes("phone")?"Recommended for phone calls":a.includes("deepgram")?"Fast live transcription for calls":a.includes("assembly")?"Low-latency English streaming, cheaper than Deepgram":a.includes("qwen")?"Realtime WebSocket transcription with multilingual support":a.includes("voxtral")||a.includes("mistral")?"Streaming speech-to-text option":a.includes("sarvam")?"Useful for Indian language workflows":a.includes("azure")?"Enterprise speech-to-text option":a.includes("whisper")?"Good low-cost multilingual fallback":s?.description||"Available speech-to-text model"}const Ws=["Deepgram","AssemblyAI","Qwen / Alibaba Cloud","Whisper","Mistral","Sarvam AI","Azure","Other transcribers"],es=(()=>{const s=new Map;for(const a of N||[]){const t=$s(a);s.has(t)||s.set(t,[]),s.get(t).push({...a,displayName:zs(a),helper:Gs(a)})}return Ws.map(a=>({cat:a,label:a,items:s.get(a)||[]})).filter(a=>a.items.length>0)})(),ss=(()=>{const s=new Map;for(const a of Q||[]){const t=za(a.id);s.has(t)||s.set(t,[]),s.get(t).push({...a,key:a.id,displayName:a.name,helper:Ra[String(a.id||"").toLowerCase()]||""})}return Oa.map(a=>({cat:a,label:a,items:s.get(a)||[]})).filter(a=>a.items.length>0)})();c.useEffect(()=>{if(Ge.current)return;Ge.current=!0;const s=cs("cached_assistants"),a=Array.isArray(s)?s.filter(t=>t?.status!=="deleted"):[];a.length>0&&(p(a),f(t=>t||a[0]),Ne(!1)),Me()},[]);const Me=async()=>{Ne(!0);try{console.log("🔄 Fetching assistants from MongoDB...");const s=localStorage.getItem("token"),a=await fetch(w.getApiUrl("/api/assistants"),{headers:{Authorization:`Bearer ${s}`}});if(a.status===401){ae();return}const t=await a.json();if(t.success){const i=(t.assistants||[]).filter(r=>r?.status!=="deleted");console.log("… Assistants loaded from MongoDB:",i.length),i.length>0?(p(i),re("cached_assistants",i),f(r=>{if(r){const u=i.find(h=>h.id===r.id);if(u)return u}return i[0]})):(p([]),f(null),re("cached_assistants",[]))}else console.error("Error Failed to fetch assistants:",t.error)}catch(s){console.error("Error Error fetching assistants from MongoDB:",s)}finally{Ne(!1)}};c.useEffect(()=>{n&&Je(n)},[n?.id,n?.model,n?.transcriber,n?.voiceModel,n?.voiceProvider,n?.elevenLabsModel,n?.minimaxModel,n?.deepgramVoiceModel,n?.systemPrompt,Je]);const as=s=>{if(!s)return{};const a={_id:s._id,name:s.name,status:s.status,model:s.model,llmProvider:s.llmProvider||ps(s.model),transcriber:s.transcriber,voiceProvider:s.voiceProvider,voiceModel:s.voiceModel,firstMessageMode:s.firstMessageMode,systemPrompt:s.systemPrompt,userId:s.userId,createdAt:s.createdAt,updatedAt:s.updatedAt,hipaaCompliance:s.hipaaCompliance,zeroDataRetention:s.zeroDataRetention,audioRecording:s.audioRecording,logging:s.logging,transcript:s.transcript,audioRecordingFormat:s.audioRecordingFormat,videoRecording:s.videoRecording,waitSeconds:s.waitSeconds,smartEndpointing:s.smartEndpointing,onPunctuationSeconds:s.onPunctuationSeconds,onNoPunctuationSeconds:s.onNoPunctuationSeconds,onNumberSeconds:s.onNumberSeconds,voicemailDetectionEnabled:s.voicemailDetectionEnabled,voicemailDetectionProvider:s.voicemailDetectionProvider,voicemailInitialDetectionDelay:s.voicemailInitialDetectionDelay,voicemailDetectionRetryInterval:s.voicemailDetectionRetryInterval,voicemailMaxDetectionRetries:s.voicemailMaxDetectionRetries,voicemailMaxMessageWait:s.voicemailMaxMessageWait,voicemailBehavior:s.voicemailBehavior,voicemailMessage:s.voicemailMessage,stopSpeakingNumWords:s.stopSpeakingNumWords,stopSpeakingVoiceSeconds:s.stopSpeakingVoiceSeconds,backoffSeconds:s.backoffSeconds,silenceTimeoutSeconds:s.silenceTimeoutSeconds,silenceFallbackEnabled:s.silenceFallbackEnabled,silenceFallbackAfterSeconds:s.silenceFallbackAfterSeconds,silenceFallbackMaxRetries:s.silenceFallbackMaxRetries,fallbackMessageSilence:s.fallbackMessageSilence,maxDurationSeconds:s.maxDurationSeconds,keypadInputEnabled:s.keypadInputEnabled,keypadInputTimeout:s.keypadInputTimeout,keypadInputDelimiter:s.keypadInputDelimiter,messagingEnabled:s.messagingEnabled,messagingEndCallAfter:s.messagingEndCallAfter,messagingContent:s.messagingContent,backgroundSound:s.backgroundSound,backgroundSoundUrl:s.backgroundSoundUrl,inputMinCharacters:s.inputMinCharacters,punctuationBoundaries:s.punctuationBoundaries,fallbackVoices:s.fallbackVoices,transcriberProvider:s.transcriberProvider,transcriberLanguage:s.transcriberLanguage,backgroundDenoisingEnabled:s.backgroundDenoisingEnabled,fallbackTranscribers:s.fallbackTranscribers};return s.voiceProvider==="cartesia"?a.voiceId=s.voiceId:s.voiceProvider==="elevenlabs"?(a.elevenLabsVoiceId=s.elevenLabsVoiceId,a.elevenLabsModel=s.elevenLabsModel,s.elevenLabsSett
1ings&&(a.elevenLabsSettings=s.elevenLabsSettings)):s.voiceProvider==="minimax"?(a.minimaxModel=xe(s.minimaxModel),a.minimaxVoiceId=s.minimaxVoiceId,a.minimaxVoiceName=s.minimaxVoiceName,a.minimaxLanguage=s.minimaxLanguage,a.minimaxSpeed=s.minimaxSpeed,a.minimaxVolume=s.minimaxVolume,a.minimaxPitch=s.minimaxPitch,a.minimaxUseCustomVoice=s.minimaxUseCustomVoice,a.minimaxCustomVoiceId=s.minimaxCustomVoiceId):s.voiceProvider==="deepgram"?(a.deepgramVoiceModel=ve(s.deepgramVoiceModel),a.voiceId=a.deepgramVoiceModel,a.voiceModel=a.deepgramVoiceModel):s.voiceProvider==="openai"?(a.voiceModel=s.voiceModel||"gpt-4o-mini-tts",a.openaiVoice=s.openaiVoice||s.voiceId||"alloy",a.voiceId=a.openaiVoice,a.voiceSpeed=s.voiceSpeed||1,s.openaiInstructions&&(a.openaiInstructions=s.openaiInstructions)):s.voiceProvider==="inworld"?(a.voiceModel=s.voiceModel||"inworld-tts-1.5-max",a.inworldVoice=s.inworldVoice||s.voiceId||"Ashley",a.voiceId=a.inworldVoice,a.voiceSpeed=s.voiceSpeed||1):s.voiceProvider==="smallest"?(a.voiceModel=["lightning_v3.1","lightning_v3.1_pro"].includes(s.voiceModel)?s.voiceModel:"lightning_v3.1",a.smallestVoice=s.smallestVoice||"kanik",a.smallestLanguage=s.smallestLanguage&&s.smallestLanguage!=="all"?s.smallestLanguage:void 0,a.voiceId=a.smallestVoice,a.voiceSpeed=s.voiceSpeed||1):s.voiceProvider==="rime"?(a.voiceModel=s.voiceModel||"mistv2",a.rimeVoice=s.rimeVoice||s.voiceId||"cove",a.voiceId=a.rimeVoice,a.voiceSpeed=s.voiceSpeed||1):s.voiceProvider==="fish"?(a.fishModel=s.fishModel||"s2.1-pro",a.voiceModel=a.fishModel,a.fishVoiceId=s.fishVoiceId||s.voiceId||"",a.voiceId=a.fishVoiceId,a.fishLatency=s.fishLatency||"balanced",a.fishSpeed=s.fishSpeed??s.voiceSpeed??1,a.voiceSpeed=a.fishSpeed,s.fishVolume!=null&&(a.fishVolume=s.fishVolume),s.fishTemperature!=null&&(a.fishTemperature=s.fishTemperature),s.fishTopP!=null&&(a.fishTopP=s.fishTopP)):s.voiceProvider==="sarvam"&&(a.voiceModel="bulbul-v3",a.sarvamSpeaker=s.sarvamSpeaker||s.voiceId||"aditya",a.sarvamLanguage=s.sarvamLanguage||s.voiceLanguage||"en-IN",a.sarvamPace=s.sarvamPace??s.voiceSpeed??1,a.voiceId=a.sarvamSpeaker),s.transferSettings&&s.transferSettings.phoneNumber&&(a.transferSettings=s.transferSettings),a},qs=()=>{g(!0)},Ks=async s=>{try{const a={name:s.name,model:s.model,transcriber:"deepgram-nova-2",voiceProvider:"cartesia",azureVoiceName:"en-US-AvaNeural",voiceModel:"sonic-3.5",voiceId:ms,elevenLabsVoiceId:"21m00Tcm4TlvDq8ikWAM",elevenLabsModel:"eleven_flash_v2_5",elevenLabsSettings:{stability:.5,similarity_boost:.8,speed:1,style:0,optimize_streaming_latency:1,use_speaker_boost:!1},useCustomVoiceId:!1,customVoiceId:"",voice:s.voice,status:"active",firstMessageMode:"user_speaks_first",systemPrompt:"You are a helpful voice assistant. Be friendly and professional."};console.log("🔄 Creating assistant in MongoDB...");const t=localStorage.getItem("token"),i=await fetch(w.getApiUrl("/api/assistants"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify(a)});if(i.status===401){ae();return}const r=await i.json();r.success?(console.log("… Assistant created in MongoDB:",r.assistant),await Me(),g(!1)):(console.error("Error Failed to create assistant:",r.error),E(`Error: ${r.error}`,"error"))}catch(a){console.error("Error Error creating assistant:",a),E(`Error: ${a.message}`,"error")}},ns=async(s,a)=>{a?.stopPropagation();const t=s?.id;if(!t||qe)return;const i=he(s);if(await oa({title:"Delete assistant",message:`Delete "${i}"? This removes it from your assistant list.`,confirmLabel:"Delete assistant",cancelLabel:"Cancel",kind:"danger"}))try{Ke(t),console.log("🔄 Deleting assistant from MongoDB...");const u=await T.authedFetch(w.getApiUrl(`/api/assistants/${t}`),{method:"DELETE"});if(u.status===401){ae();return}const h=await u.json();if(h.success){console.log("… Assistant deleted from MongoDB:",t);const L=o.filter(H=>H.id!==t);p(L),re("cached_assistants",L),n?.id===t&&(f(L[0]||null),ue(!1)),E("Assistant deleted.","success")}else console.error("Error Failed to delete assistant:",h.error),E(`Error: ${h.error}`,"error")}catch(u){console.error("Error Error deleting assistant:",u),E(`Error: ${u.message}`,"error")}finally{Ke(null)}},Qs=s=>{f(s),s.voiceEngine==="openai_realtime"&&["voice","transcriber","advanced"].includes(_)&&W("model"),ue(!1)},Ys=s=>({"assistant-speaks-first":"model_generated",assistant_speaks_first:"model_generated",ai_speaks_first_with_model_generated_message:"model_generated","model-generated":"model_generated","user-speaks-first":"user_speaks_first","ai-speaks-first":"ai_speaks_first"})[s]||s||"user_speaks_first",is=s=>{const a=String(s||"");return a.startsWith("deepgram")?"deepgram":a.includes("qwen")||a.includes("dashscope")?"qwen":a.startsWith("mistral")||a.includes("voxtral")?"mistral":a.startsWith("whisper")?"groq":null},Js=s=>s==="groq"?"whisper-large-v3-turbo":s==="deepgram"?"deepgram-nova-2":s==="qwen"?"qwen3-asr-flash-realt
1ime":s==="mistral"?"mistral-voxtral-mini-realtime":"whisper-large-v3-turbo",ts=s=>{const a=String(s||"");return a.startsWith("deepgram-")?a.replace("deepgram-",""):a.includes("qwen")?"qwen3-asr-flash-realtime":a.startsWith("mistral-")||a.includes("voxtral")?"voxtral-mini-transcribe-realtime-2602":a||"whisper-large-v3-turbo"},Xs=(s,a,t)=>{const i={...s,firstMessageMode:Ys(s.firstMessageMode),[a]:t};if(a==="model"){const r=I.find(u=>u.key===t);i.llmProvider=ps(t,r)}if(a==="voiceProvider"){const r={cartesia:"Cartesia",elevenlabs:"ElevenLabs",minimax:"MiniMax",deepgram:"Deepgram",azure:"Azure",sarvam:"Sarvam",openai:"OpenAI",inworld:"Inworld",smallest:"Smallest",rime:"Rime"};i.voice=r[t]||t,i.voiceAutoFallback=!1,i.fallbackVoices=[]}if(a==="transcriberProvider"){const r=is(i.transcriber);(!r||r!==t)&&(i.transcriber=Js(t)),i.transcriberModel=ts(i.transcriber),t==="groq"&&!["en","hi"].includes(i.transcriberLanguage)&&(i.transcriberLanguage="en")}if(a==="transcriber"){const r=is(t);r&&(i.transcriberProvider=r),i.transcriberModel=ts(t)}if(a==="voiceProvider"&&t==="cartesia"&&(i.voiceModel="sonic-3.5",i.voiceId=ms,i.voiceLanguage="en"),a==="voiceProvider"&&t==="elevenlabs"&&(i.elevenLabsVoiceId="21m00Tcm4TlvDq8ikWAM",i.elevenLabsModel="eleven_flash_v2_5",i.voiceId=i.elevenLabsVoiceId,i.voiceModel=i.elevenLabsModel,i.elevenLabsSettings={stability:.5,similarity_boost:.8,speed:1,style:0,optimize_streaming_latency:1,use_speaker_boost:!1,...i.elevenLabsSettings||{}},i.useCustomVoiceId=!1,i.customVoiceId=""),a==="voiceProvider"&&t==="minimax"&&(i.minimaxModel="speech-2.6-turbo",i.minimaxVoiceId="Friendly_Person",i.minimaxLanguage="auto",i.minimaxSpeed=1,i.minimaxUseCustomVoice=!1,i.minimaxCustomVoiceId="",i.voiceId=i.minimaxVoiceId,i.voiceModel=i.minimaxModel),a==="voiceProvider"&&t==="deepgram"&&(i.deepgramVoiceModel=fe,i.voiceId=fe,i.voiceModel=fe),a==="voiceProvider"&&t==="azure"&&(i.azureVoiceN
1ame="en-US-AvaNeural",i.azureRate=1,i.voiceId=i.azureVoiceName,i.voiceModel="azure-neural"),a==="voiceProvider"&&t==="sarvam"&&(i.sarvamSpeaker="aditya",i.sarvamLanguage="en-IN",i.sarvamPace=1,i.voiceId=i.sarvamSpeaker,i.voiceModel="bulbul-v3"),a==="voiceProvider"&&t==="openai"&&(i.voiceModel="gpt-4o-mini-tts",i.openaiVoice="alloy",i.voiceId=i.openaiVoice,i.voiceSpeed=1),a==="openaiVoice"&&(i.voiceId=t),a==="voiceProvider"&&t==="inworld"&&(i.voiceModel="inworld-tts-1.5-max",i.inworldVoice="Ashley",i.voiceId=i.inworldVoice,i.voiceSpeed=1),a==="inworldVoice"&&(i.voiceId=t),a==="voiceProvider"&&t==="smallest"){const r=hs(M,"kanik")||M[0];i.voiceModel="lightning_v3.1",i.smallestVoice=r?.voice_id||"kanik",i.smallestLanguage=gs(r),i.voiceId=i.smallestVoice,i.voiceSpeed=1}if(a==="smallestLanguage"&&t==="all"&&(i.smallestLanguage=""),a==="smallestVoice"){i.voiceId=t;const r=hs(M,t),u=gs(r);u?i.smallestLanguage=u:i.smallestLanguage==="all"&&(i.smallestLanguage="")}if(a==="voiceProvider"&&t==="rime"&&(i.voiceModel="mistv2",i.rimeVoice="cove",i.voiceId=i.rimeVoice,i.voiceSpeed=1),a==="rimeVoice"&&(i.voiceId=t),a==="voiceProvider"&&t==="fish"&&(i.fishModel=i.fishModel||"s2.1-pro",i.voiceModel=i.fishModel,i.fishLatency=i.fishLatency||"balanced",i.fishSpeed=i.fishSpeed??1,i.voiceSpeed=i.fishSpeed),a==="fishVoiceId"&&(i.voiceId=t),a==="fishModel"&&(i.voiceModel=t),a==="azureVoiceN
1ame"&&(i.voiceId=t),a==="sarvamSpeaker"&&(i.voiceId=t),a==="sarvamLanguage"&&(i.voiceLanguage=t,i.transcriberLanguage=i.transcriberLanguage||"multi"),a==="deepgramVoiceModel"){const r=ve(t);i.deepgramVoiceModel=r,i.voiceId=r,i.voiceModel=r}if(a==="minimaxVoiceId"&&(i.voiceId=t,i.minimaxUseCustomVoice=!1),a==="minimaxCustomVoiceId"&&i.minimaxUseCustomVoice&&(i.voiceId=t,i.minimaxVoiceId=t),a==="minimaxModel"){const r=xe(t);i.minimaxModel=r,i.voiceModel=r}return a==="elevenLabsModel"&&String(t||"").includes("_sts_")&&(i.elevenLabsModel="eleven_flash_v2_5"),a==="elevenLabsVoiceId"&&(i.voiceId=t,i.useCustomVoiceId=!1,i.customVoiceId=""),a==="customVoiceId"&&i.useCustomVoiceId&&(i.voiceId=t),a==="useCustomVoiceId"&&(i.voiceId=t&&i.customVoiceId?i.customVoiceId:i.elevenLabsVoiceId||"21m00Tcm4TlvDq8ikWAM"),i},l=async(s,a)=>{if(n){const t=Xs(n,s,a),i=n.status==="active"?"active":"draft",r={...t,status:i};f(r),ue(!0);const u=o.map(h=>h.id===n.id?r:h);p(u),console.log("💾 Assistant config updated locally:",s,a),window.saveTimeout&&clearTimeout(window.saveTimeout),window.saveTimeout=setTimeout(async()=>{try{console.log("🔄 Saving assistant to MongoDB...");const h=localStorage.getItem("token"),L=await fetch(w.getApiUrl(`/api/assistants/${n.id}`),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h}`},body:JSON.stringify(r)});if(L.status===401){ae();return}const H=await L.json();H.success?(console.log("… Assistant saved to MongoDB:",s),p(Y=>{const ie=Y.map(te=>te.id===r.id?{...te,...r}:te);return re("cached_assistants",ie),ie})):(console.error("Error Failed to save assistant:",H.error),E(`Error Failed to save: ${H.error}`,"error"))}catch(h){console.error("Error Error saving assistant to MongoDB:",h),E(`Error Error saving: ${h.message}`,"error")}},1e3)}},Zs=async()=>{if(!(!n||ke)){if(n.status==="active"&&!se){E("Already published");return}We(!0);try{const s={...n,status:"active",lastSaved:new Date().toISOString()},a=localStorage.getItem("token"),t=await fetch(w.getApiUrl(`/api/assistants/${n.id}`),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify(s)});if(t.status===401){ae();return}const i=await t.json();if(i.success)await Me(),f(s),ue(!1),E("Published");else throw new Error(i.error||"Failed to publish assistant")}catch(s){console.error("Publish error:",s),E(`Publish failed: ${s.message}`,"error")}finally{We(!1)}}},ea=s=>s?s.voiceEngine==="openai_realtime"?{name:s.name,voiceEngine:"openai_realtime",realtime:{model:"gpt-realtime-1.5",voice:"marin",...s.realtime},firstMessageMode:s.firstMessageMode||"user_speaks_first",systemPrompt:"Your assistant instructions"}:{id:"asst_xxxxxxxxxx",name:s.name||"Your Assistant Name",model:{provider:"groq",model:s.model||"openai/gpt-oss-20b",temperature:.7,maxTokens:1e3},voice:{provider:s.voiceProvider||"cartesia",voiceId:"voice_xxxxxxxxxx",model:s.voiceModel||"sonic-3.5",language:s.voiceLanguage||"en",dialect:s.voiceDialect||"us",speed:s.voiceSpeed||1,volume:s.voiceVolume||1,pitch:s.voicePitch||1,emotion:s.voiceEmotion||"neutral"},transcriber:{provider:"groq",model:s.transcriber||"whisper-large-v3",language:"en"},conversationMemoryEnabled:s.conversationMemoryEnabled!==!1,liveDealIntelligenceEnabled:s.liveDealIntelligenceEnabled!==!1,aiHandoff:s.aiHandoff||{enabled:!1,rules:[]},firstMessage:"Hello! How can I help you today?",systemMessage:"You are a helpful AI assistant.",recordingEnabled:!0,endCallMessage:"Thank you for calling. Have a great day!",endCallPhrases:["goodbye","bye","see you later"],backgroundSound:"office",backchannelingEnabled:!0,backgroundDenoisingEnabled:!0,modelOutputInMessagesEnabled:!0,transportConfigurations:[{provider:"twilio",timeout:60,record:!0}],note:"This is a sanitized configuration template. Replace with your actual values."}:{},sa=[{value:".",label:"Period",hint:"Finish normal sentences",sample:"Thanks for calling."},{value:"?",label:"Question mark",hint:"Respond quickly to questions",sample:"Can I help?"},{value:"!",label:"Exclamation",hint:"Keep energetic replies natural",sample:"Perfect!"},{value:",",label:"Comma",hint:"Allow shorter voice chunks",sample:"Sure, one moment"},{value:";",label:"Semicolon",hint:"Split longer clauses",sample:"Confirmed; next step"},{value:":",label:"Colon",hint:"Good before lists or details",sample:"Here is what I found:"},{value:"-",label:"Dash",hint:"Handle quick aside breaks",sample:"Yes - I can do that"},{value:"-",label:"Em dash",hint:"Handle polished long pauses",sample:"Great - checking now"}],Ie=n?.punctuationBoundaries||[".","?","!",","],aa=s=>{const a=n?.punctuationBoundaries||[],t=a.includes(s)?a.filter(i=>i!==s):[...a,s];l("punctuationBoundaries",t)},Ae=s=>{const a={balanced:[".","?","!",","],responsive:[".","?","!",",",";",":"],conservative:[".","?","!"]};l("punctuationBoundaries",a[s]||a.balanced)},na=()=>e.jsxs("details",{className:"config-accordion reliability-accordion",open:!0,children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🔊"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Backup Voices"}),e.jsx("span",{className:"accordion-desc",children:"If the main voice fails during a call, these will be tried in order so the call doesn't drop."})]})]}),e.jsxs("div",{className:"accordion-body",children:[n.fallbackVoices&&n.fallbackVoices.length>0?e.jsx("div",{className:"fallback-list modern-fallback-list",children:n.fallbackVoices.map((s,a)=>e.jsxs("div",{className:`fallback-item modern-fallback-item${s.enabled===!1?" is-disabled":""}`,children:[e.jsx("span",{className:"fallback-index",children:a+1}),e.jsxs("select",{className:"setting-select",value:s.provider||"cartesia",onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],provider:t.target.value}
1,l("fallbackVoices",i)},children:[e.jsx("option",{value:"cartesia",children:"Cartesia"}),e.jsx("option",{value:"elevenlabs",children:"ElevenLabs"}),e.jsx("option",{value:"deepgram",children:"Deepgram Aura"})]}),e.jsx("input",{type:"text",className:"setting-text-input",placeholder:"Voice ID (leave blank to reuse main voice)",value:s.voiceId||"",onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],voiceId:t.target.value},l("fallbackVoices",i)}}),e.jsx("input",{type:"text",className:"setting-text-input compact-model-input",placeholder:"Model",value:s.model||"",onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],model:t.target.value},l("fallbackVoices",i)}}),e.jsxs("label",{className:"toggle-switch fallback-enable-toggle",title:s.enabled===!1?"Disabled — skipped during fallback":"Enabled",children:[e.jsx("input",{type:"checkbox",checked:s.enabled!==!1,onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],enabled:t.target.checked},l("fallbackVoices",i)}}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon-sm remove-btn",onClick:()=>{const t=n.fallbackVoices.filter((i,r)=>r!==a);l("fallbackVoices",t)},children:"×"})]},a))}):e.jsx("p",{className:"empty-hint center",children:"No backup voice added yet. Add one so calls keep working even if the main voice has an issue."}),e.jsx("button",{className:"add-fallback-btn",onClick:()=>{const s=n.fallbackVoices||[];l("fallbackVoices",[...s,{provider:"cartesia",voiceId:"",model:"sonic-3.5",enabled:!0}])},children:"+ Add Backup Voice"})]})]}),ia=()=>e.jsxs("div",{className:"punctuation-panel",children:[e.jsxs("div",{className:"punctuation-panel-head",children:[e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Punctuation Boundaries"}),e.jsx("span",{className:"setting-desc",children:"Choose where streamed LLM text can be safely split before sending it to the voice provider."})]}),e.jsxs("div",{className:"punctuation-presets",children:[e.jsx("button",{type:"button",onClick:()=>Ae("balanced"),children:"Balanced"}),e.jsx("button",{type:"button",onClick:()=>Ae("responsive"),children:"Fast"}),e.jsx("button",{type:"button",onClick:()=>Ae("conservative"),children:"Stable"})]})]}),e.jsx("div",{className:"punctuation-grid",children:sa.map(s=>e.jsxs("button",{type:"button",className:`punctuation-card ${Ie.includes(s.value)?"selected":""}`,onClick:()=>aa(s.value),children:[e.jsx("span",{className:"punctuation-mark",children:s.value}),e.jsxs("span",{className:"punctuation-copy",children:[e.jsx("strong",{children:s.label}),e.jsx("small",{children:s.hint})]}),e.jsx("em",{children:s.sample})]},s.value))}),e.jsxs("div",{className:"punctuation-summary",children:["Active boundaries: ",Ie.length?Ie.join("  "):"None"]})]}),ta=o.reduce((s,a)=>{const t=a.name||"Untitled Assistant";return s[t]=(s[t]||0)+1,s},{}),he=s=>{const a=s.name||"Untitled Assistant";return ta[a]>1?`${a} (${s.id?.slice(-6)||"copy"})`:a};return e.jsxs("div",{className:"assistants",children:[e.jsxs("div",{className:"assistants-layout",children:[e.jsxs("div",{className:"assistants-sidebar",children:[e.jsxs("div",{className:"sidebar-header",children:[e.jsxs("div",{className:"sidebar-tabs",children:[e.jsxs("button",{className:"tab-btn active",children:[e.jsx(ha,{})," Assistants"]}),e.jsxs($,{to:"/assistants/templates",className:"tab-btn",children:[e.jsx(oe,{})," Templates"]})]}),e.jsxs("button",{onClick:qs,className:"btn-create-small",children:[e.jsx(oe,{})," Create Assistant"]})]}),e.jsx("div",{className:"sidebar-search",children:e.jsx("input",{type:"text",placeholder:"Search Assistants",className:"search-input"})}),e.jsx("div",{className:"assistants-list",children:o.length===0&&!Ue?e.jsxs("div",{style:{padding:"1.5rem",textAlign:"center",color:"var(--text-secondary)",fontSize:"0.875rem"},children:["No assistants yet",e.jsx("div",{style:{marginTop:"0.875rem"},children:e.jsxs($,{to:"/assistants/templates",style:{display:"inline-flex",alignItems:"center",gap:"0.4rem",padding:"0.5rem 0.75rem",background:"var(--btn-bg, #0F172A)",color:"var(--btn-text, #fff)",borderRadius:"8px",fontSize:"0.8125rem",fontWeight:600,textDecoration:"none"},children:[e.jsx(oe,{size:13})," Browse templates"]})})]}):o.map(s=>e.jsxs("div",{className:`assistant-list-item ${n?.id===s.id?"selected":""}`,onClick:()=>Qs(s),children:[e.jsxs("div",{className:"list-item-info",children:[e.jsx("h4",{children:he(s)}),e.jsxs("span",{className:"assistant-list-meta",children:[e.jsx("span",{className:`status-dot ${s.status}`}),s.voiceEngine==="openai_realtime"?"Realtime voice":"Custom voice stack"]})]}),e.jsx("button",{type:"button",className:"assistant-list-delete",onClick:a=>ns(s,a),disabled:qe===s.id,title:`Delete ${he(s)}`,"aria-label":`Delete ${he(s)}`,children:e.jsx(ga,{size:15})})]},s.id))})]}),e.jsx("div",{className:"assistants-content","data-scroll-restore":"page",children:n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"config-header",children:[e.jsx("h1",{children:n.name}),e.jsxs("span",{className:"assistant-id",style:{cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"0.25rem"},onClick:()=>{navigator.clipboard.writeText(n.id)},title:"Click to copy ID",children:[n.id.substring(0,20),"...",e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})]}),e.jsxs("div",{className:"header-actions",children:[e.jsxs("button",{className:"btn-secondary",onClick:async()=>{try{const a=await(await T.authedFetch(w.getApiUrl("/api/models/refresh"),{method:"POST"})).json();a.success?(await Ye(),E(`… Refreshed ${Object.keys(a.models,"success").length} LLM models`)):E(`Error Error: ${a.error}`,"error")}catch(s){E(`Error Error refreshing models: ${s.message}`,"error")}},children:[e.jsx(os,{size:14,style:{marginRight:"4px"}})," Refresh Models"]}),e.jsx("button",{className:"btn-secondary",onClick:()=>de(!0),title:"View JSON Configuration",children:"Code"}),e.jsx("button",{className:"btn-secondary delete-assistant-btn",onClick:()=>ns(n.id),title:"Delete assistant",children:"Delete"}),e.jsxs($,{to:`/make-call?assistantId=${encodeURIComponent(n.id)}`,className:"btn-primary",children:[e.jsx(xa,{size:16}),"Test with a Call"]}),e.jsx("button",{className:`btn-publish ${n.status==="active"&&!se?"btn-publish-done":"btn-publish-pending"}`,onClick:Zs,disabled:ke||n.status==="active"&&!se,title:n.status==="active"&&!se?"Up to date":"Publish your latest changes",children:ke?"Publishing...":n.status==="active"&&!se?"Published":"Publish"})]})]}),e.jsxs("section",{className:"assistant-engine-picker","aria-labelledby":"assistant-engine-heading",children:[e.jsxs("div",{className:"assistant-engine-copy",children:[e.jsx("span",{className:"assistant-engine-kicker",children:"VOICE SETUP"}),e.jsx("h2",{id:"assistant-engine-heading",children:"Choose how this assistant is built"})]}),e.jsxs("div",{className:"assistant-engine-options",role:"radiogroup","aria-label":"Call engine",children:[e.jsxs("button",{type:"button",className:`assistant-engine-option ${n.voiceEngine!=="openai_realtime"?"active":""}`,role:"radio","aria-checked":n.voiceEngine!=="openai_realtime",onClick:()=>{l("voiceEngine","custom"),W("model")},children:[e.jsx("span",{className:"assistant-engine-icon",children:e.jsx(ba,{size:18})}),e.jsxs("span",{className:"assistant-engine-label",children:[e.jsx("strong",{children:"Custom Voice Stack"}),e.jsx("small",{children:"Build with your selected STT, AI model, and voice"})]}),n.voiceEngine!=="openai_realtime"&&e.jsx("span",{className:"assistant-engine-state",children:"Selected"})]}),e.jsxs("button",{type:"button",className:`assistant-engine-option ${n.voiceEngine==="openai_realtime"?"active":""}`,role:"radio","aria-checked":n.voiceEngine==="openai_realtime",onClick:()=>{l("voiceEngine","openai_realtime"),W("model")},children:[e.jsx("span",{className:"assistant-engine-icon live",children:e.jsx(vs,{size:18})}),e.jsxs("span",{className:"assistant-engine-label",children:[e.jsx("strong",{children:"Realtime Voice"}),e.jsx("small",{children:"One speech-to-speech model for the full conversation"})]}),n.voiceEngine==="openai_realtime"&&e.jsx("span",{className:"assistant-engine-state",children:"Selected"})]})]}),n.voiceEngine==="openai_realtime"&&n.multiAgentWorkspaceId&&e.jsxs("div",{className:"assistant-engine-notice",role:"alert",children:[e.jsx(ya,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:"Multi-agent workspaces currently require Custom Voice Stack."})]})]}),e.jsxs("div",{className:"config-tabs",children:[e.jsx("button",{className:`tab-btn ${_==="model"?"active":""}`,onClick:()=>W("model"),children:n.voiceEngine==="openai_realtime"?"Live settings":"Model"}),n.voiceEngine!=="openai_realtime"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`tab-btn ${_==="transcriber"?"active":""}`,onClick:()=>W("transcriber"),children:"Transcriber"}),e.jsx("button",{className:`tab-btn ${_==="voice"?"active":""}`,onClick:()=>W("voice"),children:"Voice"}),e.jsx("button",{className:`tab-btn ${_==="advanced"?"active":""}`,onClick:()=>W("advanced"),children:"Advanced"})]}),e.jsx("button",{className:`tab-btn ${_==="knowledge"?"active":""}`,onClick:()=>W("knowledge"),children:"Knowledge Base"}),e.jsx("button",{className:`tab-btn ${_==="code"?"active":""}`,onClick:()=>W("code"),children:"Code"})]}),_!=="advanced"&&n.voiceEngine!=="openai_realtime"&&e.jsxs("div",{className:"vagle-cost-card",children:[e.jsxs("div",{className:"vagle-cost-head",children:[e.jsxs("div",{className:"vagle-cost-head-titles",children:[e.jsx("span",{className:"vagle-cost-title",children:"Estimated Vagle Cost"}),e.jsx("span",{className:"vagle-cost-sub",children:"Operational cost per minute · telephony billed separately"})]}),e.jsx("div",{className:"vagle-cost-toggle","aria-label":"Cost currency",children:e.jsx("span",{className:"active",children:"$ USD"})})]}),e.jsx("div",{className:"vagle-cost-body",children:(()=>{const s=ye;if(!s)return e.jsx("span",{className:"vagle-cost-loading",children:"Calculating…"});if(s.shape==="error")return e.jsx("span",{className:"vagle-cost-loading",style:{color:"#c00"},children:s.error||"Pricing unavailable. Please retry."});const a=s.shape==="canonical",t=te=>{const ls=Number(te??0),ge=Math.abs(ls);let Pe=2;return ge>0&&ge<.01&&(Pe=4),ge>0&&ge<.001&&(Pe=6),`$${ls.toFixed(Pe)}/min`},i=a?s.components:s.legacy||s,r=a?s.total:s.legacy?s.legacy.total:s.total,u=i?.llm,h=i?.stt,L=i?.tts,H=i?.platform,Y=i?.infra,ie=i?.storage;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"vagle-cost-row",children:[e.jsxs("span",{className:"vagle-cost-label",children:["LLM ",e.jsx("em",{children:u?.model||"—"})]}),e.jsx("span",{className:"vagle-cost-value",children:t(a?u?.totalUSD:u?.perMin)})]}),e.jsxs("div",{className:"vagle-cost-row",children:[e.jsxs("span",{className:"vagle-cost-label",children:["STT ",e.jsx("em",{children:h?.model||"—"})]}),e.jsx("span",{className:"vagle-cost-value",children:t(a?h?.totalUSD:h?.perMin)})]}),e.jsxs("div",{className:"vagle-cost-row",children:[e.jsxs("span",{className:"vagle-cost-label",children:["TTS ",e.jsx("em",{children:L?.model||"—"})]}),e.jsx("span",{className:"vagle-cost-value",children:t(a?L?.totalUSD:L?.perMin)})]}),e.jsxs("div",{className:"vagle-cost-row",children:[e.jsx("span",{className:"vagle-cost-label",children:"Platform"}),e.jsx("span",{className:"vagle-cost-value",children:t(a?H?.totalUSD:H?.perMin)})]}),a&&Y?.enabled&&e.jsxs("div",{className:"vagle-cost-row",children:[e.jsx("span",{className:"vagle-cost-label",children:"Infra"}),e.jsx("span",{className:"vagle-cost-value",children:t(Y.totalUSD)})]}),a&&ie?.enabled&&e.jsxs("div",{className:"vagle-cost-row",children:[e.jsx("span",{className:"vagle-cost-label",children:"Storage"}),e.jsx("span",{className:"vagle-cost-value",children:t(ie.totalUSD)})]}),e.jsxs("div",{className:"vagle-cost-row total",children:[e.jsx("span",{className:"vagle-cost-label",children:"Total / min"}),e.jsx("span",{className:"vagle-cost-value",children:t(a?r?.usd:r?.perMin)})]})]})})()})]}),e.jsxs("div",{className:`config-section ${_==="advanced"?"advanced-config-section":""}`,children:[_==="model"&&n.voiceEngine==="openai_realtime"?e.jsx(Aa,{assistant:n,onChange:l}):_==="model"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"AI MODEL"}),e.jsx("p",{className:"section-subtitle",children:"Choose the reasoning model your assistant uses during calls."}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["AI model ",e.jsx("span",{className:"label-info",children:"(i)"})]}),ws?e.jsx("div",{style:{padding:"10px 12px",border:"1px solid rgba(0,0,0,0.12)",borderRadius:"6px",color:"#888",fontSize:"0.85rem"},children:"Loading models..."}):Ze.length>0?e.jsx(Fe,{groups:Ze,value:n.model||"",onChange:s=>l("model",s),placeholder:"Select AI model"}):e.jsx("select",{value:n.model||"",onChange:s=>l("model",s.target.value),children:e.jsxs("optgroup",{label:"Groq (Fastest)",children:[e.jsx("option",{value:"openai/gpt-oss-20b",children:"GPT-OSS 20B (Fast)"}),e.jsx("option",{value:"openai/gpt-oss-120b",children:"GPT-OSS 120B (Balanced)"}),e.jsx("option",{value:"qwen/qwen3.6-27b",children:"Qwen 3.6 27B"})]})}),e.jsx("small",{style:{color:"var(--text-muted)",fontSize:"0.72rem",marginTop:"4px",display:"block"},children:"For most business calls, use a fast value model. Use premium models when accuracy matters more than cost."})]})]}):_==="transcriber"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"TRANSCRIBER"}),e.jsx("p",{className:"section-subtitle",children:"Choose how voice is converted to text during live calls."}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Speech-to-text provider and model ",e.jsx("span",{className:"label-info",children:"(i)"})]}),es.length>0?e.jsx(Fe,{groups:es,value:n.transcriber||"whisper-large-v3",onChange:s=>
1l("transcriber",s),disabled:N.length===0,placeholder:"Select transcriber"}):e.jsxs("select",{value:n.transcriber||"whisper-large-v3",onChange:s=>l("transcriber",s.target.value),children:[e.jsx("option",{value:"whisper-large-v3",children:"Whisper Large v3"}),e.jsx("option",{value:"whisper-large-v3-turbo",children:"Whisper Large v3 Turbo"}),e.jsx("option",{value:"deepgram-nova-2",children:"Deepgram Nova-2"}),e.jsx("option",{value:"qwen3-asr-flash-realtime",children:"Qwen3 ASR Flash Realtime"}),e.jsx("option",{value:"mistral-voxtral-mini-realtime",children:"Mistral Voxtral Mini Realtime"})]}),e.jsx("small",{style:{color:"var(--text-muted)",fontSize:"0.72rem",marginTop:"4px",display:"block"},children:"Deepgram is recommended for live phone calls. Whisper is useful when cost is the priority."})]})]}):_==="voice"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"VOICE"}),e.jsx("p",{className:"section-subtitle",children:"Configure text-to-speech voice provider and settings."}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Voice Provider ",e.jsx("span",{className:"label-info",children:"(i)"})]}),ss.length>0?e.jsx(Fe,{groups:ss,value:n.voiceProvider||"cartesia",onChange:s=>l("voiceProvider",s),placeholder:"Select voice provider"}):e.jsxs("select",{value:n.voiceProvider||"cartesia",onChange:s=>l("voiceProvider",s.target.value),children:[e.jsx("option",{value:"cartesia",children:"Cartesia"}),e.jsx("option",{value:"elevenlabs",children:"ElevenLabs"}),e.jsx("option",{value:"minimax",children:"MiniMax Voice"}),e.jsx("option",{value:"deepgram",children:"Deepgram Aura"}),e.jsx("option",{value:"sarvam",children:"Sarvam Bulbul v3 (Indian)"}),e.jsx("option",{value:"azure",children:"Azure Neural Voices"})]})]}),(n.voiceProvider||"cartesia")==="cartesia"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Voice Model ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("select",{value:Le.has(n.voiceModel)?n.voiceModel:"sonic-3.5",onChange:s=>l("voiceModel",s.target.value),disabled:S.length===0,children:S.length>0?S.map(s=>{const a=fs(s.latency);return e.jsxs("option",{value:s.key,children:[s.name,a?` — ⚡ ${a.display} · ${a.label}`:""]},s.key)}):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"sonic-3.5",children:"Sonic 3.5 - Best Quality"}),e.jsx("option",{value:"sonic-3",children:"Sonic 3 - Speed/Emotion Controls"}),e.jsx("option",{value:"sonic-turbo",children:"Sonic Turbo - Lowest Latency"})]})})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Language ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("select",{value:n.voiceLanguage||"en",onChange:s=>{l("voiceLanguage",s.target.value);const a=F.filter(t=>(t.language||"en")===s.target.value);a.length>0&&!a.some(t=>t.id===n.voiceId)&&l("voiceId",a[0].id)},children:Da.map(([s,a])=>e.jsx("option",{value:s,children:a},s))})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Accent/Dialect ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("select",{value:n.voiceDialect||"us",onChange:s=>l("voiceDialect",s.target.value),disabled:!["en","es","pt","fr"].includes(n.voiceLanguage||"en"),children:[(n.voiceLanguage||"en")==="en"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"us",children:"US English"}),e.jsx("option",{value:"uk",children:"British English"}),e.jsx("option",{value:"au",children:"Australian English"}),e.jsx("option",{value:"in",children:"Indian English"}),e.jsx("option",{value:"so",children:"South African English"})]}),n.voiceLanguage==="es"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"es",children:"Spain Spanish"}),e.jsx("option",{value:"mx",children:"Mexican Spanish"}),e.jsx("option",{value:"ar",children:"Argentinian Spanish"})]}),n.voiceLanguage==="pt"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"br",children:"Brazilian Portuguese"}),e.jsx("option",{value:"pt",children:"European Portuguese"})]}),n.voiceLanguage==="fr"&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"fr",children:"French (France)"}),e.jsx("option",{value:"ca",children:"Canadian French"})]}),!["en","es","pt","fr"].includes(n.voiceLanguage||"en")&&e.jsx("option",{value:"",children:"No dialect options available"})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Voice ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("select",{value:n.voiceId||"a0e99841-438c-4a64-b679-ae501e7d6091",onChange:s=>l("voiceId",s.target.value),disabled:F.length===0,children:(()=>{const s=n.voiceLanguage||"en",a=F.filter(i=>(i.language||"en")===s),t=a.length>0?a:F;return t.length>0?t.map(i=>e.jsxs("option",{value:i.id,children:[i.name,i.accent?` (${i.accent})`:""]},i.key)):e.jsx("option",{value:"a0e99841-438c-4a64-b679-ae501e7d6091",children:"British Lady"})})()}),(()=>{const s=n.voiceLanguage||"en";return F.filter(t=>(t.language||"en")===s).length===0&&F.length>0?e.jsx("small",{style:{color:"#b45309",fontSize:"0.72rem"},children:"No Cartesia voices tagged for this language yet — showing all voices instead."}):null})()]}),(n.voiceModel==="sonic-3"||n.voiceModel?.startsWith("sonic-3"))&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Emotion"}),e.jsxs("select",{value:n.voiceEmotion||"neutral",onChange:s=>l("voiceEmotion",s.target.value),children:[e.jsx("option",{value:"neutral",children:"Neutral"}),e.jsx("option",{value:"happy",children:"Happy"}),e.jsx("option",{value:"excited",children:"Excited"}),e.jsx("option",{value:"content",children:"Content"}),e.jsx("option",{value:"calm",children:"Calm"}),e.jsx("option",{value:"confident",children:"Confident"}),e.jsx("option",{value:"curious",children:"Curious"}),e.jsx("option",{value:"sad",children:"Sad"}),e.jsx("option",{value:"angry",children:"Angry"}),e.jsx("option",{value:"scared",children:"Scared"}),e.jsx("option",{value:"surprised",children:"Surprised"}),e.jsx("option",{value:"frustrated",children:"Frustrated"}),e.jsx("option",{value:"sympathetic",children:"Sympathetic"}),e.jsx("option",{value:"determined",children:"Determined"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",className:"slider",style:P(n.voiceSpeed||1,.6,1.5),value:n.voiceSpeed||1,onChange:s=>l("voiceSpeed",parseFloat(s.target.value)),min:"0.6",max:"1.5",step:"0.1"}),e.jsxs("span",{className:"slider-value",children:[n.voiceSpeed||1,"x"]})]})]})]}),n.voiceProvider==="elevenlabs"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Voice Model ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("select",{value:(n.elevenLabsModel||"").includes("_sts_")?"eleven_flash_v2_5":n.elevenLabsModel||"eleven_flash_v2_5",onChange:s=>l("elevenLabsModel",s.target.value),disabled:je.length===0,children:je.length>0?je.map(s=>e.jsx("option",{value:s.model_id,children:s.name},s.model_id)):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"eleven_flash_v2_5",children:"Eleven Flash v2.5 - Fastest"}),e.jsx("option",{value:"eleven_turbo_v2_5",children:"Eleven Turbo v2.5"}),e.jsx("option",{value:"eleven_turbo_v2",children:"Eleven Turbo v2"}),e.jsx("option",{value:"eleven_multilingual_v2",children:"Eleven Multilingual v2"})]})})]}),Ee(q.map(s=>({language:s.labels?.language})))&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Language ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("select",{value:n.elevenLabsLanguage||"all",onChange:s=>l("elevenLabsLanguage",s.target.value),children:[e.jsx("option",{value:"all",children:"All languages"}),Te(q.map(s=>({language:s.labels?.language}))).map(([s,a])=>e.jsx("option",{value:s,children:a},s))]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Voice ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("select",{value:n.elevenLabsVoiceId||"21m00Tcm4TlvDq8ikWAM",onChange:s=>l("elevenLabsVoiceId",s.target.value),disabled:q.length===0||n.useCustomVoiceId,children:(()=>{const s=n.elevenLabsLanguage||"all",a=s==="all"?q:q.filter(i=>String(i.labels?.language||"").toLowerCase()===s),t=a.length>0?a:q;return t.length>0?t.map(i=>e.jsxs("option",{value:i.voice_id,children:[i.name,i.labels?.accent?` (${i.labels.accent})`:""]},i.voice_id)):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"21m00Tcm4TlvDq8ikWAM",children:"Rachel"}),e.jsx("option",{value:"EXAVITQu4vr4xnSDxMaL",children:"Bella"}),e.jsx("option",{value:"ErXwobaYiN019PkySvjV",children:"Antoni"})]})})()})]}),e.jsx("div",{className:"form-group",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n.useCustomVoiceId||!1,onChange:s=>l("useCustomVoiceId",s.target.checked)}),"Add Voice ID Manually ",e.jsx("span",{className:"label-info",children:"(i)"})]})}),n.useCustomVoiceId&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Custom Voice ID ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("input",{type:"text",placeholder:"Enter Voice ID (e.g., 21m00Tcm4TlvDq8ikWAM)",value:n.customVoiceId||"",onChange:s=>l("customVoiceId",s.target.value),className:"custom-voice-input"}),e.jsx("div",{className:"input-help",children:"Enter your custom ElevenLabs voice ID. You can find this in your ElevenLabs dashboard."})]}),e.jsxs("div",{className:"elevenlabs-control-grid",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Stability ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("div",{className:"slider-container",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:n.elevenLabsSett
1ings?.stability??.5,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,stability:parseFloat(s.target.value)}),className:"slider",style:P(n.elevenLabsSettings?.stability??.5,0,1)}),e.jsx("span",{className:"slider-value",children:(n.elevenLabsSettings?.stability??.5).toFixed(2)})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"More Variable"}),e.jsx("span",{children:"More Stable"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Clarity + Similarity ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("div",{className:"slider-container",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:n.elevenLabsSettings?.similarity_boost??.8,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,similarity_boost:parseFloat(s.target.value)}),className:"slider",style:P(n.elevenLabsSettings?.similarity_boost??.8,0,1)}),e.jsx("span",{className:"slider-value",children:(n.elevenLabsSettings?.similarity_boost??.8).toFixed(2)})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"Low"}),e.jsx("span",{children:"High"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Speed ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("div",{className:"slider-container",children:[e.jsx("input",{type:"range",min:"0.7",max:"1.2",step:"0.01",value:n.elevenLabsSettings?.speed??1,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,speed:parseFloat(s.target.value)}),className:"slider",style:P(n.elevenLabsSettings?.speed??1,.7,1.2)}),e.jsx("span",{className:"slider-value",children:(n.elevenLabsSettings?.speed??1).toFixed(2)})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"Slower"}),e.jsx("span",{children:"Faster"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Style Exaggeration ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("div",{className:"slider-container",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:n.elevenLabsSettings?.style??0,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,style:parseFloat(s.target.value)}),className:"slider",style:P(n.elevenLabsSettings?.style??0,0,1)}),e.jsx("span",{className:"slider-value",children:(n.elevenLabsSettings?.style??0).toFixed(2)})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"None (Fastest)"}),e.jsx("span",{children:"Exaggerated"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Optimize Streaming Latency ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("div",{className:"slider-container",children:[e.jsx("input",{type:"range",min:"0",max:"4",step:"1",value:n.elevenLabsSettings?.optimize_streaming_latency??1,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,optimize_streaming_latency:parseInt(s.target.value,10)}),className:"slider",style:P(n.elevenLabsSettings?.optimize_streaming_latency??1,0,4)}),e.jsx("span",{className:"slider-value",children:n.elevenLabsSettings?.optimize_streaming_latency??1})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"More Latency"}),e.jsx("span",{children:"Less Latency"})]})]}),e.jsx("div",{className:"form-group speaker-boost-card",children:e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:n.elevenLabsSettings?.use_speaker_boost??!1,onChange:s=>l("elevenLabsSettings",{...n.elevenLabsSettings,use_speaker_boost:s.target.checked})}),"Use Speaker Boost ",e.jsx("span",{className:"label-info",children:"(i)"})]})})]})]}),n.voiceProvider==="minimax"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"MiniMax Model"}),e.jsxs("select",{value:xe(n.minimaxModel),onChange:s=>l("minimaxModel",s.target.value),children:[e.jsx("option",{value:"speech-2.6-turbo",children:"MiniMax Speech 2.6 Turbo (recommended for calls)"}),e.jsx("option",{value:"speech-2.8-turbo",children:"MiniMax Speech 2.8 Turbo (newest, expressive)"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Turbo models are tuned for real-time calls. HD models are disabled for live agents because they add avoidable synthesis latency."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Language"}),e.jsxs("select",{value:n.minimaxLanguage||"auto",onChange:s=>l("minimaxLanguage",s.target.value),children:[e.jsx("option",{value:"auto",children:"Auto (detects language automatically)"}),e.jsxs("optgroup",{label:"English & Hindi",children:[e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"hi",children:"Hindi"}),e.jsx("option",{value:"hinglish",children:"Hinglish"})]}),e.jsxs("optgroup",{label:"Indian Languages",children:[e.jsx("option",{value:"ta",children:"Tamil"}),e.jsx("option",{value:"te",children:"Telugu"}),e.jsx("option",{value:"bn",children:"Bengali"}),e.jsx("option",{value:"mr",children:"Marathi"}),e.jsx("option",{value:"gu",children:"Gujarati"}),e.jsx("option",{value:"kn",children:"Kannada"}),e.jsx("option",{value:"ml",children:"Malayalam"}),e.jsx("option",{value:"pa",children:"Punjabi"}),e.jsx("option",{value:"ur",children:"Urdu"})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"MiniMax Voice (System Voices)"}),e.jsxs("select",{value:n.minimaxUseCustomVoice?"":n.minimaxVoiceId||"",onChange:s=>{l("minimaxVoiceId",s.target.value)},disabled:n.minimaxUseCustomVoice,children:[e.jsx("option",{value:"",children:"— Select a voice —"}),n.minimaxVoiceId&&!n.minimaxUseCustomVoice&&!Object.values(O).flat().some(s=>s.voice_id===n.minimaxVoiceId)&&e.jsxs("option",{value:n.minimaxVoiceId,children:[n.minimaxVoiceName||n.minimaxVoiceId," (current)"]}),O.multilingual?.length>0&&e.jsx("optgroup",{label:"Multilingual (recommended for Hindi/EN)",children:O.multilingual.map(s=>
1e.jsxs("option",{value:s.voice_id,children:[s.name," (",s.gender,")"]},s.voice_id))}),O.english?.length>0&&e.jsx("optgroup",{label:"English",children:O.english.map(s=>e.jsxs("option",{value:s.voice_id,children:[s.name," (",s.gender,", ",s.accent,")"]},s.voice_id))}),O.hindi?.length>0&&e.jsx("optgroup",{label:"Hindi / Indian",children:O.hindi.map(s=>e.jsxs("option",{value:s.voice_id,children:[s.name," (",s.gender,")"]},s.voice_id))}),O.chinese?.length>0&&e.jsx("optgroup",{label:"Chinese",children:O.chinese.map(s=>e.jsxs("option",{value:s.voice_id,children:[s.name," (",s.gender,")"]},s.voice_id))})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Multilingual voices work for Hindi, English, and other languages."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("input",{type:"checkbox",checked:!!n.minimaxUseCustomVoice,onChange:s=>l("minimaxUseCustomVoice",s.target.checked)}),"Use Custom Cloned Voice ID"]}),n.minimaxUseCustomVoice&&e.jsx("input",{type:"text",placeholder:"Paste your cloned voice ID from MiniMax console",value:n.minimaxCustomVoiceId||"",onChange:s=>{l("minimaxCustomVoiceId",s.target.value),l("minimaxVoiceId",s.target.value)},style:{marginTop:"8px"}}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Use this for voices you've cloned in your MiniMax console."})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Speech Speed: ",(n.minimaxSpeed??1).toFixed(2),"x"]}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.minimaxSpeed??1,onChange:s=>l("minimaxSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.minimaxSpeed??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.minimaxSpeed??1).toFixed(2),"x"]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Volume: ",(n.minimaxVolume??1).toFixed(2)]}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.1",max:"2.0",step:"0.05",value:n.minimaxVolume??1,onChange:s=>l("minimaxVolume",parseFloat(s.target.value)),className:"slider",style:P(n.minimaxVolume??1,.1,2)}),e.jsx("span",{className:"slider-value",children:(n.minimaxVolume??1).toFixed(2)})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Pitch: ",n.minimaxPitch??0]}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"-12",max:"12",step:"1",value:n.minimaxPitch??0,onChange:s=>l("minimaxPitch",parseInt(s.target.value,10)),className:"slider",style:P(n.minimaxPitch??0,-12,12)}),e.jsx("span",{className:"slider-value",children:n.minimaxPitch??0})]}),e.jsxs("div",{className:"slider-hints",children:[e.jsx("span",{children:"Lower"}),e.jsx("span",{children:"Higher"})]})]})]}),n.voiceProvider==="deepgram"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Deepgram Aura Voice ",e.jsx("span",{className:"label-info",children:"ⓘ"})]}),e.jsx("select",{value:ve(n.deepgramVoiceModel),onChange:s=>l("deepgramVoiceModel",s.target.value),children:De.map(s=>e.jsxs("option",{value:s.id,children:[s.name," - ",s.detail]},s.id))}),e.jsx("small",{className:"helper-text",children:"Aura voices are optimized for fast conversational text-to-speech."})]}),e.jsx("div",{className:"form-group",children:e.jsx("small",{className:"helper-text",style:{display:"block",color:"#6B7280"},children:"Deepgram Aura does not support speed, pitch, or volume modulation. Pick a different provider (Cartesia, ElevenLabs, MiniMax, Azure, or Sarvam) if you need to fine-tune the voice."})})]}),n.voiceProvider==="sarvam"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Sarvam Voice"}),e.jsxs("select",{value:n.sarvamSpeaker||"aditya",onChange:s=>l("sarvamSpeaker",s.target.value),children:[e.jsxs("optgroup",{label:"Female (Recommended: Priya, Ishita)",children:[e.jsx("option",{value:"priya",children:"Priya (recommended)"}),e.jsx("option",{value:"ishita",children:"Ishita (recommended)"}),e.jsx("option",{value:"ritu",children:"Ritu"}),e.jsx("option",{value:"neha",children:"Neha"}),e.jsx("option",{value:"pooja",children:"Pooja"}),e.jsx("option",{value:"simran",children:"Simran"}),e.jsx("option",{value:"kavya",children:"Kavya"}),e.jsx("option",{value:"shreya",children:"Shreya"}),e.jsx("option",{value:"roopa",children:"Roopa"}),e.jsx("option",{value:"tanya",children:"Tanya"}),e.jsx("option",{value:"shruti",children:"Shruti"}),e.jsx("option",{value:"suhani",children:"Suhani"}),e.jsx("option",{value:"kavitha",children:"Kavitha"}),e.jsx("option",{value:"rupali",children:"Rupali"})]}),e.jsxs("optgroup",{label:"Male (Recommended: Shubh, Ratan, Mani)",children:[e.jsx("option",{value:"shubh",children:"Shubh (default)"}),e.jsx("option",{value:"ratan",children:"Ratan"}),e.jsx("option",{value:"mani",children:"Mani"}),e.jsx("option",{value:"aditya",children:"Aditya"}),e.jsx("option",{value:"rahul",children:"Rahul"}),e.jsx("option",{value:"rohan",children:"Rohan"}),e.jsx("option",{value:"amit",children:"Amit"}),e.jsx("option",{value:"dev",children:"Dev"}),e.jsx("option",{value:"varun",children:"Varun (deep/dramatic)"}),e.jsx("option",{value:"manan",children:"Manan"}),e.jsx("option",{value:"sumit",children:"Sumit"}),e.jsx("option",{value:"kabir",children:"Kabir"}),e.jsx("option",{value:"aayan",children:"Aayan"}),e.jsx("option",{value:"ashutosh",children:"Ashutosh"}),e.jsx("option",{value:"advait",children:"Advait"}),e.jsx("option",{value:"anand",children:"Anand"}),e.jsx("option",{value:"tarun",children:"Tarun"}),e.jsx("option",{value:"sunny",children:"Sunny"}),e.jsx("option",{value:"gokul",children:"Gokul"}),e.jsx("option",{value:"vijay",children:"Vijay"}),e.jsx("option",{value:"mohit",children:"Mohit"}),e.jsx("option",{value:"rehan",children:"Rehan"}),e.jsx("option",{value:"soham",children:"Soham"})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Language"}),e.jsxs("select",{value:n.sarvamLanguage||"en-IN",onChange:s=>l("sarvamLanguage",s.target.value),children:[e.jsx("option",{value:"en-IN",children:"English (India)"}),e.jsx("option",{value:"hi-IN",children:"Hindi / Hinglish"}),e.jsx("option",{value:"bn-IN",children:"Bengali"}),e.jsx("option",{value:"ta-IN",children:"Tamil"}),e.jsx("option",{value:"te-IN",children:"Telugu"}),e.jsx("option",{value:"kn-IN",children:"Kannada"}),e.jsx("option",{value:"ml-IN",children:"Malayalam"}),e.jsx("option",{value:"mr-IN",children:"Marathi"}),e.jsx("option",{value:"gu-IN",children:"Gujarati"}),e.jsx("option",{value:"pa-IN",children:"Punjabi"}),e.jsx("option",{value:"od-IN",children:"Odia"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.sarvamPace??1,onChange:s=>l("sarvamPace",parseFloat(s.target.value)),className:"slider",style:P(n.sarvamPace??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.sarvamPace??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="azure"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Azure Voice"}
1),e.jsxs("select",{value:n.azureVoiceName||"en-US-AvaNeural",onChange:s=>l("azureVoiceName",s.target.value),children:[e.jsxs("optgroup",{label:"English (US)",children:[e.jsx("option",{value:"en-US-AvaNeural",children:"Ava (Female)"}),e.jsx("option",{value:"en-US-AndrewNeural",children:"Andrew (Male)"}),e.jsx("option",{value:"en-US-EmmaNeural",children:"Emma (Female)"}),e.jsx("option",{value:"en-US-BrianNeural",children:"Brian (Male)"}),e.jsx("option",{value:"en-US-JennyNeural",children:"Jenny (Female)"}),e.jsx("option",{value:"en-US-GuyNeural",children:"Guy (Male)"}),e.jsx("option",{value:"en-US-AriaNeural",children:"Aria (Female)"}),e.jsx("option",{value:"en-US-DavisNeural",children:"Davis (Male)"})]}),e.jsxs("optgroup",{label:"English (UK)",children:[e.jsx("option",{value:"en-GB-SoniaNeural",children:"Sonia (Female)"}),e.jsx("option",{value:"en-GB-RyanNeural",children:"Ryan (Male)"}),e.jsx("option",{value:"en-GB-LibbyNeural",children:"Libby (Female)"})]}),e.jsxs("optgroup",{label:"English (India)",children:[e.jsx("option",{value:"en-IN-NeerjaNeural",children:"Neerja (Female)"}),e.jsx("option",{value:"en-IN-PrabhatNeural",children:"Prabhat (Male)"}),e.jsx("option",{value:"en-IN-AaravNeural",children:"Aarav (Male)"}),e.jsx("option",{value:"en-IN-AashiNeural",children:"Aashi (Female)"})]}),e.jsxs("optgroup",{label:"Hindi",children:[e.jsx("option",{value:"hi-IN-SwaraNeural",children:"Swara (Female)"}),e.jsx("option",{value:"hi-IN-MadhurNeural",children:"Madhur (Male)"}),e.jsx("option",{value:"hi-IN-AaravNeural",children:"Aarav (Male)"}),e.jsx("option",{value:"hi-IN-AnanyaNeural",children:"Ananya (Female)"})]}),e.jsxs("optgroup",{label:"Tamil",children:[e.jsx("option",{value:"ta-IN-PallaviNeural",children:"Pallavi (Female)"}),e.jsx("option",{value:"ta-IN-ValluvarNeural",children:"Valluvar (Male)"})]}),e.jsxs("optgroup",{label:"Telugu",children:[e.jsx("option",{value:"te-IN-ShrutiNeural",children:"Shruti (Female)"}),e.jsx("option",{value:"te-IN-MohanNeural",children:"Mohan (Male)"})]}),e.jsxs("optgroup",{label:"Bengali",children:[e.jsx("option",{value:"bn-IN-TanishaaNeural",children:"Tanishaa (Female)"}),e.jsx("option",{value:"bn-IN-BashkarNeural",children:"Bashkar (Male)"})]}),e.jsxs("optgroup",{label:"Marathi",children:[e.jsx("option",{value:"mr-IN-AarohiNeural",children:"Aarohi (Female)"}),e.jsx("option",{value:"mr-IN-ManoharNeural",children:"Manohar (Male)"})]}),e.jsxs("optgroup",{label:"Gujarati",children:[e.jsx("option",{value:"gu-IN-DhwaniNeural",children:"Dhwani (Female)"}),e.jsx("option",{value:"gu-IN-NiranjanNeural",children:"Niranjan (Male)"})]}),e.jsxs("optgroup",{label:"Kannada",children:[e.jsx("option",{value:"kn-IN-SapnaNeural",children:"Sapna (Female)"}),e.jsx("option",{value:"kn-IN-GaganNeural",children:"Gagan (Male)"})]}),e.jsxs("optgroup",{label:"Malayalam",children:[e.jsx("option",{value:"ml-IN-SobhanaNeural",children:"Sobhana (Female)"}),e.jsx("option",{value:"ml-IN-MidhunNeural",children:"Midhun (Male)"})]}),e.jsxs("optgroup",{label:"Punjabi",children:[e.jsx("option",{value:"pa-IN-OjasNeural",children:"Ojas (Male)"}),e.jsx("option",{value:"pa-IN-VaaniNeural",children:"Vaani (Female)"})]}),e.jsxs("optgroup",{label:"Urdu",children:[e.jsx("option",{value:"ur-IN-GulNeural",children:"Gul (Female)"}),e.jsx("option",{value:"ur-IN-SalmanNeural",children:"Salman (Male)"})]})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Azure neural voices, hosted in Central India for low latency."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.azureRate??1,onChange:s=>l("azureRate",parseFloat(s.target.value)),className:"slider",style:P(n.azureRate??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.azureRate??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="openai"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"OpenAI Model"}),e.jsxs("select",{value:n.voiceModel||"gpt-4o-mini-tts",onChange:s=>l("voiceModel",s.target.value),children:[e.jsx("option",{value:"gpt-4o-mini-tts",children:"GPT-4o mini TTS (cheapest, steerable)"}),e.jsx("option",{value:"tts-1",children:"TTS-1 (standard, low latency)"}),e.jsx("option",{value:"tts-1-hd",children:"TTS-1 HD (higher quality)"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"gpt-4o-mini-tts supports tone steering via the instructions field below."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"OpenAI Voice"}),e.jsxs("select",{value:n.openaiVoice||"alloy",onChange:s=>l("openaiVoice",s.target.value),children:[e.jsx("option",{value:"alloy",children:"Alloy (neutral)"}),e.jsx("option",{value:"ash",children:"Ash (male)"}),e.jsx("option",{value:"ballad",children:"Ballad (male)"}),e.jsx("option",{value:"coral",children:"Coral (female)"}),e.jsx("option",{value:"echo",children:"Echo (male)"}),e.jsx("option",{value:"fable",children:"Fable (neutral)"}),e.jsx("option",{value:"onyx",children:"Onyx (deep male)"}),e.jsx("option",{value:"nova",children:"Nova (female)"}),e.jsx("option",{value:"sage",children:"Sage (female)"}),e.jsx("option",{value:"shimmer",children:"Shimmer (female)"}),e.jsx("option",{value:"verse",children:"Verse (neutral)"})]})]}),(n.voiceModel||"gpt-4o-mini-tts")==="gpt-4o-mini-tts"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Voice Instructions (optional)"}),e.jsx("input",{type:"text",maxLength:500,placeholder:"e.g. Speak warmly and calmly, like a friendly support agent",value:n.openaiInstructions||"",onChange:s=>l("openaiInstructions",s.target.value)}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Steers tone/emotion. Only applies to gpt-4o-mini-tts."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.25",max:"4.0",step:"0.05",value:n.voiceSpeed??1,onChange:s=>l("voiceSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.voiceSpeed??1,.25,4)}),e.jsxs("span",{className:"slider-value",children:[(n.voiceSpeed??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="inworld"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Inworld Model"}),e.jsxs("select",{value:n.voiceModel||"inworld-tts-1.5-max",onChange:s=>l("voiceModel",s.target.value),children:[e.jsx("option",{value:"inworld-tts-1.5-max",children:"TTS 1.5 Max (quality)"}),e.jsx("option",{value:"inworld-tts-1.5-mini",children:"TTS 1.5 Mini (fastest)"}),e.jsx("option",{value:"inworld-tts-2",children:"TTS 2 (steerable, 100+ langs)"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Streamed over WebSocket. Note: your Inworld API key must have the TTS scope enabled."})]}),Ee(K)&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Language ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("select",{value:n.inworldLanguage||"all",onChange:s=>l("inworldLanguage",s.target.value),children:[e.jsx("option",{value:"all",children:"All languages"}),Te(K).map(([s,a])=>e.jsx("option",{value:s,children:a},s))]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Inworld Voice"}),e.jsx("select",{value:n.inworldVoice||"Ashley",onChange:s=>l("inworldVoice",s.target.value),children:K.length?_e(us(K,n.inworldLanguage),"gender"):e.jsx("option",{value:"Ashley",children:"Ashley"})})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"1.5",step:"0.05",value:n.voiceSpeed??1,onChange:s=>l("voiceSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.voiceSpeed??1,.5,1.5)}),e.jsxs("span",{className:"slider-value",children:[(n.voiceSpeed??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="smallest"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Smallest Model"}),e.jsxs("select",{value:n.voiceModel||"lightning_v3.1",onChange:s=>l("voiceModel",s.target.value),children:[e.jsx("option",{value:"lightning_v3.1",children:"Lightning v3.1"}),e.jsx("option",{value:"lightning_v3.1_pro",children:"Lightning v3.1 Pro"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Ultra-low-latency streaming over WebSocket."})]}),Ee(M)&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["Language ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("select",{value:n.smallestLanguage==="all"?"":n.smallestLanguage||"",onChange:s=>l("smallestLanguage",s.target.value),children:[e.jsx("option",{value:"",children:"All languages"}),Te(M).map(([s,a])=>e.jsx("option",{value:s,children:a},s))]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Smallest Voice"}),e.jsx("select",{value:n.smallestVoice||"kanik",onChange:s=>l("smallestVoice",s.target.value),children:M.length?_e(us(M,n.smallestLanguage==="all"?"":n.smallestLanguage),"gender"):e.jsx("option",{value:"kanik",children:"Kanik"})})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.voiceSpeed??1,onChange:s=>l("voiceSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.voiceSpeed??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.voiceSpeed??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="rime"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Rime Model"}),e.jsxs("select",{value:n.voiceModel||"mistv2",onChange:s=>l("voiceModel",s.target.value),children:[e.jsx("option",{value:"mistv2",children:"Mist v2 (fastest, cheapest)"}),e.jsx("option",{value:"mistv3",children:"Mist v3"}),e.jsx("option",{value:"arcana",children:"Arcana (expressive)"}),e.jsx("option",{value:"coda",children:"Coda (flagship)"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Sub-200ms streaming over WebSocket (/ws3)."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Rime Voice"}),e.jsx("select",{value:n.rimeVoice||"cove",onChange:s=>l("rimeVoice",s.target.value),children:Z.length?_e(Z.filter(s=>!s.model||!n.voiceModel||s.model===n.voiceModel),"language"):e.jsx("option",{value:"cove",children:"Cove"})})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.voiceSpeed??1,onChange:s=>l("voiceSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.voiceSpeed??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.voiceSpeed??1).toFixed(2),"x"]})]})]})]}),n.voiceProvider==="fish"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Fish Model"}),e.jsxs("select",{value:n.fishModel||"s2.1-pro",onChange:s=>l("fishModel",s.target.value),children:[e.jsx("option",{value:"s2.1-pro",children:"S2.1 Pro (highest quality)"}),e.jsx("option",{value:"s2-pro",children:"S2 Pro"}),e.jsx("option",{value:"speech-1.6",children:"Speech 1.6 (fast)"}),e.jsx("option",{value:"speech-1.5",children:"Speech 1.5"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Streaming synthesis over HTTP. Balanced latency mode is tuned for live calls."})]}),(()=>{const s=new Set(Be.map(r=>r.voice_id)),a=n.fishVoiceId||"",t=Ns||a&&!s.has(a),i=t?"__custom__":a;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Voice"}),e.jsxs("select",{value:i,onChange:r=>{const u=r.target.value;u==="__custom__"?Re(!0):(Re(!1),l("fishVoiceId",u))},children:[e.jsx("option",{value:"",children:"Default voice (Aria)"}),Be.map(r=>e.jsxs("option",{value:r.voice_id,children:[r.name,r.gender?` (${r.gender})`:""]},r.voice_id)),e.jsx("option",{value:"__custom__",children:"Custom voice — paste your own ID…"})]}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"Pick a ready-made voice, or choose Custom to use your own/cloned voice from fish.audio."})]}),t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Custom Reference ID"}),e.jsx("input",{type:"text",value:a,placeholder:"e.g. ca3007f96ae7499ab87d27ea3599956a",onChange:r=>l("fishVoiceId",r.target.value.trim())}),e.jsx("small",{style:{color:"#666",fontSize:"0.75rem"},children:"The 32-character ID from the voice URL on fish.audio (fish.audio/m/<id>)."})]})]})})(),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Latency Mode"}),e.jsxs("select",{value:n.fishLatency||"balanced",onChange:s=>l("fishLatency",s.target.value),children:[e.jsx("option",{value:"balanced",children:"Balanced (lower latency — recommended for calls)"}),e.jsx("option",{value:"normal",children:"Normal (higher quality)"})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Speech Speed"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0.5",max:"2.0",step:"0.05",value:n.fishSpeed??1,onChange:s=>l("fishSpeed",parseFloat(s.target.value)),className:"slider",style:P(n.fishSpeed??1,.5,2)}),e.jsxs("span",{className:"slider-value",children:[(n.fishSpeed??1).toFixed(2),"x"]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Volume (dB)"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"-20",max:"20",step:"1",value:n.fishVolume??0,onChange:s=>l("fishVolume",parseInt(s.target.value,10)),className:"slider",style:P(n.fishVolume??0,-20,20)}),e.jsxs("span",{className:"slider-value",children:[n.fishVolume??0," dB"]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Temperature (expressiveness)"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:n.fishTemperature??.7,onChange:s=>l("fishTemperature",parseFloat(s.target.value)),className:"slider",style:P(n.fishTemperature??.7,0,1)}),e.jsx("span",{className:"slider-value",children:(n.fishTemperature??.7).toFixed(2)})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Top P (diversity)"}),e.jsxs("div",{className:"slider-control",children:[e.jsx("input",{type:"range",min:"0",max:"1",step:"0.05",value:n.fishTopP??.7,onChange:s=>l("fishTopP",parseFloat(s.target.value)),className:"slider",style:P(n.fishTopP??.7,0,1)}),e.jsx("span",{className:"slider-value",children:(n.fishTopP??.7).toFixed(2)})]})]})]})]}):_==="advanced"?e.jsxs("div",{className:"advanced-tab-intro",children:[e.jsx("span",{className:"section-kicker",children:"Settings"}),e.jsx("h2",{className:"section-title",children:"Advanced Controls"}),e.jsx("p",{className:"section-subtitle",children:"Customize how your assistant handles calls — backup voices, privacy, voicemail, speaking timing, and more."})]}):_==="knowledge"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"KNOWLEDGE BASE"}),e.jsx("p",{className:"section-subtitle",children:"Attach uploaded Knowledge Bases to this assistant for RAG-powered answers."}),e.jsx(Ma,{assistant:n,onUpdate:l})]}):_==="code"?e.jsx(Ga,{assistant:n,baseUrl:typeof window<"u"?window.location.origin:"",formatAssistantConfig:ea,showToast:E}):null,_==="model"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["First Message Mode ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsxs("select",{value:n.firstMessageMode||"user_speaks_first",onChange:s=>l("firstMessageMode",s.target.value),children:[e.jsx("option",{value:"ai_speaks_first",children:"AI Speaks First"}),e.jsx("option",{value:"user_speaks_first",children:"User Speaks First"}),e.jsx("option",{value:"model_generated",children:"Model Generated Message"})]})]}),n.firstMessageMode==="ai_speaks_first"&&e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{children:["First Message ",e.jsx("span",{className:"label-info",children:"(i)"})]}),e.jsx("textarea",{value:n.firstM
1essage||"",onChange:s=>l("firstMessage",s.target.value),placeholder:"Hello! How can I help you today?",rows:2})]}),n.firstMessageMode==="model_generated"&&e.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginBottom:"1rem",padding:"0.5rem 0.75rem",background:"var(--bg-tertiary)",borderRadius:"6px"},children:"The AI will generate a natural opening message using your system prompt and selected model at call start."}),n.firstMessageMode==="user_speaks_first"&&e.jsx("p",{style:{fontSize:"0.75rem",color:"var(--text-muted)",marginBottom:"1rem",padding:"0.5rem 0.75rem",background:"var(--bg-tertiary)",borderRadius:"6px"},children:"The assistant will wait silently for the user to speak first."}),e.jsxs("div",{className:"form-group",children:[e.jsxs("div",{className:"prompt-field-header",children:[e.jsx("label",{children:"System Prompt"}),e.jsxs("div",{className:"prompt-header-actions",children:[e.jsx("button",{type:"button",className:"prompt-generate-btn",onClick:()=>ee(!0),title:"Generate a structured system prompt from business details",children:"Generate"}),e.jsxs("button",{type:"button",className:"prompt-expand-btn",onClick:()=>C(!0),title:"Open the system prompt in full screen",children:[e.jsx(va,{size:14}),e.jsx("span",{children:"Full screen"})]})]})]}),e.jsx("textarea",{value:n.systemPrompt||"",onChange:s=>l("systemPrompt",s.target.value),placeholder:"You are a helpful voice assistant. Be friendly and professional.",rows:12,className:"system-prompt-textarea"}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",flexWrap:"wrap",gap:"8px",fontSize:"0.72rem",color:"var(--text-muted)",marginTop:"4px"},children:[e.jsxs("span",{children:[Ce.toLocaleString()," chars · ~",ne.toLocaleString()," tokens"]}),(()=>{const s=ye;if(!s||s.shape==="error")return null;const a=s.shape==="canonical",t=a?s.components?.llm:s.legacy?.llm||s.llm,i=a?t?.promptCostUSD:t?.promptCostPerMin;return i==null?null:e.jsxs("span",{children:["Prompt cost: $",Number(i).toFixed(2),"/min"]})})()]}),U&&e.jsx("div",{style:{marginTop:"6px",padding:"6px 10px",borderRadius:"6px",fontSize:"0.75rem",background:U.level==="high"?"rgba(255, 70, 70, 0.1)":U.level==="medium"?"rgba(255, 165, 0, 0.1)":"rgba(255, 200, 0, 0.08)",color:U.level==="high"?"#ff4757":U.level==="medium"?"#e07b00":"#946e00",border:`1px solid ${U.level==="high"?"rgba(255, 70, 70, 0.3)":U.level==="medium"?"rgba(255, 165, 0, 0.3)":"rgba(255, 200, 0, 0.25)"}`},children:U.text})]}),e.jsx(Wa,{assistant:n}),e.jsx(qa,{assistant:n}),e.jsx(Ka,{assistant:n})]})]}),n&&_==="advanced"&&e.jsxs("div",{className:"advanced-sections",children:[e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🔒"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Privacy"}),e.jsx("span",{className:"accordion-desc",children:"Control what gets recorded and stored during calls."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🏥"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"HIPAA Compliance"}),e.jsx("span",{className:"setting-desc",children:"You have the HIPAA add-on to enable HIPAA compliance. Go to Billing."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.hipaaCompliance||!1,onChange:s=>l("hipaaCompliance",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🗑️"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Zero Data Retention (ZDR)"}),e.jsx("span",{className:"setting-desc",children:"You have the ZDR add-on to enable Zero Data Retention. Go to Billing."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.zeroDataRetention||!1,onChange:s=>l("zeroDataRetention",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),v.loading?e.jsx("div",{className:"setting-row","aria-live":"polite",children:e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:e.jsx(os,{className:"spin"})}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Call recording"}),e.jsx("span",{className:"setting-desc",children:"Checking recording access…"})]})]})}):v.error?e.jsx("div",{className:"setting-row",children:e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"⚠️"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Call recording"}),e.jsx("span",{className:"setting-desc",children:"Recording access could not be verified. Refresh the page to try again."})]})]})}):v.allowed?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🎙️"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Call recording"}),e.jsx("span",{className:"setting-desc",children:"Recording is enabled for this Enterprise account. Toggle off per-assistant if a particular assistant should not be recorded."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.audioRecording!==!1,onChange:s=>l("audioRecording",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]})}):e.jsx("div",{className:"setting-row",style:{background:"#FFF7ED",borderRadius:12,padding:14,border:"1px dashed rgba(249, 115, 22, 0.35)"},children:e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔒"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Call recording"}),e.jsx("span",{className:"setting-desc",children:v.plan==="enterprise"?"Recording access is not enabled for this Enterprise account. Contact your admin to grant access.":"Call recording is available only for Enterprise accounts with admin approval. Contact sales to upgrade."})]})]})}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"📋"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Logging"}),e.jsx("span",{className:"setting-desc",children:"Enable or disable logging during a call. Disable on this assistant to keep in portion of signed conversation periods."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.logging!==!1,onChange:s=>l("logging",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"📝"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Transcript"}),e.jsx("span",{className:"setting-desc",children:"Enable or disable transcription during a call. Disable on this assistant to keep in portion of signed conversation periods."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.transcript!==!1,onChange:s=>l("transcript",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),v.allowed&&e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🎵"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Audio recording format"}),e.jsx("span",{className:"setting-desc",children:"Choose the format for call recordings."})]})]}),e.jsxs("select",{className:"setting-select",value:n.audioRecordingFormat||"wav",onChange:s=>l("audioRecordingFormat",s.target.value),children:[e.jsx("option",{value:"wav",children:"WAV"}),e.jsx("option",{value:"mp3",children:"MP3"}),e.jsx("option",{value:"ogg",children:"OGG"})]})]})]})]}),na(),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🗣️"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"When to Start Speaking"}),e.jsx("span",{className:"accordion-desc",children:"How long the assistant waits before responding after the caller stops talking."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Timer"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Wait Seconds"}),e.jsx("span",{className:"setting-desc",children:"This is how long assistant waits before speaking."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"5",step:"0.1",value:n.waitSeconds??.4,onCh
1ange:s=>l("waitSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"5",step:"0.1",value:n.waitSeconds??.4,onChange:s=>l("waitSeconds",parseFloat(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🧠"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Smart Endpointing"}),e.jsx("span",{className:"setting-desc",children:"Enable for more accurate speech endpoint detection. Useful only available in English."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.smartEndpointing||!1,onChange:s=>l("smartEndpointing",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Pause"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"On Punctuation Seconds"}),e.jsx("span",{className:"setting-desc",children:"Minimum seconds to wait after transcription ending with punctuation."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"5",step:"0.1",value:n.onPunctuationSeconds??.1,onChange:s=>l("onPunctuationSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"5",step:"0.1",value:n.onPunctuationSeconds??.1,onChange:s=>l("onPunctuationSeconds",parseFloat(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"💬"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"On No Punctuation Seconds"}),e.jsx("span",{className:"setting-desc",children:"Minimum seconds to wait after transcription ending without punctuation."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"5",step:"0.1",value:n.onNoPunctuationSeconds??1.5,onChange:s=>l("onNoPunctuationSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"5",step:"0.1",value:n.onNoPunctuationSeconds??1.5,onChange:s=>l("onNoPunctuationSeconds",parseFloat(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔢"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"On Number Seconds"}),e.jsx("span",{className:"setting-desc",children:"Minimum seconds to wait after transcription ending with a number."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"5",step:"0.1",value:n.onNumberSeconds??.5,onChange:s=>l("onNumberSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"5",step:"0.1",value:n.onNumberSeconds??.5,onChange:s=>l("onNumberSeconds",parseFloat(s.target.value))})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"📞"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Voicemail Handling"}),e.jsx("span",{className:"accordion-desc",children:"What happens when an outbound call reaches an answering machine. Uses our own transcript-based detection — no carrier add-on required."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"VM"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Enable Voicemail Detection"}),e.jsx("span",{className:"setting-desc",children:"Detect answering machines on outbound calls and act automatically. Off by default; applies to outbound calls only."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.voicemailDetectionEnabled||!1,onChange:s=>l("voicemailDetectionEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Act"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"When voicemail is detected"}),e.jsx("span",{className:"setting-desc",children:"What the assistant does when it detects an answering machine."})]})]}),e.jsxs("select",{className:"setting-select",value:n.voicemailBehavior||"leave_message_then_hangup",onChange:s=>l("voicemailBehavior",s.target.value),children:[e.jsx("option",{value:"leave_message_then_hangup",children:"Leave a message, then hang up"}),e.jsx("option",{value:"hangup_immediately",children:"Hang up (no message)"}),e.jsx("option",{value:"continue_call",children:"Keep talking"})]})]}),(n.voicemailBehavior||"leave_message_then_hangup")==="leave_message_then_hangup"&&e.jsxs("div",{className:"setting-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"setting-info",style:{marginBottom:"0.5rem"},children:e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Voicemail message"}),e.jsx("span",{className:"setting-desc",children:"Spoken when a voicemail is detected, then the call ends. Keep it short."})]})}),e.jsx("textarea",{className:"setting-text-input",rows:3,maxLength:500,placeholder:"Hi, sorry we missed you — please call us back at your convenience.",value:n.voicemailMessage||"",onChange:s=>l("voicemailMessage",s.target.value)})]}),e.jsxs("div",{style:{display:"none"},children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"📱"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Voicemail Detection Provider"}),e.jsx("span",{className:"setting-desc",children:"Vagle uses advanced AI for detection. Google/OpenAI use simple models. Twilio uses traditional AMD."})]})]}),e.jsxs("select",{className:"setting-select",value:n.voicemailDetectionProvider||"google",onCh
1ange:s=>l("voicemailDetectionProvider",s.target.value),children:[e.jsx("option",{value:"google",children:"Google"}),e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"twilio",children:"Twilio (AMD)"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Timer"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Initial Detection Delay"}),e.jsx("span",{className:"setting-desc",children:"Delay before the first detection check."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"30",step:"1",value:n.voicemailInitialDetectionDelay??5,onChange:s=>l("voicemailInitialDetectionDelay",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"30",step:"1",value:n.voicemailInitialDetectionDelay??5,onChange:s=>l("voicemailInitialDetectionDelay",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔄"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Detection Retry Interval"}),e.jsx("span",{className:"setting-desc",children:"Interval between detection checks."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0.5",max:"20",step:"0.1",value:n.voicemailDetectionRetryInterval??5,onChange:s=>l("voicemailDetectionRetryInterval",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0.5",max:"20",step:"0.1",value:n.voicemailDetectionRetryInterval??5,onChange:s=>l("voicemailDetectionRetryInterval",parseFloat(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔁"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Max Detection Retries"}),e.jsx("span",{className:"setting-desc",children:"Limit on detection attempts."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"1",max:"10",step:"1",value:n.voicemailMaxDetectionRetries??6,onChange:s=>l("voicemailMaxDetectionRetries",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"1",max:"10",step:"1",value:n.voicemailMaxDetectionRetries??6,onChange:s=>l("voicemailMaxDetectionRetries",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Wait"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Max Voicemail Message Wait"}),e.jsx("span",{className:"setting-desc",children:"Max wait time before leaving voicemail message if it is voicemail."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"60",step:"1",value:n.voicemailMaxMessageWait??0,onChange:s=>l("voicemailMaxMessageWait",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"60",step:"1",value:n.voicemailMaxMessageWait??0,onChange:s=>l("voicemailMaxMessageWait",parseInt(s.target.value))})]})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🛑"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"When to Stop Speaking"}),e.jsx("span",{className:"accordion-desc",children:"How the assistant reacts when the caller interrupts or talks over it."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"#"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Number of Words"}),e.jsx("span",{className:"setting-desc",children:"This is the number of words that the customer has to say before the assistant will stop talking."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"10",step:"1",value:n.stopSpeakingNumWords??3,onChange:s=>l("stopSpeakingNumWords",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"10",step:"1",value:n.stopSpeakingNumWords??3,onChange:s=>l("stopSpeakingNumWords",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔊"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Voice Seconds"}),e.jsx("span",{className:"setting-desc",children:"This is the seconds customer has to speak before the assistant stops talking."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"0.5",step:"0.01",value:n.stopSpeakingVoiceSeconds??.2,onChange:s=>l("stopSpeakingVoiceSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"0.5",step:"0.01",value:n.stopSpeakingVoiceSeconds??.2,onChange:s=>l("stopSpeakingVoiceSeconds",parseFloat(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Back"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Back Off Seconds"}),e.jsx("span",{className:"setting-desc",children:"This is the seconds to wait before the assistant will start talking again after being interrupted."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"10",step:"0.1",value:n.backoffSeconds??1,onChange:s=>l("backoffSeconds",parseFloat(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"10",step:"0.1",value:n.backoffSeconds??1,onChange:s=>l("backoffSeconds",parseFloat(s.target.value))})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"Clock"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Call Timeout Settings"}),e.jsx("span",{className:"accordion-desc",children:"Configure when the assistant should end a call based on silence or duration."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Prompt"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Ask again on silence"}),e.jsx("span",{className:"setting-desc",children:"When the caller goes quiet, the assistant checks in instead of ending the call immediately."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.silenceFallbackEnabled!==!1,onChange:s=>l("silenceFallbackEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),n.silenceFallbackEnabled!==!1&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Wait"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Check-in after silence"}),e.jsx("span",{className:"setting-desc",children:"How many seconds of caller silence before the assistant asks again."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"1",max:"60",step:"1",value:n.silenceFallbackAfterSeconds??10,onChange:s=>l("silenceFallbackAfterSeconds",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"1",max:"60",step:"1",value:n.silenceFallbackAfterSeconds??10,onChange:s=>l("silenceFallbackAfterSeconds",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Retry"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Check-in retries"}),e.jsx("span",{className:"setting-desc",children:"How many times to ask before the normal max-retry behavior runs."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"10",step:"1",value:n.silenceFallbackMaxRetries??2,onCh
1ange:s=>l("silenceFallbackMaxRetries",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"10",step:"1",value:n.silenceFallbackMaxRetries??2,onChange:s=>l("silenceFallbackMaxRetries",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row vertical",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Say"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Silence check-in message"}),e.jsx("span",{className:"setting-desc",children:"What the assistant says when the caller does not reply."})]})]}),e.jsx("textarea",{className:"setting-text-input",rows:3,maxLength:500,placeholder:"Are you still there? Please say something if you need assistance.",value:n.fallbackMessageSilence||"",onChange:s=>l("fallbackMessageSilence",s.target.value)})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔇"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Silence Timeout"}),e.jsx("span",{className:"setting-desc",children:"How long to wait before a call is automatically ended due to inactivity."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"10",max:"3600",step:"1",value:n.silenceTimeoutSeconds??30,onChange:s=>l("silenceTimeoutSeconds",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"10",max:"3600",step:"1",value:n.silenceTimeoutSeconds??30,onChange:s=>l("silenceTimeoutSeconds",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Timer"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Maximum Duration"}),e.jsx("span",{className:"setting-desc",children:"The maximum number of seconds a call will last."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"10",max:"43200",step:"10",value:n.maxDurationSeconds??600,onChange:s=>l("maxDurationSeconds",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"10",max:"43200",step:"1",value:n.maxDurationSeconds??600,onChange:s=>l("maxDurationSeconds",parseInt(s.target.value))})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🔢"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Keypad Input Settings"}),e.jsx("span",{className:"accordion-desc",children:"Configure whether a user can input digits via the keypad, and when to process the input."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"¨ï¸"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Enable Keypad Input"}),e.jsx("span",{className:"setting-desc",children:"Accept user input via the keypad."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.keypadInputEnabled||!1,onChange:s=>l("keypadInputEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),n.keypadInputEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"Timer"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Timeout"}),e.jsx("span",{className:"setting-desc",children:"The number of seconds to wait before processing the user's keypad input. Set to 0 to only wait for a delimiter."})]})]}),e.jsxs("div",{className:"slider-group",children:[e.jsx("input",{type:"range",min:"0",max:"10",step:"1",value:n.keypadInputTimeout??2,onChange:s=>l("keypadInputTimeout",parseInt(s.target.value))}),e.jsx("input",{type:"number",className:"slider-value",min:"0",max:"10",step:"1",value:n.keypadInputTimeout??2,onChange:s=>l("keypadInputTimeout",parseInt(s.target.value))})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"#"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Delimiter"}),e.jsx("span",{className:"setting-desc",children:"A character that will be used to determine when to process the user's keypad input. If both delimiter and timeout are set, the first to be reached will cause the input to be processed."})]})]}),e.jsx("div",{className:"delimiter-input-group",children:e.jsx("input",{type:"text",className:"delimiter-input",maxLength:"1",value:n.keypadInputDelimiter||"#",onChange:s=>l("keypadInputDelimiter",s.target.value)})})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"💬"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Messaging"}),e.jsx("span",{className:"accordion-desc",children:"Configure post-call messaging behavior for the assistant."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"📩"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Enable Messaging"}),e.jsx("span",{className:"setting-desc",children:"Send a message after the call ends (e.g. summary, follow-up link)."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.messagingEnabled||!1,onChange:s=>l("messagingEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),n.messagingEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔚"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"End Call After Message"}),e.jsx("span",{className:"setting-desc",children:"Automatically end the call after the message is sent."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.messagingEndCallAfter||!1,onChange:s=>l("messagingEndCallAfter",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsxs("div",{className:"setting-info",style:{marginBottom:"0.5rem"},children:[e.jsx("span",{className:"setting-icon",children:"📝"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Message Content"}),e.jsxs("span",{className:"setting-desc",children:["The message to send after the call. Supports variables like ","{{summary}}"," and ","{{caller_number}}","."]})]})]}),e.jsx("textarea",{className:"messaging-textarea",rows:3,placeholder:"Thank y
1ou for calling! Here's a summary of our conversation: {{summary}}",value:n.messagingContent||"",onChange:s=>l("messagingContent",s.target.value)})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"↔"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Agent Memory and Handoff"}),e.jsx("span",{className:"accordion-desc",children:"Let this assistant remember returning callers, score intent, and hand off internally to another AI assistant when needed."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🧠"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Conversation memory"}),e.jsx("span",{className:"setting-desc",children:"Use short previous-call memory for the same phone number, including outcome, summary, objections, and next step."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.conversationMemoryEnabled!==!1,onChange:s=>l("conversationMemoryEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"↗"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Live deal intelligence"}),e.jsx("span",{className:"setting-desc",children:"Track buying intent, objections, buyer profile, and next best action during the call. Scores are private and never spoken to the caller."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.liveDealIntelligenceEnabled!==!1,onChange:s=>l("liveDealIntelligenceEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"⇄"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Allow AI agent handoff"}),e.jsx("span",{className:"setting-desc",children:"Switch internally to another assistant when the caller asks for sales, support, pricing, booking, technical help, or escalation."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:!!n.aiHandoff?.enabled,onChange:s=>{const a=n.aiHandoff||{};l("aiHandoff",{...a,enabled:s.target.checked,rules:Array.isArray(a.rules)&&a.rules.length?a.rules:[{triggers:[],targetAssistantId:"",targetRole:"",label:""}]})}}),e.jsx("span",{className:"toggle-slider"})]})]}),n.aiHandoff?.enabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-col",children:[e.jsx("span",{className:"setting-label",children:"Target assistant"}),e.jsxs("select",{className:"setting-select full-width",value:n.aiHandoff?.rules?.[0]?.targetAssistantId||"",onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{};l("aiHandoff",{...a,enabled:!0,rules:[{...t,targetAssistantId:s.target.value}]})},children:[e.jsx("option",{value:"",children:"Choose an assistant"}),(o||[]).filter(s=>String(s.id||s._id)!==String(n.id||n._id)).map(s=>e.jsx("option",{value:s.id||s._id,children:s.name},s.id||s._id))]})]}),e.jsxs("div",{className:"setting-col",children:[e.jsx("span",{className:"setting-label",children:"Role label"}),e.jsx("input",{className:"setting-text-input",placeholder:"Sales, booking, technical, pricing",value:n.aiHandoff?.rules?.[0]?.targetRole||"",onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{};l("aiHandoff",{...a,enabled:!0,rules:[{...t,targetRole:s.target.value,label:s.target.value||t.label||"Matched handoff rule"}]})}})]})]}),e.jsxs("div",{className:"setting-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsxs("div",{className:"setting-info",style:{marginBottom:"0.5rem"},children:[e.jsx("span",{className:"setting-icon",children:"#"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Trigger words"}),e.jsx("span",{className:"setting-desc",children:"Comma-separated words or phrases. Example: pricing, quote, technical issue, book appointment."})]})]}),e.jsx("input",{className:"setting-text-input full-width",placeholder:"pricing, quote, technical issue, booking",value:(n.aiHandoff?.rules?.[0]?.triggers||[]).join(", "),onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{},i=s.target.value.split(",").map(r=>
1r.trim()).filter(Boolean);l("aiHandoff",{...a,enabled:!0,rules:[{...t,triggers:i}]})}})]}),e.jsx("div",{className:"setting-row",children:e.jsxs("div",{className:"setting-col",children:[e.jsx("span",{className:"setting-label",children:"Routing mode"}),e.jsxs("select",{className:"setting-select full-width",value:n.aiHandoff?.routingMode||"keyword",onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]};l("aiHandoff",{...a,enabled:!0,routingMode:s.target.value})},children:[e.jsx("option",{value:"keyword",children:"Keyword match (fast, no extra cost)"}),e.jsx("option",{value:"ai",children:"AI decides (smarter, adds one LLM step per turn)"})]}),e.jsx("span",{className:"setting-desc",children:n.aiHandoff?.routingMode==="ai"?"The AI reads intent and picks the specialist. Trigger words become hints/examples.":"Switches when the caller says one of the trigger words above."})]})}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"👋"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Introduce specialist on switch"}),e.jsx("span",{className:"setting-desc",children:"When the call switches, the specialist opens with a short self-introduction."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.aiHandoff?.rules?.[0]?.introEnabled!==!1,onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{};l("aiHandoff",{...a,enabled:!0,rules:[{...t,introEnabled:s.target.checked}]})}}),e.jsx("span",{className:"toggle-slider"})]})]}),n.aiHandoff?.rules?.[0]?.introEnabled!==!1&&e.jsxs("div",{className:"setting-row",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("span",{className:"setting-label",children:"Custom intro line (optional)"}),e.jsx("input",{className:"setting-text-input full-width",placeholder:'Leave blank for auto, e.g. "Hi, I\\u2019m the technical specialist \\u2014 happy to help."',value:n.aiHandoff?.rules?.[0]?.introLine||"",onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{};l("aiHandoff",{...a,enabled:!0,rules:[{...t,introLine:s.target.value}]})}}),e.jsx("span",{className:"setting-desc",children:"Blank = the specialist introduces itself naturally. Filled = spoken word-for-word."})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🧠"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Share memory with this specialist"}),e.jsx("span",{className:"setting-desc",children:"Give the specialist the caller\\u2019s previous-call memory summary. The current call transcript is always shared during a live handoff."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.aiHandoff?.rules?.[0]?.shareMemory!==!1,onChange:s=>{const a=n.aiHandoff||{enabled:!0,rules:[]},t=a.rules?.[0]||{};l("aiHandoff",{...a,enabled:!0,rules:[{...t,shareMemory:s.target.checked}]})}}),e.jsx("span",{className:"toggle-slider"})]})]})]})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"Settings"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Additional Configuration"}),e.jsx("span",{className:"accordion-desc",children:"Configure additional settings for the voice of your assistant."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsx("div",{className:"setting-row",children:e.jsxs("div",{className:"setting-col",children:[e.jsxs("span",{className:"setting-label",children:["Input Min Characters ",e.jsx("span",{className:"label-info",children:"ⓘ"})]}),e.jsx("input",{type:"number",className:"setting-text-input",min:"1",max:"200",value:n.inputMinCharacters??30,onChange:s=>l("inputMinCharacters",parseInt(s.target.value)||30)})]})}),ia(),e.jsxs("div",{className:"setting-row legacy-punctuation-select",style:{flexDirection:"column",alignItems:"stretch"},children:[e.jsx("div",{className:"setting-info",style:{marginBottom:"0.5rem"},children:e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Punctuation Boundaries"}),e.jsx("span",{className:"setting-desc",children:"These are the punctuations that are considered valid boundaries or delimiters. This helps decide the chunks that are sent to the voice provider for the voice generation as the LLM tokens are streaming in."})]})}),e.jsxs("select",{className:"setting-select full-width",multiple:!0,size:3,value:n.punctuationBoundaries||[],onChange:s=>{const a=Array.from(s.target.selectedOptions,t=>t.value);l("punctuationBoundaries",a)},children:[e.jsx("option",{value:".",children:". (Period)"}),e.jsx("option",{value:",",children:" , (Comma)"}),e.jsx("option",{value:"?",children:"? (Question Mark)"}),e.jsx("option",{value:"!",children:"! (Exclamation)"}),e.jsx("option",{value:";",children:"; (Semicolon)"}),e.jsx("option",{value:":",children:": (Colon)"}),e.jsx("option",{value:"-",children:"- (Em Dash)"})]}),(!n.punctuationBoundaries||n.punctuationBoundaries.length===0)&&e.jsx("span",{className:"empty-hint",children:"No Punctuation Boundaries Added"})]})]})]}),e.jsxs("details",{className:"config-accordion legacy-fallback-section",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🔄"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Fallback Voices"}),e.jsx("span",{className:"accordion-desc",children:"No fallbacks configured - If primary voice fails, these providers will be tried in order."})]})]}),e.jsxs("div",{className:"accordion-body",children:[n.fallbackVoices&&n.fallbackVoices.length>0?e.jsx("div",{className:"fallback-list",children:n.fallbackVoices.map((s,a)=>e.jsxs("div",{className:"fallback-item",children:[e.jsx("span",{className:"fallback-index",children:a+1}),e.jsxs("select",{className:"setting-select",value:s.provider||"cartesia",onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],provider:t.target.value}
1,l("fallbackVoices",i)},children:[e.jsx("option",{value:"cartesia",children:"Cartesia"}),e.jsx("option",{value:"elevenlabs",children:"ElevenLabs"}),e.jsx("option",{value:"deepgram",children:"Deepgram Aura"})]}),e.jsx("input",{type:"text",className:"setting-text-input",placeholder:"Voice ID",value:s.voiceId||"",onChange:t=>{const i=[...n.fallbackVoices];i[a]={...i[a],voiceId:t.target.value},l("fallbackVoices",i)}}),e.jsx("button",{className:"btn-icon-sm remove-btn",onClick:()=>{const t=n.fallbackVoices.filter((i,r)=>r!==a);l("fallbackVoices",t)},children:"×"})]},a))}):e.jsx("p",{className:"empty-hint center",children:"No fallbacks configured. Add a fallback provider for improved reliability."}),e.jsx("button",{className:"add-fallback-btn",onClick:()=>{const s=n.fallbackVoices||[];l("fallbackVoices",[...s,{provider:"cartesia",voiceId:""}])},children:"+ Add Voice Fallback"})]})]}),e.jsxs("details",{className:"config-accordion",children:[e.jsxs("summary",{className:"accordion-header",children:[e.jsx("span",{className:"accordion-icon",children:"🎙️"}),e.jsxs("div",{children:[e.jsx("span",{className:"accordion-title",children:"Transcriber"}),e.jsx("span",{className:"accordion-desc",children:"This section allows you to configure the transcription settings for the assistant."})]})]}),e.jsxs("div",{className:"accordion-body",children:[e.jsxs("div",{className:"setting-row",children:[e.jsx("div",{className:"setting-info",children:e.jsx("div",{children:e.jsx("span",{className:"setting-label",children:"Provider"})})}),e.jsxs("select",{className:"setting-select",value:n.transcriberProvider||"deepgram",onChange:s=>l("transcriberProvider",s.target.value),children:[e.jsx("option",{value:"deepgram",children:"Deepgram"}),e.jsx("option",{value:"groq",children:"Whisper"})]})]}),e.jsxs("div",{className:"setting-row",children:[e.jsx("div",{className:"setting-info",children:e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Language"}),e.jsx("span",{className:"setting-help",style:{color:"#6b7280",fontSize:"0.75rem"},children:"Pin language so Whisper doesn't auto-detect (and confuse Hindi with Urdu, etc)."})]})}),e.jsx("select",{className:"setting-select",value:n.transcriberLanguage||"en",onChange:s=>l("transcriberLanguage",s.target.value),children:(n.transcriberProvider||"deepgram")==="groq"?e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"hi",children:"Hindi"})]}):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"auto",children:"Auto-detect (English + Hindi / Hinglish)"}),e.jsx("option",{value:"multi",children:"Multilingual (Hinglish — English + Hindi)"}),e.jsx("option",{value:"en",children:"English"}),e.jsx("option",{value:"en-IN",children:"English (India)"}),e.jsx("option",{value:"hi",children:"Hindi"})]})})]}),e.jsxs("div",{className:"setting-row",children:[e.jsx("div",{className:"setting-info",children:e.jsx("div",{children:e.jsx("span",{className:"setting-label",children:"Model"})})}),e.jsx("select",{className:"setting-select",value:n.transcriber||"whisper-large-v3",onChange:s=>l("transcriber",s.target.value),children:N.length>0?N.map(s=>e.jsx("option",{value:s.key,children:s.name},s.key)):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"whisper-large-v3",children:"Whisper V3 Large"}),e.jsx("option",{value:"whisper-large-v3-turbo",children:"Whisper V3 Turbo"}),e.jsx("option",{value:"deepgram-nova-2",children:"Deepgram Nova-2"}),e.jsx("option",{value:"qwen3-asr-flash-realtime",children:"Qwen3 ASR Flash Realtime"})]})})]}),e.jsxs("div",{className:"setting-row",children:[e.jsxs("div",{className:"setting-info",children:[e.jsx("span",{className:"setting-icon",children:"🔇"}),e.jsxs("div",{children:[e.jsx("span",{className:"setting-label",children:"Backgroun
1d Denoising Enabled"}),e.jsx("span",{className:"setting-desc",children:"Filter background noise while the user is talking."})]})]}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:n.backgroundDenoisingEnabled||!1,onChange:s=>l("backgroundDenoisingEnabled",s.target.checked)}),e.jsx("span",{className:"toggle-slider"})]})]})]})]})]})]}):Ue?e.jsx(ra,{label:"Loading your assistant...",fullPage:!1}):e.jsxs("div",{className:"empty-config",children:[e.jsx(oe,{size:64}),e.jsx("h2",{children:"No Assistant Selected"}),e.jsx("p",{children:"Pick an assistant from the list, or use the Create Assistant button on the left."})]})})]}),y&&n&&da.createPortal(e.jsxs("div",{className:"prompt-fullscreen-overlay",style:{position:"fixed",inset:0,zIndex:2147483647,width:"100vw",height:"100dvh",isolation:"isolate"},role:"dialog","aria-modal":"true","aria-labelledby":"prompt-fullscreen-title",children:[e.jsxs("div",{className:"prompt-fullscreen-header",children:[e.jsxs("div",{className:"prompt-fullscreen-title-wrap",children:[e.jsx("h2",{id:"prompt-fullscreen-title",children:"System Prompt"}),e.jsx("span",{className:"prompt-fullscreen-subtitle",children:n.name||"Assistant"})]}),e.jsxs("button",{type:"button",className:"prompt-fullscreen-close",onClick:()=>C(!1),"aria-label":"Close full screen editor",children:[e.jsx(xs,{size:18}),e.jsx("span",{children:"Close editor"})]})]}),e.jsx("div",{className:"prompt-fullscreen-body",children:e.jsx("textarea",{ref:k,className:"prompt-fullscreen-textarea",value:n.systemPrompt||"",onChange:s=>l("systemPrompt",s.target.value),placeholder:"You are a helpful voice assistant. Be friendly and professional.",spellCheck:!0})}),e.jsxs("div",{className:"prompt-fullscreen-footer",children:[e.jsxs("div",{className:"prompt-fullscreen-meta",children:[e.jsxs("span",{children:[Ce.toLocaleString()," chars · ~",ne.toLocaleString()," tokens"]}),(()=>{const s=ye;if(!s||s.shape==="error")return null;const a=s.shape==="canonical",t=a?s.components?.llm:s.legacy?.llm||s.llm,i=a?t?.promptCostUSD:t?.promptCostPerMin;return i==null?null:e.jsxs("span",{children:["Prompt cost: $",Number(i).toFixed(2),"/min"]})})(),e.jsx("span",{className:"prompt-fullscreen-autosave",children:"Changes save automatically"})]}),U&&e.jsx("div",{className:`prompt-fullscreen-warning level-${U.level}`,children:U.text})]})]}),document.body),d&&e.jsx("div",{className:"modal-overlay",onClick:()=>g(!1),children:e.jsxs("div",{className:"modal-content",onClick:s=>s.stopPropagation(),children:[e.jsx("h2",{children:"Create New Assistant"}),e.jsxs("form",{onSubmit:s=>{s.preventDefault(),me.name.trim()&&(Ks({...me,model:"openai/gpt-oss-120b"}),we({name:"",model:"openai/gpt-oss-120b",voice:"Cartesia Sonic"}))},children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Assistant Name"}),e.jsx("input",{type:"text",value:me.name,onChange:s=>we({...me,name:s.target.value}),placeholder:"e.g., Customer Support Bot",required:!0,autoFocus:!0})]}),e.jsxs("p",{style:{fontSize:"0.82rem",color:"#64748b",margin:"4px 0 16px",lineHeight:1.5},children:["Your assistant is created with smart defaults — ",e.jsx("strong",{children:"GPT-5.4 Mini"})," model,",e.jsx("strong",{children:" Deepgram"})," transcriber, and a ready voice. You can change the model, voice, prompt, and tools anytime in the assistant settings."]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"submit",className:"btn-primary",children:"Create Assistant"}),e.jsx("button",{type:"button",onClick:()=>{g(!1),we({name:"",model:"openai/gpt-oss-120b",voice:"Cartesia Sonic"})},className:"btn-secondary",children:"Cancel"})]})]})]})}),Ms&&e.jsx("div",{className:"modal-overlay",onClick:()=>!z&&ee(!1),children:e.jsxs("div",{className:"json-modal",onClick:s=>s.stopPropagation(),style:{maxWidth:"640px"},children:[e.jsxs("div",{className:"json-modal-header",children:[e.jsx("h2",{style:{margin:0},children:"Generate System Prompt"}),e.jsx("button",{className:"close-btn",onClick:()=>!z&&ee(!1),disabled:z,children:"×"})]}),e.jsxs("div",{style:{padding:"16px 20px",maxHeight:"70vh",overflow:"auto"},children:[e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--text-muted)",marginBottom:"16
1px"},children:"Tell us about your assistant and we'll build a structured Vagle Realtime system prompt. You can edit it after."}),e.jsxs("div",{className:"prompt-quality-grid",children:[e.jsxs("button",{type:"button",className:`prompt-quality-card ${A.promptQuality==="best_quality"?"active":""}`,onClick:()=>R(s=>({...s,promptQuality:"best_quality"})),disabled:z,children:[e.jsx("span",{children:"Best Quality"}),e.jsx("small",{children:"Detailed agent structure with identity, priority order, source of truth, tool logic, confirmations, and recovery. Higher token usage."})]}),e.jsxs("button",{type:"button",className:`prompt-quality-card ${A.promptQuality!=="best_quality"?"active":""}`,onClick:()=>R(s=>({...s,promptQuality:"cost_effective"})),disabled:z,children:[e.jsx("span",{children:"Cost Effective"}),e.jsx("small",{children:"Compact production prompt for lower realtime cost and latency while keeping tool usage, behavior, and escalation rules clear."})]})]}),e.jsxs("div",{style:{display:"grid",gap:"12px",gridTemplateColumns:"1fr 1fr"},children:[e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Business name",e.jsx("input",{type:"text",value:A.businessName,onChange:s=>R(a=>({...a,businessName:s.target.value})),placeholder:"Acme Corp",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{fontSize:"0.78rem"},children:["Industry",e.jsx("input",{type:"text",value:A.industry,onChange:s=>R(a=>({...a,industry:s.target.value})),placeholder:"real estate, healthcare…",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{fontSize:"0.78rem"},children:["Call type",e.jsxs("select",{value:A.callType,onChange:s=>R(a=>({...a,callType:s.target.value})),style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"},children:[e.jsx("option",{value:"both",children:"Inbound + Outbound"}),e.jsx("option",{value:"inbound",children:"Inbound only"}),e.jsx("option",{value:"outbound",children:"Outbound only"})]})]}),e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Assistant role",e.jsx("input",{type:"text",value:A.role,onChange:s=>R(a=>({...a,role:s.target.value})),placeholder:"Lead qualification, customer support, appointment booking…",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Main goal",e.jsx("input",{type:"text",value:A.mainGoal,onCh
1ange:s=>R(a=>({...a,mainGoal:s.target.value})),placeholder:"Book a demo, qualify lead, resolve support ticket…",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Information to collect (comma or newline separated)",e.jsx("textarea",{value:A.requiredInfo,onChange:s=>R(a=>({...a,requiredInfo:s.target.value})),placeholder:"Name, phone, preferred time, budget…",rows:2,style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{fontSize:"0.78rem"},children:["Tone",e.jsx("input",{type:"text",value:A.tone,onChange:s=>R(a=>({...a,tone:s.target.value})),placeholder:"professional, friendly…",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{fontSize:"0.78rem"},children:["Tool usage preference",e.jsx("input",{type:"text",value:A.tools,onChange:s=>R(a=>({...a,tools:s.target.value})),placeholder:"calendar, CRM lookup, payment…",style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Escalation rules",e.jsx("textarea",{value:A.escalationRules,onChange:s=>R(a=>({...a,escalationRules:s.target.value})),placeholder:"When to hand off to a human (e.g. payment issue, angry caller)",rows:2,style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]}),e.jsxs("label",{style:{gridColumn:"1 / -1",fontSize:"0.78rem"},children:["Extra instructions (optional)",e.jsx("textarea",{value:A.extraInstructions,onChange:s=>R(a=>({...a,extraInstructions:s.target.value})),placeholder:"Anything else the assistant must follow",rows:2,style:{width:"100%",marginTop:"4px",padding:"8px 10px",borderRadius:"6px",border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)"}})]})]}),$e&&e.jsx("div",{style:{marginTop:"12px",padding:"8px 12px",background:"rgba(255, 70, 70, 0.1)",color:"#ff4757",borderRadius:"6px",fontSize:"0.82rem"},children:$e}),e.jsx("p",{style:{marginTop:"12px",fontSize:"0.72rem",color:"var(--text-muted)"},children:"Generating prompts uses a small amount of LLM tokens. During beta this is free."})]}),e.jsxs("div",{className:"json-modal-footer",style:{display:"flex",gap:"8px",justifyContent:"flex-end",padding:"12px 20px"},children:[e.jsx("button",{type:"button",className:"btn-secondary",onClick:()=>!z&&ee(!1),disabled:z,children:"Cancel"}),e.jsx("button",{type:"button",onClick:Fs,disabled:z,style:{padding:"8px 16px",borderRadius:"6px",border:"none",background:"#111827",color:"#fff",fontSize:"0.85rem",cursor:z?"not-allowed":"pointer",opacity:z?.7:1},children:z?"Generating…":"Generate System Prompt"})]})]})}),Cs&&n&&e.jsx("div",{className:"modal-overlay",onClick:()=>de(!1),children:e.jsxs("div",{className:"json-modal",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"json-modal-header",children:[e.jsxs("h3",{children:["Code · ",n.name]}),e.jsx("button",{className:"close-btn",onClick:()=>de(!1),children:"×"})]}),e.jsxs("div",{className:"json-modal-content",children:[e.jsxs("div",{className:"json-info",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Assistant ID:"})," ",e.jsx("code",{children:n._id||n.id})]}),e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.85rem"},children:["Use a ",e.jsx("strong",{children:"private API key"})," from the API Keys page to trigger calls. Replace",e.jsx("code",{children:" YOUR_PRIVATE_KEY"}),", ",e.jsx("code",{children:"YOUR_PHONE_ID"}),", and ",e.jsx("code",{children:"+15551234567"})," with real values."]})]}),e.jsxs("div",{style:{padding:"1rem 1.25rem"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("strong",{children:"Trigger an outbound call (cURL)"}),e.jsx("button",{className:"btn-secondary",style:{padding:"0.35rem 0.75rem",fontSize:"0.8rem"},onClick:()=>{const s=n._id||n.id,a=as(n),t=JSON.stringify({assistantId:s,phoneNumberId:"YOUR_PHONE_ID",toNumber:"+15551234567",assistant:a},null,2),i=`curl -X POST '${window.location.origin}/api/v1/calls' \\
2  -H 'X-Api-Key: YOUR_PRIVATE_KEY' \\
3  -H 'Content-Type: application/json' \\
4  -d '${t}'`;navigator.clipboard.writeText(i),E("cURL copied","success")},children:"Copy"})]}),e.jsx("div",{className:"json-container",style:{padding:0},children:e.jsx("pre",{className:"json-code",style:{maxHeight:"420px"},children:(()=>{const s=n._id||n.id,a=as(n),t=JSON.stringify({assistantId:s,phoneNumberId:"YOUR_PHONE_ID",toNumber:"+15551234567",assistant:a},null,2);return`curl -X POST '${window.location.origin}/api/v1/calls' \\
5  -H 'X-Api-Key: YOUR_PRIVATE_KEY' \\
6  -H 'Content-Type: application/json' \\
7  -d '${t}'`})()})})]}),e.jsx("div",{className:"json-actions",children:e.jsx("button",{className:"btn-secondary",onClick:()=>de(!1),children:"Close"})})]})]})}),Se&&e.jsx("div",{className:`app-toast app-toast-${Se.kind}`,role:"status",children:Se.message})]})}function Fe({groups:o,value:p,onChange:d,disabled:g=!1,placeholder:n="Select model"}){const[f,y]=c.useState(!1),[C,k]=c.useState(null),v=c.useRef(null),x=(()=>{for(const m of o){const N=m.items.find(b=>b.key===p);if(N)return N.displayName||N.name}return p||n})();c.useEffect(()=>{if(!f)return;function m(N){v.current&&(v.current.contains(N.target)||(y(!1),k(null)))}return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)}
7,[f]);function I(m){d(m),y(!1),k(null)}return e.jsxs("div",{ref:v,style:{position:"relative",width:"100%"},children:[e.jsxs("button",{type:"button",disabled:g,onClick:()=>y(m=>!m),style:{width:"100%",padding:"10px 12px",textAlign:"left",background:"#fff",border:"1px solid rgba(0,0,0,0.12)",borderRadius:"6px",fontSize:"0.9rem",color:"#222",cursor:g?"not-allowed":"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{children:x}),e.jsx("span",{style:{opacity:.5,fontSize:"0.75rem"},children:"▾"})]}),f&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:50,display:"flex",background:"#fff",border:"1px solid rgba(0,0,0,0.12)",borderRadius:"8px",boxShadow:"0 8px 24px rgba(0,0,0,0.12)",overflow:"hidden",width:"auto"},children:[e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",minWidth:"220px",maxHeight:"320px",overflowY:"auto"},children:o.filter(m=>(m.items||[]).some(N=>N.available!==!1)).map(m=>{const N=C===m.cat;return e.jsxs("li",{onMouseEnter:()=>k(m.cat),onClick:()=>k(m.cat),style:{padding:"8px 14px",cursor:"pointer",fontSize:"0.85rem",color:N?"#fff":"#222",background:N?"#111":"transparent",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px"},children:[e.jsx("span",{children:m.label}),e.jsxs("span",{style:{opacity:N?.85:.45,fontSize:"0.75rem"},children:[(m.items||[]).filter(b=>b.available!==!1).length," ›"]})]},m.cat)})}),C&&e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",borderLeft:"1px solid rgba(0,0,0,0.08)",minWidth:"260px",maxHeight:"320px",overflowY:"auto"},children:(o.find(m=>m.cat===C)?.items||[]).filter(m=>m.available!==!1).map(m=>{const N=m.key===p,b=m.available===!1;return e.jsxs("li",{onClick:()=>{b||I(m.key)},style:{padding:"8px 14px",cursor:b?"not-allowed":"pointer",fontSize:"0.85rem",color:b?"#a1a1aa":N?"#fff":"#222",background:N?"#2563eb":"transparent",minWidth:"280px",opacity:b?.55:1},onMouseEnter:S=>{!N&&!b&&(S.currentTarget.style.background="#f3f4f6")},onMouseLeave:S=>{N||(S.currentTarget.style.background="transparent")},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px",fontWeight:600},children:[e.jsxs("span",{children:[m.displayName||m.name,b?" (unavailable)":""]}),(()=>{const S=fs(m.latency);return S?e.jsxs("span",{title:`Approx. first-response latency: ${S.display}`,style:{flexShrink:0,fontSize:"0.66rem",fontWeight:700,lineHeight:1,padding:"3px 7px",borderRadius:"999px",color:N?"#fff":S.color,background:N?"rgba(255,255,255,0.22)":S.bg,whiteSpace:"nowrap"},children:["⚡ ",S.display," · ",S.label]}):null})()]}),m.helper&&e.jsx("span",{style:{display:"block",marginTop:"2px",color:N?"rgba(255,255,255,0.82)":"#64748b",fontSize:"0.72rem",lineHeight:1.35},children:m.helper})]},m.key)})})]})]})}function Ga({assistant:o,baseUrl:p,formatAssistantConfig:d,showToast:g}){const[n,f]=c.useState("curl"),[y,C]=c.useState(!1);if(!o)return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"CODE & INTEGRATIONS"}),e.jsx("p",{className:"section-subtitle",children:"Select an assistant to view ready-to-use code snippets."})]});const k=o._id||o.id||"asst_xxxxxxxxxx",v=d(o),x=JSON.stringify(v,null,2),I=JSON.stringify({assistantId:k,phoneNumberId:"YOUR_PHONE_ID",toNumber:"+15551234567",firstMessage:"Hi, this is a follow-up call from Vagle."},null,2),m=`curl -X POST '${p}/api/v1/calls' \\
8  -H 'X-Api-Key: vk_priv_YOUR_PRIVATE_KEY' \\
9  -H 'Content-Type: application/json' \\
10  -d '${I}'`,N=`// npm install undici (Node 18+ has fetch built in)
11const res = await fetch('${p}/api/v1/calls', {
12  method: 'POST',
13  headers: {
14    'X-Api-Key': 'vk_priv_YOUR_PRIVATE_KEY',
15    'Content-Type': 'application/json',
16  },
17  body: JSON.stringify({
18    assistantId:   '${k}',
19    phoneNumberId: 'YOUR_PHONE_ID',
20    toNumber:      '+15551234567',
21  }),
22})
23const data = await res.json()
24console.log(data)`,b=`# pip install requests
25import requests
26
27resp = requests.post(
28    '${p}/api/v1/calls',
29    headers={
30        'X-Api-Key': 'vk_priv_YOUR_PRIVATE_KEY',
31        'Content-Type': 'application/json',
32    },
33    json={
34        'assistantId':   '${k}',
35        'phoneNumberId': 'YOUR_PHONE_ID',
36        'toNumber':      '+15551234567',
37    },
38)
39print(resp.json())`,S=n==="curl"?m:n==="node"?N:n==="python"?b:x;async function B(){try{await navigator.clipboard.writeText(S),C(!0),setTimeout(()=>C(!1),1400),typeof g=="function"&&g("Copied to clipboard","success")}catch{typeof g=="function"&&g("Could not copy","error")}}const F=[{key:"curl",label:"cURL"},{key:"node",label:"Node.js"},{key:"python",label:"Python"},{key:"json",label:"Assistant JSON"}];return e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"section-title",children:"CODE & INTEGRATIONS"}),e.jsxs("p",{className:"section-subtitle",children:["Drop these into your stack to talk to Vagle over HTTP."," ",e.jsx($,{to:"/docs/api",style:{color:"#F97316",fontWeight:700},children:"Open API docs →"})]}),e.jsx("div",{style:{background:"#FFFFFF",border:"1px solid rgba(15, 23, 42, 0.08)",borderRadius:12,padding:16,marginBottom:14,fontSize:"0.9rem"},children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:16,color:"#475569"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7rem",color:"#94A3B8",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:"Assistant ID"}),e.jsx("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"#111111",fontWeight:700},children:k})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7rem",color:"#94A3B8",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:"Endpoint"}),e.jsxs("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"#111111",fontWeight:700},children:["POST ",p,"/api/v1/calls"]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"0.7rem",color:"#94A3B8",textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:700},children:"Auth"}),e.jsx("div",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"#111111",fontWeight:700},children:"X-Api-Key: vk_priv_…"})]})]})}),e.jsx("div",{style:{display:"inline-flex",background:"#F1F5F9",border:"1px solid rgba(15, 23, 42, 0.08)",borderRadius:999,padding:4,gap:4,marginBottom:8},children:F.map(V=>e.jsx("button",{type:"button",onClick:()=>f(V.key),style:{padding:"6px 12px",borderRadius:999,border:0,fontSize:"0.78rem",fontWeight:700,cursor:"pointer",background:n===V.key?"#FFFFFF":"transparent",color:n===V.key?"#111111":"#475569",boxShadow:n===V.key?"0 1px 2px rgba(15,23,42,0.08)":"none"},children:V.label},V.key))}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{type:"button",onClick:B,style:{position:"absolute",top:10,right:10,background:"rgba(255,255,255,0.10)",color:"#FFFFFF",border:"1px solid rgba(255,255,255,0.18)",borderRadius:8,fontSize:"0.74rem",fontWeight:700,padding:"5px 10px",cursor:"pointer"},children:y?"Copied":"Copy"}),e.jsx("pre",{style:{background:"#0B1220",color:"#E2E8F0",fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:"0.82rem",lineHeight:1.55,borderRadius:12,padding:"16px 18px",overflowX:"auto",whiteSpace:"pre",margin:0,maxHeight:460},children:S})]}),e.jsxs("p",{style:{marginTop:12,fontSize:"0.82rem",color:"#64748B"},children:["Replace ",e.jsx("code",{children:"vk_priv_YOUR_PRIVATE_KEY"})," with a key from"," ",e.jsx($,{to:"/api-keys",style:{color:"#F97316",fontWeight:700},children:"API Keys"})," ","and ",e.jsx("code",{children:"YOUR_PHONE_ID"})," with one of your"," ",e.jsx($,{to:"/phone-numbers",style:{color:"#F97316",fontWeight:700},children:"phone numbers"}),". Full reference at"," ",e.jsx($,{to:"/docs/api",style:{color:"#F97316",fontWeight:700},children:"/docs/api"}),"."]})]})}function Wa({assistant:o}){const[p,d]=c.useState([]),[g,n]=c.useState([]),[f,y]=c.useState(!1);if(c.useEffect(()=>{if(!o?.id)return;let m=!1;return(async()=>{try{const[N,b]=await Promise.all([T.authedFetch(w.getApiUrl(`/api/assistants/${o.id}/tools`)),T.authedFetch(w.getApiUrl("/api/tools"))]),S=await N.json().catch(()=>({})),B=await b.json().catch(()=>({}));if(m)return;d(Array.isArray(S?.tools)?S.tools:[]),n(Array.isArray(B?.tools)?B.tools:[])}finally{m||y(!0)}})(),()=>{m=!0}},[o?.id]),!f)return null;const C=p.filter(m=>m&&m.enabled!==!1),k=new Map(g.map(m=>[String(m.id),m])),v=C.map(m=>
39k.get(String(m.toolId))?.name).filter(Boolean),x=C.length,I=x>0&&fa(o?.model);return e.jsxs("div",{className:"assistant-connected-tools",role:"region","aria-label":"Connected tools",children:[e.jsxs("div",{className:"actl-left",children:[e.jsx("span",{className:"actl-title",children:"Connected Tools"}),e.jsx("span",{className:"actl-meta",children:x===0?"No tools connected. Open the Tool Workspace to add tools this assistant can call during a conversation.":`${x} tool${x===1?"":"s"} connected${v.length?": "+v.slice(0,3).join(", ")+(v.length>3?"…":""):""}`}),I?e.jsxs("span",{className:"actl-warning",role:"status",children:["⚠ ",ja]}):null]}),e.jsx($,{to:"/tools/workspace",className:"actl-link",children:"Open Tool Workspace"})]})}function qa({assistant:o}){const[p,d]=c.useState([]),[g,n]=c.useState(!1);if(c.useEffect(()=>{let x=!1;return(async()=>{try{const m=await(await T.authedFetch(w.getApiUrl("/api/knowledge-base"))).json().catch(()=>({}));x||d(Array.isArray(m?.knowledgeBases)?m.knowledgeBases:[])}finally{x||n(!0)}})(),()=>{x=!0}},[o?.id]),!g)return null;const f=(o?.knowledgeBaseIds||[]).map(String),y=new Map(p.map(x=>[String(x.id),x])),C=f.map(x=>y.get(x)).filter(Boolean),k=C.map(x=>x.name).slice(0,3),v=C.length;return e.jsxs("div",{className:"assistant-connected-tools",role:"region","aria-label":"Connected knowledge",children:[e.jsxs("div",{className:"actl-left",children:[e.jsx("span",{className:"actl-title",children:"Connected Knowledge"}),e.jsx("span",{className:"actl-meta",children:v===0?"No documents connected. Open the Tool Workspace to attach a Knowledge Base.":`${v} document${v===1?"":"s"} connected${k.length?": "+k.join(", ")+(v>3?"…":""):""}`})]}),e.jsx($,{to:"/tools/workspace",className:"actl-link",children:"Open Tool Workspace"})]})}function Ka({assistant:o}){const[p,d]=c.useState([]),[g,n]=c.useState(!1),{smartAssets:f,allAccess:y,loading:C}=ca(),k=!!(f?.unlocked||y?.unlocked);if(c.useEffect(()=>{if(!o?.id||C)return;if(!k){d([]),n(!0);return}let b=!1;return(async()=>{try{const B=await(await T.authedFetch(w.getApiUrl("/api/smart-assets"))).json().catch(()=>({}));b||d(Array.isArray(B?.assets)?B.assets:[])}finally{b||n(!0)}})(),()=>{b=!0}},[o?.id,k,C]),!g)return null;const v=String(o?.id||o?._id||""),x=p.filter(b=>(b.assignedAssistantIds||[]).map(String).includes(v)),I=x.map(b=>b.name||b.originalName||"Smart Asset").slice(0,3),m=x.length,N=b=>b==="whatsapp"?"Direct WhatsApp":b==="whatsapp_link"?"WhatsApp link":"Email";return e.jsxs("div",{className:"assistant-connected-tools",role:"region","aria-label":"Assigned smart assets",children:[e.jsxs("div",{className:"actl-left",children:[e.jsx("span",{className:"actl-title",children:"Assigned Smart Assets"}),e.jsx("span",{className:"actl-meta",children:m===0?"No PDFs or documents assigned. Open Smart Assets to assign brochures, quotes, menus, or forms this assistant can send.":`${m} asset${m===1?"":"s"} assigned${I.length?": "+I.join(", ")+(m>3?"...":""):""}`}),x.length>0&&e.jsx("span",{className:"actl-meta",children:x.slice(0,2).map(b=>{const S=b.name||b.originalName||"Smart Asset",B=(b.allowedChannels||[]).map(N).join(", ")||"Email",F=b.description||b.sendInstructions||b.originalName||"Available to send during calls.";return`${S}: ${F} (${B})`}).join(" | ")})]}),e.jsx($,{to:"/smart-assets",className:"actl-link",children:"Open Smart Assets"})]})}export{fn as default};

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.