1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[68186],{20067:function(){},72061:function(){},17624:function(e,a,t){"use strict";t.d(a,{d:function(){return C}});var s=t(57437),l=t(2265),n=t(2093),i=t(84881),r=t(6076),o=t(17689),d=t(45131),c=t(63639),u=t(15863),m=t(13041),p=t(48662),x=t(82023),h=t(65302),f=t(82431),g=t(74291),b=t(17168),v=t(12381),j=t(40279),y=t(15291),N=t(71837),w=t(69064);let k="__none__",_=[{code:k,label:"No prefix (use as-is)"},{code:"+91",label:"+91 India"},{code:"+1",label:"+1 USA / Canada"},{code:"+44",label:"+44 UK"},{code:"+971",label:"+971 UAE"},{code:"+65",label:"+65 Singapore"},{code:"+61",label:"+61 Australia"}];function C(e){var a,t,m,p;let{open:x,onOpenChange:h,embedded:f=!1}=e,{user:C}=(0,i.a)(),z=(null==C?void 0:C.workspace_id)||"",[q,T]=(0,l.useState)("upload"),[P,R]=(0,l.useState)("call"),[Z,E]=(0,l.useState)(!1),[V,B]=(0,l.useState)(20),[Q,F]=(0,l.useState)(null),[L,M]=(0,l.useState)("upload"),[K,H]=(0,l.useState)(""),[U,G]=(0,l.useState)([]),[O,W]=(0,l.useState)([]),[Y,X]=(0,l.useState)({name:"",phone:"",email:"",company:"",notes:"",interest:"",city:""}),[$,J]=(0,l.useState)("+91"),[ee,ea]=(0,l.useState)([]),[et,es]=(0,l.useState)({}),[el,en]=(0,l.useState)({}),[ei,er]=(0,l.useState)({}),eo=(e,a,t)=>er(s=>({...s,[e]:{...s[e]||{},[a]:t}})),ed=(e,a,t)=>{var s;return(null===(s=ei[e])||void 0===s?void 0:s[a])!==void 0?ei[e][a]:t||""},[ec,eu]=(0,l.useState)([]),[em,ep]=(0,l.useState)("__auto__"),[ex,eh]=(0,l.useState)(null),[ef,eg]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(!x)return;let e=!1;return N.api.get("/quick-demo/pipelines").then(a=>{var t;e||eu((null===(t=a.data)||void 0===t?void 0:t.pipelines)||[])}).catch(()=>{}),()=>{e=!0}},[x]),(0,l.useEffect)(()=>{var e;if(!x)return;let a=!1,t="__auto__"===em?(null===(e=ec.find(e=>e.ai_calling_enabled))||void 0===e?void 0:e.id)||"":em;if(!t){eh(null);return}return N.api.get("/quick-demo/pipeline/".concat(t,"/preview")).then(e=>{a||eh(e.data)}).catch(()=>{eh(null)}),()=>{a=!0}},[x,em,ec]);let[eb,ev]=(0,l.useState)(null),[ej,ey]=(0,l.useState)(null),[eN,ew]=(0,l.useState)("india"),[ek,e_]=(0,l.useState)("pipecat_sip"),[eC,eS]=(0,l.useState)("ml-IN-Chirp3-HD-Kore"),eA=(0,l.useRef)(null),eD=(0,l.useRef)(null);(0,l.useEffect)(()=>{x||(eA.current&&clearInterval(eA.current),eA.current=null,M("upload"),H(""),G([]),W([]),X({name:"",phone:"",email:"",company:"",notes:"",interest:"",city:""}),ev(null),ey(null),F(null))},[x]),(0,l.useEffect)(()=>{if(!eb||"progress"!==L)return;let e=!1,a=async()=>{try{var a;let t=await N.api.get("/quick-demo/batch/".concat(eb,"/progress"));if(e)return;ey(t.data),(null===(a=t.data)||void 0===a?void 0:a.is_complete)&&eA.current&&(clearInterval(eA.current),eA.current=null)}catch(a){if(e)return;console.error("progress poll failed",a)}};return a(),eA.current=setInterval(a,3e3),()=>{e=!0,eA.current&&clearInterval(eA.current),eA.current=null}},[eb,L]);let eI=(e,a)=>{let t={name:"",phone:"",email:"",company:"",notes:"",interest:"",city:""},s=e=>(e||"").toLowerCase().trim(),l=/^[\s+()\-.\d]{7,20}$/,n=/^[\w.+-]+@[\w-]+\.[\w.-]+$/;for(let a of e){let e=s(a);!t.name&&("name"===e||e.includes("full name")||e.includes("customer name")||e.includes("client name")||e.includes("lead name")||e.includes("contact name")||"fullname"===e||"firstname"===e||"first name"===e||e.includes("नाम")||e.includes("Ø§ÙØ§Ø³Ù
")||(e.includes("name")||e.includes("contact"))&&!e.includes("company")&&!e.includes("business"))?t.name=a:!t.phone&&("phone"===e||"mobile"===e||"whatsapp"===e||"number"===e||"cell"===e||"tel"===e||"telephone"===e||"mob"===e||"cellphone"===e||"phone no"===e||"phone no."===e||"mobile no"===e||"mobile no."===e||"contact no"===e||"contact no."===e||"contact number"===e||"whatsapp no"===e||"whatsapp number"===e||e.includes("phone")||e.includes("mobile")||e.includes("whatsapp")||e.includes("cell")||e.includes("मà¥à¤¬à¤¾à¤à¤²")||e.includes("اÙÙØ§ØªÙ"))?t.phone=a:!t.email&&("email"===e||"e-mail"===e||"mail"===e||e.includes("email")||e.includes("mail")||e.includes("e-mail"))?t.email=a:!t.company&&("company"===e||"org"===e||e.includes("company")||e.includes("business")||e.includes("organisation")||e.includes("organization"))?t.company=a:t.notes||"notes"!==e&&"n
1ote"!==e&&"comment"!==e&&"comments"!==e&&"remark"!==e&&"remarks"!==e?!t.interest&&("interest"===e||"product"===e||"looking for"===e||"lookingfor"===e||e.includes("interest"))?t.interest=a:t.city||"city"!==e&&"location"!==e&&"town"!==e&&"place"!==e||(t.city=a):t.notes=a}if((!t.phone||!t.name)&&a&&a.length){let s=a.slice(0,5),i=e.filter(e=>e!==t.name&&e!==t.phone&&e!==t.email&&e!==t.company);if(!t.phone){let e="",a=0;for(let t of i){let n=s.reduce((e,a)=>{var s;return e+(l.test(String(null!==(s=null==a?void 0:a[t])&&void 0!==s?s:"").trim())?1:0)},0);n>a&&n>=Math.ceil(.6*s.length)&&(e=t,a=n)}e&&(t.phone=e)}if(!t.name){for(let e of i)if(e!==t.phone&&s.reduce((a,t)=>{var s;let i=String(null!==(s=null==t?void 0:t[e])&&void 0!==s?s:"").trim();return a+(i&&!l.test(i)&&!n.test(i)&&/[A-Za-zà¤-ॿØ-Û¿]/.test(i)?1:0)},0)>=Math.ceil(.6*s.length)){t.name=e;break}}}return t},ez=(0,l.useCallback)(async e=>{if(e.size>8388608){w.default.error("File is ".concat((e.size/1024/1024).toFixed(1)," MB â quick demo only uses the top ").concat(200," rows. ")+"Trim to ~".concat(200,"â50 rows and re-upload."));return}H(e.name);try{let a=await e.arrayBuffer(),t=n.ij(a,{type:"array",sheetRows:206}),s=t.Sheets[t.SheetNames[0]],l=n.P6.sheet_to_json(s,{defval:"",raw:!1});if(!l.length){w.default.error("File is empty");return}let i=Object.keys(l[0]),r=e=>String(null!=e?e:"").toLowerCase().replace(/[^a-z0-9]/g,""),o=new Set(["name","fullname","customername","clientname","leadname","contactname","firstname","lastname","phone","phonenumber","phoneno","mobile","mobilenumber","mobileno","mob","whatsapp","whatsappnumber","whatsappno","cell","cellphone","tel","telephone","contact","contactno","contactnumber","number","email","emailid","emailaddress","mail","company","companyname","organization","organisation","org","business","notes","note","comment","comments","remark","remarks","interest","product","city","location","town","place","address","sn","sno","srno","serialno","sl","slno","rno","naam","नाम","Ø§ÙØ§Ø³Ù
","peyaru","peyar","peyarsamuga","samacharam"]),d=e=>i.every(a=>{var t;return!String(null!==(t=e[a])&&void 0!==t?t:"").trim()}),c=e=>{let a=i.filter(a=>{var t;return String(null!==(t=e[a])&&void 0!==t?t:"").trim()});if(a.length<2)return!1;let t=a.filter(a=>r(e[a])===r(a)).length;return t/a.length>=.5&&t>=2||a.filter(a=>o.has(r(e[a]))).length>=2},u=l.filter(e=>!d(e)&&!c(e)),m=u.slice(0,200);if(!m.length){w.default.error("No usable rows after filtering empty / header-echo rows");return}let p=l.length-u.length;G(i),W(m),X(eI(i,m)),M("mapping"),p>0?w.default.success("Loaded ".concat(m.length," rows â skipped ").concat(p," blank/header rows.")):l.length>200&&w.default.success("Loaded top ".concat(200," rows (file may have more â quick demo cap)."))}catch(e){console.error(e),w.default.error("Failed to read file")}},[]);(0,l.useEffect)(()=>{if("mapping"!==L||!O.length)return;let e=$===k?"":$||"",a=[];for(let d of O.slice(0,200)){var t,s,l,n,i,r,o;let c=String(null!==(t=d[Y.phone])&&void 0!==t?t:"").trim();c&&e&&!c.startsWith("+")&&(c=e+c.replace(/[^0-9]/g,"")),a.push({name:String(null!==(s=d[Y.name])&&void 0!==s?s:"").trim(),phone:c,email:String(null!==(l=d[Y.email])&&void 0!==l?l:"").trim(),company:String(null!==(n=d[Y.company])&&void 0!==n?n:"").trim(),notes:Y.notes?String(null!==(i=d[Y.notes])&&void 0!==i?i:"").trim():void 0,interest:Y.interest?String(null!==(r=d[Y.interest])&&void 0!==r?r:"").trim():void 0,city:Y.city?String(null!==(o=d[Y.city])&&void 0!==o?o:"").trim():void 0})}ea(a)},[L,O,Y,$]);let eq=ee.filter(e=>e.phone&&e.name),eT=ee.filter(e=>!e.phone).length,eP=ee.filter(e=>e.phone&&!e.name).length,eR=O.length>200?O.length-200:0,eZ=ee.map((e,a)=>({...e,name:ed(a,"name",e.name),phone:void 0!==el[a]?el[a]:e.phone||"",email:ed(a,"email",e.email),company:ed(a,"company",e.company),notes:ed(a,"notes",e.notes),interest:ed(a,"interest",e.interest),city:ed(a,"city",e.city)})),eE=eZ.filter((e,a)=>{var t,s;return!1!==et[a]&&!!(null===(t=e.phone)||void 0===t?void 0:t.trim())&&!!(null===(s=e.name)||void 0===s?void 0:s.trim())}).map(e=>({...e,name:(e.name||"").trim(),phone:(e.phone||"").trim(),email:(e.email||"").trim(),company:(e.company||"").trim(),notes:(e.notes||"").trim(),interest:(e.interest||"").trim(),city:(e.city||"").trim()})),eV=ee.map((e,a)=>a).filter(e=>{let a=ee[e];return!!(a.phone||a.name)}),eB=ee.length-eV.length,eQ=async()=>
1{if(!eE.length){w.default.error("Pick at least one row with a phone number");return}let e=(null==ex?void 0:ex.pipeline_id)||("__auto__"===em?null:em);E(!0),M("firing");try{let a=await N.api.post("/quick-demo/upload-run",{rows:eE,mode:P,filename:K,dispatch:!1,pipeline_id:e,telephony:eN,voice_provider:ek,voice_id:eC});ev(a.data.demo_batch_id),M("progress"),w.default.success("Imported ".concat(a.data.leads_created," contacts. Review and click Start AI Calling."))}catch(e){var a,t;w.default.error((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.detail)||"Upload failed"),M("mapping")}finally{E(!1)}},eF=async()=>{var e,a,t,s;if(!eb)return;let l=null!==(a=null==ej?void 0:null===(e=ej.counts)||void 0===e?void 0:e.total)&&void 0!==a?a:0;if(window.confirm("About to start AI calls to ".concat(l||"all imported"," number").concat(1===l?"":"s",". Continue?"))){E(!0);try{let e=new URL("/quick-demo/batch/".concat(eb,"/dispatch"),window.location.origin);e.searchParams.set("telephony",eN),ek&&e.searchParams.set("voice_provider",ek),eC&&e.searchParams.set("voice_id",eC);let a=await N.api.post(e.pathname+e.search);w.default.success("Dispatch queued â ".concat(a.data.leads_to_call," calls starting now"))}catch(e){w.default.error((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(t=s.data)||void 0===t?void 0:t.detail)||"Dispatch failed")}finally{E(!1)}}},eL=async()=>{if(!window.confirm("About to create ".concat(V," sample leads and ").concat("voice"===P?"send AI voice messages":"both"===P?"fire AI calls + voice":"fire AI calls",". Continue?")))return;E(!0);let e=(null==ex?void 0:ex.pipeline_id)||("__auto__"===em?null:em);try{let a=await N.api.post("/quick-demo/run",{mode:P,count:V,dispatch:!0,pipeline_id:e,telephony:eN,voice_provider:ek,voice_id:eC});F(a.data)}catch(e){var a,t;w.default.error((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.detail)||"Sample run failed")}finally{E(!1)}},eM=(0,s.jsxs)(s.Fragment,{children:[f?(0,s.jsxs)("div",{className:"space-y-1 mb-4",children:[(0,s.jsxs)("h1",{className:"font-display text-2xl font-semibold flex items-center gap-2",children:[(0,s.jsx)(r.Z,{className:"w-6 h-6 text-fuchsia-600"}),"Quick Demo"]}),(0,s.jsxs)("p",{className:"text-sm text-slate-500",children:["Upload up to ",200," rows from Excel/CSV â we auto-detect columns, fire AI calls, and show live ratings here. No need to assign to a pipeline."]})]}):(0,s.jsxs)(g.fK,{children:[(0,s.jsxs)(g.$N,{className:"flex items-center gap-2",children:[(0,s.jsx)(r.Z,{className:"w-5 h-5 text-fuchsia-600"}),"Quick Demo"]}),(0,s.jsxs)(g.Be,{children:["Upload up to ",200," rows from Excel/CSV â we auto-detect columns, fire AI calls, and show live ratings here. No need to assign to a pipeline."]})]}),(0,s.jsxs)(b.Tabs,{value:q,onValueChange:e=>T(e),className:"w-full",children:[(0,s.jsxs)(b.TabsList,{className:"grid w-full grid-cols-2 mb-3",children:[(0,s.jsx)(b.TabsTrigger,{value:"upload",children:"\uD83D\uDCC2 Upload your data"}),(0,s.jsx)(b.TabsTrigger,{value:"sample",children:"\uD83C\uDFB2 Sample leads"})]}),(0,s.jsxs)(b.TabsContent,{value:"upload",className:"mt-0 space-y-3",children:[(0,s.jsx)(S,{value:P,onChange:R}),(0,s.jsx)(A,{pipelines:ec,value:em,onChange:ep,scriptPreview:ex,showPreview:ef,onTogglePreview:()=>eg(e=>!e),workspaceId:z,telephonyRegion:eN,setTelephonyRegion:ew,setBulkVoiceProvider:e_,setBulkVoiceId:eS,onScriptUpdated:()=>{var e;let a="__auto__"===em?(null===(e=ec.find(e=>e.ai_calling_enabled))||void 0===e?void 0:e.id)||"":em;a&&N.api.get("/quick-demo/pipeline/".concat(a,"/preview")).then(e=>eh(e.data)).catch(()=>{})}}),"upload"===L&&(0,s.jsxs)("div",{onClick:()=>{var e;return null===(e=eD.current)||void 0===e?void 0:e.click()},onDragOver:e=>e.preventDefault(),onDrop:e=>{var a;e.preventDefault();let t=null===(a=e.dataTransfer.files)||void 0===a?void 0:a[0];t&&ez(t)},className:"border-2 border-dashed border-slate-300 dark:border-slate-700 rounded-lg p-8 text-center cursor-pointer hover:border-fuchsia-500 transition",children:[(0,s.jsx)(o.Z,{className:"w-10 h-10 mx-auto text-slate-400 mb-2"}),(0,s.jsx)("div",{className:"text-sm font-medium",children:"Click or drop your Excel / CSV file"}),(0,s.jsxs)("div",{className:"text-xs text-slate-500 mt-1",children:["Up to ",200," rows â first sheet is used. We auto-detect Name / Phone / Email / Company."]}),(0,s.jsx)("input",{ref:eD,type:"file",accept:".xlsx,.xls,.csv",className:"hidden",onChange:e=>{var a;let t=null===(a=e.target.files)||void 0===a?void 0:a[0];t&&ez(t)}}),(0,s.jsxs)("div",{className:"mt-3 text-[11px] text-slate-500",children:["Don't have a file?"," ",(0,s.jsx)("a",{href:"/api/quick-demo/template.csv",onClick:e=>e.stopPropagation(),className:"text-fuchsia-600 hover:underline font-medium",download:!0,children:"Download starter template"})]})]}),"mapping"===L&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs text-slate-500",children:[(0,s.jsxs)("span",{children:["\uD83D\uDCC4 ",K," \xb7 ",O.length," rows",eR>0?" (will use first ".concat(200,", skipping ").concat(eR,")"):""]}),(0,s.jsxs)(v.z,{size:"sm",variant:"ghost",className:"h-7 text-xs",onClick:()=>{M("upload"),H(""),G([]),W([])},children:[(0,s.jsx)(d.Z,{className:"w-3 h-3 mr-1"})," Change file"]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,s.jsx)(D,{label:"Name *",required:!0,value:Y.name,cols:U,onChange:e=>X(a=>({...a,name:e}))}),(0,s.jsx)(D,{label:"Phone *",required:!0,value:Y.phone,cols:U,onChange:e=>X(a=>({...a,phone:e}))}),(0,s.jsx)(D,{label:"Email",value:Y.email,cols:U,onChange:e=>X(a=>({...a,email:e}))}),(0,s.jsx)(D,{label:"Company",value:Y.company,cols:U,onChange:e=>X(a=>({...a,company:e}))}),(0,s.jsx)(D,{label:"Notes (per-lead context)",value:Y.notes,cols:U,onChange:e=>X(a=>({...a,notes:e}))}),(0,s.jsx)(D,{label:"Interest / Product",value:Y.interest,cols:U,onChange:e=>X(a=>({...a,interest:e}))}),(0,s.jsx)(D,{label:"City / Location",value:Y.city,cols:U,onChange:e=>X(a=>({...a,city:e}))})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Country code for phones missing it"}),(0,s.jsxs)("p",{className:"text-[11px] text-slate-500",children:["Numbers like ",(0,s.jsx)("span",{className:"font-mono",children:"9876543210"})," get prefixed to"," ",(0,s.jsx)("span",{className:"font-mono",children:"+91 9876543210"}),". Numbers already starting with"," ",(0,s.jsx)("span",{className:"font-mono",children:"+"})," are left alone."]}),(0,s.jsxs)(y.Ph,{value:$,onValueChange:J,children:[(0,s.jsx)(y.i4,{className:"h-8 text-sm",children:(0,s.jsx)(y.ki,{})}),(0,s.jsx)(y.Bw,{children:_.map(e=>(0,s.jsx)(y.Ql,{value:e.code,children:e.label},e.code||"none"))})]})]}),(0,s.jsxs)("div",{className:"border border-slate-200 dark:border-slate-700 rounded-md overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 bg-slate-50 dark:bg-slate-800 border-b border-slate-200 dark:border-slate-700 text-xs font-medium flex items-center justify-between",children:[(0,s.jsxs)("span",{children:["Review & edit (",eE.length," selected \xb7 ",eq.length," valid \xb7 ",eP+eT>0?"".concat(eP+eT," skipped"):"all good",")"]}),(0,s.jsxs)("div",{className:"flex items-center gap-3 text-slate-500",children:[(0,s.jsx)("button",{type:"button",className:"hover:text-fuchsia-600",onClick:()=>{let e={};ee.forEach((a,t)=>{let s=eZ[t]||ee[t];s.phone&&s.name&&(e[t]=!0)}),es(e)},children:"Select all"}),(0,s.jsx)("button",{type:"button",className:"hover:text-fuchsia-600",onClick:()=>{es(Object.fromEntries(ee.map((e,a)=>[a,!1])))},children:"Clear"})]})]}),(0,s.jsxs)("div",{className:"max-h-72 overflow-y-auto text-xs",children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 bg-slate-50/60 dark:bg-slate-800/40 border-b border-slate-100 dar
1k:border-slate-800 grid grid-cols-[24px,1.1fr,1.4fr,1.2fr,1fr,1.4fr] gap-2 text-[10px] font-medium text-slate-500 uppercase tracking-wide",children:[(0,s.jsx)("span",{}),(0,s.jsx)("span",{children:"Name"}),(0,s.jsx)("span",{children:"Phone"}),(0,s.jsx)("span",{children:"Email"}),(0,s.jsx)("span",{children:"Company"}),(0,s.jsx)("span",{children:"Context (interest \xb7 city \xb7 notes)"})]}),eV.map(e=>{let a=ee[e],t=eZ[e]||a,l=!!t.phone&&!!t.name,n=!1!==et[e]&&l,i=t.phone?t.name?"":"no name":"no phone",r=[t.interest,t.city,t.notes].filter(Boolean).join(" \xb7 "),o="text-xs h-6 px-1.5 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none w-full";return(0,s.jsxs)("div",{className:"px-3 py-1.5 border-b border-slate-100 dark:border-slate-800 grid grid-cols-[24px,1.1fr,1.4fr,1.2fr,1fr,1.4fr] gap-2 items-center ".concat(l?"":"bg-rose-50/40 dark:bg-rose-950/20 opacity-80"),children:[(0,s.jsx)("input",{type:"checkbox",disabled:!l,checked:n,onChange:a=>es(t=>({...t,[e]:a.target.checked})),className:"w-3.5 h-3.5 accent-fuchsia-600",title:i&&"Skipped: ".concat(i)}),(0,s.jsx)("input",{type:"text",value:t.name||"",onChange:a=>eo(e,"name",a.target.value),className:o,placeholder:"Name *"}),(0,s.jsx)("input",{type:"tel",value:t.phone||"",onChange:a=>en(t=>({...t,[e]:a.target.value})),className:"".concat(o," font-mono"),placeholder:"+91â¦"}),(0,s.jsx)("input",{type:"email",value:t.email||"",onChange:a=>eo(e,"email",a.target.value),className:o,placeholder:"email@â¦"}),(0,s.jsx)("input",{type:"text",value:t.company||"",onChange:a=>eo(e,"company",a.target.value),className:o,placeholder:"Company"}),(0,s.jsx)("input",{type:"text",value:r,onChange:a=>{eo(e,"notes",a.target.value),eo(e,"interest",""),eo(e,"city","")},className:o,placeholder:"e.g. asked about EMI, Mumbai, follow up Mon",title:"Combined context â flows into the AI Calling system prompt as lead context"})]},e)})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-md bg-amber-50 dark:bg-amber-900/20 text-xs text-amber-800 dark:text-amber-200",children:[(0,s.jsx)(c.Z,{className:"w-4 h-4 shrink-0"}),(0,s.jsxs)("span",{children:["Calls will dial only the ",(0,s.jsx)("b",{children:eE.length})," rows you selected. Edit any cell inline.",eB>0&&(0,s.jsxs)(s.Fragment,{children:[" \xb7 ",eB," blank/header row(s) hidden."]})]})]}),(0,s.jsxs)(v.z,{disabled:Z||!eE.length||!Y.name||!Y.phone,onClick:eQ,className:"w-full bg-gradient-to-r from-fuchsia-600 to-violet-600 hover:from-fuchsia-700 hover:to-violet-700 text-white",children:[Z?(0,s.jsx)(u.Z,{className:"w-4 h-4 mr-1 animate-spin"}):(0,s.jsx)(r.Z,{className:"w-4 h-4 mr-1"}),"Import & review ",eE.length," contact",1===eE.length?"":"s"]})]}),"firing"===L&&(0,s.jsxs)("div",{className:"flex flex-col items-center gap-2 py-10",children:[(0,s.jsx)(u.Z,{className:"w-6 h-6 animate-spin text-fuchsia-600"}),(0,s.jsx)("span",{className:"text-sm text-slate-600 dark:text-slate-300",children:"Creating leads + queueing callsâ¦"})]}),"progress"===L&&ej&&(0,s.jsxs)(s.Fragment,{children:[(null===(a=ej.counts)||void 0===a?void 0:a.completed)===0&&(null===(t=ej.counts)||void 0===t?void 0:t.calling)===0&&(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2 p-3 rounded-md bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-900",children:[(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsxs)("div",{className:"font-medium text-amber-900 dark:text-amber-200",children:[null===(m=ej.counts)||void 0===m?void 0:m.total," contact",(null===(p=ej.counts)||void 0===p?void 0:p.total)===1?"":"s"," imported"]}),(0,s.jsxs)("div",{className:"text-xs text-amber-700 dark:text-amber-300/90",children:["Review the list below. Click ",(0,s.jsx)("b",{children:"Start AI Calling"})," when ready â phones will ring within seconds."]})]}),(0,s.jsxs)("div",{className:"flex gap-2 shrink-0",children:[(0,s.jsx)(v.z,{size:"sm",variant:"ghost",disabled:Z,onClick:async()=>{if(eb&&window.confirm("Delete these imported contacts and stop the demo?")){E(!0);try{await N.api.post("/quick-demo/clear"),w.default.success("Demo cleared"),M("upload"),H(""),G([]),W([]),ev(null),ey(null)}catch(t){var e,a;w.default.error((null==t?void 0:null===(a=t.response)||void 0===a?void 0:null===(e=a.data)||void 0===e?void 0:e.detail)||"Clear failed")}finally{E(!1)}}},children:"Clear"}),(0,s.jsxs)(v.z,{size:"sm",disabled:Z,onClick:eF,className:"bg-gradient-to-r from-fuchsia-600 to-violet-600 hover:from-fuchsia-700 hover:to-violet-700 text-white",children:[Z?(0,s.jsx)(u.Z,{className:"w-4 h-4 mr-1 animate-spin"}):(0,s.jsx)(r.Z,{className:"w-4 h-4 mr-1"}),"Start AI Calling"]})]})]}),(0,s.jsx)(I,{progress:ej,onRunAnother:()=>{M("upload"),H(""),G([]),W([]),ev(null),ey(null)},onClose:()=>h(!1)})]})]}),(0,s.jsxs)(b.TabsContent,{value:"sample",className:"mt-0 space-y-3",children:[(0,s.jsx)(S,{value:P,onChange:R}),(0,s.jsx)(A,{pipelines:ec,value:em,onChange:ep,scriptPreview:ex,showPreview:ef,onTogglePreview:()=>eg(e=>!e),workspaceId:z,telephonyRegion:eN,setTelephonyRegion:ew,setBulkVoiceProvider:e_,setBulkVoiceId:eS,onScriptUpdated:()=>{var e;let a="__auto__"===em?(null===(e=ec.find(e=>e.ai_calling_enabled))||void 0===e?void 0:e.id)||"":em;a&&N.api.get("/quick-demo/pipeline/".concat(a,"/preview")).then(e=>eh(e.data)).catch(()=>{})}}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("label",{className:"text-xs font-medium",children:["Number of sample leads (1â",200,")"]}),(0,s.jsx)(j.I,{type:"number",min:1,max:200,value:V,onChange:e=>B(Math.min(200,Math.max(1,Number(e.target.value)))),className:"h-9"})]}),(0,s.jsx)("div",{className:"text-xs text-slate-500 p-2 rounded-md bg-slate-50 dark:bg-slate-800",children:"Uses 20 hardcoded Indian sample leads with placeholder numbers. Good for end-to-e
1nd smoke testing when you don't want to dial real numbers."}),(0,s.jsxs)(v.z,{disabled:Z,onClick:eL,className:"w-full bg-gradient-to-r from-fuchsia-600 to-violet-600 hover:from-fuchsia-700 hover:to-violet-700 text-white",children:[Z?(0,s.jsx)(u.Z,{className:"w-4 h-4 mr-1 animate-spin"}):(0,s.jsx)(r.Z,{className:"w-4 h-4 mr-1"}),"Fire ",V," sample lead",1===V?"":"s"]}),Q&&(0,s.jsx)("div",{className:"p-3 rounded-md bg-emerald-50 dark:bg-emerald-900/20 text-sm",children:(0,s.jsxs)("div",{className:"font-medium text-emerald-700 dark:text-emerald-300",children:["â
",Q.leads_created," sample leads created \xb7 ",Q.events_published," events fired"]})})]})]})]});return f?(0,s.jsx)("div",{className:"max-w-5xl mx-auto p-4 sm:p-6",children:eM}):(0,s.jsx)(g.Vq,{open:x,onOpenChange:h,children:(0,s.jsx)(g.cZ,{className:"max-w-3xl max-h-[88vh] overflow-y-auto",children:eM})})}function S(e){let{value:a,onChange:t}=e,l=[{id:"call",label:"Call",icon:(0,s.jsx)(m.Z,{className:"w-3.5 h-3.5"})},{id:"voice",label:"Voice",icon:(0,s.jsx)(p.Z,{className:"w-3.5 h-3.5"})},{id:"both",label:"Both",icon:(0,s.jsx)(x.Z,{className:"w-3.5 h-3.5"})}];return(0,s.jsx)("div",{className:"flex gap-1.5",children:l.map(e=>(0,s.jsxs)("button",{onClick:()=>t(e.id),className:"flex-1 flex items-center justify-center gap-1 px-3 py-1.5 text-xs font-medium rounded-md border transition ".concat(a===e.id?"bg-fuchsia-600 text-white border-fuchsia-600":"bg-transparent text-slate-600 dark:text-slate-300 border-slate-300 dark:border-slate-700 hover:border-fuchsia-400"),children:[e.icon,e.label]},e.id))})}function A(e){var a,t,n;let{pipelines:i,value:r,onChange:o,scriptPreview:d,showPreview:c,onTogglePreview:p,onScriptUpdated:h,workspaceId:f,telephonyRegion:g,setTelephonyRegion:b,setBulkVoiceProvider:j,setBulkVoiceId:k}=e,[_,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(""),[D,I]=(0,l.useState)(""),[z,q]=(0,l.useState)("en"),T=(0,l.useRef)(null),[P,R]=(0,l.useState)(""),[Z,E]=(0,l.useState)([]),[V,B]=(0,l.useState)(""),[Q,F]=(0,l.useState)(""),[L,M]=(0,l.useState)(""),[K,H]=(0,l.useState)(""),[U,G]=(0,l.useState)("gemini-3-flash-preview"),[O,W]=(0,l.useState)(.3),[Y,X]=(0,l.useState)(1),[$,J]=(0,l.useState)(2),[ee,ea]=(0,l.useState)(3),[et,es]=(0,l.useState)(!0),[el,en]=(0,l.useState)(!1);(0,l.useEffect)(()=>{if(d){A(d.agent_name||""),I(d.company_name||"");let e=d.pipeline_id||null;T.current!==e&&(q(d.language||"en"),T.current=e),R(d.voice_type||""),E([...d.qualification_questions||[]]),B(d.greeting_template||""),F(d.closing_message||""),M(d.ai_instructions||""),H(d.product_context||"");let a=d.perf_tuning||{};G(a.llm_model||"gemini-3-flash-preview"),W("number"==typeof a.temperature?a.temperature:.3),X("number"==typeof a.voice_speed?a.voice_speed:1),J("number"==typeof a.turn_timeout?a.turn_timeout:2),ea("number"==typeof a.optimize_streaming_latency?a.optimize_streaming_latency:3),es(!1!==a.auto_mode),C(!1)}},[null==d?void 0:d.pipeline_id]);let ei=(()=>{let e=[],a=[V,L,K,...Z].join("\n");return/\[(describe|list|price|number|region|placeholder|your )/i.test(a)&&e.push("Placeholder brackets like `[describeâ¦]` or `[price]` will be read aloud â replace with real text."),V&&!/\{\{?\s*lead_name\s*\}?\}/i.test(V)&&e.push("Greeting is missing {{lead_name}} â calls won't be personalized."),0===Z.length?e.push("No qualification questions â call will be very short."):Z.some(e=>e.trim().length<5)&&e.push("One or more questions are too short to be useful."),e})(),er=async()=>{if(null==d?void 0:d.pipeline_id){en(!0);try{let e={agent_name:S,company_name:D,language:z,voice_type:P,qualification_questions:Z.filter(e=>e.trim()),greeting_template:V,closing_message:Q,ai_instructions:L,product_context:K,llm_model:U,advanced_voice_settings:{temperature:O,voice_speed:Y,turn_timeout:$,optimize_streaming_latency:ee,auto_mode:et}},a=[N.api.put("/lead-pipelines/".concat(d.pipeline_id,"/ai-calling-settings?workspace_id=").concat(encodeURIComponent(f)),e),N.api.put("/ai-voice/settings",e).catch(e=>{var a;return console.warn("AI Voice settings sync failed (non-fatal):",(null==e?void 0:null===(a=e.response)||void 0===a?void 0:a.data)||e),null})];await Promise.all(a),w.default.success("Script updated"),C(!1),h()}catch(t){var e,a;w.default.error((null==t?void 0:null===(a=t.response)||void 0===a?void 0:null===(e=a.data)||void 0===e?void 0:e.detail)||"Save failed")}finally{en(!1)}}},[eo,ed]=(0,l.useState)(!1),[ec,eu]=(0,l.useState)(""),[em,ep]=(0,l.useState)(!1),[ex,eh]=(0,l.useState)(null),ef=async()=>{var e,a,t;if(ec.trim()&&(null==d?void 0:d.pipeline_id)){ep(!0),eh(null);try{let a=await N.api.post("/quick-demo/pipeline/".concat(d.pipeline_id,"/ai-assist"),{instruction:ec,greeting:V,qualification_questions:Z,ai_instructions:L,product_context:K});eh((null===(e=a.data)||void 0===e?void 0:e.suggested)||null)}catch(e){w.default.error((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.detail)||"AI Assist failed")}finally{ep(!1)}}},eg=async()=>{var e,a,t;if(!ex)return;
1let s=ex.greeting||V,l=(null===(e=ex.qualification_questions)||void 0===e?void 0:e.length)?ex.qualification_questions:Z,n=ex.ai_instructions||L,i=ex.product_context||K;if(B(s),E(l),M(n),H(i),eh(null),eu(""),ed(!1),!(null==d?void 0:d.pipeline_id)){w.default.success("Applied");return}en(!0);try{let e={agent_name:S,company_name:D,language:z,voice_type:P,qualification_questions:l.filter(e=>e.trim()),greeting_template:s,closing_message:Q,ai_instructions:n,product_context:i,llm_model:U,advanced_voice_settings:{temperature:O,voice_speed:Y,turn_timeout:$,optimize_streaming_latency:ee,auto_mode:et}};await Promise.all([N.api.put("/lead-pipelines/".concat(d.pipeline_id,"/ai-calling-settings?workspace_id=").concat(encodeURIComponent(f)),e),N.api.put("/ai-voice/settings",e).catch(()=>null)]),w.default.success("AI applied \xb7 saved"),C(!1),h()}catch(e){w.default.error((null==e?void 0:null===(t=e.response)||void 0===t?void 0:null===(a=t.data)||void 0===a?void 0:a.detail)||"Auto-save failed â click Save manually")}finally{en(!1)}},[eb,ev]=(0,l.useState)(""),[ej,ey]=(0,l.useState)(!1),[eN,ew]=(0,l.useState)("pipecat_sip"),ek=!["elevenlabs","studio"].includes(eN),[e_,eC]=(0,l.useState)("priya"),[eS,eA]=(0,l.useState)("oO7sLA3dWfQXsKeSAjpA"),[eD,eI]=(0,l.useState)("Aoede"),[ez,eq]=(0,l.useState)("ml-IN-Chirp3-HD-Kore");(0,l.useEffect)(()=>{ek&&"india"!==g&&b("india")},[ek,g]),(0,l.useEffect)(()=>{let e="sarvam"===eN?e_:"google"===eN?eD:"studio"===eN||"pipecat_sip"===eN||"pipecat_studio"===eN?ez:"elevenlabs"===eN?eS:"";j(eN),k(e)},[eN,e_,eD,ez,eS,j,k]);let eT=async()=>{var e,a,t,s,l,n;let i=eb.trim();if(!i){w.default.error("Enter your phone number to receive the test call");return}if(!/^\+?[1-9]\d{7,14}$/.test(i)){w.default.error("Phone must be E.164 (e.g. +919876543210)");return}if(!(null==d?void 0:d.pipeline_id)){w.default.error("No pipeline selected");return}ey(!0);try{let l="sarvam"===eN?e_:"google"===eN?eD:"studio"===eN||"pipecat_sip"===eN||"pipecat_studio"===eN?ez:"elevenlabs"===eN?eS:void 0,n=await N.api.post("/ai-calls/test-call",{phone_number:i,pipeline_id:d.pipeline_id,provider:eN,telephony:g,voice_id:l,language:z}),r=(null===(a=n.data)||void 0===a?void 0:null===(e=a.conversation_id)||void 0===e?void 0:e.slice(0,8))||(null===(s=n.data)||void 0===s?void 0:null===(t=s.call_sid)||void 0===t?void 0:t.slice(0,8))||"";w.default.success("Test call started â your phone will ring (".concat(r,"â¦)"))}catch(e){w.default.error((null==e?void 0:null===(n=e.response)||void 0===n?void 0:null===(l=n.data)||void 0===l?void 0:l.detail)||"Test call failed")}finally{ey(!1)}},eP=i.filter(e=>e.ai_calling_enabled),eR=0===eP.length;return(0,s.jsxs)("div",{className:"space-y-2 p-3 rounded-md border border-slate-200 dark:border-slate-700 bg-slate-50/40 dark:bg-slate-900/40",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-medium",children:"Pipeline (drives AI Calling script + voice)"}),d&&(0,s.jsx)("button",{type:"button",onClick:p,className:"text-[11px] text-fuchsia-600 hover:underline",children:c?"Hide script":"Preview script"})]}),eR?(0,s.jsxs)("div",{className:"text-xs p-2 rounded bg-amber-50 dark:bg-amber-900/20 text-amber-800 dark:text-amber-200",children:["No pipeline in this workspace has AI Calling enabled. Open ",(0,s.jsx)("b",{children:"Settings â Pipelines â AI Calling"}),", enable it on at least one pipeline, then come back."]}):(0,s.jsxs)(y.Ph,{value:r,onValueChange:o,children:[(0,s.jsx)(y.i4,{className:"h-9 text-sm",children:(0,s.jsx)(y.ki,{})}),(0,s.jsxs)(y.Bw,{children:[(0,s.jsxs)(y.Ql,{value:"__auto__",children:["Auto â first eligible (",(null===(a=eP[0])||void 0===a?void 0:a.name)||"â",")"]}),i.map(e=>(0,s.jsxs)(y.Ql,{value:e.id,disabled:!e.ai_calling_enabled,children:[e.name,!e.ai_calling_enabled&&(0,s.jsx)("span",{className:"text-slate-400 ml-1",children:"(AI Calling off)"})]},e.id))]})]}),d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 text-[11px]",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Agent"}),(0,s.jsx)("div",{className:"font-medium truncate",children:d.agent_name||"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Company"}),(0,s.jsx)("div",{className:"font-medium truncate",children:d.company_name||"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Language"}),(0,s.jsx)("div",{className:"font-medium",children:d.language||"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Voice"}),(0,s.jsx)("div",{className:"font-medium truncate",children:d.voice_type||"â"})]})]}),_?(0,s.jsxs)("div",{className:"space-y-2 text-[11px]",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)("label",{className:"text-slate-500",children:"Agent name"}),(0,s.jsx)("input",{type:"text",value:S,onChange:e=>A(e.target.value),className:"w-full text-xs h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"Priya"})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)("label",{className:"text-slate-500",children:"Company name"}),(0,s.jsx)("input",{type:"text",value:D,onChange:e=>I(e.target.value),className:"w-full text-xs h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"SocialSelling.AI"})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)("label",{className:"text-slate-500",children:"Language"}),(0,s.jsxs)(y.Ph,{value:z||"en",onValueChange:q,children:[(0,s.jsx)(y.i4,{className:"h-7 text-xs",children:(0,s.jsx)(y.ki,{})}),(0,s.jsxs)(y.Bw,{children:[(0,s.jsx)(y.Ql,{value:"en",children:"English"}),(0,s.jsx)(y.Ql,{value:"hi",children:"Hindi"}),(0,s.jsx)(y.Ql,{value:"ml",children:"Malayalam"}),(0,s.jsx)(y.Ql,{value:"ta",children:"Tamil"}),(0,s.jsx)(y.Ql,{value:"te",children:"Telugu"}),(0,s.jsx)(y.Ql,{value:"kn",children:"Kannada"}),(0,s.jsx)(y.Ql,{value:"mr",children:"Marathi"}),(0,s.jsx)(y.Ql,{value:"bn",children:"Bengali"}),(0,s.jsx)(y.Ql,{value:"gu",children:"Gujarati"}),(0,s.jsx)(y.Ql,{value:"pa",children:"Punjabi"})]})]})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsx)("label",{className:"text-slate-500",children:"Voice"}),(0,s.jsxs)(y.Ph,{value:P||"lily_female_demo",onValueChange:R,children:[(0,s.jsx)(y.i4,{className:"h-7 text-xs",children:(0,s.jsx)(y.ki,{})}),(0,s.jsxs)(y.Bw,{children:[(0,s.jsx)(y.Ql,{value:"lily_female_demo",children:"Lily \xb7 female \xb7 British (best for Malayalam â proven)"}),(0,s.jsx)(y.Ql,{value:"liam_male",children:"Liam \xb7 male \xb7 American (proven default)"}),(0,s.jsx)(y.Ql,{value:"sia_female",children:"Sia \xb7 female \xb7 Indian English (sales-professional)"}),(0,s.jsx)(y.Ql,{value:"viraj_male",children:"Viraj \xb7 male \xb7 Hindi (energetic narrator)"})]})]})]})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Greeting (uses ","{{lead_name}}"," placeholder)"]}),(0,s.jsx)("textarea",{value:V,onChange:e=>B(e.target.value),rows:2,className:"w-full text-xs px-2 py-1.5 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"Hello {{lead_name}}, this is â¦"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Qualification questions (",Z.length,")"]}),(0,s.jsx)("button",{type:"button",onClick:()=>E(e=>[...e,""]),className:"text-[11px] text-fuchsia-600 hover:underline",children:"+ Add"})]}),Z.map((e,a)=>(0,s.jsxs)("div",{className:"flex items-start gap-1",children:[(0,s.jsxs)("span",{className:"text-slate-400 text-[11px] mt-1.5 w-4 text-right",children:[a+1,"."]}
1),(0,s.jsx)("textarea",{value:e,onChange:e=>E(t=>t.map((t,s)=>s===a?e.target.value:t)),rows:1,className:"flex-1 text-xs px-2 py-1 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"What's your timeline?"}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("button",{type:"button",onClick:()=>E(e=>a>0?[...e.slice(0,a-1),e[a],e[a-1],...e.slice(a+1)]:e),disabled:0===a,className:"text-slate-400 hover:text-fuchsia-600 disabled:opacity-30 text-xs leading-none px-1",children:"â"}),(0,s.jsx)("button",{type:"button",onClick:()=>E(e=>a<e.length-1?[...e.slice(0,a),e[a+1],e[a],...e.slice(a+2)]:e),disabled:a===Z.length-1,className:"text-slate-400 hover:text-fuchsia-600 disabled:opacity-30 text-xs leading-none px-1",children:"â"})]}),(0,s.jsx)("button",{type:"button",onClick:()=>E(e=>e.filter((e,t)=>t!==a)),className:"text-rose-500 hover:text-rose-700 text-xs leading-none px-1 mt-1.5",children:"â"})]},a))]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Sign-off message (spoken after the last question â supports ","{{lead_name}}",", ","{{agent_name}}",", ","{{company_name}}",")"]}),(0,s.jsx)("textarea",{value:Q,onChange:e=>F(e.target.value),rows:2,className:"w-full text-xs px-2 py-1.5 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"Thank you {{lead_name}} for your time! We'll contact you soon. Goodbye!"})]}),(0,s.jsxs)("details",{className:"space-y-1",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-slate-500 hover:text-fuchsia-600",children:"More fields (product context, AI instructions)"}),(0,s.jsxs)("div",{className:"space-y-1 mt-1",children:[(0,s.jsx)("label",{className:"text-slate-500",children:"Product context (background facts)"}),(0,s.jsx)("textarea",{value:K,onChange:e=>H(e.target.value),rows:3,className:"w-full text-xs px-2 py-1.5 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"What we sell, key features, pricing tiersâ¦"}),(0,s.jsx)("label",{className:"text-slate-500",children:"AI instructions (custom rules)"}),(0,s.jsx)("textarea",{value:L,onChange:e=>M(e.target.value),rows:3,className:"w-full text-xs px-2 py-1.5 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",placeholder:"- Be friendly and conversational - Don't quote exact pricing"})]})]}),(0,s.jsxs)("details",{className:"space-y-1",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-slate-500 hover:text-fuchsia-600",children:"Advanced tuning (LLM, voice, latency)"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2 mt-1",children:[(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Temperature (",O.toFixed(2),")"]}),(0,s.jsx)("input",{type:"range",min:0,max:1,step:.05,value:O,onChange:e=>W(parseFloat(e.target.value)),className:"w-full accent-fuchsia-600"})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Voice speed (",Y.toFixed(2),"\xd7)"]}),(0,s.jsx)("input",{type:"range",min:.7,max:1.3,step:.05,value:Y,onChange:e=>X(parseFloat(e.target.value)),className:"w-full accent-fuchsia-600"})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Turn timeout (",$.toFixed(1),"s)"]}),(0,s.jsx)("input",{type:"range",min:1,max:6,step:.5,value:$,onChange:e=>J(parseFloat(e.target.value)),className:"w-full accent-fuchsia-600"})]}),(0,s.jsxs)("div",{className:"space-y-0.5",children:[(0,s.jsxs)("label",{className:"text-slate-500",children:["Streaming latency (",ee," of 4)"]}),(0,s.jsx)("input",{type:"range",min:0,max:4,step:1,value:ee,onChange:e=>ea(parseInt(e.target.value)),className:"w-full accent-fuchsia-600"})]}),(0,s.jsx)("div",{className:"space-y-0.5",children:(0,s.jsxs)("label",{className:"text-slate-500 flex items-center gap-1",children:[(0,s.jsx)("input",{type:"checkbox",checked:et,onChange:e=>es(e.target.checked),className:"w-3 h-3 accent-fuchsia-600"}),"Smart turn detection (auto barge-in)"]})})]}),(0,s.jsx)("p",{className:"text-[10px] text-slate-500 pt-1",children:"Defaults are the production tuned values. Lower turn-timeout = snappier replies. Higher temperature = more natural variation but less predictable."})]}),eo?(0,s.jsxs)("div",{className:"space-y-2 p-2 rounded border border-fuchsia-200 dark:border-fuchsia-800 bg-fuchsia-50/40 dark:bg-fuchsia-950/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(x.Z,{className:"w-3.5 h-3.5 text-fuchsia-600"}),(0,s.jsx)("span",{className:"text-[11px] font-medium",children:"AI Assist"}),(0,s.jsx)("button",{type:"button",onClick:()=>{ed(!1),eh(null)},className:"ml-auto text-[10px] text-slate-500 hover:text-rose-500",children:"Close"})]}),(0,s.jsx)("textarea",{value:ec,onChange:e=>eu(e.target.value),rows:2,placeholder:"e.g. Make it more friendly \xb7 Add EMI questions \xb7 Translate to Hindi \xb7 Keep it under 90 seconds total",className:"w-full text-xs px-2 py-1.5 rounded border border-fuchsia-200 dark:border-fuchsia-800 bg-white dark:bg-slate-900 focus:border-fuchsia-500 focus:outline-none"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:["Make it more friendly","Add EMI options question","Translate to Hindi","Keep it under 90 seconds","Sound less salesy"].map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>eu(e),className:"text-[10px] px-1.5 py-0.5 rounded bg-fuchsia-100 dark:bg-fuchsia-900/40 text-fuchsia-700 dark:text-fuchsia-300 hover:bg-fuchsia-200 dark:hover:bg-fuchsia-900/60",children:e},e))}),(0,s.jsxs)(v.z,{size:"sm",disabled:em||!ec.trim(),onClick:ef,className:"bg-fuchsia-600 hover:bg-fuchsia-700 text-white",children:[em?(0,s.jsx)(u.Z,{className:"w-3 h-3 mr-1 animate-spin"}):(0,s.jsx)(x.Z,{className:"w-3 h-3 mr-1"}),"Generate"]}),ex&&(0,s.jsxs)("div",{className:"space-y-1.5 mt-1 p-2 rounded bg-white dark:bg-slate-900 border border-fuchsia-200 dark:border-fuchsia-800",children:[(0,s.jsx)("div",{className:"text-[11px] font-medium text-fuchsia-700 dark:text-fuchsia-300",children:"Suggested rewrite:"}),ex.greeting&&(0,s.jsxs)("div",{className:"text-[11px]",children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Greeting:"}),(0,s.jsxs)("div",{className:"italic mt-0.5",children:['"',ex.greeting,'"']})]}),(null===(n=ex.qualification_questions)||void 0===n?void 0:n.length)>0&&(0,s.jsxs)("div",{className:"text-[11px]",children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Questions:"}),(0,s.jsx)("ol",{className:"list-decimal ml-4 mt-0.5",children:ex.qualification_questions.map((e,a)=>(0,s.jsx)("li",{children:e},a))})]}),ex.ai_instructions&&(0,s.jsxs)("details",{className:"text-[11px]",children:[(0,s.jsx)("summary",{className:"cursor-pointer text-slate-500 hover:text-fuchsia-600",children:"Show AI instructions + product context"}),(0,s.jsx)("pre",{className:"text-[10px] whitespace-pre-wrap mt-1",children:ex.ai_instructions}),ex.product_context&&(0,s.jsx)("pre",{className:"text-[10px] whitespace-pre-wrap mt-1 text-slate-600",children:ex.product_context})]}),(0,s.jsxs)("div",{className:"flex gap-2 pt-1",children:[(0,s.jsx)(v.z,{size:"sm",onClick:eg,className:"bg-emerald-600 hover:bg-emerald-700 text-white",children:"Apply to draft"}),(0,s.jsx)(v.z,{size:"sm",variant:"ghost",onClick:()=>eh(null),children:"Discard"})]})]})]}):(0,s.jsxs)("button",{type:"button",onClick:()=>ed(!0),className:"inline-flex items-center gap-1 text-[11px] px-2 py-1 rounded border border-fuchsia-200 dark:border-fuchsia-800 text-fuchsia-700 dark:text-fuchsia-300 hover:bg-fuchsia-50 dark:hover:bg-fuchsia-900/20",children:[(0,s.jsx)(x.Z,{className:"w-3 h-3"}),"AI Assist (rewrite this script)"]}),ei.length>0&&(0,s.jsxs)("div",{className:"text-[11px] p-2 rounded bg-amber-50 dark:bg-amber-900/20 text-amber-800 dark:text-amber-200",children:[(0,s.jsx)("div",{className:"font-medium mb-0.5",children:"Heads-up before saving:"}),(0,s.jsx)("ul",{className:"list-disc ml-4 space-y-0.5",children:ei.map((e,a)=>(0,s.jsx)("li",{children:e},a))})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(v.z,{size:"sm",disabled:el,onClick:er,className:"bg-fuchsia-600 hover:bg-fuchsia-700 text-white",children:[el?(0,s.jsx)(u.Z,{className:"w-3 h-3 mr-1 animate-spin"}):null,"Save"]}),(0,s.jsx)(v.z,{size:"sm",variant:"ghost",disabled:el,onClick:()=>C(!1),children:"Cancel"})]})]}):(0,s.jsxs)(s.Fragment,{children:[d.greeting_template&&(0,s.jsxs)("div",{className:"text-[11px]",children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Greeting:"})," ",(0,s.jsxs)("span",{className:"italic",children:['"',d.greeting_template,'"']})]}),(null===(t=d.qualification_questions)||void 0===t?void 0:t.length)>0?(0,s.jsxs)("div",{className:"text-[11px]",children:[(0,s.jsxs)("span",{className:"text-slate-500",children:["Questions (",d.qual
1ification_questions.length,"):"]}),(0,s.jsx)("ol",{className:"list-decimal ml-4 mt-0.5",children:d.qualification_questions.map((e,a)=>(0,s.jsx)("li",{children:e},a))})]}):(0,s.jsx)("div",{className:"text-[11px] text-slate-500 italic",children:"No qualification questions configured."}),d.closing_message?(0,s.jsxs)("div",{className:"text-[11px]",children:[(0,s.jsx)("span",{className:"text-slate-500",children:"Sign-off:"})," ",(0,s.jsxs)("span",{className:"italic",children:['"',d.closing_message,'"']})]}):(0,s.jsx)("div",{className:"text-[11px] text-slate-500 italic",children:"No sign-off configured â agent will improvise a goodbye."}),(0,s.jsxs)("div",{className:"flex items-center gap-3 text-[11px]",children:[(0,s.jsx)("button",{type:"button",onClick:()=>C(!0),className:"text-fuchsia-600 hover:underline",children:"Edit script"}),(0,s.jsx)("span",{className:"text-slate-300",children:"\xb7"}),(0,s.jsx)("a",{href:"/dashboard/leads?pipeline_id=".concat(d.pipeline_id,"&view=pipeline&action=ai-calling-settings"),target:"_blank",rel:"noopener noreferrer",className:"text-slate-500 hover:text-fuchsia-600",children:"Open full Pipeline AI Settings â"})]})]}),(0,s.jsxs)("div",{className:"border-t border-slate-200 dark:border-slate-700 pt-2 mt-2 space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,s.jsx)(m.Z,{className:"w-3.5 h-3.5 text-fuchsia-600"}),(0,s.jsx)("span",{className:"text-[11px] text-slate-500",children:"Voice:"}),(0,s.jsxs)("select",{value:eN,onChange:e=>ew(e.target.value),className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",children:[(0,s.jsx)("option",{value:"elevenlabs",children:"â¡ Premium"}),(0,s.jsx)("option",{value:"studio",children:"\uD83D\uDCFB Studio"}),(0,s.jsx)("option",{value:"pipecat_sip",children:"\uD83D\uDEF0ï¸ Studio SIP (no ring)"}),(0,s.jsx)("option",{value:"google",children:"\uD83D\uDD2E Realtime"}),(0,s.jsx)("option",{value:"deepgram",disabled:!0,children:"\uD83D\uDEA7 Beta (soon)"})]}),"elevenlabs"===eN&&(0,s.jsx)("select",{value:eS,onChange:e=>eA(e.target.value),title:"Speaker â switch and click Call me to A/B compare",className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",children:[{id:"oO7sLA3dWfQXsKeSAjpA",label:"Sia â warm female (default)"},{id:"9BWtsMINqrJLrRacOk9x",label:"Aria â clear female"},{id:"EXAVITQu4vr4xnSDxMaL",label:"Sarah â soft female"},{id:"cgSgspJ2msm6clMCkdW9",label:"Jessica â friendly female"},{id:"XB0fDUnXU5powFXDhCwa",label:"Charlotte â mature female"},{id:"IKne3meq5aSn9XLyUdCD",label:"Charlie â friendly male"},{id:"iP95p4xoKVk53GoZ742B",label:"Chris â neutral male"},{id:"nPczCjzI2devNBz1zQrb",label:"Brian â warm male"}].map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),"sarvam"===eN&&(0,s.jsx)("select",{value:e_,onChange:e=>eC(e.target.value),title:"Speaker â switch and click Call me to A/B compare",className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",children:[{id:"priya",label:"Priya â warm female (default)"},{id:"neha",label:"Neha â energetic female"},{id:"shreya",label:"Shreya â mature female"},{id:"kavya",label:"Kavya â friendly female"},{id:"suhani",label:"Suhani â sweet female"},{id:"kavitha",label:"Kavitha â South-Indian female"},{id:"shubh",label:"Shubh â neutral male (default)"},{id:"aditya",label:"Aditya â confident male"},{id:"rahul",label:"Rahul â friendly male"},{id:"gokul",label:"Gokul â Kerala male"}].map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),("studio"===eN||"pipecat_sip"===eN||"pipecat_studio"===eN)&&(0,s.jsx)("select",{value:ez,onChange:e=>eq(e.target.value),title:"Speaker â Chirp 3 HD generative voices, falls back to Wavenet if HD unavailable",className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",children:[{id:"ml-IN-Chirp3-HD-Aoede",label:"â¡ Aoede HD â bright female (Chirp 3, fast)"},{id:"ml-IN-Chirp3-HD-Charon",label:"â¡ Charon HD â deep male (Chirp 3, fast)"},{id:"ml-IN-Wavenet-A",label:"â¡ Wavenet A â female (basic, very fast fallback)"},{id:"Aoede",label:"⨠Aoede â bright female (Gemini-TTS, slower, emotion tags)"},{id:"Kore",label:"⨠Kore â clear female (Gemini-TTS, slower, emotion tags)"},{id:"Leda",label:"⨠Leda â soft female (Gemini-TTS, slower, emotion tags)"},{id:"Charon",label:"⨠Charon â deep male (Gemini-TTS, slower, emotion tags)"},{id:"Puck",label:"⨠Puck â energetic male (Gemini-TTS, slower, emotion tags)"},{id:"Fenrir",label:"⨠Fenrir â strong male (Gemini-TTS, slower, emotion tags)"}].map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),"google"===eN&&(0,s.jsx)("select",{value:eD,onChange:e=>eI(e.target.value),title:"Speaker â switch and click Call me to A/B compare",className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none",children:[{id:"Aoede",label:"Aoede â bright female (default)"},{id:"Kore",label:"Kore â clear female"},{id:"Leda",label:"Leda â soft female"},{id:"Zephyr",label:"Zephyr â breezy female"},{id:"Charon",label:"Charon â deep male"},{id:"Fenrir",label:"Fenrir â strong male"},{id:"Orus",label:"Orus â warm male"},{id:"Puck",label:"Puck â energetic male"}].map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))}),(0,s.jsx)("span",{className:"text-[11px] text-slate-500 ml-1",children:"Region:"}),(0,s.jsxs)("select",{value:g,onChange:e=>b(e.target.value),disabled:ek,title:ek?"This voice is India-only":"",className:"text-[11px] h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none disabled:opacity-60",children:[(0,s.jsx)("option",{value:"international",children:"\uD83C\uDF0D International"}),(0,s.jsx)("option",{value:"india",children:"\uD83C\uDDEE\uD83C\uDDF3 India"})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(m.Z,{className:"w-3.5 h-3.5 text-fuchsia-600"}),(0,s.jsx)("span",{className:"text-[11px] text-slate-500 mr-1",children:"Test call:"}),(0,s.jsx)("input",{type:"tel",value:eb,onChange:e=>ev(e.target.value),placeholder:"+91â¦",className:"flex-1 text-xs h-7 px-2 rounded border border-slate-200 dark:border-slate-700 bg-transparent focus:border-fuchsia-500 focus:outline-none font-mono"}),(0,s.jsxs)(v.z,{size:"sm",disabled:ej||!eb||_,onClick:eT,className:"h-7 text-[11px] bg-emerald-600 hover:bg-emerald-700 text-white",title:_?"Save script changes first":"",children:[ej?(0,s.jsx)(u.Z,{className:"w-3 h-3 mr-1 animate-spin"}):null,"Call me"]})]})]}),c&&(0,s.jsx)("div",{className:"mt-2 max-h-64 overflow-y-auto rounded bg-slate-900 text-slate-100 p-3 text-[11px] font-mono whitespace-pre-wrap",children:d.rendered_system_prompt})]})]})}function D(e){let{label:a,value:t,cols:l,onChange:n,required:i}=e;return(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("label",{className:"text-xs font-medium ".concat(i&&!t?"text-rose-600":""),children:a}),(0,s.jsxs)(y.Ph,{value:t||"__none__",onValueChange:e=>n("__none__"===e?"":e),children:[(0,s.jsx)(y.i4,{className:"h-8 text-xs",children:(0,s.jsx)(y.ki,{})}),(0,s.jsxs)(y.Bw,{children:[(0,s.jsx)(y.Ql,{value:"__none__",children:(0,s.jsx)("span",{className:"text-slate-400",children:"â none â"})}),l.map(e=>(0,s.jsx)(y.Ql,{value:e,children:function(e){let a=/^__EMPTY(?:_(\d+))?$/.exec(e);if(!a)return e;let t=a[1]?parseInt(a[1],10)+1:1;return"Column ".concat(t," (no header)")}(e)},e))]})]})]})}function I(e){let{progress:a,onRunAnother:t,onClose:l}
1=e,n=a.counts,i=a.classification_counts;return(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-5 gap-2",children:[(0,s.jsx)(q,{label:"Total",value:String(n.total),tone:"idle"}),(0,s.jsx)(q,{label:"Queued",value:String(n.queued),tone:n.queued>0?"warn":"idle"}),(0,s.jsx)(q,{label:"Calling",value:String(n.calling),tone:n.calling>0?"live":"idle"}),(0,s.jsx)(q,{label:"Done",value:String(n.completed),tone:"ok"}),(0,s.jsx)(q,{label:"Avg score",value:null!=a.avg_score?"".concat(a.avg_score):"â",tone:"idle"})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-rose-100 text-rose-700 dark:bg-rose-900/30 dark:text-rose-200",children:["\uD83D\uDD25 hot ",i.hot]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-200",children:["âï¸ warm ",i.warm]}),(0,s.jsxs)("span",{className:"px-2 py-0.5 rounded-full bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200",children:["âï¸ cold ",i.cold]}),!a.is_complete&&(0,s.jsxs)("span",{className:"ml-auto inline-flex items-center gap-1 text-slate-500",children:[(0,s.jsx)(u.Z,{className:"w-3 h-3 animate-spin"})," live"]}),a.is_complete&&(0,s.jsxs)("span",{className:"ml-auto inline-flex items-center gap-1 text-emerald-600",children:[(0,s.jsx)(h.Z,{className:"w-3 h-3"})," all calls complete"]})]}),(0,s.jsx)("div",{className:"border border-slate-200 dark:border-slate-700 rounded-md overflow-hidden",children:(0,s.jsx)("div",{className:"max-h-72 overflow-y-auto text-xs divide-y divide-slate-100 dark:divide-slate-800",children:a.items.map(e=>(0,s.jsx)(z,{item:e},e.lead_id))})}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 items-center",children:[(0,s.jsxs)(v.z,{variant:"outline",size:"sm",onClick:t,children:[(0,s.jsx)(f.Z,{className:"w-3.5 h-3.5 mr-1"})," Run another"]}),a.pipeline_id&&(0,s.jsx)("a",{href:"/dashboard/leads?pipeline_id=".concat(a.pipeline_id,"&view=kanban"),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 px-3 h-8 text-xs rounded border border-fuchsia-300 dark:border-fuchsia-700 text-fuchsia-700 dark:text-fuchsia-300 hover:bg-fuchsia-50 dark:hover:bg-fuchsia-900/20",children:"Open Kanban"}),(0,s.jsx)(v.z,{size:"sm",onClick:l,className:"ml-auto",children:"Close"})]})]})}function z(e){let{item:a}=e,t={queued:"bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-200",calling:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200",completed:"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-200",failed:"bg-rose-100 text-rose-700 dark:bg-rose-900/30 dark:text-rose-200",no_phone:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-200"}[a.status],l="hot"===a.classification?"bg-rose-100 text-rose-700 dark:bg-rose-900/30 dark:text-rose-200":"warm"===a.classification?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-200":"cold"===a.classification?"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200":"";return(0,s.jsxs)("div",{className:"px-3 py-2 grid grid-cols-12 gap-2 items-center",children:[(0,s.jsxs)("div",{className:"col-span-3 truncate",children:[(0,s.jsx)("div",{className:"font-medium truncate",children:a.name||"â"}),(0,s.jsx)("div",{className:"text-[10px] text-slate-500 truncate",children:a.phone||"no phone"})]}),(0,s.jsx)("div",{className:"col-span-2",children:(0,s.jsxs)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium ".concat(t),children:["calling"===a.status&&(0,s.jsx)(u.Z,{className:"w-2.5 h-2.5 inline animate-spin mr-0.5"}),a.status]})}),(0,s.jsx)("div",{className:"col-span-2",children:null!=a.score?(0,s.jsx)("span",{className:"font-semibold tabular-nums",children:a.score}):(0,s.jsx)("span",{className:"text-slate-400",children:"â"})}),(0,s.jsx)("div",{className:"col-span-2",children:a.classification&&(0,s.jsx)("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium ".concat(l),children:a.classification})}),(0,s.jsxs)("div",{className:"col-span-3 text-[10px] text-slate-500",title:a.ai_summary||"",children:[a.stage_name&&(0,s.jsxs)("div",{className:"inline-flex items-center gap-1 truncate mb-0.5",children:[(0,s.jsx)("span",{className:"text-slate-400",children:"â"}),(0,s.jsx)("span",{className:"font-medium text-slate-700 dark:text-slate-200 truncate",children:a.stage_name})]}),a.conversation_id?(0,s.jsx)("audio",{controls:!0,preload:"none",src:"/api/calls/elevenlabs/audio/".concat(a.conversation_id),className:"h-6 w-full max-w-[200px]",title:a.ai_summary||"".concat(a.duration_seconds||0,"s call")}):!a.stage_name&&(0,s.jsx)("span",{className:"truncate",children:a.ai_summary||(a.duration_seconds?"".concat(a.duration_seconds,"s"):"")})]})]})}function q(e){let{label:a,value:t,tone:l}=e;return(0,s.jsxs)("div",{className:"rounded-md border p-2 ".concat("live"===l?"border-blue-300 bg-blue-50 dark:border-blue-700 dark:bg-blue-900/30":"warn"===l?"border-amber-300 bg-amber-50 dark:border-amber-700 dark:bg-amber-900/30":"ok"===l?"border-emerald-300 bg-emerald-50 dark:border-emerald-700 dark:bg-emerald-900/30":"border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900"),children:[(0,s.jsx)("div",{className:"text-[10px] text-slate-500 dark:text-slate-400 uppercase tracking-wide",children:a}),(0,s.jsx)("div",{className:"text-lg font-bold tabular-nums",children:t})]})}},12381:function(e,a,t){"use strict";t.d(a,{d:function(){return o},z:function(){return d}});var s=t(57437),l=t(2265),n=t(37053),i=t(90535),r=t(93448);let o=(0,i.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"}}),d=l.forwardRef((e,a)=>{let{className:t,variant:l,size:i,asChild:d=!1,...c}=e,u=d?n.g7:"button";return(0,s.jsx)(u,{className:(0,r.cn)(o({variant:l,size:i,className:t})),ref:a,...c})});d.displayName="Button"},79820:function(e,a,t){"use strict";t.d(a,{Ol:function(){return r},SZ:function(){return d},Zb:function(){return i},aY:function(){return c},eW:function(){return u},ll:function(){return o}});var s=t(57437),l=t(2265),n=t(93448);let i=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("rounded-[4px] border bg-card text-card-foreground shadow",t),...l})});
1i.displayName="Card";let r=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("flex flex-col space-y-1.5 p-6",t),...l})});r.displayName="CardHeader";let o=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("font-display font-semibold leading-none tracking-tight",t),...l})});o.displayName="CardTitle";let d=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("text-sm text-muted-foreground",t),...l})});d.displayName="CardDescription";let c=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("p-6 pt-0",t),...l})});c.displayName="CardContent";let u=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)("div",{ref:a,className:(0,n.cn)("flex items-center p-6 pt-0",t),...l})});u.displayName="CardFooter"},74291:function(e,a,t){"use strict";t.d(a,{$N:function(){return h},Be:function(){return f},Vq:function(){return o},cN:function(){return x},cZ:function(){return m},fK:function(){return p},hg:function(){return d}});var s=t(57437),l=t(2265),n=t(49027),i=t(93448),r=t(20653);let o=n.fC,d=n.xz,c=n.h_;n.x8;let u=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.aV,{ref:a,className:(0,i.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...l})});u.displayName=n.aV.displayName;let m=l.forwardRef((e,a)=>{let{className:t,children:l,overlayClassName:o,...d}=e;return(0,s.jsxs)(c,{children:[(0,s.jsx)(u,{className:o}),(0,s.jsxs)(n.VY,{ref:a,className:(0,i.cn)("fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200","w-[calc(100%-1rem)] xs:w-[calc(100%-2rem)] sm:w-full max-w-lg","p-4 sm:p-6","max-h-[90vh] sm:max-h-[85vh]","rounded-lg sm:rounded-lg","flex flex-col","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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...d,children:[l,(0,s.jsxs)(n.x8,{className:"absolute right-3 top-3 sm:right-4 sm:top-4 z-50 rounded-full opacity-70 ring-offset-background transition-all hover:opacity-100 hover:bg-gray-100 dark:hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground bg-white dark:bg-gray-900 shadow-md border border-gray-200 dark:border-gray-700 p-1.5",children:[(0,s.jsx)(r.Pxu,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});m.displayName=n.VY.displayName;let p=e=>{let{className:a,...t}=e;return(0,s.jsx)("div",{className:(0,i.cn)("flex flex-col space-y-1.5 text-center sm:text-left flex-shrink-0",a),...t})};p.displayName="DialogHeader";let x=e=>{let{className:a,...t}=e;return(0,s.jsx)("div",{className:(0,i.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 flex-shrink-0 mt-4",a),...t})};x.displayName="DialogFooter";let h=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.Dx,{ref:a,className:(0,i.cn)("font-display text-lg font-semibold leading-none tracking-tight",t),...l})});h.displayName=n.Dx.displayName;let f=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.dk,{ref:a,className:(0,i.cn)("text-sm text-muted-foreground",t),...l})});f.displayName=n.dk.displayName},40279:function(e,a,t){"use strict";t.d(a,{I:function(){return i}});var s=t(57437),l=t(2265),n=t(93448);let i=l.forwardRef((e,a)=>{let{className:t,type:l,error:i,...r}=e;return(0,s.jsx)("input",{type:l,"aria-invalid":i?"true":void 0,className:(0,n.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",i&&"border-red-500 focus-visible:ring-red-500",t),ref:a,...r})});i.displayName="Input"},15291:function(e,a,t){"use strict";t.d(a,{Bw:function(){return p},DI:function(){return c},Ph:function(){return d},Ql:function(){return h},i4:function(){return m},ki:function(){return u},n5:function(){return x}});var s=t(57437),l=t(2265),n=t(56873),i=t(40875),r=t(30401),o=t(93448);let d=n.fC,c=n.ZA,u=n.B4,m=l.forwardRef((e,a)=>{let{className:t,children:l,...r}=e;return(0,s.jsxs)(n.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",t),...r,children:[l,(0,s.jsx)(n.JO,{asChild:!0,children:(0,s.jsx)(i.Z,{className:"h-4 w-4 opacity-50"})})]})});m.displayName=n.xz.displayName;let p=l.forwardRef((e,a)=>{let{className:t,children:l,position:i="popper",...r}=e;return(0,s.jsx)(n.h_,{children:(0,s.jsx)(n.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"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:i,...r,children:(0,s.jsx)(n.l_,{className:(0,o.cn)("p-1 max-h-[300px] overflow-y-auto","popper"===i&&"w-full min-w-[var(--radix-select-trigger-width)]"),children:l})})})});p.displayName=n.VY.displayName;let x=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.__,{ref:a,className:(0,o.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...l})});x.displayName=n.__.displayName;let h=l.forwardRef((e,a)=>{let{className:t,children:l,...i}=e;return(0,s.jsxs)(n.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",t),...i,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.wU,{children:(0,s.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,s.jsx)(n.eT,{children:l})]})});h.displayName=n.ck.displayName,l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.Z0,{ref:a,className:(0,o.cn)("-mx-1 my-1 h-px bg-gray-100 dark:bg-gray-700",t),...l})}).displayName=n.Z0.displayName},17168:function(e,a,t){"use strict";t.d(a,{Tabs:function(){return r},TabsContent:function(){return c},TabsList:function(){return o},TabsTrigger:function(){return d}});var s=t(57437),l=t(2265),n=t(20271),i=t(93448);let r=n.fC,o=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.aV,{ref:a,className:(0,i.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",t),...l})});o.displayName=n.aV.displayName;let d=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.xz,{ref:a,className:(0,i.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",t),...l})});d.displayName=n.xz.displayName;let c=l.forwardRef((e,a)=>{let{className:t,...l}=e;return(0,s.jsx)(n.VY,{ref:a,className:(0,i.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",t),...l})});c.displayName=n.VY.displayName},93448:function(e,a,t){"use strict";t.d(a,{cn:function(){return n}});var s=t(61994),l=t(53335);function n(){for(var e=arguments.length,a=Array(e),t=0;t<e;t++)a[t]=arguments[t];return(0,l.m6)((0,s.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.