1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[13689],{13689:function(e,a,s){s.r(a),s.d(a,{default:function(){return M}});var t=s(57437),n=s(2265),l=s(79820),r=s(12381),i=s(69174),o=s(32660),c=s(82023),d=s(99397),u=s(15863),m=s(95805),h=s(86595),x=s(13041),p=s(48662),g=s(15868),f=s(18930),v=s(18949),j=s(40279),b=s(75060),y=s(23675),_=s(94589),N=s(15291),w=s(17168),k=s(92369),C=s(53417),I=s(44794),T=s(29525),Z=s(38220),S=s(42449),A=s(83229),z=s(32489),q=s(44743),R=s(22252),W=s(95661),O=s(14438);let P=[{key:"lily_female",label:"Lily â warm female"},{key:"rachel_female",label:"Rachel â professional female"},{key:"james_male",label:"James â calm male"},{key:"adam_male",label:"Adam â energetic male"}],Y=[{key:"en",label:"English"},{key:"hi",label:"Hindi"},{key:"ml",label:"Malayalam"},{key:"ta",label:"Tamil"},{key:"te",label:"Telugu"},{key:"kn",label:"Kannada"},{key:"bn",label:"Bengali"}],D=[{n:1,label:"Mon"},{n:2,label:"Tue"},{n:3,label:"Wed"},{n:4,label:"Thu"},{n:5,label:"Fri"},{n:6,label:"Sat"},{n:7,label:"Sun"}],Q=["whatsapp","email","sms","push"],V=[{key:"phone",label:"Phone calls"},{key:"whatsapp_voice",label:"WhatsApp voice"},{key:"whatsapp_text",label:"WhatsApp text"},{key:"instagram_text",label:"Instagram DM"},{key:"messenger_text",label:"Messenger"}];function B(){return{persona_name:"",description:"",is_default:!1,is_active:!0,agent_name:"AI Assistant",company_name:"",voice_provider:"elevenlabs",voice_type:"lily_female",voice_speed:1,language:"en",llm_model:"orchestrator-auto",custom_system_prompt:"",ai_instructions:"",greeting_template:"",product_context:"",qualification_questions:[],response_temperature:.5,response_style:"balanced",knowledge_collection:"",enabled_tools:[],enabled_channels:["phone","whatsapp_voice","whatsapp_text"],hot_threshold:70,warm_threshold:40,trigger_on_new_lead:!0,trigger_on_inbound_message:!0,trigger_sources:[],calling_hours_start:"09:00",calling_hours_end:"18:00",calling_days:[1,2,3,4,5],timezone:"Asia/Kolkata",max_attempts:3,retry_delay_minutes:60,notify_on_hot_lead:!0,notify_on_warm_lead:!1,notify_on_cold_lead:!1,hot_notify_channels:["whatsapp","email"],warm_notify_channels:["email"],cold_notify_channels:[],notification_recipient_type:"workspace_owner",notification_custom_phones:[],notification_custom_emails:[],cold_nurture_enabled:!1,cold_nurture_delay_days:3,cold_nurture_messages:[],cold_nurture_channel:"whatsapp",hot_lead_action:"round_robin",warm_lead_action:"round_robin",cold_lead_action:"manual_assignment",assignment_strategy:"round_robin",max_turns:8,reply_timeout_hours:24,voice_clip_max_seconds:30,escalate_on_objection:!0,handoff_keywords:["agent","human","talk to person"],fallback_to_text:!0,call_timeout_seconds:60,exclude_sources:[],rag_enabled:!0,auto_respond_enabled:!1,confidence_auto_respond:.7,confidence_suggest:.5,confidence_escalate:.3,max_chat_turns:3,require_citations:!0,escalation_keywords:[],sensitive_topics:[],use_emojis:!0,use_bold:!0,use_checkmarks:!1,use_hyperlinks:!0,max_message_length:600,sales_methodology:"consultative",close_technique:"assumptive",urgency_phrases:[],max_questions_before_recommending:3,objection_responses:[],auto_capture_lead_fields:!0}}function F(e){let{id:a,workspace_id:s,version:t,parent_persona_id:n,created_at:l,updated_at:r,...i}=e;return{...i,qualification_questions:e.qualification_questions||[],enabled_tools:e.enabled_tools||[],enabled_channels:e.enabled_channels||["phone"]}}function U(e){let{label:a,hint:s,children:n}=e;return(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(b._,{className:"text-xs font-medium",children:a}),n,s&&(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s})]})}function E(e){let{label:a,hint:s,checked:n,onChange:l}=e;return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 py-1",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm",children:a}),s&&(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s})]}),(0,t.jsx)(_.r,{checked:n,onCheckedChange:l})]})}function H(e){var a,s,o,m,h,_,H,M,K,L,X,G,J,$,ee,ea,es;let{initial:et,onSaved:en,onCancel:el}
1=e,[er,ei]=(0,n.useState)(et?F(et):B()),[eo,ec]=(0,n.useState)(!1),[ed,eu]=(0,n.useState)(""),[em,eh]=(0,n.useState)([]),[ex,ep]=(0,n.useState)(!1),[eg,ef]=(0,n.useState)(null),[ev,ej]=(0,n.useState)({name:"",description:"",price:void 0,currency:"INR",category:"",sku:""}),[eb,ey]=(0,n.useState)(!1),[e_,eN]=(0,n.useState)(""),[ew,ek]=(0,n.useState)([]),[eC,eI]=(0,n.useState)(!1),[eT,eZ]=(0,n.useState)([]),[eS,eA]=(0,n.useState)(!1);(0,n.useEffect)(()=>{v.X.knowledgeCollections().then(e=>eZ(e.collections||[])).catch(()=>eZ([]))},[]),(0,n.useEffect)(()=>{let e=er.knowledge_collection||"";e&&eT.length&&!eT.find(a=>a.value===e)&&eA(!0)},[eT,er.knowledge_collection]);let ez=async()=>{ep(!0);try{let e=await (0,W.Xp)({limit:100});eh(e)}catch(e){console.warn("Could not load products:",null==e?void 0:e.message)}finally{ep(!1)}};(0,n.useEffect)(()=>{ez()},[]);let eq=e=>{ef(e),ej({name:e.name,description:e.description,price:e.price,currency:e.currency,category:e.category,sku:e.sku}),ey(!0)},eR=async()=>{var e,a,s;if(!(null===(e=ev.name)||void 0===e?void 0:e.trim())){O.A.error("Product needs a name");return}try{eg?(await (0,W.nM)(eg.id,ev),O.A.success("Product updated")):(await (0,W.ry)(ev),O.A.success("Product added")),ey(!1),ez()}catch(e){O.A.error((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(a=s.data)||void 0===a?void 0:a.detail)||"Could not save product")}},eW=async e=>{if(confirm('Remove "'.concat(e.name,'" from the catalog?')))try{await (0,W.Ir)(e.id),eh(a=>a.filter(a=>a.id!==e.id)),O.A.success("Product removed")}catch(e){var a,s;O.A.error((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(a=s.data)||void 0===a?void 0:a.detail)||"Could not remove product")}},eO=async()=>{let e=e_.trim();if(!e||!(null==et?void 0:et.id))return;eI(!0);let a={role:"user",content:e};ek(e=>[...e,a]),eN("");try{let s=await v.X.test(et.id,e,[...ew,a]);ek(e=>[...e,{role:"assistant",content:s.response,meta:{confidence:s.confidence,sources:s.sources,ms:s.processing_time_ms,model:s.model}}])}catch(e){ek(a=>{var s,t;return[...a,{role:"assistant",content:"(error) ".concat((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(s=t.data)||void 0===s?void 0:s.detail)||(null==e?void 0:e.message)||"Test failed"),meta:{error:!0}}]})}finally{eI(!1)}};(0,n.useEffect)(()=>{ei(et?F(et):B())},[et]);let eP=(e,a)=>ei(s=>({...s,[e]:a})),eY=e=>{let a=er.enabled_channels||[];eP("enabled_channels",a.includes(e)?a.filter(a=>a!==e):[...a,e])},eD=()=>{let e=ed.trim();e&&(eP("qualification_questions",[...er.qualification_questions||[],e]),eu(""))},eQ=e=>{eP("qualification_questions",(er.qualification_questions||[]).filter((a,s)=>s!==e))},eV=async()=>{var e,a,s;if(!(null===(e=er.persona_name)||void 0===e?void 0:e.trim())){O.A.error("Give your agent a name first");return}ec(!0);try{let e=(null==et?void 0:et.id)?await v.X.update(et.id,er):await v.X.create(er);O.A.success((null==et?void 0:et.id)?"Saved":"Agent created"),en(e.persona)}catch(e){O.A.error((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(a=s.data)||void 0===a?void 0:a.detail)||"Could not save")}finally{ec(!1)}};return(0,t.jsx)(l.Zb,{className:"overflow-hidden",children:(0,t.jsxs)(w.Tabs,{defaultValue:"profile",className:"w-full",children:[(0,t.jsx)(l.Ol,{className:"pb-0 border-b",children:(0,t.jsxs)(w.TabsList,{className:"grid grid-cols-4 md:grid-cols-8 gap-1 bg-muted/50 p-1 rounded-lg w-full",children:[(0,t.jsxs)(w.TabsTrigger,{value:"profile",className:"text-xs gap-1",children:[(0,t.jsx)(k.Z,{className:"h-3.5 w-3.5"}),"Profile"]}),(0,t.jsxs)(w.TabsTrigger,{value:"call",className:"text-xs gap-1",children:[(0,t.jsx)(x.Z,{className:"h-3.5 w-3.5"}),"Calls"]}),(0,t.jsxs)(w.TabsTrigger,{value:"voice",className:"text-xs gap-1",children:[(0,t.jsx)(p.Z,{className:"h-3.5 w-3.5"}),"Voice"]}),(0,t.jsxs)(w.TabsTrigger,{value:"text",className:"text-xs gap-1",children:[(0,t.jsx)(C.Z,{className:"h-3.5 w-3.5"}),"Text"]}),(0,t.jsxs)(w.TabsTrigger,{value:"products",className:"text-xs gap-1",children:[(0,t.jsx)(I.Z,{className:"h-3.5 w-3.5"}),"Products"]}),(0,t.jsxs)(w.TabsTrigger,{value:"tools",className:"text-xs gap-1",children:[(0,t.jsx)(T.Z,{className:"h-3.5 w-3.5"}),"Tools"]}),(0,t.jsxs)(w.TabsTrigger,{value:"advanced",className:"text-xs gap-1",children:[(0,t.jsx)(c.Z,{className:"h-3.5 w-3.5"}),"Tuning"]}),(0,t.jsxs)(w.TabsTrigger,{value:"test",className:"text-xs gap-1",children:[(0,t.jsx)(Z.Z,{className:"h-3.5 w-3.5"}),"Test"]})]})}),(0,t.jsxs)(l.aY,{className:"pt-5 space-y-5",children:[(0,t.jsxs)(w.TabsContent,{value:"profile",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"Who is this agent?"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"One identity that talks to your leads on phone, voice notes and chat."})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Internal name *",hint:"Just for you â e.g. 'Acme â Warm Inbound'",children:(0,t.jsx)(j.I,{value:er.persona_name,onChange:e=>eP("persona_name",e.target.value),placeholder:"Agent name (internal)"})}),(0,t.jsx)(U,{label:"Description (optional)",hint:"A short note for your team",children:(0,t.jsx)(j.I,{value:er.description||"",onChange:e=>eP("description",e.target.value),placeholder:"What this agent is for"})}),(0,t.jsx)(U,{label:"What the agent calls itself",hint:"The name customers hear: 'Hi, I'm ___'",children:(0,t.jsx)(j.I,{value:er.agent_name||"",onChange:e=>eP("agent_name",e.target.value),placeholder:"Sara"})}),(0,t.jsx)(U,{label:"Company name",hint:"Your business name the agent will say",children:(0,t.jsx)(j.I,{value:er.company_name||"",onChange:e=>eP("company_name",e.target.value),placeholder:"Acme"})}),(0,t.jsx)(U,{label:"Voice",hint:"Used on calls and voice notes",children:(0,t.jsxs)(N.Ph,{value:er.voice_type||"",onValueChange:e=>eP("voice_type",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsx)(N.Bw,{children:P.map(e=>(0,t.jsx)(N.Ql,{value:e.key,children:e.label},e.key))})]})}),(0,t.jsx)(U,{label:"Language",hint:"The language the agent speaks",children:(0,t.jsxs)(N.Ph,{value:er.language||"en",onValueChange:e=>eP("language",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsx)(N.Bw,{children:Y.map(e=>(0,t.jsx)(N.Ql,{value:e.key,children:e.label},e.key))})]})})]}),(0,t.jsxs)("div",{className:"border-t pt-4 space-y-2",children:[(0,t.jsx)("h4",{className:"text-xs font-semibold uppercase text-muted-foreground",children:"Where this agent works"}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"Pick the channels where this agent is allowed to engage."}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 pt-1",children:V.map(e=>
1{let a=(er.enabled_channels||[]).includes(e.key);return(0,t.jsx)("button",{type:"button",onClick:()=>eY(e.key),className:"text-xs px-3 py-1.5 rounded-full transition border ".concat(a?"bg-violet-100 dark:bg-violet-900/30 text-violet-800 dark:text-violet-200 border-violet-300 dark:border-violet-700":"bg-muted/50 text-muted-foreground border-transparent hover:bg-muted"),children:e.label},e.key)})})]}),(0,t.jsxs)("div",{className:"border-t pt-4 flex items-center gap-6 flex-wrap",children:[(0,t.jsx)(E,{label:"Make this the default agent",hint:"Used when no specific agent is chosen",checked:!!er.is_default,onChange:e=>eP("is_default",e)}),(0,t.jsx)(E,{label:"Active",hint:"Turn off to pause this agent without deleting it",checked:!1!==er.is_active,onChange:e=>eP("is_active",e)})]})]}),(0,t.jsxs)(w.TabsContent,{value:"call",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"When and how the agent calls leads"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Calling window, retry policy, and what to do after a call ends."})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"When to call"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(E,{label:"Call new leads automatically",hint:"Triggers when a lead is captured",checked:!!er.trigger_on_new_lead,onChange:e=>eP("trigger_on_new_lead",e)}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3 pt-2",children:[(0,t.jsx)(U,{label:"Start time",children:(0,t.jsx)(j.I,{type:"time",value:er.calling_hours_start||"09:00",onChange:e=>eP("calling_hours_start",e.target.value)})}),(0,t.jsx)(U,{label:"End time",children:(0,t.jsx)(j.I,{type:"time",value:er.calling_hours_end||"18:00",onChange:e=>eP("calling_hours_end",e.target.value)})}),(0,t.jsx)(U,{label:"Timezone",children:(0,t.jsx)(j.I,{value:er.timezone||"Asia/Kolkata",onChange:e=>eP("timezone",e.target.value)})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(b._,{className:"text-xs",children:"Days of the week"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1",children:D.map(e=>{let a=(er.calling_days||[]).includes(e.n);return(0,t.jsx)("button",{type:"button",onClick:()=>{let s=er.calling_days||[];eP("calling_days",a?s.filter(a=>a!==e.n):[...s,e.n].sort())},className:"text-xs px-3 py-1.5 rounded-full border ".concat(a?"bg-violet-100 dark:bg-violet-900/30 text-violet-800 dark:text-violet-200 border-violet-300":"bg-muted/50 text-muted-foreground border-transparent hover:bg-muted"),children:e.label},e.n)})})]})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"If the call doesn't connect"})}),(0,t.jsxs)(l.aY,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,t.jsx)(U,{label:"Try this many times",hint:"How many call attempts per lead",children:(0,t.jsx)(j.I,{type:"number",min:"1",max:"10",value:er.max_attempts||3,onChange:e=>eP("max_attempts",parseInt(e.target.value)||3)})}),(0,t.jsx)(U,{label:"Wait between tries (min)",children:(0,t.jsx)(j.I,{type:"number",min:"5",max:"1440",value:er.retry_delay_minutes||60,onChange:e=>eP("retry_delay_minutes",parseInt(e.target.value)||60)})}),(0,t.jsx)(U,{label:"Ring for (seconds)",hint:"How long to wait before giving up on a call",children:(0,t.jsx)(j.I,{type:"number",min:"15",max:"120",value:null!==(o=er.call_timeout_seconds)&&void 0!==o?o:60,onChange:e=>eP("call_timeout_seconds",parseInt(e.target.value)||60)})})]}),(0,t.jsx)("div",{className:"mt-3",children:(0,t.jsx)(U,{label:"Don't call leads from these sources (comma-separated)",hint:"e.g. instagram, manual_import â leave blank to call all sources",children:(0,t.jsx)(j.I,{value:(er.exclude_sources||[]).join(", "),onChange:e=>eP("exclude_sources",e.target.value.split(",").map(e=>e.trim()).filter(Boolean)),placeholder:"instagram, manual_import"})})})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"After the call â sort the lead"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"The agent gives the lead a score 0â100. Above the hot line = hot lead, between = warm, below = cold."}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Hot if score is at least",children:(0,t.jsx)(j.I,{type:"number",min:"0",max:"100",value:null!==(m=er.hot_threshold)&&void 0!==m?m:70,onChange:e=>eP("hot_threshold",parseInt(e.target.value)||70)})}),(0,t.jsx)(U,{label:"Warm if score is at least",children:(0,t.jsx)(j.I,{type:"number",min:"0",max:"100",value:null!==(h=er.warm_threshold)&&void 0!==h?h:4
10,onChange:e=>eP("warm_threshold",parseInt(e.target.value)||40)})})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{tier:"hot",key:"hot_lead_action",label:"\uD83D\uDD25 Hot lead"},{tier:"warm",key:"warm_lead_action",label:"\uD83C\uDF24 Warm lead"},{tier:"cold",key:"cold_lead_action",label:"\uD83E\uDDCA Cold lead"}].map(e=>{let{tier:a,key:s,label:n}=e;return(0,t.jsx)(U,{label:n,children:(0,t.jsxs)(N.Ph,{value:er[s]||"manual_assignment",onValueChange:e=>eP(s,e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"round_robin",children:"Assign round-robin"}),(0,t.jsx)(N.Ql,{value:"least_loaded",children:"Give to least busy agent"}),(0,t.jsx)(N.Ql,{value:"schedule_followup",children:"Schedule a follow-up"}),(0,t.jsx)(N.Ql,{value:"manual_assignment",children:"Leave for manual"})]})]})},a)})})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Notify your team"})}),(0,t.jsx)(l.aY,{className:"space-y-3",children:["hot","warm","cold"].map(e=>{let a="notify_on_".concat(e,"_lead"),s="".concat(e,"_notify_channels"),n=!!er[a],l=er[s]||[];return(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)(E,{label:"Notify when a ".concat(e," lead is found"),checked:n,onChange:e=>eP(a,e)}),n&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 pl-1",children:Q.map(e=>{let a=l.includes(e);return(0,t.jsx)("button",{type:"button",onClick:()=>eP(s,a?l.filter(a=>a!==e):[...l,e]),className:"text-[11px] px-2 py-0.5 rounded-full border ".concat(a?"bg-emerald-100 dark:bg-emerald-900/30 text-emerald-800 dark:text-emerald-200 border-emerald-300":"bg-muted/50 text-muted-foreground border-transparent hover:bg-muted"),children:e},e)})})]},e)})})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Don't drop cold leads â keep them warm"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(E,{label:"Send follow-up messages to cold leads",hint:"Automatic drip campaign to revive cold leads",checked:!!er.cold_nurture_enabled,onChange:e=>eP("cold_nurture_enabled",e)}),er.cold_nurture_enabled&&(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Wait this many days before first message",children:(0,t.jsx)(j.I,{type:"number",min:"0",max:"60",value:null!==(_=er.cold_nurture_delay_days)&&void 0!==_?_:3,onChange:e=>eP("cold_nurture_delay_days",parseInt(e.target.value)||3)})}),(0,t.jsx)(U,{label:"Send through",children:(0,t.jsxs)(N.Ph,{value:er.cold_nurture_channel||"whatsapp",onValueChange:e=>eP("cold_nurture_channel",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"whatsapp",children:"WhatsApp"}),(0,t.jsx)(N.Ql,{value:"email",children:"Email"}),(0,t.jsx)(N.Ql,{value:"sms",children:"SMS"})]})]})})]})]})]})]}),(0,t.jsxs)(w.TabsContent,{value:"voice",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"Voice notes on WhatsApp & Instagram"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Settings for the recorded voice messages your agent sends back to leads."})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Voice limits"})}),(0,t.jsx)(l.aY,{children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,t.jsx)(U,{label:"How long can each clip be? (sec)",hint:"Max length of each voice note",children:(0,t.jsx)(j.I,{type:"number",min:"5",max:"120",value:null!==(H=er.voice_clip_max_seconds)&&void 0!==H?H:30,onChange:e=>eP("voice_clip_max_seconds",parseInt(e.target.value)||30)})}),(0,t.jsx)(U,{label:"Max back-and-forth turns",hint:"Stop after this many exchanges",children:(0,t.jsx)(j.I,{type:"number",min:"1",max:"30",value:null!==(M=er.max_turns)&&void 0!==M?M:8,onChange:e=>eP("max_turns",parseInt(e.target.value)||8)})}),(0,t.jsx)(U,{label:"Wait for reply (hours)",hint:"If lead doesn't reply in this time, end the conversation",children:(0,t.jsx)(j.I,{type:"number",min:"1",max:"168",value:null!==(K=er.reply_timeout_hours)&&void 0!==K?K:24,onChange:e=>eP("reply_timeout_hours",parseInt(e.target.value)||24)})})]})})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"When to hand off to a human"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(E,{label:"Hand off if lead pushes back",hint:"Pass to a human agent when an objection is detected",checked:!!er.escalate_on_objection,onChange:e=>eP("escalate_on_objection",e)}),(0,t.jsx)(E,{label:"Send text if voice fails",hint:"Fall back to a text reply if voice generation breaks",checked:!!er.fallback_to_text,onChange:e=>eP("fallback_to_text",e)}),(0,t.jsx)(U,{label:"Words that trigger handoff",hint:"Comma-separated. If the lead says any of these, the agent hands off to a human.",children:(0,t.jsx)(j.I,{value:(er.handoff_keywords||[]).join(", "),onChange:e=>eP("handoff_keywords",e.target.value.split(",").map(e=>
1e.trim()).filter(Boolean)),placeholder:"agent, human, talk to person"})})]})]})]}),(0,t.jsxs)(w.TabsContent,{value:"text",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"How the agent answers in chat"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Knowledge base, tone, and reply behavior for text channels (WhatsApp, Instagram, Messenger)."})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Knowledge"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"When the lead asks something off-script (about your product, pricing, process), the agent answers from this knowledge collection â on phone, voice notes AND text chat."}),(0,t.jsx)(E,{label:"Use the knowledge base",hint:"Turn off to make the agent rely only on its prompt",checked:!!er.rag_enabled,onChange:e=>eP("rag_enabled",e)}),er.rag_enabled&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{label:"Knowledge collection",hint:eS?"Type a collection name. Will be used even if it has no docs yet.":'Pick from collections that exist in your workspace, or choose "Otherâ¦" to type one.',children:eS?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(j.I,{value:er.knowledge_collection||"",onChange:e=>eP("knowledge_collection",e.target.value),placeholder:"my_custom_kb"}),(0,t.jsx)(r.z,{type:"button",size:"sm",variant:"ghost",onClick:()=>{eA(!1),eP("knowledge_collection","")},className:"text-xs",children:"Pick from list"})]}):(0,t.jsxs)(N.Ph,{value:er.knowledge_collection||"__none__",onValueChange:e=>{"__custom__"===e?(eA(!0),eP("knowledge_collection","")):"__none__"===e?eP("knowledge_collection",""):eP("knowledge_collection",e)},children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{placeholder:"Pick a collection"})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"__none__",children:(0,t.jsx)("span",{className:"text-muted-foreground",children:"â No knowledge base â"})}),eT.map(e=>(0,t.jsx)(N.Ql,{value:e.value,children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[e.value,(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground",children:e.doc_count>0?"".concat(e.doc_count," docs"):"empty"})]})},e.value)),(0,t.jsx)(N.Ql,{value:"__custom__",children:(0,t.jsx)("span",{className:"text-violet-600",children:"Other⦠(type a custom name)"})})]})]})}),(0,t.jsx)(E,{label:"Always cite sources",hint:"Forces the agent to reference where the answer came from",checked:!!er.require_citations,onChange:e=>eP("require_citations",e)})]})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"When to auto-reply vs. ask a human"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(E,{label:"Reply automatically",hint:"When confidence is high enough, the agent answers without waiting for a human",checked:!!er.auto_respond_enabled,onChange:e=>eP("auto_respond_enabled",e)}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"The agent rates its own confidence (0â1) for every reply. Use these to decide what to do."}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[(0,t.jsx)(U,{label:"Auto-reply if confidence â¥",hint:"High confidence â send the reply",children:(0,t.jsx)(j.I,{type:"number",step:"0.05",min:"0",max:"1",value:null!==(L=er.confidence_auto_respond)&&void 0!==L?L:.7,onChange:e=>eP("confidence_auto_respond",parseFloat(e.target.value)||.7)})}),(0,t.jsx)(U,{label:"Suggest reply if â¥",hint:"Medium â show as suggestion to the human",children:(0,t.jsx)(j.I,{type:"number",step:"0.05",min:"0",max:"1",value:null!==(X=er.confidence_suggest)&&void 0!==X?X:.5,onChange:e=>eP("confidence_suggest",parseFloat(e.target.value)||.5)})}),(0,t.jsx)(U,{label:"Escalate if â¥",hint:"Low â ping a human to take over",children:(0,t.jsx)(j.I,{type:"number",step:"0.05",min:"0",max:"1",value:null!==(G=er.confidence_escalate)&&void 0!==G?G:.3,onChange:e=>eP("confidence_escalate",parseFloat(e.target.value)||.3)})})]}),(0,t.jsx)(U,{label:"Max chat turns before stopping",hint:"How many AI replies in one chat thread before pausing",children:(0,t.jsx)(j.I,{type:"number",min:"1",max:"20",value:null!==(J=er.max_chat_turns)&&void 0!==J?J:3,onCh
1ange:e=>eP("max_chat_turns",parseInt(e.target.value)||3)})})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Reply tone"})}),(0,t.jsx)(l.aY,{children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Style",hint:"How the agent words replies",children:(0,t.jsxs)(N.Ph,{value:er.response_style||"balanced",onValueChange:e=>eP("response_style",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"concise",children:"Concise â short and to the point"}),(0,t.jsx)(N.Ql,{value:"balanced",children:"Balanced â friendly and clear"}),(0,t.jsx)(N.Ql,{value:"detailed",children:"Detailed â thorough explanations"})]})]})}),(0,t.jsx)(U,{label:"Creativity: ".concat(null===(a=er.response_temperature)||void 0===a?void 0:a.toFixed(2)),hint:"0 = always the same wording. 1 = more varied.",children:(0,t.jsx)(j.I,{type:"number",step:"0.1",min:"0",max:"1",value:null!==($=er.response_temperature)&&void 0!==$?$:.5,onChange:e=>eP("response_temperature",parseFloat(e.target.value)||.5)})})]})})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Message formatting"})}),(0,t.jsxs)(l.aY,{className:"space-y-2",children:[(0,t.jsx)(E,{label:"Use emojis",hint:"Add emojis to text replies",checked:!!er.use_emojis,onChange:e=>eP("use_emojis",e)}),(0,t.jsx)(E,{label:"Use bold text",hint:"Highlight key phrases with **bold**",checked:!!er.use_bold,onChange:e=>eP("use_bold",e)}),(0,t.jsx)(E,{label:"Use checkmark bullets",hint:"Format lists with â checkmarks",checked:!!er.use_checkmarks,onChange:e=>eP("use_checkmarks",e)}),(0,t.jsx)(E,{label:"Auto-link URLs",hint:"Make web addresses clickable",checked:!!er.use_hyperlinks,onChange:e=>eP("use_hyperlinks",e)}),(0,t.jsx)(U,{label:"Max characters per message",hint:"Cap reply length to keep messages digestible",children:(0,t.jsx)(j.I,{type:"number",min:"100",max:"2000",value:null!==(ee=er.max_message_length)&&void 0!==ee?ee:600,onChange:e=>eP("max_message_length",parseInt(e.target.value)||600)})})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Guardrails"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(U,{label:"Words that hand off to a human (comma-separated)",hint:"If the lead types any of these, the agent passes the chat to a human",children:(0,t.jsx)(j.I,{value:(er.escalation_keywords||[]).join(", "),onChange:e=>eP("escalation_keywords",e.target.value.split(",").map(e=>e.trim()).filter(Boolean)),placeholder:"refund, complaint, cancel, manager"})}),(0,t.jsx)(U,{label:"Topics the agent should never discuss (comma-separated)",hint:"The agent will politely decline if these come up",children:(0,t.jsx)(j.I,{value:(er.sensitive_topics||[]).join(", "),onChange:e=>eP("sensitive_topics",e.target.value.split(",").map(e=>e.trim()).filter(Boolean)),placeholder:"medical advice, legal advice, competitor pricing"})})]})]})]}),(0,t.jsxs)(w.TabsContent,{value:"products",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"What does this agent talk about?"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"The product / service the agent represents, and the questions it should ask leads."})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide flex items-center gap-1.5",children:[(0,t.jsx)(S.Z,{className:"h-3.5 w-3.5"}),"Product catalog"]}),(0,t.jsx)(l.SZ,{className:"text-[11px]",children:"Items the agent can recommend by name. Same catalog used by chat replies."})]}),(0,t.jsxs)(r.z,{size:"sm",variant:"outline",onClick:()=>{ef(null),ej({name:"",description:"",price:void 0,currency:"INR",category:"",sku:""}),ey(!0)},className:"gap-1",children:[(0,t.jsx)(d.Z,{className:"h-3.5 w-3.5"}),"Add product"]})]})}),(0,t.jsxs)(l.aY,{className:"space-y-2",children:[eb&&(0,t.jsxs)("div",{className:"rounded-md border bg-background p-3 space-y-2",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:[(0,t.jsx)(U,{label:"Name *",children:(0,t.jsx)(j.I,{value:ev.name,onChange:e=>ej(a=>({...a,name:e.target.value})),placeholder:"Yoga Retreat â 5 days"})}),(0,t.jsx)(U,{label:"Category",children:(0,t.jsx)(j.I,{value:ev.category||"",onChange:e=>ej(a=>({...a,category:e.target.value})),placeholder:"Retreats / Courses / Subscriptions"})}),(0,t.jsx)(U,{label:"Price",children:(0,t.jsx)(j.I,{type:"number",value:null!==(ea=ev.price)&&void 0!==ea?ea:"",onCh
1ange:e=>ej(a=>({...a,price:e.target.value?parseFloat(e.target.value):void 0})),placeholder:"15000"})}),(0,t.jsx)(U,{label:"Currency",children:(0,t.jsxs)(N.Ph,{value:ev.currency||"INR",onValueChange:e=>ej(a=>({...a,currency:e})),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"INR",children:"INR â â¹"}),(0,t.jsx)(N.Ql,{value:"USD",children:"USD â $"}),(0,t.jsx)(N.Ql,{value:"EUR",children:"EUR â â¬"}),(0,t.jsx)(N.Ql,{value:"GBP",children:"GBP â \xa3"})]})]})}),(0,t.jsx)(U,{label:"SKU",children:(0,t.jsx)(j.I,{value:ev.sku||"",onChange:e=>ej(a=>({...a,sku:e.target.value})),placeholder:"SKU-001"})})]}),(0,t.jsx)(U,{label:"Short description",children:(0,t.jsx)(y.g,{rows:2,value:ev.description||"",onChange:e=>ej(a=>({...a,description:e.target.value})),placeholder:"What is it? Used by the agent when recommending."})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-end pt-1",children:[(0,t.jsx)(r.z,{size:"sm",variant:"ghost",onClick:()=>ey(!1),children:"Cancel"}),(0,t.jsxs)(r.z,{size:"sm",onClick:eR,className:"gap-1",children:[(0,t.jsx)(A.Z,{className:"h-3.5 w-3.5"}),eg?"Save changes":"Add product"]})]})]}),ex?(0,t.jsxs)("div",{className:"text-xs text-muted-foreground flex items-center gap-2 py-3",children:[(0,t.jsx)(u.Z,{className:"h-3.5 w-3.5 animate-spin"})," Loadingâ¦"]}):0===em.length?(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground italic py-2",children:"No products in your catalog yet. Add the items the agent should recommend by name."}):(0,t.jsx)("div",{className:"space-y-1.5",children:em.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 px-3 py-2 rounded-md border bg-background hover:bg-muted/30 transition",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsxs)("div",{className:"text-[11px] text-muted-foreground flex items-center gap-2 flex-wrap",children:[null!=e.price&&(0,t.jsxs)("span",{children:[e.currency," ",e.price.toLocaleString()]}),e.category&&(0,t.jsxs)("span",{children:["\xb7 ",e.category]}),e.sku&&(0,t.jsxs)("span",{children:["\xb7 SKU ",e.sku]}),e.status&&"active"!==e.status&&(0,t.jsx)(i.C,{variant:"outline",className:"text-[10px] py-0 h-4",children:e.status})]}),e.description&&(0,t.jsx)("div",{className:"text-[11px] text-muted-foreground line-clamp-1 mt-0.5",children:e.description})]}),(0,t.jsx)(r.z,{size:"sm",variant:"ghost",onClick:()=>eq(e),className:"h-8 w-8 p-0",children:(0,t.jsx)(g.Z,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(r.z,{size:"sm",variant:"ghost",onClick:()=>eW(e),className:"h-8 w-8 p-0 text-rose-600 hover:text-rose-700",children:(0,t.jsx)(f.Z,{className:"h-3.5 w-3.5"})})]},e.id))})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Greeting"})}),(0,t.jsx)(l.aY,{children:(0,t.jsx)(U,{label:"First line spoken on a call",hint:"Variables: {{lead_name}}, {{agent_name}}, {{company_name}}",children:(0,t.jsx)(y.g,{rows:2,value:er.greeting_template||"",onChange:e=>eP("greeting_template",e.target.value),placeholder:"Hi {{lead_name}}, this is {{agent_name}} from {{company_name}}â¦"})})})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"About your product"})}),(0,t.jsx)(l.aY,{children:(0,t.jsx)(U,{label:"What you sell â used as background, NOT a script",hint:"The agent only mentions these details if the lead asks. Don't paste your full sales pitch here.",children:(0,t.jsx)(y.g,{rows:4,value:er.product_context||"",onChange:e=>eP("product_context",e.target.value),placeholder:"We sell premium yoga retreats in Kerala for working professionals. Price range â¹15,000â25,000â¦"})})})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsxs)(l.Ol,{className:"pb-2",children:[(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Questions to ask the lead"}),(0,t.jsx)(l.SZ,{className:"text-[11px]",children:"The agent asks one question at a time, in order. Used to qualify and score the lead."})]}),(0,t.jsxs)(l.aY,{className:"space-y-2",children:[(er.qualification_questions||[]).map((e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-xs text-muted-foreground w-5",children:[a+1,"."]}
1),(0,t.jsx)(j.I,{value:String(e),readOnly:!0,className:"text-sm"}),(0,t.jsx)(r.z,{size:"sm",variant:"ghost",onClick:()=>eQ(a),className:"h-9 w-9 p-0",children:(0,t.jsx)(z.Z,{className:"h-4 w-4"})})]},a)),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-1",children:[(0,t.jsx)(j.I,{value:ed,onChange:e=>eu(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),eD())},placeholder:"Type a question and press Enterâ¦"}),(0,t.jsxs)(r.z,{size:"sm",variant:"outline",onClick:eD,className:"gap-1",children:[(0,t.jsx)(d.Z,{className:"h-3.5 w-3.5"}),"Add"]})]}),0===(er.qualification_questions||[]).length&&(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground italic",children:'No questions yet â the agent will use defaults: "What\'s your goal?" / "Where are you based?" / "When can you start?"'})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"How the agent sells"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Sales style",hint:"The agent's overall sales personality",children:(0,t.jsxs)(N.Ph,{value:er.sales_methodology||"consultative",onValueChange:e=>eP("sales_methodology",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"consultative",children:"Consultative â listen first, advise"}),(0,t.jsx)(N.Ql,{value:"solution",children:"Solution â match problems to features"}),(0,t.jsx)(N.Ql,{value:"aggressive",children:"Aggressive â push for the close"}),(0,t.jsx)(N.Ql,{value:"soft_sell",children:"Soft sell â gentle, no pressure"})]})]})}),(0,t.jsx)(U,{label:"How it closes",hint:"Closing technique",children:(0,t.jsxs)(N.Ph,{value:er.close_technique||"assumptive",onValueChange:e=>eP("close_technique",e),children:[(0,t.jsx)(N.i4,{children:(0,t.jsx)(N.ki,{})}),(0,t.jsxs)(N.Bw,{children:[(0,t.jsx)(N.Ql,{value:"assumptive",children:"Assumptive â assume the sale ('when do we start?')"}),(0,t.jsx)(N.Ql,{value:"summary",children:"Summary â recap benefits, then ask"}),(0,t.jsx)(N.Ql,{value:"take_away",children:"Take-away â scarcity-driven"}),(0,t.jsx)(N.Ql,{value:"question",children:"Question â let the lead self-close"})]})]})})]}),(0,t.jsx)(U,{label:"Discovery questions before recommending",hint:"The agent asks at least this many qualifying questions before pitching",children:(0,t.jsx)(j.I,{type:"number",min:"0",max:"10",value:null!==(es=er.max_questions_before_recommending)&&void 0!==es?es:3,onChange:e=>eP("max_questions_before_recommending",parseInt(e.target.value)||3)})}),(0,t.jsx)(U,{label:"Urgency phrases (comma-separated)",hint:"Optional phrases the agent can sprinkle in: 'limited slots', 'offer ends Friday'â¦",children:(0,t.jsx)(j.I,{value:(er.urgency_phrases||[]).join(", "),onChange:e=>eP("urgency_phrases",e.target.value.split(",").map(e=>e.trim()).filter(Boolean)),placeholder:"only 5 slots left, this week only"})}),(0,t.jsx)(E,{label:"Auto-capture lead details from messages",hint:"Pull name / email / phone / company out of what the lead types",checked:!!er.auto_capture_lead_fields,onChange:e=>eP("auto_capture_lead_fields",e)})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsxs)(l.Ol,{className:"pb-2",children:[(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Common objections + how to respond"}),(0,t.jsx)(l.SZ,{className:"text-[11px]",children:"Pre-written responses for objections you hear all the time. The agent uses these instead of improvising."})]}),(0,t.jsxs)(l.aY,{className:"space-y-2",children:[(er.objection_responses||[]).map((e,a)=>(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_2fr_auto] gap-2 items-center",children:[(0,t.jsx)(j.I,{value:e.objection||"",onChange:e=>{let s=[...er.objection_responses||[]];s[a]={...s[a],objection:e.target.value},eP("objection_responses",s)},placeholder:"Objection (e.g. 'too expensive')"}),(0,t.jsx)(j.I,{value:e.response||"",onChange:e=>{let s=[...er.objection_responses||[]];s[a]={...s[a],response:e.target.value},eP("objection_responses",s)},placeholder:"What the agent should say back"}),(0,t.jsx)(r.z,{size:"sm",variant:"ghost",onClick:()=>eP("objection_responses",(er.objection_responses||[]).filter((e,s)=>s!==a)),className:"h-9 w-9 p-0",children:(0,t.jsx)(z.Z,{className:"h-4 w-4"})})]},a)),(0,t.jsxs)(r.z,{size:"sm",variant:"outline",onClick:()=>eP("objection_responses",[...er.objection_responses||[],{objection:"",response:""}]),className:"gap-1",children:[(0,t.jsx)(d.Z,{className:"h-3.5 w-3.5"}),"Add objection"]})]})]})]}),(0,t.jsxs)(w.TabsContent,{value:"tools",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"What can this agent DO during a conversation?"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Actions the agent can take â book meetings, check inventory, raise tickets â without handing off."})]}),(0,t.jsx)(l.Zb,{className:"border-dashed bg-muted/10",children:(0,t.jsxs)(l.aY,{className:"py-8 text-center space-y-2",children:[(0,t.jsx)(T.Z,{className:"h-8 w-8 mx-auto text-muted-foreground
1/50"}),(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Tool calling â coming soon"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground max-w-md mx-auto",children:"Tools you enable here will be saved on the agent. The runtime that lets the agent actually call them on a live call ships in the next release."}),(0,t.jsx)(i.C,{variant:"outline",className:"text-[10px]",children:"In development"})]})}),(er.enabled_tools||[]).length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:(er.enabled_tools||[]).map((e,a)=>(0,t.jsxs)(i.C,{variant:"secondary",className:"gap-1 text-xs",children:[e,(0,t.jsx)(z.Z,{className:"h-3 w-3 cursor-pointer",onClick:()=>eP("enabled_tools",(er.enabled_tools||[]).filter((e,s)=>s!==a))})]},a))})]}),(0,t.jsxs)(w.TabsContent,{value:"advanced",className:"space-y-5 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold mb-1",children:["Fine-tuning ",(0,t.jsx)(i.C,{variant:"outline",className:"text-[10px] ml-1",children:"advanced"})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Power-user settings. Most users don't need to touch these."})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Custom instructions"})}),(0,t.jsxs)(l.aY,{className:"space-y-3",children:[(0,t.jsx)(U,{label:"Extra rules for the agent",hint:"Specific dos and don'ts. Added to every conversation.",children:(0,t.jsx)(y.g,{rows:3,value:er.ai_instructions||"",onChange:e=>eP("ai_instructions",e.target.value),placeholder:"Always ask for budget before pitching pricing. Never promise refunds."})}),(0,t.jsx)(U,{label:"Replace the entire agent prompt",hint:"Leave blank to use the default sales-agent prompt. Only fill if you know what you're doing.",children:(0,t.jsx)(y.g,{rows:4,value:er.custom_system_prompt||"",onChange:e=>eP("custom_system_prompt",e.target.value),placeholder:"(Advanced) Full system prompt that overrides defaults"})})]})]}),(0,t.jsxs)(l.Zb,{className:"bg-muted/20",children:[(0,t.jsx)(l.Ol,{className:"pb-2",children:(0,t.jsx)(l.ll,{className:"text-xs uppercase text-muted-foreground tracking-wide",children:"Voice timing"})}),(0,t.jsx)(l.aY,{children:(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[(0,t.jsx)(U,{label:"Speaking rate (".concat(null===(s=er.voice_speed)||void 0===s?void 0:s.toFixed(2),")"),hint:"0.5 = slow, 1.0 = normal, 2.0 = fast",children:(0,t.jsx)(j.I,{type:"number",step:"0.1",min:"0.5",max:"2.0",value:er.voice_speed||1,onChange:e=>eP("voice_speed",parseFloat(e.target.value)||1)})}),(0,t.jsx)(U,{label:"Voice style descriptor",hint:"Hint the TTS engine uses for tone â friendly / professional / energetic",children:(0,t.jsx)(j.I,{value:er.voice_style||"",onChange:e=>eP("voice_style",e.target.value),placeholder:"friendly"})})]})})]})]}),(0,t.jsxs)(w.TabsContent,{value:"test",className:"space-y-4 mt-0",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold mb-1",children:"Try the agent before going live"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mb-3",children:"Type a message as if you were a lead. The agent replies using its real prompt, knowledge collection and LLM model â same code paths as a live chat."})]}),(null==et?void 0:et.id)?(0,t.jsx)(l.Zb,{className:"bg-background border",children:(0,t.jsx)(l.aY,{className:"p-0",children:(0,t.jsxs)("div",{className:"flex flex-col h-[480px]",children:[(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 bg-muted/10",children:[0===ew.length&&(0,t.jsxs)("div",{className:"text-center text-xs text-muted-foreground py-12",children:[(0,t.jsx)(Z.Z,{className:"h-6 w-6 mx-auto mb-2 opacity-40"}),"Start the conversation to see how the agent responds."]}),ew.map((e,a)=>{var s,n,l,r;return(0,t.jsx)("div",{className:"flex ".concat("user"===e.role?"justify-end":"justify-start"),children:(0,t.jsxs)("div",{className:"max-w-[80%] rounded-2xl px-3 py-2 text-sm whitespace-pre-wrap ".concat("user"===e.role?"bg-violet-600 text-white":(null===(s=e.meta)||void 0===s?void 0:s.error)?"bg-rose-100 dar
1k:bg-rose-900/30 text-rose-900 dark:text-rose-200 border border-rose-300":"bg-card border"),children:[e.content,"assistant"===e.role&&e.meta&&!e.meta.error&&(0,t.jsxs)("div",{className:"text-[10px] opacity-70 mt-1.5 flex items-center gap-2 flex-wrap",children:[e.meta.model&&(0,t.jsx)("span",{children:e.meta.model}),"number"==typeof e.meta.confidence&&(0,t.jsxs)("span",{children:["\xb7 conf ",(100*e.meta.confidence).toFixed(0),"%"]}),null!=e.meta.ms&&(0,t.jsxs)("span",{children:["\xb7 ",e.meta.ms," ms"]}),(null===(n=e.meta.sources)||void 0===n?void 0:n.length)>0&&(0,t.jsxs)("span",{children:["\xb7 ",e.meta.sources.length," KB source",e.meta.sources.length>1?"s":""]})]}),"assistant"===e.role&&(null===(r=e.meta)||void 0===r?void 0:null===(l=r.sources)||void 0===l?void 0:l.length)>0&&(0,t.jsxs)("details",{className:"mt-2",children:[(0,t.jsx)("summary",{className:"text-[10px] opacity-70 cursor-pointer",children:"Show sources"}),(0,t.jsx)("ul",{className:"mt-1 space-y-1",children:e.meta.sources.map((e,a)=>{var s;return(0,t.jsx)("li",{className:"text-[10px] opacity-80 border-l-2 border-violet-400/50 pl-2",children:null===(s=e.content)||void 0===s?void 0:s.slice(0,200)},a)})})]})]})},a)}),eC&&(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"bg-card border rounded-2xl px-3 py-2 text-sm flex items-center gap-2",children:[(0,t.jsx)(u.Z,{className:"h-3.5 w-3.5 animate-spin"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"Thinkingâ¦"})]})})]}),(0,t.jsxs)("div",{className:"border-t bg-background p-3 flex items-center gap-2",children:[(0,t.jsx)(j.I,{value:e_,onChange:e=>eN(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),eO())},placeholder:"Ask something the lead might askâ¦",disabled:eC}),(0,t.jsxs)(r.z,{onClick:eO,disabled:eC||!e_.trim(),className:"gap-1",children:[(0,t.jsx)(q.Z,{className:"h-3.5 w-3.5"}),"Send"]}),ew.length>0&&(0,t.jsx)(r.z,{variant:"ghost",size:"sm",onClick:()=>ek([]),className:"text-xs",children:"Clear"})]})]})})}):(0,t.jsx)(l.Zb,{className:"border-dashed bg-muted/10",children:(0,t.jsxs)(l.aY,{className:"py-8 text-center space-y-2",children:[(0,t.jsx)(Z.Z,{className:"h-8 w-8 mx-auto text-muted-foreground/50"}),(0,t.jsx)("h4",{className:"text-sm font-medium",children:"Save the agent first"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground max-w-md mx-auto",children:'Hit "Create agent" at the bottom â once saved, you can test it here.'})]})}),(0,t.jsxs)("p",{className:"text-[11px] text-muted-foreground flex items-start gap-1.5",children:[(0,t.jsx)(R.Z,{className:"h-3 w-3 mt-0.5 shrink-0"}),(0,t.jsxs)("span",{children:["Test responses use the agent's saved settings. If you change something above, hit ",(0,t.jsx)("strong",{children:"Save changes"})," first, then re-run the test."]})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-6 py-3 border-t bg-background/95 backdrop-blur sticky bottom-0",children:[el&&(0,t.jsx)(r.z,{variant:"outline",onClick:el,disabled:eo,children:"Cancel"}),(0,t.jsxs)(r.z,{onClick:eV,disabled:eo,className:"gap-1",children:[eo?(0,t.jsx)(u.Z,{className:"h-4 w-4 animate-spin"}):(0,t.jsx)(A.Z,{className:"h-4 w-4"}),(null==et?void 0:et.id)?"Save changes":"Create agent"]})]})]})})}function M(){let[e,a]=(0,n.useState)([]),[s,j]=(0,n.useState)(!0),[b,y]=(0,n.useState)(null),_=(0,n.useCallback)(async()=>{j(!0);try{let e=await v.X.list({include_inactive:!1});a(e.personas)}catch(a){var e,s;O.A.error((null==a?void 0:null===(s=a.response)||void 0===s?void 0:null===(e=s.data)||void 0===e?void 0:e.detail)||"Failed to load personas")}finally{j(!1)}},[]);(0,n.useEffect)(()=>{_()},[_]);let N=async e=>{if(confirm('Archive "'.concat(e.persona_name,'"? It can be restored later via the API.')))try{await v.X.remove(e.id),O.A.success("Persona archived"),_()}catch(e){var a,s;O.A.error((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(a=s.data)||void 0===a?void 0:a.detail)||"Failed to archive persona")}};return b?(0,t.jsxs)("div",{className:"container mx-auto p-4 md:p-6 max-w-4xl",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-4",children:(0,t.jsxs)(r.z,{variant:"ghost",size:"sm",onClick:()=>y(null),className:"gap-1",children:[(0,t.jsx)(o.Z,{className:"h-4 w-4"}),"Back to personas"]})}),(0,t.jsxs)("h1",{className:"text-2xl font-semibold mb-1 flex items-center gap-2",children:[(0,t.jsx)(c.Z,{className:"h-6 w-6 text-violet-500"}),"new"===b?"New persona":b.persona_name]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-6",children:"One identity shared across phone, voice notes and text chat."}),(0,t.jsx)(H,{initial:"new"===b?null:b,onSaved:e=>{y(null),_()},onCancel:()=>y(null)})]}):(0,t.jsxs)("div",{className:"container mx-auto p-4 md:p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-2xl font-semibold flex items-center gap-2",children:[(0,t.jsx)(c.Z,{className:"h-6 w-6 text-violet-500"}),"Agent Studio"]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"One persona = one AI agent identity. Phone calls, voice notes and text chat share the same voice, brain and knowledge."})]}),(0,t.jsxs)(r.z,{onClick:()=>y("new"),className:"gap-1.5",children:[(0,t.jsx)(d.Z,{className:"h-4 w-4"}),"New persona"]})]}),s?(0,t.jsxs)("div",{className:"flex items-center justify-center py-20 text-muted-foreground",children:[(0,t.jsx)(u.Z,{className:"h-5 w-5 animate-spin mr-2"}),"Loadingâ¦"]}):0===e.length?(0,t.jsx)(l.Zb,{className:"border-dashed",children:(0,t.jsxs)(l.aY,{className:"py-16 text-center space-y-4",children:[(0,t.jsx)("div",{className:"mx-auto h-12 w-12 rounded-2xl bg-violet-100 dar
1k:bg-violet-900/30 flex items-center justify-center",children:(0,t.jsx)(m.Z,{className:"h-6 w-6 text-violet-600"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"No personas yet"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1 max-w-md mx-auto",children:"Create your first persona to consolidate identity, voice, brain and knowledge across every AI surface."})]}),(0,t.jsxs)(r.z,{onClick:()=>y("new"),className:"gap-1.5 mt-2",children:[(0,t.jsx)(d.Z,{className:"h-4 w-4"}),"Create your first persona"]})]})}):(0,t.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:e.map(e=>(0,t.jsxs)(l.Zb,{className:"hover:border-violet-300 transition cursor-pointer group",children:[(0,t.jsx)(l.Ol,{className:"pb-3",children:(0,t.jsx)("div",{className:"flex items-start justify-between",children:(0,t.jsxs)("div",{className:"space-y-1 flex-1 min-w-0",children:[(0,t.jsxs)(l.ll,{className:"text-base flex items-center gap-2 truncate",children:[e.is_default&&(0,t.jsx)(h.Z,{className:"h-3.5 w-3.5 text-amber-500 fill-amber-500 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.persona_name})]}),e.description&&(0,t.jsx)(l.SZ,{className:"text-xs line-clamp-2",children:e.description})]})})}),(0,t.jsxs)(l.aY,{className:"space-y-3 pb-4",children:[(0,t.jsxs)("div",{className:"text-xs space-y-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16",children:"Agent:"}),(0,t.jsx)("span",{className:"font-medium truncate",children:e.agent_name||"â"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16",children:"Voice:"}),(0,t.jsxs)("span",{className:"truncate",children:[e.voice_type||"â"," \xb7 ",e.language||"en"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16",children:"LLM:"}),(0,t.jsx)("span",{className:"truncate",children:e.llm_model||"â"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-muted-foreground w-16",children:"KB:"}),(0,t.jsx)("span",{className:"truncate text-foreground/80",children:e.knowledge_collection||(0,t.jsx)("span",{className:"text-muted-foreground italic",children:"none"})})]})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1",children:(e.enabled_channels||[]).map(e=>{let a=e.startsWith("phone")?x.Z:e.includes("voice")?p.Z:null;return(0,t.jsxs)(i.C,{variant:"secondary",className:"text-[10px] py-0 h-5 gap-1",children:[a&&(0,t.jsx)(a,{className:"h-2.5 w-2.5"}),e.replace(/_/g," ")]},e)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pt-2 border-t",children:[(0,t.jsxs)(r.z,{size:"sm",variant:"outline",className:"flex-1 gap-1",onClick:()=>y(e),children:[(0,t.jsx)(g.Z,{className:"h-3.5 w-3.5"}),"Edit"]}),(0,t.jsx)(r.z,{size:"sm",variant:"ghost",className:"text-rose-600 hover:text-rose-700 hover:bg-rose-50 dark:hover:bg-rose-950/40",onClick:()=>N(e),children:(0,t.jsx)(f.Z,{className:"h-3.5 w-3.5"})})]})]})]},e.id))})]})}},69174:function(e,a,s){s.d(a,{C:function(){return i}});var t=s(57437);s(2265);var n=s(90535),l=s(93448);let r=(0,n.j)("inline-flex items-center rounded-[4px] border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function i(e){let{className:a,variant:s,...n}=e;return(0,t.jsx)("div",{className:(0,l.cn)(r({variant:s}),a),...n})}},12381:function(e,a,s){s.d(a,{d:function(){return o},z:function(){return c}});var t=s(57437),n=s(2265),l=s(37053),r=s(90535),i=s(93448);let o=(0,r.j)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-[4px] text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-[4px] px-3 text-xs",lg:"h-10 rounded-[4px] px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),c=n.forwardRef((e,a)=>{let{className:s,variant:n,size:r,asChild:c=!1,...d}=e,u=c?l.g7:"button";return(0,t.jsx)(u,{className:(0,i.cn)(o({variant:n,size:r,className:s})),ref:a,...d})});c.displayName="Button"},79820:function(e,a,s){s.d(a,{Ol:function(){return i},SZ:function(){return c},Zb:function(){return r},aY:function(){return d},eW:function(){return u},ll:function(){return o}});var t=s(57437),n=s(2265),l=s(93448);let r=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("rounded-[4px] border bg-card text-card-foreground shadow",s),...n})});
1r.displayName="Card";let i=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",s),...n})});i.displayName="CardHeader";let o=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("font-display font-semibold leading-none tracking-tight",s),...n})});o.displayName="CardTitle";let c=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("text-sm text-muted-foreground",s),...n})});c.displayName="CardDescription";let d=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("p-6 pt-0",s),...n})});d.displayName="CardContent";let u=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)("div",{ref:a,className:(0,l.cn)("flex items-center p-6 pt-0",s),...n})});u.displayName="CardFooter"},40279:function(e,a,s){s.d(a,{I:function(){return r}});var t=s(57437),n=s(2265),l=s(93448);let r=n.forwardRef((e,a)=>{let{className:s,type:n,error:r,...i}=e;return(0,t.jsx)("input",{type:n,"aria-invalid":r?"true":void 0,className:(0,l.cn)("flex h-9 w-full rounded-[4px] border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r&&"border-red-500 focus-visible:ring-red-500",s),ref:a,...i})});r.displayName="Input"},75060:function(e,a,s){s.d(a,{_:function(){return c}});var t=s(57437),n=s(2265),l=s(6394),r=s(90535),i=s(93448);let o=(0,r.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.f,{ref:a,className:(0,i.cn)(o(),s),...n})});c.displayName=l.f.displayName},15291:function(e,a,s){s.d(a,{Bw:function(){return h},DI:function(){return d},Ph:function(){return c},Ql:function(){return p},i4:function(){return m},ki:function(){return u},n5:function(){return x}});var t=s(57437),n=s(2265),l=s(56873),r=s(40875),i=s(30401),o=s(93448);let c=l.fC,d=l.ZA,u=l.B4,m=n.forwardRef((e,a)=>{let{className:s,children:n,...i}=e;return(0,t.jsxs)(l.xz,{ref:a,className:(0,o.cn)("flex h-10 w-full items-center justify-between rounded-[4px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 dark:text-gray-100 px-3 py-2 text-sm r
1ing-offset-white dark:ring-offset-gray-950 placeholder:text-gray-500 dark:placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-gray-950 dark:focus:ring-gray-300 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),...i,children:[n,(0,t.jsx)(l.JO,{asChild:!0,children:(0,t.jsx)(r.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=l.xz.displayName;let h=n.forwardRef((e,a)=>{let{className:s,children:n,position:r="popper",...i}=e;return(0,t.jsx)(l.h_,{children:(0,t.jsx)(l.VY,{ref:a,className:(0,o.cn)("relative z-50 min-w-[8rem] overflow-hidden rounded-[4px] border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-gray-950 dark:text-gray-100 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===r&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:r,...i,children:(0,t.jsx)(l.l_,{className:(0,o.cn)("p-1 max-h-[300px] overflow-y-auto","popper"===r&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:n})})})});h.displayName=l.VY.displayName;let x=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.__,{ref:a,className:(0,o.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...n})});x.displayName=l.__.displayName;let p=n.forwardRef((e,a)=>{let{className:s,children:n,...r}=e;return(0,t.jsxs)(l.ck,{ref:a,className:(0,o.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-gray-100 dark:focus:bg-gray-700 focus:text-gray-900 dark:focus:text-gray-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[(0,t.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,t.jsx)(l.wU,{children:(0,t.jsx)(i.Z,{className:"h-4 w-4"})})}),(0,t.jsx)(l.eT,{children:n})]})});p.displayName=l.ck.displayName,n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.Z0,{ref:a,className:(0,o.cn)("-mx-1 my-1 h-px bg-gray-100 dark:bg-gray-700",s),...n})}).displayName=l.Z0.displayName},94589:function(e,a,s){s.d(a,{r:function(){return i}});var t=s(57437),n=s(2265),l=s(50721),r=s(93448);let i=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.fC,{className:(0,r.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 dark:focus-visible:ring-gray-300 focus-visible:ring-offset-2 focus-visible:ring-offset-white dark:focus-visible:ring-offset-gray-950 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-gray-900 dark:data-[state=checked]:bg-gray-100 data-[state=unchecked]:bg-gray-200 dark:data-[state=unchecked]:bg-gray-700",s),...n,ref:a,children:(0,t.jsx)(l.bU,{className:(0,r.cn)("pointer-events-none block h-5 w-5 rounded-full bg-white dark:bg-gray-900 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})})});i.displayName=l.fC.displayName},17168:function(e,a,s){s.d(a,{Tabs:function(){return i},TabsContent:function(){return d},TabsList:function(){return o},TabsTrigger:function(){return c}});var t=s(57437),n=s(2265),l=s(20271),r=s(93448);let i=l.fC,o=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.aV,{ref:a,className:(0,r.cn)("inline-flex h-10 items-center justify-center rounded-[4px] bg-gray-100 dark:bg-gray-800 p-1 text-gray-500 dark:text-gray-400",s),...n})});o.displayName=l.aV.displayName;let c=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.xz,{ref:a,className:(0,r.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-white dark:ring-offset-gray-950 transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 dark:focus-visible:ring-gray-300 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-white dark:data-[state=active]:bg-gray-900 data-[state=active]:text-gray-950 dark:data-[state=active]:text-gray-100 data-[state=active]:shadow-sm",s),...n})});c.displayName=l.xz.displayName;let d=n.forwardRef((e,a)=>{let{className:s,...n}=e;return(0,t.jsx)(l.VY,{ref:a,className:(0,r.cn)("mt-2 ring-offset-white dark:ring-offset-gray-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-950 dark:focus-visible:ring-gray-300 focus-visible:ring-offset-2",s),...n})});d.displayName=l.VY.displayName},23675:function(e,a,s){s.d(a,{g:function(){return r}});var t=s(57437),n=s(2265),l=s(93448);let r=n.forwardRef((e,a)=>{let{className:s,error:n,...r}=e;return(0,t.jsx)("textarea",{"aria-invalid":n?"true":void 0,className:(0,l.cn)("flex min-h-[80px] w-full rounded-[4px] border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n&&"border-red-500 focus-visible:ring-red-500",s),ref:a,...r})});r.displayName="Textarea"},18949:function(e,a,s){s.d(a,{X:function(){return n}});var t=s(71837);let n={list:async e=>(await t.api.get("/agent-personas",{params:e})).data,get:async e=>(await t.api.get("/agent-personas/".concat(e))).data,create:async e=>(await t.api.post("/agent-personas",e)).data,update:async(e,a)=>(await t.api.patch("/agent-personas/".concat(e),a)).data,remove:async e=>(await t.api.delete("/agent-personas/".concat(e))).data,attachToPipeline:async(e,a)=>(await t.api.post("/agent-personas/attach/pipeline/".concat(e),{persona_id:a})).data,attachToVoice:async e=>(await t.api.post("/agent-personas/attach/voice",{persona_id:e})).data,knowledgeCollections:async()=>(await t.api.get("/agent-personas/knowledge-collections")).data,test:async(e,a,s)=>(await t.api.post("/agent-personas/".concat(e,"/test"),{message:a,history:s},{timeout:6e4})).data,testCall:async(e,a)=>(await t.api.post("/agent-personas/".concat(e,"/test-call"),{...a,mode:"call"},{timeout:6e4})).data,testVoice:async(e,a)=>(await t.api.post("/agent-personas/".concat(e,"/test-voice"),{...a,mode:"voice"},{timeout:6e4})).data,testClassify:async(e,a)=>(await t.api.post("/agent-personas/".concat(e,"/test-classify"),{...a,mode:"classify"},{timeout:6e4})).data}},95661:function(e,a,s){s.d(a,{C4:function(){return l},Ir:function(){return d},KF:function(){return m},R1:function(){return n},RD:function(){return p},XC:function(){return x},Xp:function(){return i},iN:function(){return r},lp:function(){return u},nE:function(){return f},nM:function(){return c},ry:function(){return o},sP:function(){return g},uP:function(){return v},wn:function(){return h}});var t=s(71837);async function n(){return(await t.api.get("/customer-agent/config")).data}async function l(e){return(await t.api.put("/customer-agent/config",e)).data}async function r(){var e;return(null===(e=(await t.api.get("/customer-agent/available-tools")).data)||void 0===e?void 0:e.tools)||[]}async function i(e){return(await t.api.get("/products",{params:e})).data||[]}async function o(e){return(await t.api.post("/products",e)).data}async function c(e,a){return(await t.api.put("/products/".concat(e),a)).data}async function d(e){await t.api.delete("/products/".concat(e))}function u(e){return{workspace_id:"default",total_documents:e.length,collections:{},queries_today:0,avg_confidence:0,escalation_rate:0}}async function m(){var e,a,s,n;let l,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"knowledge_base",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;try{l=await t.api.get("/v2/rag/documents",{params:{collection_type:r,limit:i}})}catch(e){l=await t.api.get("/rag/documents",{params:{collection_type:r,limit:i}})}let o=(null===(e=l.data)||void 0===e?void 0:e.documents)||(null===(s=l.data)||void 0===s?void 0:null===(a=s.data)||void 0===a?void 0:a.documents)||[];return console.log("[KB] getRAGDocuments:",o.length,"docs from",null===(n=l.config)||void 0===n?void 0:n.url),o.map(e=>{var a,s;return{id:e.id||e.document_id,title:e.title||(null===(a=e.content)||void 0===a?void 0:a.substring(0,60))||"Untitled",content_preview:(null===(s=e.content)||void 0===s?void 0:s.substring(0,150))||"",source_type:e.source_type||e.document_type||"manual",created_at:e.created_at||e.uploaded_at||new Date().toISOString(),chunk_count:e.chunks||1}})}async function h(e,a){return(await t.api.post("/v2/rag/documents",{title:e,content:a,document_type:"knowledge_base"})).data}async function x(e,a){var s;let n=new FormData;n.append("file",e),a&&n.append("title",a),n.append("document_type","general");let l=await t.api.post("/rag/documents/upload",n,{headers:{"Content-Type":"multipart/form-data"},timeout:6e4});return(null===(s=l.data)||void 0===s?void 0:s.data)||l.data}async function p(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"general";await t.api.delete("/rag/documents/".concat(e),{params:{collection_type:a}})}async function g(e){var a;let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"general",n=await t.api.get("/rag/documents/".concat(e,"/content"),{params:{collection_type:s}});return(null===(a=n.data)||void 0===a?void 0:a.data)||n.data}async function f(e){var a,s,n,l,r;let i=await t.api.post("/rag/query",{query:e,collection_type:"general",generate_response:!0,n_results:5}),o=(null===(a=i.data)||void 0===a?void 0:a.data)||i.data;return{success:!0,action:o.ai_response?"auto_respond":"search",response:o.ai_response||(null===(n=o.results)||void 0===n?void 0:null===(s=n[0])||void 0===s?void 0:s.content)||"No relevant documents found.",confidence_score:(null===(r=o.results)||void 0===r?void 0:null===(l=r[0])||void 0===l?void 0:l.relevance_score)||0,sources:(o.results||[]).map(e=>{var a,s,t;return{id:e.id||"",title:(null===(a=e.metadata)||void 0===a?void 0:a.title)||(null===(s=e.metadata)||void 0===s?void 0:s.filename)||"Document",excerpt:(null===(t=e.content)||void 0===t?void 0:t.substring(0,200))||"",relevance_score:e.relevance_score||e.score||0}}),processing_time_ms:0}}async function v(e,a,s){return(await t.api.post("/customer-agent/test",{message:e,conversation_history:a,profile_id:s||void 0},{timeout:6e4})).data}},93448:function(e,a,s){s.d(a,{cn:function(){return l}});var t=s(61994),n=s(53335);function l(){for(var e=arguments.length,a=Array(e),s=0;s<e;s++)a[s]=arguments[s];return(0,n.m6)((0,t.W)(a))}}}]);
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.