1import{k as e,v as Ce,w as we,x as ke,y as De,z as Ae,B as Se,O as Te}from"./vendor-radix-D823uugn.js";import{r}from"./vendor-react-glauINiL.js";import{t as g}from"./use-toast-BIsZ-81Z.js";import{u as B,m as Pe,j as Ee,x as Ie}from"./queries-DraX9nMg.js";import{u as H,x as Re,y as ze,z as $e,B as _e}from"./mutations-wrQUKwus.js";import{C as te,a as Me,b as Le,d as Oe}from"./card-DBYplX18.js";import{c as W,X as re,b as P,y as Fe,B as c,E as ne,J as ie,h as He,v as Ue,w as qe,F as Ge}from"./index-B5h3Aqqi.js";import{I as q}from"./input-CV1FZFeV.js";import{S as J,a as K,b as Z,c as Q,d as T}from"./select-8SvDOWqa.js";import{P as Ve}from"./pencil-Bgdkwo-A.js";import{T as Be}from"./trash-2-CrbG-3kR.js";import"./vendor-apollo-CQmIcWCv.js";import"./useIsomorphicLayoutEffect-DfcIdw78.js";import"./vendor-charts-ZOglVwNV.js";const Je=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ke=W("folder",Je);const Ze=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Qe=W("smartphone",Ze);const We=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Xe=W("zap",We);function Ye({...s}){return e.jsx(Ce,{"data-slot":"dialog",...s})}function ea({...s}){return e.jsx(Se,{"data-slot":"dialog-portal",...s})}function aa({className:s,...t}){return e.jsx(Te,{"data-slot":"dialog-overlay",className:P("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",s),...t})}function sa({className:s,children:t,showCloseButton:f=!0,...m}){return e.jsxs(ea,{children:[e.jsx(aa,{}),e.jsxs(we,{"data-slot":"dialog-content",className:P("bg-background 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 fixed top-1/2 left-1/2 z-50 grid w-[calc(100%-2rem)] max-w-md -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl border p-5 slab-raised duration-200",s),...m,children:[t,f&&e.jsxs(ke,{className:"ring-offset-background focus:ring-ring absolute top-4 right-4 cursor-pointer rounded-xs opacity-60 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[e.jsx(re,{className:"size-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ta({className:s,...t}){return e.jsx("div",{"data-slot":"dialog-header",className:P("flex flex-col gap-1.5",s),...t})}function na({className:s,...t}){return e.jsx("div",{"data-slot":"dialog-footer",className:P("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",s),...t})}function la({className:s,...t}){return e.jsx(De,{"data-slot":"dialog-title",className:P("text-foreground text-base font-semibold",s),...t})}function ra({className:s,...t}){return e.jsx(Ae,{"data-slot":"dialog-description",className:P("text-muted-foreground text-sm",s),...t})}const X=[{value:"",label:"Auto-detect"},{value:"eng",label:"English"},{value:"est",label:"Estonian"},{value:"rus",label:"Russian"},{value:"deu",label:"German"},{value:"fra",label:"French"},{value:"spa",label:"Spanish"},{value:"ita",label:"Italian"},{value:"por",label:"Portuguese"},{value:"nld",label:"Dutch"},{value:"pol",label:"Polish"},{value:"fin",label:"Finnish"},{value:"swe",label:"Swedish"},{value:"dan",label:"Danish"},{value:"nor",label:"Norwegian"},{value:"jpn",label:"Japanese"},{value:"zho",label:"Chinese"},{value:"kor",label:"Korean"},{value:"hin",label:"Hindi"},{value:"ara",label:"Arabic"},{value:"tur",label:"Turkish"},{value:"ukr",label:"Ukrainian"},{value:"ces",label:"Czech"},{value:"slk",label:"Slovak"},{value:"hun",label:"Hungarian"},{value:"ron",label:"Romanian"},{value:"bul",label:"Bulgarian"},{value:"hrv",label:"Croatian"},{value:"ell",label:"Greek"},{value:"heb",label:"Hebrew"},{value:"tha",label:"Thai"},{value:"vie",label:"Vietnamese"},{value:"ind",label:"Indonesian"},{value:"lav",label:"Latvian"},{value:"lit",label:"Lithuanian"}];function U(s,t){return{phoneNumber:s.phoneNumber,name:s.name,languageCode:s.languageCode||void 0,defaultProjectId:s.defaultProjectId||void 0,defaultCrmTemplateId:s.defaultCrmTemplateId||void 0,crmAutomationApproved:s.crmAutomationApproved===!0,crmAutomationProvider:s.crmAutomationProvider||"pipedrive",crmAutomationAllowedActions:s.crmAutomationAllowedActions||["create_call_activity","create_follow_up_task","create_meeting_activity"],pipedrivePersonId:s.pipedrivePersonId||void 0,pipedriveDealId:s.pipedriveDealId||void 0,pipedriveOrgId:s.pipedriveOrgId||void 0,...t}}const R="block text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",z="inline-flex max-w-full items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px] leading-tight text-muted-foreground";function le({contact:s,projects:t,crmTemplates:f,className:m}){const o=s.languageCode?X.find(h=>h.value===s.languageCode)?.label??s.languageCode:null,u=s.defaultProjectId?t.find(h=>h.id===s.defaultProjectId)?.name??"Project":null,p=s.defaultCrmTemplateId?f.find(h=>
1h.id===s.defaultCrmTemplateId)?.name??"Template":null,j=s.crmAutomationApproved===!0;return!o&&!u&&!p&&!j&&!s.syncToDevice?null:e.jsxs("div",{className:`min-w-0 flex-wrap items-center gap-1 ${m}`,children:[o&&e.jsxs("span",{className:z,title:`Transcription language: ${o}`,children:[e.jsx(ie,{className:"h-3 w-3 shrink-0 opacity-70"}),e.jsx("span",{className:"uppercase tracking-wide",children:s.languageCode})]}),u&&e.jsxs("span",{className:z,title:`Default project: ${u}`,children:[e.jsx(Ke,{className:"h-3 w-3 shrink-0 opacity-70"}),e.jsx("span",{className:"max-w-24 truncate",children:u})]}),p&&e.jsxs("span",{className:z,title:`CRM template: ${p}`,children:[e.jsx(Ge,{className:"h-3 w-3 shrink-0 opacity-70"}),e.jsx("span",{className:"max-w-24 truncate",children:p})]}),j&&e.jsxs("span",{className:z,title:"Approved for automatic low-risk CRM updates",children:[e.jsx(Xe,{className:"h-3 w-3 shrink-0 opacity-70"}),"CRM"]}),s.syncToDevice&&e.jsxs("span",{className:z,title:"Name and number changes sync to your iPhone contacts",children:[e.jsx(Qe,{className:"h-3 w-3 shrink-0 opacity-70"}),"iPhone"]})]})}const ia=r.memo(function({contact:t,projects:f,crmTemplates:m,isExpanded:o,onToggleExpanded:u,onLanguageChange:p,onDefaultProjectChange:j,onCrmTemplateChange:h,onToggleCrmAutomation:E,onToggleSyncToDevice:$,onRename:N,onRequestDelete:_}){const y=t.crmAutomationApproved===!0,[M,k]=r.useState(!1),[d,A]=r.useState(""),L=`contact-settings-${t.id}`,S=()=>{A(t.name||""),k(!0)},b=()=>{const n=d.trim();n!==(t.name||"")&&N(t,n),k(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`group cursor-pointer border-t border-border/60 transition-colors first:border-t-0 hover:bg-muted/20 ${o?"bg-muted/20":""}`,onClick:()=>u(t.id),children:[e.jsx("td",{className:"py-2 pl-3 pr-0 align-top",children:e.jsxs(c,{type:"button",variant:"ghost",size:"icon-xs","aria-expanded":o,"aria-controls":L,onClick:n=>{n.stopPropagation(),u(t.id)},className:"size-5 text-muted-foreground/60 hover:text-foreground",title:o?"Hide settings":"Show settings",children:[o?e.jsx(He,{className:"size-3.5"}):e.jsx(Ue,{className:"size-3.5"}),e.jsx("span",{className:"sr-only",children:o?"Hide settings":"Show settings"})]})}),e.jsx("td",{className:"px-3 py-2 align-top",children:M?e.jsxs("form",{className:"flex items-center gap-1",onClick:n=>n.stopPropagation(),onSubmit:n=>{n.preventDefault(),n.stopPropagation(),b()},children:[e.jsx(q,{value:d,onChange:n=>A(n.target.value),onKeyDown:n=>{n.key==="Escape"&&k(!1)},placeholder:"Name",className:"h-7 min-w-0 flex-1 text-xs sm:max-w-40",autoFocus:!0}),e.jsxs(c,{type:"submit",variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground hover:text-foreground",title:"Save name",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Save name"})]}),e.jsxs(c,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 text-muted-foreground",onClick:()=>k(!1),title:"Cancel",children:[e.jsx(re,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Cancel"})]})]}):e.jsxs("div",{className:"flex min-w-0 flex-col leading-tight",children:[e.jsxs("span",{className:"flex min-w-0 items-center",children:[e.jsx("span",{className:"truncate font-medium text-foreground",children:t.name||e.jsx("span",{className:"text-muted-foreground italic",children:"Unknown"})}),t.source==="manual"&&e.jsx("span",{className:"ml-1.5 shrink-0 rounded bg-muted px-1 py-0.5 text-[9px] font-medium uppercase tracking-wide text-muted-foreground align-middle",title:"Added in Superscribe. Phone contact syncs will not rename it.",children:"Manual"}),e.jsxs(c,{type:"button",variant:"ghost",size:"icon-xs",className:"ml-1.5 size-4 text-muted-foreground/60 opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100",onClick:n=>{n.stopPropagation(),S()},title:"Edit name",children:[e.jsx(Ve,{className:"h-3 w-3"}),e.jsx("span",{className:"sr-only",children:"Edit name"})]})]}),e.jsx("span",{className:"mt-0.5 truncate font-mono text-[11px] text-muted-foreground sm:hidden",children:t.phoneNumber}),e.jsxs("span",{className:"mt-0.5 text-[10px] text-muted-foreground
1/60",children:["Updated ",new Date(t.updatedAt).toLocaleDateString()]}),e.jsx(le,{contact:t,projects:f,crmTemplates:m,className:"mt-1.5 flex sm:hidden"})]})}),e.jsx("td",{className:"w-0 px-0 py-2 align-top font-mono text-[11px] text-muted-foreground sm:w-auto sm:px-3",children:e.jsx("span",{className:"hidden truncate sm:block",children:t.phoneNumber})}),e.jsx("td",{className:"w-0 px-0 py-2 align-top sm:w-auto sm:px-3",children:e.jsx(le,{contact:t,projects:f,crmTemplates:m,className:"hidden sm:flex"})}),e.jsx("td",{className:"px-3 py-2 text-right align-top",children:e.jsxs(c,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive opacity-70 transition-opacity group-hover:opacity-100",onClick:n=>{n.stopPropagation(),_(t)},title:"Delete contact",children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Delete contact"})]})})]}),o&&e.jsx("tr",{className:"bg-muted/20",children:e.jsx("td",{id:L,colSpan:5,className:"px-3 pb-4 pt-1 sm:pl-11 sm:pr-6",children:e.jsxs("div",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2 xl:grid-cols-3",children:[e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("span",{className:R,children:"Language"}),e.jsxs(J,{value:t.languageCode||"auto",onValueChange:n=>p(t,n),children:[e.jsx(K,{className:"h-8 w-full text-xs",children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(T,{value:"auto",children:"Auto-detect"}),X.filter(n=>n.value).map(n=>e.jsx(T,{value:n.value,children:n.label},n.value))]})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("span",{className:R,children:"Default Project"}),e.jsxs(J,{value:t.defaultProjectId||"none",onValueChange:n=>j(t,n),children:[e.jsx(K,{className:"h-8 w-full text-xs",children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(T,{value:"none",children:"No default project"}),f.map(n=>e.jsx(T,{value:n.id,children:n.name},n.id))]})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("span",{className:R,children:"CRM Template"}),e.jsxs(J,{value:t.defaultCrmTemplateId||"none",onValueChange:n=>h(t,n),children:[e.jsx(K,{className:"h-8 w-full text-xs",children:e.jsx(Z,{})}),e.jsxs(Q,{children:[e.jsx(T,{value:"none",children:"Use integration default"}),m.map(n=>e.jsx(T,{value:n.id,children:n.enabled?n.name:`${n.name} (off)`},n.id))]})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("span",{className:R,children:"Auto CRM"}),e.jsxs("div",{className:"flex items-start gap-2 pt-0.5",children:[e.jsxs("button",{type:"button",role:"switch","aria-checked":y,onClick:()=>E(t),className:`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors ${y?"border-primary/40 bg-primary":"border-border bg-muted"}`,title:y?"Approved for automatic low-risk CRM updates":"Unapproved calls will queue for CRM review",children:[e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-background shadow-sm transition-transform ${y?"translate-x-5":"translate-x-1"}`}),e.jsx("span",{className:"sr-only",children:"Toggle automatic CRM updates"})]}),e.jsx("p",{className:"text-[11px] leading-tight text-muted-foreground",children:y?"Low-risk CRM updates sync automatically after calls":"Calls queue for CRM review instead of auto-syncing"})]})]}),e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsx("span",{className:R,children:"iPhone Sync"}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 pt-0.5",title:t.syncToDevice?"Name and number changes sync to your iPhone contacts":"Edits stay in Superscribe unless synced",children:[e.jsx("input",{type:"checkbox",checked:t.syncToDevice,onChange:()=>$(t),className:"mt-0.5 h-3.5 w-3.5 shrink-0 cursor-pointer accent-primary"}),e.jsx("span",{className:"text-[11px] leading-tight text-muted-foreground",children:"Sync name and number to your iPhone contacts"})]}),t.source!=="manual"&&!t.syncToDevice&&e.jsx("p",{className:"text-[11px] leading-tight text-muted-foreground/60",children:"Edits stay in Superscribe unless synced"})]})]})})})]})});function ya(){const[s,t]=r.useState(""),[f,m]=r.useState(!1),[o,u]=r.useState(""),[p,j]=r.useState(""),[h,E]=r.useState(!0),[$,N]=r.useState(null),[_,y]=r.useState(!1),[M,k]=r.useState(new Set),[d,A]=r.useState(null),[L,S]=r.useState(!1),[b,n]=r.useState(!1),{data:oe,loading:de,refetch:x}=B(Pe),{data:ce}=B(Ee),{data:me}=B(Ie),[C]=H(Re,{onError:a=>
1{g({title:"Error",description:a.message,variant:"destructive"})}}),[Y]=H(_e),[O]=H($e,{onError:a=>{g({title:"Error",description:a.message,variant:"destructive"})}}),[ee]=H(ze,{onCompleted:()=>{g({title:"Contact deleted"}),x()},onError:a=>{g({title:"Error",description:a.message,variant:"destructive"})}}),D=oe?.contacts??[],G=ce?.projects??[],V=me?.crmTemplates??[],ue=s.trim().toLowerCase(),I=s?D.filter(a=>a.name?.toLowerCase().includes(ue)||a.phoneNumber.includes(s.trim())):D,pe=r.useCallback(a=>{k(l=>{const i=new Set(l);return i.has(a)?i.delete(a):i.add(a),i})},[]),he=r.useCallback(async(a,l)=>{const i=l==="auto"?"":l;await C({variables:{input:{...U(a,{languageCode:i||void 0})}}}),x();const w=X.find(v=>v.value===i)?.label??"Auto-detect";g({title:`Language set to ${w}`,description:a.name??a.phoneNumber})},[x,C]),xe=r.useCallback(async(a,l)=>{const i=l==="none"?void 0:l;await C({variables:{input:{...U(a,{defaultProjectId:i})}}}),x();const w=i?G.find(v=>v.id===i)?.name??"project":"none";g({title:"Default project updated",description:`${a.name??a.phoneNumber} â ${w}`})},[G,x,C]),ge=r.useCallback(async(a,l)=>{const i=l==="none"?void 0:l;await C({variables:{input:{...U(a,{defaultCrmTemplateId:i})}}}),x();const w=i?V.find(v=>v.id===i)?.name??"template":"none";g({title:"CRM template updated",description:`${a.name??a.phoneNumber} â ${w}`})},[V,x,C]),fe=r.useCallback(async a=>{const l=a.crmAutomationApproved!==!0,i={...a,__typename:"Contact",crmAutomationApproved:l,crmAutomationProvider:l?"pipedrive":null,updatedAt:new Date().toISOString()};await C({variables:{input:U(a,{crmAutomationApproved:l,crmAutomationProvider:l?"pipedrive":void 0})},optimisticResponse:{upsertContact:i}}),g({title:l?"Auto CRM enabled":"Auto CRM disabled",description:l?`${a.name??a.phoneNumber} can now auto-sync low-risk Pipedrive actions after calls.`:`${a.name??a.phoneNumber} will go to the CRM queue instead of auto-syncing.`})},[C]),ve=r.useCallback(a=>{A(a),S(!1)},[]),ae=r.useCallback(()=>{b||(A(null),S(!1))},[b]),Ne=r.useCallback(async()=>{if(!(!d||b)){n(!0);try{await ee({variables:{phoneNumber:d.phoneNumber}}),A(null),S(!1)}catch{}finally{n(!1)}}},[ee,b,d]),be=r.useCallback(async(a,l)=>{await O({variables:{input:{phoneNumber:a.phoneNumber,name:l}}}),x(),g({title:l?"Contact renamed":"Name cleared",description:l||a.phoneNumber})},[x,O]),je=r.useCallback(async a=>{const l=a.syncToDevice!==!0;await O({variables:{input:{phoneNumber:a.phoneNumber,syncToDevice:l}},optimisticResponse:{updateContact:{__typename:"Contact",id:a.id,phoneNumber:a.phoneNumber,name:a.name,source:a.source,syncToDevice:l,updatedAt:new Date().toISOString()}}}),g({title:l?"iPhone sync on":"iPhone sync off",description:l?`${a.name??a.phoneNumber} will sync to your iPhone contacts.`:`${a.name??a.phoneNumber} stays in Superscribe only.`})},[O]),ye=r.useCallback(async a=>{a.preventDefault();const l=o.trim(),i=l.replace(/\D/g,"");if(i.length<7){N("Enter a valid phone number");return}const w=i.slice(-7),v=D.find(F=>F.phoneNumber.replace(/\D/g,"").endsWith(w));if(v){N(`Already saved as ${v.name||v.phoneNumber}`),t(v.phoneNumber);return}y(!0),N(null);try{await Y({variables:{input:{phoneNumber:l,name:p.trim()||void 0,syncToDevice:h}}}),await x(),m(!1),u(""),j(""),E(!0),g({title:"Contact added",description:p.trim()||l})}catch(F){const se=F instanceof Error?F.message:"Could not add contact";se.includes("already exists")?(N("A contact with this number already exists"),t(w)):N(se)}finally{y(!1)}},[D,Y,p,o,h,x]);return e.jsxs("div",{className:"p-4 md:p-6 space-y-4 max-w-full overflow-x-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Contacts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Phone contacts, transcription language, default project routing, and CRM automation templates"})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[e.jsxs("div",{className:"relative flex-1 sm:min-w-64",children:[e.jsx(Fe,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(q,{placeholder:"Search...",value:s,onChange:a=>t(a.target.value),className:"pl-7 h-8 text-xs"})]}),!f&&e.jsxs(c,{variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>m(!0),children:[e.jsx(ne,{className:"mr-1.5 h-3.5 w-3.5"}),"Add contact"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[I.length," ",I.length===1?"contact":"contacts",s.trim()&&D.length!==I.length?` of ${D.length}`:""]}),s.trim()&&e.jsx(c,{variant:"ghost",size:"sm",className:"h-8 text-xs px-2 text-muted-foreground",onClick:()=>t(""),children:"Clear search"}),M.size>0&&e.jsx(c,{variant:"ghost",size:"sm",className:"h-8 text-xs px-2 text-muted-foreground",onClick:()=>k(new Set),children:"Collapse all"})]}),f&&e.jsxs(te,{children:[e.jsx(Me,{className:"pb-2",children:e.jsx(Le,{className:"text-sm",children:"New contact"})}),e.jsx(Oe,{className:"pb-4",children:e.jsxs("form",{onSubmit:ye,className:"flex flex-col gap-3 sm:flex-row sm:items-start",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(q,{placeholder:"+372 5123 456",value:o,onChange:a=>{u(a.target.value),N(null)}
1,className:"h-8 text-xs font-mono",autoFocus:!0}),$?e.jsx("p",{className:"text-[11px] text-destructive",children:$}):e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Include the country code so calls match this contact."})]}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx(q,{placeholder:"Name (optional)",value:p,onChange:a=>j(a.target.value),className:"h-8 text-xs"}),e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-1.5 text-[11px] text-muted-foreground",children:[e.jsx("input",{type:"checkbox",checked:h,onChange:a=>E(a.target.checked),className:"h-3.5 w-3.5 cursor-pointer accent-primary"}),"Sync to iPhone contacts"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(c,{type:"submit",size:"sm",className:"h-8 text-xs",disabled:_||!o.trim(),children:_?"Adding...":"Add"}),e.jsx(c,{type:"button",variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{m(!1),u(""),j(""),E(!0),N(null)},children:"Cancel"})]})]})})]}),e.jsx(te,{className:"overflow-hidden gap-0 py-0",children:de?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(ie,{className:"h-10 w-10 mx-auto mb-3 opacity-45"}),D.length===0?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"No contacts yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Add one below, or sync from the Superscribe Phone app."}),e.jsxs(c,{variant:"outline",size:"sm",className:"h-8 text-xs mt-3",onClick:()=>m(!0),children:[e.jsx(ne,{className:"mr-1.5 h-3.5 w-3.5"}),"Add contact"]})]}):e.jsxs("p",{className:"text-sm font-medium",children:['No contacts match "',s,'"']})]}):e.jsx("div",{className:"overflow-x-auto text-[13px]",children:e.jsxs("table",{className:"w-full table-fixed text-left border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/70 bg-muted/20",children:[e.jsx("th",{className:"h-9 w-9 py-2 pl-3 pr-0",children:e.jsx("span",{className:"sr-only",children:"Expand settings"})}),e.jsx("th",{className:"h-9 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Name"}),e.jsx("th",{className:"h-9 w-0 px-0 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground sm:w-40 sm:px-3",children:e.jsx("span",{className:"hidden sm:inline",children:"Phone"})}),e.jsx("th",{className:"h-9 w-0 px-0 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground sm:w-auto sm:px-3",children:e.jsx("span",{className:"hidden sm:inline",children:"Settings"})}),e.jsx("th",{className:"h-9 w-20 px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground text-right",children:"Actions"})]})}),e.jsx("tbody",{children:I.map(a=>e.jsx(ia,{contact:a,projects:G,crmTemplates:V,isExpanded:M.has(a.id),onToggleExpanded:pe,onLanguageChange:he,onDefaultProjectChange:xe,onCrmTemplateChange:ge,onToggleCrmAutomation:fe,onToggleSyncToDevice:je,onRename:be,onRequestDelete:ve},a.id))})]})})}),e.jsx(Ye,{open:d!==null,onOpenChange:a=>{a||ae()},children:e.jsx(sa,{children:d&&e.jsxs(e.Fragment,{children:[e.jsxs(ta,{children:[e.jsxs(la,{children:["Delete ",d.name||d.phoneNumber,"?"]}),e.jsxs(ra,{children:[d.name?`${d.phoneNumber} will be removed from your Superscribe contacts. `:"This number will be removed from your Superscribe contacts. ","Recordings and call history are kept."]})]}),d.syncToDevice?e.jsxs("div",{className:"rounded-lg border border-border/70 bg-muted/30 p-3",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-not-allowed",title:"Needs the next iPhone app release. Until then, delete it in the iPhone Contacts app yourself.",children:[e.jsx("input",{type:"checkbox",checked:L,disabled:!0,onChange:a=>S(a.target.checked),"aria-describedby":"delete-from-device-note",className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary cursor-not-allowed opacity-50"}),e.jsx("span",{className:"text-xs font-medium leading-tight text-muted-foreground",children:"Also delete from my iPhone contacts"})]}),e.jsxs("div",{id:"delete-from-device-note",className:"mt-1.5 space-y-1 pl-[
11.375rem]",children:[e.jsx("p",{className:"text-[11px] leading-tight text-muted-foreground",children:"Removes the entry from your iPhone address book the next time the iPhone app syncs. This cannot be undone."}),e.jsx("p",{className:"text-[11px] leading-tight text-muted-foreground/70",children:"Not available yet. It needs the next iPhone app release, so for now the entry stays in your address book and you can delete it there yourself."})]})]}):e.jsx("p",{className:"text-[11px] leading-tight text-muted-foreground",children:"This contact does not sync to your iPhone, so your iPhone contacts are not affected."}),e.jsxs(na,{children:[e.jsx(c,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:ae,disabled:b,children:"Cancel"}),e.jsx(c,{variant:"destructive",size:"sm",className:"h-8 text-xs",onClick:Ne,disabled:b,children:b?"Deleting...":"Delete contact"})]})]})})})]})}export{ya as Contacts};
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.