1import{n as A,e as O,d as K,r,s as b,j as e,a8 as ae,a9 as re,aa as ne,ab as le,b3 as oe,x as X,I as F,L as z,aJ as ie,B as k,ak as V,aI as U,ai as ee,F as te,G as de,bA as ce,C as Y,bB as me,T as xe,f as ue,P as Z,ax as he}from"./index-BQdhh5bh.js";import{T as pe}from"./trophy-CRbvnkJ8.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const se=A("Archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const fe=A("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ge=A("Frown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const je=A("Handshake",[["path",{d:"m11 17 2 2a1 1 0 1 0 3-3",key:"efffak"}],["path",{d:"m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4",key:"9pr0kb"}],["path",{d:"m21 3 1 11h-2",key:"1tisrp"}],["path",{d:"M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3",key:"1uvwmv"}],["path",{d:"M3 4h8",key:"1ep09j"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const ve=A("MessageSquareQuote",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M8 12a2 2 0 0 0 2-2V8H8",key:"1jfesj"}],["path",{d:"M14 12a2 2 0 0 0 2-2V8h-2",key:"1dq9mh"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const we=A("PanelRightClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const ye=A("PanelRightOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]]),Ne=({open:i,onOpenChange:n,onCreated:x})=>{const{t:a}=O(),{user:d}=K(),[h,R]=r.useState(1),[v,C]=r.useState([]),[w,D]=r.useState(!1),[P,S]=r.useState(""),[f,T]=r.useState(null),[g,j]=r.useState(""),[y,M]=r.useState(!1);r.useEffect(()=>{!i||!d||(R(1),S(""),T(null),j(""),(async()=>{D(!0);const{data:t}=await b.from("presentations").select("id, title, updated_at").eq("user_id",d.id).order("updated_at",{ascending:!1}).limit(100);C(t??[]),D(!1)})())},[i,d]);const c=r.useMemo(()=>{const t=P.trim().toLowerCase();return t?v.filter(l=>(l.title||"").toLowerCase().includes(t)):v},[v,P]),s=async()=>{if(!(!d||!f||!g.trim())){M(!0);try{const t=g.trim(),{data:l}=await b.from("sales_contacts").insert({user_id:d.id,name:t}).select("id").single(),{data:_,error:N}=await b.from("sales_conversations").insert({user_id:d.id,presentation_id:f.id,contact_id:(l==null?void 0:l.id)??null,title:`${t} â ${f.title||a("dealRoom.unnamedPresentation")}`,status:"active"}).select("id").single();if(N||!_)throw N;x(_.id),n(!1)}catch(t){U({title:a("common.error"),description:t==null?void 0:t.message,variant:"destructive"})}finally{M(!1)}}},m=t=>{const l=(t||"").replace(/\s+/g," ").trim();if(!l)return a("dealRoom.unnamedPresentation");const _=l.split(/[.!?\n]/)[0]||l;return _.length>60?_.slice(0,60).trimEnd()+"â¦":_},u=t=>{try{return new Date(t).toLocaleDateString(void 0,{day:"2-digit",month:"short",year:"numeric"})}catch{return""}};return e.jsx(ae,{open:i,onOpenChange:n,children:e.jsxs(re,{className:"max-w-lg w-[c
36alc(100vw-2rem)] sm:w-full overflow-hidden",children:[e.jsxs(ne,{children:[e.jsx(le,{children:a("dealRoom.newDeal")}),e.jsx(oe,{children:a(h===1?"dealRoom.newDealStep1":"dealRoom.newDealStep2")})]}),h===1&&e.jsxs("div",{className:"space-y-3 min-w-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(F,{value:P,onChange:t=>S(t.target.value),placeholder:a("dealRoom.searchPresentations"),className:"pl-9",autoFocus:!0})]}),e.jsx("div",{className:"max-h-72 overflow-y-auto rounded-lg border border-border divide-y divide-border",children:w?e.jsxs("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),a("common.loading")]}):c.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-muted-foreground px-4",children:v.length===0?a("dealRoom.noPresentationsYet"):a("dealRoom.noPresentationMatch")}):c.map(t=>e.jsxs("button",{onClick:()=>{T({...t,title:m(t.title)}),R(2)},className:"w-full text-left px-4 py-3 hover:bg-accent flex items-center gap-3 transition-colors min-w-0",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:m(t.title)}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-0.5",children:u(t.updated_at)})]}),e.jsx(ie,{className:"w-4 h-4 text-muted-foreground shrink-0"})]},t.id))})]}),h===2&&f&&e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-muted/30 px-3 py-2 min-w-0",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:a("dealRoom.selectedPresentation")}),e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:f.title||a("dealRoom.unnamedPresentation")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:a("dealRoom.fields.client")}),e.jsx(F,{value:g,onChange:t=>j(t.target.value),placeholder:a("dealRoom.placeholders.client"),autoFocus:!0,onKeyDown:t=>{t.key==="Enter"&&g.trim()&&s()}})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx(k,{variant:"ghost",onClick:()=>R(1),disabled:y,children:a("common.back","Indietro")}),e.jsxs(k,{onClick:s,disabled:!g.trim()||y,children:[y?e.jsx(z,{className:"w-4 h-4 mr-1.5 animate-spin"}):e.jsx(V,{className:"w-4 h-4 mr-1.5"}),a("dealRoom.createDeal")]})]})]})]})})},be=({conversationId:i,onActivity:n})=>{const{t:x,i18n:a}=O(),{user:d}=K(),[h,R]=r.useState([]),[v,C]=r.useState(""),[w,D]=r.useState(!1),[P,S]=r.useState(!0),[f,T]=r.useState(null),g=r.useRef(null),j=r.useCallback(async()=>{if(!d)return;S(!0);const{data:s}=await b.from("sales_messages").select("*").eq("conversation_id",i).order("created_at",{ascending:!0});R(s??[]),S(!1)},[i,d]);r.useEffect(()=>{j()},[j]),r.useEffect(()=>{var s;(s=g.current)==null||s.scrollTo({top:g.current.scrollHeight,behavior:"smooth"})},[h,w]);const y=async()=>{const s=v.trim();if(!s||w)return;C(""),D(!0);const m=`tmp-${Date.now()}`;R(u=>[...u,{id:m,role:"user",content:s,tool_calls:[],tool_results:[],created_at:new Date().toISOString()}]);try{const{data:u,error:t}=await b.functions.invoke("sales-agent",{body:{conversation_id:i,user_message:s,locale:a.language}}
36);if(t)throw t;await j(),n==null||n()}catch(u){U({title:x("common.error"),description:(u==null?void 0:u.message)||"Agent error",variant:"destructive"}),R(t=>t.filter(l=>l.id!==m)),C(s)}finally{D(!1)}},M=async(s,m)=>{try{await navigator.clipboard.writeText(s),T(m),setTimeout(()=>T(null),1500)}catch{}},c=(s,m,u)=>{if(!s)return null;const t=s.result||s,l=`${m}-tool-${u}`;return s.name==="share_presentation"&&(t!=null&&t.url)?e.jsxs("div",{className:"mt-3 rounded-xl border border-primary/30 bg-primary/5 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold uppercase tracking-wider text-primary mb-2",children:[e.jsx(ce,{className:"w-3.5 h-3.5"}),x("dealRoom.agent.shareLinkCreated")]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 text-xs bg-background rounded px-2 py-1.5 truncate border border-border",children:t.url}),e.jsx(k,{size:"sm",variant:"outline",onClick:()=>M(t.url,l),className:"shrink-0",children:f===l?e.jsx(V,{className:"w-3.5 h-3.5"}):e.jsx(Y,{className:"w-3.5 h-3.5"})})]})]},l):s.name==="draft_pitch_from_slides"&&(t!=null&&t.draft)?e.jsxs("div",{className:"mt-3 rounded-xl border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-2",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ve,{className:"w-3.5 h-3.5"}),x("dealRoom.agent.draftReady")," · ",t.channel]}),e.jsx(k,{size:"sm",variant:"ghost",onClick:()=>M(t.draft,l),className:"h-7 px-2",children:f===l?e.jsx(V,{className:"w-3.5 h-3.5"}):e.jsx(Y,{className:"w-3.5 h-3.5"})})]}),e.jsx("p",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:t.draft})]},l):t!=null&&t.error?e.jsx("div",{className:"mt-3 text-xs text-destructive bg-destructive/10 rounded-lg px-3 py-2",children:t.error},l):null};return e.jsxs("div",{className:"flex flex-col h-full bg-background",children:[e.jsxs("div",{ref:g,className:"flex-1 overflow-y-auto px-4 sm:px-6 py-6 space-y-4",children:[P?e.jsxs("div",{className:"flex items-center justify-center py-12 text-sm text-muted-foreground",children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),x("common.loading")]}):h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center max-w-md mx-auto",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-primary/10 flex items-center justify-center mb-3",children:e.jsx(ee,{className:"w-6 h-6 text-primary"})}),e.jsx("h3",{className:"text-sm font-semibold text-foreground mb-1",children:x("dealRoom.agent.welcomeTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:x("dealRoom.agent.welcomeBody")}),e.jsx("div",{className:"mt-4 grid grid-cols-1 gap-1.5 w-full",children:[x("dealRoom.agent.suggestion1"),x("dealRoom.agent.suggestion2"),x("dealRoom.agent.suggestion3")].map((s,m)=>e.jsx("button",{onClick:()=>C(s),className:"text-left text-xs text-foreground bg-muted/50 hover:bg-muted rounded-lg px-3 py-2 transition-colors",children:s},m))})]}):h.filter(s=>s.role==="user"||s.role==="assistant").map(s=>e.jsx("div",{className:`flex ${s.role==="user"?"justify-end":"justify-start"}`,children:e.jsxs("div",{className:`max-w-[85%] rounded-2xl px-4 py-2.5 ${s.role==="user"?"bg-primary text-primary-foreground":"bg-muted text-foreground"}`,children:[s.content&&e.jsx("p",{className:"text-sm whitespace-pre-wrap leading-relaxed break-words",children:s.content}),Array.isArray(s.tool_results)&&s.tool_results.map((m,u)=>c(m,s.id,u))]})},s.id)),w&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"bg-muted rounded-2xl px-4 py-2.5 flex items-center gap-2",children:[e.jsx(z,{className:"w-4 h-4 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:x("dealRoom.agent.thinking")})]})})]}),e.jsx("div",{className:"border-t border-border bg-background p-3 sm:p-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(te,{value:v,onCh
36ange:s=>C(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),y())},placeholder:x("dealRoom.agent.inputPlaceholder"),className:"resize-none pr-12 min-h-[60px] max-h-32",rows:2,disabled:w}),e.jsx(k,{size:"icon",onClick:y,disabled:!v.trim()||w,className:"absolute right-2 bottom-2 h-8 w-8",children:e.jsx(de,{className:"w-4 h-4"})})]})})]})},W=({conversation:i,onUpdated:n,onDeleted:x})=>{const{t:a}=O(),[d,h]=r.useState(null),[R,v]=r.useState(""),[C,w]=r.useState(null),[D,P]=r.useState(0),[S,f]=r.useState(!0),[T,g]=r.useState(!1);r.useEffect(()=>{(async()=>{var c,s;if(f(!0),i.contact_id){const{data:m}=await b.from("sales_contacts").select("*").eq("id",i.contact_id).maybeSingle();m&&h(m)}if(i.presentation_id){const{data:m}=await b.from("presentations").select("title, messages").eq("id",i.presentation_id).maybeSingle();if(m){v(m.title||"");const u=m.messages||[];for(let t=u.length-1;t>=0;t--){const l=u[t];if(l.role==="assistant"&&Array.isArray(l.slides)&&l.slides.length){P(l.slides.length),w(((c=l.slides[0])==null?void 0:c.imageUrl)||((s=l.slides[0])==null?void 0:s.image_url)||null);break}}}}f(!1)})()},[i.id,i.contact_id,i.presentation_id]);const j=async c=>{d&&(h({...d,...c}),g(!0),await b.from("sales_contacts").update(c).eq("id",d.id),g(!1))},y=async c=>{await b.from("sales_conversations").update({status:c}).eq("id",i.id),n(),U({title:a(`dealRoom.statusUpdated.${c}`)})},M=async()=>{confirm(a("dealRoom.deleteConfirm"))&&(await b.from("sales_conversations").delete().eq("id",i.id),x())};return S?e.jsxs("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),a("common.loading")]}):e.jsxs("div",{className:"h-full overflow-y-auto p-4 sm:p-5 space-y-5",children:[i.presentation_id&&e.jsxs("div",{className:"rounded-xl border border-border bg-muted/20 overflow-hidden",children:[C?e.jsx("div",{className:"aspect-video bg-muted relative",children:e.jsx("img",{src:C,alt:R,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"aspect-video bg-muted flex items-center justify-center",children:e.jsx(fe,{className:"w-8 h-8 text-muted-foreground"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:a("dealRoom.context.presentation")}),e.jsx("p",{className:"text-sm font-semibold text-foreground line-clamp-2",children:R||a("dealRoom.unnamedPresentation")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a("dealRoom.context.slideCount",{count:D})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground",children:a("dealRoom.context.client")})]}),d&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(F,{value:d.name,onChange:c=>j({name:c.target.value}),placeholder:a("dealRoom.placeholders.client")}),e.jsx(F,{value:d.phone||"",onChange:c=>j({phone:c.target.value}),placeholder:a("dealRoom.placeholders.phone"),type:"tel"}),e.jsx(F,{value:d.email||"",onChange:c=>j({email:c.target.value}),placeholder:a("dealRoom.placeholders.email"),type:"email"}),e.jsx(te,{value:d.notes,onChange:c=>j({notes:c.target.value}),placeholder:a("dealRoom.placeholders.notes"),rows:3,className:"resize-none"}),T&&e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1",children:[e.jsx(z,{className:"w-3 h-3 animate-spin"})," ",a("common.saving","Salvataggio...")]})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t border-border",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground",children:a("dealRoom.context.dealStatus")}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5",children:[e.jsxs(k,{variant:i.status==="won"?"default":"outline",size:"sm",onClick:()=>y("won"),className:"text-xs",children:[e.jsx(pe,{className:"w-3 h-3 mr-1"}),a("dealRoom.statusShort.won")]}),e.jsxs(k,{variant:i.status==="lost"?"destructive":"outline",size:"sm",onClick:()=>y("lost"),className:"text-xs",children:[e.jsx(ge,{className:"w-3 h-3 mr-1"}),a("dealRoom.statusShort.lost")]}),e.jsxs(k,{variant:i.status==="archived"?"secondary":"outline",size:"sm",onClick:()=>y("archived"),className:"text-xs",children:[e.jsx(se,{className:"w-3 h-3 mr-1"}),a("dealRoom.statusShort.archived")]})]}),i.status!=="active"&&e.jsx(k,{variant:"ghost",size:"sm",onClick:()=>y("active"),className:"w-full text-xs",children:a("dealRoom.context.reopen")})]}),e.jsx("div",{className:"pt-2 border-t border-border",children:e.jsxs(k,{variant:"ghost",size:"sm",onClick:M,className:"w-full text-xs text-destructive hover:text-destructive",children:[e.jsx(xe,{className:"w-3 h-3 mr-1.5"}),a("dealRoom.context.delete")]})})]})};function ke(i,n){const x=Date.now()-new Date(i).getTime(),a=864e5;if(x<a)return new Date(i).toLocaleTimeString(n,{hour:"2-digit",minute:"2-digit"});const d=Math.floor(x/a);return d===1?n==="en"?"yesterday":n==="es"?"ayer":n==="fr"?"hier":"ieri":d<7?`${d}${n==="en"?"d":"g"}`:new Date(i).toLocaleDateString(n,{day:"numeric",month:"short"})}const Se=({onBack:i})=>{var G;const{t:n,i18n:x}=O(),{user:a}=K(),d=x.language==="en"?"en-US":x.language==="es"?"es-ES":x.language==="fr"?"fr-FR":"it-IT",[h,R]=r.useState([]),[v,C]=r.useState({}),[w,D]=r.useState({}),[P,S]=r.useState(!0),[f,T]=r.useState(""),[g,j]=r.useState(null),[y,M]=r.useState(!1),[c,s]=r.useState(!1),[m,u]=r.useState(!0),t=r.useCallback(async()=>
36{if(!a)return;S(!0);const{data:o,error:I}=await b.from("sales_conversations").select("*").eq("user_id",a.id).order("last_activity_at",{ascending:!1});if(I){U({title:n("common.error"),description:ue(I),variant:"destructive"}),S(!1);return}const p=o??[];R(p);const q=Array.from(new Set(p.map(L=>L.contact_id).filter(Boolean))),$=Array.from(new Set(p.map(L=>L.presentation_id).filter(Boolean))),[{data:B},{data:H}]=await Promise.all([q.length?b.from("sales_contacts").select("id, name").in("id",q):Promise.resolve({data:[]}),$.length?b.from("presentations").select("id, title").in("id",$):Promise.resolve({data:[]})]),E={};for(const L of B??[])E[L.id]=L;C(E);const J={};for(const L of H??[])J[L.id]=L.title||"";D(J),S(!1)},[a,n]);r.useEffect(()=>{t()},[t]);const{active:l,archived:_}=r.useMemo(()=>{const o=f.trim().toLowerCase(),I=p=>{var B,H,E;if(!o)return!0;const q=p.contact_id?((H=(B=v[p.contact_id])==null?void 0:B.name)==null?void 0:H.toLowerCase())??"":"",$=p.presentation_id?((E=w[p.presentation_id])==null?void 0:E.toLowerCase())??"":"";return p.title.toLowerCase().includes(o)||q.includes(o)||$.includes(o)};return{active:h.filter(p=>p.status==="active"&&I(p)),archived:h.filter(p=>p.status!=="active"&&I(p))}},[h,v,w,f]),N=g?h.find(o=>o.id===g)??null:null,Q=o=>{var q;const I=o.contact_id?(q=v[o.contact_id])==null?void 0:q.name:"",p=o.presentation_id?w[o.presentation_id]:"";return e.jsxs("button",{onClick:()=>j(o.id),className:`w-full text-left px-3 py-2.5 rounded-lg transition-colors ${g===o.id?"bg-accent":"hover:bg-accent/50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-0.5",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate flex-1",children:I||o.title||n("dealRoom.unnamedClient")}),e.jsx("span",{className:"text-[10px] text-muted-foreground tabular-nums shrink-0",children:ke(o.last_activity_at,d)})]}),p&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:p})]},o.id)};return e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col h-full",children:[e.jsx("div",{className:"px-4 sm:px-6 pt-6 shrink-0",children:e.jsxs("div",{className:"max-w-[66rem] mx-auto relative overflow-hidden rounded-2xl bg-gradient-to-br from-primary/15 via-primary/5 to-transparent border border-foreground
36/80 px-6 py-8 sm:py-10",children:[e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,hsl(var(--primary)/0.12),transparent_70%)]"}),e.jsxs("div",{className:"relative flex items-center gap-4",children:[e.jsx("div",{className:"flex items-center justify-center w-12 h-12 rounded-xl bg-primary/15 text-primary shrink-0",children:e.jsx(je,{className:"w-6 h-6"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-foreground tracking-tight truncate",children:n("dealRoom.title")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:n("dealRoom.bannerSubtitle")})]})]})]})}),e.jsx("div",{className:"flex-1 overflow-hidden p-4 sm:p-6 pt-4",children:e.jsxs("div",{className:"max-w-[88rem] mx-auto h-full grid gap-4 grid-cols-1 lg:grid-cols-[280px_minmax(0,1fr)] xl:grid-cols-[280px_minmax(0,1fr)_320px]",children:[e.jsxs("div",{className:"flex flex-col rounded-2xl border border-border bg-card overflow-hidden min-h-0",children:[e.jsxs("div",{className:"p-3 border-b border-border space-y-2 shrink-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx(F,{value:f,onChange:o=>T(o.target.value),placeholder:n("dealRoom.searchClient"),className:"pl-8 h-9 text-sm"})]}),e.jsxs(k,{size:"sm",onClick:()=>s(!0),className:"w-full",children:[e.jsx(Z,{className:"w-4 h-4 mr-1.5"}),n("dealRoom.newDeal")]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:P?e.jsxs("div",{className:"flex items-center justify-center py-8 text-xs text-muted-foreground",children:[e.jsx(z,{className:"w-4 h-4 mr-2 animate-spin"}),n("common.loading")]}):h.length===0?e.jsx("div",{className:"px-3 py-8 text-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:n("dealRoom.emptyState")})}):e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"px-2 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground font-semibold",children:[n("dealRoom.activeDeals")," · ",l.length]}),e.jsx("div",{className:"space-y-0.5",children:l.map(Q)})]}),_.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsxs("button",{onClick:()=>M(o=>!o),className:"w-full px-2 py-1.5 flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground font-semibold hover:text-foreground transition-colors",children:[e.jsx(he,{className:`w-3 h-3 transition-transform ${y?"":"-rotate-90"}`}),e.jsx(se,{className:"w-3 h-3"}),n("dealRoom.archivedDeals")," · ",_.length]}),y&&e.jsx("div",{className:"space-y-0.5 mt-1",children:_.map(Q)})]}),l.length===0&&_.length===0&&f&&e.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:n("dealRoom.noSearchResults")})]})})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card overflow-hidden min-h-0 flex flex-col",children:N?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between gap-2 shrink-0",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:N.contact_id?(G=v[N.contact_id])==null?void 0:G.name:N.title}),N.presentation_id&&w[N.presentation_id]&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:w[N.presentation_id]})]}),e.jsx(k,{variant:"ghost",size:"icon",onClick:()=>u(o=>!o),className:"xl:hidden h-8 w-8 shrink-0",children:m?e.jsx(we,{className:"w-4 h-4"}):e.jsx(ye,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(be,{conversationId:N.id,onActivity:t})})]}):e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-primary/10 flex items-center justify-center mb-4",children:e.jsx(ee,{className:"w-8 h-8 text-primary"})}),e.jsx("h2",{className:"text-lg font-semibold text-foreground mb-2",children:h.length===0?n("dealRoom.openFirstDeal"):n("dealRoom.selectDeal")}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-sm mb-4",children:n("dealRoom.emptyChatBody")}),h.length===0&&e.jsxs(k,{onClick:()=>s(!0),children:[e.jsx(Z,{className:"w-4 h-4 mr-1.5"}),n("dealRoom.newDeal")]})]})}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden xl:block rounded-2xl border border-border bg-card overflow-hidden min-h-0",children:e.jsx(W,{conversation:N,onUpdated:t,onDeleted:()=>{j(null),t()}})}),m&&e.jsx("div",{className:"xl:hidden fixed inset-0 z-50 bg-background/80 backdrop-blur-sm",onClick:()=>u(!1),children:e.jsx("div",{className:"absolute right-0 top-0 bottom-0 w-full max-w-sm bg-card border-l border-border shadow-2xl",onClick:o=>o.stopPropagation(),children:e.jsx(W,{conversation:N,onUpdated:t,onDeleted:()=>{j(null),u(!1),t()}})})})]})]})}),e.jsx(Ne,{open:c,onOpenChange:s,onCreated:o=>{j(o),t()}})]})};export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.